Mesa (master): vc4: Initialize the various qreg arrays when allocating them.

Eric Anholt anholt at kemper.freedesktop.org
Wed Sep 17 21:31:06 UTC 2014


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

Author: Eric Anholt <eric at anholt.net>
Date:   Wed Sep 17 13:10:51 2014 -0700

vc4: Initialize the various qreg arrays when allocating them.

This is particularly important for outputs, where we try to MOV the whole
vec4 to the VPM, even if only 1-3 components had been set up.  It might
also be important for temporaries, if the shader reads components before
writing them.

---

 src/gallium/drivers/vc4/vc4_program.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c
index a662dc2..539fede 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -73,12 +73,16 @@ resize_qreg_array(struct vc4_compile *c,
         if (*size >= decl_size)
                 return;
 
+        uint32_t old_size = *size;
         *size = MAX2(*size * 2, decl_size);
         *regs = reralloc(c, *regs, struct qreg, *size);
         if (!*regs) {
                 fprintf(stderr, "Malloc failure\n");
                 abort();
         }
+
+        for (uint32_t i = old_size; i < *size; i++)
+                (*regs)[i] = c->undef;
 }
 
 static struct qreg




More information about the mesa-commit mailing list