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 StringSet(const std::vector
<std::string
>& strs
) {
48 string_set_
.insert(strs
.begin(), strs
.end());
51 void Init(const char* s
) {
52 std::string
str(s
? s
: "");
56 void Init(const std::string
& str
) {
57 std::vector
<std::string
> tokens
;
58 Tokenize(str
, " ", &tokens
);
59 string_set_
.insert(tokens
.begin(), tokens
.end());
62 bool Contains(const char* s
) {
63 return string_set_
.find(s
) != string_set_
.end();
66 bool Contains(const std::string
& s
) {
67 return string_set_
.find(s
) != string_set_
.end();
70 const std::set
<std::string
>& GetImpl() {
75 std::set
<std::string
> string_set_
;
78 // Process a string of wordaround type IDs (seperated by ',') and set up
79 // the corresponding Workaround flags.
80 void StringToWorkarounds(
81 const std::string
& types
, FeatureInfo::Workarounds
* workarounds
) {
83 std::vector
<std::string
> pieces
;
84 base::SplitString(types
, ',', &pieces
);
85 for (size_t i
= 0; i
< pieces
.size(); ++i
) {
87 bool succeed
= base::StringToInt(pieces
[i
], &number
);
90 #define GPU_OP(type, name) \
92 workarounds->name = true; \
94 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP
)
100 if (workarounds
->max_texture_size_limit_4096
)
101 workarounds
->max_texture_size
= 4096;
102 if (workarounds
->max_cube_map_texture_size_limit_4096
)
103 workarounds
->max_cube_map_texture_size
= 4096;
104 if (workarounds
->max_cube_map_texture_size_limit_1024
)
105 workarounds
->max_cube_map_texture_size
= 1024;
106 if (workarounds
->max_cube_map_texture_size_limit_512
)
107 workarounds
->max_cube_map_texture_size
= 512;
109 if (workarounds
->max_fragment_uniform_vectors_32
)
110 workarounds
->max_fragment_uniform_vectors
= 32;
111 if (workarounds
->max_varying_vectors_16
)
112 workarounds
->max_varying_vectors
= 16;
113 if (workarounds
->max_vertex_uniform_vectors_256
)
114 workarounds
->max_vertex_uniform_vectors
= 256;
117 } // anonymous namespace.
119 FeatureInfo::FeatureFlags::FeatureFlags()
120 : chromium_color_buffer_float_rgba(false),
121 chromium_color_buffer_float_rgb(false),
122 chromium_framebuffer_multisample(false),
123 chromium_sync_query(false),
124 use_core_framebuffer_multisample(false),
125 multisampled_render_to_texture(false),
126 use_img_for_multisampled_render_to_texture(false),
127 oes_standard_derivatives(false),
128 oes_egl_image_external(false),
130 oes_compressed_etc1_rgb8_texture(false),
131 packed_depth24_stencil8(false),
133 enable_texture_float_linear(false),
134 enable_texture_half_float_linear(false),
135 angle_translated_shader_source(false),
136 angle_pack_reverse_row_order(false),
137 arb_texture_rectangle(false),
138 angle_instanced_arrays(false),
139 occlusion_query_boolean(false),
140 use_arb_occlusion_query2_for_occlusion_query_boolean(false),
141 use_arb_occlusion_query_for_occlusion_query_boolean(false),
142 native_vertex_array_object(false),
143 ext_texture_format_atc(false),
144 ext_texture_format_bgra8888(false),
145 ext_texture_format_dxt1(false),
146 ext_texture_format_dxt5(false),
147 enable_shader_name_hashing(false),
148 enable_samplers(false),
149 ext_draw_buffers(false),
150 nv_draw_buffers(false),
151 ext_frag_depth(false),
152 ext_shader_texture_lod(false),
153 use_async_readpixels(false),
154 map_buffer_range(false),
155 ext_discard_framebuffer(false),
156 angle_depth_texture(false),
157 is_swiftshader(false),
158 angle_texture_usage(false),
159 ext_texture_storage(false),
160 chromium_path_rendering(false),
161 blend_equation_advanced(false),
162 blend_equation_advanced_coherent(false),
163 ext_texture_rg(false),
164 enable_subscribe_uniform(false) {
167 FeatureInfo::Workarounds::Workarounds() :
168 #define GPU_OP(type, name) name(false),
169 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP
)
172 max_cube_map_texture_size(0),
173 max_fragment_uniform_vectors(0),
174 max_varying_vectors(0),
175 max_vertex_uniform_vectors(0) {
178 FeatureInfo::FeatureInfo() {
179 InitializeBasicState(*base::CommandLine::ForCurrentProcess());
182 FeatureInfo::FeatureInfo(const base::CommandLine
& command_line
) {
183 InitializeBasicState(command_line
);
186 void FeatureInfo::InitializeBasicState(const base::CommandLine
& command_line
) {
187 if (command_line
.HasSwitch(switches::kGpuDriverBugWorkarounds
)) {
188 std::string types
= command_line
.GetSwitchValueASCII(
189 switches::kGpuDriverBugWorkarounds
);
190 StringToWorkarounds(types
, &workarounds_
);
192 feature_flags_
.enable_shader_name_hashing
=
193 !command_line
.HasSwitch(switches::kDisableShaderNameHashing
);
195 feature_flags_
.is_swiftshader
=
196 (command_line
.GetSwitchValueASCII(switches::kUseGL
) == "swiftshader");
198 feature_flags_
.enable_subscribe_uniform
=
199 command_line
.HasSwitch(switches::kEnableSubscribeUniformExtension
);
201 static const GLenum kAlphaTypes
[] = {
204 static const GLenum kRGBTypes
[] = {
206 GL_UNSIGNED_SHORT_5_6_5
,
208 static const GLenum kRGBATypes
[] = {
210 GL_UNSIGNED_SHORT_4_4_4_4
,
211 GL_UNSIGNED_SHORT_5_5_5_1
,
213 static const GLenum kLuminanceTypes
[] = {
216 static const GLenum kLuminanceAlphaTypes
[] = {
219 static const FormatInfo kFormatTypes
[] = {
220 { GL_ALPHA
, kAlphaTypes
, arraysize(kAlphaTypes
), },
221 { GL_RGB
, kRGBTypes
, arraysize(kRGBTypes
), },
222 { GL_RGBA
, kRGBATypes
, arraysize(kRGBATypes
), },
223 { GL_LUMINANCE
, kLuminanceTypes
, arraysize(kLuminanceTypes
), },
224 { GL_LUMINANCE_ALPHA
, kLuminanceAlphaTypes
,
225 arraysize(kLuminanceAlphaTypes
), } ,
227 for (size_t ii
= 0; ii
< arraysize(kFormatTypes
); ++ii
) {
228 const FormatInfo
& info
= kFormatTypes
[ii
];
229 ValueValidator
<GLenum
>& validator
= texture_format_validators_
[info
.format
];
230 for (size_t jj
= 0; jj
< info
.count
; ++jj
) {
231 validator
.AddValue(info
.types
[jj
]);
236 bool FeatureInfo::Initialize() {
237 disallowed_features_
= DisallowedFeatures();
238 InitializeFeatures();
242 bool FeatureInfo::Initialize(const DisallowedFeatures
& disallowed_features
) {
243 disallowed_features_
= disallowed_features
;
244 InitializeFeatures();
248 bool IsGL_REDSupportedOnFBOs() {
249 // Skia uses GL_RED with frame buffers, unfortunately, Mesa claims to support
250 // GL_EXT_texture_rg, but it doesn't support it on frame buffers. To fix
251 // this, we try it, and if it fails, we don't expose GL_EXT_texture_rg.
252 GLint fb_binding
= 0;
253 GLint tex_binding
= 0;
254 glGetIntegerv(GL_FRAMEBUFFER_BINDING
, &fb_binding
);
255 glGetIntegerv(GL_TEXTURE_BINDING_2D
, &tex_binding
);
257 GLuint textureId
= 0;
258 glGenTextures(1, &textureId
);
259 glBindTexture(GL_TEXTURE_2D
, textureId
);
260 GLubyte data
[1] = {0};
261 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RED_EXT
, 1, 1, 0, GL_RED_EXT
,
262 GL_UNSIGNED_BYTE
, data
);
263 GLuint textureFBOID
= 0;
264 glGenFramebuffersEXT(1, &textureFBOID
);
265 glBindFramebufferEXT(GL_FRAMEBUFFER
, textureFBOID
);
266 glFramebufferTexture2DEXT(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
,
269 glCheckFramebufferStatusEXT(GL_FRAMEBUFFER
) != GL_FRAMEBUFFER_UNSUPPORTED
;
270 glDeleteFramebuffersEXT(1, &textureFBOID
);
271 glDeleteTextures(1, &textureId
);
273 glBindFramebufferEXT(GL_FRAMEBUFFER
, static_cast<GLuint
>(fb_binding
));
274 glBindTexture(GL_TEXTURE_2D
, static_cast<GLuint
>(tex_binding
));
276 DCHECK(glGetError() == GL_NO_ERROR
);
281 void FeatureInfo::InitializeFeatures() {
282 // Figure out what extensions to turn on.
283 StringSet extensions
;
284 // We need to figure out how to query the extension string before we
285 // have a GLVersionInfo available.
286 const char* version_str
=
287 reinterpret_cast<const char*>(glGetString(GL_VERSION
));
288 unsigned major_version
, minor_version
;
290 gfx::GLVersionInfo::ParseVersionString(
291 version_str
, &major_version
, &minor_version
, &is_es
, &is_es3
);
292 if (!is_es
&& major_version
>= 3) {
293 std::vector
<std::string
> exts
;
294 GLint num_extensions
= 0;
295 glGetIntegerv(GL_NUM_EXTENSIONS
, &num_extensions
);
296 for (GLint i
= 0; i
< num_extensions
; ++i
) {
297 const char* extension
= reinterpret_cast<const char*>(
298 glGetStringi(GL_EXTENSIONS
, i
));
299 DCHECK(extension
!= NULL
);
300 exts
.push_back(extension
);
304 extensions
= reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS
));
307 const char* renderer_str
=
308 reinterpret_cast<const char*>(glGetString(GL_RENDERER
));
310 gl_version_info_
.reset(new gfx::GLVersionInfo(
311 version_str
, renderer_str
, extensions
.GetImpl()));
313 AddExtensionString("GL_ANGLE_translated_shader_source");
314 AddExtensionString("GL_CHROMIUM_async_pixel_transfers");
315 AddExtensionString("GL_CHROMIUM_bind_uniform_location");
316 AddExtensionString("GL_CHROMIUM_command_buffer_query");
317 AddExtensionString("GL_CHROMIUM_command_buffer_latency_query");
318 AddExtensionString("GL_CHROMIUM_copy_texture");
319 AddExtensionString("GL_CHROMIUM_get_error_query");
320 AddExtensionString("GL_CHROMIUM_lose_context");
321 AddExtensionString("GL_CHROMIUM_pixel_transfer_buffer_object");
322 AddExtensionString("GL_CHROMIUM_rate_limit_offscreen_context");
323 AddExtensionString("GL_CHROMIUM_resize");
324 AddExtensionString("GL_CHROMIUM_resource_safe");
325 AddExtensionString("GL_CHROMIUM_strict_attribs");
326 AddExtensionString("GL_CHROMIUM_texture_mailbox");
327 AddExtensionString("GL_CHROMIUM_trace_marker");
328 AddExtensionString("GL_EXT_debug_marker");
330 if (feature_flags_
.enable_subscribe_uniform
) {
331 AddExtensionString("GL_CHROMIUM_subscribe_uniform");
334 // OES_vertex_array_object is emulated if not present natively,
335 // so the extension string is always exposed.
336 AddExtensionString("GL_OES_vertex_array_object");
338 if (!disallowed_features_
.gpu_memory_manager
)
339 AddExtensionString("GL_CHROMIUM_gpu_memory_manager");
341 if (extensions
.Contains("GL_ANGLE_translated_shader_source")) {
342 feature_flags_
.angle_translated_shader_source
= true;
345 // Check if we should allow GL_EXT_texture_compression_dxt1 and
346 // GL_EXT_texture_compression_s3tc.
347 bool enable_dxt1
= false;
348 bool enable_dxt3
= false;
349 bool enable_dxt5
= false;
350 bool have_s3tc
= extensions
.Contains("GL_EXT_texture_compression_s3tc");
352 have_s3tc
|| extensions
.Contains("GL_ANGLE_texture_compression_dxt3");
354 have_s3tc
|| extensions
.Contains("GL_ANGLE_texture_compression_dxt5");
356 if (extensions
.Contains("GL_EXT_texture_compression_dxt1") || have_s3tc
) {
367 feature_flags_
.ext_texture_format_dxt1
= true;
369 AddExtensionString("GL_EXT_texture_compression_dxt1");
370 validators_
.compressed_texture_format
.AddValue(
371 GL_COMPRESSED_RGB_S3TC_DXT1_EXT
);
372 validators_
.compressed_texture_format
.AddValue(
373 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
);
377 // The difference between GL_EXT_texture_compression_s3tc and
378 // GL_CHROMIUM_texture_compression_dxt3 is that the former
379 // requires on the fly compression. The latter does not.
380 AddExtensionString("GL_CHROMIUM_texture_compression_dxt3");
381 validators_
.compressed_texture_format
.AddValue(
382 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
);
386 feature_flags_
.ext_texture_format_dxt5
= true;
388 // The difference between GL_EXT_texture_compression_s3tc and
389 // GL_CHROMIUM_texture_compression_dxt5 is that the former
390 // requires on the fly compression. The latter does not.
391 AddExtensionString("GL_CHROMIUM_texture_compression_dxt5");
392 validators_
.compressed_texture_format
.AddValue(
393 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
);
396 bool have_atc
= extensions
.Contains("GL_AMD_compressed_ATC_texture") ||
397 extensions
.Contains("GL_ATI_texture_compression_atitc");
399 feature_flags_
.ext_texture_format_atc
= true;
401 AddExtensionString("GL_AMD_compressed_ATC_texture");
402 validators_
.compressed_texture_format
.AddValue(GL_ATC_RGB_AMD
);
403 validators_
.compressed_texture_format
.AddValue(
404 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD
);
407 // Check if we should enable GL_EXT_texture_filter_anisotropic.
408 if (extensions
.Contains("GL_EXT_texture_filter_anisotropic")) {
409 AddExtensionString("GL_EXT_texture_filter_anisotropic");
410 validators_
.texture_parameter
.AddValue(
411 GL_TEXTURE_MAX_ANISOTROPY_EXT
);
412 validators_
.g_l_state
.AddValue(
413 GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
);
416 // Check if we should support GL_OES_packed_depth_stencil and/or
417 // GL_GOOGLE_depth_texture / GL_CHROMIUM_depth_texture.
419 // NOTE: GL_OES_depth_texture requires support for depth cubemaps.
420 // GL_ARB_depth_texture requires other features that
421 // GL_OES_packed_depth_stencil does not provide.
423 // Therefore we made up GL_GOOGLE_depth_texture / GL_CHROMIUM_depth_texture.
425 // GL_GOOGLE_depth_texture is legacy. As we exposed it into NaCl we can't
428 bool enable_depth_texture
= false;
429 if (!workarounds_
.disable_depth_texture
&&
430 (extensions
.Contains("GL_ARB_depth_texture") ||
431 extensions
.Contains("GL_OES_depth_texture") ||
432 extensions
.Contains("GL_ANGLE_depth_texture") ||
433 gl_version_info_
->is_es3
||
434 gl_version_info_
->is_desktop_core_profile
)) {
435 enable_depth_texture
= true;
436 feature_flags_
.angle_depth_texture
=
437 extensions
.Contains("GL_ANGLE_depth_texture");
440 if (enable_depth_texture
) {
441 AddExtensionString("GL_CHROMIUM_depth_texture");
442 AddExtensionString("GL_GOOGLE_depth_texture");
443 texture_format_validators_
[GL_DEPTH_COMPONENT
].AddValue(GL_UNSIGNED_SHORT
);
444 texture_format_validators_
[GL_DEPTH_COMPONENT
].AddValue(GL_UNSIGNED_INT
);
445 validators_
.texture_internal_format
.AddValue(GL_DEPTH_COMPONENT
);
446 validators_
.texture_format
.AddValue(GL_DEPTH_COMPONENT
);
447 validators_
.pixel_type
.AddValue(GL_UNSIGNED_SHORT
);
448 validators_
.pixel_type
.AddValue(GL_UNSIGNED_INT
);
451 if (extensions
.Contains("GL_EXT_packed_depth_stencil") ||
452 extensions
.Contains("GL_OES_packed_depth_stencil") ||
453 gl_version_info_
->is_es3
||
454 gl_version_info_
->is_desktop_core_profile
) {
455 AddExtensionString("GL_OES_packed_depth_stencil");
456 feature_flags_
.packed_depth24_stencil8
= true;
457 if (enable_depth_texture
) {
458 texture_format_validators_
[GL_DEPTH_STENCIL
]
459 .AddValue(GL_UNSIGNED_INT_24_8
);
460 validators_
.texture_internal_format
.AddValue(GL_DEPTH_STENCIL
);
461 validators_
.texture_format
.AddValue(GL_DEPTH_STENCIL
);
462 validators_
.pixel_type
.AddValue(GL_UNSIGNED_INT_24_8
);
464 validators_
.render_buffer_format
.AddValue(GL_DEPTH24_STENCIL8
);
467 if (gl_version_info_
->is_es3
||
468 gl_version_info_
->is_desktop_core_profile
||
469 extensions
.Contains("GL_OES_vertex_array_object") ||
470 extensions
.Contains("GL_ARB_vertex_array_object") ||
471 extensions
.Contains("GL_APPLE_vertex_array_object")) {
472 feature_flags_
.native_vertex_array_object
= true;
475 // If we're using client_side_arrays we have to emulate
476 // vertex array objects since vertex array objects do not work
477 // with client side arrays.
478 if (workarounds_
.use_client_side_arrays_for_stream_buffers
) {
479 feature_flags_
.native_vertex_array_object
= false;
482 if (gl_version_info_
->is_es3
||
483 extensions
.Contains("GL_OES_element_index_uint") ||
484 gfx::HasDesktopGLFeatures()) {
485 AddExtensionString("GL_OES_element_index_uint");
486 validators_
.index_type
.AddValue(GL_UNSIGNED_INT
);
489 // With EXT_sRGB, unsized SRGB_EXT and SRGB_ALPHA_EXT are accepted by the
490 // <format> and <internalformat> parameter of TexImage2D. GLES3 adds support
491 // for SRGB Textures but the accepted internal formats for TexImage2D are only
492 // sized formats GL_SRGB8 and GL_SRGB8_ALPHA8. Also, SRGB_EXT isn't a valid
493 // <format> in this case. So, even with GLES3 explicitly check for
495 if (((gl_version_info_
->is_es3
||
496 extensions
.Contains("GL_OES_rgb8_rgba8")) &&
497 extensions
.Contains("GL_EXT_sRGB")) || gfx::HasDesktopGLFeatures()) {
498 AddExtensionString("GL_EXT_sRGB");
499 texture_format_validators_
[GL_SRGB_EXT
].AddValue(GL_UNSIGNED_BYTE
);
500 texture_format_validators_
[GL_SRGB_ALPHA_EXT
].AddValue(GL_UNSIGNED_BYTE
);
501 validators_
.texture_internal_format
.AddValue(GL_SRGB_EXT
);
502 validators_
.texture_internal_format
.AddValue(GL_SRGB_ALPHA_EXT
);
503 validators_
.texture_format
.AddValue(GL_SRGB_EXT
);
504 validators_
.texture_format
.AddValue(GL_SRGB_ALPHA_EXT
);
505 validators_
.render_buffer_format
.AddValue(GL_SRGB8_ALPHA8_EXT
);
506 validators_
.frame_buffer_parameter
.AddValue(
507 GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT
);
510 bool enable_texture_format_bgra8888
= false;
511 bool enable_read_format_bgra
= false;
512 bool enable_render_buffer_bgra
= false;
513 bool enable_immutable_texture_format_bgra_on_es3
=
514 extensions
.Contains("GL_APPLE_texture_format_BGRA8888");
516 // Check if we should allow GL_EXT_texture_format_BGRA8888
517 if (extensions
.Contains("GL_EXT_texture_format_BGRA8888") ||
518 enable_immutable_texture_format_bgra_on_es3
||
519 extensions
.Contains("GL_EXT_bgra")) {
520 enable_texture_format_bgra8888
= true;
523 // Only desktop GL extension GL_EXT_bgra or ANGLE guarantee that we can
524 // allocate a renderbuffer with this format.
525 if (extensions
.Contains("GL_EXT_bgra") || gl_version_info_
->is_angle
) {
526 enable_render_buffer_bgra
= true;
529 if (extensions
.Contains("GL_EXT_read_format_bgra") ||
530 extensions
.Contains("GL_EXT_bgra")) {
531 enable_read_format_bgra
= true;
534 if (enable_texture_format_bgra8888
) {
535 feature_flags_
.ext_texture_format_bgra8888
= true;
536 AddExtensionString("GL_EXT_texture_format_BGRA8888");
537 texture_format_validators_
[GL_BGRA_EXT
].AddValue(GL_UNSIGNED_BYTE
);
538 validators_
.texture_internal_format
.AddValue(GL_BGRA_EXT
);
539 validators_
.texture_format
.AddValue(GL_BGRA_EXT
);
542 if (enable_read_format_bgra
) {
543 AddExtensionString("GL_EXT_read_format_bgra");
544 validators_
.read_pixel_format
.AddValue(GL_BGRA_EXT
);
547 if (enable_render_buffer_bgra
) {
548 AddExtensionString("GL_CHROMIUM_renderbuffer_format_BGRA8888");
549 validators_
.render_buffer_format
.AddValue(GL_BGRA8_EXT
);
552 if (extensions
.Contains("GL_OES_rgb8_rgba8") || gfx::HasDesktopGLFeatures()) {
553 AddExtensionString("GL_OES_rgb8_rgba8");
554 validators_
.render_buffer_format
.AddValue(GL_RGB8_OES
);
555 validators_
.render_buffer_format
.AddValue(GL_RGBA8_OES
);
558 // Check if we should allow GL_OES_texture_npot
559 if (gl_version_info_
->is_es3
||
560 gl_version_info_
->is_desktop_core_profile
||
561 extensions
.Contains("GL_ARB_texture_non_power_of_two") ||
562 extensions
.Contains("GL_OES_texture_npot")) {
563 AddExtensionString("GL_OES_texture_npot");
564 feature_flags_
.npot_ok
= true;
567 // Check if we should allow GL_OES_texture_float, GL_OES_texture_half_float,
568 // GL_OES_texture_float_linear, GL_OES_texture_half_float_linear
569 bool enable_texture_float
= false;
570 bool enable_texture_float_linear
= false;
571 bool enable_texture_half_float
= false;
572 bool enable_texture_half_float_linear
= false;
574 bool may_enable_chromium_color_buffer_float
= false;
576 if (extensions
.Contains("GL_ARB_texture_float") ||
577 gl_version_info_
->is_desktop_core_profile
) {
578 enable_texture_float
= true;
579 enable_texture_float_linear
= true;
580 enable_texture_half_float
= true;
581 enable_texture_half_float_linear
= true;
582 may_enable_chromium_color_buffer_float
= true;
584 // GLES3 adds support for Float type by default but it doesn't support all
585 // formats as GL_OES_texture_float(i.e.LUMINANCE_ALPHA,LUMINANCE and Alpha)
586 if (extensions
.Contains("GL_OES_texture_float")) {
587 enable_texture_float
= true;
588 if (extensions
.Contains("GL_OES_texture_float_linear")) {
589 enable_texture_float_linear
= true;
591 // This extension allows a variety of floating point formats to be
592 // rendered to via framebuffer objects. Enable it's usage only if
593 // support for Floating textures is enabled.
594 if ((gl_version_info_
->is_es3
&&
595 extensions
.Contains("GL_EXT_color_buffer_float")) ||
596 gl_version_info_
->is_angle
) {
597 may_enable_chromium_color_buffer_float
= true;
601 // TODO(dshwang): GLES3 supports half float by default but GL_HALF_FLOAT_OES
602 // isn't equal to GL_HALF_FLOAT.
603 if (extensions
.Contains("GL_OES_texture_half_float")) {
604 enable_texture_half_float
= true;
605 if (extensions
.Contains("GL_OES_texture_half_float_linear")) {
606 enable_texture_half_float_linear
= true;
611 if (enable_texture_float
) {
612 texture_format_validators_
[GL_ALPHA
].AddValue(GL_FLOAT
);
613 texture_format_validators_
[GL_RGB
].AddValue(GL_FLOAT
);
614 texture_format_validators_
[GL_RGBA
].AddValue(GL_FLOAT
);
615 texture_format_validators_
[GL_LUMINANCE
].AddValue(GL_FLOAT
);
616 texture_format_validators_
[GL_LUMINANCE_ALPHA
].AddValue(GL_FLOAT
);
617 validators_
.pixel_type
.AddValue(GL_FLOAT
);
618 validators_
.read_pixel_type
.AddValue(GL_FLOAT
);
619 AddExtensionString("GL_OES_texture_float");
620 if (enable_texture_float_linear
) {
621 AddExtensionString("GL_OES_texture_float_linear");
625 if (enable_texture_half_float
) {
626 texture_format_validators_
[GL_ALPHA
].AddValue(GL_HALF_FLOAT_OES
);
627 texture_format_validators_
[GL_RGB
].AddValue(GL_HALF_FLOAT_OES
);
628 texture_format_validators_
[GL_RGBA
].AddValue(GL_HALF_FLOAT_OES
);
629 texture_format_validators_
[GL_LUMINANCE
].AddValue(GL_HALF_FLOAT_OES
);
630 texture_format_validators_
[GL_LUMINANCE_ALPHA
].AddValue(GL_HALF_FLOAT_OES
);
631 validators_
.pixel_type
.AddValue(GL_HALF_FLOAT_OES
);
632 validators_
.read_pixel_type
.AddValue(GL_HALF_FLOAT_OES
);
633 AddExtensionString("GL_OES_texture_half_float");
634 if (enable_texture_half_float_linear
) {
635 AddExtensionString("GL_OES_texture_half_float_linear");
639 if (may_enable_chromium_color_buffer_float
) {
640 static_assert(GL_RGBA32F_ARB
== GL_RGBA32F
&&
641 GL_RGBA32F_EXT
== GL_RGBA32F
&&
642 GL_RGB32F_ARB
== GL_RGB32F
&&
643 GL_RGB32F_EXT
== GL_RGB32F
,
644 "sized float internal format variations must match");
645 // We don't check extension support beyond ARB_texture_float on desktop GL,
646 // and format support varies between GL configurations. For example, spec
647 // prior to OpenGL 3.0 mandates framebuffer support only for one
648 // implementation-chosen format, and ES3.0 EXT_color_buffer_float does not
649 // support rendering to RGB32F. Check for framebuffer completeness with
650 // formats that the extensions expose, and only enable an extension when a
651 // framebuffer created with its texture format is reported as complete.
652 GLint fb_binding
= 0;
653 GLint tex_binding
= 0;
654 glGetIntegerv(GL_FRAMEBUFFER_BINDING
, &fb_binding
);
655 glGetIntegerv(GL_TEXTURE_BINDING_2D
, &tex_binding
);
661 glGenTextures(1, &tex_id
);
662 glGenFramebuffersEXT(1, &fb_id
);
663 glBindTexture(GL_TEXTURE_2D
, tex_id
);
664 // Nearest filter needed for framebuffer completeness on some drivers.
665 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
666 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA32F
, width
, width
, 0, GL_RGBA
,
668 glBindFramebufferEXT(GL_FRAMEBUFFER
, fb_id
);
669 glFramebufferTexture2DEXT(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
,
670 GL_TEXTURE_2D
, tex_id
, 0);
671 GLenum statusRGBA
= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER
);
672 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGB32F
, width
, width
, 0, GL_RGB
,
674 GLenum statusRGB
= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER
);
675 glDeleteFramebuffersEXT(1, &fb_id
);
676 glDeleteTextures(1, &tex_id
);
678 glBindFramebufferEXT(GL_FRAMEBUFFER
, static_cast<GLuint
>(fb_binding
));
679 glBindTexture(GL_TEXTURE_2D
, static_cast<GLuint
>(tex_binding
));
681 DCHECK(glGetError() == GL_NO_ERROR
);
683 if (statusRGBA
== GL_FRAMEBUFFER_COMPLETE
) {
684 validators_
.texture_internal_format
.AddValue(GL_RGBA32F
);
685 feature_flags_
.chromium_color_buffer_float_rgba
= true;
686 AddExtensionString("GL_CHROMIUM_color_buffer_float_rgba");
688 if (statusRGB
== GL_FRAMEBUFFER_COMPLETE
) {
689 validators_
.texture_internal_format
.AddValue(GL_RGB32F
);
690 feature_flags_
.chromium_color_buffer_float_rgb
= true;
691 AddExtensionString("GL_CHROMIUM_color_buffer_float_rgb");
695 // Check for multisample support
696 if (!workarounds_
.disable_chromium_framebuffer_multisample
) {
697 bool ext_has_multisample
=
698 extensions
.Contains("GL_EXT_framebuffer_multisample") ||
699 gl_version_info_
->is_es3
||
700 gl_version_info_
->is_desktop_core_profile
;
701 if (gl_version_info_
->is_angle
) {
702 ext_has_multisample
|=
703 extensions
.Contains("GL_ANGLE_framebuffer_multisample");
705 feature_flags_
.use_core_framebuffer_multisample
=
706 gl_version_info_
->is_es3
|| gl_version_info_
->is_desktop_core_profile
;
707 if (ext_has_multisample
) {
708 feature_flags_
.chromium_framebuffer_multisample
= true;
709 validators_
.frame_buffer_target
.AddValue(GL_READ_FRAMEBUFFER_EXT
);
710 validators_
.frame_buffer_target
.AddValue(GL_DRAW_FRAMEBUFFER_EXT
);
711 validators_
.g_l_state
.AddValue(GL_READ_FRAMEBUFFER_BINDING_EXT
);
712 validators_
.g_l_state
.AddValue(GL_MAX_SAMPLES_EXT
);
713 validators_
.render_buffer_parameter
.AddValue(GL_RENDERBUFFER_SAMPLES_EXT
);
714 AddExtensionString("GL_CHROMIUM_framebuffer_multisample");
718 if (!workarounds_
.disable_multisampled_render_to_texture
) {
719 if (extensions
.Contains("GL_EXT_multisampled_render_to_texture")) {
720 feature_flags_
.multisampled_render_to_texture
= true;
721 } else if (extensions
.Contains("GL_IMG_multisampled_render_to_texture")) {
722 feature_flags_
.multisampled_render_to_texture
= true;
723 feature_flags_
.use_img_for_multisampled_render_to_texture
= true;
725 if (feature_flags_
.multisampled_render_to_texture
) {
726 validators_
.render_buffer_parameter
.AddValue(
727 GL_RENDERBUFFER_SAMPLES_EXT
);
728 validators_
.g_l_state
.AddValue(GL_MAX_SAMPLES_EXT
);
729 validators_
.frame_buffer_parameter
.AddValue(
730 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT
);
731 AddExtensionString("GL_EXT_multisampled_render_to_texture");
735 if (extensions
.Contains("GL_OES_depth24") || gfx::HasDesktopGLFeatures() ||
736 gl_version_info_
->is_es3
) {
737 AddExtensionString("GL_OES_depth24");
738 feature_flags_
.oes_depth24
= true;
739 validators_
.render_buffer_format
.AddValue(GL_DEPTH_COMPONENT24
);
742 if (!workarounds_
.disable_oes_standard_derivatives
&&
743 (gl_version_info_
->is_es3
||
744 extensions
.Contains("GL_OES_standard_derivatives") ||
745 gfx::HasDesktopGLFeatures())) {
746 AddExtensionString("GL_OES_standard_derivatives");
747 feature_flags_
.oes_standard_derivatives
= true;
748 validators_
.hint_target
.AddValue(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES
);
749 validators_
.g_l_state
.AddValue(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES
);
752 if (extensions
.Contains("GL_OES_EGL_image_external")) {
753 AddExtensionString("GL_OES_EGL_image_external");
754 feature_flags_
.oes_egl_image_external
= true;
755 validators_
.texture_bind_target
.AddValue(GL_TEXTURE_EXTERNAL_OES
);
756 validators_
.get_tex_param_target
.AddValue(GL_TEXTURE_EXTERNAL_OES
);
757 validators_
.texture_parameter
.AddValue(GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES
);
758 validators_
.g_l_state
.AddValue(GL_TEXTURE_BINDING_EXTERNAL_OES
);
761 if (extensions
.Contains("GL_OES_compressed_ETC1_RGB8_texture")) {
762 AddExtensionString("GL_OES_compressed_ETC1_RGB8_texture");
763 feature_flags_
.oes_compressed_etc1_rgb8_texture
= true;
764 validators_
.compressed_texture_format
.AddValue(GL_ETC1_RGB8_OES
);
767 if (extensions
.Contains("GL_AMD_compressed_ATC_texture")) {
768 AddExtensionString("GL_AMD_compressed_ATC_texture");
769 validators_
.compressed_texture_format
.AddValue(
771 validators_
.compressed_texture_format
.AddValue(
772 GL_ATC_RGBA_EXPLICIT_ALPHA_AMD
);
773 validators_
.compressed_texture_format
.AddValue(
774 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD
);
777 if (extensions
.Contains("GL_IMG_texture_compression_pvrtc")) {
778 AddExtensionString("GL_IMG_texture_compression_pvrtc");
779 validators_
.compressed_texture_format
.AddValue(
780 GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG
);
781 validators_
.compressed_texture_format
.AddValue(
782 GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG
);
783 validators_
.compressed_texture_format
.AddValue(
784 GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
);
785 validators_
.compressed_texture_format
.AddValue(
786 GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
);
789 // Ideally we would only expose this extension on Mac OS X, to
790 // support GL_CHROMIUM_iosurface and the compositor. We don't want
791 // applications to start using it; they should use ordinary non-
792 // power-of-two textures. However, for unit testing purposes we
793 // expose it on all supported platforms.
794 if (extensions
.Contains("GL_ARB_texture_rectangle") ||
795 gl_version_info_
->is_desktop_core_profile
) {
796 AddExtensionString("GL_ARB_texture_rectangle");
797 feature_flags_
.arb_texture_rectangle
= true;
798 validators_
.texture_bind_target
.AddValue(GL_TEXTURE_RECTANGLE_ARB
);
799 // For the moment we don't add this enum to the texture_target
800 // validator. This implies that the only way to get image data into a
801 // rectangular texture is via glTexImageIOSurface2DCHROMIUM, which is
802 // just fine since again we don't want applications depending on this
804 validators_
.get_tex_param_target
.AddValue(GL_TEXTURE_RECTANGLE_ARB
);
805 validators_
.g_l_state
.AddValue(GL_TEXTURE_BINDING_RECTANGLE_ARB
);
808 #if defined(OS_MACOSX)
809 AddExtensionString("GL_CHROMIUM_iosurface");
812 // TODO(gman): Add support for these extensions.
815 feature_flags_
.enable_texture_float_linear
|= enable_texture_float_linear
;
816 feature_flags_
.enable_texture_half_float_linear
|=
817 enable_texture_half_float_linear
;
819 if (extensions
.Contains("GL_ANGLE_pack_reverse_row_order")) {
820 AddExtensionString("GL_ANGLE_pack_reverse_row_order");
821 feature_flags_
.angle_pack_reverse_row_order
= true;
822 validators_
.pixel_store
.AddValue(GL_PACK_REVERSE_ROW_ORDER_ANGLE
);
823 validators_
.g_l_state
.AddValue(GL_PACK_REVERSE_ROW_ORDER_ANGLE
);
826 if (extensions
.Contains("GL_ANGLE_texture_usage")) {
827 feature_flags_
.angle_texture_usage
= true;
828 AddExtensionString("GL_ANGLE_texture_usage");
829 validators_
.texture_parameter
.AddValue(GL_TEXTURE_USAGE_ANGLE
);
832 // Note: Only APPLE_texture_format_BGRA8888 extension allows BGRA8_EXT in
833 // ES3's glTexStorage2D. We prefer support BGRA to texture storage.
834 // So we don't expose GL_EXT_texture_storage when ES3 +
835 // GL_EXT_texture_format_BGRA8888 because we fail the GL_BGRA8 requirement.
836 // However we expose GL_EXT_texture_storage when just ES3 because we don't
837 // claim to handle GL_BGRA8.
838 bool support_texture_storage_on_es3
=
839 (gl_version_info_
->is_es3
&&
840 enable_immutable_texture_format_bgra_on_es3
) ||
841 (gl_version_info_
->is_es3
&&
842 !enable_texture_format_bgra8888
);
843 if (extensions
.Contains("GL_EXT_texture_storage") ||
844 extensions
.Contains("GL_ARB_texture_storage") ||
845 support_texture_storage_on_es3
||
846 gl_version_info_
->is_desktop_core_profile
) {
847 feature_flags_
.ext_texture_storage
= true;
848 AddExtensionString("GL_EXT_texture_storage");
849 validators_
.texture_parameter
.AddValue(GL_TEXTURE_IMMUTABLE_FORMAT_EXT
);
850 if (enable_texture_format_bgra8888
)
851 validators_
.texture_internal_format_storage
.AddValue(GL_BGRA8_EXT
);
852 if (enable_texture_float
) {
853 validators_
.texture_internal_format_storage
.AddValue(GL_RGBA32F_EXT
);
854 validators_
.texture_internal_format_storage
.AddValue(GL_RGB32F_EXT
);
855 validators_
.texture_internal_format_storage
.AddValue(GL_ALPHA32F_EXT
);
856 validators_
.texture_internal_format_storage
.AddValue(
857 GL_LUMINANCE32F_EXT
);
858 validators_
.texture_internal_format_storage
.AddValue(
859 GL_LUMINANCE_ALPHA32F_EXT
);
861 if (enable_texture_half_float
) {
862 validators_
.texture_internal_format_storage
.AddValue(GL_RGBA16F_EXT
);
863 validators_
.texture_internal_format_storage
.AddValue(GL_RGB16F_EXT
);
864 validators_
.texture_internal_format_storage
.AddValue(GL_ALPHA16F_EXT
);
865 validators_
.texture_internal_format_storage
.AddValue(
866 GL_LUMINANCE16F_EXT
);
867 validators_
.texture_internal_format_storage
.AddValue(
868 GL_LUMINANCE_ALPHA16F_EXT
);
872 bool have_ext_occlusion_query_boolean
=
873 extensions
.Contains("GL_EXT_occlusion_query_boolean");
874 bool have_arb_occlusion_query2
=
875 extensions
.Contains("GL_ARB_occlusion_query2");
876 bool have_arb_occlusion_query
=
877 extensions
.Contains("GL_ARB_occlusion_query");
879 if (!workarounds_
.disable_ext_occlusion_query
&&
880 (have_ext_occlusion_query_boolean
||
881 have_arb_occlusion_query2
||
882 have_arb_occlusion_query
)) {
883 AddExtensionString("GL_EXT_occlusion_query_boolean");
884 feature_flags_
.occlusion_query_boolean
= true;
885 feature_flags_
.use_arb_occlusion_query2_for_occlusion_query_boolean
=
886 !have_ext_occlusion_query_boolean
&& have_arb_occlusion_query2
;
887 feature_flags_
.use_arb_occlusion_query_for_occlusion_query_boolean
=
888 !have_ext_occlusion_query_boolean
&& have_arb_occlusion_query
&&
889 !have_arb_occlusion_query2
;
892 if (!workarounds_
.disable_angle_instanced_arrays
&&
893 (extensions
.Contains("GL_ANGLE_instanced_arrays") ||
894 (extensions
.Contains("GL_ARB_instanced_arrays") &&
895 extensions
.Contains("GL_ARB_draw_instanced")) ||
896 gl_version_info_
->is_es3
)) {
897 AddExtensionString("GL_ANGLE_instanced_arrays");
898 feature_flags_
.angle_instanced_arrays
= true;
899 validators_
.vertex_attribute
.AddValue(GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE
);
902 bool vendor_agnostic_draw_buffers
=
903 extensions
.Contains("GL_ARB_draw_buffers") ||
904 extensions
.Contains("GL_EXT_draw_buffers");
905 if (!workarounds_
.disable_ext_draw_buffers
&&
906 (vendor_agnostic_draw_buffers
||
907 (extensions
.Contains("GL_NV_draw_buffers") &&
908 gl_version_info_
->is_es3
) ||
909 gl_version_info_
->is_desktop_core_profile
)) {
910 AddExtensionString("GL_EXT_draw_buffers");
911 feature_flags_
.ext_draw_buffers
= true;
913 // This flag is set to enable emulation of EXT_draw_buffers when we're
914 // running on GLES 3.0+, NV_draw_buffers extension is supported and
915 // glDrawBuffers from GLES 3.0 core has been bound. It toggles using the
916 // NV_draw_buffers extension directive instead of EXT_draw_buffers extension
917 // directive in ESSL 100 shaders translated by ANGLE, enabling them to write
918 // into multiple gl_FragData values, which is not by default possible in
919 // ESSL 100 with core GLES 3.0. For more information, see the
920 // NV_draw_buffers specification.
921 feature_flags_
.nv_draw_buffers
= !vendor_agnostic_draw_buffers
;
923 GLint max_color_attachments
= 0;
924 glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT
, &max_color_attachments
);
925 for (GLenum i
= GL_COLOR_ATTACHMENT1_EXT
;
926 i
< static_cast<GLenum
>(GL_COLOR_ATTACHMENT0
+ max_color_attachments
);
928 validators_
.attachment
.AddValue(i
);
930 static_assert(GL_COLOR_ATTACHMENT0_EXT
== GL_COLOR_ATTACHMENT0
,
931 "GL_COLOR_ATTACHMENT0_EXT should equal GL_COLOR_ATTACHMENT0");
933 validators_
.g_l_state
.AddValue(GL_MAX_COLOR_ATTACHMENTS_EXT
);
934 validators_
.g_l_state
.AddValue(GL_MAX_DRAW_BUFFERS_ARB
);
935 GLint max_draw_buffers
= 0;
936 glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB
, &max_draw_buffers
);
937 for (GLenum i
= GL_DRAW_BUFFER0_ARB
;
938 i
< static_cast<GLenum
>(GL_DRAW_BUFFER0_ARB
+ max_draw_buffers
);
940 validators_
.g_l_state
.AddValue(i
);
944 if (gl_version_info_
->is_es3
||
945 extensions
.Contains("GL_EXT_blend_minmax") ||
946 gfx::HasDesktopGLFeatures()) {
947 AddExtensionString("GL_EXT_blend_minmax");
948 validators_
.equation
.AddValue(GL_MIN_EXT
);
949 validators_
.equation
.AddValue(GL_MAX_EXT
);
950 static_assert(GL_MIN_EXT
== GL_MIN
&& GL_MAX_EXT
== GL_MAX
,
951 "min & max variations must match");
954 // TODO(dshwang): GLES3 supports gl_FragDepth, not gl_FragDepthEXT.
955 if (extensions
.Contains("GL_EXT_frag_depth") || gfx::HasDesktopGLFeatures()) {
956 AddExtensionString("GL_EXT_frag_depth");
957 feature_flags_
.ext_frag_depth
= true;
960 if (extensions
.Contains("GL_EXT_shader_texture_lod") ||
961 gfx::HasDesktopGLFeatures()) {
962 AddExtensionString("GL_EXT_shader_texture_lod");
963 feature_flags_
.ext_shader_texture_lod
= true;
966 #if !defined(OS_MACOSX)
967 if (workarounds_
.disable_egl_khr_fence_sync
) {
968 gfx::g_driver_egl
.ext
.b_EGL_KHR_fence_sync
= false;
970 if (workarounds_
.disable_egl_khr_wait_sync
) {
971 gfx::g_driver_egl
.ext
.b_EGL_KHR_wait_sync
= false;
974 if (workarounds_
.disable_arb_sync
)
975 gfx::g_driver_gl
.ext
.b_GL_ARB_sync
= false;
976 bool ui_gl_fence_works
= gfx::GLFence::IsSupported();
977 UMA_HISTOGRAM_BOOLEAN("GPU.FenceSupport", ui_gl_fence_works
);
979 feature_flags_
.map_buffer_range
=
980 gl_version_info_
->is_es3
||
981 gl_version_info_
->is_desktop_core_profile
||
982 extensions
.Contains("GL_ARB_map_buffer_range") ||
983 extensions
.Contains("GL_EXT_map_buffer_range");
985 // Really it's part of core OpenGL 2.1 and up, but let's assume the
986 // extension is still advertised.
987 bool has_pixel_buffers
=
988 gl_version_info_
->is_es3
||
989 gl_version_info_
->is_desktop_core_profile
||
990 extensions
.Contains("GL_ARB_pixel_buffer_object") ||
991 extensions
.Contains("GL_NV_pixel_buffer_object");
993 // We will use either glMapBuffer() or glMapBufferRange() for async readbacks.
994 if (has_pixel_buffers
&& ui_gl_fence_works
&&
995 !workarounds_
.disable_async_readpixels
) {
996 feature_flags_
.use_async_readpixels
= true;
999 if (gl_version_info_
->is_es3
||
1000 extensions
.Contains("GL_ARB_sampler_objects")) {
1001 feature_flags_
.enable_samplers
= true;
1002 // TODO(dsinclair): Add AddExtensionString("GL_CHROMIUM_sampler_objects")
1006 if ((gl_version_info_
->is_es3
||
1007 extensions
.Contains("GL_EXT_discard_framebuffer")) &&
1008 !workarounds_
.disable_discard_framebuffer
) {
1009 // DiscardFramebufferEXT is automatically bound to InvalidateFramebuffer.
1010 AddExtensionString("GL_EXT_discard_framebuffer");
1011 feature_flags_
.ext_discard_framebuffer
= true;
1014 if (ui_gl_fence_works
) {
1015 AddExtensionString("GL_CHROMIUM_sync_query");
1016 feature_flags_
.chromium_sync_query
= true;
1019 bool blend_equation_advanced_coherent
=
1020 extensions
.Contains("GL_NV_blend_equation_advanced_coherent") ||
1021 extensions
.Contains("GL_KHR_blend_equation_advanced_coherent");
1023 if (blend_equation_advanced_coherent
||
1024 extensions
.Contains("GL_NV_blend_equation_advanced") ||
1025 extensions
.Contains("GL_KHR_blend_equation_advanced")) {
1026 const GLenum equations
[] = {GL_MULTIPLY_KHR
,
1038 GL_HSL_SATURATION_KHR
,
1040 GL_HSL_LUMINOSITY_KHR
};
1042 for (GLenum equation
: equations
)
1043 validators_
.equation
.AddValue(equation
);
1044 if (blend_equation_advanced_coherent
)
1045 AddExtensionString("GL_KHR_blend_equation_advanced_coherent");
1047 AddExtensionString("GL_KHR_blend_equation_advanced");
1048 feature_flags_
.blend_equation_advanced
= true;
1049 feature_flags_
.blend_equation_advanced_coherent
=
1050 blend_equation_advanced_coherent
;
1053 if (extensions
.Contains("GL_NV_path_rendering")) {
1054 if (extensions
.Contains("GL_EXT_direct_state_access") ||
1055 gl_version_info_
->is_es3
) {
1056 AddExtensionString("GL_CHROMIUM_path_rendering");
1057 feature_flags_
.chromium_path_rendering
= true;
1058 validators_
.g_l_state
.AddValue(GL_PATH_MODELVIEW_MATRIX_CHROMIUM
);
1059 validators_
.g_l_state
.AddValue(GL_PATH_PROJECTION_MATRIX_CHROMIUM
);
1063 if ((gl_version_info_
->is_es3
|| gl_version_info_
->is_desktop_core_profile
||
1064 extensions
.Contains("GL_EXT_texture_rg") ||
1065 extensions
.Contains("GL_ARB_texture_rg")) &&
1066 IsGL_REDSupportedOnFBOs()) {
1067 feature_flags_
.ext_texture_rg
= true;
1068 AddExtensionString("GL_EXT_texture_rg");
1070 validators_
.texture_format
.AddValue(GL_RED_EXT
);
1071 validators_
.texture_format
.AddValue(GL_RG_EXT
);
1072 validators_
.texture_internal_format
.AddValue(GL_RED_EXT
);
1073 validators_
.texture_internal_format
.AddValue(GL_RG_EXT
);
1074 validators_
.read_pixel_format
.AddValue(GL_RED_EXT
);
1075 validators_
.read_pixel_format
.AddValue(GL_RG_EXT
);
1076 validators_
.render_buffer_format
.AddValue(GL_R8_EXT
);
1077 validators_
.render_buffer_format
.AddValue(GL_RG8_EXT
);
1079 texture_format_validators_
[GL_RED_EXT
].AddValue(GL_UNSIGNED_BYTE
);
1080 texture_format_validators_
[GL_RG_EXT
].AddValue(GL_UNSIGNED_BYTE
);
1082 if (enable_texture_float
) {
1083 texture_format_validators_
[GL_RED_EXT
].AddValue(GL_FLOAT
);
1084 texture_format_validators_
[GL_RG_EXT
].AddValue(GL_FLOAT
);
1086 if (enable_texture_half_float
) {
1087 texture_format_validators_
[GL_RED_EXT
].AddValue(GL_HALF_FLOAT_OES
);
1088 texture_format_validators_
[GL_RG_EXT
].AddValue(GL_HALF_FLOAT_OES
);
1092 #if !defined(OS_MACOSX)
1093 if (workarounds_
.ignore_egl_sync_failures
) {
1094 gfx::GLFenceEGL::SetIgnoreFailures();
1099 bool FeatureInfo::IsES3Capable() const {
1100 if (gl_version_info_
->IsAtLeastGLES(3, 0))
1102 // TODO(zmo): For Desktop GL, with anything lower than 4.2, we need to check
1103 // the existence of a few extensions to have full WebGL 2 capabilities.
1104 if (gl_version_info_
->IsAtLeastGL(4, 2))
1106 #if defined(OS_MACOSX)
1107 // TODO(zmo): For experimentation purpose on MacOSX with core profile,
1108 // allow 3.2 or plus for now.
1109 if (gl_version_info_
->IsAtLeastGL(3, 2))
1115 void FeatureInfo::EnableES3Validators() {
1116 DCHECK(IsES3Capable());
1117 validators_
.UpdateValuesES3();
1120 void FeatureInfo::AddExtensionString(const char* s
) {
1122 size_t pos
= extensions_
.find(str
);
1123 while (pos
!= std::string::npos
&&
1124 pos
+ str
.length() < extensions_
.length() &&
1125 extensions_
.substr(pos
+ str
.length(), 1) != " ") {
1126 // This extension name is a substring of another.
1127 pos
= extensions_
.find(str
, pos
+ str
.length());
1129 if (pos
== std::string::npos
) {
1130 extensions_
+= (extensions_
.empty() ? "" : " ") + str
;
1134 FeatureInfo::~FeatureInfo() {
1137 } // namespace gles2