Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / gpu / command_buffer / service / feature_info.cc
blobc86de231fd4695af0574699fbab0570a12d47675
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"
7 #include <set>
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 "gpu/command_buffer/service/texture_definition.h"
18 #include "gpu/config/gpu_switches.h"
19 #include "ui/gl/gl_fence.h"
20 #include "ui/gl/gl_implementation.h"
22 #if !defined(OS_MACOSX)
23 #include "ui/gl/gl_fence_egl.h"
24 #endif
26 namespace gpu {
27 namespace gles2 {
29 namespace {
31 struct FormatInfo {
32 GLenum format;
33 const GLenum* types;
34 size_t count;
37 class StringSet {
38 public:
39 StringSet() {}
41 StringSet(const char* s) {
42 Init(s);
45 StringSet(const std::string& str) {
46 Init(str);
49 StringSet(const std::vector<std::string>& strs) {
50 string_set_.insert(strs.begin(), strs.end());
53 void Init(const char* s) {
54 std::string str(s ? s : "");
55 Init(str);
58 void Init(const std::string& str) {
59 std::vector<std::string> tokens;
60 Tokenize(str, " ", &tokens);
61 string_set_.insert(tokens.begin(), tokens.end());
64 bool Contains(const char* s) {
65 return string_set_.find(s) != string_set_.end();
68 bool Contains(const std::string& s) {
69 return string_set_.find(s) != string_set_.end();
72 const std::set<std::string>& GetImpl() {
73 return string_set_;
76 private:
77 std::set<std::string> string_set_;
80 // Process a string of wordaround type IDs (seperated by ',') and set up
81 // the corresponding Workaround flags.
82 void StringToWorkarounds(
83 const std::string& types, FeatureInfo::Workarounds* workarounds) {
84 DCHECK(workarounds);
85 std::vector<std::string> pieces;
86 base::SplitString(types, ',', &pieces);
87 for (size_t i = 0; i < pieces.size(); ++i) {
88 int number = 0;
89 bool succeed = base::StringToInt(pieces[i], &number);
90 DCHECK(succeed);
91 switch (number) {
92 #define GPU_OP(type, name) \
93 case gpu::type: \
94 workarounds->name = true; \
95 break;
96 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP)
97 #undef GPU_OP
98 default:
99 NOTIMPLEMENTED();
102 if (workarounds->max_texture_size_limit_4096)
103 workarounds->max_texture_size = 4096;
104 if (workarounds->max_cube_map_texture_size_limit_4096)
105 workarounds->max_cube_map_texture_size = 4096;
106 if (workarounds->max_cube_map_texture_size_limit_1024)
107 workarounds->max_cube_map_texture_size = 1024;
108 if (workarounds->max_cube_map_texture_size_limit_512)
109 workarounds->max_cube_map_texture_size = 512;
111 if (workarounds->max_fragment_uniform_vectors_32)
112 workarounds->max_fragment_uniform_vectors = 32;
113 if (workarounds->max_varying_vectors_16)
114 workarounds->max_varying_vectors = 16;
115 if (workarounds->max_vertex_uniform_vectors_256)
116 workarounds->max_vertex_uniform_vectors = 256;
119 } // anonymous namespace.
121 FeatureInfo::FeatureFlags::FeatureFlags()
122 : chromium_color_buffer_float_rgba(false),
123 chromium_color_buffer_float_rgb(false),
124 chromium_framebuffer_multisample(false),
125 chromium_sync_query(false),
126 use_core_framebuffer_multisample(false),
127 multisampled_render_to_texture(false),
128 use_img_for_multisampled_render_to_texture(false),
129 oes_standard_derivatives(false),
130 oes_egl_image_external(false),
131 oes_depth24(false),
132 oes_compressed_etc1_rgb8_texture(false),
133 packed_depth24_stencil8(false),
134 npot_ok(false),
135 enable_texture_float_linear(false),
136 enable_texture_half_float_linear(false),
137 angle_translated_shader_source(false),
138 angle_pack_reverse_row_order(false),
139 arb_texture_rectangle(false),
140 angle_instanced_arrays(false),
141 occlusion_query_boolean(false),
142 use_arb_occlusion_query2_for_occlusion_query_boolean(false),
143 use_arb_occlusion_query_for_occlusion_query_boolean(false),
144 native_vertex_array_object(false),
145 ext_texture_format_atc(false),
146 ext_texture_format_bgra8888(false),
147 ext_texture_format_dxt1(false),
148 ext_texture_format_dxt5(false),
149 enable_shader_name_hashing(false),
150 enable_samplers(false),
151 ext_draw_buffers(false),
152 nv_draw_buffers(false),
153 ext_frag_depth(false),
154 ext_shader_texture_lod(false),
155 use_async_readpixels(false),
156 map_buffer_range(false),
157 ext_discard_framebuffer(false),
158 angle_depth_texture(false),
159 is_swiftshader(false),
160 angle_texture_usage(false),
161 ext_texture_storage(false),
162 chromium_path_rendering(false),
163 blend_equation_advanced(false),
164 blend_equation_advanced_coherent(false),
165 ext_texture_rg(false),
166 enable_subscribe_uniform(false),
167 emulate_primitive_restart_fixed_index(false) {
170 FeatureInfo::Workarounds::Workarounds() :
171 #define GPU_OP(type, name) name(false),
172 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP)
173 #undef GPU_OP
174 max_texture_size(0),
175 max_cube_map_texture_size(0),
176 max_fragment_uniform_vectors(0),
177 max_varying_vectors(0),
178 max_vertex_uniform_vectors(0) {
181 FeatureInfo::FeatureInfo() {
182 InitializeBasicState(*base::CommandLine::ForCurrentProcess());
185 FeatureInfo::FeatureInfo(const base::CommandLine& command_line) {
186 InitializeBasicState(command_line);
189 void FeatureInfo::InitializeBasicState(const base::CommandLine& command_line) {
190 if (command_line.HasSwitch(switches::kGpuDriverBugWorkarounds)) {
191 std::string types = command_line.GetSwitchValueASCII(
192 switches::kGpuDriverBugWorkarounds);
193 StringToWorkarounds(types, &workarounds_);
195 feature_flags_.enable_shader_name_hashing =
196 !command_line.HasSwitch(switches::kDisableShaderNameHashing);
198 feature_flags_.is_swiftshader =
199 (command_line.GetSwitchValueASCII(switches::kUseGL) == "swiftshader");
201 feature_flags_.enable_subscribe_uniform =
202 command_line.HasSwitch(switches::kEnableSubscribeUniformExtension);
204 enable_unsafe_es3_apis_switch_ =
205 command_line.HasSwitch(switches::kEnableUnsafeES3APIs);
207 unsafe_es3_apis_enabled_ = false;
210 bool FeatureInfo::Initialize() {
211 disallowed_features_ = DisallowedFeatures();
212 InitializeFeatures();
213 return true;
216 bool FeatureInfo::Initialize(const DisallowedFeatures& disallowed_features) {
217 disallowed_features_ = disallowed_features;
218 InitializeFeatures();
219 return true;
222 bool IsGL_REDSupportedOnFBOs() {
223 // Skia uses GL_RED with frame buffers, unfortunately, Mesa claims to support
224 // GL_EXT_texture_rg, but it doesn't support it on frame buffers. To fix
225 // this, we try it, and if it fails, we don't expose GL_EXT_texture_rg.
226 GLint fb_binding = 0;
227 GLint tex_binding = 0;
228 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &fb_binding);
229 glGetIntegerv(GL_TEXTURE_BINDING_2D, &tex_binding);
231 GLuint textureId = 0;
232 glGenTextures(1, &textureId);
233 glBindTexture(GL_TEXTURE_2D, textureId);
234 GLubyte data[1] = {0};
235 glTexImage2D(GL_TEXTURE_2D, 0, GL_RED_EXT, 1, 1, 0, GL_RED_EXT,
236 GL_UNSIGNED_BYTE, data);
237 GLuint textureFBOID = 0;
238 glGenFramebuffersEXT(1, &textureFBOID);
239 glBindFramebufferEXT(GL_FRAMEBUFFER, textureFBOID);
240 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
241 textureId, 0);
242 bool result =
243 glCheckFramebufferStatusEXT(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_UNSUPPORTED;
244 glDeleteFramebuffersEXT(1, &textureFBOID);
245 glDeleteTextures(1, &textureId);
247 glBindFramebufferEXT(GL_FRAMEBUFFER, static_cast<GLuint>(fb_binding));
248 glBindTexture(GL_TEXTURE_2D, static_cast<GLuint>(tex_binding));
250 DCHECK(glGetError() == GL_NO_ERROR);
252 return result;
255 void FeatureInfo::InitializeFeatures() {
256 // Figure out what extensions to turn on.
257 StringSet extensions;
258 // We need to figure out how to query the extension string before we
259 // have a GLVersionInfo available.
260 const char* version_str =
261 reinterpret_cast<const char*>(glGetString(GL_VERSION));
262 unsigned major_version, minor_version;
263 bool is_es, is_es3;
264 gfx::GLVersionInfo::ParseVersionString(
265 version_str, &major_version, &minor_version, &is_es, &is_es3);
266 if (!is_es && major_version >= 3) {
267 std::vector<std::string> exts;
268 GLint num_extensions = 0;
269 glGetIntegerv(GL_NUM_EXTENSIONS, &num_extensions);
270 for (GLint i = 0; i < num_extensions; ++i) {
271 const char* extension = reinterpret_cast<const char*>(
272 glGetStringi(GL_EXTENSIONS, i));
273 DCHECK(extension != NULL);
274 exts.push_back(extension);
276 extensions = exts;
277 } else {
278 extensions = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
281 const char* renderer_str =
282 reinterpret_cast<const char*>(glGetString(GL_RENDERER));
284 gl_version_info_.reset(new gfx::GLVersionInfo(
285 version_str, renderer_str, extensions.GetImpl()));
287 AddExtensionString("GL_ANGLE_translated_shader_source");
288 AddExtensionString("GL_CHROMIUM_async_pixel_transfers");
289 AddExtensionString("GL_CHROMIUM_bind_uniform_location");
290 AddExtensionString("GL_CHROMIUM_command_buffer_query");
291 AddExtensionString("GL_CHROMIUM_command_buffer_latency_query");
292 AddExtensionString("GL_CHROMIUM_copy_texture");
293 AddExtensionString("GL_CHROMIUM_get_error_query");
294 AddExtensionString("GL_CHROMIUM_lose_context");
295 AddExtensionString("GL_CHROMIUM_pixel_transfer_buffer_object");
296 AddExtensionString("GL_CHROMIUM_rate_limit_offscreen_context");
297 AddExtensionString("GL_CHROMIUM_resize");
298 AddExtensionString("GL_CHROMIUM_resource_safe");
299 AddExtensionString("GL_CHROMIUM_strict_attribs");
300 AddExtensionString("GL_CHROMIUM_texture_mailbox");
301 AddExtensionString("GL_CHROMIUM_trace_marker");
302 AddExtensionString("GL_EXT_debug_marker");
304 if (feature_flags_.enable_subscribe_uniform) {
305 AddExtensionString("GL_CHROMIUM_subscribe_uniform");
308 // OES_vertex_array_object is emulated if not present natively,
309 // so the extension string is always exposed.
310 AddExtensionString("GL_OES_vertex_array_object");
312 if (!disallowed_features_.gpu_memory_manager)
313 AddExtensionString("GL_CHROMIUM_gpu_memory_manager");
315 if (extensions.Contains("GL_ANGLE_translated_shader_source")) {
316 feature_flags_.angle_translated_shader_source = true;
319 // Check if we should allow GL_EXT_texture_compression_dxt1 and
320 // GL_EXT_texture_compression_s3tc.
321 bool enable_dxt1 = false;
322 bool enable_dxt3 = false;
323 bool enable_dxt5 = false;
324 bool have_s3tc = extensions.Contains("GL_EXT_texture_compression_s3tc");
325 bool have_dxt3 =
326 have_s3tc || extensions.Contains("GL_ANGLE_texture_compression_dxt3");
327 bool have_dxt5 =
328 have_s3tc || extensions.Contains("GL_ANGLE_texture_compression_dxt5");
330 if (extensions.Contains("GL_EXT_texture_compression_dxt1") || have_s3tc) {
331 enable_dxt1 = true;
333 if (have_dxt3) {
334 enable_dxt3 = true;
336 if (have_dxt5) {
337 enable_dxt5 = true;
340 if (enable_dxt1) {
341 feature_flags_.ext_texture_format_dxt1 = true;
343 AddExtensionString("GL_EXT_texture_compression_dxt1");
344 validators_.compressed_texture_format.AddValue(
345 GL_COMPRESSED_RGB_S3TC_DXT1_EXT);
346 validators_.compressed_texture_format.AddValue(
347 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT);
350 if (enable_dxt3) {
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);
359 if (enable_dxt5) {
360 feature_flags_.ext_texture_format_dxt5 = true;
362 // The difference between GL_EXT_texture_compression_s3tc and
363 // GL_CHROMIUM_texture_compression_dxt5 is that the former
364 // requires on the fly compression. The latter does not.
365 AddExtensionString("GL_CHROMIUM_texture_compression_dxt5");
366 validators_.compressed_texture_format.AddValue(
367 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT);
370 bool have_atc = extensions.Contains("GL_AMD_compressed_ATC_texture") ||
371 extensions.Contains("GL_ATI_texture_compression_atitc");
372 if (have_atc) {
373 feature_flags_.ext_texture_format_atc = true;
375 AddExtensionString("GL_AMD_compressed_ATC_texture");
376 validators_.compressed_texture_format.AddValue(GL_ATC_RGB_AMD);
377 validators_.compressed_texture_format.AddValue(
378 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD);
381 // Check if we should enable GL_EXT_texture_filter_anisotropic.
382 if (extensions.Contains("GL_EXT_texture_filter_anisotropic")) {
383 AddExtensionString("GL_EXT_texture_filter_anisotropic");
384 validators_.texture_parameter.AddValue(
385 GL_TEXTURE_MAX_ANISOTROPY_EXT);
386 validators_.g_l_state.AddValue(
387 GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT);
390 // Check if we should support GL_OES_packed_depth_stencil and/or
391 // GL_GOOGLE_depth_texture / GL_CHROMIUM_depth_texture.
393 // NOTE: GL_OES_depth_texture requires support for depth cubemaps.
394 // GL_ARB_depth_texture requires other features that
395 // GL_OES_packed_depth_stencil does not provide.
397 // Therefore we made up GL_GOOGLE_depth_texture / GL_CHROMIUM_depth_texture.
399 // GL_GOOGLE_depth_texture is legacy. As we exposed it into NaCl we can't
400 // get rid of it.
402 bool enable_depth_texture = false;
403 if (!workarounds_.disable_depth_texture &&
404 (extensions.Contains("GL_ARB_depth_texture") ||
405 extensions.Contains("GL_OES_depth_texture") ||
406 extensions.Contains("GL_ANGLE_depth_texture") ||
407 gl_version_info_->is_es3 ||
408 gl_version_info_->is_desktop_core_profile)) {
409 enable_depth_texture = true;
410 feature_flags_.angle_depth_texture =
411 extensions.Contains("GL_ANGLE_depth_texture");
414 if (enable_depth_texture) {
415 AddExtensionString("GL_CHROMIUM_depth_texture");
416 AddExtensionString("GL_GOOGLE_depth_texture");
417 validators_.texture_internal_format.AddValue(GL_DEPTH_COMPONENT);
418 validators_.texture_format.AddValue(GL_DEPTH_COMPONENT);
419 validators_.pixel_type.AddValue(GL_UNSIGNED_SHORT);
420 validators_.pixel_type.AddValue(GL_UNSIGNED_INT);
423 if (extensions.Contains("GL_EXT_packed_depth_stencil") ||
424 extensions.Contains("GL_OES_packed_depth_stencil") ||
425 gl_version_info_->is_es3 ||
426 gl_version_info_->is_desktop_core_profile) {
427 AddExtensionString("GL_OES_packed_depth_stencil");
428 feature_flags_.packed_depth24_stencil8 = true;
429 if (enable_depth_texture) {
430 validators_.texture_internal_format.AddValue(GL_DEPTH_STENCIL);
431 validators_.texture_format.AddValue(GL_DEPTH_STENCIL);
432 validators_.pixel_type.AddValue(GL_UNSIGNED_INT_24_8);
434 validators_.render_buffer_format.AddValue(GL_DEPTH24_STENCIL8);
437 if (gl_version_info_->is_es3 ||
438 gl_version_info_->is_desktop_core_profile ||
439 extensions.Contains("GL_OES_vertex_array_object") ||
440 extensions.Contains("GL_ARB_vertex_array_object") ||
441 extensions.Contains("GL_APPLE_vertex_array_object")) {
442 feature_flags_.native_vertex_array_object = true;
445 // If we're using client_side_arrays we have to emulate
446 // vertex array objects since vertex array objects do not work
447 // with client side arrays.
448 if (workarounds_.use_client_side_arrays_for_stream_buffers) {
449 feature_flags_.native_vertex_array_object = false;
452 if (gl_version_info_->is_es3 ||
453 extensions.Contains("GL_OES_element_index_uint") ||
454 gfx::HasDesktopGLFeatures()) {
455 AddExtensionString("GL_OES_element_index_uint");
456 validators_.index_type.AddValue(GL_UNSIGNED_INT);
459 // With EXT_sRGB, unsized SRGB_EXT and SRGB_ALPHA_EXT are accepted by the
460 // <format> and <internalformat> parameter of TexImage2D. GLES3 adds support
461 // for SRGB Textures but the accepted internal formats for TexImage2D are only
462 // sized formats GL_SRGB8 and GL_SRGB8_ALPHA8. Also, SRGB_EXT isn't a valid
463 // <format> in this case. So, even with GLES3 explicitly check for
464 // GL_EXT_sRGB.
465 if (((gl_version_info_->is_es3 ||
466 extensions.Contains("GL_OES_rgb8_rgba8")) &&
467 extensions.Contains("GL_EXT_sRGB")) || gfx::HasDesktopGLFeatures()) {
468 AddExtensionString("GL_EXT_sRGB");
469 validators_.texture_internal_format.AddValue(GL_SRGB_EXT);
470 validators_.texture_internal_format.AddValue(GL_SRGB_ALPHA_EXT);
471 validators_.texture_format.AddValue(GL_SRGB_EXT);
472 validators_.texture_format.AddValue(GL_SRGB_ALPHA_EXT);
473 validators_.render_buffer_format.AddValue(GL_SRGB8_ALPHA8_EXT);
474 validators_.frame_buffer_parameter.AddValue(
475 GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT);
478 bool enable_texture_format_bgra8888 = false;
479 bool enable_read_format_bgra = false;
480 bool enable_render_buffer_bgra = false;
481 bool enable_immutable_texture_format_bgra_on_es3 =
482 extensions.Contains("GL_APPLE_texture_format_BGRA8888");
484 // Check if we should allow GL_EXT_texture_format_BGRA8888
485 if (extensions.Contains("GL_EXT_texture_format_BGRA8888") ||
486 enable_immutable_texture_format_bgra_on_es3 ||
487 extensions.Contains("GL_EXT_bgra")) {
488 enable_texture_format_bgra8888 = true;
491 // Only desktop GL extension GL_EXT_bgra or ANGLE guarantee that we can
492 // allocate a renderbuffer with this format.
493 if (extensions.Contains("GL_EXT_bgra") || gl_version_info_->is_angle) {
494 enable_render_buffer_bgra = true;
497 if (extensions.Contains("GL_EXT_read_format_bgra") ||
498 extensions.Contains("GL_EXT_bgra")) {
499 enable_read_format_bgra = true;
502 if (enable_texture_format_bgra8888) {
503 feature_flags_.ext_texture_format_bgra8888 = true;
504 AddExtensionString("GL_EXT_texture_format_BGRA8888");
505 validators_.texture_internal_format.AddValue(GL_BGRA_EXT);
506 validators_.texture_format.AddValue(GL_BGRA_EXT);
509 if (enable_read_format_bgra) {
510 AddExtensionString("GL_EXT_read_format_bgra");
511 validators_.read_pixel_format.AddValue(GL_BGRA_EXT);
514 if (enable_render_buffer_bgra) {
515 AddExtensionString("GL_CHROMIUM_renderbuffer_format_BGRA8888");
516 validators_.render_buffer_format.AddValue(GL_BGRA8_EXT);
519 if (extensions.Contains("GL_OES_rgb8_rgba8") || gfx::HasDesktopGLFeatures()) {
520 AddExtensionString("GL_OES_rgb8_rgba8");
521 validators_.render_buffer_format.AddValue(GL_RGB8_OES);
522 validators_.render_buffer_format.AddValue(GL_RGBA8_OES);
525 // Check if we should allow GL_OES_texture_npot
526 if (gl_version_info_->is_es3 ||
527 gl_version_info_->is_desktop_core_profile ||
528 extensions.Contains("GL_ARB_texture_non_power_of_two") ||
529 extensions.Contains("GL_OES_texture_npot")) {
530 AddExtensionString("GL_OES_texture_npot");
531 feature_flags_.npot_ok = true;
534 // Check if we should allow GL_OES_texture_float, GL_OES_texture_half_float,
535 // GL_OES_texture_float_linear, GL_OES_texture_half_float_linear
536 bool enable_texture_float = false;
537 bool enable_texture_float_linear = false;
538 bool enable_texture_half_float = false;
539 bool enable_texture_half_float_linear = false;
541 bool may_enable_chromium_color_buffer_float = false;
543 if (extensions.Contains("GL_ARB_texture_float") ||
544 gl_version_info_->is_desktop_core_profile) {
545 enable_texture_float = true;
546 enable_texture_float_linear = true;
547 enable_texture_half_float = true;
548 enable_texture_half_float_linear = true;
549 may_enable_chromium_color_buffer_float = true;
550 } else {
551 // GLES3 adds support for Float type by default but it doesn't support all
552 // formats as GL_OES_texture_float(i.e.LUMINANCE_ALPHA,LUMINANCE and Alpha)
553 if (extensions.Contains("GL_OES_texture_float")) {
554 enable_texture_float = true;
555 if (extensions.Contains("GL_OES_texture_float_linear")) {
556 enable_texture_float_linear = true;
558 // This extension allows a variety of floating point formats to be
559 // rendered to via framebuffer objects. Enable it's usage only if
560 // support for Floating textures is enabled.
561 if ((gl_version_info_->is_es3 &&
562 extensions.Contains("GL_EXT_color_buffer_float")) ||
563 gl_version_info_->is_angle) {
564 may_enable_chromium_color_buffer_float = true;
568 // TODO(dshwang): GLES3 supports half float by default but GL_HALF_FLOAT_OES
569 // isn't equal to GL_HALF_FLOAT.
570 if (extensions.Contains("GL_OES_texture_half_float")) {
571 enable_texture_half_float = true;
572 if (extensions.Contains("GL_OES_texture_half_float_linear")) {
573 enable_texture_half_float_linear = true;
578 if (enable_texture_float) {
579 validators_.pixel_type.AddValue(GL_FLOAT);
580 validators_.read_pixel_type.AddValue(GL_FLOAT);
581 AddExtensionString("GL_OES_texture_float");
582 if (enable_texture_float_linear) {
583 AddExtensionString("GL_OES_texture_float_linear");
587 if (enable_texture_half_float) {
588 validators_.pixel_type.AddValue(GL_HALF_FLOAT_OES);
589 validators_.read_pixel_type.AddValue(GL_HALF_FLOAT_OES);
590 AddExtensionString("GL_OES_texture_half_float");
591 if (enable_texture_half_float_linear) {
592 AddExtensionString("GL_OES_texture_half_float_linear");
596 if (may_enable_chromium_color_buffer_float) {
597 static_assert(GL_RGBA32F_ARB == GL_RGBA32F &&
598 GL_RGBA32F_EXT == GL_RGBA32F &&
599 GL_RGB32F_ARB == GL_RGB32F &&
600 GL_RGB32F_EXT == GL_RGB32F,
601 "sized float internal format variations must match");
602 // We don't check extension support beyond ARB_texture_float on desktop GL,
603 // and format support varies between GL configurations. For example, spec
604 // prior to OpenGL 3.0 mandates framebuffer support only for one
605 // implementation-chosen format, and ES3.0 EXT_color_buffer_float does not
606 // support rendering to RGB32F. Check for framebuffer completeness with
607 // formats that the extensions expose, and only enable an extension when a
608 // framebuffer created with its texture format is reported as complete.
609 GLint fb_binding = 0;
610 GLint tex_binding = 0;
611 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &fb_binding);
612 glGetIntegerv(GL_TEXTURE_BINDING_2D, &tex_binding);
614 GLuint tex_id = 0;
615 GLuint fb_id = 0;
616 GLsizei width = 16;
618 glGenTextures(1, &tex_id);
619 glGenFramebuffersEXT(1, &fb_id);
620 glBindTexture(GL_TEXTURE_2D, tex_id);
621 // Nearest filter needed for framebuffer completeness on some drivers.
622 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
623 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, width, width, 0, GL_RGBA,
624 GL_FLOAT, NULL);
625 glBindFramebufferEXT(GL_FRAMEBUFFER, fb_id);
626 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
627 GL_TEXTURE_2D, tex_id, 0);
628 GLenum statusRGBA = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER);
629 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, width, width, 0, GL_RGB,
630 GL_FLOAT, NULL);
631 GLenum statusRGB = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER);
632 glDeleteFramebuffersEXT(1, &fb_id);
633 glDeleteTextures(1, &tex_id);
635 glBindFramebufferEXT(GL_FRAMEBUFFER, static_cast<GLuint>(fb_binding));
636 glBindTexture(GL_TEXTURE_2D, static_cast<GLuint>(tex_binding));
638 DCHECK(glGetError() == GL_NO_ERROR);
640 if (statusRGBA == GL_FRAMEBUFFER_COMPLETE) {
641 validators_.texture_internal_format.AddValue(GL_RGBA32F);
642 feature_flags_.chromium_color_buffer_float_rgba = true;
643 AddExtensionString("GL_CHROMIUM_color_buffer_float_rgba");
645 if (statusRGB == GL_FRAMEBUFFER_COMPLETE) {
646 validators_.texture_internal_format.AddValue(GL_RGB32F);
647 feature_flags_.chromium_color_buffer_float_rgb = true;
648 AddExtensionString("GL_CHROMIUM_color_buffer_float_rgb");
652 // Check for multisample support
653 if (!workarounds_.disable_chromium_framebuffer_multisample) {
654 bool ext_has_multisample =
655 extensions.Contains("GL_EXT_framebuffer_multisample") ||
656 gl_version_info_->is_es3 ||
657 gl_version_info_->is_desktop_core_profile;
658 if (gl_version_info_->is_angle) {
659 ext_has_multisample |=
660 extensions.Contains("GL_ANGLE_framebuffer_multisample");
662 feature_flags_.use_core_framebuffer_multisample =
663 gl_version_info_->is_es3 || gl_version_info_->is_desktop_core_profile;
664 if (ext_has_multisample) {
665 feature_flags_.chromium_framebuffer_multisample = true;
666 validators_.frame_buffer_target.AddValue(GL_READ_FRAMEBUFFER_EXT);
667 validators_.frame_buffer_target.AddValue(GL_DRAW_FRAMEBUFFER_EXT);
668 validators_.g_l_state.AddValue(GL_READ_FRAMEBUFFER_BINDING_EXT);
669 validators_.g_l_state.AddValue(GL_MAX_SAMPLES_EXT);
670 validators_.render_buffer_parameter.AddValue(GL_RENDERBUFFER_SAMPLES_EXT);
671 AddExtensionString("GL_CHROMIUM_framebuffer_multisample");
675 if (!workarounds_.disable_multisampled_render_to_texture) {
676 if (extensions.Contains("GL_EXT_multisampled_render_to_texture")) {
677 feature_flags_.multisampled_render_to_texture = true;
678 } else if (extensions.Contains("GL_IMG_multisampled_render_to_texture")) {
679 feature_flags_.multisampled_render_to_texture = true;
680 feature_flags_.use_img_for_multisampled_render_to_texture = true;
682 if (feature_flags_.multisampled_render_to_texture) {
683 validators_.render_buffer_parameter.AddValue(
684 GL_RENDERBUFFER_SAMPLES_EXT);
685 validators_.g_l_state.AddValue(GL_MAX_SAMPLES_EXT);
686 validators_.frame_buffer_parameter.AddValue(
687 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT);
688 AddExtensionString("GL_EXT_multisampled_render_to_texture");
692 if (extensions.Contains("GL_OES_depth24") || gfx::HasDesktopGLFeatures() ||
693 gl_version_info_->is_es3) {
694 AddExtensionString("GL_OES_depth24");
695 feature_flags_.oes_depth24 = true;
696 validators_.render_buffer_format.AddValue(GL_DEPTH_COMPONENT24);
699 if (!workarounds_.disable_oes_standard_derivatives &&
700 (gl_version_info_->is_es3 ||
701 extensions.Contains("GL_OES_standard_derivatives") ||
702 gfx::HasDesktopGLFeatures())) {
703 AddExtensionString("GL_OES_standard_derivatives");
704 feature_flags_.oes_standard_derivatives = true;
705 validators_.hint_target.AddValue(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES);
706 validators_.g_l_state.AddValue(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES);
709 if (extensions.Contains("GL_OES_EGL_image_external")) {
710 AddExtensionString("GL_OES_EGL_image_external");
711 feature_flags_.oes_egl_image_external = true;
712 validators_.texture_bind_target.AddValue(GL_TEXTURE_EXTERNAL_OES);
713 validators_.get_tex_param_target.AddValue(GL_TEXTURE_EXTERNAL_OES);
714 validators_.texture_parameter.AddValue(GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES);
715 validators_.g_l_state.AddValue(GL_TEXTURE_BINDING_EXTERNAL_OES);
718 if (extensions.Contains("GL_OES_compressed_ETC1_RGB8_texture")) {
719 AddExtensionString("GL_OES_compressed_ETC1_RGB8_texture");
720 feature_flags_.oes_compressed_etc1_rgb8_texture = true;
721 validators_.compressed_texture_format.AddValue(GL_ETC1_RGB8_OES);
724 if (extensions.Contains("GL_AMD_compressed_ATC_texture")) {
725 AddExtensionString("GL_AMD_compressed_ATC_texture");
726 validators_.compressed_texture_format.AddValue(
727 GL_ATC_RGB_AMD);
728 validators_.compressed_texture_format.AddValue(
729 GL_ATC_RGBA_EXPLICIT_ALPHA_AMD);
730 validators_.compressed_texture_format.AddValue(
731 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD);
734 if (extensions.Contains("GL_IMG_texture_compression_pvrtc")) {
735 AddExtensionString("GL_IMG_texture_compression_pvrtc");
736 validators_.compressed_texture_format.AddValue(
737 GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG);
738 validators_.compressed_texture_format.AddValue(
739 GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG);
740 validators_.compressed_texture_format.AddValue(
741 GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG);
742 validators_.compressed_texture_format.AddValue(
743 GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG);
746 // Ideally we would only expose this extension on Mac OS X, to
747 // support GL_CHROMIUM_iosurface and the compositor. We don't want
748 // applications to start using it; they should use ordinary non-
749 // power-of-two textures. However, for unit testing purposes we
750 // expose it on all supported platforms.
751 if (extensions.Contains("GL_ARB_texture_rectangle") ||
752 gl_version_info_->is_desktop_core_profile) {
753 AddExtensionString("GL_ARB_texture_rectangle");
754 feature_flags_.arb_texture_rectangle = true;
755 validators_.texture_bind_target.AddValue(GL_TEXTURE_RECTANGLE_ARB);
756 // For the moment we don't add this enum to the texture_target
757 // validator. This implies that the only way to get image data into a
758 // rectangular texture is via glTexImageIOSurface2DCHROMIUM, which is
759 // just fine since again we don't want applications depending on this
760 // extension.
761 validators_.get_tex_param_target.AddValue(GL_TEXTURE_RECTANGLE_ARB);
762 validators_.g_l_state.AddValue(GL_TEXTURE_BINDING_RECTANGLE_ARB);
765 #if defined(OS_MACOSX)
766 AddExtensionString("GL_CHROMIUM_iosurface");
767 #endif
769 // TODO(gman): Add support for these extensions.
770 // GL_OES_depth32
772 feature_flags_.enable_texture_float_linear |= enable_texture_float_linear;
773 feature_flags_.enable_texture_half_float_linear |=
774 enable_texture_half_float_linear;
776 if (extensions.Contains("GL_ANGLE_pack_reverse_row_order")) {
777 AddExtensionString("GL_ANGLE_pack_reverse_row_order");
778 feature_flags_.angle_pack_reverse_row_order = true;
779 validators_.pixel_store.AddValue(GL_PACK_REVERSE_ROW_ORDER_ANGLE);
780 validators_.g_l_state.AddValue(GL_PACK_REVERSE_ROW_ORDER_ANGLE);
783 if (extensions.Contains("GL_ANGLE_texture_usage")) {
784 feature_flags_.angle_texture_usage = true;
785 AddExtensionString("GL_ANGLE_texture_usage");
786 validators_.texture_parameter.AddValue(GL_TEXTURE_USAGE_ANGLE);
789 // Note: Only APPLE_texture_format_BGRA8888 extension allows BGRA8_EXT in
790 // ES3's glTexStorage2D. We prefer support BGRA to texture storage.
791 // So we don't expose GL_EXT_texture_storage when ES3 +
792 // GL_EXT_texture_format_BGRA8888 because we fail the GL_BGRA8 requirement.
793 // However we expose GL_EXT_texture_storage when just ES3 because we don't
794 // claim to handle GL_BGRA8.
795 bool support_texture_storage_on_es3 =
796 (gl_version_info_->is_es3 &&
797 enable_immutable_texture_format_bgra_on_es3) ||
798 (gl_version_info_->is_es3 &&
799 !enable_texture_format_bgra8888);
800 if (extensions.Contains("GL_EXT_texture_storage") ||
801 extensions.Contains("GL_ARB_texture_storage") ||
802 support_texture_storage_on_es3 ||
803 gl_version_info_->is_desktop_core_profile) {
804 feature_flags_.ext_texture_storage = true;
805 AddExtensionString("GL_EXT_texture_storage");
806 validators_.texture_parameter.AddValue(GL_TEXTURE_IMMUTABLE_FORMAT_EXT);
807 if (enable_texture_format_bgra8888)
808 validators_.texture_internal_format_storage.AddValue(GL_BGRA8_EXT);
809 if (enable_texture_float) {
810 validators_.texture_internal_format_storage.AddValue(GL_RGBA32F_EXT);
811 validators_.texture_internal_format_storage.AddValue(GL_RGB32F_EXT);
812 validators_.texture_internal_format_storage.AddValue(GL_ALPHA32F_EXT);
813 validators_.texture_internal_format_storage.AddValue(
814 GL_LUMINANCE32F_EXT);
815 validators_.texture_internal_format_storage.AddValue(
816 GL_LUMINANCE_ALPHA32F_EXT);
818 if (enable_texture_half_float) {
819 validators_.texture_internal_format_storage.AddValue(GL_RGBA16F_EXT);
820 validators_.texture_internal_format_storage.AddValue(GL_RGB16F_EXT);
821 validators_.texture_internal_format_storage.AddValue(GL_ALPHA16F_EXT);
822 validators_.texture_internal_format_storage.AddValue(
823 GL_LUMINANCE16F_EXT);
824 validators_.texture_internal_format_storage.AddValue(
825 GL_LUMINANCE_ALPHA16F_EXT);
829 bool have_ext_occlusion_query_boolean =
830 extensions.Contains("GL_EXT_occlusion_query_boolean");
831 bool have_arb_occlusion_query2 =
832 extensions.Contains("GL_ARB_occlusion_query2");
833 bool have_arb_occlusion_query =
834 extensions.Contains("GL_ARB_occlusion_query");
836 if (!workarounds_.disable_ext_occlusion_query &&
837 (have_ext_occlusion_query_boolean ||
838 have_arb_occlusion_query2 ||
839 have_arb_occlusion_query)) {
840 AddExtensionString("GL_EXT_occlusion_query_boolean");
841 feature_flags_.occlusion_query_boolean = true;
842 feature_flags_.use_arb_occlusion_query2_for_occlusion_query_boolean =
843 !have_ext_occlusion_query_boolean && have_arb_occlusion_query2;
844 feature_flags_.use_arb_occlusion_query_for_occlusion_query_boolean =
845 !have_ext_occlusion_query_boolean && have_arb_occlusion_query &&
846 !have_arb_occlusion_query2;
849 if (!workarounds_.disable_angle_instanced_arrays &&
850 (extensions.Contains("GL_ANGLE_instanced_arrays") ||
851 (extensions.Contains("GL_ARB_instanced_arrays") &&
852 extensions.Contains("GL_ARB_draw_instanced")) ||
853 gl_version_info_->is_es3)) {
854 AddExtensionString("GL_ANGLE_instanced_arrays");
855 feature_flags_.angle_instanced_arrays = true;
856 validators_.vertex_attribute.AddValue(GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE);
859 bool vendor_agnostic_draw_buffers =
860 extensions.Contains("GL_ARB_draw_buffers") ||
861 extensions.Contains("GL_EXT_draw_buffers");
862 if (!workarounds_.disable_ext_draw_buffers &&
863 (vendor_agnostic_draw_buffers ||
864 (extensions.Contains("GL_NV_draw_buffers") &&
865 gl_version_info_->is_es3) ||
866 gl_version_info_->is_desktop_core_profile)) {
867 AddExtensionString("GL_EXT_draw_buffers");
868 feature_flags_.ext_draw_buffers = true;
870 // This flag is set to enable emulation of EXT_draw_buffers when we're
871 // running on GLES 3.0+, NV_draw_buffers extension is supported and
872 // glDrawBuffers from GLES 3.0 core has been bound. It toggles using the
873 // NV_draw_buffers extension directive instead of EXT_draw_buffers extension
874 // directive in ESSL 100 shaders translated by ANGLE, enabling them to write
875 // into multiple gl_FragData values, which is not by default possible in
876 // ESSL 100 with core GLES 3.0. For more information, see the
877 // NV_draw_buffers specification.
878 feature_flags_.nv_draw_buffers = !vendor_agnostic_draw_buffers;
880 GLint max_color_attachments = 0;
881 glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &max_color_attachments);
882 for (GLenum i = GL_COLOR_ATTACHMENT1_EXT;
883 i < static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + max_color_attachments);
884 ++i) {
885 validators_.attachment.AddValue(i);
887 static_assert(GL_COLOR_ATTACHMENT0_EXT == GL_COLOR_ATTACHMENT0,
888 "GL_COLOR_ATTACHMENT0_EXT should equal GL_COLOR_ATTACHMENT0");
890 validators_.g_l_state.AddValue(GL_MAX_COLOR_ATTACHMENTS_EXT);
891 validators_.g_l_state.AddValue(GL_MAX_DRAW_BUFFERS_ARB);
892 GLint max_draw_buffers = 0;
893 glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &max_draw_buffers);
894 for (GLenum i = GL_DRAW_BUFFER0_ARB;
895 i < static_cast<GLenum>(GL_DRAW_BUFFER0_ARB + max_draw_buffers);
896 ++i) {
897 validators_.g_l_state.AddValue(i);
901 if (gl_version_info_->is_es3 ||
902 extensions.Contains("GL_EXT_blend_minmax") ||
903 gfx::HasDesktopGLFeatures()) {
904 AddExtensionString("GL_EXT_blend_minmax");
905 validators_.equation.AddValue(GL_MIN_EXT);
906 validators_.equation.AddValue(GL_MAX_EXT);
907 static_assert(GL_MIN_EXT == GL_MIN && GL_MAX_EXT == GL_MAX,
908 "min & max variations must match");
911 // TODO(dshwang): GLES3 supports gl_FragDepth, not gl_FragDepthEXT.
912 if (extensions.Contains("GL_EXT_frag_depth") || gfx::HasDesktopGLFeatures()) {
913 AddExtensionString("GL_EXT_frag_depth");
914 feature_flags_.ext_frag_depth = true;
917 if (extensions.Contains("GL_EXT_shader_texture_lod") ||
918 gfx::HasDesktopGLFeatures()) {
919 AddExtensionString("GL_EXT_shader_texture_lod");
920 feature_flags_.ext_shader_texture_lod = true;
923 #if !defined(OS_MACOSX)
924 if (workarounds_.disable_egl_khr_fence_sync) {
925 gfx::g_driver_egl.ext.b_EGL_KHR_fence_sync = false;
927 if (workarounds_.disable_egl_khr_wait_sync) {
928 gfx::g_driver_egl.ext.b_EGL_KHR_wait_sync = false;
930 #endif
931 if (workarounds_.disable_arb_sync)
932 gfx::g_driver_gl.ext.b_GL_ARB_sync = false;
933 bool ui_gl_fence_works = gfx::GLFence::IsSupported();
934 UMA_HISTOGRAM_BOOLEAN("GPU.FenceSupport", ui_gl_fence_works);
936 feature_flags_.map_buffer_range =
937 gl_version_info_->is_es3 ||
938 gl_version_info_->is_desktop_core_profile ||
939 extensions.Contains("GL_ARB_map_buffer_range") ||
940 extensions.Contains("GL_EXT_map_buffer_range");
942 // Really it's part of core OpenGL 2.1 and up, but let's assume the
943 // extension is still advertised.
944 bool has_pixel_buffers =
945 gl_version_info_->is_es3 ||
946 gl_version_info_->is_desktop_core_profile ||
947 extensions.Contains("GL_ARB_pixel_buffer_object") ||
948 extensions.Contains("GL_NV_pixel_buffer_object");
950 // We will use either glMapBuffer() or glMapBufferRange() for async readbacks.
951 if (has_pixel_buffers && ui_gl_fence_works &&
952 !workarounds_.disable_async_readpixels) {
953 feature_flags_.use_async_readpixels = true;
956 if (gl_version_info_->is_es3 ||
957 extensions.Contains("GL_ARB_sampler_objects")) {
958 feature_flags_.enable_samplers = true;
959 // TODO(dsinclair): Add AddExtensionString("GL_CHROMIUM_sampler_objects")
960 // when available.
963 if ((gl_version_info_->is_es3 ||
964 extensions.Contains("GL_EXT_discard_framebuffer")) &&
965 !workarounds_.disable_discard_framebuffer) {
966 // DiscardFramebufferEXT is automatically bound to InvalidateFramebuffer.
967 AddExtensionString("GL_EXT_discard_framebuffer");
968 feature_flags_.ext_discard_framebuffer = true;
971 if (ui_gl_fence_works) {
972 AddExtensionString("GL_CHROMIUM_sync_query");
973 feature_flags_.chromium_sync_query = true;
976 if (!workarounds_.disable_blend_equation_advanced) {
977 bool blend_equation_advanced_coherent =
978 extensions.Contains("GL_NV_blend_equation_advanced_coherent") ||
979 extensions.Contains("GL_KHR_blend_equation_advanced_coherent");
981 if (blend_equation_advanced_coherent ||
982 extensions.Contains("GL_NV_blend_equation_advanced") ||
983 extensions.Contains("GL_KHR_blend_equation_advanced")) {
984 const GLenum equations[] = {GL_MULTIPLY_KHR,
985 GL_SCREEN_KHR,
986 GL_OVERLAY_KHR,
987 GL_DARKEN_KHR,
988 GL_LIGHTEN_KHR,
989 GL_COLORDODGE_KHR,
990 GL_COLORBURN_KHR,
991 GL_HARDLIGHT_KHR,
992 GL_SOFTLIGHT_KHR,
993 GL_DIFFERENCE_KHR,
994 GL_EXCLUSION_KHR,
995 GL_HSL_HUE_KHR,
996 GL_HSL_SATURATION_KHR,
997 GL_HSL_COLOR_KHR,
998 GL_HSL_LUMINOSITY_KHR};
1000 for (GLenum equation : equations)
1001 validators_.equation.AddValue(equation);
1002 if (blend_equation_advanced_coherent)
1003 AddExtensionString("GL_KHR_blend_equation_advanced_coherent");
1005 AddExtensionString("GL_KHR_blend_equation_advanced");
1006 feature_flags_.blend_equation_advanced = true;
1007 feature_flags_.blend_equation_advanced_coherent =
1008 blend_equation_advanced_coherent;
1012 if (extensions.Contains("GL_NV_path_rendering")) {
1013 if (extensions.Contains("GL_EXT_direct_state_access") ||
1014 gl_version_info_->is_es3) {
1015 AddExtensionString("GL_CHROMIUM_path_rendering");
1016 feature_flags_.chromium_path_rendering = true;
1017 validators_.g_l_state.AddValue(GL_PATH_MODELVIEW_MATRIX_CHROMIUM);
1018 validators_.g_l_state.AddValue(GL_PATH_PROJECTION_MATRIX_CHROMIUM);
1022 if ((gl_version_info_->is_es3 || gl_version_info_->is_desktop_core_profile ||
1023 extensions.Contains("GL_EXT_texture_rg") ||
1024 extensions.Contains("GL_ARB_texture_rg")) &&
1025 IsGL_REDSupportedOnFBOs()) {
1026 feature_flags_.ext_texture_rg = true;
1027 AddExtensionString("GL_EXT_texture_rg");
1029 validators_.texture_format.AddValue(GL_RED_EXT);
1030 validators_.texture_format.AddValue(GL_RG_EXT);
1031 validators_.texture_internal_format.AddValue(GL_RED_EXT);
1032 validators_.texture_internal_format.AddValue(GL_R8_EXT);
1033 validators_.texture_internal_format.AddValue(GL_RG_EXT);
1034 validators_.texture_internal_format.AddValue(GL_RG8_EXT);
1035 validators_.read_pixel_format.AddValue(GL_RED_EXT);
1036 validators_.read_pixel_format.AddValue(GL_RG_EXT);
1037 validators_.render_buffer_format.AddValue(GL_R8_EXT);
1038 validators_.render_buffer_format.AddValue(GL_RG8_EXT);
1040 UMA_HISTOGRAM_BOOLEAN("GPU.TextureRG", feature_flags_.ext_texture_rg);
1042 #if !defined(OS_MACOSX)
1043 if (workarounds_.ignore_egl_sync_failures) {
1044 gfx::GLFenceEGL::SetIgnoreFailures();
1046 #endif
1048 if (workarounds_.avoid_egl_image_target_texture_reuse) {
1049 TextureDefinition::AvoidEGLTargetTextureReuse();
1052 if (gl_version_info_->IsLowerThanGL(4, 3)) {
1053 // crbug.com/481184.
1054 // GL_PRIMITIVE_RESTART_FIXED_INDEX is only available on Desktop GL 4.3+,
1055 // but we emulate ES 3.0 on top of Desktop GL 4.2+.
1056 feature_flags_.emulate_primitive_restart_fixed_index = true;
1060 bool FeatureInfo::IsES3Capable() const {
1061 if (!enable_unsafe_es3_apis_switch_)
1062 return false;
1063 if (gl_version_info_)
1064 return gl_version_info_->IsES3Capable();
1065 return false;
1068 void FeatureInfo::EnableES3Validators() {
1069 DCHECK(IsES3Capable());
1070 validators_.UpdateValuesES3();
1072 GLint max_color_attachments = 0;
1073 glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);
1074 const int kTotalColorAttachmentEnums = 16;
1075 const GLenum kColorAttachments[] = {
1076 GL_COLOR_ATTACHMENT0,
1077 GL_COLOR_ATTACHMENT1,
1078 GL_COLOR_ATTACHMENT2,
1079 GL_COLOR_ATTACHMENT3,
1080 GL_COLOR_ATTACHMENT4,
1081 GL_COLOR_ATTACHMENT5,
1082 GL_COLOR_ATTACHMENT6,
1083 GL_COLOR_ATTACHMENT7,
1084 GL_COLOR_ATTACHMENT8,
1085 GL_COLOR_ATTACHMENT9,
1086 GL_COLOR_ATTACHMENT10,
1087 GL_COLOR_ATTACHMENT11,
1088 GL_COLOR_ATTACHMENT12,
1089 GL_COLOR_ATTACHMENT13,
1090 GL_COLOR_ATTACHMENT14,
1091 GL_COLOR_ATTACHMENT15,
1093 if (max_color_attachments < kTotalColorAttachmentEnums) {
1094 validators_.attachment.RemoveValues(
1095 kColorAttachments + max_color_attachments,
1096 kTotalColorAttachmentEnums - max_color_attachments);
1099 GLint max_draw_buffers = 0;
1100 glGetIntegerv(GL_MAX_DRAW_BUFFERS, &max_draw_buffers);
1101 const int kTotalDrawBufferEnums = 16;
1102 const GLenum kDrawBuffers[] = {
1103 GL_DRAW_BUFFER0,
1104 GL_DRAW_BUFFER1,
1105 GL_DRAW_BUFFER2,
1106 GL_DRAW_BUFFER3,
1107 GL_DRAW_BUFFER4,
1108 GL_DRAW_BUFFER5,
1109 GL_DRAW_BUFFER6,
1110 GL_DRAW_BUFFER7,
1111 GL_DRAW_BUFFER8,
1112 GL_DRAW_BUFFER9,
1113 GL_DRAW_BUFFER10,
1114 GL_DRAW_BUFFER11,
1115 GL_DRAW_BUFFER12,
1116 GL_DRAW_BUFFER13,
1117 GL_DRAW_BUFFER14,
1118 GL_DRAW_BUFFER15,
1120 if (max_draw_buffers < kTotalDrawBufferEnums) {
1121 validators_.g_l_state.RemoveValues(
1122 kDrawBuffers + max_draw_buffers,
1123 kTotalDrawBufferEnums - max_draw_buffers);
1126 unsafe_es3_apis_enabled_ = true;
1129 void FeatureInfo::AddExtensionString(const char* s) {
1130 std::string str(s);
1131 size_t pos = extensions_.find(str);
1132 while (pos != std::string::npos &&
1133 pos + str.length() < extensions_.length() &&
1134 extensions_.substr(pos + str.length(), 1) != " ") {
1135 // This extension name is a substring of another.
1136 pos = extensions_.find(str, pos + str.length());
1138 if (pos == std::string::npos) {
1139 extensions_ += (extensions_.empty() ? "" : " ") + str;
1143 FeatureInfo::~FeatureInfo() {
1146 } // namespace gles2
1147 } // namespace gpu