[Mesa-dev] [PATCH] glsl: Trigger precision mismatch error only if both symbols are used

Tomasz Figa tfiga at chromium.org
Mon Sep 25 09:53:24 UTC 2017


Commit 259fc505454ea6a67aeacf6cdebf1398d9947759 added linker error for
mismatching uniform precision, as required by GLES specification and
conformance test-suite.

Several Android applications, including Forge of Empires, have shaders
which violate this rule, on a dead varying that will be eliminated.
The problem affects a big number of applications using Cocos2D engine
and other GLES implementations accept this, so work around the problem
by erroring out only if both symbols are actually referenced in the
code, which is the only case when the mismatch can cause incorrect
behavior.

Based on Kenneth Graunke's patch from Bugzilla, reworked from a drirc
option that completely bypasses the check into an incoditional check
that triggers either an error or warning, respectively if both
declarations are further referenced by the code or not.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97532
Signed-off-by: Tomasz Figa <tfiga at chromium.org>
---
 src/compiler/glsl/linker.cpp | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index f352c5385ca..1c534ea1a3b 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -1121,10 +1121,16 @@ cross_validate_globals(struct gl_shader_program *prog,
          if (prog->IsES && (prog->data->Version != 310 ||
                             !var->get_interface_type()) &&
              existing->data.precision != var->data.precision) {
-            linker_error(prog, "declarations for %s `%s` have "
-                         "mismatching precision qualifiers\n",
-                         mode_string(var), var->name);
-            return;
+            if (existing->data.used && var->data.used) {
+               linker_error(prog, "declarations for %s `%s` have "
+                            "mismatching precision qualifiers\n",
+                            mode_string(var), var->name);
+               return;
+            } else {
+               linker_warning(prog, "declarations for %s `%s` have "
+                              "mismatching precision qualifiers\n",
+                              mode_string(var), var->name);
+            }
          }
       } else
          variables->add_variable(var);
-- 
2.14.1.821.g8fa685d3b7-goog



More information about the mesa-dev mailing list