From 70a07ac35269c037adb2b724df28357b7f87efb1 Mon Sep 17 00:00:00 2001 From: Ilia Mirkin Date: Wed, 15 Jan 2014 03:47:48 -0500 Subject: [PATCH] nv50: handle gl_Layer writes in GP Marks gl_Layer as only having one component, and makes sure to keep track of where it is and emit it in the output map, since it is not an input to the FP. Signed-off-by: Ilia Mirkin --- .../drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp | 1 + src/gallium/drivers/nouveau/nv50/nv50_program.c | 5 +++++ src/gallium/drivers/nouveau/nv50/nv50_program.h | 2 ++ src/gallium/drivers/nouveau/nv50/nv50_shader_state.c | 12 +++++++++++- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp index 321410e4d45..33ebb54da97 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp @@ -1030,6 +1030,7 @@ bool Source::scanInstruction(const struct tgsi_full_instruction *inst) if (info->out[dst.getIndex(0)].sn == TGSI_SEMANTIC_PSIZE || info->out[dst.getIndex(0)].sn == TGSI_SEMANTIC_PRIMID || + info->out[dst.getIndex(0)].sn == TGSI_SEMANTIC_LAYER || info->out[dst.getIndex(0)].sn == TGSI_SEMANTIC_FOG) info->out[dst.getIndex(0)].mask &= 1; diff --git a/src/gallium/drivers/nouveau/nv50/nv50_program.c b/src/gallium/drivers/nouveau/nv50/nv50_program.c index f46f240cc3c..82e1b8a2232 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_program.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_program.c @@ -103,6 +103,10 @@ nv50_vertprog_assign_slots(struct nv50_ir_prog_info *info) case TGSI_SEMANTIC_BCOLOR: prog->vp.bfc[info->out[i].si] = i; break; + case TGSI_SEMANTIC_LAYER: + prog->gp.has_layer = true; + prog->gp.layerid = n; + break; default: break; } @@ -331,6 +335,7 @@ nv50_program_translate(struct nv50_program *prog, uint16_t chipset) prog->vp.clpd[1] = map_undef; prog->vp.psiz = map_undef; prog->gp.primid = 0x80; + prog->gp.has_layer = 0; info->driverPriv = prog; diff --git a/src/gallium/drivers/nouveau/nv50/nv50_program.h b/src/gallium/drivers/nouveau/nv50/nv50_program.h index 95167272f44..5b092bde815 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_program.h +++ b/src/gallium/drivers/nouveau/nv50/nv50_program.h @@ -90,6 +90,8 @@ struct nv50_program { uint32_t vert_count; ubyte primid; /* primitive id output register */ uint8_t prim_type; /* point, line strip or tri strip */ + bool has_layer; + ubyte layerid; /* hw value of layer output */ } gp; void *fixups; /* relocation records */ diff --git a/src/gallium/drivers/nouveau/nv50/nv50_shader_state.c b/src/gallium/drivers/nouveau/nv50/nv50_shader_state.c index ff711f96b63..b24e3ac90e6 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_shader_state.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_shader_state.c @@ -346,6 +346,7 @@ nv50_fp_linkage_validate(struct nv50_context *nv50) struct nv50_varying dummy; int i, n, c, m; uint32_t primid = 0; + uint32_t layerid = vp->gp.layerid; uint32_t psiz = 0x000; uint32_t interp = fp->fp.interp; uint32_t colors = fp->fp.colors; @@ -412,6 +413,12 @@ nv50_fp_linkage_validate(struct nv50_context *nv50) map[m++] = vp->gp.primid; } + if (vp->gp.has_layer) { + // In GL4.x, layer can be an fp input, but not in 3.x. Make sure to add + // it to the output map. + map[m++] = layerid; + } + if (nv50->rast->pipe.point_size_per_vertex) { psiz = (m << 4) | 1; map[m++] = vp->vp.psiz; @@ -468,9 +475,12 @@ nv50_fp_linkage_validate(struct nv50_context *nv50) BEGIN_NV04(push, NV50_3D(SEMANTIC_COLOR), 4); PUSH_DATA (push, colors); PUSH_DATA (push, (vp->vp.clpd_nr << 8) | 4); - PUSH_DATA (push, 0); + PUSH_DATA (push, layerid); PUSH_DATA (push, psiz); + BEGIN_NV04(push, NV50_3D(LAYER), 1); + PUSH_DATA (push, vp->gp.has_layer << 16); + BEGIN_NV04(push, NV50_3D(FP_INTERPOLANT_CTRL), 1); PUSH_DATA (push, interp); -- 2.30.2