summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gallium/drivers/nv50/nv50_program.c14
-rw-r--r--src/gallium/drivers/nv50/nv50_program.h1
-rw-r--r--src/gallium/drivers/nv50/nv50_tgsi_to_nc.c10
3 files changed, 20 insertions, 5 deletions
diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c
index 182a591eb37..523603ca3af 100644
--- a/src/gallium/drivers/nv50/nv50_program.c
+++ b/src/gallium/drivers/nv50/nv50_program.c
@@ -187,13 +187,14 @@ prog_immediate(struct nv50_translation_info *ti,
const struct tgsi_full_immediate *imm)
{
int c;
- unsigned n = ++ti->immd32_nr;
+ unsigned n = ti->immd32_nr++;
- if (n == (1 << (ffs(n) - 1)))
- ti->immd32 = REALLOC(ti->immd32, (n / 2) * 16, (n * 2) * 16);
+ assert(ti->immd32_nr <= ti->scan.immediate_count);
for (c = 0; c < 4; ++c)
- ti->immd32[(n - 1) * 4 + c] = imm->u[c].Uint;
+ ti->immd32[n * 4 + c] = imm->u[c].Uint;
+
+ ti->immd32_ty[n] = imm->Immediate.DataType;
}
static INLINE unsigned
@@ -495,6 +496,9 @@ nv50_prog_scan(struct nv50_translation_info *ti)
tgsi_dump(p->pipe.tokens, 0);
#endif
+ ti->immd32 = (uint32_t *)MALLOC(ti->scan.immediate_count * 16);
+ ti->immd32_ty = (ubyte *)MALLOC(ti->scan.immediate_count * sizeof(ubyte));
+
tgsi_parse_init(&parse, p->pipe.tokens);
while (!tgsi_parse_end_of_tokens(&parse)) {
tgsi_parse_token(&parse);
@@ -561,6 +565,8 @@ nv50_program_tx(struct nv50_program *p)
out:
if (ti->immd32)
FREE(ti->immd32);
+ if (ti->immd32_ty)
+ FREE(ti->immd32_ty);
FREE(ti);
return ret ? FALSE : TRUE;
}
diff --git a/src/gallium/drivers/nv50/nv50_program.h b/src/gallium/drivers/nv50/nv50_program.h
index 1184d9be3b4..639f06217ed 100644
--- a/src/gallium/drivers/nv50/nv50_program.h
+++ b/src/gallium/drivers/nv50/nv50_program.h
@@ -116,6 +116,7 @@ struct nv50_translation_info {
struct tgsi_shader_info scan;
uint32_t *immd32;
unsigned immd32_nr;
+ ubyte *immd32_ty;
ubyte edgeflag_out;
struct nv50_subroutine subr[NV50_PROG_MAX_SUBROUTINES];
int subr_nr;
diff --git a/src/gallium/drivers/nv50/nv50_tgsi_to_nc.c b/src/gallium/drivers/nv50/nv50_tgsi_to_nc.c
index 27d851e9fdb..141d2cd325f 100644
--- a/src/gallium/drivers/nv50/nv50_tgsi_to_nc.c
+++ b/src/gallium/drivers/nv50/nv50_tgsi_to_nc.c
@@ -1022,7 +1022,15 @@ emit_fetch(struct bld_context *bld, const struct tgsi_full_instruction *insn,
case TGSI_FILE_IMMEDIATE:
assert(idx < bld->ti->immd32_nr);
res = bld_load_imm_u32(bld, bld->ti->immd32[idx * 4 + swz]);
- res->reg.type = type;
+
+ switch (bld->ti->immd32_ty[idx]) {
+ case TGSI_IMM_FLOAT32: res->reg.type = NV_TYPE_F32; break;
+ case TGSI_IMM_UINT32: res->reg.type = NV_TYPE_U32; break;
+ case TGSI_IMM_INT32: res->reg.type = NV_TYPE_S32; break;
+ default:
+ res->reg.type = type;
+ break;
+ }
break;
case TGSI_FILE_INPUT:
res = bld_saved_input(bld, idx, swz);