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/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 } | 861 } |
862 | 862 |
863 bool EnsureGPUMemoryAvailable(size_t estimated_size) { | 863 bool EnsureGPUMemoryAvailable(size_t estimated_size) { |
864 MemoryTracker* tracker = memory_tracker(); | 864 MemoryTracker* tracker = memory_tracker(); |
865 if (tracker) { | 865 if (tracker) { |
866 return tracker->EnsureGPUMemoryAvailable(estimated_size); | 866 return tracker->EnsureGPUMemoryAvailable(estimated_size); |
867 } | 867 } |
868 return true; | 868 return true; |
869 } | 869 } |
870 | 870 |
| 871 bool IsWebGLContext() const { |
| 872 return webgl_version_ == 1 || webgl_version_ == 2; |
| 873 } |
| 874 |
871 bool IsOffscreenBufferMultisampled() const { | 875 bool IsOffscreenBufferMultisampled() const { |
872 return offscreen_target_samples_ > 1; | 876 return offscreen_target_samples_ > 1; |
873 } | 877 } |
874 | 878 |
875 // Creates a Texture for the given texture. | 879 // Creates a Texture for the given texture. |
876 TextureRef* CreateTexture( | 880 TextureRef* CreateTexture( |
877 GLuint client_id, GLuint service_id) { | 881 GLuint client_id, GLuint service_id) { |
878 return texture_manager()->CreateTexture(client_id, service_id); | 882 return texture_manager()->CreateTexture(client_id, service_id); |
879 } | 883 } |
880 | 884 |
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1965 | 1969 |
1966 // Number of commands remaining to be processed in DoCommands(). | 1970 // Number of commands remaining to be processed in DoCommands(). |
1967 int commands_to_process_; | 1971 int commands_to_process_; |
1968 | 1972 |
1969 bool has_robustness_extension_; | 1973 bool has_robustness_extension_; |
1970 error::ContextLostReason context_lost_reason_; | 1974 error::ContextLostReason context_lost_reason_; |
1971 bool context_was_lost_; | 1975 bool context_was_lost_; |
1972 bool reset_by_robustness_extension_; | 1976 bool reset_by_robustness_extension_; |
1973 bool supports_post_sub_buffer_; | 1977 bool supports_post_sub_buffer_; |
1974 | 1978 |
| 1979 // Indicates whether this is a context for WebGL1, WebGL2, or others. |
| 1980 // 0: other types |
| 1981 // 1: WebGL 1 |
| 1982 // 2: WebGL 2 |
| 1983 unsigned webgl_version_; |
| 1984 |
1975 // These flags are used to override the state of the shared feature_info_ | 1985 // These flags are used to override the state of the shared feature_info_ |
1976 // member. Because the same FeatureInfo instance may be shared among many | 1986 // member. Because the same FeatureInfo instance may be shared among many |
1977 // contexts, the assumptions on the availablity of extensions in WebGL | 1987 // contexts, the assumptions on the availablity of extensions in WebGL |
1978 // contexts may be broken. These flags override the shared state to preserve | 1988 // contexts may be broken. These flags override the shared state to preserve |
1979 // WebGL semantics. | 1989 // WebGL semantics. |
1980 bool force_webgl_glsl_validation_; | |
1981 bool derivatives_explicitly_enabled_; | 1990 bool derivatives_explicitly_enabled_; |
1982 bool frag_depth_explicitly_enabled_; | 1991 bool frag_depth_explicitly_enabled_; |
1983 bool draw_buffers_explicitly_enabled_; | 1992 bool draw_buffers_explicitly_enabled_; |
1984 bool shader_texture_lod_explicitly_enabled_; | 1993 bool shader_texture_lod_explicitly_enabled_; |
1985 | 1994 |
1986 bool compile_shader_always_succeeds_; | 1995 bool compile_shader_always_succeeds_; |
1987 | 1996 |
1988 // An optional behaviour to lose the context and group when OOM. | 1997 // An optional behaviour to lose the context and group when OOM. |
1989 bool lose_context_when_out_of_memory_; | 1998 bool lose_context_when_out_of_memory_; |
1990 | 1999 |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2509 current_decoder_error_(error::kNoError), | 2518 current_decoder_error_(error::kNoError), |
2510 use_shader_translator_(true), | 2519 use_shader_translator_(true), |
2511 validators_(group_->feature_info()->validators()), | 2520 validators_(group_->feature_info()->validators()), |
2512 feature_info_(group_->feature_info()), | 2521 feature_info_(group_->feature_info()), |
2513 frame_number_(0), | 2522 frame_number_(0), |
2514 has_robustness_extension_(false), | 2523 has_robustness_extension_(false), |
2515 context_lost_reason_(error::kUnknown), | 2524 context_lost_reason_(error::kUnknown), |
2516 context_was_lost_(false), | 2525 context_was_lost_(false), |
2517 reset_by_robustness_extension_(false), | 2526 reset_by_robustness_extension_(false), |
2518 supports_post_sub_buffer_(false), | 2527 supports_post_sub_buffer_(false), |
2519 force_webgl_glsl_validation_(false), | 2528 webgl_version_(0), |
2520 derivatives_explicitly_enabled_(false), | 2529 derivatives_explicitly_enabled_(false), |
2521 frag_depth_explicitly_enabled_(false), | 2530 frag_depth_explicitly_enabled_(false), |
2522 draw_buffers_explicitly_enabled_(false), | 2531 draw_buffers_explicitly_enabled_(false), |
2523 shader_texture_lod_explicitly_enabled_(false), | 2532 shader_texture_lod_explicitly_enabled_(false), |
2524 compile_shader_always_succeeds_(false), | 2533 compile_shader_always_succeeds_(false), |
2525 lose_context_when_out_of_memory_(false), | 2534 lose_context_when_out_of_memory_(false), |
2526 service_logging_(base::CommandLine::ForCurrentProcess()->HasSwitch( | 2535 service_logging_(base::CommandLine::ForCurrentProcess()->HasSwitch( |
2527 switches::kEnableGPUServiceLoggingGPU)), | 2536 switches::kEnableGPUServiceLoggingGPU)), |
2528 viewport_max_width_(0), | 2537 viewport_max_width_(0), |
2529 viewport_max_height_(0), | 2538 viewport_max_height_(0), |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2566 const DisallowedFeatures& disallowed_features, | 2575 const DisallowedFeatures& disallowed_features, |
2567 const std::vector<int32>& attribs) { | 2576 const std::vector<int32>& attribs) { |
2568 TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize"); | 2577 TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize"); |
2569 DCHECK(context->IsCurrent(surface.get())); | 2578 DCHECK(context->IsCurrent(surface.get())); |
2570 DCHECK(!context_.get()); | 2579 DCHECK(!context_.get()); |
2571 DCHECK(!offscreen || !offscreen_size.IsEmpty()); | 2580 DCHECK(!offscreen || !offscreen_size.IsEmpty()); |
2572 | 2581 |
2573 ContextCreationAttribHelper attrib_parser; | 2582 ContextCreationAttribHelper attrib_parser; |
2574 if (!attrib_parser.Parse(attribs)) | 2583 if (!attrib_parser.Parse(attribs)) |
2575 return false; | 2584 return false; |
| 2585 webgl_version_ = attrib_parser.webgl_version; |
2576 | 2586 |
2577 surfaceless_ = surface->IsSurfaceless() && !offscreen; | 2587 surfaceless_ = surface->IsSurfaceless() && !offscreen; |
2578 | 2588 |
2579 set_initialized(); | 2589 set_initialized(); |
2580 gpu_state_tracer_ = GPUStateTracer::Create(&state_); | 2590 gpu_state_tracer_ = GPUStateTracer::Create(&state_); |
2581 | 2591 |
2582 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 2592 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
2583 switches::kEnableGPUDebugging)) { | 2593 switches::kEnableGPUDebugging)) { |
2584 set_debug(true); | 2594 set_debug(true); |
2585 } | 2595 } |
(...skipping 21 matching lines...) Expand all Loading... |
2607 | 2617 |
2608 // If the failIfMajorPerformanceCaveat context creation attribute was true | 2618 // If the failIfMajorPerformanceCaveat context creation attribute was true |
2609 // and we are using a software renderer, fail. | 2619 // and we are using a software renderer, fail. |
2610 if (attrib_parser.fail_if_major_perf_caveat && | 2620 if (attrib_parser.fail_if_major_perf_caveat && |
2611 feature_info_->feature_flags().is_swiftshader) { | 2621 feature_info_->feature_flags().is_swiftshader) { |
2612 group_ = NULL; // Must not destroy ContextGroup if it is not initialized. | 2622 group_ = NULL; // Must not destroy ContextGroup if it is not initialized. |
2613 Destroy(true); | 2623 Destroy(true); |
2614 return false; | 2624 return false; |
2615 } | 2625 } |
2616 | 2626 |
2617 if (!group_->Initialize(this, disallowed_features)) { | 2627 disallowed_features_ = disallowed_features; |
2618 LOG(ERROR) << "GpuScheduler::InitializeCommon failed because group " | 2628 if (webgl_version_ == 1) { |
2619 << "failed to initialize."; | 2629 disallowed_features_.npot_support = true; |
| 2630 } |
| 2631 |
| 2632 if (!group_->Initialize(this, |
| 2633 ContextGroup::GetContextType(webgl_version_), |
| 2634 disallowed_features_)) { |
2620 group_ = NULL; // Must not destroy ContextGroup if it is not initialized. | 2635 group_ = NULL; // Must not destroy ContextGroup if it is not initialized. |
2621 Destroy(true); | 2636 Destroy(true); |
2622 return false; | 2637 return false; |
2623 } | 2638 } |
2624 CHECK_GL_ERROR(); | 2639 CHECK_GL_ERROR(); |
2625 | 2640 |
2626 if (attrib_parser.es3_context_required && | 2641 if (webgl_version_ == 2) { |
2627 feature_info_->IsES3Capable()) { | 2642 if (!feature_info_->IsES3Capable()) { |
| 2643 LOG(ERROR) << "Underlying driver does not support ES3."; |
| 2644 Destroy(true); |
| 2645 return false; |
| 2646 } |
2628 feature_info_->EnableES3Validators(); | 2647 feature_info_->EnableES3Validators(); |
2629 set_unsafe_es3_apis_enabled(true); | 2648 set_unsafe_es3_apis_enabled(true); |
2630 } | 2649 } |
2631 | 2650 |
2632 disallowed_features_ = disallowed_features; | |
2633 | |
2634 state_.attrib_values.resize(group_->max_vertex_attribs()); | 2651 state_.attrib_values.resize(group_->max_vertex_attribs()); |
2635 vertex_array_manager_.reset(new VertexArrayManager()); | 2652 vertex_array_manager_.reset(new VertexArrayManager()); |
2636 | 2653 |
2637 GLuint default_vertex_attrib_service_id = 0; | 2654 GLuint default_vertex_attrib_service_id = 0; |
2638 if (features().native_vertex_array_object) { | 2655 if (features().native_vertex_array_object) { |
2639 glGenVertexArraysOES(1, &default_vertex_attrib_service_id); | 2656 glGenVertexArraysOES(1, &default_vertex_attrib_service_id); |
2640 glBindVertexArrayOES(default_vertex_attrib_service_id); | 2657 glBindVertexArrayOES(default_vertex_attrib_service_id); |
2641 } | 2658 } |
2642 | 2659 |
2643 state_.default_vertex_attrib_manager = | 2660 state_.default_vertex_attrib_manager = |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3150 resources.MaxExpressionComplexity = 256; | 3167 resources.MaxExpressionComplexity = 256; |
3151 resources.MaxCallStackDepth = 256; | 3168 resources.MaxCallStackDepth = 256; |
3152 | 3169 |
3153 GLint range[2] = { 0, 0 }; | 3170 GLint range[2] = { 0, 0 }; |
3154 GLint precision = 0; | 3171 GLint precision = 0; |
3155 GetShaderPrecisionFormatImpl(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, | 3172 GetShaderPrecisionFormatImpl(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, |
3156 range, &precision); | 3173 range, &precision); |
3157 resources.FragmentPrecisionHigh = | 3174 resources.FragmentPrecisionHigh = |
3158 PrecisionMeetsSpecForHighpFloat(range[0], range[1], precision); | 3175 PrecisionMeetsSpecForHighpFloat(range[0], range[1], precision); |
3159 | 3176 |
3160 if (force_webgl_glsl_validation_) { | 3177 if (IsWebGLContext()) { |
3161 resources.OES_standard_derivatives = derivatives_explicitly_enabled_; | 3178 resources.OES_standard_derivatives = derivatives_explicitly_enabled_; |
3162 resources.EXT_frag_depth = frag_depth_explicitly_enabled_; | 3179 resources.EXT_frag_depth = frag_depth_explicitly_enabled_; |
3163 resources.EXT_draw_buffers = draw_buffers_explicitly_enabled_; | 3180 resources.EXT_draw_buffers = draw_buffers_explicitly_enabled_; |
3164 if (!draw_buffers_explicitly_enabled_) | 3181 if (!draw_buffers_explicitly_enabled_) |
3165 resources.MaxDrawBuffers = 1; | 3182 resources.MaxDrawBuffers = 1; |
3166 resources.EXT_shader_texture_lod = shader_texture_lod_explicitly_enabled_; | 3183 resources.EXT_shader_texture_lod = shader_texture_lod_explicitly_enabled_; |
3167 resources.NV_draw_buffers = | 3184 resources.NV_draw_buffers = |
3168 draw_buffers_explicitly_enabled_ && features().nv_draw_buffers; | 3185 draw_buffers_explicitly_enabled_ && features().nv_draw_buffers; |
3169 } else { | 3186 } else { |
3170 resources.OES_standard_derivatives = | 3187 resources.OES_standard_derivatives = |
3171 features().oes_standard_derivatives ? 1 : 0; | 3188 features().oes_standard_derivatives ? 1 : 0; |
3172 resources.ARB_texture_rectangle = | 3189 resources.ARB_texture_rectangle = |
3173 features().arb_texture_rectangle ? 1 : 0; | 3190 features().arb_texture_rectangle ? 1 : 0; |
3174 resources.OES_EGL_image_external = | 3191 resources.OES_EGL_image_external = |
3175 features().oes_egl_image_external ? 1 : 0; | 3192 features().oes_egl_image_external ? 1 : 0; |
3176 resources.EXT_draw_buffers = | 3193 resources.EXT_draw_buffers = |
3177 features().ext_draw_buffers ? 1 : 0; | 3194 features().ext_draw_buffers ? 1 : 0; |
3178 resources.EXT_frag_depth = | 3195 resources.EXT_frag_depth = |
3179 features().ext_frag_depth ? 1 : 0; | 3196 features().ext_frag_depth ? 1 : 0; |
3180 resources.EXT_shader_texture_lod = | 3197 resources.EXT_shader_texture_lod = |
3181 features().ext_shader_texture_lod ? 1 : 0; | 3198 features().ext_shader_texture_lod ? 1 : 0; |
3182 resources.NV_draw_buffers = | 3199 resources.NV_draw_buffers = |
3183 features().nv_draw_buffers ? 1 : 0; | 3200 features().nv_draw_buffers ? 1 : 0; |
3184 } | 3201 } |
3185 | 3202 |
3186 ShShaderSpec shader_spec; | 3203 ShShaderSpec shader_spec; |
3187 if (force_webgl_glsl_validation_) { | 3204 if (IsWebGLContext()) { |
3188 shader_spec = unsafe_es3_apis_enabled() ? SH_WEBGL2_SPEC : SH_WEBGL_SPEC; | 3205 shader_spec = webgl_version_ == 2 ? SH_WEBGL2_SPEC : SH_WEBGL_SPEC; |
3189 } else { | 3206 } else { |
3190 shader_spec = unsafe_es3_apis_enabled() ? SH_GLES3_SPEC : SH_GLES2_SPEC; | 3207 shader_spec = unsafe_es3_apis_enabled() ? SH_GLES3_SPEC : SH_GLES2_SPEC; |
3191 } | 3208 } |
3192 | 3209 |
3193 if ((shader_spec == SH_WEBGL_SPEC || shader_spec == SH_WEBGL2_SPEC) && | 3210 if ((shader_spec == SH_WEBGL_SPEC || shader_spec == SH_WEBGL2_SPEC) && |
3194 features().enable_shader_name_hashing) | 3211 features().enable_shader_name_hashing) |
3195 resources.HashFunction = &CityHash64; | 3212 resources.HashFunction = &CityHash64; |
3196 else | 3213 else |
3197 resources.HashFunction = NULL; | 3214 resources.HashFunction = NULL; |
3198 ShaderTranslatorInterface::GlslImplementationType implementation_type = | 3215 ShaderTranslatorInterface::GlslImplementationType implementation_type = |
(...skipping 5598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8797 GLenum name = static_cast<GLenum>(c.name); | 8814 GLenum name = static_cast<GLenum>(c.name); |
8798 if (!validators_->string_type.IsValid(name)) { | 8815 if (!validators_->string_type.IsValid(name)) { |
8799 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetString", name, "name"); | 8816 LOCAL_SET_GL_ERROR_INVALID_ENUM("glGetString", name, "name"); |
8800 return error::kNoError; | 8817 return error::kNoError; |
8801 } | 8818 } |
8802 | 8819 |
8803 const char* str = nullptr; | 8820 const char* str = nullptr; |
8804 std::string extensions; | 8821 std::string extensions; |
8805 switch (name) { | 8822 switch (name) { |
8806 case GL_VERSION: | 8823 case GL_VERSION: |
8807 str = "OpenGL ES 2.0 Chromium"; | 8824 if (unsafe_es3_apis_enabled()) |
| 8825 str = "OpenGL ES 3.0 Chromium"; |
| 8826 else |
| 8827 str = "OpenGL ES 2.0 Chromium"; |
8808 break; | 8828 break; |
8809 case GL_SHADING_LANGUAGE_VERSION: | 8829 case GL_SHADING_LANGUAGE_VERSION: |
8810 str = "OpenGL ES GLSL ES 1.0 Chromium"; | 8830 if (unsafe_es3_apis_enabled()) |
| 8831 str = "OpenGL ES GLSL ES 3.0 Chromium"; |
| 8832 else |
| 8833 str = "OpenGL ES GLSL ES 1.0 Chromium"; |
8811 break; | 8834 break; |
8812 case GL_RENDERER: | 8835 case GL_RENDERER: |
8813 case GL_VENDOR: | 8836 case GL_VENDOR: |
8814 // Return the unmasked VENDOR/RENDERER string for WebGL contexts. | 8837 // Return the unmasked VENDOR/RENDERER string for WebGL contexts. |
8815 // They are used by WEBGL_debug_renderer_info. | 8838 // They are used by WEBGL_debug_renderer_info. |
8816 if (!force_webgl_glsl_validation_) | 8839 if (!IsWebGLContext()) |
8817 str = "Chromium"; | 8840 str = "Chromium"; |
8818 else | 8841 else |
8819 str = reinterpret_cast<const char*>(glGetString(name)); | 8842 str = reinterpret_cast<const char*>(glGetString(name)); |
8820 break; | 8843 break; |
8821 case GL_EXTENSIONS: | 8844 case GL_EXTENSIONS: |
8822 { | 8845 { |
8823 // For WebGL contexts, strip out the OES derivatives and | 8846 // For WebGL contexts, strip out the OES derivatives and |
8824 // EXT frag depth extensions if they have not been enabled. | 8847 // EXT frag depth extensions if they have not been enabled. |
8825 if (force_webgl_glsl_validation_) { | 8848 if (IsWebGLContext()) { |
8826 extensions = feature_info_->extensions(); | 8849 extensions = feature_info_->extensions(); |
8827 if (!derivatives_explicitly_enabled_) { | 8850 if (!derivatives_explicitly_enabled_) { |
8828 size_t offset = extensions.find(kOESDerivativeExtension); | 8851 size_t offset = extensions.find(kOESDerivativeExtension); |
8829 if (std::string::npos != offset) { | 8852 if (std::string::npos != offset) { |
8830 extensions.replace(offset, arraysize(kOESDerivativeExtension), | 8853 extensions.replace(offset, arraysize(kOESDerivativeExtension), |
8831 std::string()); | 8854 std::string()); |
8832 } | 8855 } |
8833 } | 8856 } |
8834 if (!frag_depth_explicitly_enabled_) { | 8857 if (!frag_depth_explicitly_enabled_) { |
8835 size_t offset = extensions.find(kEXTFragDepthExtension); | 8858 size_t offset = extensions.find(kEXTFragDepthExtension); |
(...skipping 2288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11124 // TODO(gman): decide how to remove the need for this const_cast. | 11147 // TODO(gman): decide how to remove the need for this const_cast. |
11125 // I could make validators_ non const but that seems bad as this is the only | 11148 // I could make validators_ non const but that seems bad as this is the only |
11126 // place it is needed. I could make some special friend class of validators | 11149 // place it is needed. I could make some special friend class of validators |
11127 // just to allow this to set them. That seems silly. I could refactor this | 11150 // just to allow this to set them. That seems silly. I could refactor this |
11128 // code to use the extension mechanism or the initialization attributes to | 11151 // code to use the extension mechanism or the initialization attributes to |
11129 // turn this feature on. Given that the only real point of this is to make | 11152 // turn this feature on. Given that the only real point of this is to make |
11130 // the conformance tests pass and given that there is lots of real work that | 11153 // the conformance tests pass and given that there is lots of real work that |
11131 // needs to be done it seems like refactoring for one to one of those | 11154 // needs to be done it seems like refactoring for one to one of those |
11132 // methods is a very low priority. | 11155 // methods is a very low priority. |
11133 const_cast<Validators*>(validators_)->vertex_attrib_type.AddValue(GL_FIXED); | 11156 const_cast<Validators*>(validators_)->vertex_attrib_type.AddValue(GL_FIXED); |
11134 } else if (feature_str.compare("webgl_enable_glsl_webgl_validation") == 0) { | |
11135 force_webgl_glsl_validation_ = true; | |
11136 InitializeShaderTranslator(); | |
11137 } else { | 11157 } else { |
11138 return error::kNoError; | 11158 return error::kNoError; |
11139 } | 11159 } |
11140 | 11160 |
11141 *result = 1; // true. | 11161 *result = 1; // true. |
11142 return error::kNoError; | 11162 return error::kNoError; |
11143 } | 11163 } |
11144 | 11164 |
11145 error::Error GLES2DecoderImpl::HandleGetRequestableExtensionsCHROMIUM( | 11165 error::Error GLES2DecoderImpl::HandleGetRequestableExtensionsCHROMIUM( |
11146 uint32 immediate_data_size, | 11166 uint32 immediate_data_size, |
(...skipping 15 matching lines...) Expand all Loading... |
11162 *static_cast<const gles2::cmds::RequestExtensionCHROMIUM*>(cmd_data); | 11182 *static_cast<const gles2::cmds::RequestExtensionCHROMIUM*>(cmd_data); |
11163 Bucket* bucket = GetBucket(c.bucket_id); | 11183 Bucket* bucket = GetBucket(c.bucket_id); |
11164 if (!bucket || bucket->size() == 0) { | 11184 if (!bucket || bucket->size() == 0) { |
11165 return error::kInvalidArguments; | 11185 return error::kInvalidArguments; |
11166 } | 11186 } |
11167 std::string feature_str; | 11187 std::string feature_str; |
11168 if (!bucket->GetAsString(&feature_str)) { | 11188 if (!bucket->GetAsString(&feature_str)) { |
11169 return error::kInvalidArguments; | 11189 return error::kInvalidArguments; |
11170 } | 11190 } |
11171 | 11191 |
11172 bool desire_webgl_glsl_validation = | |
11173 feature_str.find("GL_CHROMIUM_webglsl") != std::string::npos; | |
11174 bool desire_standard_derivatives = false; | 11192 bool desire_standard_derivatives = false; |
11175 bool desire_frag_depth = false; | 11193 bool desire_frag_depth = false; |
11176 bool desire_draw_buffers = false; | 11194 bool desire_draw_buffers = false; |
11177 bool desire_shader_texture_lod = false; | 11195 bool desire_shader_texture_lod = false; |
11178 if (force_webgl_glsl_validation_) { | 11196 if (IsWebGLContext()) { |
11179 desire_standard_derivatives = | 11197 desire_standard_derivatives = |
11180 feature_str.find("GL_OES_standard_derivatives") != std::string::npos; | 11198 feature_str.find("GL_OES_standard_derivatives") != std::string::npos; |
11181 desire_frag_depth = | 11199 desire_frag_depth = |
11182 feature_str.find("GL_EXT_frag_depth") != std::string::npos; | 11200 feature_str.find("GL_EXT_frag_depth") != std::string::npos; |
11183 desire_draw_buffers = | 11201 desire_draw_buffers = |
11184 feature_str.find("GL_EXT_draw_buffers") != std::string::npos; | 11202 feature_str.find("GL_EXT_draw_buffers") != std::string::npos; |
11185 desire_shader_texture_lod = | 11203 desire_shader_texture_lod = |
11186 feature_str.find("GL_EXT_shader_texture_lod") != std::string::npos; | 11204 feature_str.find("GL_EXT_shader_texture_lod") != std::string::npos; |
11187 } | 11205 } |
11188 | 11206 |
11189 if (desire_webgl_glsl_validation != force_webgl_glsl_validation_ || | 11207 if (desire_standard_derivatives != derivatives_explicitly_enabled_ || |
11190 desire_standard_derivatives != derivatives_explicitly_enabled_ || | |
11191 desire_frag_depth != frag_depth_explicitly_enabled_ || | 11208 desire_frag_depth != frag_depth_explicitly_enabled_ || |
11192 desire_draw_buffers != draw_buffers_explicitly_enabled_) { | 11209 desire_draw_buffers != draw_buffers_explicitly_enabled_ || |
11193 force_webgl_glsl_validation_ |= desire_webgl_glsl_validation; | 11210 desire_shader_texture_lod != shader_texture_lod_explicitly_enabled_) { |
11194 derivatives_explicitly_enabled_ |= desire_standard_derivatives; | 11211 derivatives_explicitly_enabled_ |= desire_standard_derivatives; |
11195 frag_depth_explicitly_enabled_ |= desire_frag_depth; | 11212 frag_depth_explicitly_enabled_ |= desire_frag_depth; |
11196 draw_buffers_explicitly_enabled_ |= desire_draw_buffers; | 11213 draw_buffers_explicitly_enabled_ |= desire_draw_buffers; |
11197 shader_texture_lod_explicitly_enabled_ |= desire_shader_texture_lod; | 11214 shader_texture_lod_explicitly_enabled_ |= desire_shader_texture_lod; |
11198 InitializeShaderTranslator(); | 11215 InitializeShaderTranslator(); |
11199 } | 11216 } |
11200 | 11217 |
11201 UpdateCapabilities(); | 11218 UpdateCapabilities(); |
11202 | 11219 |
11203 return error::kNoError; | 11220 return error::kNoError; |
(...skipping 2225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13429 } | 13446 } |
13430 } | 13447 } |
13431 | 13448 |
13432 // Include the auto-generated part of this file. We split this because it means | 13449 // Include the auto-generated part of this file. We split this because it means |
13433 // we can easily edit the non-auto generated parts right here in this file | 13450 // we can easily edit the non-auto generated parts right here in this file |
13434 // instead of having to edit some template or the code generator. | 13451 // instead of having to edit some template or the code generator. |
13435 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 13452 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
13436 | 13453 |
13437 } // namespace gles2 | 13454 } // namespace gles2 |
13438 } // namespace gpu | 13455 } // namespace gpu |
OLD | NEW |