summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2016-05-23 16:46:46 +1000
committerTimothy Arceri <[email protected]>2016-07-07 10:26:43 +1000
commit0eea6b3297930d36cd510fa6b0e35c91935928f2 (patch)
tree56e7a427bb8f9efa27a0ddbce202a441ea5defd7
parent771f6db76fd051766bc0c7ad590cd4c9c8ecd8a4 (diff)
nir: add new intrinsic field for storing component offset
This offset is used for packing. Reviewed-by: Kenneth Graunke <[email protected]>
-rw-r--r--src/compiler/nir/nir.h6
-rw-r--r--src/compiler/nir/nir_intrinsics.h12
-rw-r--r--src/compiler/nir/nir_lower_io.c8
-rw-r--r--src/compiler/nir/nir_print.c3
4 files changed, 23 insertions, 6 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 94dee4db351..23f7f1f66cf 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -987,6 +987,11 @@ typedef enum {
*/
NIR_INTRINSIC_BINDING = 7,
+ /**
+ * Component offset.
+ */
+ NIR_INTRINSIC_COMPONENT = 8,
+
NIR_INTRINSIC_NUM_INDEX_FLAGS,
} nir_intrinsic_index_flag;
@@ -1053,6 +1058,7 @@ INTRINSIC_IDX_ACCESSORS(ucp_id, UCP_ID, unsigned)
INTRINSIC_IDX_ACCESSORS(range, RANGE, unsigned)
INTRINSIC_IDX_ACCESSORS(desc_set, DESC_SET, unsigned)
INTRINSIC_IDX_ACCESSORS(binding, BINDING, unsigned)
+INTRINSIC_IDX_ACCESSORS(component, COMPONENT, unsigned)
/**
* \group texture information
diff --git a/src/compiler/nir/nir_intrinsics.h b/src/compiler/nir/nir_intrinsics.h
index d88ec3cb58b..ccca1ffbda2 100644
--- a/src/compiler/nir/nir_intrinsics.h
+++ b/src/compiler/nir/nir_intrinsics.h
@@ -336,15 +336,15 @@ LOAD(uniform, 1, 2, BASE, RANGE, xx, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC
/* src[] = { buffer_index, offset }. No const_index */
LOAD(ubo, 2, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
/* src[] = { offset }. const_index[] = { base } */
-LOAD(input, 1, 1, BASE, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
+LOAD(input, 1, 2, BASE, COMPONENT, xx, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
/* src[] = { vertex, offset }. const_index[] = { base } */
-LOAD(per_vertex_input, 2, 1, BASE, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
+LOAD(per_vertex_input, 2, 2, BASE, COMPONENT, xx, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
/* src[] = { buffer_index, offset }. No const_index */
LOAD(ssbo, 2, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
/* src[] = { offset }. const_index[] = { base } */
-LOAD(output, 1, 1, BASE, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
+LOAD(output, 1, 1, BASE, COMPONENT, xx, NIR_INTRINSIC_CAN_ELIMINATE)
/* src[] = { vertex, offset }. const_index[] = { base } */
-LOAD(per_vertex_output, 2, 1, BASE, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
+LOAD(per_vertex_output, 2, 1, BASE, COMPONENT, xx, NIR_INTRINSIC_CAN_ELIMINATE)
/* src[] = { offset }. const_index[] = { base } */
LOAD(shared, 1, 1, BASE, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
/* src[] = { offset }. const_index[] = { base, range } */
@@ -362,9 +362,9 @@ LOAD(push_constant, 1, 2, BASE, RANGE, xx,
INTRINSIC(store_##name, srcs, ARR(0, 1, 1, 1), false, 0, 0, num_indices, idx0, idx1, idx2, flags)
/* src[] = { value, offset }. const_index[] = { base, write_mask } */
-STORE(output, 2, 2, BASE, WRMASK, xx, 0)
+STORE(output, 2, 3, BASE, WRMASK, COMPONENT, 0)
/* src[] = { value, vertex, offset }. const_index[] = { base, write_mask } */
-STORE(per_vertex_output, 3, 2, BASE, WRMASK, xx, 0)
+STORE(per_vertex_output, 3, 3, BASE, WRMASK, COMPONENT, 0)
/* src[] = { value, block_index, offset }. const_index[] = { write_mask } */
STORE(ssbo, 3, 1, WRMASK, xx, xx, 0)
/* src[] = { value, offset }. const_index[] = { base, write_mask } */
diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c
index a8399245b0b..72f1b05e675 100644
--- a/src/compiler/nir/nir_lower_io.c
+++ b/src/compiler/nir/nir_lower_io.c
@@ -274,6 +274,10 @@ nir_lower_io_block(nir_block *block,
nir_intrinsic_set_base(load,
intrin->variables[0]->var->data.driver_location);
+ if (mode == nir_var_shader_in || mode == nir_var_shader_out) {
+ nir_intrinsic_set_component(load,
+ intrin->variables[0]->var->data.location_frac);
+ }
if (load->intrinsic == nir_intrinsic_load_uniform) {
nir_intrinsic_set_range(load,
@@ -322,6 +326,10 @@ nir_lower_io_block(nir_block *block,
nir_intrinsic_set_base(store,
intrin->variables[0]->var->data.driver_location);
+ if (mode == nir_var_shader_out) {
+ nir_intrinsic_set_component(store,
+ intrin->variables[0]->var->data.location_frac);
+ }
nir_intrinsic_set_write_mask(store, nir_intrinsic_write_mask(intrin));
if (per_vertex)
diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
index 36176ece5ef..bca8a3525ed 100644
--- a/src/compiler/nir/nir_print.c
+++ b/src/compiler/nir/nir_print.c
@@ -570,6 +570,7 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state)
[NIR_INTRINSIC_RANGE] = "range",
[NIR_INTRINSIC_DESC_SET] = "desc-set",
[NIR_INTRINSIC_BINDING] = "binding",
+ [NIR_INTRINSIC_COMPONENT] = "component",
};
for (unsigned idx = 1; idx < NIR_INTRINSIC_NUM_INDEX_FLAGS; idx++) {
if (!info->index_map[idx])
@@ -614,6 +615,8 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state)
nir_foreach_variable(var, var_list) {
if ((var->data.driver_location == nir_intrinsic_base(instr)) &&
+ (instr->intrinsic == nir_intrinsic_load_uniform ||
+ var->data.location_frac == nir_intrinsic_component(instr)) &&
var->name) {
fprintf(fp, "\t/* %s */", var->name);
break;