| 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 3255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3266 shader_spec = webgl_version_ == 2 ? SH_WEBGL2_SPEC : SH_WEBGL_SPEC; | 3266 shader_spec = webgl_version_ == 2 ? SH_WEBGL2_SPEC : SH_WEBGL_SPEC; |
| 3267 } else { | 3267 } else { |
| 3268 shader_spec = unsafe_es3_apis_enabled() ? SH_GLES3_SPEC : SH_GLES2_SPEC; | 3268 shader_spec = unsafe_es3_apis_enabled() ? SH_GLES3_SPEC : SH_GLES2_SPEC; |
| 3269 } | 3269 } |
| 3270 | 3270 |
| 3271 if ((shader_spec == SH_WEBGL_SPEC || shader_spec == SH_WEBGL2_SPEC) && | 3271 if ((shader_spec == SH_WEBGL_SPEC || shader_spec == SH_WEBGL2_SPEC) && |
| 3272 features().enable_shader_name_hashing) | 3272 features().enable_shader_name_hashing) |
| 3273 resources.HashFunction = &CityHash64; | 3273 resources.HashFunction = &CityHash64; |
| 3274 else | 3274 else |
| 3275 resources.HashFunction = NULL; | 3275 resources.HashFunction = NULL; |
| 3276 ShaderTranslatorInterface::GlslImplementationType implementation_type = | 3276 |
| 3277 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 ? | |
| 3278 ShaderTranslatorInterface::kGlslES : ShaderTranslatorInterface::kGlsl; | |
| 3279 int driver_bug_workarounds = 0; | 3277 int driver_bug_workarounds = 0; |
| 3280 if (workarounds().needs_glsl_built_in_function_emulation) | 3278 if (workarounds().needs_glsl_built_in_function_emulation) |
| 3281 driver_bug_workarounds |= SH_EMULATE_BUILT_IN_FUNCTIONS; | 3279 driver_bug_workarounds |= SH_EMULATE_BUILT_IN_FUNCTIONS; |
| 3282 if (workarounds().init_gl_position_in_vertex_shader) | 3280 if (workarounds().init_gl_position_in_vertex_shader) |
| 3283 driver_bug_workarounds |= SH_INIT_GL_POSITION; | 3281 driver_bug_workarounds |= SH_INIT_GL_POSITION; |
| 3284 if (workarounds().unfold_short_circuit_as_ternary_operation) | 3282 if (workarounds().unfold_short_circuit_as_ternary_operation) |
| 3285 driver_bug_workarounds |= SH_UNFOLD_SHORT_CIRCUIT; | 3283 driver_bug_workarounds |= SH_UNFOLD_SHORT_CIRCUIT; |
| 3286 if (workarounds().init_varyings_without_static_use) | 3284 if (workarounds().init_varyings_without_static_use) |
| 3287 driver_bug_workarounds |= SH_INIT_VARYINGS_WITHOUT_STATIC_USE; | 3285 driver_bug_workarounds |= SH_INIT_VARYINGS_WITHOUT_STATIC_USE; |
| 3288 if (workarounds().unroll_for_loop_with_sampler_array_index) | 3286 if (workarounds().unroll_for_loop_with_sampler_array_index) |
| 3289 driver_bug_workarounds |= SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX; | 3287 driver_bug_workarounds |= SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX; |
| 3290 if (workarounds().scalarize_vec_and_mat_constructor_args) | 3288 if (workarounds().scalarize_vec_and_mat_constructor_args) |
| 3291 driver_bug_workarounds |= SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS; | 3289 driver_bug_workarounds |= SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS; |
| 3292 if (workarounds().regenerate_struct_names) | 3290 if (workarounds().regenerate_struct_names) |
| 3293 driver_bug_workarounds |= SH_REGENERATE_STRUCT_NAMES; | 3291 driver_bug_workarounds |= SH_REGENERATE_STRUCT_NAMES; |
| 3294 if (workarounds().remove_pow_with_constant_exponent) | 3292 if (workarounds().remove_pow_with_constant_exponent) |
| 3295 driver_bug_workarounds |= SH_REMOVE_POW_WITH_CONSTANT_EXPONENT; | 3293 driver_bug_workarounds |= SH_REMOVE_POW_WITH_CONSTANT_EXPONENT; |
| 3296 | 3294 |
| 3297 if (base::CommandLine::InitializedForCurrentProcess() && | 3295 if (base::CommandLine::InitializedForCurrentProcess() && |
| 3298 base::CommandLine::ForCurrentProcess()->HasSwitch( | 3296 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 3299 switches::kEmulateShaderPrecision)) | 3297 switches::kEmulateShaderPrecision)) |
| 3300 resources.WEBGL_debug_shader_precision = true; | 3298 resources.WEBGL_debug_shader_precision = true; |
| 3301 | 3299 |
| 3300 ShShaderOutput shader_output_language = |
| 3301 ShaderTranslator::GetShaderOutputLanguageForContext( |
| 3302 feature_info_->gl_version_info()); |
| 3303 |
| 3302 vertex_translator_ = shader_translator_cache()->GetTranslator( | 3304 vertex_translator_ = shader_translator_cache()->GetTranslator( |
| 3303 GL_VERTEX_SHADER, | 3305 GL_VERTEX_SHADER, shader_spec, &resources, shader_output_language, |
| 3304 shader_spec, | |
| 3305 &resources, | |
| 3306 implementation_type, | |
| 3307 static_cast<ShCompileOptions>(driver_bug_workarounds)); | 3306 static_cast<ShCompileOptions>(driver_bug_workarounds)); |
| 3308 if (!vertex_translator_.get()) { | 3307 if (!vertex_translator_.get()) { |
| 3309 LOG(ERROR) << "Could not initialize vertex shader translator."; | 3308 LOG(ERROR) << "Could not initialize vertex shader translator."; |
| 3310 Destroy(true); | 3309 Destroy(true); |
| 3311 return false; | 3310 return false; |
| 3312 } | 3311 } |
| 3313 | 3312 |
| 3314 fragment_translator_ = shader_translator_cache()->GetTranslator( | 3313 fragment_translator_ = shader_translator_cache()->GetTranslator( |
| 3315 GL_FRAGMENT_SHADER, | 3314 GL_FRAGMENT_SHADER, shader_spec, &resources, shader_output_language, |
| 3316 shader_spec, | |
| 3317 &resources, | |
| 3318 implementation_type, | |
| 3319 static_cast<ShCompileOptions>(driver_bug_workarounds)); | 3315 static_cast<ShCompileOptions>(driver_bug_workarounds)); |
| 3320 if (!fragment_translator_.get()) { | 3316 if (!fragment_translator_.get()) { |
| 3321 LOG(ERROR) << "Could not initialize fragment shader translator."; | 3317 LOG(ERROR) << "Could not initialize fragment shader translator."; |
| 3322 Destroy(true); | 3318 Destroy(true); |
| 3323 return false; | 3319 return false; |
| 3324 } | 3320 } |
| 3325 return true; | 3321 return true; |
| 3326 } | 3322 } |
| 3327 | 3323 |
| 3328 bool GLES2DecoderImpl::GenBuffersHelper(GLsizei n, const GLuint* client_ids) { | 3324 bool GLES2DecoderImpl::GenBuffersHelper(GLsizei n, const GLuint* client_ids) { |
| (...skipping 11220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14549 return error::kNoError; | 14545 return error::kNoError; |
| 14550 } | 14546 } |
| 14551 | 14547 |
| 14552 // Include the auto-generated part of this file. We split this because it means | 14548 // Include the auto-generated part of this file. We split this because it means |
| 14553 // we can easily edit the non-auto generated parts right here in this file | 14549 // we can easily edit the non-auto generated parts right here in this file |
| 14554 // instead of having to edit some template or the code generator. | 14550 // instead of having to edit some template or the code generator. |
| 14555 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 14551 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 14556 | 14552 |
| 14557 } // namespace gles2 | 14553 } // namespace gles2 |
| 14558 } // namespace gpu | 14554 } // namespace gpu |
| OLD | NEW |