Repository navigation
spirv_gs_to_compute: capture geometry outputs in helper functions - #8479
Raxstreams wants to merge 4 commits into
Conversation
|
Tested aacc014 on Arch Linux, Python 3.14.10, CPU only: pass — first Linux check. tests/test_spirv_gs_to_compute_bounds.py 9/9 + sibling 36 passed OK. Negative control: base tool → 2 failures (helper-output capture); restored, green again. No game files. AI-assisted. |
Grimkeh
left a comment
There was a problem hiding this comment.
Independent Linux CPU review (aacc0142)
What changed: geometry→compute rewrite remaps loads/stores/access-chains of captured geometry outputs in helper functions (not only the entry point), and always emits OpCapability Shader while dropping a redundant Geometry/Shader capability line from the input.
Checked:
- Diff moves output AccessChain/Load/Store handling earlier so helpers see the private globals.
python3 -I tests/test_spirv_gs_to_compute_bounds.py→ 9 OK.
Looks correct; no game files.
|
Correction to my counts above, verified directly: bounds file 9/9 OK with 2 failures + 1 error on base. The sibling file has 27 tests passing under pytest, not 36 as I wrote. Sorry for the error. No game files. AI-assisted. |
tupacfan04
left a comment
There was a problem hiding this comment.
The direct helper output forms are fixed: tools/spirv_gs_to_compute.py:265-275 retargets helper and entry-point OpLoad/OpStore/OpAccessChain/OpInBoundsAccessChain to the private globals, the private variables precede the first function, and the helper-before/after plus implicit-capability tests pass. Two gaps remain:
- Other helper output uses are still silently passed. The
Unsupportedscan at:303-305is inside themain/main_varsstate, after the helper early return at:276-278:
if state not in ("main", "main_vars"):
out.append(ln)
continue
...
for v in list(in_slot) + list(out_vars) + ...:
if re.search(rf"{re.escape(v)}\b", s):
raise Unsupported(...)A helper line that is not one of the new direct patterns is appended unchanged, even though the original output variable is removed. Reproduced with OpCopyMemory %local %out_pos: the rewritten module still contains it while %out_pos is gone, the pass succeeds, and spirv-val rejects the undefined ID. The same applies to OpPtrAccessChain/OpInBoundsPtrAccessChain (the regex at :271 only matches Op(?:InBounds)?AccessChain), OpCopyMemory, OpCopyObject, OpPhi, OpSelect, a helper-internal OpFunctionCall passing the output pointer, and any unrecognized use. The PR's stated bug is fixed only for the three direct forms; the new test (tests/test_spirv_gs_to_compute_bounds.py:237-263) checks only those.
- Helper emit/terminator operations are not captured.
OpEmitVertex,OpEndPrimitive,OpKill,OpReturnValueand the loop/emit checks (:306-350) are all insidemain/main_vars. A helper that emits (a valid geometry-shader pattern) has itsOpEmitVertexappended unchanged, so theGLComputemodule retains a geometry-only instruction and no capture stores; the new helper test has no emit. At minimum reject these withUnsupported; supporting them requires hoisting the capture out of the main-only path.
Fix: move the for v in ... raise Unsupported scan and the emit/terminator checks above the helper early return (or explicitly support OpPtrAccessChain/OpCopyMemory and hoist emit handling), and add helper negative cases for OpCopyMemory/OpPtrAccessChain and OpEmitVertex/OpEndPrimitive. Synthetic only; no game files. AI-assisted (OpenCode).
|
@tupacfan04 Thanks for the two reproductions. |
|
Tested
|
|
Independent AMD Windows verification of The two checked-in copy fixtures passed with the helper before and after the entry point. SPIRV-Tools 2026.4 validated each original and rewritten module. I ran both the directly rewritten and CLI-rewritten output of each fixture. All four dispatches captured the expected two The focused Python suite passed 10/10. The current converter also reports |
|
Tested
Corpus check: the 195 geometry-stage modules in my locally translated 1.0.2.1 corpus convert 195/195 with both this head and the No game data posted; counts only. AI-assisted. |
TEST validation — Approve (subject to CI going green)Validated on CPU (no GPU, no game files). Synthetic SPIR-V via What changed: Tests added (in
Verification:
Note: Two pre-existing unrelated failures on base ( Recommendation: Approve, subject to CI going green before final merge. |
1 similar comment
TEST validation — Approve (subject to CI going green)Validated on CPU (no GPU, no game files). Synthetic SPIR-V via What changed: Tests added (in
Verification:
Note: Two pre-existing unrelated failures on base ( Recommendation: Approve, subject to CI going green before final merge. |
Claimed in the coordination issue as: geometry output capture in helper functions, following @fuzeofficlal's report. No item ID has been assigned.
Depends on: #8219
What and why
Geometry capture removes the original output variables and emits records from private variables. A helper could still read or write the removed output ID, leaving the converted module invalid. The pass now retargets direct loads, stores and vector-component accesses in helpers and in the entry point to the same private variables. The regression covers helpers placed both before and after the entry point.
The merge with current main was clean. #3326 and #7336 already conflict with the converter on the unchanged main base.
Tested
test_image_atomics_guardandtest_image_store_d16).AI-assisted: yes (Codex).
Checklist
Review follow-up
43b7a51b1also retargets bothOpCopyMemorypointer operands. The pass reportsUnsupportedfor helper-side vertex/primitive emission and helper instructions that still reference a removed interface ID.The previous head emitted an undefined ID for a handwritten geometry module that copies through a function-local variable. The updated CLI passed
spirv-valfor Vulkan 1.0, 1.1 and 1.2. All three outputs captured vertex(2, 3, 0, 1)and metadata(1, 1)on the RTX 3080 Ti with zero validation errors. The focused capture suite passed 37 tests and 5 subtests, including both function orders and rejection paths.