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_astc(false),
150 ext_texture_format_atc(false),
151 ext_texture_format_bgra8888(false),
152 ext_texture_format_dxt1(false),
153 ext_texture_format_dxt5(false),
154 enable_shader_name_hashing(false),
155 enable_samplers(false),
156 ext_draw_buffers(false),
157 nv_draw_buffers(false),
158 ext_frag_depth(false),
159 ext_shader_texture_lod(false),
160 use_async_readpixels(false),
161 map_buffer_range(false),
162 ext_discard_framebuffer(false),
163 angle_depth_texture(false),
164 is_swiftshader(false),
165 angle_texture_usage(false),
166 ext_texture_storage(false),
167 chromium_path_rendering(false),
168 blend_equation_advanced(false),
169 blend_equation_advanced_coherent(false),
170 ext_texture_rg(false),
171 chromium_image_ycbcr_422(false),
172 enable_subscribe_uniform(false),
173 emulate_primitive_restart_fixed_index(false),
174 ext_render_buffer_format_bgra8888(false) {}
176 FeatureInfo::Workarounds::Workarounds() :
177 #define GPU_OP(type, name) name(false),
178 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP
)
181 max_cube_map_texture_size(0),
182 max_fragment_uniform_vectors(0),
183 max_varying_vectors(0),
184 max_vertex_uniform_vectors(0),
185 max_copy_texture_chromium_size(0) {
188 FeatureInfo::FeatureInfo() {
189 InitializeBasicState(base::CommandLine::InitializedForCurrentProcess()
190 ? base::CommandLine::ForCurrentProcess()
194 FeatureInfo::FeatureInfo(const base::CommandLine
& command_line
) {
195 InitializeBasicState(&command_line
);
198 void FeatureInfo::InitializeBasicState(const base::CommandLine
* command_line
) {
202 if (command_line
->HasSwitch(switches::kGpuDriverBugWorkarounds
)) {
203 std::string types
= command_line
->GetSwitchValueASCII(
204 switches::kGpuDriverBugWorkarounds
);
205 StringToWorkarounds(types
, &workarounds_
);
207 feature_flags_
.enable_shader_name_hashing
=
208 !command_line
->HasSwitch(switches::kDisableShaderNameHashing
);
210 feature_flags_
.is_swiftshader
=
211 (command_line
->GetSwitchValueASCII(switches::kUseGL
) == "swiftshader");
213 feature_flags_
.enable_subscribe_uniform
=
214 command_line
->HasSwitch(switches::kEnableSubscribeUniformExtension
);
216 enable_unsafe_es3_apis_switch_
=
217 command_line
->HasSwitch(switches::kEnableUnsafeES3APIs
);
219 enable_gl_path_rendering_switch_
=
220 command_line
->HasSwitch(switches::kEnableGLPathRendering
);
222 unsafe_es3_apis_enabled_
= false;
225 bool FeatureInfo::Initialize() {
226 disallowed_features_
= DisallowedFeatures();
227 InitializeFeatures();
231 bool FeatureInfo::Initialize(const DisallowedFeatures
& disallowed_features
) {
232 disallowed_features_
= disallowed_features
;
233 InitializeFeatures();
237 bool IsGL_REDSupportedOnFBOs() {
238 // Skia uses GL_RED with frame buffers, unfortunately, Mesa claims to support
239 // GL_EXT_texture_rg, but it doesn't support it on frame buffers. To fix
240 // this, we try it, and if it fails, we don't expose GL_EXT_texture_rg.
241 GLint fb_binding
= 0;
242 GLint tex_binding
= 0;
243 glGetIntegerv(GL_FRAMEBUFFER_BINDING
, &fb_binding
);
244 glGetIntegerv(GL_TEXTURE_BINDING_2D
, &tex_binding
);
246 GLuint textureId
= 0;
247 glGenTextures(1, &textureId
);
248 glBindTexture(GL_TEXTURE_2D
, textureId
);
249 GLubyte data
[1] = {0};
250 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RED_EXT
, 1, 1, 0, GL_RED_EXT
,
251 GL_UNSIGNED_BYTE
, data
);
252 GLuint textureFBOID
= 0;
253 glGenFramebuffersEXT(1, &textureFBOID
);
254 glBindFramebufferEXT(GL_FRAMEBUFFER
, textureFBOID
);
255 glFramebufferTexture2DEXT(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
,
258 glCheckFramebufferStatusEXT(GL_FRAMEBUFFER
) != GL_FRAMEBUFFER_UNSUPPORTED
;
259 glDeleteFramebuffersEXT(1, &textureFBOID
);
260 glDeleteTextures(1, &textureId
);
262 glBindFramebufferEXT(GL_FRAMEBUFFER
, static_cast<GLuint
>(fb_binding
));
263 glBindTexture(GL_TEXTURE_2D
, static_cast<GLuint
>(tex_binding
));
265 DCHECK(glGetError() == GL_NO_ERROR
);
270 void FeatureInfo::InitializeFeatures() {
271 // Figure out what extensions to turn on.
272 StringSet
extensions(gfx::GetGLExtensionsFromCurrentContext());
274 const char* version_str
=
275 reinterpret_cast<const char*>(glGetString(GL_VERSION
));
276 const char* renderer_str
=
277 reinterpret_cast<const char*>(glGetString(GL_RENDERER
));
279 gl_version_info_
.reset(new gfx::GLVersionInfo(
280 version_str
, renderer_str
, extensions
.GetImpl()));
282 AddExtensionString("GL_ANGLE_translated_shader_source");
283 AddExtensionString("GL_CHROMIUM_async_pixel_transfers");
284 AddExtensionString("GL_CHROMIUM_bind_uniform_location");
285 AddExtensionString("GL_CHROMIUM_command_buffer_query");
286 AddExtensionString("GL_CHROMIUM_command_buffer_latency_query");
287 AddExtensionString("GL_CHROMIUM_copy_texture");
288 AddExtensionString("GL_CHROMIUM_get_error_query");
289 AddExtensionString("GL_CHROMIUM_lose_context");
290 AddExtensionString("GL_CHROMIUM_pixel_transfer_buffer_object");
291 AddExtensionString("GL_CHROMIUM_rate_limit_offscreen_context");
292 AddExtensionString("GL_CHROMIUM_resize");
293 AddExtensionString("GL_CHROMIUM_resource_safe");
294 AddExtensionString("GL_CHROMIUM_strict_attribs");
295 AddExtensionString("GL_CHROMIUM_texture_mailbox");
296 AddExtensionString("GL_CHROMIUM_trace_marker");
297 AddExtensionString("GL_EXT_debug_marker");
299 if (feature_flags_
.enable_subscribe_uniform
) {
300 AddExtensionString("GL_CHROMIUM_subscribe_uniform");
303 // OES_vertex_array_object is emulated if not present natively,
304 // so the extension string is always exposed.
305 AddExtensionString("GL_OES_vertex_array_object");
307 if (!disallowed_features_
.gpu_memory_manager
)
308 AddExtensionString("GL_CHROMIUM_gpu_memory_manager");
310 if (extensions
.Contains("GL_ANGLE_translated_shader_source")) {
311 feature_flags_
.angle_translated_shader_source
= true;
314 // Check if we should allow GL_EXT_texture_compression_dxt1 and
315 // GL_EXT_texture_compression_s3tc.
316 bool enable_dxt1
= false;
317 bool enable_dxt3
= false;
318 bool enable_dxt5
= false;
319 bool have_s3tc
= extensions
.Contains("GL_EXT_texture_compression_s3tc");
321 have_s3tc
|| extensions
.Contains("GL_ANGLE_texture_compression_dxt3");
323 have_s3tc
|| extensions
.Contains("GL_ANGLE_texture_compression_dxt5");
325 if (extensions
.Contains("GL_EXT_texture_compression_dxt1") || have_s3tc
) {
336 feature_flags_
.ext_texture_format_dxt1
= true;
338 AddExtensionString("GL_EXT_texture_compression_dxt1");
339 validators_
.compressed_texture_format
.AddValue(
340 GL_COMPRESSED_RGB_S3TC_DXT1_EXT
);
341 validators_
.compressed_texture_format
.AddValue(
342 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
);
344 validators_
.texture_internal_format_storage
.AddValue(
345 GL_COMPRESSED_RGB_S3TC_DXT1_EXT
);
346 validators_
.texture_internal_format_storage
.AddValue(
347 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
);
351 // The difference between GL_EXT_texture_compression_s3tc and
352 // GL_CHROMIUM_texture_compression_dxt3 is that the former
353 // requires on the fly compression. The latter does not.
354 AddExtensionString("GL_CHROMIUM_texture_compression_dxt3");
355 validators_
.compressed_texture_format
.AddValue(
356 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
);
357 validators_
.texture_internal_format_storage
.AddValue(
358 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
);
362 feature_flags_
.ext_texture_format_dxt5
= true;
364 // The difference between GL_EXT_texture_compression_s3tc and
365 // GL_CHROMIUM_texture_compression_dxt5 is that the former
366 // requires on the fly compression. The latter does not.
367 AddExtensionString("GL_CHROMIUM_texture_compression_dxt5");
368 validators_
.compressed_texture_format
.AddValue(
369 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
);
370 validators_
.texture_internal_format_storage
.AddValue(
371 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
);
374 bool have_astc
= extensions
.Contains("GL_KHR_texture_compression_astc_ldr");
376 feature_flags_
.ext_texture_format_astc
= true;
377 AddExtensionString("GL_KHR_texture_compression_astc_ldr");
379 // GL_COMPRESSED_RGBA_ASTC(0x93B0 ~ 0x93BD)
380 GLint astc_format_it
= GL_COMPRESSED_RGBA_ASTC_4x4_KHR
;
381 GLint astc_format_max
= GL_COMPRESSED_RGBA_ASTC_12x12_KHR
;
382 for (; astc_format_it
<= astc_format_max
; astc_format_it
++)
383 validators_
.compressed_texture_format
.AddValue(astc_format_it
);
385 // GL_COMPRESSED_SRGB8_ALPHA8_ASTC(0x93D0 ~ 0x93DD)
386 astc_format_it
= GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR
;
387 astc_format_max
= GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR
;
388 for (; astc_format_it
<= astc_format_max
; astc_format_it
++)
389 validators_
.compressed_texture_format
.AddValue(astc_format_it
);
392 bool have_atc
= extensions
.Contains("GL_AMD_compressed_ATC_texture") ||
393 extensions
.Contains("GL_ATI_texture_compression_atitc");
395 feature_flags_
.ext_texture_format_atc
= true;
397 AddExtensionString("GL_AMD_compressed_ATC_texture");
398 validators_
.compressed_texture_format
.AddValue(GL_ATC_RGB_AMD
);
399 validators_
.compressed_texture_format
.AddValue(
400 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD
);
402 validators_
.texture_internal_format_storage
.AddValue(GL_ATC_RGB_AMD
);
403 validators_
.texture_internal_format_storage
.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 validators_
.texture_internal_format
.AddValue(GL_DEPTH_COMPONENT
);
444 validators_
.texture_format
.AddValue(GL_DEPTH_COMPONENT
);
445 validators_
.pixel_type
.AddValue(GL_UNSIGNED_SHORT
);
446 validators_
.pixel_type
.AddValue(GL_UNSIGNED_INT
);
449 if (extensions
.Contains("GL_EXT_packed_depth_stencil") ||
450 extensions
.Contains("GL_OES_packed_depth_stencil") ||
451 gl_version_info_
->is_es3
||
452 gl_version_info_
->is_desktop_core_profile
) {
453 AddExtensionString("GL_OES_packed_depth_stencil");
454 feature_flags_
.packed_depth24_stencil8
= true;
455 if (enable_depth_texture
) {
456 validators_
.texture_internal_format
.AddValue(GL_DEPTH_STENCIL
);
457 validators_
.texture_format
.AddValue(GL_DEPTH_STENCIL
);
458 validators_
.pixel_type
.AddValue(GL_UNSIGNED_INT_24_8
);
460 validators_
.render_buffer_format
.AddValue(GL_DEPTH24_STENCIL8
);
463 if (gl_version_info_
->is_es3
||
464 gl_version_info_
->is_desktop_core_profile
||
465 extensions
.Contains("GL_OES_vertex_array_object") ||
466 extensions
.Contains("GL_ARB_vertex_array_object") ||
467 extensions
.Contains("GL_APPLE_vertex_array_object")) {
468 feature_flags_
.native_vertex_array_object
= true;
471 // If we're using client_side_arrays we have to emulate
472 // vertex array objects since vertex array objects do not work
473 // with client side arrays.
474 if (workarounds_
.use_client_side_arrays_for_stream_buffers
) {
475 feature_flags_
.native_vertex_array_object
= false;
478 if (gl_version_info_
->is_es3
||
479 extensions
.Contains("GL_OES_element_index_uint") ||
480 gfx::HasDesktopGLFeatures()) {
481 AddExtensionString("GL_OES_element_index_uint");
482 validators_
.index_type
.AddValue(GL_UNSIGNED_INT
);
485 // With EXT_sRGB, unsized SRGB_EXT and SRGB_ALPHA_EXT are accepted by the
486 // <format> and <internalformat> parameter of TexImage2D. GLES3 adds support
487 // for SRGB Textures but the accepted internal formats for TexImage2D are only
488 // sized formats GL_SRGB8 and GL_SRGB8_ALPHA8. Also, SRGB_EXT isn't a valid
489 // <format> in this case. So, even with GLES3 explicitly check for
491 if (((gl_version_info_
->is_es3
||
492 extensions
.Contains("GL_OES_rgb8_rgba8")) &&
493 extensions
.Contains("GL_EXT_sRGB")) || gfx::HasDesktopGLFeatures()) {
494 AddExtensionString("GL_EXT_sRGB");
495 validators_
.texture_internal_format
.AddValue(GL_SRGB_EXT
);
496 validators_
.texture_internal_format
.AddValue(GL_SRGB_ALPHA_EXT
);
497 validators_
.texture_format
.AddValue(GL_SRGB_EXT
);
498 validators_
.texture_format
.AddValue(GL_SRGB_ALPHA_EXT
);
499 validators_
.render_buffer_format
.AddValue(GL_SRGB8_ALPHA8_EXT
);
500 validators_
.frame_buffer_parameter
.AddValue(
501 GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT
);
504 bool enable_texture_format_bgra8888
= false;
505 bool enable_read_format_bgra
= false;
506 bool enable_render_buffer_bgra
= false;
507 bool enable_immutable_texture_format_bgra_on_es3
=
508 extensions
.Contains("GL_APPLE_texture_format_BGRA8888");
510 // Check if we should allow GL_EXT_texture_format_BGRA8888
511 if (extensions
.Contains("GL_EXT_texture_format_BGRA8888") ||
512 enable_immutable_texture_format_bgra_on_es3
||
513 !gl_version_info_
->is_es
) {
514 enable_texture_format_bgra8888
= true;
517 // Only desktop GL extension GL_EXT_bgra or ANGLE guarantee that we can
518 // allocate a renderbuffer with this format.
519 if (extensions
.Contains("GL_EXT_bgra") || gl_version_info_
->is_angle
) {
520 enable_render_buffer_bgra
= true;
523 if (extensions
.Contains("GL_EXT_read_format_bgra") ||
524 extensions
.Contains("GL_EXT_bgra")) {
525 enable_read_format_bgra
= true;
528 if (enable_texture_format_bgra8888
) {
529 feature_flags_
.ext_texture_format_bgra8888
= true;
530 AddExtensionString("GL_EXT_texture_format_BGRA8888");
531 validators_
.texture_internal_format
.AddValue(GL_BGRA_EXT
);
532 validators_
.texture_format
.AddValue(GL_BGRA_EXT
);
535 if (enable_read_format_bgra
) {
536 AddExtensionString("GL_EXT_read_format_bgra");
537 validators_
.read_pixel_format
.AddValue(GL_BGRA_EXT
);
540 // We only support timer queries if we also support glGetInteger64v.
541 // For GL_EXT_disjoint_timer_query, glGetInteger64v is only support under ES3.
542 if ((gl_version_info_
->is_es3
&&
543 extensions
.Contains("GL_EXT_disjoint_timer_query")) ||
544 extensions
.Contains("GL_ARB_timer_query") ||
545 extensions
.Contains("GL_EXT_timer_query")) {
546 AddExtensionString("GL_EXT_disjoint_timer_query");
549 if (enable_render_buffer_bgra
) {
550 feature_flags_
.ext_render_buffer_format_bgra8888
= true;
551 AddExtensionString("GL_CHROMIUM_renderbuffer_format_BGRA8888");
552 validators_
.render_buffer_format
.AddValue(GL_BGRA8_EXT
);
555 if (extensions
.Contains("GL_OES_rgb8_rgba8") || gfx::HasDesktopGLFeatures()) {
556 AddExtensionString("GL_OES_rgb8_rgba8");
557 validators_
.render_buffer_format
.AddValue(GL_RGB8_OES
);
558 validators_
.render_buffer_format
.AddValue(GL_RGBA8_OES
);
561 // Check if we should allow GL_OES_texture_npot
562 if (!disallowed_features_
.npot_support
&&
563 (gl_version_info_
->is_es3
||
564 gl_version_info_
->is_desktop_core_profile
||
565 extensions
.Contains("GL_ARB_texture_non_power_of_two") ||
566 extensions
.Contains("GL_OES_texture_npot"))) {
567 AddExtensionString("GL_OES_texture_npot");
568 feature_flags_
.npot_ok
= true;
571 // Check if we should allow GL_OES_texture_float, GL_OES_texture_half_float,
572 // GL_OES_texture_float_linear, GL_OES_texture_half_float_linear
573 bool enable_texture_float
= false;
574 bool enable_texture_float_linear
= false;
575 bool enable_texture_half_float
= false;
576 bool enable_texture_half_float_linear
= false;
578 bool may_enable_chromium_color_buffer_float
= false;
580 if (extensions
.Contains("GL_ARB_texture_float") ||
581 gl_version_info_
->is_desktop_core_profile
) {
582 enable_texture_float
= true;
583 enable_texture_float_linear
= true;
584 enable_texture_half_float
= true;
585 enable_texture_half_float_linear
= true;
586 may_enable_chromium_color_buffer_float
= true;
588 // GLES3 adds support for Float type by default but it doesn't support all
589 // formats as GL_OES_texture_float(i.e.LUMINANCE_ALPHA,LUMINANCE and Alpha)
590 if (extensions
.Contains("GL_OES_texture_float")) {
591 enable_texture_float
= true;
592 if (extensions
.Contains("GL_OES_texture_float_linear")) {
593 enable_texture_float_linear
= true;
595 // This extension allows a variety of floating point formats to be
596 // rendered to via framebuffer objects. Enable it's usage only if
597 // support for Floating textures is enabled.
598 if ((gl_version_info_
->is_es3
&&
599 extensions
.Contains("GL_EXT_color_buffer_float")) ||
600 gl_version_info_
->is_angle
) {
601 may_enable_chromium_color_buffer_float
= true;
605 // TODO(dshwang): GLES3 supports half float by default but GL_HALF_FLOAT_OES
606 // isn't equal to GL_HALF_FLOAT.
607 if (extensions
.Contains("GL_OES_texture_half_float")) {
608 enable_texture_half_float
= true;
609 if (extensions
.Contains("GL_OES_texture_half_float_linear")) {
610 enable_texture_half_float_linear
= true;
615 if (enable_texture_float
) {
616 validators_
.pixel_type
.AddValue(GL_FLOAT
);
617 validators_
.read_pixel_type
.AddValue(GL_FLOAT
);
618 AddExtensionString("GL_OES_texture_float");
619 if (enable_texture_float_linear
) {
620 AddExtensionString("GL_OES_texture_float_linear");
624 if (enable_texture_half_float
) {
625 validators_
.pixel_type
.AddValue(GL_HALF_FLOAT_OES
);
626 validators_
.read_pixel_type
.AddValue(GL_HALF_FLOAT_OES
);
627 AddExtensionString("GL_OES_texture_half_float");
628 if (enable_texture_half_float_linear
) {
629 AddExtensionString("GL_OES_texture_half_float_linear");
633 if (may_enable_chromium_color_buffer_float
) {
634 static_assert(GL_RGBA32F_ARB
== GL_RGBA32F
&&
635 GL_RGBA32F_EXT
== GL_RGBA32F
&&
636 GL_RGB32F_ARB
== GL_RGB32F
&&
637 GL_RGB32F_EXT
== GL_RGB32F
,
638 "sized float internal format variations must match");
639 // We don't check extension support beyond ARB_texture_float on desktop GL,
640 // and format support varies between GL configurations. For example, spec
641 // prior to OpenGL 3.0 mandates framebuffer support only for one
642 // implementation-chosen format, and ES3.0 EXT_color_buffer_float does not
643 // support rendering to RGB32F. Check for framebuffer completeness with
644 // formats that the extensions expose, and only enable an extension when a
645 // framebuffer created with its texture format is reported as complete.
646 GLint fb_binding
= 0;
647 GLint tex_binding
= 0;
648 glGetIntegerv(GL_FRAMEBUFFER_BINDING
, &fb_binding
);
649 glGetIntegerv(GL_TEXTURE_BINDING_2D
, &tex_binding
);
655 glGenTextures(1, &tex_id
);
656 glGenFramebuffersEXT(1, &fb_id
);
657 glBindTexture(GL_TEXTURE_2D
, tex_id
);
658 // Nearest filter needed for framebuffer completeness on some drivers.
659 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
660 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA32F
, width
, width
, 0, GL_RGBA
,
662 glBindFramebufferEXT(GL_FRAMEBUFFER
, fb_id
);
663 glFramebufferTexture2DEXT(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
,
664 GL_TEXTURE_2D
, tex_id
, 0);
665 GLenum statusRGBA
= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER
);
666 glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGB32F
, width
, width
, 0, GL_RGB
,
668 GLenum statusRGB
= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER
);
669 glDeleteFramebuffersEXT(1, &fb_id
);
670 glDeleteTextures(1, &tex_id
);
672 glBindFramebufferEXT(GL_FRAMEBUFFER
, static_cast<GLuint
>(fb_binding
));
673 glBindTexture(GL_TEXTURE_2D
, static_cast<GLuint
>(tex_binding
));
675 DCHECK(glGetError() == GL_NO_ERROR
);
677 if (statusRGBA
== GL_FRAMEBUFFER_COMPLETE
) {
678 validators_
.texture_internal_format
.AddValue(GL_RGBA32F
);
679 feature_flags_
.chromium_color_buffer_float_rgba
= true;
680 AddExtensionString("GL_CHROMIUM_color_buffer_float_rgba");
682 if (statusRGB
== GL_FRAMEBUFFER_COMPLETE
) {
683 validators_
.texture_internal_format
.AddValue(GL_RGB32F
);
684 feature_flags_
.chromium_color_buffer_float_rgb
= true;
685 AddExtensionString("GL_CHROMIUM_color_buffer_float_rgb");
689 // Check for multisample support
690 if (!workarounds_
.disable_chromium_framebuffer_multisample
) {
691 bool ext_has_multisample
=
692 extensions
.Contains("GL_EXT_framebuffer_multisample") ||
693 gl_version_info_
->is_es3
||
694 gl_version_info_
->is_desktop_core_profile
;
695 if (gl_version_info_
->is_angle
) {
696 ext_has_multisample
|=
697 extensions
.Contains("GL_ANGLE_framebuffer_multisample");
699 feature_flags_
.use_core_framebuffer_multisample
=
700 gl_version_info_
->is_es3
|| gl_version_info_
->is_desktop_core_profile
;
701 if (ext_has_multisample
) {
702 feature_flags_
.chromium_framebuffer_multisample
= true;
703 validators_
.frame_buffer_target
.AddValue(GL_READ_FRAMEBUFFER_EXT
);
704 validators_
.frame_buffer_target
.AddValue(GL_DRAW_FRAMEBUFFER_EXT
);
705 validators_
.g_l_state
.AddValue(GL_READ_FRAMEBUFFER_BINDING_EXT
);
706 validators_
.g_l_state
.AddValue(GL_MAX_SAMPLES_EXT
);
707 validators_
.render_buffer_parameter
.AddValue(GL_RENDERBUFFER_SAMPLES_EXT
);
708 AddExtensionString("GL_CHROMIUM_framebuffer_multisample");
712 if (!workarounds_
.disable_multisampled_render_to_texture
) {
713 if (extensions
.Contains("GL_EXT_multisampled_render_to_texture")) {
714 feature_flags_
.multisampled_render_to_texture
= true;
715 } else if (extensions
.Contains("GL_IMG_multisampled_render_to_texture")) {
716 feature_flags_
.multisampled_render_to_texture
= true;
717 feature_flags_
.use_img_for_multisampled_render_to_texture
= true;
719 if (feature_flags_
.multisampled_render_to_texture
) {
720 validators_
.render_buffer_parameter
.AddValue(
721 GL_RENDERBUFFER_SAMPLES_EXT
);
722 validators_
.g_l_state
.AddValue(GL_MAX_SAMPLES_EXT
);
723 validators_
.frame_buffer_parameter
.AddValue(
724 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT
);
725 AddExtensionString("GL_EXT_multisampled_render_to_texture");
729 if (extensions
.Contains("GL_OES_depth24") || gfx::HasDesktopGLFeatures() ||
730 gl_version_info_
->is_es3
) {
731 AddExtensionString("GL_OES_depth24");
732 feature_flags_
.oes_depth24
= true;
733 validators_
.render_buffer_format
.AddValue(GL_DEPTH_COMPONENT24
);
736 if (gl_version_info_
->is_es3
||
737 extensions
.Contains("GL_OES_standard_derivatives") ||
738 gfx::HasDesktopGLFeatures()) {
739 AddExtensionString("GL_OES_standard_derivatives");
740 feature_flags_
.oes_standard_derivatives
= true;
741 validators_
.hint_target
.AddValue(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES
);
742 validators_
.g_l_state
.AddValue(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES
);
745 if (extensions
.Contains("GL_OES_EGL_image_external")) {
746 AddExtensionString("GL_OES_EGL_image_external");
747 feature_flags_
.oes_egl_image_external
= true;
748 validators_
.texture_bind_target
.AddValue(GL_TEXTURE_EXTERNAL_OES
);
749 validators_
.get_tex_param_target
.AddValue(GL_TEXTURE_EXTERNAL_OES
);
750 validators_
.texture_parameter
.AddValue(GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES
);
751 validators_
.g_l_state
.AddValue(GL_TEXTURE_BINDING_EXTERNAL_OES
);
754 if (extensions
.Contains("GL_OES_compressed_ETC1_RGB8_texture")) {
755 AddExtensionString("GL_OES_compressed_ETC1_RGB8_texture");
756 feature_flags_
.oes_compressed_etc1_rgb8_texture
= true;
757 validators_
.compressed_texture_format
.AddValue(GL_ETC1_RGB8_OES
);
758 validators_
.texture_internal_format_storage
.AddValue(GL_ETC1_RGB8_OES
);
761 if (extensions
.Contains("GL_AMD_compressed_ATC_texture")) {
762 AddExtensionString("GL_AMD_compressed_ATC_texture");
763 validators_
.compressed_texture_format
.AddValue(
765 validators_
.compressed_texture_format
.AddValue(
766 GL_ATC_RGBA_EXPLICIT_ALPHA_AMD
);
767 validators_
.compressed_texture_format
.AddValue(
768 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD
);
770 validators_
.texture_internal_format_storage
.AddValue(
772 validators_
.texture_internal_format_storage
.AddValue(
773 GL_ATC_RGBA_EXPLICIT_ALPHA_AMD
);
774 validators_
.texture_internal_format_storage
.AddValue(
775 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD
);
778 if (extensions
.Contains("GL_IMG_texture_compression_pvrtc")) {
779 AddExtensionString("GL_IMG_texture_compression_pvrtc");
780 validators_
.compressed_texture_format
.AddValue(
781 GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG
);
782 validators_
.compressed_texture_format
.AddValue(
783 GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG
);
784 validators_
.compressed_texture_format
.AddValue(
785 GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
);
786 validators_
.compressed_texture_format
.AddValue(
787 GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
);
789 validators_
.texture_internal_format_storage
.AddValue(
790 GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG
);
791 validators_
.texture_internal_format_storage
.AddValue(
792 GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG
);
793 validators_
.texture_internal_format_storage
.AddValue(
794 GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
);
795 validators_
.texture_internal_format_storage
.AddValue(
796 GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
);
799 // Ideally we would only expose this extension on Mac OS X, to
800 // support GL_CHROMIUM_iosurface and the compositor. We don't want
801 // applications to start using it; they should use ordinary non-
802 // power-of-two textures. However, for unit testing purposes we
803 // expose it on all supported platforms.
804 if (extensions
.Contains("GL_ARB_texture_rectangle") ||
805 gl_version_info_
->is_desktop_core_profile
) {
806 AddExtensionString("GL_ARB_texture_rectangle");
807 feature_flags_
.arb_texture_rectangle
= true;
808 // Rectangle textures are used as samplers via glBindTexture, framebuffer
809 // textures via glFramebufferTexture2D, and copy destinations via
811 validators_
.texture_bind_target
.AddValue(GL_TEXTURE_RECTANGLE_ARB
);
812 validators_
.texture_target
.AddValue(GL_TEXTURE_RECTANGLE_ARB
);
813 validators_
.get_tex_param_target
.AddValue(GL_TEXTURE_RECTANGLE_ARB
);
814 validators_
.g_l_state
.AddValue(GL_TEXTURE_BINDING_RECTANGLE_ARB
);
817 #if defined(OS_MACOSX)
818 AddExtensionString("GL_CHROMIUM_iosurface");
821 if (extensions
.Contains("GL_APPLE_ycbcr_422")) {
822 AddExtensionString("GL_CHROMIUM_ycbcr_422_image");
823 feature_flags_
.chromium_image_ycbcr_422
= true;
826 // TODO(gman): Add support for these extensions.
829 feature_flags_
.enable_texture_float_linear
|= enable_texture_float_linear
;
830 feature_flags_
.enable_texture_half_float_linear
|=
831 enable_texture_half_float_linear
;
833 if (extensions
.Contains("GL_ANGLE_pack_reverse_row_order")) {
834 AddExtensionString("GL_ANGLE_pack_reverse_row_order");
835 feature_flags_
.angle_pack_reverse_row_order
= true;
836 validators_
.pixel_store
.AddValue(GL_PACK_REVERSE_ROW_ORDER_ANGLE
);
837 validators_
.g_l_state
.AddValue(GL_PACK_REVERSE_ROW_ORDER_ANGLE
);
840 if (extensions
.Contains("GL_ANGLE_texture_usage")) {
841 feature_flags_
.angle_texture_usage
= true;
842 AddExtensionString("GL_ANGLE_texture_usage");
843 validators_
.texture_parameter
.AddValue(GL_TEXTURE_USAGE_ANGLE
);
846 // Note: Only APPLE_texture_format_BGRA8888 extension allows BGRA8_EXT in
847 // ES3's glTexStorage2D. We prefer support BGRA to texture storage.
848 // So we don't expose GL_EXT_texture_storage when ES3 +
849 // GL_EXT_texture_format_BGRA8888 because we fail the GL_BGRA8 requirement.
850 // However we expose GL_EXT_texture_storage when just ES3 because we don't
851 // claim to handle GL_BGRA8.
852 bool support_texture_storage_on_es3
=
853 (gl_version_info_
->is_es3
&&
854 enable_immutable_texture_format_bgra_on_es3
) ||
855 (gl_version_info_
->is_es3
&&
856 !enable_texture_format_bgra8888
);
857 if (!workarounds_
.disable_texture_storage
&&
858 (extensions
.Contains("GL_EXT_texture_storage") ||
859 extensions
.Contains("GL_ARB_texture_storage") ||
860 support_texture_storage_on_es3
||
861 gl_version_info_
->is_desktop_core_profile
)) {
862 feature_flags_
.ext_texture_storage
= true;
863 AddExtensionString("GL_EXT_texture_storage");
864 validators_
.texture_parameter
.AddValue(GL_TEXTURE_IMMUTABLE_FORMAT_EXT
);
865 if (enable_texture_format_bgra8888
)
866 validators_
.texture_internal_format_storage
.AddValue(GL_BGRA8_EXT
);
867 if (enable_texture_float
) {
868 validators_
.texture_internal_format_storage
.AddValue(GL_RGBA32F_EXT
);
869 validators_
.texture_internal_format_storage
.AddValue(GL_RGB32F_EXT
);
870 validators_
.texture_internal_format_storage
.AddValue(GL_ALPHA32F_EXT
);
871 validators_
.texture_internal_format_storage
.AddValue(
872 GL_LUMINANCE32F_EXT
);
873 validators_
.texture_internal_format_storage
.AddValue(
874 GL_LUMINANCE_ALPHA32F_EXT
);
876 if (enable_texture_half_float
) {
877 validators_
.texture_internal_format_storage
.AddValue(GL_RGBA16F_EXT
);
878 validators_
.texture_internal_format_storage
.AddValue(GL_RGB16F_EXT
);
879 validators_
.texture_internal_format_storage
.AddValue(GL_ALPHA16F_EXT
);
880 validators_
.texture_internal_format_storage
.AddValue(
881 GL_LUMINANCE16F_EXT
);
882 validators_
.texture_internal_format_storage
.AddValue(
883 GL_LUMINANCE_ALPHA16F_EXT
);
887 bool have_ext_occlusion_query_boolean
=
888 extensions
.Contains("GL_EXT_occlusion_query_boolean");
889 bool have_arb_occlusion_query2
=
890 extensions
.Contains("GL_ARB_occlusion_query2");
891 bool have_arb_occlusion_query
=
892 extensions
.Contains("GL_ARB_occlusion_query");
894 if (have_ext_occlusion_query_boolean
||
895 have_arb_occlusion_query2
||
896 have_arb_occlusion_query
) {
897 AddExtensionString("GL_EXT_occlusion_query_boolean");
898 feature_flags_
.occlusion_query_boolean
= true;
899 feature_flags_
.use_arb_occlusion_query2_for_occlusion_query_boolean
=
900 !have_ext_occlusion_query_boolean
&& have_arb_occlusion_query2
;
901 feature_flags_
.use_arb_occlusion_query_for_occlusion_query_boolean
=
902 !have_ext_occlusion_query_boolean
&& have_arb_occlusion_query
&&
903 !have_arb_occlusion_query2
;
906 if (!workarounds_
.disable_angle_instanced_arrays
&&
907 (extensions
.Contains("GL_ANGLE_instanced_arrays") ||
908 (extensions
.Contains("GL_ARB_instanced_arrays") &&
909 extensions
.Contains("GL_ARB_draw_instanced")) ||
910 gl_version_info_
->is_es3
)) {
911 AddExtensionString("GL_ANGLE_instanced_arrays");
912 feature_flags_
.angle_instanced_arrays
= true;
913 validators_
.vertex_attribute
.AddValue(GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE
);
916 bool vendor_agnostic_draw_buffers
=
917 extensions
.Contains("GL_ARB_draw_buffers") ||
918 extensions
.Contains("GL_EXT_draw_buffers");
919 if (!workarounds_
.disable_ext_draw_buffers
&&
920 (vendor_agnostic_draw_buffers
||
921 (extensions
.Contains("GL_NV_draw_buffers") &&
922 gl_version_info_
->is_es3
) ||
923 gl_version_info_
->is_desktop_core_profile
)) {
924 AddExtensionString("GL_EXT_draw_buffers");
925 feature_flags_
.ext_draw_buffers
= true;
927 // This flag is set to enable emulation of EXT_draw_buffers when we're
928 // running on GLES 3.0+, NV_draw_buffers extension is supported and
929 // glDrawBuffers from GLES 3.0 core has been bound. It toggles using the
930 // NV_draw_buffers extension directive instead of EXT_draw_buffers extension
931 // directive in ESSL 100 shaders translated by ANGLE, enabling them to write
932 // into multiple gl_FragData values, which is not by default possible in
933 // ESSL 100 with core GLES 3.0. For more information, see the
934 // NV_draw_buffers specification.
935 feature_flags_
.nv_draw_buffers
= !vendor_agnostic_draw_buffers
;
937 GLint max_color_attachments
= 0;
938 glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT
, &max_color_attachments
);
939 for (GLenum i
= GL_COLOR_ATTACHMENT1_EXT
;
940 i
< static_cast<GLenum
>(GL_COLOR_ATTACHMENT0
+ max_color_attachments
);
942 validators_
.attachment
.AddValue(i
);
944 static_assert(GL_COLOR_ATTACHMENT0_EXT
== GL_COLOR_ATTACHMENT0
,
945 "GL_COLOR_ATTACHMENT0_EXT should equal GL_COLOR_ATTACHMENT0");
947 validators_
.g_l_state
.AddValue(GL_MAX_COLOR_ATTACHMENTS_EXT
);
948 validators_
.g_l_state
.AddValue(GL_MAX_DRAW_BUFFERS_ARB
);
949 GLint max_draw_buffers
= 0;
950 glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB
, &max_draw_buffers
);
951 for (GLenum i
= GL_DRAW_BUFFER0_ARB
;
952 i
< static_cast<GLenum
>(GL_DRAW_BUFFER0_ARB
+ max_draw_buffers
);
954 validators_
.g_l_state
.AddValue(i
);
958 if (gl_version_info_
->is_es3
||
959 extensions
.Contains("GL_EXT_blend_minmax") ||
960 gfx::HasDesktopGLFeatures()) {
961 AddExtensionString("GL_EXT_blend_minmax");
962 validators_
.equation
.AddValue(GL_MIN_EXT
);
963 validators_
.equation
.AddValue(GL_MAX_EXT
);
964 static_assert(GL_MIN_EXT
== GL_MIN
&& GL_MAX_EXT
== GL_MAX
,
965 "min & max variations must match");
968 // TODO(dshwang): GLES3 supports gl_FragDepth, not gl_FragDepthEXT.
969 if (extensions
.Contains("GL_EXT_frag_depth") || gfx::HasDesktopGLFeatures()) {
970 AddExtensionString("GL_EXT_frag_depth");
971 feature_flags_
.ext_frag_depth
= true;
974 if (extensions
.Contains("GL_EXT_shader_texture_lod") ||
975 gfx::HasDesktopGLFeatures()) {
976 AddExtensionString("GL_EXT_shader_texture_lod");
977 feature_flags_
.ext_shader_texture_lod
= true;
980 bool ui_gl_fence_works
= gfx::GLFence::IsSupported();
981 UMA_HISTOGRAM_BOOLEAN("GPU.FenceSupport", ui_gl_fence_works
);
983 feature_flags_
.map_buffer_range
=
984 gl_version_info_
->is_es3
||
985 gl_version_info_
->is_desktop_core_profile
||
986 extensions
.Contains("GL_ARB_map_buffer_range") ||
987 extensions
.Contains("GL_EXT_map_buffer_range");
989 // Really it's part of core OpenGL 2.1 and up, but let's assume the
990 // extension is still advertised.
991 bool has_pixel_buffers
=
992 gl_version_info_
->is_es3
||
993 gl_version_info_
->is_desktop_core_profile
||
994 extensions
.Contains("GL_ARB_pixel_buffer_object") ||
995 extensions
.Contains("GL_NV_pixel_buffer_object");
997 // We will use either glMapBuffer() or glMapBufferRange() for async readbacks.
998 if (has_pixel_buffers
&& ui_gl_fence_works
&&
999 !workarounds_
.disable_async_readpixels
) {
1000 feature_flags_
.use_async_readpixels
= true;
1003 if (gl_version_info_
->is_es3
||
1004 extensions
.Contains("GL_ARB_sampler_objects")) {
1005 feature_flags_
.enable_samplers
= true;
1006 // TODO(dsinclair): Add AddExtensionString("GL_CHROMIUM_sampler_objects")
1010 if ((gl_version_info_
->is_es3
||
1011 extensions
.Contains("GL_EXT_discard_framebuffer")) &&
1012 !workarounds_
.disable_discard_framebuffer
) {
1013 // DiscardFramebufferEXT is automatically bound to InvalidateFramebuffer.
1014 AddExtensionString("GL_EXT_discard_framebuffer");
1015 feature_flags_
.ext_discard_framebuffer
= true;
1018 if (ui_gl_fence_works
) {
1019 AddExtensionString("GL_CHROMIUM_sync_query");
1020 feature_flags_
.chromium_sync_query
= true;
1023 if (!workarounds_
.disable_blend_equation_advanced
) {
1024 bool blend_equation_advanced_coherent
=
1025 extensions
.Contains("GL_NV_blend_equation_advanced_coherent") ||
1026 extensions
.Contains("GL_KHR_blend_equation_advanced_coherent");
1028 if (blend_equation_advanced_coherent
||
1029 extensions
.Contains("GL_NV_blend_equation_advanced") ||
1030 extensions
.Contains("GL_KHR_blend_equation_advanced")) {
1031 const GLenum equations
[] = {GL_MULTIPLY_KHR
,
1043 GL_HSL_SATURATION_KHR
,
1045 GL_HSL_LUMINOSITY_KHR
};
1047 for (GLenum equation
: equations
)
1048 validators_
.equation
.AddValue(equation
);
1049 if (blend_equation_advanced_coherent
)
1050 AddExtensionString("GL_KHR_blend_equation_advanced_coherent");
1052 AddExtensionString("GL_KHR_blend_equation_advanced");
1053 feature_flags_
.blend_equation_advanced
= true;
1054 feature_flags_
.blend_equation_advanced_coherent
=
1055 blend_equation_advanced_coherent
;
1059 if (enable_gl_path_rendering_switch_
&&
1060 !workarounds_
.disable_gl_path_rendering
&&
1061 extensions
.Contains("GL_NV_path_rendering") &&
1062 (extensions
.Contains("GL_EXT_direct_state_access") ||
1063 gl_version_info_
->is_es3
)) {
1064 AddExtensionString("GL_CHROMIUM_path_rendering");
1065 feature_flags_
.chromium_path_rendering
= true;
1066 validators_
.g_l_state
.AddValue(GL_PATH_MODELVIEW_MATRIX_CHROMIUM
);
1067 validators_
.g_l_state
.AddValue(GL_PATH_PROJECTION_MATRIX_CHROMIUM
);
1068 validators_
.g_l_state
.AddValue(GL_PATH_STENCIL_FUNC_CHROMIUM
);
1069 validators_
.g_l_state
.AddValue(GL_PATH_STENCIL_REF_CHROMIUM
);
1070 validators_
.g_l_state
.AddValue(GL_PATH_STENCIL_VALUE_MASK_CHROMIUM
);
1073 if ((gl_version_info_
->is_es3
|| gl_version_info_
->is_desktop_core_profile
||
1074 extensions
.Contains("GL_EXT_texture_rg") ||
1075 extensions
.Contains("GL_ARB_texture_rg")) &&
1076 IsGL_REDSupportedOnFBOs()) {
1077 feature_flags_
.ext_texture_rg
= true;
1078 AddExtensionString("GL_EXT_texture_rg");
1080 validators_
.texture_format
.AddValue(GL_RED_EXT
);
1081 validators_
.texture_format
.AddValue(GL_RG_EXT
);
1082 validators_
.texture_internal_format
.AddValue(GL_RED_EXT
);
1083 validators_
.texture_internal_format
.AddValue(GL_R8_EXT
);
1084 validators_
.texture_internal_format
.AddValue(GL_RG_EXT
);
1085 validators_
.texture_internal_format
.AddValue(GL_RG8_EXT
);
1086 validators_
.read_pixel_format
.AddValue(GL_RED_EXT
);
1087 validators_
.read_pixel_format
.AddValue(GL_RG_EXT
);
1088 validators_
.render_buffer_format
.AddValue(GL_R8_EXT
);
1089 validators_
.render_buffer_format
.AddValue(GL_RG8_EXT
);
1091 UMA_HISTOGRAM_BOOLEAN("GPU.TextureRG", feature_flags_
.ext_texture_rg
);
1093 #if !defined(OS_MACOSX)
1094 if (workarounds_
.ignore_egl_sync_failures
) {
1095 gfx::GLFenceEGL::SetIgnoreFailures();
1099 if (workarounds_
.avoid_egl_image_target_texture_reuse
) {
1100 TextureDefinition::AvoidEGLTargetTextureReuse();
1103 if (gl_version_info_
->IsLowerThanGL(4, 3)) {
1104 // crbug.com/481184.
1105 // GL_PRIMITIVE_RESTART_FIXED_INDEX is only available on Desktop GL 4.3+,
1106 // but we emulate ES 3.0 on top of Desktop GL 4.2+.
1107 feature_flags_
.emulate_primitive_restart_fixed_index
= true;
1111 bool FeatureInfo::IsES3Capable() const {
1112 if (!enable_unsafe_es3_apis_switch_
)
1114 if (gl_version_info_
)
1115 return gl_version_info_
->IsES3Capable();
1119 void FeatureInfo::EnableES3Validators() {
1120 DCHECK(IsES3Capable());
1121 validators_
.UpdateValuesES3();
1123 GLint max_color_attachments
= 0;
1124 glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS
, &max_color_attachments
);
1125 const int kTotalColorAttachmentEnums
= 16;
1126 const GLenum kColorAttachments
[] = {
1127 GL_COLOR_ATTACHMENT0
,
1128 GL_COLOR_ATTACHMENT1
,
1129 GL_COLOR_ATTACHMENT2
,
1130 GL_COLOR_ATTACHMENT3
,
1131 GL_COLOR_ATTACHMENT4
,
1132 GL_COLOR_ATTACHMENT5
,
1133 GL_COLOR_ATTACHMENT6
,
1134 GL_COLOR_ATTACHMENT7
,
1135 GL_COLOR_ATTACHMENT8
,
1136 GL_COLOR_ATTACHMENT9
,
1137 GL_COLOR_ATTACHMENT10
,
1138 GL_COLOR_ATTACHMENT11
,
1139 GL_COLOR_ATTACHMENT12
,
1140 GL_COLOR_ATTACHMENT13
,
1141 GL_COLOR_ATTACHMENT14
,
1142 GL_COLOR_ATTACHMENT15
,
1144 if (max_color_attachments
< kTotalColorAttachmentEnums
) {
1145 validators_
.attachment
.RemoveValues(
1146 kColorAttachments
+ max_color_attachments
,
1147 kTotalColorAttachmentEnums
- max_color_attachments
);
1150 GLint max_draw_buffers
= 0;
1151 glGetIntegerv(GL_MAX_DRAW_BUFFERS
, &max_draw_buffers
);
1152 const int kTotalDrawBufferEnums
= 16;
1153 const GLenum kDrawBuffers
[] = {
1171 if (max_draw_buffers
< kTotalDrawBufferEnums
) {
1172 validators_
.g_l_state
.RemoveValues(
1173 kDrawBuffers
+ max_draw_buffers
,
1174 kTotalDrawBufferEnums
- max_draw_buffers
);
1177 unsafe_es3_apis_enabled_
= true;
1180 void FeatureInfo::AddExtensionString(const char* s
) {
1182 size_t pos
= extensions_
.find(str
);
1183 while (pos
!= std::string::npos
&&
1184 pos
+ str
.length() < extensions_
.length() &&
1185 extensions_
.substr(pos
+ str
.length(), 1) != " ") {
1186 // This extension name is a substring of another.
1187 pos
= extensions_
.find(str
, pos
+ str
.length());
1189 if (pos
== std::string::npos
) {
1190 extensions_
+= (extensions_
.empty() ? "" : " ") + str
;
1194 FeatureInfo::~FeatureInfo() {
1197 } // namespace gles2