Chromium Code Reviews

Side by Side Diff: gpu/command_buffer/service/mailbox_manager_sync.cc

Issue 952893003: Update from https://crrev.com/317530 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fix gn for nacl Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/mailbox_manager_sync.h" 5 #include "gpu/command_buffer/service/mailbox_manager_sync.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <queue> 8 #include <queue>
9 9
10 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
11 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
12 #include "gpu/command_buffer/service/texture_manager.h" 12 #include "gpu/command_buffer/service/texture_manager.h"
13 #include "ui/gl/gl_fence.h" 13 #include "ui/gl/gl_fence.h"
14 #include "ui/gl/gl_implementation.h" 14 #include "ui/gl/gl_implementation.h"
15 15
16 #if !defined(OS_MACOSX) 16 #if !defined(OS_MACOSX)
17 #include "ui/gl/gl_fence_egl.h" 17 #include "ui/gl/gl_fence_egl.h"
18 #endif 18 #endif
19 19
20 namespace gpu { 20 namespace gpu {
21 namespace gles2 { 21 namespace gles2 {
22 22
23 namespace { 23 namespace {
24 24
25 bool SkipTextureWorkarounds(const Texture* texture) {
26 // TODO(sievers): crbug.com/352274
27 // Should probably only fail if it already *has* mipmaps, while allowing
28 // incomplete textures here.
29 bool needs_mips =
30 texture->min_filter() != GL_NEAREST && texture->min_filter() != GL_LINEAR;
31 if (texture->target() != GL_TEXTURE_2D || needs_mips || !texture->IsDefined())
32 return true;
33
34 return false;
35 }
36
37 base::LazyInstance<base::Lock> g_lock = LAZY_INSTANCE_INITIALIZER; 25 base::LazyInstance<base::Lock> g_lock = LAZY_INSTANCE_INITIALIZER;
38 26
39 typedef std::map<uint32, linked_ptr<gfx::GLFence>> SyncPointToFenceMap; 27 typedef std::map<uint32, linked_ptr<gfx::GLFence>> SyncPointToFenceMap;
40 base::LazyInstance<SyncPointToFenceMap> g_sync_point_to_fence = 28 base::LazyInstance<SyncPointToFenceMap> g_sync_point_to_fence =
41 LAZY_INSTANCE_INITIALIZER; 29 LAZY_INSTANCE_INITIALIZER;
42 #if !defined(OS_MACOSX) 30 #if !defined(OS_MACOSX)
43 base::LazyInstance<std::queue<SyncPointToFenceMap::iterator>> g_sync_points = 31 base::LazyInstance<std::queue<SyncPointToFenceMap::iterator>> g_sync_points =
44 LAZY_INSTANCE_INITIALIZER; 32 LAZY_INSTANCE_INITIALIZER;
45 #endif 33 #endif
46 34
(...skipping 142 matching lines...)
189 MailboxManagerSync::TextureGroupRef::~TextureGroupRef() { 177 MailboxManagerSync::TextureGroupRef::~TextureGroupRef() {
190 } 178 }
191 179
192 MailboxManagerSync::MailboxManagerSync() { 180 MailboxManagerSync::MailboxManagerSync() {
193 } 181 }
194 182
195 MailboxManagerSync::~MailboxManagerSync() { 183 MailboxManagerSync::~MailboxManagerSync() {
196 DCHECK_EQ(0U, texture_to_group_.size()); 184 DCHECK_EQ(0U, texture_to_group_.size());
197 } 185 }
198 186
187 // static
188 bool MailboxManagerSync::SkipTextureWorkarounds(const Texture* texture) {
189 // Cannot support mips due to support mismatch between
190 // EGL_KHR_gl_texture_2D_image and glEGLImageTargetTexture2DOES for
191 // texture levels.
192 bool has_mips = texture->NeedsMips() && texture->texture_complete();
193 return texture->target() != GL_TEXTURE_2D || has_mips;
194 }
195
199 bool MailboxManagerSync::UsesSync() { 196 bool MailboxManagerSync::UsesSync() {
200 return true; 197 return true;
201 } 198 }
202 199
203 Texture* MailboxManagerSync::ConsumeTexture(const Mailbox& mailbox) { 200 Texture* MailboxManagerSync::ConsumeTexture(const Mailbox& mailbox) {
204 base::AutoLock lock(g_lock.Get()); 201 base::AutoLock lock(g_lock.Get());
205 TextureGroup* group = TextureGroup::FromName(mailbox); 202 TextureGroup* group = TextureGroup::FromName(mailbox);
206 if (!group) 203 if (!group)
207 return NULL; 204 return NULL;
208 205
(...skipping 78 matching lines...)
287 284
288 // Make sure we don't clobber with an older version 285 // Make sure we don't clobber with an older version
289 if (!definition.IsOlderThan(group_ref->version)) 286 if (!definition.IsOlderThan(group_ref->version))
290 return; 287 return;
291 288
292 // Also don't push redundant updates. Note that it would break the 289 // Also don't push redundant updates. Note that it would break the
293 // versioning. 290 // versioning.
294 if (definition.Matches(texture)) 291 if (definition.Matches(texture))
295 return; 292 return;
296 293
294 DCHECK_IMPLIES(gl_image, image_buffer.get());
297 if (gl_image && !image_buffer->IsClient(gl_image)) { 295 if (gl_image && !image_buffer->IsClient(gl_image)) {
298 LOG(ERROR) << "MailboxSync: Incompatible attachment"; 296 LOG(ERROR) << "MailboxSync: Incompatible attachment";
299 return; 297 return;
300 } 298 }
301 299
302 group->SetDefinition(TextureDefinition(texture, ++group_ref->version, 300 group->SetDefinition(TextureDefinition(texture, ++group_ref->version,
303 gl_image ? image_buffer : NULL)); 301 gl_image ? image_buffer : NULL));
304 } 302 }
305 303
306 void MailboxManagerSync::PushTextureUpdates(uint32 sync_point) { 304 void MailboxManagerSync::PushTextureUpdates(uint32 sync_point) {
(...skipping 18 matching lines...)
325 if (texture_version == definition.version() || 323 if (texture_version == definition.version() ||
326 definition.IsOlderThan(texture_version)) 324 definition.IsOlderThan(texture_version))
327 continue; 325 continue;
328 texture_version = definition.version(); 326 texture_version = definition.version();
329 definition.UpdateTexture(texture); 327 definition.UpdateTexture(texture);
330 } 328 }
331 } 329 }
332 330
333 } // namespace gles2 331 } // namespace gles2
334 } // namespace gpu 332 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/mailbox_manager_sync.h ('k') | gpu/command_buffer/service/mailbox_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine