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

Unified 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: Put magic numbers for highp in a shared function 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/service/gles2_cmd_decoder.cc
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 2363e5346ee01712513a0217ae6e0ece0652a12c..564e04030ebb691fabc9c368d4bda71a2480915b 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -85,6 +85,12 @@ khronos_uint64_t CityHashForAngle(const char* name, unsigned int len) {
}
#endif
+static bool PrecisionMeetsSpecForHighpFloat(GLint rangeMin,
+ GLint rangeMax,
+ GLint precision) {
+ return (rangeMin >= 62) && (rangeMax >= 62) && (precision >= 16);
+}
+
static void GetShaderPrecisionFormatImpl(GLenum shader_type,
GLenum precision_type,
GLint *range, GLint *precision) {
@@ -120,6 +126,24 @@ static void GetShaderPrecisionFormatImpl(GLenum shader_type,
// platforms.
glGetShaderPrecisionFormat(shader_type, precision_type,
range, precision);
+
+ // TODO(brianderson): Make the following official workarounds.
+
+ // Some drivers have bugs where they report the ranges as a negative number.
+ // Taking the absolute value here shouldn't hurt because negative numbers
+ // aren't expected anyway.
+ range[0] = abs(range[0]);
+ range[1] = abs(range[1]);
+
+ // If the driver reports a precision for highp float that isn't actually
+ // highp, don't pretend like it's supported because shader compilation will
+ // fail anyway.
+ if (precision_type == GL_HIGH_FLOAT &&
+ !PrecisionMeetsSpecForHighpFloat(range[0], range[1], *precision)) {
+ range[0] = 0;
+ range[1] = 0;
+ *precision = 0;
+ }
}
}
@@ -2511,9 +2535,8 @@ bool GLES2DecoderImpl::InitializeShaderTranslator() {
GLint precision = 0;
GetShaderPrecisionFormatImpl(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT,
range, &precision);
- resources.FragmentPrecisionHigh = ((range[0] >= 62) &&
- (range[1] >= 62) &&
- (precision >= 16));
+ resources.FragmentPrecisionHigh =
+ PrecisionMeetsSpecForHighpFloat(range[0], range[1], precision);
#endif
if (force_webgl_glsl_validation_) {
« 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