summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/nir
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2015-04-10 15:01:16 -0400
committerRob Clark <[email protected]>2015-04-11 10:43:16 -0400
commitfd65122a900a5779393faa0ede6737fafcb95a27 (patch)
treee45b200d9ed05c56653f9bfa005712c5d9471a44 /src/gallium/auxiliary/nir
parent2faa878f13b414d3c6d1e4c3c7642f8db52d9550 (diff)
gallium/ttn: add support for system values
So far just the system values that freedreno supports, so we may add more later. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/nir')
-rw-r--r--src/gallium/auxiliary/nir/tgsi_to_nir.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c
index 0e871642b88..9d988b06445 100644
--- a/src/gallium/auxiliary/nir/tgsi_to_nir.c
+++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c
@@ -153,6 +153,8 @@ ttn_emit_declaration(struct ttn_compile *c)
} else if (file == TGSI_FILE_ADDRESS) {
c->addr_reg = nir_local_reg_create(b->impl);
c->addr_reg->num_components = 4;
+ } else if (file == TGSI_FILE_SYSTEM_VALUE) {
+ /* Nothing to record for system values. */
} else if (file == TGSI_FILE_SAMPLER) {
/* Nothing to record for samplers. */
} else {
@@ -324,6 +326,38 @@ ttn_src_for_file_and_index(struct ttn_compile *c, unsigned file, unsigned index,
assert(!indirect);
break;
+ case TGSI_FILE_SYSTEM_VALUE: {
+ nir_intrinsic_instr *load;
+ nir_intrinsic_op op;
+ unsigned ncomp = 1;
+
+ switch (c->scan->system_value_semantic_name[index]) {
+ case TGSI_SEMANTIC_VERTEXID_NOBASE:
+ op = nir_intrinsic_load_vertex_id_zero_base;
+ break;
+ case TGSI_SEMANTIC_VERTEXID:
+ op = nir_intrinsic_load_vertex_id;
+ break;
+ case TGSI_SEMANTIC_BASEVERTEX:
+ op = nir_intrinsic_load_base_vertex;
+ break;
+ case TGSI_SEMANTIC_INSTANCEID:
+ op = nir_intrinsic_load_instance_id;
+ break;
+ default:
+ unreachable("bad system value");
+ }
+
+ load = nir_intrinsic_instr_create(b->shader, op);
+ load->num_components = ncomp;
+
+ nir_ssa_dest_init(&load->instr, &load->dest, ncomp, NULL);
+ nir_instr_insert_after_cf_list(b->cf_node_list, &load->instr);
+
+ src = nir_src_for_ssa(&load->dest.ssa);
+ break;
+ }
+
case TGSI_FILE_INPUT:
case TGSI_FILE_CONSTANT: {
nir_intrinsic_instr *load;