diff options
author | Eric Anholt <[email protected]> | 2015-08-04 14:28:02 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2015-09-16 15:03:53 -0400 |
commit | 8fd3e53f3dc40e4013348e63a0cc7a2787410899 (patch) | |
tree | c5bca82d5093d81a4b5ecd7d5232c636dd684761 /src/gallium/drivers/vc4 | |
parent | 7a275fcda8ffa3d69b7be6f356469f4af272a6ad (diff) |
gallium/ttn: Convert to using VARYING_SLOT_* / FRAG_RESULT_*.
This avoids exceeding the size of the .index bitfield since it got
truncated, and should make our NIR look more like the NIR that the rest of
the NIR developers are working on.
v2: split out vc4 updates, first patch uses varying_slot_to_tgsi_semantic()
helper, and second patch does the actual conversion.
v3: add frag_result_to_tgsi_semantic() helper and don't try to map
frag_results to semantic name/index as if they were varying_slot's
v4: use VERT_ATTRIB_ for VS inputs
v5: Fix vc4 build.
Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium/drivers/vc4')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_nir_lower_blend.c | 6 | ||||
-rw-r--r-- | src/gallium/drivers/vc4/vc4_nir_lower_io.c | 13 | ||||
-rw-r--r-- | src/gallium/drivers/vc4/vc4_program.c | 19 |
3 files changed, 28 insertions, 10 deletions
diff --git a/src/gallium/drivers/vc4/vc4_nir_lower_blend.c b/src/gallium/drivers/vc4/vc4_nir_lower_blend.c index 808cbea8fde..f8c3c5f65bf 100644 --- a/src/gallium/drivers/vc4/vc4_nir_lower_blend.c +++ b/src/gallium/drivers/vc4/vc4_nir_lower_blend.c @@ -38,6 +38,7 @@ #include "util/u_format.h" #include "vc4_qir.h" #include "glsl/nir/nir_builder.h" +#include "nir/tgsi_to_nir.h" #include "vc4_context.h" /** Emits a load of the previous fragment color from the tile buffer. */ @@ -400,7 +401,10 @@ vc4_nir_lower_blend_block(nir_block *block, void *state) } } assert(output_var); - unsigned semantic_name = output_var->data.location; + unsigned semantic_name, semantic_index; + + varying_slot_to_tgsi_semantic(output_var->data.location, + &semantic_name, &semantic_index); if (semantic_name != TGSI_SEMANTIC_COLOR) continue; diff --git a/src/gallium/drivers/vc4/vc4_nir_lower_io.c b/src/gallium/drivers/vc4/vc4_nir_lower_io.c index c401415fda7..31ac64b0f7a 100644 --- a/src/gallium/drivers/vc4/vc4_nir_lower_io.c +++ b/src/gallium/drivers/vc4/vc4_nir_lower_io.c @@ -22,6 +22,7 @@ */ #include "vc4_qir.h" +#include "nir/tgsi_to_nir.h" #include "tgsi/tgsi_info.h" #include "glsl/nir/nir_builder.h" @@ -71,8 +72,11 @@ vc4_nir_lower_input(struct vc4_compile *c, nir_builder *b, } } assert(input_var); - int semantic_name = input_var->data.location; - int semantic_index = input_var->data.index; + unsigned semantic_name, semantic_index; + + varying_slot_to_tgsi_semantic(input_var->data.location, + &semantic_name, &semantic_index); + /* All TGSI-to-NIR inputs are vec4. */ assert(intr->num_components == 4); @@ -141,7 +145,10 @@ vc4_nir_lower_output(struct vc4_compile *c, nir_builder *b, } } assert(output_var); - unsigned semantic_name = output_var->data.location; + unsigned semantic_name, semantic_index; + + varying_slot_to_tgsi_semantic(output_var->data.location, + &semantic_name, &semantic_index); if (c->stage == QSTAGE_COORD && (semantic_name != TGSI_SEMANTIC_POSITION && diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c index e002983fdbb..7d59a2f0702 100644 --- a/src/gallium/drivers/vc4/vc4_program.c +++ b/src/gallium/drivers/vc4/vc4_program.c @@ -1412,11 +1412,12 @@ ntq_setup_inputs(struct vc4_compile *c) for (unsigned i = 0; i < num_entries; i++) { nir_variable *var = vars[i]; unsigned array_len = MAX2(glsl_get_length(var->type), 1); - /* XXX: map loc slots to semantics */ - unsigned semantic_name = var->data.location; - unsigned semantic_index = var->data.index; + unsigned semantic_name, semantic_index; unsigned loc = var->data.driver_location; + varying_slot_to_tgsi_semantic(var->data.location, + &semantic_name, &semantic_index); + assert(array_len == 1); (void)array_len; resize_qreg_array(c, &c->inputs, &c->inputs_array_size, @@ -1448,11 +1449,17 @@ ntq_setup_outputs(struct vc4_compile *c) { foreach_list_typed(nir_variable, var, node, &c->s->outputs) { unsigned array_len = MAX2(glsl_get_length(var->type), 1); - /* XXX: map loc slots to semantics */ - unsigned semantic_name = var->data.location; - unsigned semantic_index = var->data.index; + unsigned semantic_name, semantic_index; unsigned loc = var->data.driver_location * 4; + if (c->stage == QSTAGE_FRAG) { + frag_result_to_tgsi_semantic(var->data.location, + &semantic_name, &semantic_index); + } else { + varying_slot_to_tgsi_semantic(var->data.location, + &semantic_name, &semantic_index); + } + assert(array_len == 1); (void)array_len; |