On Tue, Aug 4, 2015 at 5:28 PM, Eric Anholt <e...@anholt.net> wrote: > 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. > --- > The freedreno changes here are untested. > > src/gallium/auxiliary/nir/tgsi_to_nir.c | 144 +++++++++++++++-- > src/gallium/auxiliary/nir/tgsi_to_nir.h | 3 + > .../drivers/freedreno/ir3/ir3_compiler_nir.c | 14 +- > src/gallium/drivers/vc4/vc4_context.h | 9 +- > src/gallium/drivers/vc4/vc4_nir_lower_io.c | 18 +-- > src/gallium/drivers/vc4/vc4_opt_dead_code.c | 2 +- > src/gallium/drivers/vc4/vc4_program.c | 174 > +++++++++------------ > src/gallium/drivers/vc4/vc4_qir.c | 2 +- > src/gallium/drivers/vc4/vc4_qir.h | 21 ++- > 9 files changed, 241 insertions(+), 146 deletions(-) > > diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c > b/src/gallium/auxiliary/nir/tgsi_to_nir.c > index 4130697..983d19d 100644 > --- a/src/gallium/auxiliary/nir/tgsi_to_nir.c > +++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c > @@ -93,6 +93,99 @@ struct ttn_compile { > #define ttn_channel(b, src, swiz) \ > nir_swizzle(b, src, SWIZ(swiz, swiz, swiz, swiz), 1, false) > > +static gl_varying_slot > +tgsi_varying_semantic_to_slot(unsigned semantic, unsigned index) > +{ > + switch (semantic) { > + case TGSI_SEMANTIC_POSITION: > + return VARYING_SLOT_POS; > + case TGSI_SEMANTIC_COLOR: > + if (index == 0) > + return VARYING_SLOT_COL0; > + else > + return VARYING_SLOT_COL1; > + case TGSI_SEMANTIC_BCOLOR: > + if (index == 0) > + return VARYING_SLOT_BFC0; > + else > + return VARYING_SLOT_BFC1; > + case TGSI_SEMANTIC_FOG: > + return VARYING_SLOT_FOGC; > + case TGSI_SEMANTIC_PSIZE: > + return VARYING_SLOT_PSIZ; > + case TGSI_SEMANTIC_GENERIC: > + return VARYING_SLOT_VAR0 + index; > + case TGSI_SEMANTIC_FACE: > + return VARYING_SLOT_FACE; > + case TGSI_SEMANTIC_EDGEFLAG: > + return VARYING_SLOT_EDGE; > + case TGSI_SEMANTIC_PRIMID: > + return VARYING_SLOT_PRIMITIVE_ID; > + case TGSI_SEMANTIC_CLIPDIST: > + if (index == 0) > + return VARYING_SLOT_CLIP_DIST0; > + else > + return VARYING_SLOT_CLIP_DIST1; > + case TGSI_SEMANTIC_CLIPVERTEX: > + return VARYING_SLOT_CLIP_VERTEX; > + case TGSI_SEMANTIC_TEXCOORD: > + return VARYING_SLOT_TEX0 + index; > + case TGSI_SEMANTIC_PCOORD: > + return VARYING_SLOT_PNTC; > + case TGSI_SEMANTIC_VIEWPORT_INDEX: > + return VARYING_SLOT_VIEWPORT; > + case TGSI_SEMANTIC_LAYER: > + return VARYING_SLOT_LAYER; > + default: > + fprintf(stderr, "Bad TGSI semantic: %d/%d\n", semantic, index); > + abort(); > + } > +} > + > +void > +varying_slot_to_tgsi_semantic(gl_varying_slot slot, > + unsigned *semantic_name, unsigned > *semantic_index) > +{ > + static const unsigned map[][2] = { > + [VARYING_SLOT_POS] = { TGSI_SEMANTIC_POSITION, 0 }, > + [VARYING_SLOT_COL0] = { TGSI_SEMANTIC_COLOR, 0 }, > + [VARYING_SLOT_COL1] = { TGSI_SEMANTIC_COLOR, 1 }, > + [VARYING_SLOT_BFC0] = { TGSI_SEMANTIC_BCOLOR, 0 }, > + [VARYING_SLOT_BFC1] = { TGSI_SEMANTIC_BCOLOR, 1 }, > + [VARYING_SLOT_FOGC] = { TGSI_SEMANTIC_FOG, 0 }, > + [VARYING_SLOT_PSIZ] = { TGSI_SEMANTIC_PSIZE, 0 }, > + [VARYING_SLOT_FACE] = { TGSI_SEMANTIC_FACE, 0 }, > + [VARYING_SLOT_EDGE] = { TGSI_SEMANTIC_EDGEFLAG, 0 }, > + [VARYING_SLOT_PRIMITIVE_ID] = { TGSI_SEMANTIC_PRIMID, 0 }, > + [VARYING_SLOT_CLIP_DIST0] = { TGSI_SEMANTIC_CLIPDIST, 0 }, > + [VARYING_SLOT_CLIP_DIST1] = { TGSI_SEMANTIC_CLIPDIST, 1 }, > + [VARYING_SLOT_CLIP_VERTEX] = { TGSI_SEMANTIC_CLIPVERTEX, 0 }, > + [VARYING_SLOT_PNTC] = { TGSI_SEMANTIC_PCOORD, 0 }, > + [VARYING_SLOT_VIEWPORT] = { TGSI_SEMANTIC_VIEWPORT_INDEX, 0 }, > + [VARYING_SLOT_LAYER] = { TGSI_SEMANTIC_LAYER, 0 }, > + }; > + > + if (slot >= VARYING_SLOT_VAR0) { > + *semantic_name = TGSI_SEMANTIC_GENERIC; > + *semantic_index = slot - VARYING_SLOT_VAR0; > + return; > + } > + > + if (slot >= VARYING_SLOT_TEX0 && slot <= VARYING_SLOT_TEX7) { > + *semantic_name = TGSI_SEMANTIC_TEXCOORD; > + *semantic_index = slot - VARYING_SLOT_TEX0; > + return; > + } > + > + if (slot >= ARRAY_SIZE(map)) { > + fprintf(stderr, "Unknown varying slot %d\n", slot); > + abort(); > + } > + > + *semantic_name = map[slot][0]; > + *semantic_index = map[slot][1]; > +} > + > static nir_ssa_def * > ttn_src_for_dest(nir_builder *b, nir_alu_dest *dest) > { > @@ -215,12 +308,14 @@ ttn_emit_declaration(struct ttn_compile *c) > var->data.mode = nir_var_shader_in; > var->name = ralloc_asprintf(var, "in_%d", idx); > > - /* We should probably translate to a VERT_ATTRIB_* or > VARYING_SLOT_* > - * instead, but nothing in NIR core is looking at the value > - * currently, and this is less change to drivers. > - */ > - var->data.location = decl->Semantic.Name; > - var->data.index = decl->Semantic.Index; > + if (c->scan->processor == TGSI_PROCESSOR_FRAGMENT) { > + var->data.location = > + tgsi_varying_semantic_to_slot(decl->Semantic.Name, > + decl->Semantic.Index); > + } else { > + var->data.location = idx; > + } > + var->data.index = 0; > > /* We definitely need to translate the interpolation field, > because > * nir_print will decode it. > @@ -240,6 +335,8 @@ ttn_emit_declaration(struct ttn_compile *c) > exec_list_push_tail(&b->shader->inputs, &var->node); > break; > case TGSI_FILE_OUTPUT: { > + int semantic_name = decl->Semantic.Name; > + int semantic_index = decl->Semantic.Index; > /* Since we can't load from outputs in the IR, we make > temporaries > * for the outputs and emit stores to the real outputs at the > end of > * the shader. > @@ -251,14 +348,33 @@ ttn_emit_declaration(struct ttn_compile *c) > > var->data.mode = nir_var_shader_out; > var->name = ralloc_asprintf(var, "out_%d", idx); > - > - var->data.location = decl->Semantic.Name; > - if (decl->Semantic.Name == TGSI_SEMANTIC_COLOR && > - decl->Semantic.Index == 0 && > - > c->scan->properties[TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS]) > - var->data.index = -1; > - else > - var->data.index = decl->Semantic.Index; > + var->data.index = 0; > + > + if (c->scan->processor == TGSI_PROCESSOR_FRAGMENT) { > + switch (semantic_name) { > + case TGSI_SEMANTIC_COLOR: > + if (semantic_index == 1) { > + var->data.location = FRAG_RESULT_DATA0; > + var->data.index = 1; > + } else { > + if > (c->scan->properties[TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS]) > + var->data.location = FRAG_RESULT_COLOR; > + else > + var->data.location = FRAG_RESULT_DATA0; > + }
hmm, this doesn't quite look right for MRT.. At any rate, I'm kinda thinking it is a better idea to revert the patch that changed index to one bit, and then re-apply it again *after* we've managed to work the kinks out of VARYING_SLOT_*/FRAG_RESULT_*... BR, -R > + break; > + case TGSI_SEMANTIC_POSITION: > + var->data.location = FRAG_RESULT_DEPTH; > + break; > + default: > + fprintf(stderr, "Bad TGSI semantic: %d/%d\n", > + decl->Semantic.Name, decl->Semantic.Index); > + abort(); > + } > + } else { > + var->data.location = > + tgsi_varying_semantic_to_slot(semantic_name, > semantic_index); > + } > > if (is_array) { > unsigned j; > diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.h > b/src/gallium/auxiliary/nir/tgsi_to_nir.h > index 687348a..4609ac2 100644 > --- a/src/gallium/auxiliary/nir/tgsi_to_nir.h > +++ b/src/gallium/auxiliary/nir/tgsi_to_nir.h > @@ -28,3 +28,6 @@ struct nir_shader_compiler_options *options; > struct nir_shader * > tgsi_to_nir(const void *tgsi_tokens, > const struct nir_shader_compiler_options *options); > +void > +varying_slot_to_tgsi_semantic(gl_varying_slot slot, > + unsigned *semantic_name, unsigned > *semantic_index); > diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c > b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c > index 53faf16..788add4 100644 > --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c > +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c > @@ -2120,11 +2120,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 semantic_name, semantic_index; > unsigned n = in->data.driver_location; > > + varying_slot_to_tgsi_semantic(in->data.location, > + > &semantic_name, &semantic_index); > + > DBG("; in: %u:%u, len=%ux%u, loc=%u", > semantic_name, semantic_index, array_len, > ncomp, n); > @@ -2214,12 +2215,13 @@ 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 comp = 0; > > + varying_slot_to_tgsi_semantic(in->data.location, > + > &semantic_name, &semantic_index); > + > DBG("; out: %u:%u, len=%ux%u, loc=%u", > semantic_name, semantic_index, array_len, > ncomp, n); > diff --git a/src/gallium/drivers/vc4/vc4_context.h > b/src/gallium/drivers/vc4/vc4_context.h > index 30fb285..14b9eb1 100644 > --- a/src/gallium/drivers/vc4/vc4_context.h > +++ b/src/gallium/drivers/vc4/vc4_context.h > @@ -158,18 +158,17 @@ struct vc4_compiled_shader { > * It doesn't include those that aren't part of the VPM, like > * point/line coordinates. > */ > - struct vc4_varying_semantic *input_semantics; > + struct vc4_varying_slot *input_slots; > }; > > struct vc4_program_stateobj { > struct vc4_uncompiled_shader *bind_vs, *bind_fs; > struct vc4_compiled_shader *cs, *vs, *fs; > uint8_t num_exports; > - /* Indexed by semantic name or TGSI_SEMANTIC_COUNT + semantic index > - * for TGSI_SEMANTIC_GENERIC. Special vs exports (position and > point- > - * size) are not included in this > + /* Indexed by slot. Special vs exports (position and pointsize) are > + * not included in this > */ > - uint8_t export_linkage[63]; > + uint8_t export_linkage[VARYING_SLOT_VAR0 + 8]; > }; > > struct vc4_constbuf_stateobj { > diff --git a/src/gallium/drivers/vc4/vc4_nir_lower_io.c > b/src/gallium/drivers/vc4/vc4_nir_lower_io.c > index ffc120e..9dd46ac 100644 > --- a/src/gallium/drivers/vc4/vc4_nir_lower_io.c > +++ b/src/gallium/drivers/vc4/vc4_nir_lower_io.c > @@ -22,7 +22,6 @@ > */ > > #include "vc4_qir.h" > -#include "tgsi/tgsi_info.h" > #include "glsl/nir/nir_builder.h" > > /** > @@ -69,8 +68,6 @@ 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; > > /* Generate scalar loads equivalent to the original VEC4. */ > nir_ssa_def *dests[4]; > @@ -87,8 +84,7 @@ vc4_nir_lower_input(struct vc4_compile *c, nir_builder *b, > > switch (c->stage) { > case QSTAGE_FRAG: > - switch (semantic_name) { > - case TGSI_SEMANTIC_FACE: > + if (input_var->data.location == VARYING_SLOT_FACE) { > dests[0] = nir_fsub(b, > nir_imm_float(b, 1.0), > nir_fmul(b, > @@ -97,10 +93,10 @@ vc4_nir_lower_input(struct vc4_compile *c, nir_builder *b, > dests[1] = nir_imm_float(b, 0.0); > dests[2] = nir_imm_float(b, 0.0); > dests[3] = nir_imm_float(b, 1.0); > - break; > - case TGSI_SEMANTIC_GENERIC: > + } else if (input_var->data.location >= VARYING_SLOT_VAR0) { > if (c->fs_key->point_sprite_mask & > - (1 << semantic_index)) { > + (1 << (input_var->data.location - > + VARYING_SLOT_VAR0))) { > if (!c->fs_key->is_points) { > dests[0] = nir_imm_float(b, 0.0); > dests[1] = nir_imm_float(b, 0.0); > @@ -113,7 +109,6 @@ vc4_nir_lower_input(struct vc4_compile *c, nir_builder *b, > dests[2] = nir_imm_float(b, 0.0); > dests[3] = nir_imm_float(b, 1.0); > } > - break; > } > break; > case QSTAGE_COORD: > @@ -136,11 +131,10 @@ vc4_nir_lower_output(struct vc4_compile *c, nir_builder > *b, > } > } > assert(output_var); > - unsigned semantic_name = output_var->data.location; > > if (c->stage == QSTAGE_COORD && > - (semantic_name != TGSI_SEMANTIC_POSITION && > - semantic_name != TGSI_SEMANTIC_PSIZE)) { > + output_var->data.location != VARYING_SLOT_POS && > + output_var->data.location != VARYING_SLOT_PSIZ) { > nir_instr_remove(&intr->instr); > return; > } > diff --git a/src/gallium/drivers/vc4/vc4_opt_dead_code.c > b/src/gallium/drivers/vc4/vc4_opt_dead_code.c > index ffd4242..9e79a2d 100644 > --- a/src/gallium/drivers/vc4/vc4_opt_dead_code.c > +++ b/src/gallium/drivers/vc4/vc4_opt_dead_code.c > @@ -69,7 +69,7 @@ has_nonremovable_reads(struct vc4_compile *c, struct qinst > *inst) > } > > if (inst->src[i].file == QFILE_VARY && > - c->input_semantics[inst->src[i].index].semantic == 0xff) > { > + c->input_slots[inst->src[i].index].slot == 0xff) { > return true; > } > } > diff --git a/src/gallium/drivers/vc4/vc4_program.c > b/src/gallium/drivers/vc4/vc4_program.c > index f274298..23bf64b 100644 > --- a/src/gallium/drivers/vc4/vc4_program.c > +++ b/src/gallium/drivers/vc4/vc4_program.c > @@ -30,7 +30,6 @@ > #include "util/ralloc.h" > #include "util/hash_table.h" > #include "tgsi/tgsi_dump.h" > -#include "tgsi/tgsi_info.h" > #include "tgsi/tgsi_lowering.h" > #include "tgsi/tgsi_parse.h" > #include "nir/tgsi_to_nir.h" > @@ -707,41 +706,36 @@ emit_fragcoord_input(struct vc4_compile *c, int attr) > } > > static struct qreg > -emit_fragment_varying(struct vc4_compile *c, uint8_t semantic, > - uint8_t index, uint8_t swizzle) > +emit_fragment_varying(struct vc4_compile *c, gl_varying_slot slot, > + uint8_t swizzle) > { > - uint32_t i = c->num_input_semantics++; > + uint32_t i = c->num_input_slots++; > struct qreg vary = { > QFILE_VARY, > i > }; > > - if (c->num_input_semantics >= c->input_semantics_array_size) { > - c->input_semantics_array_size = > - MAX2(4, c->input_semantics_array_size * 2); > + if (c->num_input_slots >= c->input_slots_array_size) { > + c->input_slots_array_size = > + MAX2(4, c->input_slots_array_size * 2); > > - c->input_semantics = reralloc(c, c->input_semantics, > - struct vc4_varying_semantic, > - c->input_semantics_array_size); > + c->input_slots = reralloc(c, c->input_slots, > + struct vc4_varying_slot, > + c->input_slots_array_size); > } > > - c->input_semantics[i].semantic = semantic; > - c->input_semantics[i].index = index; > - c->input_semantics[i].swizzle = swizzle; > + c->input_slots[i].slot = slot; > + c->input_slots[i].swizzle = swizzle; > > return qir_VARY_ADD_C(c, qir_FMUL(c, vary, qir_FRAG_W(c))); > } > > static void > -emit_fragment_input(struct vc4_compile *c, int attr, > - unsigned semantic_name, unsigned semantic_index) > +emit_fragment_input(struct vc4_compile *c, int attr, gl_varying_slot slot) > { > for (int i = 0; i < 4; i++) { > c->inputs[attr * 4 + i] = > - emit_fragment_varying(c, > - semantic_name, > - semantic_index, > - i); > + emit_fragment_varying(c, slot, i); > c->num_inputs++; > } > } > @@ -749,24 +743,22 @@ emit_fragment_input(struct vc4_compile *c, int attr, > static void > add_output(struct vc4_compile *c, > uint32_t decl_offset, > - uint8_t semantic_name, > - uint8_t semantic_index, > - uint8_t semantic_swizzle) > + uint8_t slot, > + uint8_t swizzle) > { > uint32_t old_array_size = c->outputs_array_size; > resize_qreg_array(c, &c->outputs, &c->outputs_array_size, > decl_offset + 1); > > if (old_array_size != c->outputs_array_size) { > - c->output_semantics = reralloc(c, > - c->output_semantics, > - struct vc4_varying_semantic, > - c->outputs_array_size); > + c->output_slots = reralloc(c, > + c->output_slots, > + struct vc4_varying_slot, > + c->outputs_array_size); > } > > - c->output_semantics[decl_offset].semantic = semantic_name; > - c->output_semantics[decl_offset].index = semantic_index; > - c->output_semantics[decl_offset].swizzle = semantic_swizzle; > + c->output_slots[decl_offset].slot = slot; > + c->output_slots[decl_offset].swizzle = swizzle; > } > > static void > @@ -1177,10 +1169,10 @@ clip_distance_discard(struct vc4_compile *c) > if (!(c->key->ucp_enables & (1 << i))) > continue; > > - struct qreg dist = emit_fragment_varying(c, > - > TGSI_SEMANTIC_CLIPDIST, > - i, > - TGSI_SWIZZLE_X); > + struct qreg dist = > + emit_fragment_varying(c, > + VARYING_SLOT_CLIP_DIST0 + (i / > 4), > + i % 4); > > qir_SF(c, dist); > > @@ -1533,9 +1525,8 @@ emit_ucp_clipdistance(struct vc4_compile *c) > */ > uint32_t output_index = c->num_outputs++; > add_output(c, output_index, > - TGSI_SEMANTIC_CLIPDIST, > - plane, > - TGSI_SWIZZLE_X); > + VARYING_SLOT_CLIP_DIST0 + plane / 4, > + plane % 4); > > > struct qreg dist = qir_uniform_f(c, 0.0); > @@ -1553,7 +1544,7 @@ emit_ucp_clipdistance(struct vc4_compile *c) > > static void > emit_vert_end(struct vc4_compile *c, > - struct vc4_varying_semantic *fs_inputs, > + struct vc4_varying_slot *fs_inputs, > uint32_t num_fs_inputs) > { > struct qreg rcp_w = qir_RCP(c, c->outputs[c->output_position_index + > 3]); > @@ -1568,15 +1559,14 @@ emit_vert_end(struct vc4_compile *c, > emit_point_size_write(c); > > for (int i = 0; i < num_fs_inputs; i++) { > - struct vc4_varying_semantic *input = &fs_inputs[i]; > + struct vc4_varying_slot *input = &fs_inputs[i]; > int j; > > for (j = 0; j < c->num_outputs; j++) { > - struct vc4_varying_semantic *output = > - &c->output_semantics[j]; > + struct vc4_varying_slot *output = > + &c->output_slots[j]; > > - if (input->semantic == output->semantic && > - input->index == output->index && > + if (input->slot == output->slot && > input->swizzle == output->swizzle) { > qir_VPM_WRITE(c, c->outputs[j]); > break; > @@ -1659,9 +1649,6 @@ 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 loc = var->data.driver_location; > > assert(array_len == 1); > @@ -1670,19 +1657,18 @@ ntq_setup_inputs(struct vc4_compile *c) > (loc + 1) * 4); > > if (c->stage == QSTAGE_FRAG) { > - if (semantic_name == TGSI_SEMANTIC_POSITION) { > + if (var->data.location == VARYING_SLOT_POS) { > emit_fragcoord_input(c, loc); > - } else if (semantic_name == TGSI_SEMANTIC_FACE) { > + } else if (var->data.location == VARYING_SLOT_FACE) { > c->inputs[loc * 4 + 0] = > qir_FRAG_REV_FLAG(c); > - } else if (semantic_name == TGSI_SEMANTIC_GENERIC && > + } else if (var->data.location == VARYING_SLOT_VAR0 && > (c->fs_key->point_sprite_mask & > - (1 << semantic_index))) { > + (1 << (var->data.location - > + VARYING_SLOT_VAR0)))) { > c->inputs[loc * 4 + 0] = c->point_x; > c->inputs[loc * 4 + 1] = c->point_y; > } else { > - emit_fragment_input(c, loc, > - semantic_name, > - semantic_index); > + emit_fragment_input(c, loc, > var->data.location); > } > } else { > emit_vertex_input(c, loc); > @@ -1695,43 +1681,37 @@ 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 loc = var->data.driver_location * 4; > > assert(array_len == 1); > (void)array_len; > > - /* NIR hack to pass through > - * TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS */ > - if (semantic_name == TGSI_SEMANTIC_COLOR && > - semantic_index == -1) > - semantic_index = 0; > - > - for (int i = 0; i < 4; i++) { > - add_output(c, > - loc + i, > - semantic_name, > - semantic_index, > - i); > - } > + for (int i = 0; i < 4; i++) > + add_output(c, loc + i, var->data.location, i); > > - switch (semantic_name) { > - case TGSI_SEMANTIC_POSITION: > - c->output_position_index = loc; > - break; > - case TGSI_SEMANTIC_CLIPVERTEX: > - c->output_clipvertex_index = loc; > - break; > - case TGSI_SEMANTIC_COLOR: > - c->output_color_index = loc; > - break; > - case TGSI_SEMANTIC_PSIZE: > - c->output_point_size_index = loc; > - break; > + if (c->stage == QSTAGE_FRAG) { > + switch (var->data.location) { > + case FRAG_RESULT_COLOR: > + case FRAG_RESULT_DATA0: > + c->output_color_index = loc; > + break; > + case FRAG_RESULT_DEPTH: > + c->output_position_index = loc; > + break; > + } > + } else { > + switch (var->data.location) { > + case VARYING_SLOT_POS: > + c->output_position_index = loc; > + break; > + case VARYING_SLOT_CLIP_VERTEX: > + c->output_clipvertex_index = loc; > + break; > + case VARYING_SLOT_PSIZ: > + c->output_point_size_index = loc; > + break; > + } > } > - > } > } > > @@ -1965,10 +1945,10 @@ vc4_shader_ntq(struct vc4_context *vc4, enum qstage > stage, > case QSTAGE_FRAG: > c->fs_key = (struct vc4_fs_key *)key; > if (c->fs_key->is_points) { > - c->point_x = emit_fragment_varying(c, ~0, ~0, 0); > - c->point_y = emit_fragment_varying(c, ~0, ~0, 0); > + c->point_x = emit_fragment_varying(c, ~0, 0); > + c->point_y = emit_fragment_varying(c, ~0, 0); > } else if (c->fs_key->is_lines) { > - c->line_x = emit_fragment_varying(c, ~0, ~0, 0); > + c->line_x = emit_fragment_varying(c, ~0, 0); > } > break; > case QSTAGE_VERT: > @@ -2043,7 +2023,7 @@ vc4_shader_ntq(struct vc4_context *vc4, enum qstage > stage, > break; > case QSTAGE_VERT: > emit_vert_end(c, > - vc4->prog.fs->input_semantics, > + vc4->prog.fs->input_slots, > vc4->prog.fs->num_inputs); > break; > case QSTAGE_COORD: > @@ -2144,7 +2124,7 @@ vc4_get_compiled_shader(struct vc4_context *vc4, enum > qstage stage, > > shader->program_id = vc4->next_compiled_program_id++; > if (stage == QSTAGE_FRAG) { > - bool input_live[c->num_input_semantics]; > + bool input_live[c->num_input_slots]; > > memset(input_live, 0, sizeof(input_live)); > list_for_each_entry(struct qinst, inst, &c->instructions, > link) { > @@ -2154,26 +2134,28 @@ vc4_get_compiled_shader(struct vc4_context *vc4, enum > qstage stage, > } > } > > - shader->input_semantics = ralloc_array(shader, > - struct > vc4_varying_semantic, > - > c->num_input_semantics); > + shader->input_slots = ralloc_array(shader, > + struct vc4_varying_slot, > + c->num_input_slots); > > - for (int i = 0; i < c->num_input_semantics; i++) { > - struct vc4_varying_semantic *sem = > &c->input_semantics[i]; > + for (int i = 0; i < c->num_input_slots; i++) { > + struct vc4_varying_slot *slot = &c->input_slots[i]; > > if (!input_live[i]) > continue; > > /* Skip non-VS-output inputs. */ > - if (sem->semantic == (uint8_t)~0) > + if (slot->slot == (uint8_t)~0) > continue; > > - if (sem->semantic == TGSI_SEMANTIC_COLOR || > - sem->semantic == TGSI_SEMANTIC_BCOLOR) { > + if (slot->slot == VARYING_SLOT_COL0 || > + slot->slot == VARYING_SLOT_COL1 || > + slot->slot == VARYING_SLOT_BFC0 || > + slot->slot == VARYING_SLOT_BFC1) { > shader->color_inputs |= (1 << > shader->num_inputs); > } > > - shader->input_semantics[shader->num_inputs] = *sem; > + shader->input_slots[shader->num_inputs] = *slot; > shader->num_inputs++; > } > } else { > diff --git a/src/gallium/drivers/vc4/vc4_qir.c > b/src/gallium/drivers/vc4/vc4_qir.c > index 1c96ef4..b365b43 100644 > --- a/src/gallium/drivers/vc4/vc4_qir.c > +++ b/src/gallium/drivers/vc4/vc4_qir.c > @@ -152,7 +152,7 @@ qir_has_side_effect_reads(struct vc4_compile *c, struct > qinst *inst) > */ > for (int i = 0; i < qir_get_op_nsrc(inst->op); i++) { > if (inst->src[i].file == QFILE_VARY && > - c->input_semantics[inst->src[i].index].semantic == 0xff) > { > + c->input_slots[inst->src[i].index].slot == 0xff) { > return true; > } > > diff --git a/src/gallium/drivers/vc4/vc4_qir.h > b/src/gallium/drivers/vc4/vc4_qir.h > index 80a1971..99f7781 100644 > --- a/src/gallium/drivers/vc4/vc4_qir.h > +++ b/src/gallium/drivers/vc4/vc4_qir.h > @@ -252,9 +252,8 @@ enum quniform_contents { > QUNIFORM_ALPHA_REF, > }; > > -struct vc4_varying_semantic { > - uint8_t semantic; > - uint8_t index; > +struct vc4_varying_slot { > + uint8_t slot; > uint8_t swizzle; > }; > > @@ -370,21 +369,21 @@ struct vc4_compile { > uint8_t vattr_sizes[8]; > > /** > - * Array of the TGSI semantics of all FS QFILE_VARY reads. > + * Array of the VARYING_SLOT_* of all FS QFILE_VARY reads. > * > * This includes those that aren't part of the VPM varyings, like > * point/line coordinates. > */ > - struct vc4_varying_semantic *input_semantics; > - uint32_t num_input_semantics; > - uint32_t input_semantics_array_size; > + struct vc4_varying_slot *input_slots; > + uint32_t num_input_slots; > + uint32_t input_slots_array_size; > > /** > - * An entry per outputs[] in the VS indicating what the semantic of > - * the output is. Used to emit from the VS in the order that the FS > - * needs. > + * An entry per outputs[] in the VS indicating what the > VARYING_SLOT_* > + * of the output is. Used to emit from the VS in the order that the > + * FS needs. > */ > - struct vc4_varying_semantic *output_semantics; > + struct vc4_varying_slot *output_slots; > > struct pipe_shader_state *shader_state; > struct vc4_key *key; > -- > 2.1.4 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev