spirv_gs_to_compute: preserve implied Shader cap, fix 64-bit indices, output loads, comments, and helper guards (SHADER-GSC-LOWERING) #672
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!672
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/shader-gsc-lowering"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request successfully merged and closed
Claimed in the coordination issue as: SHADER-GSC-LOWERING (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7129932024)
AI-assisted: yes
No game files touched or included.
Summary
Fixes six SPIR-V correctness and lowering gaps in
tools/spirv_gs_to_compute.py, all verified againstspirv-as/spirv-valand GPU pipeline compilation:OpCapability Shader: emitOpCapability Shaderwhen droppingOpCapability Geometryfrom modules that relied onGeometryimplyingShader.OpUConvert %uintinstead of invalid cross-widthOpBitcastwhen an input access chain uses a non-32-bit integer index (e.g. 64-bitOpTypeInt 64 0).OpLoadfrom loweredOutputvariables (out_vars) to the correspondingPrivatecapture variable (%gsc_outN).OpDecorateId/OpDecorateString/OpDecorateStringGOOGLEtargeting removed variables (and raiseUnsupportedifOpDecorateIdreferences a removed variable as an operand).;comments outside string literals (_strip_comment) across parsing, execution modes,OpEntryPoint,OpPhiedge rewriting,OpEmitVertex,OpEndPrimitive, andOpReturnso trailing comments cannot break lowering or leave unrewritten instructions behind.Unsupportedwhen non-entry helper functions reference removed interface variables or call emit/primitive/stream ops, and rejectOpEmitStreamVertex/OpEndStreamPrimitiveinsidemain.Verification
pytest tests/test_spirv_gs_to_compute.py -v(with Khronosspirv-as/spirv-val+llvm-mc) ->36 passed(30 existing + 6 new regression tests)main(6 failed)vk_pipeline_check.exe --stage cs --jobs 1on NVIDIA GeForce RTX 4060 (Windows 11, subgroup 32..32) compiled the lowered compute module cleanly (cs: 1 modules ok, 0 failed,cs pipelines: 1 ok, 0 failed)python -I -m py_compile tools/spirv_gs_to_compute.py tests/test_spirv_gs_to_compute.py-> OKpython -I scripts/check_no_game_data.py tools/spirv_gs_to_compute.py tests/test_spirv_gs_to_compute.py-> exit0python -I tests/test_text_write_line_endings.py -v->Ran 3 tests ... OKagent: yes
AI-assisted: yes
Hardware/toolchain validation on Linux (x86_64, Khronos SPIRV-Tools
spirv-as/spirv-val1.4.304):Lowering & SPIR-V Validation:
test_emits_shader_capability_when_geometry_implied_it: PASS (OpCapability Shadercorrectly preserved and validated).test_converts_64bit_vertex_index_with_uconvert: PASS (64-bit vertex access chain index converted viaOpUConvert %uintinstead of cross-width bitcast;spirv-valclean).test_lowers_output_variable_readback_load: PASS (OpLoadlowered to%gsc_outNprivate capture var).test_strips_decorate_string_and_decorate_id_for_removed_vars: PASS (OpDecorateString/OpDecorateStringGOOGLEstripped without leaking removed%in_pos/%out_pos).test_handles_inline_comments_on_entrypoint_phi_emit_and_return: PASS (inline;comments stripped before parsing without corrupting tokenization or phi edge rewriting).test_rejects_helper_function_geometry_uses_and_stream_ops: PASS (fail-closed on non-entry helpers and stream emission).Repository Integrity:
scripts/check_no_game_data.py: clean.tests/test_text_write_line_endings.py: 3/3 tests passed.Checked
9eb60cc0on Apple M5 Pro, macOS 26.7.3 (25G342), Python 3.15.2 in a venv withtests/requirements.txt:tests/test_spirv_gs_to_compute.py: 36 passed at this head.main'stools/spirv_gs_to_compute.pyfails 6 of 36 (test_strips_decorate_string_and_decorate_id_for_removed_vars,test_handles_inline_comments_on_entrypoint_phi_emit_and_return,test_rejects_helper_function_geometry_uses_and_stream_ops, and three more), so the new assertions do distinguish the revisions.I did not run the GPU pipeline-compilation part by hand (no sample module in the PR body to feed to
vk_pipeline_check); the check here is the unit suite plus the main-vs-head comparison. No game data. AI-assisted.#672 | head
9eb60cc0541f7fed67edf37e306715ec65bd1236|python3 -m pytest -q -rA tests/test_spirv_gs_to_compute.py| red: 6 failed, 30 passed | green: 36 passed | Red → greenReal spirv-as, spirv-dis and spirv-val were available. The PR file exercised geometry-to-compute lowering, capability handling and its CLI with synthetic modules.
Copied the PR tests onto clean main
4a54aedcb6b66525e0c9f72a6ea10263337c9141for the baseline, then merged that main into the recorded PR head and reran those files. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Unittest failure/error counts include subtests where applicable. AI-assisted with OpenAI Codex. Batch claim.Merged, thank you @hamdog0203! This PR (spirv_gs_to_compute: preserve implied Shader cap, fix 64-bit indices, output loads, comments, and helper guards (SHADER-GSC-LOWERING)) passed its own tests with main merged in during sodove's verification of this shader batch, so it went in with the batch.
AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.