From 4bb7f59b31b1266d49016bdbf39507bea24db733 Mon Sep 17 00:00:00 2001 From: Eero Tamminen Date: Fri, 16 Sep 2016 18:31:20 +0300 Subject: [PATCH] glsl/linker: Precision error -> warning with env variable Commit 259fc505454ea6a67aeacf6cdebf1398d9947759 added linker error for mismatching uniform precision, as required by GLES specification and conformance test-suite. It causes all GLB 2.7 test-suite tests to segfault and few GLMark2 test-suite ES2 version tests to fail, which are bugs in those programs: Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97532 Because those widely used test-suites had this issue, it's assumed that other drivers accept it, at least for GLES v2, and that there are also other programs with the issue, ones which won't anymore be updated / fixed. This commit adds environment variable with which user can turn that linker error into warning, if either of the uniforms is unused (i.e. precision mismatch doesn't have consequences, which is the case with GLB 2.7 & GLmark2). --- src/compiler/glsl/linker.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp index 995fc0c..56a48c0 100644 --- a/src/compiler/glsl/linker.cpp +++ b/src/compiler/glsl/linker.cpp @@ -80,6 +80,7 @@ #include "ir_rvalue_visitor.h" #include "ir_uniform.h" +#include "../util/debug.h" #include "main/shaderobj.h" #include "main/enums.h" @@ -1155,9 +1156,18 @@ cross_validate_globals(struct gl_shader_program *prog, } if (prog->IsES && existing->data.precision != var->data.precision) { - linker_error(prog, "declarations for %s `%s` have " - "mismatching precision qualifiers\n", - mode_string(var), var->name); + /* error can be avoided only if user disables it and both aren't used */ + if ((existing->data.used && var->data.used) || + env_var_as_boolean("disable_precision_mismatch_error", false) == false) + linker_error(prog, "declarations for %s `%s` have " + "mismatching precision qualifiers\n" + "(disable_precision_mismatch_error=true allows " + "this GLES spec violation for unused uniforms)\n", + mode_string(var), var->name); + else + linker_warning(prog, "declarations for %s `%s` have " + "mismatching precision qualifiers\n", + mode_string(var), var->name); return; } } else -- 2.7.4