Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 16409014: gpu: Workaround invalid values from GetShaderPrecisionFormat (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 && 113 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 &&
114 gfx::g_driver_gl.fn.glGetShaderPrecisionFormatFn) { 114 gfx::g_driver_gl.fn.glGetShaderPrecisionFormatFn) {
115 // This function is sometimes defined even though it's really just 115 // 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 116 // a stub, so we need to set range and precision as if it weren't
117 // defined before calling it. 117 // defined before calling it.
118 // On Mac OS with some GPUs, calling this generates a 118 // On Mac OS with some GPUs, calling this generates a
119 // GL_INVALID_OPERATION error. Avoid calling it on non-GLES2 119 // GL_INVALID_OPERATION error. Avoid calling it on non-GLES2
120 // platforms. 120 // platforms.
121 glGetShaderPrecisionFormat(shader_type, precision_type, 121 glGetShaderPrecisionFormat(shader_type, precision_type,
122 range, precision); 122 range, precision);
123
124 // Some drivers have bugs where they report the ranges as a negative number.
125 // Taking the absolute value here shouldn't hurt because negative numbers
126 // aren't expected anyway.
127 range[0] = abs(range[0]);
128 range[1] = abs(range[1]);
129
130 // If the driver reports a precision for highp float that isn't actually
131 // highp, don't pretend like it's supported because shader compilation will
132 // fail anyway.
133 if (precision_type == GL_HIGH_FLOAT &&
134 (range[0] < 62 || range[1] < 62 || *precision < 16)) {
Ken Russell (switch to Gerrit) 2013/06/11 20:01:27 Can the duplicate logic here and in GLES2DecoderIm
brianderson 2013/06/11 23:35:46 Done.
135 range[0] = 0;
136 range[1] = 0;
137 *precision = 0;
138 }
123 } 139 }
124 } 140 }
125 141
126 } // namespace 142 } // namespace
127 143
128 class GLES2DecoderImpl; 144 class GLES2DecoderImpl;
129 145
130 // Local versions of the SET_GL_ERROR macros 146 // Local versions of the SET_GL_ERROR macros
131 #define LOCAL_SET_GL_ERROR(error, function_name, msg) \ 147 #define LOCAL_SET_GL_ERROR(error, function_name, msg) \
132 ERRORSTATE_SET_GL_ERROR(state_.GetErrorState(), error, function_name, msg) 148 ERRORSTATE_SET_GL_ERROR(state_.GetErrorState(), error, function_name, msg)
(...skipping 2367 matching lines...) Expand 10 before | Expand all | Expand 10 after
2500 group_->max_vertex_texture_image_units(); 2516 group_->max_vertex_texture_image_units();
2501 resources.MaxCombinedTextureImageUnits = group_->max_texture_units(); 2517 resources.MaxCombinedTextureImageUnits = group_->max_texture_units();
2502 resources.MaxTextureImageUnits = group_->max_texture_image_units(); 2518 resources.MaxTextureImageUnits = group_->max_texture_image_units();
2503 resources.MaxFragmentUniformVectors = 2519 resources.MaxFragmentUniformVectors =
2504 group_->max_fragment_uniform_vectors(); 2520 group_->max_fragment_uniform_vectors();
2505 resources.MaxDrawBuffers = group_->max_draw_buffers(); 2521 resources.MaxDrawBuffers = group_->max_draw_buffers();
2506 resources.MaxExpressionComplexity = 256; 2522 resources.MaxExpressionComplexity = 256;
2507 resources.MaxCallStackDepth = 256; 2523 resources.MaxCallStackDepth = 256;
2508 2524
2509 #if (ANGLE_SH_VERSION >= 110) 2525 #if (ANGLE_SH_VERSION >= 110)
2510 GLint range[2] = { 0, 0 }; 2526 GLint range[2] = { 0, 0 };
greggman 2013/06/11 21:58:50 What kbr said, should this code have the same work
brianderson 2013/06/11 23:35:46 The workaround is in GetShaderPrecisionFormatImpl
2511 GLint precision = 0; 2527 GLint precision = 0;
2512 GetShaderPrecisionFormatImpl(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, 2528 GetShaderPrecisionFormatImpl(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT,
2513 range, &precision); 2529 range, &precision);
2514 resources.FragmentPrecisionHigh = ((range[0] >= 62) && 2530 resources.FragmentPrecisionHigh = ((range[0] >= 62) &&
2515 (range[1] >= 62) && 2531 (range[1] >= 62) &&
2516 (precision >= 16)); 2532 (precision >= 16));
2517 #endif 2533 #endif
2518 2534
2519 if (force_webgl_glsl_validation_) { 2535 if (force_webgl_glsl_validation_) {
2520 resources.OES_standard_derivatives = derivatives_explicitly_enabled_; 2536 resources.OES_standard_derivatives = derivatives_explicitly_enabled_;
(...skipping 7799 matching lines...) Expand 10 before | Expand all | Expand 10 after
10320 return error::kNoError; 10336 return error::kNoError;
10321 } 10337 }
10322 10338
10323 // Include the auto-generated part of this file. We split this because it means 10339 // 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 10340 // 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. 10341 // instead of having to edit some template or the code generator.
10326 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 10342 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
10327 10343
10328 } // namespace gles2 10344 } // namespace gles2
10329 } // namespace gpu 10345 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698