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 <limits.h> | 7 #include <limits.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 3184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3195 resources.MaxCallStackDepth = 256; | 3195 resources.MaxCallStackDepth = 256; |
3196 resources.MaxDualSourceDrawBuffers = group_->max_dual_source_draw_buffers(); | 3196 resources.MaxDualSourceDrawBuffers = group_->max_dual_source_draw_buffers(); |
3197 | 3197 |
3198 GLint range[2] = { 0, 0 }; | 3198 GLint range[2] = { 0, 0 }; |
3199 GLint precision = 0; | 3199 GLint precision = 0; |
3200 GetShaderPrecisionFormatImpl(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, | 3200 GetShaderPrecisionFormatImpl(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, |
3201 range, &precision); | 3201 range, &precision); |
3202 resources.FragmentPrecisionHigh = | 3202 resources.FragmentPrecisionHigh = |
3203 PrecisionMeetsSpecForHighpFloat(range[0], range[1], precision); | 3203 PrecisionMeetsSpecForHighpFloat(range[0], range[1], precision); |
3204 | 3204 |
3205 if (feature_info_->IsWebGLContext()) { | |
3206 resources.OES_standard_derivatives = derivatives_explicitly_enabled_; | |
3207 resources.EXT_frag_depth = frag_depth_explicitly_enabled_; | |
3208 resources.EXT_draw_buffers = draw_buffers_explicitly_enabled_; | |
3209 if (!draw_buffers_explicitly_enabled_) | |
3210 resources.MaxDrawBuffers = 1; | |
3211 resources.EXT_shader_texture_lod = shader_texture_lod_explicitly_enabled_; | |
3212 resources.NV_draw_buffers = | |
3213 draw_buffers_explicitly_enabled_ && features().nv_draw_buffers; | |
3214 } else { | |
3215 resources.OES_standard_derivatives = | |
3216 features().oes_standard_derivatives ? 1 : 0; | |
3217 resources.ARB_texture_rectangle = | |
3218 features().arb_texture_rectangle ? 1 : 0; | |
3219 resources.OES_EGL_image_external = | |
3220 features().oes_egl_image_external ? 1 : 0; | |
3221 resources.EXT_draw_buffers = | |
3222 features().ext_draw_buffers ? 1 : 0; | |
3223 resources.EXT_frag_depth = | |
3224 features().ext_frag_depth ? 1 : 0; | |
3225 resources.EXT_shader_texture_lod = | |
3226 features().ext_shader_texture_lod ? 1 : 0; | |
3227 resources.NV_draw_buffers = | |
3228 features().nv_draw_buffers ? 1 : 0; | |
3229 resources.EXT_blend_func_extended = | |
3230 features().ext_blend_func_extended ? 1 : 0; | |
3231 } | |
3232 | |
3233 ShShaderSpec shader_spec; | 3205 ShShaderSpec shader_spec; |
3234 switch (feature_info_->context_type()) { | 3206 switch (feature_info_->context_type()) { |
3235 case CONTEXT_TYPE_WEBGL1: | 3207 case CONTEXT_TYPE_WEBGL1: |
3236 shader_spec = SH_WEBGL_SPEC; | 3208 shader_spec = SH_WEBGL_SPEC; |
| 3209 resources.OES_standard_derivatives = derivatives_explicitly_enabled_; |
| 3210 resources.EXT_frag_depth = frag_depth_explicitly_enabled_; |
| 3211 resources.EXT_draw_buffers = draw_buffers_explicitly_enabled_; |
| 3212 if (!draw_buffers_explicitly_enabled_) |
| 3213 resources.MaxDrawBuffers = 1; |
| 3214 resources.EXT_shader_texture_lod = shader_texture_lod_explicitly_enabled_; |
| 3215 resources.NV_draw_buffers = |
| 3216 draw_buffers_explicitly_enabled_ && features().nv_draw_buffers; |
3237 break; | 3217 break; |
3238 case CONTEXT_TYPE_WEBGL2: | 3218 case CONTEXT_TYPE_WEBGL2: |
3239 shader_spec = SH_WEBGL2_SPEC; | 3219 shader_spec = SH_WEBGL2_SPEC; |
3240 break; | 3220 break; |
3241 case CONTEXT_TYPE_OPENGLES2: | 3221 case CONTEXT_TYPE_OPENGLES2: |
3242 shader_spec = SH_GLES2_SPEC; | 3222 shader_spec = SH_GLES2_SPEC; |
| 3223 resources.OES_standard_derivatives = |
| 3224 features().oes_standard_derivatives ? 1 : 0; |
| 3225 resources.ARB_texture_rectangle = |
| 3226 features().arb_texture_rectangle ? 1 : 0; |
| 3227 resources.OES_EGL_image_external = |
| 3228 features().oes_egl_image_external ? 1 : 0; |
| 3229 resources.EXT_draw_buffers = |
| 3230 features().ext_draw_buffers ? 1 : 0; |
| 3231 resources.EXT_frag_depth = |
| 3232 features().ext_frag_depth ? 1 : 0; |
| 3233 resources.EXT_shader_texture_lod = |
| 3234 features().ext_shader_texture_lod ? 1 : 0; |
| 3235 resources.NV_draw_buffers = |
| 3236 features().nv_draw_buffers ? 1 : 0; |
| 3237 resources.EXT_blend_func_extended = |
| 3238 features().ext_blend_func_extended ? 1 : 0; |
3243 break; | 3239 break; |
3244 case CONTEXT_TYPE_OPENGLES3: | 3240 case CONTEXT_TYPE_OPENGLES3: |
3245 shader_spec = SH_GLES3_SPEC; | 3241 shader_spec = SH_GLES3_SPEC; |
| 3242 resources.ARB_texture_rectangle = |
| 3243 features().arb_texture_rectangle ? 1 : 0; |
| 3244 resources.OES_EGL_image_external = |
| 3245 features().oes_egl_image_external ? 1 : 0; |
| 3246 resources.EXT_blend_func_extended = |
| 3247 features().ext_blend_func_extended ? 1 : 0; |
3246 break; | 3248 break; |
3247 default: | 3249 default: |
3248 NOTREACHED(); | 3250 NOTREACHED(); |
3249 shader_spec = SH_GLES2_SPEC; | 3251 shader_spec = SH_GLES2_SPEC; |
3250 break; | 3252 break; |
3251 } | 3253 } |
3252 | 3254 |
3253 if (((shader_spec == SH_WEBGL_SPEC || shader_spec == SH_WEBGL2_SPEC) && | 3255 if (((shader_spec == SH_WEBGL_SPEC || shader_spec == SH_WEBGL2_SPEC) && |
3254 features().enable_shader_name_hashing) || | 3256 features().enable_shader_name_hashing) || |
3255 force_shader_name_hashing_for_test) | 3257 force_shader_name_hashing_for_test) |
(...skipping 6722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9978 case GL_VENDOR: | 9980 case GL_VENDOR: |
9979 // Return the unmasked VENDOR/RENDERER string for WebGL contexts. | 9981 // Return the unmasked VENDOR/RENDERER string for WebGL contexts. |
9980 // They are used by WEBGL_debug_renderer_info. | 9982 // They are used by WEBGL_debug_renderer_info. |
9981 if (!feature_info_->IsWebGLContext()) | 9983 if (!feature_info_->IsWebGLContext()) |
9982 str = "Chromium"; | 9984 str = "Chromium"; |
9983 else | 9985 else |
9984 str = reinterpret_cast<const char*>(glGetString(name)); | 9986 str = reinterpret_cast<const char*>(glGetString(name)); |
9985 break; | 9987 break; |
9986 case GL_EXTENSIONS: | 9988 case GL_EXTENSIONS: |
9987 { | 9989 { |
9988 // For WebGL contexts, strip out the OES derivatives and | 9990 // For WebGL contexts, strip out shader extensions if they have not |
9989 // EXT frag depth extensions if they have not been enabled. | 9991 // been enabled on WebGL1 or no longer exist (become core) in WebGL2. |
9990 if (feature_info_->IsWebGLContext()) { | 9992 if (feature_info_->IsWebGLContext()) { |
9991 extensions = feature_info_->extensions(); | 9993 extensions = feature_info_->extensions(); |
9992 if (!derivatives_explicitly_enabled_) { | 9994 if (!derivatives_explicitly_enabled_) { |
9993 size_t offset = extensions.find(kOESDerivativeExtension); | 9995 size_t offset = extensions.find(kOESDerivativeExtension); |
9994 if (std::string::npos != offset) { | 9996 if (std::string::npos != offset) { |
9995 extensions.replace(offset, arraysize(kOESDerivativeExtension), | 9997 extensions.replace(offset, arraysize(kOESDerivativeExtension), |
9996 std::string()); | 9998 std::string()); |
9997 } | 9999 } |
9998 } | 10000 } |
9999 if (!frag_depth_explicitly_enabled_) { | 10001 if (!frag_depth_explicitly_enabled_) { |
(...skipping 2323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12323 } | 12325 } |
12324 std::string feature_str; | 12326 std::string feature_str; |
12325 if (!bucket->GetAsString(&feature_str)) { | 12327 if (!bucket->GetAsString(&feature_str)) { |
12326 return error::kInvalidArguments; | 12328 return error::kInvalidArguments; |
12327 } | 12329 } |
12328 | 12330 |
12329 bool desire_standard_derivatives = false; | 12331 bool desire_standard_derivatives = false; |
12330 bool desire_frag_depth = false; | 12332 bool desire_frag_depth = false; |
12331 bool desire_draw_buffers = false; | 12333 bool desire_draw_buffers = false; |
12332 bool desire_shader_texture_lod = false; | 12334 bool desire_shader_texture_lod = false; |
12333 if (feature_info_->IsWebGLContext()) { | 12335 if (feature_info_->context_type() == CONTEXT_TYPE_WEBGL1) { |
12334 desire_standard_derivatives = | 12336 desire_standard_derivatives = |
12335 feature_str.find("GL_OES_standard_derivatives") != std::string::npos; | 12337 feature_str.find("GL_OES_standard_derivatives") != std::string::npos; |
12336 desire_frag_depth = | 12338 desire_frag_depth = |
12337 feature_str.find("GL_EXT_frag_depth") != std::string::npos; | 12339 feature_str.find("GL_EXT_frag_depth") != std::string::npos; |
12338 desire_draw_buffers = | 12340 desire_draw_buffers = |
12339 feature_str.find("GL_EXT_draw_buffers") != std::string::npos; | 12341 feature_str.find("GL_EXT_draw_buffers") != std::string::npos; |
12340 desire_shader_texture_lod = | 12342 desire_shader_texture_lod = |
12341 feature_str.find("GL_EXT_shader_texture_lod") != std::string::npos; | 12343 feature_str.find("GL_EXT_shader_texture_lod") != std::string::npos; |
12342 } | 12344 } |
12343 | 12345 |
(...skipping 3230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15574 } | 15576 } |
15575 | 15577 |
15576 // Include the auto-generated part of this file. We split this because it means | 15578 // Include the auto-generated part of this file. We split this because it means |
15577 // we can easily edit the non-auto generated parts right here in this file | 15579 // we can easily edit the non-auto generated parts right here in this file |
15578 // instead of having to edit some template or the code generator. | 15580 // instead of having to edit some template or the code generator. |
15579 #include "base/macros.h" | 15581 #include "base/macros.h" |
15580 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 15582 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
15581 | 15583 |
15582 } // namespace gles2 | 15584 } // namespace gles2 |
15583 } // namespace gpu | 15585 } // namespace gpu |
OLD | NEW |