summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Clark <robdclark@gmail.com>2015-01-23 13:32:29 -0500
committerRob Clark <robdclark@gmail.com>2015-01-23 13:32:32 -0500
commit171fbd900dc47fb44288e21e3763ee6bb41be50f (patch)
treea31602b1b654f6176a9fa8c4a5f9b9685a7df73b
parent053af66b4937816d90491e4019a497f66286ea81 (diff)
ir3emu: sorta emulate texture sam instructions better
Don't completely ignore all the other src registers. Otherwise we could miss some RA bugs.
-rw-r--r--asm/ir-a3xx.c2
-rw-r--r--ir3emu.c29
2 files changed, 29 insertions, 2 deletions
diff --git a/asm/ir-a3xx.c b/asm/ir-a3xx.c
index f3fd6ad..0768a15 100644
--- a/asm/ir-a3xx.c
+++ b/asm/ir-a3xx.c
@@ -86,7 +86,7 @@ static uint32_t reg(struct ir3_register *reg, struct ir3_shader_info *info,
if (reg->flags & IR3_REG_IMMED) {
val.iim_val = reg->iim_val;
} else {
- int8_t max = (reg->num + repeat) >> 2;
+ int max = (reg->num + repeat) >> 2;
val.comp = reg->num & 0x3;
val.num = reg->num >> 2;
diff --git a/ir3emu.c b/ir3emu.c
index f8aaf21..f7983c9 100644
--- a/ir3emu.c
+++ b/ir3emu.c
@@ -726,7 +726,7 @@ emu_run_cat4(struct ir3_emu_ctx *ctx, instr_cat4_t *cat4)
static void
emu_run_cat5(struct ir3_emu_ctx *ctx, instr_cat5_t *cat5)
{
- unsigned i, srccomp = 2;
+ unsigned i, srccomp = 2, src2comp = 0;
regval_t dst[4];
/* TODO handle various # of components and args.. */
@@ -742,6 +742,11 @@ emu_run_cat5(struct ir3_emu_ctx *ctx, instr_cat5_t *cat5)
break;
}
+ if (cat5->is_s)
+ srccomp++;
+
+ if (cat5->is_a)
+ srccomp++;
if (cat5->is_p)
srccomp++;
@@ -749,6 +754,17 @@ emu_run_cat5(struct ir3_emu_ctx *ctx, instr_cat5_t *cat5)
if (cat5->is_3d)
srccomp++;
+ if (cat5->is_o) {
+ /* XXX not really correct, I think (if I understand trans_samp()
+ * properly).. but we'd need to know about the texture type to
+ * actually know # of components.. probably should get the
+ * cmdline compiler to spit that out in a header comment..
+ */
+ src2comp = 3;
+ }
+
+ emu_assert(ctx, srccomp < 4);
+
for (i = 0; i < 4; i++) {
unsigned j = (i % srccomp);
regval_t src;
@@ -759,6 +775,17 @@ emu_run_cat5(struct ir3_emu_ctx *ctx, instr_cat5_t *cat5)
});
dst[i].u = src.u + cat5->norm.samp + cat5->norm.tex;
+
+ if (src2comp) {
+ j = (i % src2comp);
+
+ src = read_src(ctx, 0, (struct ir3_regsrc){
+ .src = (reg_t)(cat5->src1 + j),
+ .full = cat5->full,
+ });
+
+ dst[i].u += src.u;
+ }
}
for (i = 0; i < 4; i++) {