| 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 <list> | 10 #include <list> |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 namespace gpu { | 77 namespace gpu { |
| 78 namespace gles2 { | 78 namespace gles2 { |
| 79 | 79 |
| 80 namespace { | 80 namespace { |
| 81 | 81 |
| 82 static const char kOESDerivativeExtension[] = "GL_OES_standard_derivatives"; | 82 static const char kOESDerivativeExtension[] = "GL_OES_standard_derivatives"; |
| 83 static const char kEXTFragDepthExtension[] = "GL_EXT_frag_depth"; | 83 static const char kEXTFragDepthExtension[] = "GL_EXT_frag_depth"; |
| 84 static const char kEXTDrawBuffersExtension[] = "GL_EXT_draw_buffers"; | 84 static const char kEXTDrawBuffersExtension[] = "GL_EXT_draw_buffers"; |
| 85 static const char kEXTShaderTextureLodExtension[] = "GL_EXT_shader_texture_lod"; | 85 static const char kEXTShaderTextureLodExtension[] = "GL_EXT_shader_texture_lod"; |
| 86 | 86 |
| 87 #if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108 | |
| 88 khronos_uint64_t CityHashForAngle(const char* name, unsigned int len) { | |
| 89 return static_cast<khronos_uint64_t>( | |
| 90 CityHash64(name, static_cast<size_t>(len))); | |
| 91 } | |
| 92 #endif | |
| 93 | |
| 94 static bool PrecisionMeetsSpecForHighpFloat(GLint rangeMin, | 87 static bool PrecisionMeetsSpecForHighpFloat(GLint rangeMin, |
| 95 GLint rangeMax, | 88 GLint rangeMax, |
| 96 GLint precision) { | 89 GLint precision) { |
| 97 return (rangeMin >= 62) && (rangeMax >= 62) && (precision >= 16); | 90 return (rangeMin >= 62) && (rangeMax >= 62) && (precision >= 16); |
| 98 } | 91 } |
| 99 | 92 |
| 100 static void GetShaderPrecisionFormatImpl(GLenum shader_type, | 93 static void GetShaderPrecisionFormatImpl(GLenum shader_type, |
| 101 GLenum precision_type, | 94 GLenum precision_type, |
| 102 GLint *range, GLint *precision) { | 95 GLint *range, GLint *precision) { |
| 103 switch (precision_type) { | 96 switch (precision_type) { |
| (...skipping 2657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2761 resources.MaxVertexTextureImageUnits = | 2754 resources.MaxVertexTextureImageUnits = |
| 2762 group_->max_vertex_texture_image_units(); | 2755 group_->max_vertex_texture_image_units(); |
| 2763 resources.MaxCombinedTextureImageUnits = group_->max_texture_units(); | 2756 resources.MaxCombinedTextureImageUnits = group_->max_texture_units(); |
| 2764 resources.MaxTextureImageUnits = group_->max_texture_image_units(); | 2757 resources.MaxTextureImageUnits = group_->max_texture_image_units(); |
| 2765 resources.MaxFragmentUniformVectors = | 2758 resources.MaxFragmentUniformVectors = |
| 2766 group_->max_fragment_uniform_vectors(); | 2759 group_->max_fragment_uniform_vectors(); |
| 2767 resources.MaxDrawBuffers = group_->max_draw_buffers(); | 2760 resources.MaxDrawBuffers = group_->max_draw_buffers(); |
| 2768 resources.MaxExpressionComplexity = 256; | 2761 resources.MaxExpressionComplexity = 256; |
| 2769 resources.MaxCallStackDepth = 256; | 2762 resources.MaxCallStackDepth = 256; |
| 2770 | 2763 |
| 2771 #if (ANGLE_SH_VERSION >= 110) | |
| 2772 GLint range[2] = { 0, 0 }; | 2764 GLint range[2] = { 0, 0 }; |
| 2773 GLint precision = 0; | 2765 GLint precision = 0; |
| 2774 GetShaderPrecisionFormatImpl(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, | 2766 GetShaderPrecisionFormatImpl(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, |
| 2775 range, &precision); | 2767 range, &precision); |
| 2776 resources.FragmentPrecisionHigh = | 2768 resources.FragmentPrecisionHigh = |
| 2777 PrecisionMeetsSpecForHighpFloat(range[0], range[1], precision); | 2769 PrecisionMeetsSpecForHighpFloat(range[0], range[1], precision); |
| 2778 #endif | |
| 2779 | 2770 |
| 2780 if (force_webgl_glsl_validation_) { | 2771 if (force_webgl_glsl_validation_) { |
| 2781 resources.OES_standard_derivatives = derivatives_explicitly_enabled_; | 2772 resources.OES_standard_derivatives = derivatives_explicitly_enabled_; |
| 2782 resources.EXT_frag_depth = frag_depth_explicitly_enabled_; | 2773 resources.EXT_frag_depth = frag_depth_explicitly_enabled_; |
| 2783 resources.EXT_draw_buffers = draw_buffers_explicitly_enabled_; | 2774 resources.EXT_draw_buffers = draw_buffers_explicitly_enabled_; |
| 2784 if (!draw_buffers_explicitly_enabled_) | 2775 if (!draw_buffers_explicitly_enabled_) |
| 2785 resources.MaxDrawBuffers = 1; | 2776 resources.MaxDrawBuffers = 1; |
| 2786 #if (ANGLE_SH_VERSION >= 123) | |
| 2787 resources.EXT_shader_texture_lod = shader_texture_lod_explicitly_enabled_; | 2777 resources.EXT_shader_texture_lod = shader_texture_lod_explicitly_enabled_; |
| 2788 #endif | |
| 2789 } else { | 2778 } else { |
| 2790 resources.OES_standard_derivatives = | 2779 resources.OES_standard_derivatives = |
| 2791 features().oes_standard_derivatives ? 1 : 0; | 2780 features().oes_standard_derivatives ? 1 : 0; |
| 2792 resources.ARB_texture_rectangle = | 2781 resources.ARB_texture_rectangle = |
| 2793 features().arb_texture_rectangle ? 1 : 0; | 2782 features().arb_texture_rectangle ? 1 : 0; |
| 2794 resources.OES_EGL_image_external = | 2783 resources.OES_EGL_image_external = |
| 2795 features().oes_egl_image_external ? 1 : 0; | 2784 features().oes_egl_image_external ? 1 : 0; |
| 2796 resources.EXT_draw_buffers = | 2785 resources.EXT_draw_buffers = |
| 2797 features().ext_draw_buffers ? 1 : 0; | 2786 features().ext_draw_buffers ? 1 : 0; |
| 2798 resources.EXT_frag_depth = | 2787 resources.EXT_frag_depth = |
| 2799 features().ext_frag_depth ? 1 : 0; | 2788 features().ext_frag_depth ? 1 : 0; |
| 2800 #if (ANGLE_SH_VERSION >= 123) | |
| 2801 resources.EXT_shader_texture_lod = | 2789 resources.EXT_shader_texture_lod = |
| 2802 features().ext_shader_texture_lod ? 1 : 0; | 2790 features().ext_shader_texture_lod ? 1 : 0; |
| 2803 #endif | |
| 2804 } | 2791 } |
| 2805 | 2792 |
| 2806 ShShaderSpec shader_spec = force_webgl_glsl_validation_ ? SH_WEBGL_SPEC | 2793 ShShaderSpec shader_spec = force_webgl_glsl_validation_ ? SH_WEBGL_SPEC |
| 2807 : SH_GLES2_SPEC; | 2794 : SH_GLES2_SPEC; |
| 2808 if (shader_spec == SH_WEBGL_SPEC && features().enable_shader_name_hashing) | 2795 if (shader_spec == SH_WEBGL_SPEC && features().enable_shader_name_hashing) |
| 2809 #if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108 | |
| 2810 resources.HashFunction = &CityHashForAngle; | |
| 2811 #else | |
| 2812 resources.HashFunction = &CityHash64; | 2796 resources.HashFunction = &CityHash64; |
| 2813 #endif | |
| 2814 else | 2797 else |
| 2815 resources.HashFunction = NULL; | 2798 resources.HashFunction = NULL; |
| 2816 ShaderTranslatorInterface::GlslImplementationType implementation_type = | 2799 ShaderTranslatorInterface::GlslImplementationType implementation_type = |
| 2817 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 ? | 2800 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 ? |
| 2818 ShaderTranslatorInterface::kGlslES : ShaderTranslatorInterface::kGlsl; | 2801 ShaderTranslatorInterface::kGlslES : ShaderTranslatorInterface::kGlsl; |
| 2819 int driver_bug_workarounds = 0; | 2802 int driver_bug_workarounds = 0; |
| 2820 if (workarounds().needs_glsl_built_in_function_emulation) | 2803 if (workarounds().needs_glsl_built_in_function_emulation) |
| 2821 driver_bug_workarounds |= SH_EMULATE_BUILT_IN_FUNCTIONS; | 2804 driver_bug_workarounds |= SH_EMULATE_BUILT_IN_FUNCTIONS; |
| 2822 if (workarounds().init_gl_position_in_vertex_shader) | 2805 if (workarounds().init_gl_position_in_vertex_shader) |
| 2823 driver_bug_workarounds |= SH_INIT_GL_POSITION; | 2806 driver_bug_workarounds |= SH_INIT_GL_POSITION; |
| 2824 if (workarounds().unfold_short_circuit_as_ternary_operation) | 2807 if (workarounds().unfold_short_circuit_as_ternary_operation) |
| 2825 driver_bug_workarounds |= SH_UNFOLD_SHORT_CIRCUIT; | 2808 driver_bug_workarounds |= SH_UNFOLD_SHORT_CIRCUIT; |
| 2826 if (workarounds().init_varyings_without_static_use) | 2809 if (workarounds().init_varyings_without_static_use) |
| 2827 driver_bug_workarounds |= SH_INIT_VARYINGS_WITHOUT_STATIC_USE; | 2810 driver_bug_workarounds |= SH_INIT_VARYINGS_WITHOUT_STATIC_USE; |
| 2828 if (workarounds().unroll_for_loop_with_sampler_array_index) | 2811 if (workarounds().unroll_for_loop_with_sampler_array_index) |
| 2829 driver_bug_workarounds |= SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX; | 2812 driver_bug_workarounds |= SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX; |
| 2830 if (workarounds().scalarize_vec_and_mat_constructor_args) | 2813 if (workarounds().scalarize_vec_and_mat_constructor_args) |
| 2831 driver_bug_workarounds |= SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS; | 2814 driver_bug_workarounds |= SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS; |
| 2832 if (workarounds().regenerate_struct_names) | 2815 if (workarounds().regenerate_struct_names) |
| 2833 driver_bug_workarounds |= SH_REGENERATE_STRUCT_NAMES; | 2816 driver_bug_workarounds |= SH_REGENERATE_STRUCT_NAMES; |
| 2834 | 2817 |
| 2835 vertex_translator_ = shader_translator_cache()->GetTranslator( | 2818 vertex_translator_ = shader_translator_cache()->GetTranslator( |
| 2836 #if (ANGLE_SH_VERSION >= 126) | |
| 2837 GL_VERTEX_SHADER, | 2819 GL_VERTEX_SHADER, |
| 2838 #else | |
| 2839 SH_VERTEX_SHADER, | |
| 2840 #endif | |
| 2841 shader_spec, | 2820 shader_spec, |
| 2842 &resources, | 2821 &resources, |
| 2843 implementation_type, | 2822 implementation_type, |
| 2844 static_cast<ShCompileOptions>(driver_bug_workarounds)); | 2823 static_cast<ShCompileOptions>(driver_bug_workarounds)); |
| 2845 if (!vertex_translator_.get()) { | 2824 if (!vertex_translator_.get()) { |
| 2846 LOG(ERROR) << "Could not initialize vertex shader translator."; | 2825 LOG(ERROR) << "Could not initialize vertex shader translator."; |
| 2847 Destroy(true); | 2826 Destroy(true); |
| 2848 return false; | 2827 return false; |
| 2849 } | 2828 } |
| 2850 | 2829 |
| 2851 fragment_translator_ = shader_translator_cache()->GetTranslator( | 2830 fragment_translator_ = shader_translator_cache()->GetTranslator( |
| 2852 #if (ANGLE_SH_VERSION >= 126) | |
| 2853 GL_FRAGMENT_SHADER, | 2831 GL_FRAGMENT_SHADER, |
| 2854 #else | |
| 2855 SH_FRAGMENT_SHADER, | |
| 2856 #endif | |
| 2857 shader_spec, | 2832 shader_spec, |
| 2858 &resources, | 2833 &resources, |
| 2859 implementation_type, | 2834 implementation_type, |
| 2860 static_cast<ShCompileOptions>(driver_bug_workarounds)); | 2835 static_cast<ShCompileOptions>(driver_bug_workarounds)); |
| 2861 if (!fragment_translator_.get()) { | 2836 if (!fragment_translator_.get()) { |
| 2862 LOG(ERROR) << "Could not initialize fragment shader translator."; | 2837 LOG(ERROR) << "Could not initialize fragment shader translator."; |
| 2863 Destroy(true); | 2838 Destroy(true); |
| 2864 return false; | 2839 return false; |
| 2865 } | 2840 } |
| 2866 return true; | 2841 return true; |
| (...skipping 8296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11163 } | 11138 } |
| 11164 } | 11139 } |
| 11165 | 11140 |
| 11166 // Include the auto-generated part of this file. We split this because it means | 11141 // Include the auto-generated part of this file. We split this because it means |
| 11167 // we can easily edit the non-auto generated parts right here in this file | 11142 // we can easily edit the non-auto generated parts right here in this file |
| 11168 // instead of having to edit some template or the code generator. | 11143 // instead of having to edit some template or the code generator. |
| 11169 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 11144 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 11170 | 11145 |
| 11171 } // namespace gles2 | 11146 } // namespace gles2 |
| 11172 } // namespace gpu | 11147 } // namespace gpu |
| OLD | NEW |