diff --git a/tests/semantic/test_salu_wqm32.py b/tests/semantic/test_salu_wqm32.py index 5ab78a0695..3d0f23c391 100644 --- a/tests/semantic/test_salu_wqm32.py +++ b/tests/semantic/test_salu_wqm32.py @@ -5,7 +5,7 @@ Covers both: - Data path (32-bit nibble expansion + SCC) via tools/rdna2spirv.py -> spirv_mini_interp.py. - Lane-mask path (32-lane wave32, 8 quads) via tools/rdna2spirv.py -> spirv_wave_interp.py (vertex stage - uses OpGroupNonUniformShuffle for quad_any; fragment/compute stages are checked for OpGroupNonUniformQuadSwap). + uses OpGroupNonUniformBallot for quad_any; the fragment stage is checked for OpGroupNonUniformQuadSwap). Standard library only; no game data. """ diff --git a/tools/rdna2spirv.py b/tools/rdna2spirv.py index 7e4529e75c..9860d40edb 100644 --- a/tools/rdna2spirv.py +++ b/tools/rdna2spirv.py @@ -7169,11 +7169,10 @@ def wave_mask(self, a): def quad_any(self, v): """This lane's value after whole-quad mode: all ones if any of the 4 lanes of its quad (4n .. 4n+3 of the wave) has `v` non-zero, else 0. A quad never crosses the 32/32 half of a wave64, so a 32-wide subgroup is - exact. Without emulation the subgroup's quad ops do it (the invocations of a quad are 4 consecutive subgroup - invocations; in a fragment shader the 2x2 quad, which on hardware is also 4 consecutive lanes; vertex, - geometry and mesh shaders shuffle, as quad operations are only guaranteed in fragment and compute stages); - emulated, the four lanes' values are read through the exchange buffer. Not handled: an absent invocation in - a partial quad (a compute group whose size is not a multiple of 4) gives an undefined value natively.""" + exact. Without emulation the subgroup's ops do it: in a fragment shader the 2x2 quad, which on hardware is + also 4 consecutive lanes; every other stage ballots, so a partial quad (fewer than 4 of the quad's lanes + running, e.g. 2 active lanes of a 32-lane subgroup) is exact too, as a lane's bit is set only when it is + running with `v` non-zero. Emulated, the four lanes' values are read through the exchange buffer.""" b = self.tmp() self.emit(f"{b} = OpSelect %uint {self.tmp_bool_nz(v)} {self.cu(1)} {self.cu(0)}") if self.emulate: @@ -7202,10 +7201,11 @@ def quad_any(self, v): self.emit(f"{o} = OpBitwiseOr %uint {acc} {sw}") acc = o else: - # Non-fragment stages (CS/VS/GS/MS) can have partial quads (subgroup size or thread count not a multiple - # of 4), where QuadSwap or unguarded shuffles from absent lanes are undefined in SPIR-V. Ballot sets bit l - # iff lane l is running with `v != 0`, so extracting this lane's 4-bit quad nibble is exact on any partial - # subgroup up to 128 lanes without needing GroupNonUniformQuad or any shuffle. + # Non-fragment stages (CS/VS/GS/MS) can have partial quads (fewer than 4 of the quad's lanes running: a + # subgroup or workgroup size not a multiple of 4, or a partial wave, e.g. 2 active lanes of a 32-lane + # subgroup), where QuadSwap or unguarded shuffles from absent lanes are undefined in SPIR-V. Ballot sets + # bit l iff lane l is running with `v != 0`, so extracting this lane's 4-bit quad nibble is exact on any + # partial subgroup up to 128 lanes without needing GroupNonUniformQuad or any shuffle. self.uses_subgroup = self.uses_ballot = True nz = self.tmp_bool_nz(v) bal, widx, word, qoff, shifted, acc = (self.tmp() for _ in range(6))