Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/async_pixel_transfer_manager.h" | 5 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | |
| 7 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 8 #include "base/sys_info.h" | 9 #include "base/sys_info.h" |
| 9 #include "gpu/command_buffer/service/async_pixel_transfer_manager_egl.h" | 10 #include "gpu/command_buffer/service/async_pixel_transfer_manager_egl.h" |
| 10 #include "gpu/command_buffer/service/async_pixel_transfer_manager_idle.h" | 11 #include "gpu/command_buffer/service/async_pixel_transfer_manager_idle.h" |
| 11 #include "gpu/command_buffer/service/async_pixel_transfer_manager_stub.h" | 12 #include "gpu/command_buffer/service/async_pixel_transfer_manager_stub.h" |
| 12 #include "gpu/command_buffer/service/async_pixel_transfer_manager_sync.h" | 13 #include "gpu/command_buffer/service/async_pixel_transfer_manager_sync.h" |
| 14 #include "gpu/command_buffer/service/gpu_switches.h" | |
| 13 #include "ui/gl/gl_context.h" | 15 #include "ui/gl/gl_context.h" |
| 14 #include "ui/gl/gl_implementation.h" | 16 #include "ui/gl/gl_implementation.h" |
| 15 | 17 |
| 16 namespace gpu { | 18 namespace gpu { |
| 17 namespace { | 19 namespace { |
| 18 | 20 |
| 19 enum GpuType { | 21 enum GpuType { |
| 20 GPU_BROADCOM, | 22 GPU_BROADCOM, |
| 21 GPU_IMAGINATION, | 23 GPU_IMAGINATION, |
| 22 GPU_NVIDIA_ES31, | 24 GPU_NVIDIA_ES31, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 | 56 |
| 55 return GPU_OTHER; | 57 return GPU_OTHER; |
| 56 } | 58 } |
| 57 | 59 |
| 58 bool AllowTransferThreadForGpu() { | 60 bool AllowTransferThreadForGpu() { |
| 59 GpuType gpu = GetGpuType(); | 61 GpuType gpu = GetGpuType(); |
| 60 return gpu != GPU_BROADCOM && gpu != GPU_IMAGINATION && | 62 return gpu != GPU_BROADCOM && gpu != GPU_IMAGINATION && |
| 61 gpu != GPU_NVIDIA_ES31 && gpu != GPU_ADRENO_420; | 63 gpu != GPU_NVIDIA_ES31 && gpu != GPU_ADRENO_420; |
| 62 } | 64 } |
| 63 | 65 |
| 66 bool TransferWithThreadedTextureMailboxes() { | |
| 67 base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); | |
| 68 // AsyncPixelTransferManagerEGL is not compatible with threaded texture | |
| 69 // mailbox sharing due to EGLImage limitations. | |
| 70 return cl->HasSwitch(switches::kEnableThreadedTextureMailboxes) && | |
| 71 cl->HasSwitch(switches::kEnableAsyncPixelWithThreadedTextureMailboxes); | |
|
no sievers
2015/01/15 20:26:05
Do we really need the other command line (kEnableA
boliu
2015/01/21 02:08:01
I wanted the new one as a fallback in case anythin
| |
| 72 } | |
| 73 | |
| 64 } | 74 } |
| 65 | 75 |
| 66 // We only used threaded uploads when we can: | 76 // We only used threaded uploads when we can: |
| 67 // - Create EGLImages out of OpenGL textures (EGL_KHR_gl_texture_2D_image) | 77 // - Create EGLImages out of OpenGL textures (EGL_KHR_gl_texture_2D_image) |
| 68 // - Bind EGLImages to OpenGL textures (GL_OES_EGL_image) | 78 // - Bind EGLImages to OpenGL textures (GL_OES_EGL_image) |
| 69 // - Use fences (to test for upload completion). | 79 // - Use fences (to test for upload completion). |
| 70 // - The heap size is large enough. | 80 // - The heap size is large enough. |
| 71 // TODO(kaanb|epenner): Remove the IsImagination() check pending the | 81 // TODO(kaanb|epenner): Remove the IsImagination() check pending the |
| 72 // resolution of crbug.com/249147 | 82 // resolution of crbug.com/249147 |
| 73 // TODO(kaanb|epenner): Remove the IsLowEndDevice() check pending the | 83 // TODO(kaanb|epenner): Remove the IsLowEndDevice() check pending the |
| 74 // resolution of crbug.com/271929 | 84 // resolution of crbug.com/271929 |
| 75 AsyncPixelTransferManager* AsyncPixelTransferManager::Create( | 85 AsyncPixelTransferManager* AsyncPixelTransferManager::Create( |
| 76 gfx::GLContext* context) { | 86 gfx::GLContext* context) { |
| 77 DCHECK(context->IsCurrent(NULL)); | 87 DCHECK(context->IsCurrent(NULL)); |
| 88 bool threaded_texture_mailboxes = TransferWithThreadedTextureMailboxes(); | |
|
epenner
2015/01/15 00:28:23
Nit.
Mildly prefer reversing the bool to be "use_
boliu
2015/01/21 02:08:01
Done.
| |
| 78 switch (gfx::GetGLImplementation()) { | 89 switch (gfx::GetGLImplementation()) { |
| 79 case gfx::kGLImplementationEGLGLES2: | 90 case gfx::kGLImplementationEGLGLES2: |
| 80 DCHECK(context); | 91 DCHECK(context); |
| 81 if (!base::SysInfo::IsLowEndDevice() && | 92 if (!base::SysInfo::IsLowEndDevice() && |
| 82 context->HasExtension("EGL_KHR_fence_sync") && | 93 context->HasExtension("EGL_KHR_fence_sync") && |
| 83 context->HasExtension("EGL_KHR_image") && | 94 context->HasExtension("EGL_KHR_image") && |
| 84 context->HasExtension("EGL_KHR_image_base") && | 95 context->HasExtension("EGL_KHR_image_base") && |
| 85 context->HasExtension("EGL_KHR_gl_texture_2D_image") && | 96 context->HasExtension("EGL_KHR_gl_texture_2D_image") && |
| 86 context->HasExtension("GL_OES_EGL_image") && | 97 context->HasExtension("GL_OES_EGL_image") && |
| 98 !threaded_texture_mailboxes && | |
| 87 AllowTransferThreadForGpu()) { | 99 AllowTransferThreadForGpu()) { |
| 88 TRACE_EVENT0("gpu", "AsyncPixelTransferManager_CreateWithThread"); | 100 TRACE_EVENT0("gpu", "AsyncPixelTransferManager_CreateWithThread"); |
| 89 return new AsyncPixelTransferManagerEGL; | 101 return new AsyncPixelTransferManagerEGL; |
| 90 } | 102 } |
|
no sievers
2015/01/15 20:26:05
Can you put a comment that we do this because of h
boliu
2015/01/21 02:08:01
Done.
| |
| 91 return new AsyncPixelTransferManagerIdle; | 103 return new AsyncPixelTransferManagerIdle(threaded_texture_mailboxes); |
| 92 case gfx::kGLImplementationOSMesaGL: { | 104 case gfx::kGLImplementationOSMesaGL: { |
| 93 TRACE_EVENT0("gpu", "AsyncPixelTransferManager_CreateIdle"); | 105 TRACE_EVENT0("gpu", "AsyncPixelTransferManager_CreateIdle"); |
| 94 return new AsyncPixelTransferManagerIdle; | 106 return new AsyncPixelTransferManagerIdle(false); |
| 95 } | 107 } |
| 96 case gfx::kGLImplementationMockGL: | 108 case gfx::kGLImplementationMockGL: |
| 97 return new AsyncPixelTransferManagerStub; | 109 return new AsyncPixelTransferManagerStub; |
| 98 default: | 110 default: |
| 99 NOTREACHED(); | 111 NOTREACHED(); |
| 100 return NULL; | 112 return NULL; |
| 101 } | 113 } |
| 102 } | 114 } |
| 103 | 115 |
| 104 } // namespace gpu | 116 } // namespace gpu |
| OLD | NEW |