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"
10 #include "base/command_line.h"
11 #include "base/metrics/histogram_macros.h"
12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_split.h"
14 #include "gpu/command_buffer/service/gpu_switches.h"
15 #include "gpu/command_buffer/service/texture_definition.h"
16 #include "gpu/config/gpu_switches.h"
17 #include "ui/gl/gl_bindings.h"
18 #include "ui/gl/gl_fence.h"
19 #include "ui/gl/gl_implementation.h"
20 #include "ui/gl/gl_switches.h"
21 #include "ui/gl/gl_version_info.h"
23 #if !defined(OS_MACOSX)
24 #include "ui/gl/gl_fence_egl.h"
42 StringSet(const char* s
) {
46 StringSet(const std::string
& str
) {
50 StringSet(const std::vector
<std::string
>& strs
) {
51 string_set_
.insert(strs
.begin(), strs
.end());
54 void Init(const char* s
) {
55 std::string
str(s
? s
: "");
59 void Init(const std::string
& str
) {
60 std::vector
<std::string
> tokens
= base::SplitString(
61 str
, " ", base::KEEP_WHITESPACE
, base::SPLIT_WANT_NONEMPTY
);
62 string_set_
.insert(tokens
.begin(), tokens
.end());
65 bool Contains(const char* s
) {
66 return string_set_
.find(s
) != string_set_
.end();
69 bool Contains(const std::string
& s
) {
70 return string_set_
.find(s
) != string_set_
.end();
73 const std::set
<std::string
>& GetImpl() {
78 std::set
<std::string
> string_set_
;
81 // Process a string of wordaround type IDs (seperated by ',') and set up
82 // the corresponding Workaround flags.
83 void StringToWorkarounds(
84 const std::string
& types
, FeatureInfo::Workarounds
* workarounds
) {
86 for (const base::StringPiece
& piece
:
87 base::SplitStringPiece(
88 types
, ",", base::TRIM_WHITESPACE
, base::SPLIT_WANT_ALL
)) {
90 bool succeed
= base::StringToInt(piece
, &number
);
93 #define GPU_OP(type, name) \
95 workarounds->name = true; \
97 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP
)
103 if (workarounds
->max_texture_size_limit_4096
)
104 workarounds
->max_texture_size
= 4096;
105 if (workarounds
->max_cube_map_texture_size_limit_4096
)
106 workarounds
->max_cube_map_texture_size
= 4096;
107 if (workarounds
->max_cube_map_texture_size_limit_1024
)
108 workarounds
->max_cube_map_texture_size
= 1024;
109 if (workarounds
->max_cube_map_texture_size_limit_512
)
110 workarounds
->max_cube_map_texture_size
= 512;
112 if (workarounds
->max_fragment_uniform_vectors_32
)
113 workarounds
->max_fragment_uniform_vectors
= 32;
114 if (workarounds
->max_varying_vectors_16
)
115 workarounds
->max_varying_vectors
= 16;
116 if (workarounds
->max_vertex_uniform_vectors_256
)
117 workarounds
->max_vertex_uniform_vectors
= 256;
119 if (workarounds
->max_copy_texture_chromium_size_262144
)
120 workarounds
->max_copy_texture_chromium_size
= 262144;
123 } // anonymous namespace.
125 FeatureInfo::FeatureFlags::FeatureFlags()
126 : chromium_color_buffer_float_rgba(false),
127 chromium_color_buffer_float_rgb(false),
128 chromium_framebuffer_multisample(false),
129 chromium_sync_query(false),
130 use_core_framebuffer_multisample(false),
131 multisampled_render_to_texture(false),
132 use_img_for_multisampled_render_to_texture(false),
133 oes_standard_derivatives(false),
134 oes_egl_image_external(false),
136 oes_compressed_etc1_rgb8_texture(false),
137 packed_depth24_stencil8(false),
139 enable_texture_float_linear(false),
140 enable_texture_half_float_linear(false),
141 angle_translated_shader_source(false),
142 angle_pack_reverse_row_order(false),
143 arb_texture_rectangle(false),
144 angle_instanced_arrays(false),
145 occlusion_query_boolean(false),
146 use_arb_occlusion_query2_for_occlusion_query_boolean(false),
147 use_arb_occlusion_query_for_occlusion_query_boolean(false),
148 native_vertex_array_object(false),
149 ext_texture_format_atc(false),
150 ext_texture_format_bgra8888(false),
151 ext_texture_format_dxt1(false),
152 ext_texture_format_dxt5(false),
153 enable_shader_name_hashing(false),
154 enable_samplers(false),
155 ext_draw_buffers(false),
156 nv_draw_buffers(false),
157 ext_frag_depth(false),
158 ext_shader_texture_lod(false),
159 use_async_readpixels(false),
160 map_buffer_range(false),
161 ext_discard_framebuffer(false),
162 angle_depth_texture(false),
163 is_swiftshader(false),
164 angle_texture_usage(false),
165 ext_texture_storage(false),
166 chromium_path_rendering(false),
167 blend_equation_advanced(false),
168 blend_equation_advanced_coherent(false),
169 ext_texture_rg(false),
170 chromium_image_ycbcr_422(false),
171 enable_subscribe_uniform(false),
172 emulate_primitive_restart_fixed_index(false),
173 ext_render_buffer_format_bgra8888(false) {}
175 FeatureInfo::Workarounds::Workarounds() :
176 #define GPU_OP(type, name) name(false),
177 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP
)
180 max_cube_map_texture_size(0),
181 max_fragment_uniform_vectors(0),
182 max_varying_vectors(0),
183 max_vertex_uniform_vectors(0),
184 max_copy_texture_chromium_size(0) {
187 FeatureInfo::FeatureInfo() {
188 InitializeBasicState(base::CommandLine::InitializedForCurrentProcess()
189 ? base::CommandLine::ForCurrentProcess()
193 FeatureInfo::FeatureInfo(const base::CommandLine
& command_line
) {
194 InitializeBasicState(&command_line
);
197 void FeatureInfo::InitializeBasicState(const base::CommandLine
* command_line
) {
201 if (command_line
->HasSwitch(switches::kGpuDriverBugWorkarounds
)) {
202 std::string types
= command_line
->GetSwitchValueASCII(
203 switches::kGpuDriverBugWorkarounds
);
204 StringToWorkarounds(types
, &workarounds_
);
206 feature_flags_
.enable_shader_name_hashing
=
207 !command_line
->HasSwitch(switches::kDisableShaderNameHashing
);
209 feature_flags_
.is_swiftshader
=
210 (command_line
->GetSwitchValueASCII(switches::kUseGL
) == "swiftshader");
212 feature_flags_
.enable_subscribe_uniform
=
213 command_line
->HasSwitch(switches::kEnableSubscribeUniformExtension
);
215 enable_unsafe_es3_apis_switch_
=
216 command_line
->HasSwitch(switches::kEnableUnsafeES3APIs
);
218 enable_gl_path_rendering_switch_
=
219 command_line
->HasSwitch(switches::kEnableGLPathRendering
);
221 unsafe_es3_apis_enabled_
= false;
224 bool FeatureInfo::Initialize() {
225 disallowed_features_
= DisallowedFeatures();
226 InitializeFeatures();
230 bool FeatureInfo::Initialize(const DisallowedFeatures
& disallowed_features
) {
231 disallowed_features_
= disallowed_features
;
232 InitializeFeatures();
236 bool IsGL_REDSupportedOnFBOs() {
237 // Skia uses GL_RED with frame buffers, unfortunately, Mesa claims to support
238 // GL_EXT_texture_rg, but it doesn't support it on frame buffers. To fix
239 // this, we try it, and if it fails, we don't expose GL_EXT_texture_rg.
240 GLint fb_binding
= 0;
241 GLint tex_binding
= 0;
242 glGetIntegerv(GL_FRAMEBUFFER_BINDING
, &fb_binding
);
243 glGetIntegerv(GL_TEXTURE_BINDING_2D
, &tex_binding
);
245 GLuint textureId
= 0;
246 glGenTextures(1, &textureId
);
247 glBindTexture(GL_TEXTURE_2D
, textureId
);
248 GLubyte data
[1] = {0};
249 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RED_EXT
, 1, 1, 0, GL_RED_EXT
,
250 GL_UNSIGNED_BYTE
, data
);
251 GLuint textureFBOID
= 0;
252 glGenFramebuffersEXT(1, &textureFBOID
);
253 glBindFramebufferEXT(GL_FRAMEBUFFER
, textureFBOID
);
254 glFramebufferTexture2DEXT(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
,
257 glCheckFramebufferStatusEXT(GL_FRAMEBUFFER
) != GL_FRAMEBUFFER_UNSUPPORTED
;
258 glDeleteFramebuffersEXT(1, &textureFBOID
);
259 glDeleteTextures(1, &textureId
);
261 glBindFramebufferEXT(GL_FRAMEBUFFER
, static_cast<GLuint
>(fb_binding
));
262 glBindTexture(GL_TEXTURE_2D
, static_cast<GLuint
>(tex_binding
));
264 DCHECK(glGetError() == GL_NO_ERROR
);
269 void FeatureInfo::InitializeFeatures() {
270 // Figure out what extensions to turn on.
271 StringSet
extensions(gfx::GetGLExtensionsFromCurrentContext());
273 const char* version_str
=
274 reinterpret_cast<const char*>(glGetString(GL_VERSION
));
275 const char* renderer_str
=
276 reinterpret_cast<const char*>(glGetString(GL_RENDERER
));
278 gl_version_info_
.reset(new gfx::GLVersionInfo(
279 version_str
, renderer_str
, extensions
.GetImpl()));
281 AddExtensionString("GL_ANGLE_translated_shader_source");
282 AddExtensionString("GL_CHROMIUM_async_pixel_transfers");
283 AddExtensionString("GL_CHROMIUM_bind_uniform_location");
284 AddExtensionString("GL_CHROMIUM_command_buffer_query");
285 AddExtensionString("GL_CHROMIUM_command_buffer_latency_query");
286 AddExtensionString("GL_CHROMIUM_copy_texture");
287 AddExtensionString("GL_CHROMIUM_get_error_query");
288 AddExtensionString("GL_CHROMIUM_lose_context");
289 AddExtensionString("GL_CHROMIUM_pixel_transfer_buffer_object");
290 AddExtensionString("GL_CHROMIUM_rate_limit_offscreen_context");
291 AddExtensionString("GL_CHROMIUM_resize");
292 AddExtensionString("GL_CHROMIUM_resource_safe");
293 AddExtensionString("GL_CHROMIUM_strict_attribs");
294 AddExtensionString("GL_CHROMIUM_texture_mailbox");
295 AddExtensionString("GL_CHROMIUM_trace_marker");
296 AddExtensionString("GL_EXT_debug_marker");
298 if (feature_flags_
.enable_subscribe_uniform
) {
299 AddExtensionString("GL_CHROMIUM_subscribe_uniform");
302 // OES_vertex_array_object is emulated if not present natively,
303 // so the extension string is always exposed.
304 AddExtensionString("GL_OES_vertex_array_object");
306 if (!disallowed_features_
.gpu_memory_manager
)
307 AddExtensionString("GL_CHROMIUM_gpu_memory_manager");
309 if (extensions
.Contains("GL_ANGLE_translated_shader_source")) {
310 feature_flags_
.angle_translated_shader_source
= true;
313 // Check if we should allow GL_EXT_texture_compression_dxt1 and
314 // GL_EXT_texture_compression_s3tc.
315 bool enable_dxt1
= false;
316 bool enable_dxt3
= false;
317 bool enable_dxt5
= false;
318 bool have_s3tc
= extensions
.Contains("GL_EXT_texture_compression_s3tc");
320 have_s3tc
|| extensions
.Contains("GL_ANGLE_texture_compression_dxt3");
322 have_s3tc
|| extensions
.Contains("GL_ANGLE_texture_compression_dxt5");
324 if (extensions
.Contains("GL_EXT_texture_compression_dxt1") || have_s3tc
) {
335 feature_flags_
.ext_texture_format_dxt1
= true;
337 AddExtensionString("GL_EXT_texture_compression_dxt1");
338 validators_
.compressed_texture_format
.AddValue(
339 GL_COMPRESSED_RGB_S3TC_DXT1_EXT
);
340 validators_
.compressed_texture_format
.AddValue(
341 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
);
343 validators_
.texture_internal_format_storage
.AddValue(
344 GL_COMPRESSED_RGB_S3TC_DXT1_EXT
);
345 validators_
.texture_internal_format_storage
.AddValue(
346 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
);
350 // The difference between GL_EXT_texture_compression_s3tc and
351 // GL_CHROMIUM_texture_compression_dxt3 is that the former
352 // requires on the fly compression. The latter does not.
353 AddExtensionString("GL_CHROMIUM_texture_compression_dxt3");
354 validators_
.compressed_texture_format
.AddValue(
355 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
);
356 validators_
.texture_internal_format_storage
.AddValue(
357 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
);
361 feature_flags_
.ext_texture_format_dxt5
= true;
363 // The difference between GL_EXT_texture_compression_s3tc and
364 // GL_CHROMIUM_texture_compression_dxt5 is that the former
365 // requires on the fly compression. The latter does not.
366 AddExtensionString("GL_CHROMIUM_texture_compression_dxt5");
367 validators_
.compressed_texture_format
.AddValue(
368 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
);
369 validators_
.texture_internal_format_storage
.AddValue(
370 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
);
373 bool have_atc
= extensions
.Contains("GL_AMD_compressed_ATC_texture") ||
374 extensions
.Contains("GL_ATI_texture_compression_atitc");
376 feature_flags_
.ext_texture_format_atc
= true;
378 AddExtensionString("GL_AMD_compressed_ATC_texture");
379 validators_
.compressed_texture_format
.AddValue(GL_ATC_RGB_AMD
);
380 validators_
.compressed_texture_format
.AddValue(
381 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD
);
383 validators_
.texture_internal_format_storage
.AddValue(GL_ATC_RGB_AMD
);
384 validators_
.texture_internal_format_storage
.AddValue(
385 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD
);
388 // Check if we should enable GL_EXT_texture_filter_anisotropic.
389 if (extensions
.Contains("GL_EXT_texture_filter_anisotropic")) {
390 AddExtensionString("GL_EXT_texture_filter_anisotropic");
391 validators_
.texture_parameter
.AddValue(
392 GL_TEXTURE_MAX_ANISOTROPY_EXT
);
393 validators_
.g_l_state
.AddValue(
394 GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
);
397 // Check if we should support GL_OES_packed_depth_stencil and/or
398 // GL_GOOGLE_depth_texture / GL_CHROMIUM_depth_texture.
400 // NOTE: GL_OES_depth_texture requires support for depth cubemaps.
401 // GL_ARB_depth_texture requires other features that
402 // GL_OES_packed_depth_stencil does not provide.
404 // Therefore we made up GL_GOOGLE_depth_texture / GL_CHROMIUM_depth_texture.
406 // GL_GOOGLE_depth_texture is legacy. As we exposed it into NaCl we can't
409 bool enable_depth_texture
= false;
410 if (!workarounds_
.disable_depth_texture
&&
411 (extensions
.Contains("GL_ARB_depth_texture") ||
412 extensions
.Contains("GL_OES_depth_texture") ||
413 extensions
.Contains("GL_ANGLE_depth_texture") ||
414 gl_version_info_
->is_es3
||
415 gl_version_info_
->is_desktop_core_profile
)) {
416 enable_depth_texture
= true;
417 feature_flags_
.angle_depth_texture
=
418 extensions
.Contains("GL_ANGLE_depth_texture");
421 if (enable_depth_texture
) {
422 AddExtensionString("GL_CHROMIUM_depth_texture");
423 AddExtensionString("GL_GOOGLE_depth_texture");
424 validators_
.texture_internal_format
.AddValue(GL_DEPTH_COMPONENT
);
425 validators_
.texture_format
.AddValue(GL_DEPTH_COMPONENT
);
426 validators_
.pixel_type
.AddValue(GL_UNSIGNED_SHORT
);
427 validators_
.pixel_type
.AddValue(GL_UNSIGNED_INT
);
430 if (extensions
.Contains("GL_EXT_packed_depth_stencil") ||
431 extensions
.Contains("GL_OES_packed_depth_stencil") ||
432 gl_version_info_
->is_es3
||
433 gl_version_info_
->is_desktop_core_profile
) {
434 AddExtensionString("GL_OES_packed_depth_stencil");
435 feature_flags_
.packed_depth24_stencil8
= true;
436 if (enable_depth_texture
) {
437 validators_
.texture_internal_format
.AddValue(GL_DEPTH_STENCIL
);
438 validators_
.texture_format
.AddValue(GL_DEPTH_STENCIL
);
439 validators_
.pixel_type
.AddValue(GL_UNSIGNED_INT_24_8
);
441 validators_
.render_buffer_format
.AddValue(GL_DEPTH24_STENCIL8
);
444 if (gl_version_info_
->is_es3
||
445 gl_version_info_
->is_desktop_core_profile
||
446 extensions
.Contains("GL_OES_vertex_array_object") ||
447 extensions
.Contains("GL_ARB_vertex_array_object") ||
448 extensions
.Contains("GL_APPLE_vertex_array_object")) {
449 feature_flags_
.native_vertex_array_object
= true;
452 // If we're using client_side_arrays we have to emulate
453 // vertex array objects since vertex array objects do not work
454 // with client side arrays.
455 if (workarounds_
.use_client_side_arrays_for_stream_buffers
) {
456 feature_flags_
.native_vertex_array_object
= false;
459 if (gl_version_info_
->is_es3
||
460 extensions
.Contains("GL_OES_element_index_uint") ||
461 gfx::HasDesktopGLFeatures()) {
462 AddExtensionString("GL_OES_element_index_uint");
463 validators_
.index_type
.AddValue(GL_UNSIGNED_INT
);
466 // With EXT_sRGB, unsized SRGB_EXT and SRGB_ALPHA_EXT are accepted by the
467 // <format> and <internalformat> parameter of TexImage2D. GLES3 adds support
468 // for SRGB Textures but the accepted internal formats for TexImage2D are only
469 // sized formats GL_SRGB8 and GL_SRGB8_ALPHA8. Also, SRGB_EXT isn't a valid
470 // <format> in this case. So, even with GLES3 explicitly check for
472 if (((gl_version_info_
->is_es3
||
473 extensions
.Contains("GL_OES_rgb8_rgba8")) &&
474 extensions
.Contains("GL_EXT_sRGB")) || gfx::HasDesktopGLFeatures()) {
475 AddExtensionString("GL_EXT_sRGB");
476 validators_
.texture_internal_format
.AddValue(GL_SRGB_EXT
);
477 validators_
.texture_internal_format
.AddValue(GL_SRGB_ALPHA_EXT
);
478 validators_
.texture_format
.AddValue(GL_SRGB_EXT
);
479 validators_
.texture_format
.AddValue(GL_SRGB_ALPHA_EXT
);
480 validators_
.render_buffer_format
.AddValue(GL_SRGB8_ALPHA8_EXT
);
481 validators_
.frame_buffer_parameter
.AddValue(
482 GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT
);
485 bool enable_texture_format_bgra8888
= false;
486 bool enable_read_format_bgra
= false;
487 bool enable_render_buffer_bgra
= false;
488 bool enable_immutable_texture_format_bgra_on_es3
=
489 extensions
.Contains("GL_APPLE_texture_format_BGRA8888");
491 // Check if we should allow GL_EXT_texture_format_BGRA8888
492 if (extensions
.Contains("GL_EXT_texture_format_BGRA8888") ||
493 enable_immutable_texture_format_bgra_on_es3
||
494 !gl_version_info_
->is_es
) {
495 enable_texture_format_bgra8888
= true;
498 // Only desktop GL extension GL_EXT_bgra or ANGLE guarantee that we can
499 // allocate a renderbuffer with this format.
500 if (extensions
.Contains("GL_EXT_bgra") || gl_version_info_
->is_angle
) {
501 enable_render_buffer_bgra
= true;
504 if (extensions
.Contains("GL_EXT_read_format_bgra") ||
505 extensions
.Contains("GL_EXT_bgra")) {
506 enable_read_format_bgra
= true;
509 if (enable_texture_format_bgra8888
) {
510 feature_flags_
.ext_texture_format_bgra8888
= true;
511 AddExtensionString("GL_EXT_texture_format_BGRA8888");
512 validators_
.texture_internal_format
.AddValue(GL_BGRA_EXT
);
513 validators_
.texture_format
.AddValue(GL_BGRA_EXT
);
516 if (enable_read_format_bgra
) {
517 AddExtensionString("GL_EXT_read_format_bgra");
518 validators_
.read_pixel_format
.AddValue(GL_BGRA_EXT
);
521 if (enable_render_buffer_bgra
) {
522 feature_flags_
.ext_render_buffer_format_bgra8888
= true;
523 AddExtensionString("GL_CHROMIUM_renderbuffer_format_BGRA8888");
524 validators_
.render_buffer_format
.AddValue(GL_BGRA8_EXT
);
527 if (extensions
.Contains("GL_OES_rgb8_rgba8") || gfx::HasDesktopGLFeatures()) {
528 AddExtensionString("GL_OES_rgb8_rgba8");
529 validators_
.render_buffer_format
.AddValue(GL_RGB8_OES
);
530 validators_
.render_buffer_format
.AddValue(GL_RGBA8_OES
);
533 // Check if we should allow GL_OES_texture_npot
534 if (!disallowed_features_
.npot_support
&&
535 (gl_version_info_
->is_es3
||
536 gl_version_info_
->is_desktop_core_profile
||
537 extensions
.Contains("GL_ARB_texture_non_power_of_two") ||
538 extensions
.Contains("GL_OES_texture_npot"))) {
539 AddExtensionString("GL_OES_texture_npot");
540 feature_flags_
.npot_ok
= true;
543 // Check if we should allow GL_OES_texture_float, GL_OES_texture_half_float,
544 // GL_OES_texture_float_linear, GL_OES_texture_half_float_linear
545 bool enable_texture_float
= false;
546 bool enable_texture_float_linear
= false;
547 bool enable_texture_half_float
= false;
548 bool enable_texture_half_float_linear
= false;
550 bool may_enable_chromium_color_buffer_float
= false;
552 if (extensions
.Contains("GL_ARB_texture_float") ||
553 gl_version_info_
->is_desktop_core_profile
) {
554 enable_texture_float
= true;
555 enable_texture_float_linear
= true;
556 enable_texture_half_float
= true;
557 enable_texture_half_float_linear
= true;
558 may_enable_chromium_color_buffer_float
= true;
560 // GLES3 adds support for Float type by default but it doesn't support all
561 // formats as GL_OES_texture_float(i.e.LUMINANCE_ALPHA,LUMINANCE and Alpha)
562 if (extensions
.Contains("GL_OES_texture_float")) {
563 enable_texture_float
= true;
564 if (extensions
.Contains("GL_OES_texture_float_linear")) {
565 enable_texture_float_linear
= true;
567 // This extension allows a variety of floating point formats to be
568 // rendered to via framebuffer objects. Enable it's usage only if
569 // support for Floating textures is enabled.
570 if ((gl_version_info_
->is_es3
&&
571 extensions
.Contains("GL_EXT_color_buffer_float")) ||
572 gl_version_info_
->is_angle
) {
573 may_enable_chromium_color_buffer_float
= true;
577 // TODO(dshwang): GLES3 supports half float by default but GL_HALF_FLOAT_OES
578 // isn't equal to GL_HALF_FLOAT.
579 if (extensions
.Contains("GL_OES_texture_half_float")) {
580 enable_texture_half_float
= true;
581 if (extensions
.Contains("GL_OES_texture_half_float_linear")) {
582 enable_texture_half_float_linear
= true;
587 if (enable_texture_float
) {
588 validators_
.pixel_type
.AddValue(GL_FLOAT
);
589 validators_
.read_pixel_type
.AddValue(GL_FLOAT
);
590 AddExtensionString("GL_OES_texture_float");
591 if (enable_texture_float_linear
) {
592 AddExtensionString("GL_OES_texture_float_linear");
596 if (enable_texture_half_float
) {
597 validators_
.pixel_type
.AddValue(GL_HALF_FLOAT_OES
);
598 validators_
.read_pixel_type
.AddValue(GL_HALF_FLOAT_OES
);
599 AddExtensionString("GL_OES_texture_half_float");
600 if (enable_texture_half_float_linear
) {
601 AddExtensionString("GL_OES_texture_half_float_linear");
605 if (may_enable_chromium_color_buffer_float
) {
606 static_assert(GL_RGBA32F_ARB
== GL_RGBA32F
&&
607 GL_RGBA32F_EXT
== GL_RGBA32F
&&
608 GL_RGB32F_ARB
== GL_RGB32F
&&
609 GL_RGB32F_EXT
== GL_RGB32F
,
610 "sized float internal format variations must match");
611 // We don't check extension support beyond ARB_texture_float on desktop GL,
612 // and format support varies between GL configurations. For example, spec
613 // prior to OpenGL 3.0 mandates framebuffer support only for one
614 // implementation-chosen format, and ES3.0 EXT_color_buffer_float does not
615 // support rendering to RGB32F. Check for framebuffer completeness with
616 // formats that the extensions expose, and only enable an extension when a
617 // framebuffer created with its texture format is reported as complete.
618 GLint fb_binding
= 0;
619 GLint tex_binding
= 0;
620 glGetIntegerv(GL_FRAMEBUFFER_BINDING
, &fb_binding
);
621 glGetIntegerv(GL_TEXTURE_BINDING_2D
, &tex_binding
);
627 glGenTextures(1, &tex_id
);
628 glGenFramebuffersEXT(1, &fb_id
);
629 glBindTexture(GL_TEXTURE_2D
, tex_id
);
630 // Nearest filter needed for framebuffer completeness on some drivers.
631 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
632 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA32F
, width
, width
, 0, GL_RGBA
,
634 glBindFramebufferEXT(GL_FRAMEBUFFER
, fb_id
);
635 glFramebufferTexture2DEXT(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
,
636 GL_TEXTURE_2D
, tex_id
, 0);
637 GLenum statusRGBA
= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER
);
638 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGB32F
, width
, width
, 0, GL_RGB
,
640 GLenum statusRGB
= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER
);
641 glDeleteFramebuffersEXT(1, &fb_id
);
642 glDeleteTextures(1, &tex_id
);
644 glBindFramebufferEXT(GL_FRAMEBUFFER
, static_cast<GLuint
>(fb_binding
));
645 glBindTexture(GL_TEXTURE_2D
, static_cast<GLuint
>(tex_binding
));
647 DCHECK(glGetError() == GL_NO_ERROR
);
649 if (statusRGBA
== GL_FRAMEBUFFER_COMPLETE
) {
650 validators_
.texture_internal_format
.AddValue(GL_RGBA32F
);
651 feature_flags_
.chromium_color_buffer_float_rgba
= true;
652 AddExtensionString("GL_CHROMIUM_color_buffer_float_rgba");
654 if (statusRGB
== GL_FRAMEBUFFER_COMPLETE
) {
655 validators_
.texture_internal_format
.AddValue(GL_RGB32F
);
656 feature_flags_
.chromium_color_buffer_float_rgb
= true;
657 AddExtensionString("GL_CHROMIUM_color_buffer_float_rgb");
661 // Check for multisample support
662 if (!workarounds_
.disable_chromium_framebuffer_multisample
) {
663 bool ext_has_multisample
=
664 extensions
.Contains("GL_EXT_framebuffer_multisample") ||
665 gl_version_info_
->is_es3
||
666 gl_version_info_
->is_desktop_core_profile
;
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
=
672 gl_version_info_
->is_es3
|| gl_version_info_
->is_desktop_core_profile
;
673 if (ext_has_multisample
) {
674 feature_flags_
.chromium_framebuffer_multisample
= true;
675 validators_
.frame_buffer_target
.AddValue(GL_READ_FRAMEBUFFER_EXT
);
676 validators_
.frame_buffer_target
.AddValue(GL_DRAW_FRAMEBUFFER_EXT
);
677 validators_
.g_l_state
.AddValue(GL_READ_FRAMEBUFFER_BINDING_EXT
);
678 validators_
.g_l_state
.AddValue(GL_MAX_SAMPLES_EXT
);
679 validators_
.render_buffer_parameter
.AddValue(GL_RENDERBUFFER_SAMPLES_EXT
);
680 AddExtensionString("GL_CHROMIUM_framebuffer_multisample");
684 if (!workarounds_
.disable_multisampled_render_to_texture
) {
685 if (extensions
.Contains("GL_EXT_multisampled_render_to_texture")) {
686 feature_flags_
.multisampled_render_to_texture
= true;
687 } else if (extensions
.Contains("GL_IMG_multisampled_render_to_texture")) {
688 feature_flags_
.multisampled_render_to_texture
= true;
689 feature_flags_
.use_img_for_multisampled_render_to_texture
= true;
691 if (feature_flags_
.multisampled_render_to_texture
) {
692 validators_
.render_buffer_parameter
.AddValue(
693 GL_RENDERBUFFER_SAMPLES_EXT
);
694 validators_
.g_l_state
.AddValue(GL_MAX_SAMPLES_EXT
);
695 validators_
.frame_buffer_parameter
.AddValue(
696 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT
);
697 AddExtensionString("GL_EXT_multisampled_render_to_texture");
701 if (extensions
.Contains("GL_OES_depth24") || gfx::HasDesktopGLFeatures() ||
702 gl_version_info_
->is_es3
) {
703 AddExtensionString("GL_OES_depth24");
704 feature_flags_
.oes_depth24
= true;
705 validators_
.render_buffer_format
.AddValue(GL_DEPTH_COMPONENT24
);
708 if (gl_version_info_
->is_es3
||
709 extensions
.Contains("GL_OES_standard_derivatives") ||
710 gfx::HasDesktopGLFeatures()) {
711 AddExtensionString("GL_OES_standard_derivatives");
712 feature_flags_
.oes_standard_derivatives
= true;
713 validators_
.hint_target
.AddValue(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES
);
714 validators_
.g_l_state
.AddValue(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES
);
717 if (extensions
.Contains("GL_OES_EGL_image_external")) {
718 AddExtensionString("GL_OES_EGL_image_external");
719 feature_flags_
.oes_egl_image_external
= true;
720 validators_
.texture_bind_target
.AddValue(GL_TEXTURE_EXTERNAL_OES
);
721 validators_
.get_tex_param_target
.AddValue(GL_TEXTURE_EXTERNAL_OES
);
722 validators_
.texture_parameter
.AddValue(GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES
);
723 validators_
.g_l_state
.AddValue(GL_TEXTURE_BINDING_EXTERNAL_OES
);
726 if (extensions
.Contains("GL_OES_compressed_ETC1_RGB8_texture")) {
727 AddExtensionString("GL_OES_compressed_ETC1_RGB8_texture");
728 feature_flags_
.oes_compressed_etc1_rgb8_texture
= true;
729 validators_
.compressed_texture_format
.AddValue(GL_ETC1_RGB8_OES
);
730 validators_
.texture_internal_format_storage
.AddValue(GL_ETC1_RGB8_OES
);
733 if (extensions
.Contains("GL_AMD_compressed_ATC_texture")) {
734 AddExtensionString("GL_AMD_compressed_ATC_texture");
735 validators_
.compressed_texture_format
.AddValue(
737 validators_
.compressed_texture_format
.AddValue(
738 GL_ATC_RGBA_EXPLICIT_ALPHA_AMD
);
739 validators_
.compressed_texture_format
.AddValue(
740 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD
);
742 validators_
.texture_internal_format_storage
.AddValue(
744 validators_
.texture_internal_format_storage
.AddValue(
745 GL_ATC_RGBA_EXPLICIT_ALPHA_AMD
);
746 validators_
.texture_internal_format_storage
.AddValue(
747 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD
);
750 if (extensions
.Contains("GL_IMG_texture_compression_pvrtc")) {
751 AddExtensionString("GL_IMG_texture_compression_pvrtc");
752 validators_
.compressed_texture_format
.AddValue(
753 GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG
);
754 validators_
.compressed_texture_format
.AddValue(
755 GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG
);
756 validators_
.compressed_texture_format
.AddValue(
757 GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
);
758 validators_
.compressed_texture_format
.AddValue(
759 GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
);
761 validators_
.texture_internal_format_storage
.AddValue(
762 GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG
);
763 validators_
.texture_internal_format_storage
.AddValue(
764 GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG
);
765 validators_
.texture_internal_format_storage
.AddValue(
766 GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
);
767 validators_
.texture_internal_format_storage
.AddValue(
768 GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
);
771 // Ideally we would only expose this extension on Mac OS X, to
772 // support GL_CHROMIUM_iosurface and the compositor. We don't want
773 // applications to start using it; they should use ordinary non-
774 // power-of-two textures. However, for unit testing purposes we
775 // expose it on all supported platforms.
776 if (extensions
.Contains("GL_ARB_texture_rectangle") ||
777 gl_version_info_
->is_desktop_core_profile
) {
778 AddExtensionString("GL_ARB_texture_rectangle");
779 feature_flags_
.arb_texture_rectangle
= true;
780 // Rectangle textures are used as samplers via glBindTexture, framebuffer
781 // textures via glFramebufferTexture2D, and copy destinations via
783 validators_
.texture_bind_target
.AddValue(GL_TEXTURE_RECTANGLE_ARB
);
784 validators_
.texture_target
.AddValue(GL_TEXTURE_RECTANGLE_ARB
);
785 validators_
.get_tex_param_target
.AddValue(GL_TEXTURE_RECTANGLE_ARB
);
786 validators_
.g_l_state
.AddValue(GL_TEXTURE_BINDING_RECTANGLE_ARB
);
789 #if defined(OS_MACOSX)
790 AddExtensionString("GL_CHROMIUM_iosurface");
793 if (extensions
.Contains("GL_APPLE_ycbcr_422")) {
794 AddExtensionString("GL_CHROMIUM_ycbcr_422_image");
795 feature_flags_
.chromium_image_ycbcr_422
= true;
798 // TODO(gman): Add support for these extensions.
801 feature_flags_
.enable_texture_float_linear
|= enable_texture_float_linear
;
802 feature_flags_
.enable_texture_half_float_linear
|=
803 enable_texture_half_float_linear
;
805 if (extensions
.Contains("GL_ANGLE_pack_reverse_row_order")) {
806 AddExtensionString("GL_ANGLE_pack_reverse_row_order");
807 feature_flags_
.angle_pack_reverse_row_order
= true;
808 validators_
.pixel_store
.AddValue(GL_PACK_REVERSE_ROW_ORDER_ANGLE
);
809 validators_
.g_l_state
.AddValue(GL_PACK_REVERSE_ROW_ORDER_ANGLE
);
812 if (extensions
.Contains("GL_ANGLE_texture_usage")) {
813 feature_flags_
.angle_texture_usage
= true;
814 AddExtensionString("GL_ANGLE_texture_usage");
815 validators_
.texture_parameter
.AddValue(GL_TEXTURE_USAGE_ANGLE
);
818 // Note: Only APPLE_texture_format_BGRA8888 extension allows BGRA8_EXT in
819 // ES3's glTexStorage2D. We prefer support BGRA to texture storage.
820 // So we don't expose GL_EXT_texture_storage when ES3 +
821 // GL_EXT_texture_format_BGRA8888 because we fail the GL_BGRA8 requirement.
822 // However we expose GL_EXT_texture_storage when just ES3 because we don't
823 // claim to handle GL_BGRA8.
824 bool support_texture_storage_on_es3
=
825 (gl_version_info_
->is_es3
&&
826 enable_immutable_texture_format_bgra_on_es3
) ||
827 (gl_version_info_
->is_es3
&&
828 !enable_texture_format_bgra8888
);
829 if (extensions
.Contains("GL_EXT_texture_storage") ||
830 extensions
.Contains("GL_ARB_texture_storage") ||
831 support_texture_storage_on_es3
||
832 gl_version_info_
->is_desktop_core_profile
) {
833 feature_flags_
.ext_texture_storage
= true;
834 AddExtensionString("GL_EXT_texture_storage");
835 validators_
.texture_parameter
.AddValue(GL_TEXTURE_IMMUTABLE_FORMAT_EXT
);
836 if (enable_texture_format_bgra8888
)
837 validators_
.texture_internal_format_storage
.AddValue(GL_BGRA8_EXT
);
838 if (enable_texture_float
) {
839 validators_
.texture_internal_format_storage
.AddValue(GL_RGBA32F_EXT
);
840 validators_
.texture_internal_format_storage
.AddValue(GL_RGB32F_EXT
);
841 validators_
.texture_internal_format_storage
.AddValue(GL_ALPHA32F_EXT
);
842 validators_
.texture_internal_format_storage
.AddValue(
843 GL_LUMINANCE32F_EXT
);
844 validators_
.texture_internal_format_storage
.AddValue(
845 GL_LUMINANCE_ALPHA32F_EXT
);
847 if (enable_texture_half_float
) {
848 validators_
.texture_internal_format_storage
.AddValue(GL_RGBA16F_EXT
);
849 validators_
.texture_internal_format_storage
.AddValue(GL_RGB16F_EXT
);
850 validators_
.texture_internal_format_storage
.AddValue(GL_ALPHA16F_EXT
);
851 validators_
.texture_internal_format_storage
.AddValue(
852 GL_LUMINANCE16F_EXT
);
853 validators_
.texture_internal_format_storage
.AddValue(
854 GL_LUMINANCE_ALPHA16F_EXT
);
858 bool have_ext_occlusion_query_boolean
=
859 extensions
.Contains("GL_EXT_occlusion_query_boolean");
860 bool have_arb_occlusion_query2
=
861 extensions
.Contains("GL_ARB_occlusion_query2");
862 bool have_arb_occlusion_query
=
863 extensions
.Contains("GL_ARB_occlusion_query");
865 if (have_ext_occlusion_query_boolean
||
866 have_arb_occlusion_query2
||
867 have_arb_occlusion_query
) {
868 AddExtensionString("GL_EXT_occlusion_query_boolean");
869 feature_flags_
.occlusion_query_boolean
= true;
870 feature_flags_
.use_arb_occlusion_query2_for_occlusion_query_boolean
=
871 !have_ext_occlusion_query_boolean
&& have_arb_occlusion_query2
;
872 feature_flags_
.use_arb_occlusion_query_for_occlusion_query_boolean
=
873 !have_ext_occlusion_query_boolean
&& have_arb_occlusion_query
&&
874 !have_arb_occlusion_query2
;
877 if (!workarounds_
.disable_angle_instanced_arrays
&&
878 (extensions
.Contains("GL_ANGLE_instanced_arrays") ||
879 (extensions
.Contains("GL_ARB_instanced_arrays") &&
880 extensions
.Contains("GL_ARB_draw_instanced")) ||
881 gl_version_info_
->is_es3
)) {
882 AddExtensionString("GL_ANGLE_instanced_arrays");
883 feature_flags_
.angle_instanced_arrays
= true;
884 validators_
.vertex_attribute
.AddValue(GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE
);
887 bool vendor_agnostic_draw_buffers
=
888 extensions
.Contains("GL_ARB_draw_buffers") ||
889 extensions
.Contains("GL_EXT_draw_buffers");
890 if (!workarounds_
.disable_ext_draw_buffers
&&
891 (vendor_agnostic_draw_buffers
||
892 (extensions
.Contains("GL_NV_draw_buffers") &&
893 gl_version_info_
->is_es3
) ||
894 gl_version_info_
->is_desktop_core_profile
)) {
895 AddExtensionString("GL_EXT_draw_buffers");
896 feature_flags_
.ext_draw_buffers
= true;
898 // This flag is set to enable emulation of EXT_draw_buffers when we're
899 // running on GLES 3.0+, NV_draw_buffers extension is supported and
900 // glDrawBuffers from GLES 3.0 core has been bound. It toggles using the
901 // NV_draw_buffers extension directive instead of EXT_draw_buffers extension
902 // directive in ESSL 100 shaders translated by ANGLE, enabling them to write
903 // into multiple gl_FragData values, which is not by default possible in
904 // ESSL 100 with core GLES 3.0. For more information, see the
905 // NV_draw_buffers specification.
906 feature_flags_
.nv_draw_buffers
= !vendor_agnostic_draw_buffers
;
908 GLint max_color_attachments
= 0;
909 glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT
, &max_color_attachments
);
910 for (GLenum i
= GL_COLOR_ATTACHMENT1_EXT
;
911 i
< static_cast<GLenum
>(GL_COLOR_ATTACHMENT0
+ max_color_attachments
);
913 validators_
.attachment
.AddValue(i
);
915 static_assert(GL_COLOR_ATTACHMENT0_EXT
== GL_COLOR_ATTACHMENT0
,
916 "GL_COLOR_ATTACHMENT0_EXT should equal GL_COLOR_ATTACHMENT0");
918 validators_
.g_l_state
.AddValue(GL_MAX_COLOR_ATTACHMENTS_EXT
);
919 validators_
.g_l_state
.AddValue(GL_MAX_DRAW_BUFFERS_ARB
);
920 GLint max_draw_buffers
= 0;
921 glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB
, &max_draw_buffers
);
922 for (GLenum i
= GL_DRAW_BUFFER0_ARB
;
923 i
< static_cast<GLenum
>(GL_DRAW_BUFFER0_ARB
+ max_draw_buffers
);
925 validators_
.g_l_state
.AddValue(i
);
929 if (gl_version_info_
->is_es3
||
930 extensions
.Contains("GL_EXT_blend_minmax") ||
931 gfx::HasDesktopGLFeatures()) {
932 AddExtensionString("GL_EXT_blend_minmax");
933 validators_
.equation
.AddValue(GL_MIN_EXT
);
934 validators_
.equation
.AddValue(GL_MAX_EXT
);
935 static_assert(GL_MIN_EXT
== GL_MIN
&& GL_MAX_EXT
== GL_MAX
,
936 "min & max variations must match");
939 // TODO(dshwang): GLES3 supports gl_FragDepth, not gl_FragDepthEXT.
940 if (extensions
.Contains("GL_EXT_frag_depth") || gfx::HasDesktopGLFeatures()) {
941 AddExtensionString("GL_EXT_frag_depth");
942 feature_flags_
.ext_frag_depth
= true;
945 if (extensions
.Contains("GL_EXT_shader_texture_lod") ||
946 gfx::HasDesktopGLFeatures()) {
947 AddExtensionString("GL_EXT_shader_texture_lod");
948 feature_flags_
.ext_shader_texture_lod
= true;
951 bool ui_gl_fence_works
= gfx::GLFence::IsSupported();
952 UMA_HISTOGRAM_BOOLEAN("GPU.FenceSupport", ui_gl_fence_works
);
954 feature_flags_
.map_buffer_range
=
955 gl_version_info_
->is_es3
||
956 gl_version_info_
->is_desktop_core_profile
||
957 extensions
.Contains("GL_ARB_map_buffer_range") ||
958 extensions
.Contains("GL_EXT_map_buffer_range");
960 // Really it's part of core OpenGL 2.1 and up, but let's assume the
961 // extension is still advertised.
962 bool has_pixel_buffers
=
963 gl_version_info_
->is_es3
||
964 gl_version_info_
->is_desktop_core_profile
||
965 extensions
.Contains("GL_ARB_pixel_buffer_object") ||
966 extensions
.Contains("GL_NV_pixel_buffer_object");
968 // We will use either glMapBuffer() or glMapBufferRange() for async readbacks.
969 if (has_pixel_buffers
&& ui_gl_fence_works
&&
970 !workarounds_
.disable_async_readpixels
) {
971 feature_flags_
.use_async_readpixels
= true;
974 if (gl_version_info_
->is_es3
||
975 extensions
.Contains("GL_ARB_sampler_objects")) {
976 feature_flags_
.enable_samplers
= true;
977 // TODO(dsinclair): Add AddExtensionString("GL_CHROMIUM_sampler_objects")
981 if ((gl_version_info_
->is_es3
||
982 extensions
.Contains("GL_EXT_discard_framebuffer")) &&
983 !workarounds_
.disable_discard_framebuffer
) {
984 // DiscardFramebufferEXT is automatically bound to InvalidateFramebuffer.
985 AddExtensionString("GL_EXT_discard_framebuffer");
986 feature_flags_
.ext_discard_framebuffer
= true;
989 if (ui_gl_fence_works
) {
990 AddExtensionString("GL_CHROMIUM_sync_query");
991 feature_flags_
.chromium_sync_query
= true;
994 if (!workarounds_
.disable_blend_equation_advanced
) {
995 bool blend_equation_advanced_coherent
=
996 extensions
.Contains("GL_NV_blend_equation_advanced_coherent") ||
997 extensions
.Contains("GL_KHR_blend_equation_advanced_coherent");
999 if (blend_equation_advanced_coherent
||
1000 extensions
.Contains("GL_NV_blend_equation_advanced") ||
1001 extensions
.Contains("GL_KHR_blend_equation_advanced")) {
1002 const GLenum equations
[] = {GL_MULTIPLY_KHR
,
1014 GL_HSL_SATURATION_KHR
,
1016 GL_HSL_LUMINOSITY_KHR
};
1018 for (GLenum equation
: equations
)
1019 validators_
.equation
.AddValue(equation
);
1020 if (blend_equation_advanced_coherent
)
1021 AddExtensionString("GL_KHR_blend_equation_advanced_coherent");
1023 AddExtensionString("GL_KHR_blend_equation_advanced");
1024 feature_flags_
.blend_equation_advanced
= true;
1025 feature_flags_
.blend_equation_advanced_coherent
=
1026 blend_equation_advanced_coherent
;
1030 if (enable_gl_path_rendering_switch_
&&
1031 !workarounds_
.disable_gl_path_rendering
&&
1032 extensions
.Contains("GL_NV_path_rendering") &&
1033 (extensions
.Contains("GL_EXT_direct_state_access") ||
1034 gl_version_info_
->is_es3
)) {
1035 AddExtensionString("GL_CHROMIUM_path_rendering");
1036 feature_flags_
.chromium_path_rendering
= true;
1037 validators_
.g_l_state
.AddValue(GL_PATH_MODELVIEW_MATRIX_CHROMIUM
);
1038 validators_
.g_l_state
.AddValue(GL_PATH_PROJECTION_MATRIX_CHROMIUM
);
1039 validators_
.g_l_state
.AddValue(GL_PATH_STENCIL_FUNC_CHROMIUM
);
1040 validators_
.g_l_state
.AddValue(GL_PATH_STENCIL_REF_CHROMIUM
);
1041 validators_
.g_l_state
.AddValue(GL_PATH_STENCIL_VALUE_MASK_CHROMIUM
);
1044 if ((gl_version_info_
->is_es3
|| gl_version_info_
->is_desktop_core_profile
||
1045 extensions
.Contains("GL_EXT_texture_rg") ||
1046 extensions
.Contains("GL_ARB_texture_rg")) &&
1047 IsGL_REDSupportedOnFBOs()) {
1048 feature_flags_
.ext_texture_rg
= true;
1049 AddExtensionString("GL_EXT_texture_rg");
1051 validators_
.texture_format
.AddValue(GL_RED_EXT
);
1052 validators_
.texture_format
.AddValue(GL_RG_EXT
);
1053 validators_
.texture_internal_format
.AddValue(GL_RED_EXT
);
1054 validators_
.texture_internal_format
.AddValue(GL_R8_EXT
);
1055 validators_
.texture_internal_format
.AddValue(GL_RG_EXT
);
1056 validators_
.texture_internal_format
.AddValue(GL_RG8_EXT
);
1057 validators_
.read_pixel_format
.AddValue(GL_RED_EXT
);
1058 validators_
.read_pixel_format
.AddValue(GL_RG_EXT
);
1059 validators_
.render_buffer_format
.AddValue(GL_R8_EXT
);
1060 validators_
.render_buffer_format
.AddValue(GL_RG8_EXT
);
1062 UMA_HISTOGRAM_BOOLEAN("GPU.TextureRG", feature_flags_
.ext_texture_rg
);
1064 #if !defined(OS_MACOSX)
1065 if (workarounds_
.ignore_egl_sync_failures
) {
1066 gfx::GLFenceEGL::SetIgnoreFailures();
1070 if (workarounds_
.avoid_egl_image_target_texture_reuse
) {
1071 TextureDefinition::AvoidEGLTargetTextureReuse();
1074 if (gl_version_info_
->IsLowerThanGL(4, 3)) {
1075 // crbug.com/481184.
1076 // GL_PRIMITIVE_RESTART_FIXED_INDEX is only available on Desktop GL 4.3+,
1077 // but we emulate ES 3.0 on top of Desktop GL 4.2+.
1078 feature_flags_
.emulate_primitive_restart_fixed_index
= true;
1082 bool FeatureInfo::IsES3Capable() const {
1083 if (!enable_unsafe_es3_apis_switch_
)
1085 if (gl_version_info_
)
1086 return gl_version_info_
->IsES3Capable();
1090 void FeatureInfo::EnableES3Validators() {
1091 DCHECK(IsES3Capable());
1092 validators_
.UpdateValuesES3();
1094 GLint max_color_attachments
= 0;
1095 glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS
, &max_color_attachments
);
1096 const int kTotalColorAttachmentEnums
= 16;
1097 const GLenum kColorAttachments
[] = {
1098 GL_COLOR_ATTACHMENT0
,
1099 GL_COLOR_ATTACHMENT1
,
1100 GL_COLOR_ATTACHMENT2
,
1101 GL_COLOR_ATTACHMENT3
,
1102 GL_COLOR_ATTACHMENT4
,
1103 GL_COLOR_ATTACHMENT5
,
1104 GL_COLOR_ATTACHMENT6
,
1105 GL_COLOR_ATTACHMENT7
,
1106 GL_COLOR_ATTACHMENT8
,
1107 GL_COLOR_ATTACHMENT9
,
1108 GL_COLOR_ATTACHMENT10
,
1109 GL_COLOR_ATTACHMENT11
,
1110 GL_COLOR_ATTACHMENT12
,
1111 GL_COLOR_ATTACHMENT13
,
1112 GL_COLOR_ATTACHMENT14
,
1113 GL_COLOR_ATTACHMENT15
,
1115 if (max_color_attachments
< kTotalColorAttachmentEnums
) {
1116 validators_
.attachment
.RemoveValues(
1117 kColorAttachments
+ max_color_attachments
,
1118 kTotalColorAttachmentEnums
- max_color_attachments
);
1121 GLint max_draw_buffers
= 0;
1122 glGetIntegerv(GL_MAX_DRAW_BUFFERS
, &max_draw_buffers
);
1123 const int kTotalDrawBufferEnums
= 16;
1124 const GLenum kDrawBuffers
[] = {
1142 if (max_draw_buffers
< kTotalDrawBufferEnums
) {
1143 validators_
.g_l_state
.RemoveValues(
1144 kDrawBuffers
+ max_draw_buffers
,
1145 kTotalDrawBufferEnums
- max_draw_buffers
);
1148 unsafe_es3_apis_enabled_
= true;
1151 void FeatureInfo::AddExtensionString(const char* s
) {
1153 size_t pos
= extensions_
.find(str
);
1154 while (pos
!= std::string::npos
&&
1155 pos
+ str
.length() < extensions_
.length() &&
1156 extensions_
.substr(pos
+ str
.length(), 1) != " ") {
1157 // This extension name is a substring of another.
1158 pos
= extensions_
.find(str
, pos
+ str
.length());
1160 if (pos
== std::string::npos
) {
1161 extensions_
+= (extensions_
.empty() ? "" : " ") + str
;
1165 FeatureInfo::~FeatureInfo() {
1168 } // namespace gles2