summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/freedreno
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2015-08-04 14:28:02 -0700
committerEric Anholt <[email protected]>2015-09-16 15:03:53 -0400
commit8fd3e53f3dc40e4013348e63a0cc7a2787410899 (patch)
treec5bca82d5093d81a4b5ecd7d5232c636dd684761 /src/gallium/drivers/freedreno
parent7a275fcda8ffa3d69b7be6f356469f4af272a6ad (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/freedreno')
-rw-r--r--src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c61
1 files changed, 38 insertions, 23 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));