[Mesa-dev] [PATCH] glsl: Do not propagate 'precise' and 'invariant' on read-only variables
Danylo Piliaiev
danylo.piliaiev at gmail.com
Wed Aug 22 12:51:01 UTC 2018
Read-only variables could be considered inherently invariant and precise
since no expression in shader affects them.
Explicitly marking them as such is unnecessary and can cause issues,
e.g. uniform marked as invariant may require the same uniform in other
stage to be invariant too but uniforms cannot have "invariant" qualifier.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100316
Signed-off-by: Danylo Piliaiev <danylo.piliaiev at globallogic.com>
---
My assumption is that variable being read_only means that it either
loads a value from an external source or is initialized from constant value.
>From what I saw in code it's true but it may be wrong to depend on it.
src/compiler/glsl/propagate_invariance.cpp | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/compiler/glsl/propagate_invariance.cpp b/src/compiler/glsl/propagate_invariance.cpp
index b3f1d810cd..0e4233aa9f 100644
--- a/src/compiler/glsl/propagate_invariance.cpp
+++ b/src/compiler/glsl/propagate_invariance.cpp
@@ -96,6 +96,16 @@ ir_invariance_propagation_visitor::visit(ir_dereference_variable *ir)
if (this->dst_var == NULL)
return visit_continue;
+ /* Read-only variables could be considered inherently
+ * invariant and precise since no expression in shader affects them.
+ * Explicitly marking them as such is unnecessary and can cause
+ * issues, e.g. uniform marked as invariant may require the same
+ * uniform in other stage to be invariant too but uniforms cannot
+ * have "invariant" qualifier.
+ */
+ if (ir->var->data.read_only)
+ return visit_continue;
+
if (this->dst_var->data.invariant) {
if (!ir->var->data.invariant)
this->progress = true;
--
2.18.0
More information about the mesa-dev
mailing list