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/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/sys_info.h" | 8 #include "base/sys_info.h" |
| 9 #include "gpu/command_buffer/service/async_pixel_transfer_manager_egl.h" | 9 #include "gpu/command_buffer/service/async_pixel_transfer_manager_egl.h" |
| 10 #include "gpu/command_buffer/service/async_pixel_transfer_manager_idle.h" | 10 #include "gpu/command_buffer/service/async_pixel_transfer_manager_idle.h" |
| 11 #include "gpu/command_buffer/service/async_pixel_transfer_manager_stub.h" | 11 #include "gpu/command_buffer/service/async_pixel_transfer_manager_stub.h" |
| 12 #include "gpu/command_buffer/service/async_pixel_transfer_manager_sync.h" | 12 #include "gpu/command_buffer/service/async_pixel_transfer_manager_sync.h" |
| 13 #include "ui/gl/gl_context.h" | 13 #include "ui/gl/gl_context.h" |
| 14 #include "ui/gl/gl_implementation.h" | 14 #include "ui/gl/gl_implementation.h" |
| 15 | 15 |
| 16 namespace gpu { | 16 namespace gpu { |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 bool IsBroadcom() { | 19 enum GpuType { |
| 20 const char* vendor = reinterpret_cast<const char*>(glGetString(GL_VENDOR)); | 20 GPU_BROADCOM, |
| 21 if (vendor) | 21 GPU_IMAGINATION, |
| 22 return std::string(vendor).find("Broadcom") != std::string::npos; | 22 GPU_NVIDIA_ES31, |
| 23 return false; | 23 GPU_ADRENO_420, |
| 24 } | 24 GPU_OTHER, |
| 25 }; | |
| 25 | 26 |
| 26 bool IsImagination() { | 27 GpuType GetGpuType() { |
| 27 const char* vendor = reinterpret_cast<const char*>(glGetString(GL_VENDOR)); | 28 const std::string vendor( |
| 28 if (vendor) | 29 reinterpret_cast<const char*>(glGetString(GL_VENDOR))); |
| 29 return std::string(vendor).find("Imagination") != std::string::npos; | 30 const std::string renderer( |
| 30 return false; | 31 reinterpret_cast<const char*>(glGetString(GL_RENDERER))); |
| 31 } | 32 const std::string version( |
| 33 reinterpret_cast<const char*>(glGetString(GL_VERSION))); | |
| 32 | 34 |
| 33 bool IsNvidia31() { | 35 if (vendor.find("Broadcom") != std::string::npos) |
| 34 const char* vendor = reinterpret_cast<const char*>(glGetString(GL_VENDOR)); | 36 return GPU_BROADCOM; |
| 35 const char* version = reinterpret_cast<const char*>(glGetString(GL_VERSION)); | 37 |
| 36 return vendor && version && | 38 if (vendor.find("Imagination") != std::string::npos) |
| 37 std::string(vendor).find("NVIDIA") != std::string::npos && | 39 return GPU_IMAGINATION; |
| 38 std::string(version).find("OpenGL ES 3.1") != std::string::npos; | 40 |
| 41 if (vendor.find("NVIDIA") != std::string::npos && | |
| 42 version.find("OpenGL ES 3.1") != std::string::npos) { | |
| 43 return GPU_NVIDIA_ES31; | |
| 44 } | |
| 45 | |
| 46 if (vendor.find("Qualcomm") != std::string::npos && | |
| 47 renderer.find("Adreno (TM) 420") != std::string::npos) { | |
| 48 return GPU_ADRENO_420; | |
| 49 } | |
| 50 | |
| 51 return GPU_OTHER; | |
| 39 } | 52 } |
| 40 | 53 |
| 41 } | 54 } |
| 42 | 55 |
| 43 // We only used threaded uploads when we can: | 56 // We only used threaded uploads when we can: |
| 44 // - Create EGLImages out of OpenGL textures (EGL_KHR_gl_texture_2D_image) | 57 // - Create EGLImages out of OpenGL textures (EGL_KHR_gl_texture_2D_image) |
| 45 // - Bind EGLImages to OpenGL textures (GL_OES_EGL_image) | 58 // - Bind EGLImages to OpenGL textures (GL_OES_EGL_image) |
| 46 // - Use fences (to test for upload completion). | 59 // - Use fences (to test for upload completion). |
| 47 // - The heap size is large enough. | 60 // - The heap size is large enough. |
| 48 // TODO(kaanb|epenner): Remove the IsImagination() check pending the | 61 // TODO(kaanb|epenner): Remove the IsImagination() check pending the |
| 49 // resolution of crbug.com/249147 | 62 // resolution of crbug.com/249147 |
| 50 // TODO(kaanb|epenner): Remove the IsLowEndDevice() check pending the | 63 // TODO(kaanb|epenner): Remove the IsLowEndDevice() check pending the |
| 51 // resolution of crbug.com/271929 | 64 // resolution of crbug.com/271929 |
| 52 AsyncPixelTransferManager* AsyncPixelTransferManager::Create( | 65 AsyncPixelTransferManager* AsyncPixelTransferManager::Create( |
| 53 gfx::GLContext* context) { | 66 gfx::GLContext* context) { |
| 54 TRACE_EVENT0("gpu", "AsyncPixelTransferManager::Create"); | 67 DCHECK(context->IsCurrent(NULL)); |
| 68 GpuType gpu = GetGpuType(); | |
|
epennerAtGoogle
2014/09/16 00:07:15
This will likely fail some unit tests. They are ve
| |
| 69 TRACE_EVENT1("gpu", "AsyncPixelTransferManager::Create", "type", gpu); | |
| 55 switch (gfx::GetGLImplementation()) { | 70 switch (gfx::GetGLImplementation()) { |
| 56 case gfx::kGLImplementationEGLGLES2: | 71 case gfx::kGLImplementationEGLGLES2: |
| 57 DCHECK(context); | 72 DCHECK(context); |
| 58 if (context->HasExtension("EGL_KHR_fence_sync") && | 73 if (!base::SysInfo::IsLowEndDevice() && |
| 74 context->HasExtension("EGL_KHR_fence_sync") && | |
| 59 context->HasExtension("EGL_KHR_image") && | 75 context->HasExtension("EGL_KHR_image") && |
| 60 context->HasExtension("EGL_KHR_image_base") && | 76 context->HasExtension("EGL_KHR_image_base") && |
| 61 context->HasExtension("EGL_KHR_gl_texture_2D_image") && | 77 context->HasExtension("EGL_KHR_gl_texture_2D_image") && |
| 62 context->HasExtension("GL_OES_EGL_image") && | 78 context->HasExtension("GL_OES_EGL_image") && |
| 63 !IsBroadcom() && | 79 gpu != GPU_BROADCOM && |
| 64 !IsImagination() && | 80 gpu != GPU_IMAGINATION && |
| 65 !IsNvidia31() && | 81 gpu != GPU_NVIDIA_ES31 && |
| 66 !base::SysInfo::IsLowEndDevice()) { | 82 gpu != GPU_ADRENO_420) { |
| 67 return new AsyncPixelTransferManagerEGL; | 83 return new AsyncPixelTransferManagerEGL; |
| 68 } | 84 } |
| 69 return new AsyncPixelTransferManagerIdle; | 85 return new AsyncPixelTransferManagerIdle; |
| 70 case gfx::kGLImplementationOSMesaGL: | 86 case gfx::kGLImplementationOSMesaGL: |
| 71 return new AsyncPixelTransferManagerIdle; | 87 return new AsyncPixelTransferManagerIdle; |
| 72 case gfx::kGLImplementationMockGL: | 88 case gfx::kGLImplementationMockGL: |
| 73 return new AsyncPixelTransferManagerStub; | 89 return new AsyncPixelTransferManagerStub; |
| 74 default: | 90 default: |
| 75 NOTREACHED(); | 91 NOTREACHED(); |
| 76 return NULL; | 92 return NULL; |
| 77 } | 93 } |
| 78 } | 94 } |
| 79 | 95 |
| 80 } // namespace gpu | 96 } // namespace gpu |
| OLD | NEW |