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

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

Issue 11791032: Refactor FeatureInfo so you can't request features. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 } // anonymous namespace. 65 } // anonymous namespace.
66 66
67 FeatureInfo::FeatureFlags::FeatureFlags() 67 FeatureInfo::FeatureFlags::FeatureFlags()
68 : chromium_framebuffer_multisample(false), 68 : chromium_framebuffer_multisample(false),
69 oes_standard_derivatives(false), 69 oes_standard_derivatives(false),
70 oes_egl_image_external(false), 70 oes_egl_image_external(false),
71 npot_ok(false), 71 npot_ok(false),
72 enable_texture_float_linear(false), 72 enable_texture_float_linear(false),
73 enable_texture_half_float_linear(false), 73 enable_texture_half_float_linear(false),
74 chromium_webglsl(false),
75 chromium_stream_texture(false), 74 chromium_stream_texture(false),
76 angle_translated_shader_source(false), 75 angle_translated_shader_source(false),
77 angle_pack_reverse_row_order(false), 76 angle_pack_reverse_row_order(false),
78 arb_texture_rectangle(false), 77 arb_texture_rectangle(false),
79 angle_instanced_arrays(false), 78 angle_instanced_arrays(false),
80 occlusion_query_boolean(false), 79 occlusion_query_boolean(false),
81 use_arb_occlusion_query2_for_occlusion_query_boolean(false), 80 use_arb_occlusion_query2_for_occlusion_query_boolean(false),
82 use_arb_occlusion_query_for_occlusion_query_boolean(false), 81 use_arb_occlusion_query_for_occlusion_query_boolean(false),
83 native_vertex_array_object(false), 82 native_vertex_array_object(false),
84 disable_workarounds(false), 83 disable_workarounds(false),
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 }; 124 };
126 for (size_t ii = 0; ii < arraysize(kFormatTypes); ++ii) { 125 for (size_t ii = 0; ii < arraysize(kFormatTypes); ++ii) {
127 const FormatInfo& info = kFormatTypes[ii]; 126 const FormatInfo& info = kFormatTypes[ii];
128 ValueValidator<GLenum>& validator = texture_format_validators_[info.format]; 127 ValueValidator<GLenum>& validator = texture_format_validators_[info.format];
129 for (size_t jj = 0; jj < info.count; ++jj) { 128 for (size_t jj = 0; jj < info.count; ++jj) {
130 validator.AddValue(info.types[jj]); 129 validator.AddValue(info.types[jj]);
131 } 130 }
132 } 131 }
133 } 132 }
134 133
135 // Helps query for extensions.
136 class ExtensionHelper {
137 public:
138 ExtensionHelper(const char* extensions, const char* desired_features)
139 : desire_all_features_(false) {
140 // Check for "*"
141 if (desired_features &&
142 desired_features[0] == '*' &&
143 desired_features[1] == '\0') {
144 desired_features = NULL;
145 }
146
147 have_extensions_.Init(extensions);
148 desired_extensions_.Init(desired_features);
149
150 if (!desired_features) {
151 desire_all_features_ = true;
152 }
153 }
154
155 // Returns true if extension exists.
156 bool Have(const char* extension) {
157 return have_extensions_.Contains(extension);
158 }
159
160 // Returns true of an extension is desired. It may not exist.
161 bool Desire(const char* extension) {
162 return desire_all_features_ || desired_extensions_.Contains(extension);
163 }
164
165 // Returns true if an extension exists and is desired.
166 bool HaveAndDesire(const char* extension) {
167 return Have(extension) && Desire(extension);
168 }
169
170 private:
171 bool desire_all_features_;
172
173 // Extensions that exist.
174 StringSet have_extensions_;
175
176 // Extensions that are desired but may not exist.
177 StringSet desired_extensions_;
178 };
179
180 bool FeatureInfo::Initialize(const char* allowed_features) { 134 bool FeatureInfo::Initialize(const char* allowed_features) {
181 disallowed_features_ = DisallowedFeatures(); 135 disallowed_features_ = DisallowedFeatures();
182 AddFeatures(allowed_features); 136 AddFeatures();
183 return true; 137 return true;
184 } 138 }
185 139
186 bool FeatureInfo::Initialize(const DisallowedFeatures& disallowed_features, 140 bool FeatureInfo::Initialize(const DisallowedFeatures& disallowed_features,
187 const char* allowed_features) { 141 const char* allowed_features) {
188 disallowed_features_ = disallowed_features; 142 disallowed_features_ = disallowed_features;
189 AddFeatures(allowed_features); 143 AddFeatures();
190 return true; 144 return true;
191 } 145 }
192 146
193 void FeatureInfo::AddFeatures(const char* desired_features) { 147 void FeatureInfo::AddFeatures() {
194 // Figure out what extensions to turn on. 148 // Figure out what extensions to turn on.
195 ExtensionHelper ext( 149 StringSet extensions(
196 reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)), 150 reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)));
197 desired_features);
198 151
199 // NOTE: We need to check both GL_VENDOR and GL_RENDERER because for example 152 // NOTE: We need to check both GL_VENDOR and GL_RENDERER because for example
200 // Sandy Bridge on Linux reports: 153 // Sandy Bridge on Linux reports:
201 // GL_VENDOR: Tungsten Graphics, Inc 154 // GL_VENDOR: Tungsten Graphics, Inc
202 // GL_RENDERER: 155 // GL_RENDERER:
203 // Mesa DRI Intel(R) Sandybridge Desktop GEM 20100330 DEVELOPMENT 156 // Mesa DRI Intel(R) Sandybridge Desktop GEM 20100330 DEVELOPMENT
204 157
205 static GLenum string_ids[] = { 158 static GLenum string_ids[] = {
206 GL_VENDOR, 159 GL_VENDOR,
207 GL_RENDERER, 160 GL_RENDERER,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 AddExtensionString("GL_CHROMIUM_copy_texture"); 197 AddExtensionString("GL_CHROMIUM_copy_texture");
245 AddExtensionString("GL_CHROMIUM_discard_backbuffer"); 198 AddExtensionString("GL_CHROMIUM_discard_backbuffer");
246 AddExtensionString("GL_CHROMIUM_get_error_query"); 199 AddExtensionString("GL_CHROMIUM_get_error_query");
247 AddExtensionString("GL_CHROMIUM_lose_context"); 200 AddExtensionString("GL_CHROMIUM_lose_context");
248 AddExtensionString("GL_CHROMIUM_pixel_transfer_buffer_object"); 201 AddExtensionString("GL_CHROMIUM_pixel_transfer_buffer_object");
249 AddExtensionString("GL_CHROMIUM_rate_limit_offscreen_context"); 202 AddExtensionString("GL_CHROMIUM_rate_limit_offscreen_context");
250 AddExtensionString("GL_CHROMIUM_resize"); 203 AddExtensionString("GL_CHROMIUM_resize");
251 AddExtensionString("GL_CHROMIUM_resource_safe"); 204 AddExtensionString("GL_CHROMIUM_resource_safe");
252 AddExtensionString("GL_CHROMIUM_set_visibility"); 205 AddExtensionString("GL_CHROMIUM_set_visibility");
253 AddExtensionString("GL_CHROMIUM_strict_attribs"); 206 AddExtensionString("GL_CHROMIUM_strict_attribs");
207 AddExtensionString("GL_CHROMIUM_stream_texture");
254 AddExtensionString("GL_CHROMIUM_texture_mailbox"); 208 AddExtensionString("GL_CHROMIUM_texture_mailbox");
255 AddExtensionString("GL_EXT_debug_marker"); 209 AddExtensionString("GL_EXT_debug_marker");
256 210
211 feature_flags_.chromium_stream_texture = true;
212
213 // OES_vertex_array_object is emulated if not present natively,
214 // so the extension string is always exposed.
215 AddExtensionString("GL_OES_vertex_array_object");
216
257 if (!disallowed_features_.gpu_memory_manager) 217 if (!disallowed_features_.gpu_memory_manager)
258 AddExtensionString("GL_CHROMIUM_gpu_memory_manager"); 218 AddExtensionString("GL_CHROMIUM_gpu_memory_manager");
259 219
260 if (ext.Have("GL_ANGLE_translated_shader_source")) { 220 if (extensions.Contains("GL_ANGLE_translated_shader_source")) {
261 feature_flags_.angle_translated_shader_source = true; 221 feature_flags_.angle_translated_shader_source = true;
262 } 222 }
263 223
264 // Only turn this feature on if it is requested. Not by default.
265 if (desired_features && ext.Desire("GL_CHROMIUM_webglsl")) {
266 AddExtensionString("GL_CHROMIUM_webglsl");
267 feature_flags_.chromium_webglsl = true;
268 }
269
270 // Check if we should allow GL_EXT_texture_compression_dxt1 and 224 // Check if we should allow GL_EXT_texture_compression_dxt1 and
271 // GL_EXT_texture_compression_s3tc. 225 // GL_EXT_texture_compression_s3tc.
272 bool enable_dxt1 = false; 226 bool enable_dxt1 = false;
273 bool enable_dxt3 = false; 227 bool enable_dxt3 = false;
274 bool enable_dxt5 = false; 228 bool enable_dxt5 = false;
275 bool have_s3tc = ext.Have("GL_EXT_texture_compression_s3tc"); 229 bool have_s3tc = extensions.Contains("GL_EXT_texture_compression_s3tc");
276 bool have_dxt3 = have_s3tc || ext.Have("GL_ANGLE_texture_compression_dxt3"); 230 bool have_dxt3 =
277 bool have_dxt5 = have_s3tc || ext.Have("GL_ANGLE_texture_compression_dxt5"); 231 have_s3tc || extensions.Contains("GL_ANGLE_texture_compression_dxt3");
232 bool have_dxt5 =
233 have_s3tc || extensions.Contains("GL_ANGLE_texture_compression_dxt5");
278 234
279 if (ext.Desire("GL_EXT_texture_compression_dxt1") && 235 if (extensions.Contains("GL_EXT_texture_compression_dxt1") || have_s3tc) {
280 (ext.Have("GL_EXT_texture_compression_dxt1") || have_s3tc)) {
281 enable_dxt1 = true; 236 enable_dxt1 = true;
282 } 237 }
283 if (have_dxt3 && ext.Desire("GL_CHROMIUM_texture_compression_dxt3")) { 238 if (have_dxt3) {
284 enable_dxt3 = true; 239 enable_dxt3 = true;
285 } 240 }
286 if (have_dxt5 && ext.Desire("GL_CHROMIUM_texture_compression_dxt5")) { 241 if (have_dxt5) {
287 enable_dxt5 = true; 242 enable_dxt5 = true;
288 } 243 }
289 244
290 if (enable_dxt1) { 245 if (enable_dxt1) {
291 AddExtensionString("GL_EXT_texture_compression_dxt1"); 246 AddExtensionString("GL_EXT_texture_compression_dxt1");
292 validators_.compressed_texture_format.AddValue( 247 validators_.compressed_texture_format.AddValue(
293 GL_COMPRESSED_RGB_S3TC_DXT1_EXT); 248 GL_COMPRESSED_RGB_S3TC_DXT1_EXT);
294 validators_.compressed_texture_format.AddValue( 249 validators_.compressed_texture_format.AddValue(
295 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT); 250 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT);
296 } 251 }
(...skipping 10 matching lines...) Expand all
307 if (enable_dxt5) { 262 if (enable_dxt5) {
308 // The difference between GL_EXT_texture_compression_s3tc and 263 // The difference between GL_EXT_texture_compression_s3tc and
309 // GL_CHROMIUM_texture_compression_dxt5 is that the former 264 // GL_CHROMIUM_texture_compression_dxt5 is that the former
310 // requires on the fly compression. The latter does not. 265 // requires on the fly compression. The latter does not.
311 AddExtensionString("GL_CHROMIUM_texture_compression_dxt5"); 266 AddExtensionString("GL_CHROMIUM_texture_compression_dxt5");
312 validators_.compressed_texture_format.AddValue( 267 validators_.compressed_texture_format.AddValue(
313 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT); 268 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT);
314 } 269 }
315 270
316 // Check if we should enable GL_EXT_texture_filter_anisotropic. 271 // Check if we should enable GL_EXT_texture_filter_anisotropic.
317 if (ext.HaveAndDesire("GL_EXT_texture_filter_anisotropic")) { 272 if (extensions.Contains("GL_EXT_texture_filter_anisotropic")) {
318 AddExtensionString("GL_EXT_texture_filter_anisotropic"); 273 AddExtensionString("GL_EXT_texture_filter_anisotropic");
319 validators_.texture_parameter.AddValue( 274 validators_.texture_parameter.AddValue(
320 GL_TEXTURE_MAX_ANISOTROPY_EXT); 275 GL_TEXTURE_MAX_ANISOTROPY_EXT);
321 validators_.g_l_state.AddValue( 276 validators_.g_l_state.AddValue(
322 GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT); 277 GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT);
323 } 278 }
324 279
325 // Check if we should support GL_OES_packed_depth_stencil and/or 280 // Check if we should support GL_OES_packed_depth_stencil and/or
326 // GL_GOOGLE_depth_texture / GL_CHROMIUM_depth_texture. 281 // GL_GOOGLE_depth_texture / GL_CHROMIUM_depth_texture.
327 // 282 //
328 // NOTE: GL_OES_depth_texture requires support for depth cubemaps. 283 // NOTE: GL_OES_depth_texture requires support for depth cubemaps.
329 // GL_ARB_depth_texture requires other features that 284 // GL_ARB_depth_texture requires other features that
330 // GL_OES_packed_depth_stencil does not provide. 285 // GL_OES_packed_depth_stencil does not provide.
331 // 286 //
332 // Therefore we made up GL_GOOGLE_depth_texture / GL_CHROMIUM_depth_texture. 287 // Therefore we made up GL_GOOGLE_depth_texture / GL_CHROMIUM_depth_texture.
333 // 288 //
334 // GL_GOOGLE_depth_texture is legacy. As we exposed it into NaCl we can't 289 // GL_GOOGLE_depth_texture is legacy. As we exposed it into NaCl we can't
335 // get rid of it. 290 // get rid of it.
336 // 291 //
337 bool enable_depth_texture = false; 292 bool enable_depth_texture = false;
338 if ((ext.Desire("GL_GOOGLE_depth_texture") || 293 if (extensions.Contains("GL_ARB_depth_texture") ||
339 ext.Desire("GL_CHROMIUM_depth_texture")) && 294 extensions.Contains("GL_OES_depth_texture") ||
340 (ext.Have("GL_ARB_depth_texture") || 295 extensions.Contains("GL_ANGLE_depth_texture")) {
341 ext.Have("GL_OES_depth_texture") ||
342 ext.Have("GL_ANGLE_depth_texture"))) {
343 enable_depth_texture = true; 296 enable_depth_texture = true;
344 } 297 }
345 298
346 if (enable_depth_texture) { 299 if (enable_depth_texture) {
347 AddExtensionString("GL_CHROMIUM_depth_texture"); 300 AddExtensionString("GL_CHROMIUM_depth_texture");
348 AddExtensionString("GL_GOOGLE_depth_texture"); 301 AddExtensionString("GL_GOOGLE_depth_texture");
349 texture_format_validators_[GL_DEPTH_COMPONENT].AddValue(GL_UNSIGNED_SHORT); 302 texture_format_validators_[GL_DEPTH_COMPONENT].AddValue(GL_UNSIGNED_SHORT);
350 texture_format_validators_[GL_DEPTH_COMPONENT].AddValue(GL_UNSIGNED_INT); 303 texture_format_validators_[GL_DEPTH_COMPONENT].AddValue(GL_UNSIGNED_INT);
351 validators_.texture_internal_format.AddValue(GL_DEPTH_COMPONENT); 304 validators_.texture_internal_format.AddValue(GL_DEPTH_COMPONENT);
352 validators_.texture_format.AddValue(GL_DEPTH_COMPONENT); 305 validators_.texture_format.AddValue(GL_DEPTH_COMPONENT);
353 validators_.pixel_type.AddValue(GL_UNSIGNED_SHORT); 306 validators_.pixel_type.AddValue(GL_UNSIGNED_SHORT);
354 validators_.pixel_type.AddValue(GL_UNSIGNED_INT); 307 validators_.pixel_type.AddValue(GL_UNSIGNED_INT);
355 } 308 }
356 309
357 if (ext.Desire("GL_OES_packed_depth_stencil") && 310 if (extensions.Contains("GL_EXT_packed_depth_stencil") ||
358 (ext.Have("GL_EXT_packed_depth_stencil") || 311 extensions.Contains("GL_OES_packed_depth_stencil")) {
359 ext.Have("GL_OES_packed_depth_stencil"))) {
360 AddExtensionString("GL_OES_packed_depth_stencil"); 312 AddExtensionString("GL_OES_packed_depth_stencil");
361 if (enable_depth_texture) { 313 if (enable_depth_texture) {
362 texture_format_validators_[GL_DEPTH_STENCIL].AddValue( 314 texture_format_validators_[GL_DEPTH_STENCIL].AddValue(
363 GL_UNSIGNED_INT_24_8); 315 GL_UNSIGNED_INT_24_8);
364 validators_.texture_internal_format.AddValue(GL_DEPTH_STENCIL); 316 validators_.texture_internal_format.AddValue(GL_DEPTH_STENCIL);
365 validators_.texture_format.AddValue(GL_DEPTH_STENCIL); 317 validators_.texture_format.AddValue(GL_DEPTH_STENCIL);
366 validators_.pixel_type.AddValue(GL_UNSIGNED_INT_24_8); 318 validators_.pixel_type.AddValue(GL_UNSIGNED_INT_24_8);
367 } 319 }
368 validators_.render_buffer_format.AddValue(GL_DEPTH24_STENCIL8); 320 validators_.render_buffer_format.AddValue(GL_DEPTH24_STENCIL8);
369 } 321 }
370 322
371 if (ext.Desire("GL_OES_vertex_array_object")) { 323 if (extensions.Contains("GL_OES_vertex_array_object") ||
372 if (ext.Have("GL_OES_vertex_array_object") || 324 extensions.Contains("GL_ARB_vertex_array_object") ||
373 ext.Have("GL_ARB_vertex_array_object") || 325 extensions.Contains("GL_APPLE_vertex_array_object")) {
374 ext.Have("GL_APPLE_vertex_array_object")) { 326 feature_flags_.native_vertex_array_object = true;
375 feature_flags_.native_vertex_array_object = true;
376 }
377
378 // OES_vertex_array_object is emulated if not present natively,
379 // so the extension string is always exposed.
380 AddExtensionString("GL_OES_vertex_array_object");
381 } 327 }
382 328
383 if (ext.Desire("GL_OES_element_index_uint")) { 329 if (extensions.Contains("GL_OES_element_index_uint") ||
384 if (ext.Have("GL_OES_element_index_uint") || gfx::HasDesktopGLFeatures()) { 330 gfx::HasDesktopGLFeatures()) {
385 AddExtensionString("GL_OES_element_index_uint"); 331 AddExtensionString("GL_OES_element_index_uint");
386 validators_.index_type.AddValue(GL_UNSIGNED_INT); 332 validators_.index_type.AddValue(GL_UNSIGNED_INT);
387 }
388 } 333 }
389 334
390 bool enable_texture_format_bgra8888 = false; 335 bool enable_texture_format_bgra8888 = false;
391 bool enable_read_format_bgra = false; 336 bool enable_read_format_bgra = false;
392 // Check if we should allow GL_EXT_texture_format_BGRA8888 337 // Check if we should allow GL_EXT_texture_format_BGRA8888
393 if (ext.Desire("GL_EXT_texture_format_BGRA8888") && 338 if (extensions.Contains("GL_EXT_texture_format_BGRA8888") ||
394 (ext.Have("GL_EXT_texture_format_BGRA8888") || 339 extensions.Contains("GL_APPLE_texture_format_BGRA8888") ||
395 ext.Have("GL_APPLE_texture_format_BGRA8888") || 340 extensions.Contains("GL_EXT_bgra")) {
396 ext.Have("GL_EXT_bgra"))) {
397 enable_texture_format_bgra8888 = true; 341 enable_texture_format_bgra8888 = true;
398 } 342 }
399 343
400 if (ext.HaveAndDesire("GL_EXT_bgra")) { 344 if (extensions.Contains("GL_EXT_bgra")) {
401 enable_texture_format_bgra8888 = true; 345 enable_texture_format_bgra8888 = true;
402 enable_read_format_bgra = true; 346 enable_read_format_bgra = true;
403 } 347 }
404 348
405 if (ext.Desire("GL_EXT_read_format_bgra") && 349 if (extensions.Contains("GL_EXT_read_format_bgra") ||
406 (ext.Have("GL_EXT_read_format_bgra") || 350 extensions.Contains("GL_EXT_bgra")) {
407 ext.Have("GL_EXT_bgra"))) {
408 enable_read_format_bgra = true; 351 enable_read_format_bgra = true;
409 } 352 }
410 353
411 if (enable_texture_format_bgra8888) { 354 if (enable_texture_format_bgra8888) {
412 AddExtensionString("GL_EXT_texture_format_BGRA8888"); 355 AddExtensionString("GL_EXT_texture_format_BGRA8888");
413 texture_format_validators_[GL_BGRA_EXT].AddValue(GL_UNSIGNED_BYTE); 356 texture_format_validators_[GL_BGRA_EXT].AddValue(GL_UNSIGNED_BYTE);
414 validators_.texture_internal_format.AddValue(GL_BGRA_EXT); 357 validators_.texture_internal_format.AddValue(GL_BGRA_EXT);
415 validators_.texture_format.AddValue(GL_BGRA_EXT); 358 validators_.texture_format.AddValue(GL_BGRA_EXT);
416 } 359 }
417 360
418 if (enable_read_format_bgra) { 361 if (enable_read_format_bgra) {
419 AddExtensionString("GL_EXT_read_format_bgra"); 362 AddExtensionString("GL_EXT_read_format_bgra");
420 validators_.read_pixel_format.AddValue(GL_BGRA_EXT); 363 validators_.read_pixel_format.AddValue(GL_BGRA_EXT);
421 } 364 }
422 365
423 if (ext.Desire("GL_OES_rgb8_rgba8")) { 366 if (extensions.Contains("GL_OES_rgb8_rgba8") || gfx::HasDesktopGLFeatures()) {
424 if (ext.Have("GL_OES_rgb8_rgba8") || gfx::HasDesktopGLFeatures()) { 367 AddExtensionString("GL_OES_rgb8_rgba8");
425 AddExtensionString("GL_OES_rgb8_rgba8"); 368 validators_.render_buffer_format.AddValue(GL_RGB8_OES);
426 validators_.render_buffer_format.AddValue(GL_RGB8_OES); 369 validators_.render_buffer_format.AddValue(GL_RGBA8_OES);
427 validators_.render_buffer_format.AddValue(GL_RGBA8_OES);
428 }
429 } 370 }
430 371
431 // Check if we should allow GL_OES_texture_npot 372 // Check if we should allow GL_OES_texture_npot
432 if (ext.Desire("GL_OES_texture_npot") && 373 if (extensions.Contains("GL_ARB_texture_non_power_of_two") ||
433 (ext.Have("GL_ARB_texture_non_power_of_two") || 374 extensions.Contains("GL_OES_texture_npot")) {
434 ext.Have("GL_OES_texture_npot"))) {
435 AddExtensionString("GL_OES_texture_npot"); 375 AddExtensionString("GL_OES_texture_npot");
436 npot_ok = true; 376 npot_ok = true;
437 } 377 }
438 378
439 // Check if we should allow GL_OES_texture_float, GL_OES_texture_half_float, 379 // Check if we should allow GL_OES_texture_float, GL_OES_texture_half_float,
440 // GL_OES_texture_float_linear, GL_OES_texture_half_float_linear 380 // GL_OES_texture_float_linear, GL_OES_texture_half_float_linear
441 bool enable_texture_float = false; 381 bool enable_texture_float = false;
442 bool enable_texture_float_linear = false; 382 bool enable_texture_float_linear = false;
443 bool enable_texture_half_float = false; 383 bool enable_texture_half_float = false;
444 bool enable_texture_half_float_linear = false; 384 bool enable_texture_half_float_linear = false;
445 385
446 bool have_arb_texture_float = ext.Have("GL_ARB_texture_float"); 386 bool have_arb_texture_float = extensions.Contains("GL_ARB_texture_float");
447 387
448 if (have_arb_texture_float && ext.Desire("GL_ARB_texture_float")) { 388 if (have_arb_texture_float) {
449 enable_texture_float = true; 389 enable_texture_float = true;
450 enable_texture_float_linear = true; 390 enable_texture_float_linear = true;
451 enable_texture_half_float = true; 391 enable_texture_half_float = true;
452 enable_texture_half_float_linear = true; 392 enable_texture_half_float_linear = true;
453 } else { 393 } else {
454 if (ext.HaveAndDesire("GL_OES_texture_float") || 394 if (extensions.Contains("GL_OES_texture_float") || have_arb_texture_float) {
455 (have_arb_texture_float &&
456 ext.Desire("GL_OES_texture_float"))) {
457 enable_texture_float = true; 395 enable_texture_float = true;
458 if (ext.HaveAndDesire("GL_OES_texture_float_linear") || 396 if (extensions.Contains("GL_OES_texture_float_linear") ||
459 (have_arb_texture_float && 397 have_arb_texture_float) {
460 ext.Desire("GL_OES_texture_float_linear"))) {
461 enable_texture_float_linear = true; 398 enable_texture_float_linear = true;
462 } 399 }
463 } 400 }
464 if (ext.HaveAndDesire("GL_OES_texture_half_float") || 401 if (extensions.Contains("GL_OES_texture_half_float") ||
465 (have_arb_texture_float && 402 have_arb_texture_float) {
466 ext.Desire("GL_OES_texture_half_float"))) {
467 enable_texture_half_float = true; 403 enable_texture_half_float = true;
468 if (ext.HaveAndDesire("GL_OES_texture_half_float_linear") || 404 if (extensions.Contains("GL_OES_texture_half_float_linear") ||
469 (have_arb_texture_float && 405 have_arb_texture_float) {
470 ext.Desire("GL_OES_texture_half_float_linear"))) {
471 enable_texture_half_float_linear = true; 406 enable_texture_half_float_linear = true;
472 } 407 }
473 } 408 }
474 } 409 }
475 410
476 if (enable_texture_float) { 411 if (enable_texture_float) {
477 texture_format_validators_[GL_ALPHA].AddValue(GL_FLOAT); 412 texture_format_validators_[GL_ALPHA].AddValue(GL_FLOAT);
478 texture_format_validators_[GL_RGB].AddValue(GL_FLOAT); 413 texture_format_validators_[GL_RGB].AddValue(GL_FLOAT);
479 texture_format_validators_[GL_RGBA].AddValue(GL_FLOAT); 414 texture_format_validators_[GL_RGBA].AddValue(GL_FLOAT);
480 texture_format_validators_[GL_LUMINANCE].AddValue(GL_FLOAT); 415 texture_format_validators_[GL_LUMINANCE].AddValue(GL_FLOAT);
(...skipping 14 matching lines...) Expand all
495 texture_format_validators_[GL_LUMINANCE_ALPHA].AddValue(GL_HALF_FLOAT_OES); 430 texture_format_validators_[GL_LUMINANCE_ALPHA].AddValue(GL_HALF_FLOAT_OES);
496 validators_.pixel_type.AddValue(GL_HALF_FLOAT_OES); 431 validators_.pixel_type.AddValue(GL_HALF_FLOAT_OES);
497 validators_.read_pixel_type.AddValue(GL_HALF_FLOAT_OES); 432 validators_.read_pixel_type.AddValue(GL_HALF_FLOAT_OES);
498 AddExtensionString("GL_OES_texture_half_float"); 433 AddExtensionString("GL_OES_texture_half_float");
499 if (enable_texture_half_float_linear) { 434 if (enable_texture_half_float_linear) {
500 AddExtensionString("GL_OES_texture_half_float_linear"); 435 AddExtensionString("GL_OES_texture_half_float_linear");
501 } 436 }
502 } 437 }
503 438
504 // Check for multisample support 439 // Check for multisample support
505 bool ext_has_multisample = ext.Have("GL_EXT_framebuffer_multisample"); 440 bool ext_has_multisample =
441 extensions.Contains("GL_EXT_framebuffer_multisample");
506 if (!is_qualcomm || feature_flags_.disable_workarounds) { 442 if (!is_qualcomm || feature_flags_.disable_workarounds) {
507 // Some Android Qualcomm drivers falsely report this ANGLE extension string. 443 // Some Android Qualcomm drivers falsely report this ANGLE extension string.
508 // See http://crbug.com/165736 444 // See http://crbug.com/165736
509 ext_has_multisample |= ext.Have("GL_ANGLE_framebuffer_multisample"); 445 ext_has_multisample |=
446 extensions.Contains("GL_ANGLE_framebuffer_multisample");
510 } 447 }
511 if (!disallowed_features_.multisampling && 448 if (!disallowed_features_.multisampling && ext_has_multisample) {
512 ext.Desire("GL_CHROMIUM_framebuffer_multisample") &&
513 ext_has_multisample) {
514 feature_flags_.chromium_framebuffer_multisample = true; 449 feature_flags_.chromium_framebuffer_multisample = true;
515 validators_.frame_buffer_target.AddValue(GL_READ_FRAMEBUFFER_EXT); 450 validators_.frame_buffer_target.AddValue(GL_READ_FRAMEBUFFER_EXT);
516 validators_.frame_buffer_target.AddValue(GL_DRAW_FRAMEBUFFER_EXT); 451 validators_.frame_buffer_target.AddValue(GL_DRAW_FRAMEBUFFER_EXT);
517 validators_.g_l_state.AddValue(GL_READ_FRAMEBUFFER_BINDING_EXT); 452 validators_.g_l_state.AddValue(GL_READ_FRAMEBUFFER_BINDING_EXT);
518 validators_.g_l_state.AddValue(GL_MAX_SAMPLES_EXT); 453 validators_.g_l_state.AddValue(GL_MAX_SAMPLES_EXT);
519 validators_.render_buffer_parameter.AddValue(GL_RENDERBUFFER_SAMPLES_EXT); 454 validators_.render_buffer_parameter.AddValue(GL_RENDERBUFFER_SAMPLES_EXT);
520 AddExtensionString("GL_CHROMIUM_framebuffer_multisample"); 455 AddExtensionString("GL_CHROMIUM_framebuffer_multisample");
521 } 456 }
522 457
523 if (ext.HaveAndDesire("GL_OES_depth24") || 458 if (extensions.Contains("GL_OES_depth24") || gfx::HasDesktopGLFeatures()) {
524 (gfx::HasDesktopGLFeatures() && ext.Desire("GL_OES_depth24"))) {
525 AddExtensionString("GL_OES_depth24"); 459 AddExtensionString("GL_OES_depth24");
526 validators_.render_buffer_format.AddValue(GL_DEPTH_COMPONENT24); 460 validators_.render_buffer_format.AddValue(GL_DEPTH_COMPONENT24);
527 } 461 }
528 462
529 if (ext.HaveAndDesire("GL_OES_standard_derivatives") || 463 if (extensions.Contains("GL_OES_standard_derivatives") ||
530 (gfx::HasDesktopGLFeatures() && 464 gfx::HasDesktopGLFeatures()) {
531 ext.Desire("GL_OES_standard_derivatives"))) {
532 AddExtensionString("GL_OES_standard_derivatives"); 465 AddExtensionString("GL_OES_standard_derivatives");
533 feature_flags_.oes_standard_derivatives = true; 466 feature_flags_.oes_standard_derivatives = true;
534 validators_.hint_target.AddValue(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES); 467 validators_.hint_target.AddValue(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES);
535 validators_.g_l_state.AddValue(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES); 468 validators_.g_l_state.AddValue(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES);
536 } 469 }
537 470
538 if (ext.HaveAndDesire("GL_OES_EGL_image_external")) { 471 if (extensions.Contains("GL_OES_EGL_image_external")) {
539 AddExtensionString("GL_OES_EGL_image_external"); 472 AddExtensionString("GL_OES_EGL_image_external");
540 feature_flags_.oes_egl_image_external = true; 473 feature_flags_.oes_egl_image_external = true;
541 validators_.texture_bind_target.AddValue(GL_TEXTURE_EXTERNAL_OES); 474 validators_.texture_bind_target.AddValue(GL_TEXTURE_EXTERNAL_OES);
542 validators_.get_tex_param_target.AddValue(GL_TEXTURE_EXTERNAL_OES); 475 validators_.get_tex_param_target.AddValue(GL_TEXTURE_EXTERNAL_OES);
543 validators_.texture_parameter.AddValue(GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES); 476 validators_.texture_parameter.AddValue(GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES);
544 validators_.g_l_state.AddValue(GL_TEXTURE_BINDING_EXTERNAL_OES); 477 validators_.g_l_state.AddValue(GL_TEXTURE_BINDING_EXTERNAL_OES);
545 } 478 }
546 479
547 if (ext.HaveAndDesire("GL_OES_compressed_ETC1_RGB8_texture")) { 480 if (extensions.Contains("GL_OES_compressed_ETC1_RGB8_texture")) {
548 AddExtensionString("GL_OES_compressed_ETC1_RGB8_texture"); 481 AddExtensionString("GL_OES_compressed_ETC1_RGB8_texture");
549 validators_.compressed_texture_format.AddValue(GL_ETC1_RGB8_OES); 482 validators_.compressed_texture_format.AddValue(GL_ETC1_RGB8_OES);
550 } 483 }
551 484
552 if (ext.Desire("GL_CHROMIUM_stream_texture")) {
553 AddExtensionString("GL_CHROMIUM_stream_texture");
554 feature_flags_.chromium_stream_texture = true;
555 }
556
557 // Ideally we would only expose this extension on Mac OS X, to 485 // Ideally we would only expose this extension on Mac OS X, to
558 // support GL_CHROMIUM_iosurface and the compositor. We don't want 486 // support GL_CHROMIUM_iosurface and the compositor. We don't want
559 // applications to start using it; they should use ordinary non- 487 // applications to start using it; they should use ordinary non-
560 // power-of-two textures. However, for unit testing purposes we 488 // power-of-two textures. However, for unit testing purposes we
561 // expose it on all supported platforms. 489 // expose it on all supported platforms.
562 if (ext.HaveAndDesire("GL_ARB_texture_rectangle")) { 490 if (extensions.Contains("GL_ARB_texture_rectangle")) {
563 AddExtensionString("GL_ARB_texture_rectangle"); 491 AddExtensionString("GL_ARB_texture_rectangle");
564 feature_flags_.arb_texture_rectangle = true; 492 feature_flags_.arb_texture_rectangle = true;
565 validators_.texture_bind_target.AddValue(GL_TEXTURE_RECTANGLE_ARB); 493 validators_.texture_bind_target.AddValue(GL_TEXTURE_RECTANGLE_ARB);
566 // For the moment we don't add this enum to the texture_target 494 // For the moment we don't add this enum to the texture_target
567 // validator. This implies that the only way to get image data into a 495 // validator. This implies that the only way to get image data into a
568 // rectangular texture is via glTexImageIOSurface2DCHROMIUM, which is 496 // rectangular texture is via glTexImageIOSurface2DCHROMIUM, which is
569 // just fine since again we don't want applications depending on this 497 // just fine since again we don't want applications depending on this
570 // extension. 498 // extension.
571 validators_.get_tex_param_target.AddValue(GL_TEXTURE_RECTANGLE_ARB); 499 validators_.get_tex_param_target.AddValue(GL_TEXTURE_RECTANGLE_ARB);
572 validators_.g_l_state.AddValue(GL_TEXTURE_BINDING_RECTANGLE_ARB); 500 validators_.g_l_state.AddValue(GL_TEXTURE_BINDING_RECTANGLE_ARB);
573 } 501 }
574 502
575 #if defined(OS_MACOSX) 503 #if defined(OS_MACOSX)
576 if (IOSurfaceSupport::Initialize()) { 504 if (IOSurfaceSupport::Initialize()) {
577 AddExtensionString("GL_CHROMIUM_iosurface"); 505 AddExtensionString("GL_CHROMIUM_iosurface");
578 } 506 }
579 #endif 507 #endif
580 508
581 // TODO(gman): Add support for these extensions. 509 // TODO(gman): Add support for these extensions.
582 // GL_OES_depth32 510 // GL_OES_depth32
583 511
584 feature_flags_.enable_texture_float_linear |= enable_texture_float_linear; 512 feature_flags_.enable_texture_float_linear |= enable_texture_float_linear;
585 feature_flags_.enable_texture_half_float_linear |= 513 feature_flags_.enable_texture_half_float_linear |=
586 enable_texture_half_float_linear; 514 enable_texture_half_float_linear;
587 feature_flags_.npot_ok |= npot_ok; 515 feature_flags_.npot_ok |= npot_ok;
588 516
589 if (ext.Desire("GL_ANGLE_pack_reverse_row_order") && 517 if (extensions.Contains("GL_ANGLE_pack_reverse_row_order")) {
590 ext.Have("GL_ANGLE_pack_reverse_row_order")) {
591 AddExtensionString("GL_ANGLE_pack_reverse_row_order"); 518 AddExtensionString("GL_ANGLE_pack_reverse_row_order");
592 feature_flags_.angle_pack_reverse_row_order = true; 519 feature_flags_.angle_pack_reverse_row_order = true;
593 validators_.pixel_store.AddValue(GL_PACK_REVERSE_ROW_ORDER_ANGLE); 520 validators_.pixel_store.AddValue(GL_PACK_REVERSE_ROW_ORDER_ANGLE);
594 validators_.g_l_state.AddValue(GL_PACK_REVERSE_ROW_ORDER_ANGLE); 521 validators_.g_l_state.AddValue(GL_PACK_REVERSE_ROW_ORDER_ANGLE);
595 } 522 }
596 523
597 if (ext.HaveAndDesire("GL_ANGLE_texture_usage")) { 524 if (extensions.Contains("GL_ANGLE_texture_usage")) {
598 AddExtensionString("GL_ANGLE_texture_usage"); 525 AddExtensionString("GL_ANGLE_texture_usage");
599 validators_.texture_parameter.AddValue(GL_TEXTURE_USAGE_ANGLE); 526 validators_.texture_parameter.AddValue(GL_TEXTURE_USAGE_ANGLE);
600 } 527 }
601 528
602 if (ext.HaveAndDesire("GL_EXT_texture_storage")) { 529 if (extensions.Contains("GL_EXT_texture_storage")) {
603 AddExtensionString("GL_EXT_texture_storage"); 530 AddExtensionString("GL_EXT_texture_storage");
604 validators_.texture_parameter.AddValue(GL_TEXTURE_IMMUTABLE_FORMAT_EXT); 531 validators_.texture_parameter.AddValue(GL_TEXTURE_IMMUTABLE_FORMAT_EXT);
605 if (enable_texture_format_bgra8888) 532 if (enable_texture_format_bgra8888)
606 validators_.texture_internal_format_storage.AddValue(GL_BGRA8_EXT); 533 validators_.texture_internal_format_storage.AddValue(GL_BGRA8_EXT);
607 if (enable_texture_float) { 534 if (enable_texture_float) {
608 validators_.texture_internal_format_storage.AddValue(GL_RGBA32F_EXT); 535 validators_.texture_internal_format_storage.AddValue(GL_RGBA32F_EXT);
609 validators_.texture_internal_format_storage.AddValue(GL_RGB32F_EXT); 536 validators_.texture_internal_format_storage.AddValue(GL_RGB32F_EXT);
610 validators_.texture_internal_format_storage.AddValue(GL_ALPHA32F_EXT); 537 validators_.texture_internal_format_storage.AddValue(GL_ALPHA32F_EXT);
611 validators_.texture_internal_format_storage.AddValue( 538 validators_.texture_internal_format_storage.AddValue(
612 GL_LUMINANCE32F_EXT); 539 GL_LUMINANCE32F_EXT);
613 validators_.texture_internal_format_storage.AddValue( 540 validators_.texture_internal_format_storage.AddValue(
614 GL_LUMINANCE_ALPHA32F_EXT); 541 GL_LUMINANCE_ALPHA32F_EXT);
615 } 542 }
616 if (enable_texture_half_float) { 543 if (enable_texture_half_float) {
617 validators_.texture_internal_format_storage.AddValue(GL_RGBA16F_EXT); 544 validators_.texture_internal_format_storage.AddValue(GL_RGBA16F_EXT);
618 validators_.texture_internal_format_storage.AddValue(GL_RGB16F_EXT); 545 validators_.texture_internal_format_storage.AddValue(GL_RGB16F_EXT);
619 validators_.texture_internal_format_storage.AddValue(GL_ALPHA16F_EXT); 546 validators_.texture_internal_format_storage.AddValue(GL_ALPHA16F_EXT);
620 validators_.texture_internal_format_storage.AddValue( 547 validators_.texture_internal_format_storage.AddValue(
621 GL_LUMINANCE16F_EXT); 548 GL_LUMINANCE16F_EXT);
622 validators_.texture_internal_format_storage.AddValue( 549 validators_.texture_internal_format_storage.AddValue(
623 GL_LUMINANCE_ALPHA16F_EXT); 550 GL_LUMINANCE_ALPHA16F_EXT);
624 } 551 }
625 } 552 }
626 553
627 bool have_ext_occlusion_query_boolean = 554 bool have_ext_occlusion_query_boolean =
628 ext.Have("GL_EXT_occlusion_query_boolean"); 555 extensions.Contains("GL_EXT_occlusion_query_boolean");
629 bool have_arb_occlusion_query2 = ext.Have("GL_ARB_occlusion_query2"); 556 bool have_arb_occlusion_query2 =
630 bool have_arb_occlusion_query = ext.Have("GL_ARB_occlusion_query"); 557 extensions.Contains("GL_ARB_occlusion_query2");
558 bool have_arb_occlusion_query =
559 extensions.Contains("GL_ARB_occlusion_query");
631 bool ext_occlusion_query_disallowed = false; 560 bool ext_occlusion_query_disallowed = false;
632 561
633 #if defined(OS_LINUX) 562 #if defined(OS_LINUX)
634 if (!feature_flags_.disable_workarounds) { 563 if (!feature_flags_.disable_workarounds) {
635 // Intel drivers on Linux appear to be buggy. 564 // Intel drivers on Linux appear to be buggy.
636 ext_occlusion_query_disallowed = is_intel; 565 ext_occlusion_query_disallowed = is_intel;
637 } 566 }
638 #endif 567 #endif
639 568
640 if (!ext_occlusion_query_disallowed && 569 if (!ext_occlusion_query_disallowed &&
641 ext.Desire("GL_EXT_occlusion_query_boolean") &&
642 (have_ext_occlusion_query_boolean || 570 (have_ext_occlusion_query_boolean ||
643 have_arb_occlusion_query2 || 571 have_arb_occlusion_query2 ||
644 have_arb_occlusion_query)) { 572 have_arb_occlusion_query)) {
645 AddExtensionString("GL_EXT_occlusion_query_boolean"); 573 AddExtensionString("GL_EXT_occlusion_query_boolean");
646 feature_flags_.occlusion_query_boolean = true; 574 feature_flags_.occlusion_query_boolean = true;
647 feature_flags_.use_arb_occlusion_query2_for_occlusion_query_boolean = 575 feature_flags_.use_arb_occlusion_query2_for_occlusion_query_boolean =
648 !have_ext_occlusion_query_boolean && have_arb_occlusion_query2; 576 !have_ext_occlusion_query_boolean && have_arb_occlusion_query2;
649 feature_flags_.use_arb_occlusion_query_for_occlusion_query_boolean = 577 feature_flags_.use_arb_occlusion_query_for_occlusion_query_boolean =
650 !have_ext_occlusion_query_boolean && have_arb_occlusion_query && 578 !have_ext_occlusion_query_boolean && have_arb_occlusion_query &&
651 !have_arb_occlusion_query2; 579 !have_arb_occlusion_query2;
652 } 580 }
653 581
654 if (ext.Desire("GL_ANGLE_instanced_arrays") && 582 if (extensions.Contains("GL_ANGLE_instanced_arrays") ||
655 (ext.Have("GL_ANGLE_instanced_arrays") || 583 (extensions.Contains("GL_ARB_instanced_arrays") &&
656 (ext.Have("GL_ARB_instanced_arrays") && 584 extensions.Contains("GL_ARB_draw_instanced"))) {
657 ext.Have("GL_ARB_draw_instanced")))) {
658 AddExtensionString("GL_ANGLE_instanced_arrays"); 585 AddExtensionString("GL_ANGLE_instanced_arrays");
659 feature_flags_.angle_instanced_arrays = true; 586 feature_flags_.angle_instanced_arrays = true;
660 validators_.vertex_attribute.AddValue(GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE); 587 validators_.vertex_attribute.AddValue(GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE);
661 } 588 }
662 589
663 if (!disallowed_features_.swap_buffer_complete_callback) 590 if (!disallowed_features_.swap_buffer_complete_callback)
664 AddExtensionString("GL_CHROMIUM_swapbuffers_complete_callback"); 591 AddExtensionString("GL_CHROMIUM_swapbuffers_complete_callback");
665 592
666 if (!feature_flags_.disable_workarounds) { 593 if (!feature_flags_.disable_workarounds) {
667 workarounds_.set_texture_filter_before_generating_mipmap = true; 594 workarounds_.set_texture_filter_before_generating_mipmap = true;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 if (extensions_.find(str) == std::string::npos) { 636 if (extensions_.find(str) == std::string::npos) {
710 extensions_ += (extensions_.empty() ? "" : " ") + str; 637 extensions_ += (extensions_.empty() ? "" : " ") + str;
711 } 638 }
712 } 639 }
713 640
714 FeatureInfo::~FeatureInfo() { 641 FeatureInfo::~FeatureInfo() {
715 } 642 }
716 643
717 } // namespace gles2 644 } // namespace gles2
718 } // namespace gpu 645 } // 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