vc4: Initialize the various qreg arrays when allocating them.
authorEric Anholt <eric@anholt.net>
Wed, 17 Sep 2014 20:10:51 +0000 (13:10 -0700)
committerEric Anholt <eric@anholt.net>
Wed, 17 Sep 2014 21:21:24 +0000 (14:21 -0700)
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

index a662dc2ce5490bf46d9c5deca0667f00b359329b..539fede50a117e428e38ad13611f7bb5afcdc4f0 100644 (file)
@@ -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