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
3 // found in the LICENSE file.
5 #include "gpu/command_buffer/service/feature_info.h"
9 #include "base/command_line.h"
10 #include "base/macros.h"
11 #include "base/metrics/histogram.h"
12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_split.h"
14 #include "base/strings/string_util.h"
15 #include "gpu/command_buffer/service/gl_utils.h"
16 #include "gpu/command_buffer/service/gpu_switches.h"
17 #include "ui/gl/gl_fence.h"
18 #include "ui/gl/gl_implementation.h"
20 #if !defined(OS_MACOSX)
21 #include "ui/gl/gl_fence_egl.h"
39 StringSet(const char* s
) {
43 StringSet(const std::string
& str
) {
47 void Init(const char* s
) {
48 std::string
str(s
? s
: "");
52 void Init(const std::string
& str
) {
53 std::vector
<std::string
> tokens
;
54 Tokenize(str
, " ", &tokens
);
55 string_set_
.insert(tokens
.begin(), tokens
.end());
58 bool Contains(const char* s
) {
59 return string_set_
.find(s
) != string_set_
.end();
62 bool Contains(const std::string
& s
) {
63 return string_set_
.find(s
) != string_set_
.end();
67 std::set
<std::string
> string_set_
;
70 // Process a string of wordaround type IDs (seperated by ',') and set up
71 // the corresponding Workaround flags.
72 void StringToWorkarounds(
73 const std::string
& types
, FeatureInfo::Workarounds
* workarounds
) {
75 std::vector
<std::string
> pieces
;
76 base::SplitString(types
, ',', &pieces
);
77 for (size_t i
= 0; i
< pieces
.size(); ++i
) {
79 bool succeed
= base::StringToInt(pieces
[i
], &number
);
82 #define GPU_OP(type, name) \
84 workarounds->name = true; \
86 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP
)
92 if (workarounds
->max_texture_size_limit_4096
)
93 workarounds
->max_texture_size
= 4096;
94 if (workarounds
->max_cube_map_texture_size_limit_4096
)
95 workarounds
->max_cube_map_texture_size
= 4096;
96 if (workarounds
->max_cube_map_texture_size_limit_1024
)
97 workarounds
->max_cube_map_texture_size
= 1024;
98 if (workarounds
->max_cube_map_texture_size_limit_512
)
99 workarounds
->max_cube_map_texture_size
= 512;
101 if (workarounds
->max_fragment_uniform_vectors_32
)
102 workarounds
->max_fragment_uniform_vectors
= 32;
103 if (workarounds
->max_varying_vectors_16
)
104 workarounds
->max_varying_vectors
= 16;
105 if (workarounds
->max_vertex_uniform_vectors_256
)
106 workarounds
->max_vertex_uniform_vectors
= 256;
109 } // anonymous namespace.
111 FeatureInfo::FeatureFlags::FeatureFlags()
112 : chromium_color_buffer_float_rgba(false),
113 chromium_color_buffer_float_rgb(false),
114 chromium_framebuffer_multisample(false),
115 chromium_sync_query(false),
116 use_core_framebuffer_multisample(false),
117 multisampled_render_to_texture(false),
118 use_img_for_multisampled_render_to_texture(false),
119 oes_standard_derivatives(false),
120 oes_egl_image_external(false),
122 oes_compressed_etc1_rgb8_texture(false),
123 packed_depth24_stencil8(false),
125 enable_texture_float_linear(false),
126 enable_texture_half_float_linear(false),
127 angle_translated_shader_source(false),
128 angle_pack_reverse_row_order(false),
129 arb_texture_rectangle(false),
130 angle_instanced_arrays(false),
131 occlusion_query_boolean(false),
132 use_arb_occlusion_query2_for_occlusion_query_boolean(false),
133 use_arb_occlusion_query_for_occlusion_query_boolean(false),
134 native_vertex_array_object(false),
135 ext_texture_format_atc(false),
136 ext_texture_format_bgra8888(false),
137 ext_texture_format_dxt1(false),
138 ext_texture_format_dxt5(false),
139 enable_shader_name_hashing(false),
140 enable_samplers(false),
141 ext_draw_buffers(false),
142 nv_draw_buffers(false),
143 ext_frag_depth(false),
144 ext_shader_texture_lod(false),
145 use_async_readpixels(false),
146 map_buffer_range(false),
147 ext_discard_framebuffer(false),
148 angle_depth_texture(false),
149 is_swiftshader(false),
150 angle_texture_usage(false),
151 ext_texture_storage(false),
152 chromium_path_rendering(false),
153 blend_equation_advanced(false),
154 blend_equation_advanced_coherent(false),
155 ext_texture_rg(false),
156 enable_subscribe_uniform(false) {
159 FeatureInfo::Workarounds::Workarounds() :
160 #define GPU_OP(type, name) name(false),
161 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP
)
164 max_cube_map_texture_size(0),
165 max_fragment_uniform_vectors(0),
166 max_varying_vectors(0),
167 max_vertex_uniform_vectors(0) {
170 FeatureInfo::FeatureInfo() {
171 InitializeBasicState(*base::CommandLine::ForCurrentProcess());
174 FeatureInfo::FeatureInfo(const base::CommandLine
& command_line
) {
175 InitializeBasicState(command_line
);
178 void FeatureInfo::InitializeBasicState(const base::CommandLine
& command_line
) {
179 if (command_line
.HasSwitch(switches::kGpuDriverBugWorkarounds
)) {
180 std::string types
= command_line
.GetSwitchValueASCII(
181 switches::kGpuDriverBugWorkarounds
);
182 StringToWorkarounds(types
, &workarounds_
);
184 feature_flags_
.enable_shader_name_hashing
=
185 !command_line
.HasSwitch(switches::kDisableShaderNameHashing
);
187 feature_flags_
.is_swiftshader
=
188 (command_line
.GetSwitchValueASCII(switches::kUseGL
) == "swiftshader");
190 feature_flags_
.enable_subscribe_uniform
=
191 command_line
.HasSwitch(switches::kEnableSubscribeUniformExtension
);
193 static const GLenum kAlphaTypes
[] = {
196 static const GLenum kRGBTypes
[] = {
198 GL_UNSIGNED_SHORT_5_6_5
,
200 static const GLenum kRGBATypes
[] = {
202 GL_UNSIGNED_SHORT_4_4_4_4
,
203 GL_UNSIGNED_SHORT_5_5_5_1
,
205 static const GLenum kLuminanceTypes
[] = {
208 static const GLenum kLuminanceAlphaTypes
[] = {
211 static const FormatInfo kFormatTypes
[] = {
212 { GL_ALPHA
, kAlphaTypes
, arraysize(kAlphaTypes
), },
213 { GL_RGB
, kRGBTypes
, arraysize(kRGBTypes
), },
214 { GL_RGBA
, kRGBATypes
, arraysize(kRGBATypes
), },
215 { GL_LUMINANCE
, kLuminanceTypes
, arraysize(kLuminanceTypes
), },
216 { GL_LUMINANCE_ALPHA
, kLuminanceAlphaTypes
,
217 arraysize(kLuminanceAlphaTypes
), } ,
219 for (size_t ii
= 0; ii
< arraysize(kFormatTypes
); ++ii
) {
220 const FormatInfo
& info
= kFormatTypes
[ii
];
221 ValueValidator
<GLenum
>& validator
= texture_format_validators_
[info
.format
];
222 for (size_t jj
= 0; jj
< info
.count
; ++jj
) {
223 validator
.AddValue(info
.types
[jj
]);
228 bool FeatureInfo::Initialize() {
229 disallowed_features_
= DisallowedFeatures();
230 InitializeFeatures();
234 bool FeatureInfo::Initialize(const DisallowedFeatures
& disallowed_features
) {
235 disallowed_features_
= disallowed_features
;
236 InitializeFeatures();
240 bool IsGL_REDSupportedOnFBOs() {
241 // Skia uses GL_RED with frame buffers, unfortunately, Mesa claims to support
242 // GL_EXT_texture_rg, but it doesn't support it on frame buffers. To fix
243 // this, we try it, and if it fails, we don't expose GL_EXT_texture_rg.
244 GLint fb_binding
= 0;
245 GLint tex_binding
= 0;
246 glGetIntegerv(GL_FRAMEBUFFER_BINDING
, &fb_binding
);
247 glGetIntegerv(GL_TEXTURE_BINDING_2D
, &tex_binding
);
249 GLuint textureId
= 0;
250 glGenTextures(1, &textureId
);
251 glBindTexture(GL_TEXTURE_2D
, textureId
);
252 GLubyte data
[1] = {0};
253 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RED_EXT
, 1, 1, 0, GL_RED_EXT
,
254 GL_UNSIGNED_BYTE
, data
);
255 GLuint textureFBOID
= 0;
256 glGenFramebuffersEXT(1, &textureFBOID
);
257 glBindFramebufferEXT(GL_FRAMEBUFFER
, textureFBOID
);
258 glFramebufferTexture2DEXT(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
,
261 glCheckFramebufferStatusEXT(GL_FRAMEBUFFER
) != GL_FRAMEBUFFER_UNSUPPORTED
;
262 glDeleteFramebuffersEXT(1, &textureFBOID
);
263 glDeleteTextures(1, &textureId
);
265 glBindFramebufferEXT(GL_FRAMEBUFFER
, static_cast<GLuint
>(fb_binding
));
266 glBindTexture(GL_TEXTURE_2D
, static_cast<GLuint
>(tex_binding
));
268 DCHECK(glGetError() == GL_NO_ERROR
);
273 void FeatureInfo::InitializeFeatures() {
274 // Figure out what extensions to turn on.
275 StringSet
extensions(
276 reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS
)));
278 const char* renderer_str
=
279 reinterpret_cast<const char*>(glGetString(GL_RENDERER
));
280 const char* version_str
=
281 reinterpret_cast<const char*>(glGetString(GL_VERSION
));
283 gl_version_info_
.reset(new gfx::GLVersionInfo(version_str
, renderer_str
));
285 AddExtensionString("GL_ANGLE_translated_shader_source");
286 AddExtensionString("GL_CHROMIUM_async_pixel_transfers");
287 AddExtensionString("GL_CHROMIUM_bind_uniform_location");
288 AddExtensionString("GL_CHROMIUM_command_buffer_query");
289 AddExtensionString("GL_CHROMIUM_command_buffer_latency_query");
290 AddExtensionString("GL_CHROMIUM_copy_texture");
291 AddExtensionString("GL_CHROMIUM_get_error_query");
292 AddExtensionString("GL_CHROMIUM_lose_context");
293 AddExtensionString("GL_CHROMIUM_pixel_transfer_buffer_object");
294 AddExtensionString("GL_CHROMIUM_rate_limit_offscreen_context");
295 AddExtensionString("GL_CHROMIUM_resize");
296 AddExtensionString("GL_CHROMIUM_resource_safe");
297 AddExtensionString("GL_CHROMIUM_strict_attribs");
298 AddExtensionString("GL_CHROMIUM_texture_mailbox");
299 AddExtensionString("GL_CHROMIUM_trace_marker");
300 AddExtensionString("GL_EXT_debug_marker");
302 if (feature_flags_
.enable_subscribe_uniform
) {
303 AddExtensionString("GL_CHROMIUM_subscribe_uniform");
306 // OES_vertex_array_object is emulated if not present natively,
307 // so the extension string is always exposed.
308 AddExtensionString("GL_OES_vertex_array_object");
310 if (!disallowed_features_
.gpu_memory_manager
)
311 AddExtensionString("GL_CHROMIUM_gpu_memory_manager");
313 if (extensions
.Contains("GL_ANGLE_translated_shader_source")) {
314 feature_flags_
.angle_translated_shader_source
= true;
317 // Check if we should allow GL_EXT_texture_compression_dxt1 and
318 // GL_EXT_texture_compression_s3tc.
319 bool enable_dxt1
= false;
320 bool enable_dxt3
= false;
321 bool enable_dxt5
= false;
322 bool have_s3tc
= extensions
.Contains("GL_EXT_texture_compression_s3tc");
324 have_s3tc
|| extensions
.Contains("GL_ANGLE_texture_compression_dxt3");
326 have_s3tc
|| extensions
.Contains("GL_ANGLE_texture_compression_dxt5");
328 if (extensions
.Contains("GL_EXT_texture_compression_dxt1") || have_s3tc
) {
339 feature_flags_
.ext_texture_format_dxt1
= true;
341 AddExtensionString("GL_EXT_texture_compression_dxt1");
342 validators_
.compressed_texture_format
.AddValue(
343 GL_COMPRESSED_RGB_S3TC_DXT1_EXT
);
344 validators_
.compressed_texture_format
.AddValue(
345 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
);
349 // The difference between GL_EXT_texture_compression_s3tc and
350 // GL_CHROMIUM_texture_compression_dxt3 is that the former
351 // requires on the fly compression. The latter does not.
352 AddExtensionString("GL_CHROMIUM_texture_compression_dxt3");
353 validators_
.compressed_texture_format
.AddValue(
354 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
);
358 feature_flags_
.ext_texture_format_dxt5
= true;
360 // The difference between GL_EXT_texture_compression_s3tc and
361 // GL_CHROMIUM_texture_compression_dxt5 is that the former
362 // requires on the fly compression. The latter does not.
363 AddExtensionString("GL_CHROMIUM_texture_compression_dxt5");
364 validators_
.compressed_texture_format
.AddValue(
365 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
);
368 bool have_atc
= extensions
.Contains("GL_AMD_compressed_ATC_texture") ||
369 extensions
.Contains("GL_ATI_texture_compression_atitc");
371 feature_flags_
.ext_texture_format_atc
= true;
373 AddExtensionString("GL_AMD_compressed_ATC_texture");
374 validators_
.compressed_texture_format
.AddValue(GL_ATC_RGB_AMD
);
375 validators_
.compressed_texture_format
.AddValue(
376 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD
);
379 // Check if we should enable GL_EXT_texture_filter_anisotropic.
380 if (extensions
.Contains("GL_EXT_texture_filter_anisotropic")) {
381 AddExtensionString("GL_EXT_texture_filter_anisotropic");
382 validators_
.texture_parameter
.AddValue(
383 GL_TEXTURE_MAX_ANISOTROPY_EXT
);
384 validators_
.g_l_state
.AddValue(
385 GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
);
388 // Check if we should support GL_OES_packed_depth_stencil and/or
389 // GL_GOOGLE_depth_texture / GL_CHROMIUM_depth_texture.
391 // NOTE: GL_OES_depth_texture requires support for depth cubemaps.
392 // GL_ARB_depth_texture requires other features that
393 // GL_OES_packed_depth_stencil does not provide.
395 // Therefore we made up GL_GOOGLE_depth_texture / GL_CHROMIUM_depth_texture.
397 // GL_GOOGLE_depth_texture is legacy. As we exposed it into NaCl we can't
400 bool enable_depth_texture
= false;
401 if (!workarounds_
.disable_depth_texture
&&
402 (extensions
.Contains("GL_ARB_depth_texture") ||
403 extensions
.Contains("GL_OES_depth_texture") ||
404 extensions
.Contains("GL_ANGLE_depth_texture") ||
405 gl_version_info_
->is_es3
)) {
406 enable_depth_texture
= true;
407 feature_flags_
.angle_depth_texture
=
408 extensions
.Contains("GL_ANGLE_depth_texture");
411 if (enable_depth_texture
) {
412 AddExtensionString("GL_CHROMIUM_depth_texture");
413 AddExtensionString("GL_GOOGLE_depth_texture");
414 texture_format_validators_
[GL_DEPTH_COMPONENT
].AddValue(GL_UNSIGNED_SHORT
);
415 texture_format_validators_
[GL_DEPTH_COMPONENT
].AddValue(GL_UNSIGNED_INT
);
416 validators_
.texture_internal_format
.AddValue(GL_DEPTH_COMPONENT
);
417 validators_
.texture_format
.AddValue(GL_DEPTH_COMPONENT
);
418 validators_
.pixel_type
.AddValue(GL_UNSIGNED_SHORT
);
419 validators_
.pixel_type
.AddValue(GL_UNSIGNED_INT
);
422 if (extensions
.Contains("GL_EXT_packed_depth_stencil") ||
423 extensions
.Contains("GL_OES_packed_depth_stencil") ||
424 gl_version_info_
->is_es3
) {
425 AddExtensionString("GL_OES_packed_depth_stencil");
426 feature_flags_
.packed_depth24_stencil8
= true;
427 if (enable_depth_texture
) {
428 texture_format_validators_
[GL_DEPTH_STENCIL
]
429 .AddValue(GL_UNSIGNED_INT_24_8
);
430 validators_
.texture_internal_format
.AddValue(GL_DEPTH_STENCIL
);
431 validators_
.texture_format
.AddValue(GL_DEPTH_STENCIL
);
432 validators_
.pixel_type
.AddValue(GL_UNSIGNED_INT_24_8
);
434 validators_
.render_buffer_format
.AddValue(GL_DEPTH24_STENCIL8
);
437 if (gl_version_info_
->is_es3
||
438 extensions
.Contains("GL_OES_vertex_array_object") ||
439 extensions
.Contains("GL_ARB_vertex_array_object") ||
440 extensions
.Contains("GL_APPLE_vertex_array_object")) {
441 feature_flags_
.native_vertex_array_object
= true;
444 // If we're using client_side_arrays we have to emulate
445 // vertex array objects since vertex array objects do not work
446 // with client side arrays.
447 if (workarounds_
.use_client_side_arrays_for_stream_buffers
) {
448 feature_flags_
.native_vertex_array_object
= false;
451 if (gl_version_info_
->is_es3
||
452 extensions
.Contains("GL_OES_element_index_uint") ||
453 gfx::HasDesktopGLFeatures()) {
454 AddExtensionString("GL_OES_element_index_uint");
455 validators_
.index_type
.AddValue(GL_UNSIGNED_INT
);
458 // With EXT_sRGB, unsized SRGB_EXT and SRGB_ALPHA_EXT are accepted by the
459 // <format> and <internalformat> parameter of TexImage2D. GLES3 adds support
460 // for SRGB Textures but the accepted internal formats for TexImage2D are only
461 // sized formats GL_SRGB8 and GL_SRGB8_ALPHA8. Also, SRGB_EXT isn't a valid
462 // <format> in this case. So, even with GLES3 explicitly check for
464 if (((gl_version_info_
->is_es3
||
465 extensions
.Contains("GL_OES_rgb8_rgba8")) &&
466 extensions
.Contains("GL_EXT_sRGB")) || gfx::HasDesktopGLFeatures()) {
467 AddExtensionString("GL_EXT_sRGB");
468 texture_format_validators_
[GL_SRGB_EXT
].AddValue(GL_UNSIGNED_BYTE
);
469 texture_format_validators_
[GL_SRGB_ALPHA_EXT
].AddValue(GL_UNSIGNED_BYTE
);
470 validators_
.texture_internal_format
.AddValue(GL_SRGB_EXT
);
471 validators_
.texture_internal_format
.AddValue(GL_SRGB_ALPHA_EXT
);
472 validators_
.texture_format
.AddValue(GL_SRGB_EXT
);
473 validators_
.texture_format
.AddValue(GL_SRGB_ALPHA_EXT
);
474 validators_
.render_buffer_format
.AddValue(GL_SRGB8_ALPHA8_EXT
);
475 validators_
.frame_buffer_parameter
.AddValue(
476 GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT
);
479 bool enable_texture_format_bgra8888
= false;
480 bool enable_read_format_bgra
= false;
481 bool enable_render_buffer_bgra
= false;
482 bool enable_immutable_texture_format_bgra_on_es3
=
483 extensions
.Contains("GL_APPLE_texture_format_BGRA8888");
485 // Check if we should allow GL_EXT_texture_format_BGRA8888
486 if (extensions
.Contains("GL_EXT_texture_format_BGRA8888") ||
487 enable_immutable_texture_format_bgra_on_es3
||
488 extensions
.Contains("GL_EXT_bgra")) {
489 enable_texture_format_bgra8888
= true;
492 // Only desktop GL extension GL_EXT_bgra or ANGLE guarantee that we can
493 // allocate a renderbuffer with this format.
494 if (extensions
.Contains("GL_EXT_bgra") || gl_version_info_
->is_angle
) {
495 enable_render_buffer_bgra
= true;
498 if (extensions
.Contains("GL_EXT_read_format_bgra") ||
499 extensions
.Contains("GL_EXT_bgra")) {
500 enable_read_format_bgra
= true;
503 if (enable_texture_format_bgra8888
) {
504 feature_flags_
.ext_texture_format_bgra8888
= true;
505 AddExtensionString("GL_EXT_texture_format_BGRA8888");
506 texture_format_validators_
[GL_BGRA_EXT
].AddValue(GL_UNSIGNED_BYTE
);
507 validators_
.texture_internal_format
.AddValue(GL_BGRA_EXT
);
508 validators_
.texture_format
.AddValue(GL_BGRA_EXT
);
511 if (enable_read_format_bgra
) {
512 AddExtensionString("GL_EXT_read_format_bgra");
513 validators_
.read_pixel_format
.AddValue(GL_BGRA_EXT
);
516 if (enable_render_buffer_bgra
) {
517 AddExtensionString("GL_CHROMIUM_renderbuffer_format_BGRA8888");
518 validators_
.render_buffer_format
.AddValue(GL_BGRA8_EXT
);
521 if (extensions
.Contains("GL_OES_rgb8_rgba8") || gfx::HasDesktopGLFeatures()) {
522 AddExtensionString("GL_OES_rgb8_rgba8");
523 validators_
.render_buffer_format
.AddValue(GL_RGB8_OES
);
524 validators_
.render_buffer_format
.AddValue(GL_RGBA8_OES
);
527 // Check if we should allow GL_OES_texture_npot
528 if (gl_version_info_
->is_es3
||
529 extensions
.Contains("GL_ARB_texture_non_power_of_two") ||
530 extensions
.Contains("GL_OES_texture_npot")) {
531 AddExtensionString("GL_OES_texture_npot");
532 feature_flags_
.npot_ok
= true;
535 // Check if we should allow GL_OES_texture_float, GL_OES_texture_half_float,
536 // GL_OES_texture_float_linear, GL_OES_texture_half_float_linear
537 bool enable_texture_float
= false;
538 bool enable_texture_float_linear
= false;
539 bool enable_texture_half_float
= false;
540 bool enable_texture_half_float_linear
= false;
542 bool may_enable_chromium_color_buffer_float
= false;
544 if (extensions
.Contains("GL_ARB_texture_float")) {
545 enable_texture_float
= true;
546 enable_texture_float_linear
= true;
547 enable_texture_half_float
= true;
548 enable_texture_half_float_linear
= true;
549 may_enable_chromium_color_buffer_float
= true;
551 // GLES3 adds support for Float type by default but it doesn't support all
552 // formats as GL_OES_texture_float(i.e.LUMINANCE_ALPHA,LUMINANCE and Alpha)
553 if (extensions
.Contains("GL_OES_texture_float")) {
554 enable_texture_float
= true;
555 if (extensions
.Contains("GL_OES_texture_float_linear")) {
556 enable_texture_float_linear
= true;
558 // This extension allows a variety of floating point formats to be
559 // rendered to via framebuffer objects. Enable it's usage only if
560 // support for Floating textures is enabled.
561 if ((gl_version_info_
->is_es3
&&
562 extensions
.Contains("GL_EXT_color_buffer_float")) ||
563 gl_version_info_
->is_angle
) {
564 may_enable_chromium_color_buffer_float
= true;
568 // TODO(dshwang): GLES3 supports half float by default but GL_HALF_FLOAT_OES
569 // isn't equal to GL_HALF_FLOAT.
570 if (extensions
.Contains("GL_OES_texture_half_float")) {
571 enable_texture_half_float
= true;
572 if (extensions
.Contains("GL_OES_texture_half_float_linear")) {
573 enable_texture_half_float_linear
= true;
578 if (enable_texture_float
) {
579 texture_format_validators_
[GL_ALPHA
].AddValue(GL_FLOAT
);
580 texture_format_validators_
[GL_RGB
].AddValue(GL_FLOAT
);
581 texture_format_validators_
[GL_RGBA
].AddValue(GL_FLOAT
);
582 texture_format_validators_
[GL_LUMINANCE
].AddValue(GL_FLOAT
);
583 texture_format_validators_
[GL_LUMINANCE_ALPHA
].AddValue(GL_FLOAT
);
584 validators_
.pixel_type
.AddValue(GL_FLOAT
);
585 validators_
.read_pixel_type
.AddValue(GL_FLOAT
);
586 AddExtensionString("GL_OES_texture_float");
587 if (enable_texture_float_linear
) {
588 AddExtensionString("GL_OES_texture_float_linear");
592 if (enable_texture_half_float
) {
593 texture_format_validators_
[GL_ALPHA
].AddValue(GL_HALF_FLOAT_OES
);
594 texture_format_validators_
[GL_RGB
].AddValue(GL_HALF_FLOAT_OES
);
595 texture_format_validators_
[GL_RGBA
].AddValue(GL_HALF_FLOAT_OES
);
596 texture_format_validators_
[GL_LUMINANCE
].AddValue(GL_HALF_FLOAT_OES
);
597 texture_format_validators_
[GL_LUMINANCE_ALPHA
].AddValue(GL_HALF_FLOAT_OES
);
598 validators_
.pixel_type
.AddValue(GL_HALF_FLOAT_OES
);
599 validators_
.read_pixel_type
.AddValue(GL_HALF_FLOAT_OES
);
600 AddExtensionString("GL_OES_texture_half_float");
601 if (enable_texture_half_float_linear
) {
602 AddExtensionString("GL_OES_texture_half_float_linear");
606 if (may_enable_chromium_color_buffer_float
) {
607 static_assert(GL_RGBA32F_ARB
== GL_RGBA32F
&&
608 GL_RGBA32F_EXT
== GL_RGBA32F
&&
609 GL_RGB32F_ARB
== GL_RGB32F
&&
610 GL_RGB32F_EXT
== GL_RGB32F
,
611 "sized float internal format variations must match");
612 // We don't check extension support beyond ARB_texture_float on desktop GL,
613 // and format support varies between GL configurations. For example, spec
614 // prior to OpenGL 3.0 mandates framebuffer support only for one
615 // implementation-chosen format, and ES3.0 EXT_color_buffer_float does not
616 // support rendering to RGB32F. Check for framebuffer completeness with
617 // formats that the extensions expose, and only enable an extension when a
618 // framebuffer created with its texture format is reported as complete.
619 GLint fb_binding
= 0;
620 GLint tex_binding
= 0;
621 glGetIntegerv(GL_FRAMEBUFFER_BINDING
, &fb_binding
);
622 glGetIntegerv(GL_TEXTURE_BINDING_2D
, &tex_binding
);
628 glGenTextures(1, &tex_id
);
629 glGenFramebuffersEXT(1, &fb_id
);
630 glBindTexture(GL_TEXTURE_2D
, tex_id
);
631 // Nearest filter needed for framebuffer completeness on some drivers.
632 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
633 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA32F
, width
, width
, 0, GL_RGBA
,
635 glBindFramebufferEXT(GL_FRAMEBUFFER
, fb_id
);
636 glFramebufferTexture2DEXT(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
,
637 GL_TEXTURE_2D
, tex_id
, 0);
638 GLenum statusRGBA
= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER
);
639 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGB32F
, width
, width
, 0, GL_RGB
,
641 GLenum statusRGB
= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER
);
642 glDeleteFramebuffersEXT(1, &fb_id
);
643 glDeleteTextures(1, &tex_id
);
645 glBindFramebufferEXT(GL_FRAMEBUFFER
, static_cast<GLuint
>(fb_binding
));
646 glBindTexture(GL_TEXTURE_2D
, static_cast<GLuint
>(tex_binding
));
648 DCHECK(glGetError() == GL_NO_ERROR
);
650 if (statusRGBA
== GL_FRAMEBUFFER_COMPLETE
) {
651 validators_
.texture_internal_format
.AddValue(GL_RGBA32F
);
652 feature_flags_
.chromium_color_buffer_float_rgba
= true;
653 AddExtensionString("GL_CHROMIUM_color_buffer_float_rgba");
655 if (statusRGB
== GL_FRAMEBUFFER_COMPLETE
) {
656 validators_
.texture_internal_format
.AddValue(GL_RGB32F
);
657 feature_flags_
.chromium_color_buffer_float_rgb
= true;
658 AddExtensionString("GL_CHROMIUM_color_buffer_float_rgb");
662 // Check for multisample support
663 if (!workarounds_
.disable_multisampling
) {
664 bool ext_has_multisample
=
665 extensions
.Contains("GL_EXT_framebuffer_multisample") ||
666 gl_version_info_
->is_es3
;
667 if (gl_version_info_
->is_angle
) {
668 ext_has_multisample
|=
669 extensions
.Contains("GL_ANGLE_framebuffer_multisample");
671 feature_flags_
.use_core_framebuffer_multisample
= gl_version_info_
->is_es3
;
672 if (ext_has_multisample
) {
673 feature_flags_
.chromium_framebuffer_multisample
= true;
674 validators_
.frame_buffer_target
.AddValue(GL_READ_FRAMEBUFFER_EXT
);
675 validators_
.frame_buffer_target
.AddValue(GL_DRAW_FRAMEBUFFER_EXT
);
676 validators_
.g_l_state
.AddValue(GL_READ_FRAMEBUFFER_BINDING_EXT
);
677 validators_
.g_l_state
.AddValue(GL_MAX_SAMPLES_EXT
);
678 validators_
.render_buffer_parameter
.AddValue(GL_RENDERBUFFER_SAMPLES_EXT
);
679 AddExtensionString("GL_CHROMIUM_framebuffer_multisample");
681 if (extensions
.Contains("GL_EXT_multisampled_render_to_texture")) {
682 feature_flags_
.multisampled_render_to_texture
= true;
683 } else if (extensions
.Contains("GL_IMG_multisampled_render_to_texture")) {
684 feature_flags_
.multisampled_render_to_texture
= true;
685 feature_flags_
.use_img_for_multisampled_render_to_texture
= true;
687 if (feature_flags_
.multisampled_render_to_texture
) {
688 validators_
.render_buffer_parameter
.AddValue(
689 GL_RENDERBUFFER_SAMPLES_EXT
);
690 validators_
.g_l_state
.AddValue(GL_MAX_SAMPLES_EXT
);
691 validators_
.frame_buffer_parameter
.AddValue(
692 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT
);
693 AddExtensionString("GL_EXT_multisampled_render_to_texture");
697 if (extensions
.Contains("GL_OES_depth24") || gfx::HasDesktopGLFeatures() ||
698 gl_version_info_
->is_es3
) {
699 AddExtensionString("GL_OES_depth24");
700 feature_flags_
.oes_depth24
= true;
701 validators_
.render_buffer_format
.AddValue(GL_DEPTH_COMPONENT24
);
704 if (!workarounds_
.disable_oes_standard_derivatives
&&
705 (gl_version_info_
->is_es3
||
706 extensions
.Contains("GL_OES_standard_derivatives") ||
707 gfx::HasDesktopGLFeatures())) {
708 AddExtensionString("GL_OES_standard_derivatives");
709 feature_flags_
.oes_standard_derivatives
= true;
710 validators_
.hint_target
.AddValue(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES
);
711 validators_
.g_l_state
.AddValue(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES
);
714 if (extensions
.Contains("GL_OES_EGL_image_external")) {
715 AddExtensionString("GL_OES_EGL_image_external");
716 feature_flags_
.oes_egl_image_external
= true;
717 validators_
.texture_bind_target
.AddValue(GL_TEXTURE_EXTERNAL_OES
);
718 validators_
.get_tex_param_target
.AddValue(GL_TEXTURE_EXTERNAL_OES
);
719 validators_
.texture_parameter
.AddValue(GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES
);
720 validators_
.g_l_state
.AddValue(GL_TEXTURE_BINDING_EXTERNAL_OES
);
723 if (extensions
.Contains("GL_OES_compressed_ETC1_RGB8_texture")) {
724 AddExtensionString("GL_OES_compressed_ETC1_RGB8_texture");
725 feature_flags_
.oes_compressed_etc1_rgb8_texture
= true;
726 validators_
.compressed_texture_format
.AddValue(GL_ETC1_RGB8_OES
);
729 if (extensions
.Contains("GL_AMD_compressed_ATC_texture")) {
730 AddExtensionString("GL_AMD_compressed_ATC_texture");
731 validators_
.compressed_texture_format
.AddValue(
733 validators_
.compressed_texture_format
.AddValue(
734 GL_ATC_RGBA_EXPLICIT_ALPHA_AMD
);
735 validators_
.compressed_texture_format
.AddValue(
736 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD
);
739 if (extensions
.Contains("GL_IMG_texture_compression_pvrtc")) {
740 AddExtensionString("GL_IMG_texture_compression_pvrtc");
741 validators_
.compressed_texture_format
.AddValue(
742 GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG
);
743 validators_
.compressed_texture_format
.AddValue(
744 GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG
);
745 validators_
.compressed_texture_format
.AddValue(
746 GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
);
747 validators_
.compressed_texture_format
.AddValue(
748 GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
);
751 // Ideally we would only expose this extension on Mac OS X, to
752 // support GL_CHROMIUM_iosurface and the compositor. We don't want
753 // applications to start using it; they should use ordinary non-
754 // power-of-two textures. However, for unit testing purposes we
755 // expose it on all supported platforms.
756 if (extensions
.Contains("GL_ARB_texture_rectangle")) {
757 AddExtensionString("GL_ARB_texture_rectangle");
758 feature_flags_
.arb_texture_rectangle
= true;
759 validators_
.texture_bind_target
.AddValue(GL_TEXTURE_RECTANGLE_ARB
);
760 // For the moment we don't add this enum to the texture_target
761 // validator. This implies that the only way to get image data into a
762 // rectangular texture is via glTexImageIOSurface2DCHROMIUM, which is
763 // just fine since again we don't want applications depending on this
765 validators_
.get_tex_param_target
.AddValue(GL_TEXTURE_RECTANGLE_ARB
);
766 validators_
.g_l_state
.AddValue(GL_TEXTURE_BINDING_RECTANGLE_ARB
);
769 #if defined(OS_MACOSX)
770 AddExtensionString("GL_CHROMIUM_iosurface");
773 // TODO(gman): Add support for these extensions.
776 feature_flags_
.enable_texture_float_linear
|= enable_texture_float_linear
;
777 feature_flags_
.enable_texture_half_float_linear
|=
778 enable_texture_half_float_linear
;
780 if (extensions
.Contains("GL_ANGLE_pack_reverse_row_order")) {
781 AddExtensionString("GL_ANGLE_pack_reverse_row_order");
782 feature_flags_
.angle_pack_reverse_row_order
= true;
783 validators_
.pixel_store
.AddValue(GL_PACK_REVERSE_ROW_ORDER_ANGLE
);
784 validators_
.g_l_state
.AddValue(GL_PACK_REVERSE_ROW_ORDER_ANGLE
);
787 if (extensions
.Contains("GL_ANGLE_texture_usage")) {
788 feature_flags_
.angle_texture_usage
= true;
789 AddExtensionString("GL_ANGLE_texture_usage");
790 validators_
.texture_parameter
.AddValue(GL_TEXTURE_USAGE_ANGLE
);
793 // Note: Only APPLE_texture_format_BGRA8888 extension allows BGRA8_EXT in
794 // ES3's glTexStorage2D. We prefer support BGRA to texture storage.
795 // So we don't expose GL_EXT_texture_storage when ES3 +
796 // GL_EXT_texture_format_BGRA8888 because we fail the GL_BGRA8 requirement.
797 // However we expose GL_EXT_texture_storage when just ES3 because we don't
798 // claim to handle GL_BGRA8.
799 bool support_texture_storage_on_es3
=
800 (gl_version_info_
->is_es3
&&
801 enable_immutable_texture_format_bgra_on_es3
) ||
802 (gl_version_info_
->is_es3
&&
803 !enable_texture_format_bgra8888
);
804 if (extensions
.Contains("GL_EXT_texture_storage") ||
805 extensions
.Contains("GL_ARB_texture_storage") ||
806 support_texture_storage_on_es3
) {
807 feature_flags_
.ext_texture_storage
= true;
808 AddExtensionString("GL_EXT_texture_storage");
809 validators_
.texture_parameter
.AddValue(GL_TEXTURE_IMMUTABLE_FORMAT_EXT
);
810 if (enable_texture_format_bgra8888
)
811 validators_
.texture_internal_format_storage
.AddValue(GL_BGRA8_EXT
);
812 if (enable_texture_float
) {
813 validators_
.texture_internal_format_storage
.AddValue(GL_RGBA32F_EXT
);
814 validators_
.texture_internal_format_storage
.AddValue(GL_RGB32F_EXT
);
815 validators_
.texture_internal_format_storage
.AddValue(GL_ALPHA32F_EXT
);
816 validators_
.texture_internal_format_storage
.AddValue(
817 GL_LUMINANCE32F_EXT
);
818 validators_
.texture_internal_format_storage
.AddValue(
819 GL_LUMINANCE_ALPHA32F_EXT
);
821 if (enable_texture_half_float
) {
822 validators_
.texture_internal_format_storage
.AddValue(GL_RGBA16F_EXT
);
823 validators_
.texture_internal_format_storage
.AddValue(GL_RGB16F_EXT
);
824 validators_
.texture_internal_format_storage
.AddValue(GL_ALPHA16F_EXT
);
825 validators_
.texture_internal_format_storage
.AddValue(
826 GL_LUMINANCE16F_EXT
);
827 validators_
.texture_internal_format_storage
.AddValue(
828 GL_LUMINANCE_ALPHA16F_EXT
);
832 bool have_ext_occlusion_query_boolean
=
833 extensions
.Contains("GL_EXT_occlusion_query_boolean");
834 bool have_arb_occlusion_query2
=
835 extensions
.Contains("GL_ARB_occlusion_query2");
836 bool have_arb_occlusion_query
=
837 extensions
.Contains("GL_ARB_occlusion_query");
839 if (!workarounds_
.disable_ext_occlusion_query
&&
840 (have_ext_occlusion_query_boolean
||
841 have_arb_occlusion_query2
||
842 have_arb_occlusion_query
)) {
843 AddExtensionString("GL_EXT_occlusion_query_boolean");
844 feature_flags_
.occlusion_query_boolean
= true;
845 feature_flags_
.use_arb_occlusion_query2_for_occlusion_query_boolean
=
846 !have_ext_occlusion_query_boolean
&& have_arb_occlusion_query2
;
847 feature_flags_
.use_arb_occlusion_query_for_occlusion_query_boolean
=
848 !have_ext_occlusion_query_boolean
&& have_arb_occlusion_query
&&
849 !have_arb_occlusion_query2
;
852 if (!workarounds_
.disable_angle_instanced_arrays
&&
853 (extensions
.Contains("GL_ANGLE_instanced_arrays") ||
854 (extensions
.Contains("GL_ARB_instanced_arrays") &&
855 extensions
.Contains("GL_ARB_draw_instanced")) ||
856 gl_version_info_
->is_es3
)) {
857 AddExtensionString("GL_ANGLE_instanced_arrays");
858 feature_flags_
.angle_instanced_arrays
= true;
859 validators_
.vertex_attribute
.AddValue(GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE
);
862 bool vendor_agnostic_draw_buffers
=
863 extensions
.Contains("GL_ARB_draw_buffers") ||
864 extensions
.Contains("GL_EXT_draw_buffers");
865 if (!workarounds_
.disable_ext_draw_buffers
&&
866 (vendor_agnostic_draw_buffers
||
867 (extensions
.Contains("GL_NV_draw_buffers") &&
868 gl_version_info_
->is_es3
))) {
869 AddExtensionString("GL_EXT_draw_buffers");
870 feature_flags_
.ext_draw_buffers
= true;
872 // This flag is set to enable emulation of EXT_draw_buffers when we're
873 // running on GLES 3.0+, NV_draw_buffers extension is supported and
874 // glDrawBuffers from GLES 3.0 core has been bound. It toggles using the
875 // NV_draw_buffers extension directive instead of EXT_draw_buffers extension
876 // directive in ESSL 100 shaders translated by ANGLE, enabling them to write
877 // into multiple gl_FragData values, which is not by default possible in
878 // ESSL 100 with core GLES 3.0. For more information, see the
879 // NV_draw_buffers specification.
880 feature_flags_
.nv_draw_buffers
= !vendor_agnostic_draw_buffers
;
882 GLint max_color_attachments
= 0;
883 glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT
, &max_color_attachments
);
884 for (GLenum i
= GL_COLOR_ATTACHMENT1_EXT
;
885 i
< static_cast<GLenum
>(GL_COLOR_ATTACHMENT0
+ max_color_attachments
);
887 validators_
.attachment
.AddValue(i
);
889 static_assert(GL_COLOR_ATTACHMENT0_EXT
== GL_COLOR_ATTACHMENT0
,
890 "GL_COLOR_ATTACHMENT0_EXT should equal GL_COLOR_ATTACHMENT0");
892 validators_
.g_l_state
.AddValue(GL_MAX_COLOR_ATTACHMENTS_EXT
);
893 validators_
.g_l_state
.AddValue(GL_MAX_DRAW_BUFFERS_ARB
);
894 GLint max_draw_buffers
= 0;
895 glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB
, &max_draw_buffers
);
896 for (GLenum i
= GL_DRAW_BUFFER0_ARB
;
897 i
< static_cast<GLenum
>(GL_DRAW_BUFFER0_ARB
+ max_draw_buffers
);
899 validators_
.g_l_state
.AddValue(i
);
903 if (gl_version_info_
->is_es3
||
904 extensions
.Contains("GL_EXT_blend_minmax") ||
905 gfx::HasDesktopGLFeatures()) {
906 AddExtensionString("GL_EXT_blend_minmax");
907 validators_
.equation
.AddValue(GL_MIN_EXT
);
908 validators_
.equation
.AddValue(GL_MAX_EXT
);
909 static_assert(GL_MIN_EXT
== GL_MIN
&& GL_MAX_EXT
== GL_MAX
,
910 "min & max variations must match");
913 // TODO(dshwang): GLES3 supports gl_FragDepth, not gl_FragDepthEXT.
914 if (extensions
.Contains("GL_EXT_frag_depth") || gfx::HasDesktopGLFeatures()) {
915 AddExtensionString("GL_EXT_frag_depth");
916 feature_flags_
.ext_frag_depth
= true;
919 if (extensions
.Contains("GL_EXT_shader_texture_lod") ||
920 gfx::HasDesktopGLFeatures()) {
921 AddExtensionString("GL_EXT_shader_texture_lod");
922 feature_flags_
.ext_shader_texture_lod
= true;
925 #if !defined(OS_MACOSX)
926 if (workarounds_
.disable_egl_khr_fence_sync
) {
927 gfx::g_driver_egl
.ext
.b_EGL_KHR_fence_sync
= false;
929 if (workarounds_
.disable_egl_khr_wait_sync
) {
930 gfx::g_driver_egl
.ext
.b_EGL_KHR_wait_sync
= false;
933 if (workarounds_
.disable_arb_sync
)
934 gfx::g_driver_gl
.ext
.b_GL_ARB_sync
= false;
935 bool ui_gl_fence_works
= gfx::GLFence::IsSupported();
936 UMA_HISTOGRAM_BOOLEAN("GPU.FenceSupport", ui_gl_fence_works
);
938 feature_flags_
.map_buffer_range
=
939 gl_version_info_
->is_es3
||
940 extensions
.Contains("GL_ARB_map_buffer_range") ||
941 extensions
.Contains("GL_EXT_map_buffer_range");
943 // Really it's part of core OpenGL 2.1 and up, but let's assume the
944 // extension is still advertised.
945 bool has_pixel_buffers
=
946 gl_version_info_
->is_es3
||
947 extensions
.Contains("GL_ARB_pixel_buffer_object") ||
948 extensions
.Contains("GL_NV_pixel_buffer_object");
950 // We will use either glMapBuffer() or glMapBufferRange() for async readbacks.
951 if (has_pixel_buffers
&& ui_gl_fence_works
&&
952 !workarounds_
.disable_async_readpixels
) {
953 feature_flags_
.use_async_readpixels
= true;
956 if (gl_version_info_
->is_es3
||
957 extensions
.Contains("GL_ARB_sampler_objects")) {
958 feature_flags_
.enable_samplers
= true;
959 // TODO(dsinclair): Add AddExtensionString("GL_CHROMIUM_sampler_objects")
963 if ((gl_version_info_
->is_es3
||
964 extensions
.Contains("GL_EXT_discard_framebuffer")) &&
965 !workarounds_
.disable_ext_discard_framebuffer
) {
966 // DiscardFramebufferEXT is automatically bound to InvalidateFramebuffer.
967 AddExtensionString("GL_EXT_discard_framebuffer");
968 feature_flags_
.ext_discard_framebuffer
= true;
971 if (ui_gl_fence_works
) {
972 AddExtensionString("GL_CHROMIUM_sync_query");
973 feature_flags_
.chromium_sync_query
= true;
976 bool blend_equation_advanced_coherent
=
977 extensions
.Contains("GL_NV_blend_equation_advanced_coherent") ||
978 extensions
.Contains("GL_KHR_blend_equation_advanced_coherent");
980 if (blend_equation_advanced_coherent
||
981 extensions
.Contains("GL_NV_blend_equation_advanced") ||
982 extensions
.Contains("GL_KHR_blend_equation_advanced")) {
983 const GLenum equations
[] = {GL_MULTIPLY_KHR
,
995 GL_HSL_SATURATION_KHR
,
997 GL_HSL_LUMINOSITY_KHR
};
999 for (GLenum equation
: equations
)
1000 validators_
.equation
.AddValue(equation
);
1001 if (blend_equation_advanced_coherent
)
1002 AddExtensionString("GL_KHR_blend_equation_advanced_coherent");
1004 AddExtensionString("GL_KHR_blend_equation_advanced");
1005 feature_flags_
.blend_equation_advanced
= true;
1006 feature_flags_
.blend_equation_advanced_coherent
=
1007 blend_equation_advanced_coherent
;
1010 if (extensions
.Contains("GL_NV_path_rendering")) {
1011 if (extensions
.Contains("GL_EXT_direct_state_access") ||
1012 gl_version_info_
->is_es3
) {
1013 AddExtensionString("GL_CHROMIUM_path_rendering");
1014 feature_flags_
.chromium_path_rendering
= true;
1015 validators_
.g_l_state
.AddValue(GL_PATH_MODELVIEW_MATRIX_CHROMIUM
);
1016 validators_
.g_l_state
.AddValue(GL_PATH_PROJECTION_MATRIX_CHROMIUM
);
1020 if ((gl_version_info_
->is_es3
|| extensions
.Contains("GL_EXT_texture_rg") ||
1021 extensions
.Contains("GL_ARB_texture_rg")) &&
1022 IsGL_REDSupportedOnFBOs()) {
1023 feature_flags_
.ext_texture_rg
= true;
1024 AddExtensionString("GL_EXT_texture_rg");
1026 validators_
.texture_format
.AddValue(GL_RED_EXT
);
1027 validators_
.texture_format
.AddValue(GL_RG_EXT
);
1028 validators_
.texture_internal_format
.AddValue(GL_RED_EXT
);
1029 validators_
.texture_internal_format
.AddValue(GL_RG_EXT
);
1030 validators_
.read_pixel_format
.AddValue(GL_RED_EXT
);
1031 validators_
.read_pixel_format
.AddValue(GL_RG_EXT
);
1032 validators_
.render_buffer_format
.AddValue(GL_R8_EXT
);
1033 validators_
.render_buffer_format
.AddValue(GL_RG8_EXT
);
1035 texture_format_validators_
[GL_RED_EXT
].AddValue(GL_UNSIGNED_BYTE
);
1036 texture_format_validators_
[GL_RG_EXT
].AddValue(GL_UNSIGNED_BYTE
);
1038 if (enable_texture_float
) {
1039 texture_format_validators_
[GL_RED_EXT
].AddValue(GL_FLOAT
);
1040 texture_format_validators_
[GL_RG_EXT
].AddValue(GL_FLOAT
);
1042 if (enable_texture_half_float
) {
1043 texture_format_validators_
[GL_RED_EXT
].AddValue(GL_HALF_FLOAT_OES
);
1044 texture_format_validators_
[GL_RG_EXT
].AddValue(GL_HALF_FLOAT_OES
);
1048 #if !defined(OS_MACOSX)
1049 if (workarounds_
.ignore_egl_sync_failures
) {
1050 gfx::GLFenceEGL::SetIgnoreFailures();
1055 void FeatureInfo::AddExtensionString(const char* s
) {
1057 size_t pos
= extensions_
.find(str
);
1058 while (pos
!= std::string::npos
&&
1059 pos
+ str
.length() < extensions_
.length() &&
1060 extensions_
.substr(pos
+ str
.length(), 1) != " ") {
1061 // This extension name is a substring of another.
1062 pos
= extensions_
.find(str
, pos
+ str
.length());
1064 if (pos
== std::string::npos
) {
1065 extensions_
+= (extensions_
.empty() ? "" : " ") + str
;
1069 FeatureInfo::~FeatureInfo() {
1072 } // namespace gles2