Mesa (master): glsl: don' t lower fragdata array if the output data types don't match

Samuel Iglesias Gonsálvez samuelig at kemper.freedesktop.org
Tue May 5 10:51:47 UTC 2015


Module: Mesa
Branch: master
Commit: 08a4639e81f20954b2d78b0ff5bc268731372570
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=08a4639e81f20954b2d78b0ff5bc268731372570

Author: Samuel Iglesias Gonsalvez <siglesias at igalia.com>
Date:   Mon Feb  9 10:36:36 2015 +0100

glsl: don't lower fragdata array if the output data types don't match

Commit 7e414b58640aee6e243d337e72cea290c354f632 broke the gl_FragData array
into separate gl_FragData[i] variables, so drivers can eliminate useless
writes to gl_FragData improving their performance.

The problem occurs when GLSL IR code is linked in the following case:

* The FS output variable base data type does not match gl_FragData one (float
  vector)
* The FS output variable is replaced by gl_out_FragDataX because of commit
  7e414b58640aee6 with X from 0 to GL_MAX_DRAW_BUFFERS.

Then the FS output variable base data type is lost in the resulting GLSL IR,
making that the driver does a wrong assignment to gl_out_FragData components
because of unmatching data types.

This patch reverts the fragdata array lowering when the output var base data type
doesn't match gl_out_FragData, i.e., when output variable base data type is
not a float or a float vector.

This patch fixes 250 dEQP tests (tested in an Intel Haswell machine)

dEQP-GLES3.functional.fragment_out.random.* (22 failed tests)
dEQP-GLES3.functional.fragment_out.array.uint.* (120 failed tests)
dEQP-GLES3.functional.fragment_out.array.int.* (108 failed tests)

Signed-off-by: Samuel Iglesias Gonsalvez <siglesias at igalia.com>
Reviewed-by: Matt Turner <mattst88 at gmail.com>

---

 src/glsl/opt_dead_builtin_varyings.cpp |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/glsl/opt_dead_builtin_varyings.cpp b/src/glsl/opt_dead_builtin_varyings.cpp
index 92f20c7..31719d2 100644
--- a/src/glsl/opt_dead_builtin_varyings.cpp
+++ b/src/glsl/opt_dead_builtin_varyings.cpp
@@ -99,6 +99,16 @@ public:
          }
          else {
             this->fragdata_usage |= 1 << index->get_uint_component(0);
+            /* Don't lower fragdata array if the output variable
+             * is not a float variable (or float vector) because it will
+             * generate wrong register assignments because of different
+             * data types.
+             */
+            if (var->type->gl_type != GL_FLOAT &&
+                var->type->gl_type != GL_FLOAT_VEC2 &&
+                var->type->gl_type != GL_FLOAT_VEC3 &&
+                var->type->gl_type != GL_FLOAT_VEC4)
+               this->lower_fragdata_array = false;
          }
 
          /* Don't visit the leaves of ir_dereference_array. */




More information about the mesa-commit mailing list