Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Side by Side Diff: gpu/command_buffer/service/feature_info.cc

Issue 2471853002: remove 'unsafe' from ES3 apis in gpu process (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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) &&
Zhenyao Mo 2016/11/02 21:46:28 Per our offline discussion, we need to hook up Gpu
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; 208 unsafe_es3_apis_enabled_ = false;
215 209
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 StringSet extensions(gl::GetGLExtensionsFromCurrentContext()); 337 StringSet extensions(gl::GetGLExtensionsFromCurrentContext());
344 338
345 const char* version_str = 339 const char* version_str =
346 reinterpret_cast<const char*>(glGetString(GL_VERSION)); 340 reinterpret_cast<const char*>(glGetString(GL_VERSION));
347 const char* renderer_str = 341 const char* renderer_str =
348 reinterpret_cast<const char*>(glGetString(GL_RENDERER)); 342 reinterpret_cast<const char*>(glGetString(GL_RENDERER));
349 343
350 gl_version_info_.reset( 344 gl_version_info_.reset(
351 new gl::GLVersionInfo(version_str, renderer_str, extensions.GetImpl())); 345 new gl::GLVersionInfo(version_str, renderer_str, extensions.GetImpl()));
352 346
353 // TODO(kainino): This call to IsES3Capable is sort of a hack to get some 347 bool enable_es3 = IsWebGL2OrES3Context();
354 // mocked tests working. 348
355 ScopedPixelUnpackBufferOverride scoped_pbo_override( 349 ScopedPixelUnpackBufferOverride scoped_pbo_override(enable_es3, 0);
356 IsES3Capable(), context_type_, 0);
357 350
358 AddExtensionString("GL_ANGLE_translated_shader_source"); 351 AddExtensionString("GL_ANGLE_translated_shader_source");
359 AddExtensionString("GL_CHROMIUM_async_pixel_transfers"); 352 AddExtensionString("GL_CHROMIUM_async_pixel_transfers");
360 AddExtensionString("GL_CHROMIUM_bind_uniform_location"); 353 AddExtensionString("GL_CHROMIUM_bind_uniform_location");
361 AddExtensionString("GL_CHROMIUM_command_buffer_query"); 354 AddExtensionString("GL_CHROMIUM_command_buffer_query");
362 AddExtensionString("GL_CHROMIUM_command_buffer_latency_query"); 355 AddExtensionString("GL_CHROMIUM_command_buffer_latency_query");
363 AddExtensionString("GL_CHROMIUM_copy_texture"); 356 AddExtensionString("GL_CHROMIUM_copy_texture");
364 AddExtensionString("GL_CHROMIUM_deschedule"); 357 AddExtensionString("GL_CHROMIUM_deschedule");
365 AddExtensionString("GL_CHROMIUM_get_error_query"); 358 AddExtensionString("GL_CHROMIUM_get_error_query");
366 AddExtensionString("GL_CHROMIUM_lose_context"); 359 AddExtensionString("GL_CHROMIUM_lose_context");
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 glBindFramebufferEXT(GL_FRAMEBUFFER, fb_id); 842 glBindFramebufferEXT(GL_FRAMEBUFFER, fb_id);
850 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 843 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
851 GL_TEXTURE_2D, tex_id, 0); 844 GL_TEXTURE_2D, tex_id, 0);
852 GLenum status_rgba = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); 845 GLenum status_rgba = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER);
853 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, width, width, 0, GL_RGB, 846 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, width, width, 0, GL_RGB,
854 GL_FLOAT, NULL); 847 GL_FLOAT, NULL);
855 GLenum status_rgb = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); 848 GLenum status_rgb = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER);
856 849
857 // For desktop systems, check to see if we support rendering to the full 850 // For desktop systems, check to see if we support rendering to the full
858 // range of formats supported by EXT_color_buffer_float 851 // range of formats supported by EXT_color_buffer_float
859 if (status_rgba == GL_FRAMEBUFFER_COMPLETE && IsES3Capable()) { 852 if (status_rgba == GL_FRAMEBUFFER_COMPLETE && enable_es3) {
piman 2016/11/02 22:05:08 I think we still expose the extension on ES2/WebGL
Zhenyao Mo 2016/11/02 22:15:00 I checked the spec, the ES spec says it's ES3 exte
860 bool full_float_support = true; 853 bool full_float_support = true;
861 854
862 glTexImage2D(GL_TEXTURE_2D, 0, GL_R16F, width, width, 0, GL_RED, 855 glTexImage2D(GL_TEXTURE_2D, 0, GL_R16F, width, width, 0, GL_RED,
863 GL_FLOAT, NULL); 856 GL_FLOAT, NULL);
864 full_float_support &= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER) == 857 full_float_support &= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER) ==
865 GL_FRAMEBUFFER_COMPLETE; 858 GL_FRAMEBUFFER_COMPLETE;
866 glTexImage2D(GL_TEXTURE_2D, 0, GL_RG16F, width, width, 0, GL_RG, 859 glTexImage2D(GL_TEXTURE_2D, 0, GL_RG16F, width, width, 0, GL_RG,
867 GL_FLOAT, NULL); 860 GL_FLOAT, NULL);
868 full_float_support &= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER) == 861 full_float_support &= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER) ==
869 GL_FRAMEBUFFER_COMPLETE; 862 GL_FRAMEBUFFER_COMPLETE;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 EnableCHROMIUMColorBufferFloatRGBA(); 894 EnableCHROMIUMColorBufferFloatRGBA();
902 } 895 }
903 if (status_rgb == GL_FRAMEBUFFER_COMPLETE) { 896 if (status_rgb == GL_FRAMEBUFFER_COMPLETE) {
904 feature_flags_.chromium_color_buffer_float_rgb = true; 897 feature_flags_.chromium_color_buffer_float_rgb = true;
905 if (!disallowed_features_.chromium_color_buffer_float_rgb) 898 if (!disallowed_features_.chromium_color_buffer_float_rgb)
906 EnableCHROMIUMColorBufferFloatRGB(); 899 EnableCHROMIUMColorBufferFloatRGB();
907 } 900 }
908 } 901 }
909 902
910 // Enable the GL_EXT_color_buffer_float extension for WebGL 2.0 903 // Enable the GL_EXT_color_buffer_float extension for WebGL 2.0
911 if (enable_ext_color_buffer_float && IsES3Capable()) { 904 if (enable_ext_color_buffer_float && enable_es3) {
piman 2016/11/02 22:05:08 ditto
912 ext_color_buffer_float_available_ = true; 905 ext_color_buffer_float_available_ = true;
913 if (!disallowed_features_.ext_color_buffer_float) 906 if (!disallowed_features_.ext_color_buffer_float)
914 EnableEXTColorBufferFloat(); 907 EnableEXTColorBufferFloat();
915 } 908 }
916 909
917 // Check for multisample support 910 // Check for multisample support
918 if (!workarounds_.disable_chromium_framebuffer_multisample) { 911 if (!workarounds_.disable_chromium_framebuffer_multisample) {
919 bool ext_has_multisample = 912 bool ext_has_multisample =
920 extensions.Contains("GL_EXT_framebuffer_multisample") || 913 extensions.Contains("GL_EXT_framebuffer_multisample") ||
921 gl_version_info_->is_es3 || 914 gl_version_info_->is_es3 ||
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 // GL_PRIMITIVE_RESTART_FIXED_INDEX is only available on Desktop GL 4.3+, 1399 // 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+. 1400 // but we emulate ES 3.0 on top of Desktop GL 4.2+.
1408 feature_flags_.emulate_primitive_restart_fixed_index = true; 1401 feature_flags_.emulate_primitive_restart_fixed_index = true;
1409 } 1402 }
1410 1403
1411 feature_flags_.angle_robust_client_memory = 1404 feature_flags_.angle_robust_client_memory =
1412 extensions.Contains("GL_ANGLE_robust_client_memory"); 1405 extensions.Contains("GL_ANGLE_robust_client_memory");
1413 } 1406 }
1414 1407
1415 bool FeatureInfo::IsES3Capable() const { 1408 bool FeatureInfo::IsES3Capable() const {
1416 if (!enable_unsafe_es3_apis_switch_)
1417 return false;
1418 if (workarounds_.disable_texture_storage) 1409 if (workarounds_.disable_texture_storage)
1419 return false; 1410 return false;
1420 if (gl_version_info_) 1411 if (gl_version_info_)
1421 return gl_version_info_->is_es3_capable; 1412 return gl_version_info_->is_es3_capable;
1422 return false; 1413 return false;
1423 } 1414 }
1424 1415
1425 void FeatureInfo::EnableES3Validators() { 1416 void FeatureInfo::EnableES3Validators() {
1426 DCHECK(IsES3Capable()); 1417 DCHECK(IsES3Capable());
1427 validators_.UpdateValuesES3(); 1418 validators_.UpdateValuesES3();
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 if (pos == std::string::npos) { 1545 if (pos == std::string::npos) {
1555 extensions_ += (extensions_.empty() ? "" : " ") + str; 1546 extensions_ += (extensions_.empty() ? "" : " ") + str;
1556 } 1547 }
1557 } 1548 }
1558 1549
1559 FeatureInfo::~FeatureInfo() { 1550 FeatureInfo::~FeatureInfo() {
1560 } 1551 }
1561 1552
1562 } // namespace gles2 1553 } // namespace gles2
1563 } // namespace gpu 1554 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698