diff options
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c | 61 | ||||
-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 |
4 files changed, 66 insertions, 33 deletions
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c index 7ce1c976e9c..83a138515b5 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c @@ -2133,17 +2133,12 @@ setup_input(struct ir3_compile *ctx, nir_variable *in) struct ir3_shader_variant *so = ctx->so; unsigned array_len = MAX2(glsl_get_length(in->type), 1); unsigned ncomp = glsl_get_components(in->type); - /* XXX: map loc slots to semantics */ - unsigned semantic_name = in->data.location; - unsigned semantic_index = in->data.index; unsigned n = in->data.driver_location; + unsigned slot = in->data.location; - DBG("; in: %u:%u, len=%ux%u, loc=%u", - semantic_name, semantic_index, array_len, - ncomp, n); + DBG("; in: slot=%u, len=%ux%u, drvloc=%u", + slot, array_len, ncomp, n); - so->inputs[n].semantic = - ir3_semantic_name(semantic_name, semantic_index); so->inputs[n].compmask = (1 << ncomp) - 1; so->inputs[n].inloc = ctx->next_inloc; so->inputs[n].interpolate = 0; @@ -2164,11 +2159,19 @@ setup_input(struct ir3_compile *ctx, nir_variable *in) break; } - for (int i = 0; i < ncomp; i++) { - struct ir3_instruction *instr = NULL; - unsigned idx = (n * 4) + i; + if (ctx->so->type == SHADER_FRAGMENT) { + unsigned semantic_name, semantic_index; + + varying_slot_to_tgsi_semantic(slot, + &semantic_name, &semantic_index); + + so->inputs[n].semantic = + ir3_semantic_name(semantic_name, semantic_index); + + for (int i = 0; i < ncomp; i++) { + struct ir3_instruction *instr = NULL; + unsigned idx = (n * 4) + i; - if (ctx->so->type == SHADER_FRAGMENT) { if (semantic_name == TGSI_SEMANTIC_POSITION) { so->inputs[n].bary = false; so->frag_coord = true; @@ -2208,11 +2211,17 @@ setup_input(struct ir3_compile *ctx, nir_variable *in) instr = create_frag_input(ctx, so->inputs[n].inloc + i - 8, use_ldlv); } - } else { - instr = create_input(ctx->block, idx); - } - ctx->ir->inputs[idx] = instr; + ctx->ir->inputs[idx] = instr; + } + } else if (ctx->so->type == SHADER_VERTEX) { + so->inputs[n].semantic = 0; + for (int i = 0; i < ncomp; i++) { + unsigned idx = (n * 4) + i; + ctx->ir->inputs[idx] = create_input(ctx->block, idx); + } + } else { + compile_error(ctx, "unknown shader type: %d\n", ctx->so->type); } if (so->inputs[n].bary || (ctx->so->type == SHADER_VERTEX)) { @@ -2227,17 +2236,18 @@ setup_output(struct ir3_compile *ctx, nir_variable *out) struct ir3_shader_variant *so = ctx->so; unsigned array_len = MAX2(glsl_get_length(out->type), 1); unsigned ncomp = glsl_get_components(out->type); - /* XXX: map loc slots to semantics */ - unsigned semantic_name = out->data.location; - unsigned semantic_index = out->data.index; + unsigned semantic_name, semantic_index; unsigned n = out->data.driver_location; + unsigned slot = out->data.location; unsigned comp = 0; - DBG("; out: %u:%u, len=%ux%u, loc=%u", - semantic_name, semantic_index, array_len, - ncomp, n); + DBG("; out: slot=%u, len=%ux%u, drvloc=%u", + slot, array_len, ncomp, n); if (ctx->so->type == SHADER_VERTEX) { + varying_slot_to_tgsi_semantic(slot, + &semantic_name, &semantic_index); + switch (semantic_name) { case TGSI_SEMANTIC_POSITION: so->writes_pos = true; @@ -2255,7 +2265,10 @@ setup_output(struct ir3_compile *ctx, nir_variable *out) compile_error(ctx, "unknown VS semantic name: %s\n", tgsi_semantic_names[semantic_name]); } - } else { + } else if (ctx->so->type == SHADER_FRAGMENT) { + frag_result_to_tgsi_semantic(slot, + &semantic_name, &semantic_index); + switch (semantic_name) { case TGSI_SEMANTIC_POSITION: comp = 2; /* tgsi will write to .z component */ @@ -2271,6 +2284,8 @@ setup_output(struct ir3_compile *ctx, nir_variable *out) compile_error(ctx, "unknown FS semantic name: %s\n", tgsi_semantic_names[semantic_name]); } + } else { + compile_error(ctx, "unknown shader type: %d\n", ctx->so->type); } compile_assert(ctx, n < ARRAY_SIZE(so->outputs)); 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; |