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" |
| 10 #include "gpu/command_buffer/service/async_pixel_transfer_manager_compressed.h" |
9 #include "gpu/command_buffer/service/async_pixel_transfer_manager_egl.h" | 11 #include "gpu/command_buffer/service/async_pixel_transfer_manager_egl.h" |
10 #include "gpu/command_buffer/service/async_pixel_transfer_manager_idle.h" | 12 #include "gpu/command_buffer/service/async_pixel_transfer_manager_idle.h" |
11 #include "gpu/command_buffer/service/async_pixel_transfer_manager_stub.h" | 13 #include "gpu/command_buffer/service/async_pixel_transfer_manager_stub.h" |
12 #include "gpu/command_buffer/service/async_pixel_transfer_manager_sync.h" | 14 #include "gpu/command_buffer/service/async_pixel_transfer_manager_sync.h" |
| 15 #include "gpu/command_buffer/service/gpu_switches.h" |
13 #include "ui/gl/gl_context.h" | 16 #include "ui/gl/gl_context.h" |
14 #include "ui/gl/gl_implementation.h" | 17 #include "ui/gl/gl_implementation.h" |
15 | 18 |
16 namespace gpu { | 19 namespace gpu { |
17 namespace { | 20 namespace { |
18 | 21 |
19 enum GpuType { | 22 enum GpuType { |
20 GPU_BROADCOM, | 23 GPU_BROADCOM, |
21 GPU_IMAGINATION, | 24 GPU_IMAGINATION, |
22 GPU_NVIDIA_ES31, | 25 GPU_NVIDIA_ES31, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 57 |
55 return GPU_OTHER; | 58 return GPU_OTHER; |
56 } | 59 } |
57 | 60 |
58 bool AllowTransferThreadForGpu() { | 61 bool AllowTransferThreadForGpu() { |
59 GpuType gpu = GetGpuType(); | 62 GpuType gpu = GetGpuType(); |
60 return gpu != GPU_BROADCOM && gpu != GPU_IMAGINATION && | 63 return gpu != GPU_BROADCOM && gpu != GPU_IMAGINATION && |
61 gpu != GPU_NVIDIA_ES31 && gpu != GPU_ADRENO_420; | 64 gpu != GPU_NVIDIA_ES31 && gpu != GPU_ADRENO_420; |
62 } | 65 } |
63 | 66 |
| 67 bool IsAsyncEGLUploadsDisabled(gfx::GLContext* context) { |
| 68 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 69 if (!command_line.HasSwitch(switches::kDisableAsyncEGLUploadsIfCompressed)) |
| 70 return false; |
| 71 |
| 72 if (context->HasExtension("GL_EXT_texture_compression_s3tc") || |
| 73 (context->HasExtension("GL_ANGLE_texture_compression_dxt1") && |
| 74 context->HasExtension("GL_ANGLE_texture_compression_dxt5")) || |
| 75 context->HasExtension("GL_OES_compressed_ETC1_RGB8_texture") || |
| 76 context->HasExtension("GL_AMD_compressed_ATC_texture") || |
| 77 context->HasExtension("GL_ATI_texture_compression_atitc")) { |
| 78 if (!command_line.HasSwitch( |
| 79 switches::kEnableAsyncPixelTransferManagerCompressed)) { |
| 80 return true; |
| 81 } |
| 82 } |
| 83 |
| 84 return false; |
| 85 } |
64 } | 86 } |
65 | 87 |
66 // We only used threaded uploads when we can: | 88 // We only used threaded uploads when we can: |
67 // - Create EGLImages out of OpenGL textures (EGL_KHR_gl_texture_2D_image) | 89 // - Create EGLImages out of OpenGL textures (EGL_KHR_gl_texture_2D_image) |
68 // - Bind EGLImages to OpenGL textures (GL_OES_EGL_image) | 90 // - Bind EGLImages to OpenGL textures (GL_OES_EGL_image) |
69 // - Use fences (to test for upload completion). | 91 // - Use fences (to test for upload completion). |
70 // - The heap size is large enough. | 92 // - The heap size is large enough. |
| 93 // - No compressed formats are used. |
71 // TODO(kaanb|epenner): Remove the IsImagination() check pending the | 94 // TODO(kaanb|epenner): Remove the IsImagination() check pending the |
72 // resolution of crbug.com/249147 | 95 // resolution of crbug.com/249147 |
73 // TODO(kaanb|epenner): Remove the IsLowEndDevice() check pending the | 96 // TODO(kaanb|epenner): Remove the IsLowEndDevice() check pending the |
74 // resolution of crbug.com/271929 | 97 // resolution of crbug.com/271929 |
75 AsyncPixelTransferManager* AsyncPixelTransferManager::Create( | 98 AsyncPixelTransferManager* AsyncPixelTransferManager::Create( |
76 gfx::GLContext* context) { | 99 gfx::GLContext* context) { |
77 DCHECK(context->IsCurrent(NULL)); | 100 DCHECK(context->IsCurrent(NULL)); |
78 switch (gfx::GetGLImplementation()) { | 101 switch (gfx::GetGLImplementation()) { |
79 case gfx::kGLImplementationEGLGLES2: | 102 case gfx::kGLImplementationEGLGLES2: |
80 DCHECK(context); | 103 DCHECK(context); |
81 if (!base::SysInfo::IsLowEndDevice() && | 104 if (!base::SysInfo::IsLowEndDevice() && |
82 context->HasExtension("EGL_KHR_fence_sync") && | 105 context->HasExtension("EGL_KHR_fence_sync") && |
83 context->HasExtension("EGL_KHR_image") && | 106 context->HasExtension("EGL_KHR_image") && |
84 context->HasExtension("EGL_KHR_image_base") && | 107 context->HasExtension("EGL_KHR_image_base") && |
85 context->HasExtension("EGL_KHR_gl_texture_2D_image") && | 108 context->HasExtension("EGL_KHR_gl_texture_2D_image") && |
86 context->HasExtension("GL_OES_EGL_image") && | 109 context->HasExtension("GL_OES_EGL_image") && |
87 AllowTransferThreadForGpu()) { | 110 AllowTransferThreadForGpu() && !IsAsyncEGLUploadsDisabled(context)) { |
88 TRACE_EVENT0("gpu", "AsyncPixelTransferManager_CreateWithThread"); | 111 TRACE_EVENT0("gpu", "AsyncPixelTransferManager_CreateWithThread"); |
89 return new AsyncPixelTransferManagerEGL; | 112 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 113 if (command_line.HasSwitch( |
| 114 switches::kEnableAsyncPixelTransferManagerCompressed)) |
| 115 return new AsyncPixelTransferManagerCompressed; |
| 116 else |
| 117 return new AsyncPixelTransferManagerEGL; |
90 } | 118 } |
91 return new AsyncPixelTransferManagerIdle; | 119 return new AsyncPixelTransferManagerIdle; |
92 case gfx::kGLImplementationOSMesaGL: { | 120 case gfx::kGLImplementationOSMesaGL: { |
93 TRACE_EVENT0("gpu", "AsyncPixelTransferManager_CreateIdle"); | 121 TRACE_EVENT0("gpu", "AsyncPixelTransferManager_CreateIdle"); |
94 return new AsyncPixelTransferManagerIdle; | 122 return new AsyncPixelTransferManagerIdle; |
95 } | 123 } |
96 case gfx::kGLImplementationMockGL: | 124 case gfx::kGLImplementationMockGL: |
97 return new AsyncPixelTransferManagerStub; | 125 return new AsyncPixelTransferManagerStub; |
98 default: | 126 default: |
99 NOTREACHED(); | 127 NOTREACHED(); |
100 return NULL; | 128 return NULL; |
101 } | 129 } |
102 } | 130 } |
103 | 131 |
104 } // namespace gpu | 132 } // namespace gpu |
OLD | NEW |