Repository navigation
tools: spirv_gs_to_compute.py runs a translated GS as a compute capture pass (SHADER-159) - #1331
Conversation
|
Reviewed d1474ee: 2 findings
Ran: Windows 11, Python 3.13.7, SPIRV-Tools from Vulkan SDK 1.4.363.0, no llvm-mc. Review was AI-assisted (Claude Code). |
|
Tested d1474ee on Windows 11 with llvm-mc 23.1.6 and the SPIR-V tools: |
|
Heads-up on the red which is the failure that made All other checks pass, including both |
… without llvm-mc Review of ItsNotRexed#1331 (kotorvr): - the primitive-count check splits main's entry block, so an OpPhi naming the entry label as a predecessor now names %gsc_body. New test with a hand-built GS that branches in its entry block (spirv-val failed before). - the tests that translate gs_tri.asm are marked @requires_tools, like the other make_shader tests, so they skip instead of erroring without llvm-mc. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @kotorvr, both findings were right. Both are fixed in e420d60, rebased on
Rechecked on the Apple A18 Pro: AI-assisted. No game files. |
d1474ee to
e420d60
Compare
|
Tested e420d60 on RTX 4090 (driver 621.14, 32-wide subgroups), Windows 11 26200: pass
No game files used. AI-assisted run (Claude Code). |
|
M2 data point for the CPU tests (no overlap with the A18 Pro results in the PR body). Apple M2 (Mac mini, Mac14,3), macOS 26.4 (25E246), MoltenVK 1.4.2, Homebrew llvm-mc 23.1.6, Python 3.13.18 in an isolated venv with pytest 9.2.0. Fetched head e420d60 into a separate read-only worktree; no edits and no pushes. pytest tests/test_spirv_gs_to_compute.py on that head: 5 passed in 0.38s. Not run: the PR's native Metal validation (65 random triangles and the fullscreen-triangle draw). This CLT-only Mac has no metal/metalc/metallib utility and no spirv-cross on PATH, so I cannot convert the lowered module to MSL or build a Metal harness here. That is a tooling limitation, not a failure of the patch. No game files. |
… without llvm-mc Review of ItsNotRexed#1331 (kotorvr): - the primitive-count check splits main's entry block, so an OpPhi naming the entry label as a predecessor now names %gsc_body. New test with a hand-built GS that branches in its entry block (spirv-val failed before). - the tests that translate gs_tri.asm are marked @requires_tools, like the other make_shader tests, so they skip instead of erroring without llvm-mc. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
e420d60 to
8a79601
Compare
What and why
Apple GPUs have no geometry stage, so
gs_tri(and the 195$GS_VoxelizeGenericGS) can't run there. @fruvs showed a compute capture pass followed by a draw works forgs_tri. This adds that lowering as a tool:tools/spirv_gs_to_compute.py: it rewrites a translatedGeometrymodule into aGLComputemodule (64x1x1), one invocation per input primitive. The per-vertex inputs (Position, Location N) are read from an input buffer (set 1, binding 0: primitive count, then vec4 data). EachOpEmitVertexcopies the outputs to a record buffer (binding 1). A meta buffer (binding 2) holds each primitive's vertex count and strip ends.PrimitiveIdreads give the primitive, andInvocationIdgives 0. Push constants and set 0 are untouched.--layoutwrites the slot order and sizes. The tool refuses, with a message, what it doesn't handle:Invocations> 1, non-vec4 varyings, whole-array input loads.tests/test_spirv_gs_to_compute.py: translatesgs_tri.asm, lowers it, and checks the layout, the module (no GS opcodes or outputs left, 6 record stores) and spirv-val, plus the command line.docs/design.md: the "Geometry shaders" row says what it does and what's not done.Tested
Apple A18 Pro, macOS 26.6.2, SPIRV-Cross 1.4.363.0, system Metal compiler (MSL 3.1).
gs_trilowered, validated (spirv-val), converted with SPIRV-Cross and run natively:gs_tricopies 6 dwords: the position, then the attribute's xy. All 65 primitives have count 3 and the strip end after vertex 2.run_gpu_tests.pychecks forgs_tri.pytest tests/test_spirv_gs_to_compute.py: 4 passed.Not done here: wiring this into a runtime draw path, GS with cross-lane operations or more than one invocation, and the game's GS (no game files used).
Checklist
docs/design.md.AI-assisted (Claude Code): it wrote the tool and the tests, and ran everything above on the A18 Pro.
🤖 Generated with Claude Code