diff options
authorNeil Roberts <>2020-06-24 00:16:43 +0200
committerEric Engestrom <>2020-07-06 22:29:39 +0200
commit46c553bed8ad7b276f035f6ae2a1e924fa7d83e3 (patch)
parent6a7e82515707290c947c3be17c024f70aba480dd (diff)
v3d: Use stvpmd for non-uniform offsets in GSstaging/20.1
The offset for the VPM write for storing outputs from the geometry shader isn’t necessarily uniform across all the lanes. This can happen if some of the lanes don’t emit some of the vertices. In that case the offset for the subsequent vertices will be different in each lane. In that case we need to use the stvpmd instruction instead of stvpmv because it will scatter the values out. Closes: Reviewed-by: Iago Toral Quiroga <> Part-of: <> (cherry picked from commit 3b1c511b099e88d1b153de784e3bf7e951a6288f)
2 files changed, 13 insertions, 2 deletions
diff --git a/.pick_status.json b/.pick_status.json
index dbe32e7c39e..0fb9b57792e 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -2416,7 +2416,7 @@
"description": "v3d: Use stvpmd for non-uniform offsets in GS",
"nominated": false,
"nomination_type": null,
- "resolution": 4,
+ "resolution": 1,
"master_sha": null,
"because_sha": null
diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c
index 6219b381d4e..608f7edbdb7 100644
--- a/src/broadcom/compiler/nir_to_vir.c
+++ b/src/broadcom/compiler/nir_to_vir.c
@@ -2027,7 +2027,18 @@ emit_store_output_gs(struct v3d_compile *c, nir_intrinsic_instr *instr)
- vir_VPM_WRITE_indirect(c, ntq_get_src(c, instr->src[0], 0), offset);
+ struct qreg val = ntq_get_src(c, instr->src[0], 0);
+ /* The offset isn’t necessarily dynamically uniform for a geometry
+ * shader. This can happen if the shader sometimes doesn’t emit one of
+ * the vertices. In that case subsequent vertices will be written to
+ * different offsets in the VPM and we need to use the scatter write
+ * instruction to have a different offset for each lane.
+ */
+ if (nir_src_is_dynamically_uniform(instr->src[1]))
+ vir_VPM_WRITE_indirect(c, val, offset);
+ else
+ vir_STVPMD(c, offset, val);
if (vir_in_nonuniform_control_flow(c)) {
struct qinst *last_inst =