freedreno/ir3/nir: couple little fixes
authorRob Clark <robclark@freedesktop.org>
Sat, 11 Apr 2015 14:04:50 +0000 (10:04 -0400)
committerRob Clark <robclark@freedesktop.org>
Sat, 11 Apr 2015 15:41:03 +0000 (11:41 -0400)
Signed-off-by: Rob Clark <robclark@freedesktop.org>
src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c

index 34598dbab1c0e687f82f6063ea0cc03e2cfb1087..f7ea8799c2fde82bbbd727d29723a953b2168903 100644 (file)
@@ -303,6 +303,11 @@ declare_var(struct ir3_compile *ctx, nir_variable *var)
                        (length * sizeof(arr->arr[0])));
        arr->length = length;
        arr->aid = ++ctx->num_arrays;
+       /* Some shaders end up reading array elements without first writing..
+        * so initialize things to prevent null instr ptrs later:
+        */
+       for (unsigned i = 0; i < length; i++)
+               arr->arr[i] = create_immed(ctx->block, 0);
        _mesa_hash_table_insert(ctx->var_ht, var, arr);
 }
 
@@ -733,6 +738,8 @@ emit_alu(struct ir3_compile *ctx, nir_alu_instr *alu)
                compile_assert(ctx, !asrc->negate);
 
                src[i] = get_src(ctx, &asrc->src)[asrc->swizzle[chan]];
+
+               compile_assert(ctx, src[i]);
        }
 
        switch (alu->op) {
@@ -1613,8 +1620,9 @@ setup_input(struct ir3_compile *ctx, nir_variable *in)
                                /* with NIR, we need to infer TGSI_INTERPOLATE_COLOR
                                 * from the semantic name:
                                 */
-                               if ((semantic_name == TGSI_SEMANTIC_COLOR) ||
-                                               (semantic_name == TGSI_SEMANTIC_BCOLOR))
+                               if ((in->data.interpolation == INTERP_QUALIFIER_NONE) &&
+                                               ((semantic_name == TGSI_SEMANTIC_COLOR) ||
+                                                       (semantic_name == TGSI_SEMANTIC_BCOLOR)))
                                        so->inputs[n].interpolate = TGSI_INTERPOLATE_COLOR;
 
                                if (ctx->flat_bypass) {