| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gpu/command_buffer/service/feature_info.h" | 5 #include "gpu/command_buffer/service/feature_info.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 return string_set_; | 76 return string_set_; |
| 77 } | 77 } |
| 78 | 78 |
| 79 private: | 79 private: |
| 80 std::set<std::string> string_set_; | 80 std::set<std::string> string_set_; |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 class ScopedPixelUnpackBufferOverride { | 83 class ScopedPixelUnpackBufferOverride { |
| 84 public: | 84 public: |
| 85 explicit ScopedPixelUnpackBufferOverride( | 85 explicit ScopedPixelUnpackBufferOverride( |
| 86 bool is_es3_capable, | 86 bool enable_es3, |
| 87 ContextType context_type, | |
| 88 GLuint binding_override) | 87 GLuint binding_override) |
| 89 : orig_binding_(-1) { | 88 : orig_binding_(-1) { |
| 90 if (!(context_type == CONTEXT_TYPE_WEBGL1 || | 89 if (enable_es3) { |
| 91 context_type == CONTEXT_TYPE_OPENGLES2) && is_es3_capable) { | |
| 92 GLint orig_binding; | 90 GLint orig_binding; |
| 93 glGetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, &orig_binding); | 91 glGetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, &orig_binding); |
| 94 if (static_cast<GLuint>(orig_binding) != binding_override) { | 92 if (static_cast<GLuint>(orig_binding) != binding_override) { |
| 95 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, binding_override); | 93 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, binding_override); |
| 96 orig_binding_ = orig_binding; | 94 orig_binding_ = orig_binding; |
| 97 } | 95 } |
| 98 } | 96 } |
| 99 } | 97 } |
| 100 | 98 |
| 101 ~ScopedPixelUnpackBufferOverride() { | 99 ~ScopedPixelUnpackBufferOverride() { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 void FeatureInfo::InitializeBasicState(const base::CommandLine* command_line) { | 190 void FeatureInfo::InitializeBasicState(const base::CommandLine* command_line) { |
| 193 if (!command_line) | 191 if (!command_line) |
| 194 return; | 192 return; |
| 195 | 193 |
| 196 feature_flags_.enable_shader_name_hashing = | 194 feature_flags_.enable_shader_name_hashing = |
| 197 !command_line->HasSwitch(switches::kDisableShaderNameHashing); | 195 !command_line->HasSwitch(switches::kDisableShaderNameHashing); |
| 198 | 196 |
| 199 feature_flags_.is_swiftshader = | 197 feature_flags_.is_swiftshader = |
| 200 (command_line->GetSwitchValueASCII(switches::kUseGL) == "swiftshader"); | 198 (command_line->GetSwitchValueASCII(switches::kUseGL) == "swiftshader"); |
| 201 | 199 |
| 202 enable_unsafe_es3_apis_switch_ = | |
| 203 command_line->HasSwitch(switches::kEnableUnsafeES3APIs) && | |
| 204 !command_line->HasSwitch(switches::kDisableES3APIs); | |
| 205 | |
| 206 // The shader translator is needed to translate from WebGL-conformant GLES SL | 200 // The shader translator is needed to translate from WebGL-conformant GLES SL |
| 207 // to normal GLES SL, enforce WebGL conformance, translate from GLES SL 1.0 to | 201 // to normal GLES SL, enforce WebGL conformance, translate from GLES SL 1.0 to |
| 208 // target context GLSL, implement emulation of OpenGL ES features on OpenGL, | 202 // target context GLSL, implement emulation of OpenGL ES features on OpenGL, |
| 209 // etc. | 203 // etc. |
| 210 // The flag here is for testing only. | 204 // The flag here is for testing only. |
| 211 disable_shader_translator_ = | 205 disable_shader_translator_ = |
| 212 command_line->HasSwitch(switches::kDisableGLSLTranslator); | 206 command_line->HasSwitch(switches::kDisableGLSLTranslator); |
| 213 | 207 |
| 214 unsafe_es3_apis_enabled_ = false; | |
| 215 | |
| 216 // Default context_type_ to a GLES2 Context. | 208 // Default context_type_ to a GLES2 Context. |
| 217 context_type_ = CONTEXT_TYPE_OPENGLES2; | 209 context_type_ = CONTEXT_TYPE_OPENGLES2; |
| 218 | 210 |
| 219 ext_color_buffer_float_available_ = false; | 211 ext_color_buffer_float_available_ = false; |
| 220 oes_texture_float_linear_available_ = false; | 212 oes_texture_float_linear_available_ = false; |
| 221 oes_texture_half_float_linear_available_ = false; | 213 oes_texture_half_float_linear_available_ = false; |
| 222 } | 214 } |
| 223 | 215 |
| 224 bool FeatureInfo::Initialize(ContextType context_type, | 216 bool FeatureInfo::Initialize(ContextType context_type, |
| 225 const DisallowedFeatures& disallowed_features) { | 217 const DisallowedFeatures& disallowed_features) { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 StringSet extensions(gl::GetGLExtensionsFromCurrentContext()); | 335 StringSet extensions(gl::GetGLExtensionsFromCurrentContext()); |
| 344 | 336 |
| 345 const char* version_str = | 337 const char* version_str = |
| 346 reinterpret_cast<const char*>(glGetString(GL_VERSION)); | 338 reinterpret_cast<const char*>(glGetString(GL_VERSION)); |
| 347 const char* renderer_str = | 339 const char* renderer_str = |
| 348 reinterpret_cast<const char*>(glGetString(GL_RENDERER)); | 340 reinterpret_cast<const char*>(glGetString(GL_RENDERER)); |
| 349 | 341 |
| 350 gl_version_info_.reset( | 342 gl_version_info_.reset( |
| 351 new gl::GLVersionInfo(version_str, renderer_str, extensions.GetImpl())); | 343 new gl::GLVersionInfo(version_str, renderer_str, extensions.GetImpl())); |
| 352 | 344 |
| 353 // TODO(kainino): This call to IsES3Capable is sort of a hack to get some | 345 bool enable_es3 = IsWebGL2OrES3Context(); |
| 354 // mocked tests working. | 346 |
| 355 ScopedPixelUnpackBufferOverride scoped_pbo_override( | 347 ScopedPixelUnpackBufferOverride scoped_pbo_override(enable_es3, 0); |
| 356 IsES3Capable(), context_type_, 0); | |
| 357 | 348 |
| 358 AddExtensionString("GL_ANGLE_translated_shader_source"); | 349 AddExtensionString("GL_ANGLE_translated_shader_source"); |
| 359 AddExtensionString("GL_CHROMIUM_async_pixel_transfers"); | 350 AddExtensionString("GL_CHROMIUM_async_pixel_transfers"); |
| 360 AddExtensionString("GL_CHROMIUM_bind_uniform_location"); | 351 AddExtensionString("GL_CHROMIUM_bind_uniform_location"); |
| 361 AddExtensionString("GL_CHROMIUM_command_buffer_query"); | 352 AddExtensionString("GL_CHROMIUM_command_buffer_query"); |
| 362 AddExtensionString("GL_CHROMIUM_command_buffer_latency_query"); | 353 AddExtensionString("GL_CHROMIUM_command_buffer_latency_query"); |
| 363 AddExtensionString("GL_CHROMIUM_copy_texture"); | 354 AddExtensionString("GL_CHROMIUM_copy_texture"); |
| 364 AddExtensionString("GL_CHROMIUM_deschedule"); | 355 AddExtensionString("GL_CHROMIUM_deschedule"); |
| 365 AddExtensionString("GL_CHROMIUM_get_error_query"); | 356 AddExtensionString("GL_CHROMIUM_get_error_query"); |
| 366 AddExtensionString("GL_CHROMIUM_lose_context"); | 357 AddExtensionString("GL_CHROMIUM_lose_context"); |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 glBindFramebufferEXT(GL_FRAMEBUFFER, fb_id); | 840 glBindFramebufferEXT(GL_FRAMEBUFFER, fb_id); |
| 850 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | 841 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
| 851 GL_TEXTURE_2D, tex_id, 0); | 842 GL_TEXTURE_2D, tex_id, 0); |
| 852 GLenum status_rgba = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); | 843 GLenum status_rgba = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); |
| 853 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, width, width, 0, GL_RGB, | 844 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, width, width, 0, GL_RGB, |
| 854 GL_FLOAT, NULL); | 845 GL_FLOAT, NULL); |
| 855 GLenum status_rgb = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); | 846 GLenum status_rgb = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); |
| 856 | 847 |
| 857 // For desktop systems, check to see if we support rendering to the full | 848 // For desktop systems, check to see if we support rendering to the full |
| 858 // range of formats supported by EXT_color_buffer_float | 849 // range of formats supported by EXT_color_buffer_float |
| 859 if (status_rgba == GL_FRAMEBUFFER_COMPLETE && IsES3Capable()) { | 850 if (status_rgba == GL_FRAMEBUFFER_COMPLETE && enable_es3) { |
| 860 bool full_float_support = true; | 851 bool full_float_support = true; |
| 861 | 852 |
| 862 glTexImage2D(GL_TEXTURE_2D, 0, GL_R16F, width, width, 0, GL_RED, | 853 glTexImage2D(GL_TEXTURE_2D, 0, GL_R16F, width, width, 0, GL_RED, |
| 863 GL_FLOAT, NULL); | 854 GL_FLOAT, NULL); |
| 864 full_float_support &= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER) == | 855 full_float_support &= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER) == |
| 865 GL_FRAMEBUFFER_COMPLETE; | 856 GL_FRAMEBUFFER_COMPLETE; |
| 866 glTexImage2D(GL_TEXTURE_2D, 0, GL_RG16F, width, width, 0, GL_RG, | 857 glTexImage2D(GL_TEXTURE_2D, 0, GL_RG16F, width, width, 0, GL_RG, |
| 867 GL_FLOAT, NULL); | 858 GL_FLOAT, NULL); |
| 868 full_float_support &= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER) == | 859 full_float_support &= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER) == |
| 869 GL_FRAMEBUFFER_COMPLETE; | 860 GL_FRAMEBUFFER_COMPLETE; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 EnableCHROMIUMColorBufferFloatRGBA(); | 892 EnableCHROMIUMColorBufferFloatRGBA(); |
| 902 } | 893 } |
| 903 if (status_rgb == GL_FRAMEBUFFER_COMPLETE) { | 894 if (status_rgb == GL_FRAMEBUFFER_COMPLETE) { |
| 904 feature_flags_.chromium_color_buffer_float_rgb = true; | 895 feature_flags_.chromium_color_buffer_float_rgb = true; |
| 905 if (!disallowed_features_.chromium_color_buffer_float_rgb) | 896 if (!disallowed_features_.chromium_color_buffer_float_rgb) |
| 906 EnableCHROMIUMColorBufferFloatRGB(); | 897 EnableCHROMIUMColorBufferFloatRGB(); |
| 907 } | 898 } |
| 908 } | 899 } |
| 909 | 900 |
| 910 // Enable the GL_EXT_color_buffer_float extension for WebGL 2.0 | 901 // Enable the GL_EXT_color_buffer_float extension for WebGL 2.0 |
| 911 if (enable_ext_color_buffer_float && IsES3Capable()) { | 902 if (enable_ext_color_buffer_float && enable_es3) { |
| 912 ext_color_buffer_float_available_ = true; | 903 ext_color_buffer_float_available_ = true; |
| 913 if (!disallowed_features_.ext_color_buffer_float) | 904 if (!disallowed_features_.ext_color_buffer_float) |
| 914 EnableEXTColorBufferFloat(); | 905 EnableEXTColorBufferFloat(); |
| 915 } | 906 } |
| 916 | 907 |
| 917 // Check for multisample support | 908 // Check for multisample support |
| 918 if (!workarounds_.disable_chromium_framebuffer_multisample) { | 909 if (!workarounds_.disable_chromium_framebuffer_multisample) { |
| 919 bool ext_has_multisample = | 910 bool ext_has_multisample = |
| 920 extensions.Contains("GL_EXT_framebuffer_multisample") || | 911 extensions.Contains("GL_EXT_framebuffer_multisample") || |
| 921 gl_version_info_->is_es3 || | 912 gl_version_info_->is_es3 || |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1406 // GL_PRIMITIVE_RESTART_FIXED_INDEX is only available on Desktop GL 4.3+, | 1397 // GL_PRIMITIVE_RESTART_FIXED_INDEX is only available on Desktop GL 4.3+, |
| 1407 // but we emulate ES 3.0 on top of Desktop GL 4.2+. | 1398 // but we emulate ES 3.0 on top of Desktop GL 4.2+. |
| 1408 feature_flags_.emulate_primitive_restart_fixed_index = true; | 1399 feature_flags_.emulate_primitive_restart_fixed_index = true; |
| 1409 } | 1400 } |
| 1410 | 1401 |
| 1411 feature_flags_.angle_robust_client_memory = | 1402 feature_flags_.angle_robust_client_memory = |
| 1412 extensions.Contains("GL_ANGLE_robust_client_memory"); | 1403 extensions.Contains("GL_ANGLE_robust_client_memory"); |
| 1413 } | 1404 } |
| 1414 | 1405 |
| 1415 bool FeatureInfo::IsES3Capable() const { | 1406 bool FeatureInfo::IsES3Capable() const { |
| 1416 if (!enable_unsafe_es3_apis_switch_) | |
| 1417 return false; | |
| 1418 if (workarounds_.disable_texture_storage) | 1407 if (workarounds_.disable_texture_storage) |
| 1419 return false; | 1408 return false; |
| 1420 if (gl_version_info_) | 1409 if (gl_version_info_) |
| 1421 return gl_version_info_->is_es3_capable; | 1410 return gl_version_info_->is_es3_capable; |
| 1422 return false; | 1411 return false; |
| 1423 } | 1412 } |
| 1424 | 1413 |
| 1425 void FeatureInfo::EnableES3Validators() { | 1414 void FeatureInfo::EnableES3Validators() { |
| 1426 DCHECK(IsES3Capable()); | 1415 DCHECK(IsES3Capable()); |
| 1427 validators_.UpdateValuesES3(); | 1416 validators_.UpdateValuesES3(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1486 kTotalDrawBufferEnums - max_draw_buffers); | 1475 kTotalDrawBufferEnums - max_draw_buffers); |
| 1487 } | 1476 } |
| 1488 | 1477 |
| 1489 if (feature_flags_.ext_texture_format_bgra8888) { | 1478 if (feature_flags_.ext_texture_format_bgra8888) { |
| 1490 validators_.texture_internal_format.AddValue(GL_BGRA8_EXT); | 1479 validators_.texture_internal_format.AddValue(GL_BGRA8_EXT); |
| 1491 validators_.texture_sized_color_renderable_internal_format.AddValue( | 1480 validators_.texture_sized_color_renderable_internal_format.AddValue( |
| 1492 GL_BGRA8_EXT); | 1481 GL_BGRA8_EXT); |
| 1493 validators_.texture_sized_texture_filterable_internal_format.AddValue( | 1482 validators_.texture_sized_texture_filterable_internal_format.AddValue( |
| 1494 GL_BGRA8_EXT); | 1483 GL_BGRA8_EXT); |
| 1495 } | 1484 } |
| 1496 | |
| 1497 unsafe_es3_apis_enabled_ = true; | |
| 1498 } | 1485 } |
| 1499 | 1486 |
| 1500 bool FeatureInfo::IsWebGLContext() const { | 1487 bool FeatureInfo::IsWebGLContext() const { |
| 1501 // Switch statement to cause a compile-time error if we miss a case. | 1488 // Switch statement to cause a compile-time error if we miss a case. |
| 1502 switch (context_type_) { | 1489 switch (context_type_) { |
| 1503 case CONTEXT_TYPE_WEBGL1: | 1490 case CONTEXT_TYPE_WEBGL1: |
| 1504 case CONTEXT_TYPE_WEBGL2: | 1491 case CONTEXT_TYPE_WEBGL2: |
| 1505 return true; | 1492 return true; |
| 1506 case CONTEXT_TYPE_OPENGLES2: | 1493 case CONTEXT_TYPE_OPENGLES2: |
| 1507 case CONTEXT_TYPE_OPENGLES3: | 1494 case CONTEXT_TYPE_OPENGLES3: |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1554 if (pos == std::string::npos) { | 1541 if (pos == std::string::npos) { |
| 1555 extensions_ += (extensions_.empty() ? "" : " ") + str; | 1542 extensions_ += (extensions_.empty() ? "" : " ") + str; |
| 1556 } | 1543 } |
| 1557 } | 1544 } |
| 1558 | 1545 |
| 1559 FeatureInfo::~FeatureInfo() { | 1546 FeatureInfo::~FeatureInfo() { |
| 1560 } | 1547 } |
| 1561 | 1548 |
| 1562 } // namespace gles2 | 1549 } // namespace gles2 |
| 1563 } // namespace gpu | 1550 } // namespace gpu |
| OLD | NEW |