Chromium Code Reviews| Index: gpu/command_buffer/service/gles2_cmd_decoder.cc |
| diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
| index 9a37f370040bcd3f00bf34d482ed13ae5fd67cb2..dc2d8413a5fd217b44264a65b3b0280e4433ee9d 100644 |
| --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc |
| +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
| @@ -841,6 +841,10 @@ class GLES2DecoderImpl : public GLES2Decoder, |
| return true; |
| } |
| + bool IsWebGLContext() const { |
| + return webgl_version_ == 1 || webgl_version_ == 2; |
| + } |
| + |
| bool IsOffscreenBufferMultisampled() const { |
| return offscreen_target_samples_ > 1; |
| } |
| @@ -1945,12 +1949,17 @@ class GLES2DecoderImpl : public GLES2Decoder, |
| bool reset_by_robustness_extension_; |
| bool supports_post_sub_buffer_; |
| + // Indicates whether this is a context for WebGL1, WebGL2, or others. |
| + // 0: other types |
| + // 1: WebGL 1 |
| + // 2: WebGL 2 |
| + unsigned webgl_version_; |
| + |
| // These flags are used to override the state of the shared feature_info_ |
| // member. Because the same FeatureInfo instance may be shared among many |
| // contexts, the assumptions on the availablity of extensions in WebGL |
| // contexts may be broken. These flags override the shared state to preserve |
| // WebGL semantics. |
| - bool force_webgl_glsl_validation_; |
| bool derivatives_explicitly_enabled_; |
| bool frag_depth_explicitly_enabled_; |
| bool draw_buffers_explicitly_enabled_; |
| @@ -2489,7 +2498,7 @@ GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group) |
| context_was_lost_(false), |
| reset_by_robustness_extension_(false), |
| supports_post_sub_buffer_(false), |
| - force_webgl_glsl_validation_(false), |
| + webgl_version_(0), |
| derivatives_explicitly_enabled_(false), |
| frag_depth_explicitly_enabled_(false), |
| draw_buffers_explicitly_enabled_(false), |
| @@ -2546,6 +2555,7 @@ bool GLES2DecoderImpl::Initialize( |
| ContextCreationAttribHelper attrib_parser; |
| if (!attrib_parser.Parse(attribs)) |
| return false; |
| + webgl_version_ = attrib_parser.webgl_version; |
| surfaceless_ = surface->IsSurfaceless() && !offscreen; |
| @@ -2587,7 +2597,12 @@ bool GLES2DecoderImpl::Initialize( |
| return false; |
| } |
| - if (!group_->Initialize(this, disallowed_features)) { |
| + disallowed_features_ = disallowed_features; |
| + if (webgl_version_ == 1) { |
| + disallowed_features_.npot_support = true; |
| + } |
| + |
| + if (!group_->Initialize(this, disallowed_features_)) { |
| LOG(ERROR) << "GpuScheduler::InitializeCommon failed because group " |
| << "failed to initialize."; |
| group_ = NULL; // Must not destroy ContextGroup if it is not initialized. |
| @@ -2596,14 +2611,11 @@ bool GLES2DecoderImpl::Initialize( |
| } |
| CHECK_GL_ERROR(); |
| - if (attrib_parser.es3_context_required && |
|
piman
2015/06/08 21:40:21
Don't we want to keep this? I assume we don't want
Zhenyao Mo
2015/06/08 22:23:22
I am OK with only exposing ES3 for WebGL 2 for now
|
| - feature_info_->IsES3Capable()) { |
| + if (feature_info_->IsES3Capable()) { |
| feature_info_->EnableES3Validators(); |
| set_unsafe_es3_apis_enabled(true); |
| } |
| - disallowed_features_ = disallowed_features; |
| - |
| state_.attrib_values.resize(group_->max_vertex_attribs()); |
| vertex_array_manager_.reset(new VertexArrayManager()); |
| @@ -3130,7 +3142,7 @@ bool GLES2DecoderImpl::InitializeShaderTranslator() { |
| resources.FragmentPrecisionHigh = |
| PrecisionMeetsSpecForHighpFloat(range[0], range[1], precision); |
| - if (force_webgl_glsl_validation_) { |
| + if (IsWebGLContext()) { |
| resources.OES_standard_derivatives = derivatives_explicitly_enabled_; |
| resources.EXT_frag_depth = frag_depth_explicitly_enabled_; |
| resources.EXT_draw_buffers = draw_buffers_explicitly_enabled_; |
| @@ -3157,8 +3169,8 @@ bool GLES2DecoderImpl::InitializeShaderTranslator() { |
| } |
| ShShaderSpec shader_spec; |
| - if (force_webgl_glsl_validation_) { |
| - shader_spec = unsafe_es3_apis_enabled() ? SH_WEBGL2_SPEC : SH_WEBGL_SPEC; |
| + if (IsWebGLContext()) { |
| + shader_spec = webgl_version_ == 2 ? SH_WEBGL2_SPEC : SH_WEBGL_SPEC; |
| } else { |
| shader_spec = unsafe_es3_apis_enabled() ? SH_GLES3_SPEC : SH_GLES2_SPEC; |
| } |
| @@ -8782,16 +8794,22 @@ error::Error GLES2DecoderImpl::HandleGetString(uint32 immediate_data_size, |
| std::string extensions; |
| switch (name) { |
| case GL_VERSION: |
| - str = "OpenGL ES 2.0 Chromium"; |
| + if (unsafe_es3_apis_enabled()) |
| + str = "OpenGL ES 3.0 Chromium"; |
| + else |
| + str = "OpenGL ES 2.0 Chromium"; |
| break; |
| case GL_SHADING_LANGUAGE_VERSION: |
| - str = "OpenGL ES GLSL ES 1.0 Chromium"; |
| + if (unsafe_es3_apis_enabled()) |
| + str = "OpenGL ES GLSL ES 3.0 Chromium"; |
| + else |
| + str = "OpenGL ES GLSL ES 1.0 Chromium"; |
| break; |
| case GL_RENDERER: |
| case GL_VENDOR: |
| // Return the unmasked VENDOR/RENDERER string for WebGL contexts. |
| // They are used by WEBGL_debug_renderer_info. |
| - if (!force_webgl_glsl_validation_) |
| + if (!IsWebGLContext()) |
| str = "Chromium"; |
| else |
| str = reinterpret_cast<const char*>(glGetString(name)); |
| @@ -8800,7 +8818,7 @@ error::Error GLES2DecoderImpl::HandleGetString(uint32 immediate_data_size, |
| { |
| // For WebGL contexts, strip out the OES derivatives and |
| // EXT frag depth extensions if they have not been enabled. |
| - if (force_webgl_glsl_validation_) { |
| + if (IsWebGLContext()) { |
| extensions = feature_info_->extensions(); |
| if (!derivatives_explicitly_enabled_) { |
| size_t offset = extensions.find(kOESDerivativeExtension); |
| @@ -11086,9 +11104,6 @@ error::Error GLES2DecoderImpl::HandleEnableFeatureCHROMIUM( |
| // needs to be done it seems like refactoring for one to one of those |
| // methods is a very low priority. |
| const_cast<Validators*>(validators_)->vertex_attrib_type.AddValue(GL_FIXED); |
| - } else if (feature_str.compare("webgl_enable_glsl_webgl_validation") == 0) { |
| - force_webgl_glsl_validation_ = true; |
| - InitializeShaderTranslator(); |
|
Zhenyao Mo
2015/06/07 18:35:07
This second InitializeShaderTranslator() call per
|
| } else { |
| return error::kNoError; |
| } |
| @@ -11124,13 +11139,11 @@ error::Error GLES2DecoderImpl::HandleRequestExtensionCHROMIUM( |
| return error::kInvalidArguments; |
| } |
| - bool desire_webgl_glsl_validation = |
| - feature_str.find("GL_CHROMIUM_webglsl") != std::string::npos; |
|
Zhenyao Mo
2015/06/07 18:35:07
"GL_CHROMIUM_webglsl" was not the correct feature
|
| bool desire_standard_derivatives = false; |
| bool desire_frag_depth = false; |
| bool desire_draw_buffers = false; |
| bool desire_shader_texture_lod = false; |
| - if (force_webgl_glsl_validation_) { |
| + if (IsWebGLContext()) { |
| desire_standard_derivatives = |
| feature_str.find("GL_OES_standard_derivatives") != std::string::npos; |
| desire_frag_depth = |
| @@ -11141,11 +11154,10 @@ error::Error GLES2DecoderImpl::HandleRequestExtensionCHROMIUM( |
| feature_str.find("GL_EXT_shader_texture_lod") != std::string::npos; |
| } |
| - if (desire_webgl_glsl_validation != force_webgl_glsl_validation_ || |
| - desire_standard_derivatives != derivatives_explicitly_enabled_ || |
| + if (desire_standard_derivatives != derivatives_explicitly_enabled_ || |
| desire_frag_depth != frag_depth_explicitly_enabled_ || |
| - desire_draw_buffers != draw_buffers_explicitly_enabled_) { |
| - force_webgl_glsl_validation_ |= desire_webgl_glsl_validation; |
| + desire_draw_buffers != draw_buffers_explicitly_enabled_ || |
| + desire_shader_texture_lod != shader_texture_lod_explicitly_enabled_) { |
|
Zhenyao Mo
2015/06/07 18:35:07
This is apparently a bug, see above the reasoning.
|
| derivatives_explicitly_enabled_ |= desire_standard_derivatives; |
| frag_depth_explicitly_enabled_ |= desire_frag_depth; |
| draw_buffers_explicitly_enabled_ |= desire_draw_buffers; |