| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 static const char kEXTFragDepthExtension[] = "GL_EXT_frag_depth"; | 78 static const char kEXTFragDepthExtension[] = "GL_EXT_frag_depth"; |
| 79 static const char kEXTDrawBuffersExtension[] = "GL_EXT_draw_buffers"; | 79 static const char kEXTDrawBuffersExtension[] = "GL_EXT_draw_buffers"; |
| 80 | 80 |
| 81 #if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108 | 81 #if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108 |
| 82 khronos_uint64_t CityHashForAngle(const char* name, unsigned int len) { | 82 khronos_uint64_t CityHashForAngle(const char* name, unsigned int len) { |
| 83 return static_cast<khronos_uint64_t>( | 83 return static_cast<khronos_uint64_t>( |
| 84 CityHash64(name, static_cast<size_t>(len))); | 84 CityHash64(name, static_cast<size_t>(len))); |
| 85 } | 85 } |
| 86 #endif | 86 #endif |
| 87 | 87 |
| 88 static bool PrecisionMeetsSpecForHighpFloat(GLint rangeMin, |
| 89 GLint rangeMax, |
| 90 GLint precision) { |
| 91 return (rangeMin >= 62) && (rangeMax >= 62) && (precision >= 16); |
| 92 } |
| 93 |
| 88 static void GetShaderPrecisionFormatImpl(GLenum shader_type, | 94 static void GetShaderPrecisionFormatImpl(GLenum shader_type, |
| 89 GLenum precision_type, | 95 GLenum precision_type, |
| 90 GLint *range, GLint *precision) { | 96 GLint *range, GLint *precision) { |
| 91 switch (precision_type) { | 97 switch (precision_type) { |
| 92 case GL_LOW_INT: | 98 case GL_LOW_INT: |
| 93 case GL_MEDIUM_INT: | 99 case GL_MEDIUM_INT: |
| 94 case GL_HIGH_INT: | 100 case GL_HIGH_INT: |
| 95 // These values are for a 32-bit twos-complement integer format. | 101 // These values are for a 32-bit twos-complement integer format. |
| 96 range[0] = 31; | 102 range[0] = 31; |
| 97 range[1] = 30; | 103 range[1] = 30; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 113 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 && | 119 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 && |
| 114 gfx::g_driver_gl.fn.glGetShaderPrecisionFormatFn) { | 120 gfx::g_driver_gl.fn.glGetShaderPrecisionFormatFn) { |
| 115 // This function is sometimes defined even though it's really just | 121 // This function is sometimes defined even though it's really just |
| 116 // a stub, so we need to set range and precision as if it weren't | 122 // a stub, so we need to set range and precision as if it weren't |
| 117 // defined before calling it. | 123 // defined before calling it. |
| 118 // On Mac OS with some GPUs, calling this generates a | 124 // On Mac OS with some GPUs, calling this generates a |
| 119 // GL_INVALID_OPERATION error. Avoid calling it on non-GLES2 | 125 // GL_INVALID_OPERATION error. Avoid calling it on non-GLES2 |
| 120 // platforms. | 126 // platforms. |
| 121 glGetShaderPrecisionFormat(shader_type, precision_type, | 127 glGetShaderPrecisionFormat(shader_type, precision_type, |
| 122 range, precision); | 128 range, precision); |
| 129 |
| 130 // TODO(brianderson): Make the following official workarounds. |
| 131 |
| 132 // Some drivers have bugs where they report the ranges as a negative number. |
| 133 // Taking the absolute value here shouldn't hurt because negative numbers |
| 134 // aren't expected anyway. |
| 135 range[0] = abs(range[0]); |
| 136 range[1] = abs(range[1]); |
| 137 |
| 138 // If the driver reports a precision for highp float that isn't actually |
| 139 // highp, don't pretend like it's supported because shader compilation will |
| 140 // fail anyway. |
| 141 if (precision_type == GL_HIGH_FLOAT && |
| 142 !PrecisionMeetsSpecForHighpFloat(range[0], range[1], *precision)) { |
| 143 range[0] = 0; |
| 144 range[1] = 0; |
| 145 *precision = 0; |
| 146 } |
| 123 } | 147 } |
| 124 } | 148 } |
| 125 | 149 |
| 126 } // namespace | 150 } // namespace |
| 127 | 151 |
| 128 class GLES2DecoderImpl; | 152 class GLES2DecoderImpl; |
| 129 | 153 |
| 130 // Local versions of the SET_GL_ERROR macros | 154 // Local versions of the SET_GL_ERROR macros |
| 131 #define LOCAL_SET_GL_ERROR(error, function_name, msg) \ | 155 #define LOCAL_SET_GL_ERROR(error, function_name, msg) \ |
| 132 ERRORSTATE_SET_GL_ERROR(state_.GetErrorState(), error, function_name, msg) | 156 ERRORSTATE_SET_GL_ERROR(state_.GetErrorState(), error, function_name, msg) |
| (...skipping 2371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2504 group_->max_fragment_uniform_vectors(); | 2528 group_->max_fragment_uniform_vectors(); |
| 2505 resources.MaxDrawBuffers = group_->max_draw_buffers(); | 2529 resources.MaxDrawBuffers = group_->max_draw_buffers(); |
| 2506 resources.MaxExpressionComplexity = 256; | 2530 resources.MaxExpressionComplexity = 256; |
| 2507 resources.MaxCallStackDepth = 256; | 2531 resources.MaxCallStackDepth = 256; |
| 2508 | 2532 |
| 2509 #if (ANGLE_SH_VERSION >= 110) | 2533 #if (ANGLE_SH_VERSION >= 110) |
| 2510 GLint range[2] = { 0, 0 }; | 2534 GLint range[2] = { 0, 0 }; |
| 2511 GLint precision = 0; | 2535 GLint precision = 0; |
| 2512 GetShaderPrecisionFormatImpl(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, | 2536 GetShaderPrecisionFormatImpl(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, |
| 2513 range, &precision); | 2537 range, &precision); |
| 2514 resources.FragmentPrecisionHigh = ((range[0] >= 62) && | 2538 resources.FragmentPrecisionHigh = |
| 2515 (range[1] >= 62) && | 2539 PrecisionMeetsSpecForHighpFloat(range[0], range[1], precision); |
| 2516 (precision >= 16)); | |
| 2517 #endif | 2540 #endif |
| 2518 | 2541 |
| 2519 if (force_webgl_glsl_validation_) { | 2542 if (force_webgl_glsl_validation_) { |
| 2520 resources.OES_standard_derivatives = derivatives_explicitly_enabled_; | 2543 resources.OES_standard_derivatives = derivatives_explicitly_enabled_; |
| 2521 resources.EXT_frag_depth = frag_depth_explicitly_enabled_; | 2544 resources.EXT_frag_depth = frag_depth_explicitly_enabled_; |
| 2522 resources.EXT_draw_buffers = draw_buffers_explicitly_enabled_; | 2545 resources.EXT_draw_buffers = draw_buffers_explicitly_enabled_; |
| 2523 } else { | 2546 } else { |
| 2524 resources.OES_standard_derivatives = | 2547 resources.OES_standard_derivatives = |
| 2525 features().oes_standard_derivatives ? 1 : 0; | 2548 features().oes_standard_derivatives ? 1 : 0; |
| 2526 resources.ARB_texture_rectangle = | 2549 resources.ARB_texture_rectangle = |
| (...skipping 7793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10320 return error::kNoError; | 10343 return error::kNoError; |
| 10321 } | 10344 } |
| 10322 | 10345 |
| 10323 // Include the auto-generated part of this file. We split this because it means | 10346 // Include the auto-generated part of this file. We split this because it means |
| 10324 // we can easily edit the non-auto generated parts right here in this file | 10347 // we can easily edit the non-auto generated parts right here in this file |
| 10325 // instead of having to edit some template or the code generator. | 10348 // instead of having to edit some template or the code generator. |
| 10326 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10349 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 10327 | 10350 |
| 10328 } // namespace gles2 | 10351 } // namespace gles2 |
| 10329 } // namespace gpu | 10352 } // namespace gpu |
| OLD | NEW |