Mesa (master): nv50: support the InstanceID system value
Christoph Bumiller
chrisbmr at kemper.freedesktop.org
Sat Mar 5 13:53:40 UTC 2011
Module: Mesa
Branch: master
Commit: 533bf171d4c926e4ab6fcd0d51396b195b9e024f
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=533bf171d4c926e4ab6fcd0d51396b195b9e024f
Author: Christoph Bumiller <e0425955 at student.tuwien.ac.at>
Date: Sat Mar 5 14:41:08 2011 +0100
nv50: support the InstanceID system value
---
src/gallium/drivers/nv50/nv50_program.c | 17 +++++++++++++++++
src/gallium/drivers/nv50/nv50_program.h | 1 +
src/gallium/drivers/nv50/nv50_tgsi_to_nc.c | 7 +++++++
3 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c
index 1c1a420..a63f9d8 100644
--- a/src/gallium/drivers/nv50/nv50_program.c
+++ b/src/gallium/drivers/nv50/nv50_program.c
@@ -328,10 +328,15 @@ prog_decl(struct nv50_translation_info *ti,
}
break;
case TGSI_FILE_SYSTEM_VALUE:
+ /* For VP/GP inputs, they are put in s[] after the last normal input.
+ * Let sysval_map reflect the order of the sysvals in s[] and fixup later.
+ */
switch (decl->Semantic.Name) {
case TGSI_SEMANTIC_FACE:
break;
case TGSI_SEMANTIC_INSTANCEID:
+ ti->p->vp.attrs[2] |= NV50_3D_VP_GP_BUILTIN_ATTR_EN_INSTANCE_ID;
+ ti->sysval_map[first] = 2;
break;
case TGSI_SEMANTIC_PRIMID:
break;
@@ -392,6 +397,18 @@ nv50_vertprog_prepare(struct nv50_translation_info *ti)
}
}
+ for (i = 0; i < TGSI_SEMANTIC_COUNT; ++i) {
+ switch (ti->sysval_map[i]) {
+ case 2:
+ if (!(ti->p->vp.attrs[2] & NV50_3D_VP_GP_BUILTIN_ATTR_EN_VERTEX_ID))
+ ti->sysval_map[i] = 1;
+ ti->sysval_map[i] = (ti->sysval_map[i] - 1) + num_inputs;
+ break;
+ default:
+ break;
+ }
+ }
+
if (p->vp.psiz < 0x40)
p->vp.psiz = p->out[p->vp.psiz].hw;
diff --git a/src/gallium/drivers/nv50/nv50_program.h b/src/gallium/drivers/nv50/nv50_program.h
index 8f5b517..993e169 100644
--- a/src/gallium/drivers/nv50/nv50_program.h
+++ b/src/gallium/drivers/nv50/nv50_program.h
@@ -111,6 +111,7 @@ struct nv50_translation_info {
ubyte output_file;
ubyte input_map[PIPE_MAX_SHADER_INPUTS][4];
ubyte output_map[PIPE_MAX_SHADER_OUTPUTS][4];
+ ubyte sysval_map[TGSI_SEMANTIC_COUNT];
ubyte interp_mode[PIPE_MAX_SHADER_INPUTS];
int input_access[PIPE_MAX_SHADER_INPUTS][4];
int output_access[PIPE_MAX_SHADER_OUTPUTS][4];
diff --git a/src/gallium/drivers/nv50/nv50_tgsi_to_nc.c b/src/gallium/drivers/nv50/nv50_tgsi_to_nc.c
index 54b78e8..1449cb0 100644
--- a/src/gallium/drivers/nv50/nv50_tgsi_to_nc.c
+++ b/src/gallium/drivers/nv50/nv50_tgsi_to_nc.c
@@ -1159,6 +1159,13 @@ emit_fetch(struct bld_context *bld, const struct tgsi_full_instruction *insn,
case TGSI_FILE_PREDICATE:
res = bld_fetch_global(bld, &bld->pvs[idx][swz]);
break;
+ case TGSI_FILE_SYSTEM_VALUE:
+ res = new_value(bld->pc, bld->ti->input_file, NV_TYPE_U32);
+ res->reg.id = bld->ti->sysval_map[idx];
+ res = bld_insn_1(bld, NV_OP_LDA, res);
+ res = bld_insn_1(bld, NV_OP_CVT, res);
+ res->reg.type = NV_TYPE_F32;
+ break;
default:
NOUVEAU_ERR("illegal/unhandled src reg file: %d\n", src->Register.File);
abort();
More information about the mesa-commit
mailing list