Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

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

Issue 13400003: Use macro to simplify gpu driver bug workaround defs and code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/feature_info.h" 5 #include "gpu/command_buffer/service/feature_info.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_split.h" 12 #include "base/strings/string_split.h"
13 #include "gpu/command_buffer/service/gl_utils.h" 13 #include "gpu/command_buffer/service/gl_utils.h"
14 #include "gpu/command_buffer/service/gpu_driver_bug_workaround_type.h"
15 #include "gpu/command_buffer/service/gpu_switches.h" 14 #include "gpu/command_buffer/service/gpu_switches.h"
16 #include "ui/gl/gl_implementation.h" 15 #include "ui/gl/gl_implementation.h"
17 #if defined(OS_MACOSX) 16 #if defined(OS_MACOSX)
18 #include "ui/surface/io_surface_support_mac.h" 17 #include "ui/surface/io_surface_support_mac.h"
19 #endif 18 #endif
20 19
21 namespace gpu { 20 namespace gpu {
22 namespace gles2 { 21 namespace gles2 {
23 22
24 namespace { 23 namespace {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 void StringToWorkarounds( 68 void StringToWorkarounds(
70 const std::string& types, FeatureInfo::Workarounds* workarounds) { 69 const std::string& types, FeatureInfo::Workarounds* workarounds) {
71 DCHECK(workarounds); 70 DCHECK(workarounds);
72 std::vector<std::string> pieces; 71 std::vector<std::string> pieces;
73 base::SplitString(types, ',', &pieces); 72 base::SplitString(types, ',', &pieces);
74 for (size_t i = 0; i < pieces.size(); ++i) { 73 for (size_t i = 0; i < pieces.size(); ++i) {
75 int number = 0; 74 int number = 0;
76 bool succeed = base::StringToInt(pieces[i], &number); 75 bool succeed = base::StringToInt(pieces[i], &number);
77 DCHECK(succeed); 76 DCHECK(succeed);
78 switch (number) { 77 switch (number) {
79 case gpu::CLEAR_ALPHA_IN_READPIXELS: 78 #define GPU_OP(type, name) \
80 workarounds->clear_alpha_in_readpixels = true; 79 case gpu::type: \
81 break; 80 workarounds->name = true; \
82 case gpu::CLEAR_UNIFORMS_BEFORE_PROGRAM_USE: 81 break;
83 workarounds->clear_uniforms_before_program_use = true; 82 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP)
84 break; 83 #undef GPU_OP
85 case gpu::DELETE_INSTEAD_OF_RESIZE_FBO:
86 workarounds->delete_instead_of_resize_fbo = true;
87 break;
88 case gpu::DISABLE_ANGLE_FRAMEBUFFER_MULTISAMPLE:
89 workarounds->disable_angle_framebuffer_multisample = true;
90 break;
91 case gpu::DISABLE_DEPTH_TEXTURE:
92 workarounds->disable_depth_texture = true;
93 break;
94 case gpu::DISABLE_EXT_OCCLUSION_QUERY:
95 workarounds->disable_ext_occlusion_query = true;
96 break;
97 case gpu::ENABLE_CHROMIUM_FAST_NPOT_MO8_TEXTURES:
98 workarounds->enable_chromium_fast_npot_mo8_textures = true;
99 break;
100 case gpu::EXIT_ON_CONTEXT_LOST:
101 workarounds->exit_on_context_lost = true;
102 break;
103 case gpu::FLUSH_ON_CONTEXT_SWITCH:
104 workarounds->flush_on_context_switch = true;
105 break;
106 case gpu::MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_1024:
107 if (workarounds->max_cube_map_texture_size == 0 ||
108 workarounds->max_cube_map_texture_size > 1024)
109 workarounds->max_cube_map_texture_size = 1024;
110 break;
111 case gpu::MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_4096:
112 if (workarounds->max_cube_map_texture_size == 0 ||
113 workarounds->max_cube_map_texture_size > 4096)
114 workarounds->max_cube_map_texture_size = 4096;
115 break;
116 case gpu::MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_512:
117 if (workarounds->max_cube_map_texture_size == 0 ||
118 workarounds->max_cube_map_texture_size > 512)
119 workarounds->max_cube_map_texture_size = 512;
120 break;
121 case gpu::MAX_TEXTURE_SIZE_LIMIT_4096:
122 if (workarounds->max_texture_size == 0 ||
123 workarounds->max_texture_size > 4096)
124 workarounds->max_texture_size = 4096;
125 break;
126 case gpu::NEEDS_GLSL_BUILT_IN_FUNCTION_EMULATION:
127 workarounds->needs_glsl_built_in_function_emulation = true;
128 break;
129 case gpu::NEEDS_OFFSCREEN_BUFFER_WORKAROUND:
130 workarounds->needs_offscreen_buffer_workaround = true;
131 break;
132 case gpu::RESTORE_SCISSOR_ON_FBO_CHANGE:
133 workarounds->restore_scissor_on_fbo_change = true;
134 break;
135 case REVERSE_POINT_SPRITE_COORD_ORIGIN:
136 workarounds->reverse_point_sprite_coord_origin = true;
137 break;
138 case gpu::SET_TEXTURE_FILTER_BEFORE_GENERATING_MIPMAP:
139 workarounds->set_texture_filter_before_generating_mipmap = true;
140 break;
141 case gpu::USE_CLIENT_SIDE_ARRAYS_FOR_STREAM_BUFFERS:
142 workarounds->use_client_side_arrays_for_stream_buffers = true;
143 break;
144 case gpu::USE_CURRENT_PROGRAM_AFTER_SUCCESSFUL_LINK:
145 workarounds->use_current_program_after_successful_link = true;
146 break;
147 default: 84 default:
148 NOTIMPLEMENTED(); 85 NOTIMPLEMENTED();
149 } 86 }
150 } 87 }
88 if (workarounds->max_texture_size_limit_4096)
89 workarounds->max_texture_size = 4096;
90 if (workarounds->max_cube_map_texture_size_limit_4096)
91 workarounds->max_cube_map_texture_size = 4096;
92 if (workarounds->max_cube_map_texture_size_limit_1024)
93 workarounds->max_cube_map_texture_size = 1024;
94 if (workarounds->max_cube_map_texture_size_limit_512)
95 workarounds->max_cube_map_texture_size = 512;
151 } 96 }
152 97
153 } // anonymous namespace. 98 } // anonymous namespace.
154 99
155 FeatureInfo::FeatureFlags::FeatureFlags() 100 FeatureInfo::FeatureFlags::FeatureFlags()
156 : chromium_framebuffer_multisample(false), 101 : chromium_framebuffer_multisample(false),
157 oes_standard_derivatives(false), 102 oes_standard_derivatives(false),
158 oes_egl_image_external(false), 103 oes_egl_image_external(false),
159 npot_ok(false), 104 npot_ok(false),
160 enable_texture_float_linear(false), 105 enable_texture_float_linear(false),
161 enable_texture_half_float_linear(false), 106 enable_texture_half_float_linear(false),
162 chromium_stream_texture(false), 107 chromium_stream_texture(false),
163 angle_translated_shader_source(false), 108 angle_translated_shader_source(false),
164 angle_pack_reverse_row_order(false), 109 angle_pack_reverse_row_order(false),
165 arb_texture_rectangle(false), 110 arb_texture_rectangle(false),
166 angle_instanced_arrays(false), 111 angle_instanced_arrays(false),
167 occlusion_query_boolean(false), 112 occlusion_query_boolean(false),
168 use_arb_occlusion_query2_for_occlusion_query_boolean(false), 113 use_arb_occlusion_query2_for_occlusion_query_boolean(false),
169 use_arb_occlusion_query_for_occlusion_query_boolean(false), 114 use_arb_occlusion_query_for_occlusion_query_boolean(false),
170 native_vertex_array_object(false), 115 native_vertex_array_object(false),
171 enable_shader_name_hashing(false), 116 enable_shader_name_hashing(false),
172 enable_samplers(false), 117 enable_samplers(false),
173 ext_draw_buffers(false) { 118 ext_draw_buffers(false) {
174 } 119 }
175 120
176 FeatureInfo::Workarounds::Workarounds() 121 FeatureInfo::Workarounds::Workarounds() :
177 : clear_alpha_in_readpixels(false), 122 #define GPU_OP(type, name) name(false),
178 clear_uniforms_before_program_use(false), 123 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP)
179 delete_instead_of_resize_fbo(false), 124 #undef GPU_OP
180 disable_angle_framebuffer_multisample(false), 125 max_texture_size(0),
181 disable_depth_texture(false), 126 max_cube_map_texture_size(0) {
182 disable_ext_occlusion_query(false),
183 enable_chromium_fast_npot_mo8_textures(false),
184 exit_on_context_lost(false),
185 flush_on_context_switch(false),
186 needs_glsl_built_in_function_emulation(false),
187 needs_offscreen_buffer_workaround(false),
188 restore_scissor_on_fbo_change(false),
189 reverse_point_sprite_coord_origin(false),
190 set_texture_filter_before_generating_mipmap(false),
191 use_client_side_arrays_for_stream_buffers(false),
192 use_current_program_after_successful_link(false),
193 max_texture_size(0),
194 max_cube_map_texture_size(0) {
195 } 127 }
196 128
197 FeatureInfo::FeatureInfo() { 129 FeatureInfo::FeatureInfo() {
198 static const GLenum kAlphaTypes[] = { 130 static const GLenum kAlphaTypes[] = {
199 GL_UNSIGNED_BYTE, 131 GL_UNSIGNED_BYTE,
200 }; 132 };
201 static const GLenum kRGBTypes[] = { 133 static const GLenum kRGBTypes[] = {
202 GL_UNSIGNED_BYTE, 134 GL_UNSIGNED_BYTE,
203 GL_UNSIGNED_SHORT_5_6_5, 135 GL_UNSIGNED_SHORT_5_6_5,
204 }; 136 };
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 if (extensions_.find(str) == std::string::npos) { 634 if (extensions_.find(str) == std::string::npos) {
703 extensions_ += (extensions_.empty() ? "" : " ") + str; 635 extensions_ += (extensions_.empty() ? "" : " ") + str;
704 } 636 }
705 } 637 }
706 638
707 FeatureInfo::~FeatureInfo() { 639 FeatureInfo::~FeatureInfo() {
708 } 640 }
709 641
710 } // namespace gles2 642 } // namespace gles2
711 } // namespace gpu 643 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/feature_info.h ('k') | gpu/command_buffer/service/feature_info_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698