r600g: add missing literals
authorDave Airlie <airlied@redhat.com>
Mon, 30 Aug 2010 23:02:02 +0000 (09:02 +1000)
committerDave Airlie <airlied@redhat.com>
Mon, 30 Aug 2010 23:43:48 +0000 (09:43 +1000)
Also add an error if we hit this problem again, we need to do this better
possibly tying the literal addition to the last flag.

Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/drivers/r600/r600_asm.c
src/gallium/drivers/r600/r600_shader.c

index 1a354a6293bc0bff263954e846a696b8f0be2e8c..6483dac70398dfed47c849b01d6e73796796b525 100644 (file)
@@ -375,6 +375,9 @@ static int r600_bc_alu_build(struct r600_bc *bc, struct r600_bc_alu *alu, unsign
                                        S_SQ_ALU_WORD1_OP2_UPDATE_PRED(alu->predicate);
        }
        if (alu->last) {
+               if (alu->nliteral && !alu->literal_added) {
+                       R600_ERR("Bug in ALU processing for instruction 0x%08x, literal not added correctly\n");
+               }
                for (i = 0; i < alu->nliteral; i++) {
                        bc->bytecode[id++] = alu->value[i];
                }
index 652d4035cc8d2a89cae8c69cd46ecbbb7263b19b..4834eaa9de7e8a8962e500e59f431832434027d6 100644 (file)
@@ -1018,6 +1018,10 @@ static int tgsi_lit(struct r600_shader_ctx *ctx)
        if (r)
                return r;
 
+       r = r600_bc_add_literal(ctx->bc, ctx->value);
+       if (r)
+               return r;
+
        if (inst->Dst[0].Register.WriteMask & (1 << 2))
        {
                int chan;
@@ -1038,6 +1042,9 @@ static int tgsi_lit(struct r600_shader_ctx *ctx)
                if (r)
                        return r;
 
+               r = r600_bc_add_literal(ctx->bc, ctx->value);
+               if (r)
+                       return r;
                chan = alu.dst.chan;
                sel = alu.dst.sel;
 
@@ -1063,6 +1070,9 @@ static int tgsi_lit(struct r600_shader_ctx *ctx)
                if (r)
                        return r;
 
+               r = r600_bc_add_literal(ctx->bc, ctx->value);
+               if (r)
+                       return r;
                /* dst.z = exp(tmp.x) */
                memset(&alu, 0, sizeof(struct r600_bc_alu));
                alu.inst = V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE;
@@ -1149,6 +1159,9 @@ static int tgsi_trans_srcx_replicate(struct r600_shader_ctx *ctx)
        alu.dst.write = 1;
        alu.last = 1;
        r = r600_bc_add_alu(ctx->bc, &alu);
+       if (r)
+               return r;
+       r = r600_bc_add_literal(ctx->bc, ctx->value);
        if (r)
                return r;
        /* replicate result */
@@ -1760,6 +1773,10 @@ static int tgsi_exp(struct r600_shader_ctx *ctx)
                if (r)
                        return r;
 
+               r = r600_bc_add_literal(ctx->bc, ctx->value);
+               if (r)
+                       return r;
+
                alu.inst = V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE;
                alu.src[0].sel = ctx->temp_reg;
                alu.src[0].chan = 0;
@@ -1771,6 +1788,10 @@ static int tgsi_exp(struct r600_shader_ctx *ctx)
                r = r600_bc_add_alu(ctx->bc, &alu);
                if (r)
                        return r;
+
+               r = r600_bc_add_literal(ctx->bc, ctx->value);
+               if (r)
+                       return r;
        }
                
        /* result.y = tmp - floor(tmp); */
@@ -1796,6 +1817,9 @@ static int tgsi_exp(struct r600_shader_ctx *ctx)
                r = r600_bc_add_alu(ctx->bc, &alu);
                if (r)
                        return r;
+               r = r600_bc_add_literal(ctx->bc, ctx->value);
+               if (r)
+                       return r;
        }
 
        /* result.z = RoughApprox2ToX(tmp);*/
@@ -1816,7 +1840,9 @@ static int tgsi_exp(struct r600_shader_ctx *ctx)
                r = r600_bc_add_alu(ctx->bc, &alu);
                if (r)
                        return r;
-
+               r = r600_bc_add_literal(ctx->bc, ctx->value);
+               if (r)
+                       return r;
        }
 
        /* result.w = 1.0;*/
@@ -1834,6 +1860,9 @@ static int tgsi_exp(struct r600_shader_ctx *ctx)
                r = r600_bc_add_alu(ctx->bc, &alu);
                if (r)
                        return r;
+               r = r600_bc_add_literal(ctx->bc, ctx->value);
+               if (r)
+                       return r;
        }
        return tgsi_helper_copy(ctx, inst);
 }