Mesa (master): vc4: Initialize undefined temporaries to 0.

Eric Anholt anholt at kemper.freedesktop.org
Thu Oct 9 19:50:05 UTC 2014


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

Author: Eric Anholt <eric at anholt.net>
Date:   Thu Oct  9 17:49:23 2014 +0200

vc4: Initialize undefined temporaries to 0.

Under the simulator, reading registers before writing them triggers an
assertion failure.  c->undef gets treated as r0, which will usually be
written, but not if it's used in the first instruction.  We should
definitely not be aborting in this case, and return some sort of undefined
value instead.

Fixes glsl-user-varying-ff.

---

 src/gallium/drivers/vc4/vc4_program.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c
index 93f9956..ec66dae 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -957,10 +957,15 @@ emit_tgsi_declaration(struct vc4_compile *c,
                       struct tgsi_full_declaration *decl)
 {
         switch (decl->Declaration.File) {
-        case TGSI_FILE_TEMPORARY:
+        case TGSI_FILE_TEMPORARY: {
+                uint32_t old_size = c->temps_array_size;
                 resize_qreg_array(c, &c->temps, &c->temps_array_size,
                                   (decl->Range.Last + 1) * 4);
+
+                for (int i = old_size; i < c->temps_array_size; i++)
+                        c->temps[i] = qir_uniform_ui(c, 0);
                 break;
+        }
 
         case TGSI_FILE_INPUT:
                 resize_qreg_array(c, &c->inputs, &c->inputs_array_size,




More information about the mesa-commit mailing list