Repository navigation
rdna2spirv: deduplicate vertex inputs per register (SHADER-644) - #3498
sarveshgamers wants to merge 1 commit into
Conversation
When an ISG1 input signature packs multiple semantic elements into the same input register (e.g. .xy and .zw), building g.vertex_inputs directly from the signature produced duplicate entries for that register.
This caused rdna2spirv to emit duplicate %vin{reg} OpVariable declarations, duplicate interface tokens in OpEntryPoint, and duplicate entry-block loads, failing spirv-val with 'Id is defined more than once'.
Deduplicate vertex inputs per register index while verifying that components sharing a register declare consistent component types (rejecting conflicting types with Unsupported).
Add tests/semantic/test_vs_packed_inputs.py covering deduplication, OpEntryPoint/OpVariable/OpDecorate integrity, spirv-val validation, and conflicting-type rejection. Update docs/design.md.
All 7,324 semantic tests pass. AI-assisted.
whattheflop
left a comment
There was a problem hiding this comment.
AI-assisted source review at 4aa29e7c. The per-register deduplication fixes the duplicate SPIR-V IDs for same-type signatures. There is a remaining input-layout issue: runtime/shims/d3d12_vulkan_device.cpp:2643 sets each Vulkan attribute's location from input->register_index. If TEXCOORD0.xy and TEXCOORD1.zw both describe register 0 and the application binds them as separate attributes, the runtime still emits two attributes at location 0, even with this translator fix. The subsequent feed check also accepts one bound attribute as feeding both semantics.
The existing D3D-388 work (#3512, stacked on #3403) overlaps this translator hunk and gives each independently bound semantic a location, then reconstructs the logical register columns. The two approaches should be reconciled before either is used as the end-to-end packed-input fix. A regression that gives the two attributes different buffers or offsets and checks all four independent words distinguishes the fixes. This review used source only and did not submit a duplicate-location pipeline to a driver.
|
Code read at 4aa29e7. The module becomes valid, but I think the data for the second element of a shared register can no longer arrive correctly, so it would be safer to refuse this case than to accept it.
Suggestion: keep it No game files. AI-assisted (Claude Code). |
|
Thank you @whattheflop for the detailed architectural review. Indeed, while this PR addresses the standalone translator issue where duplicate %vin\ variables caused \spirv-val\ failures, your D3D-388 work (#3512) is the complete end-to-end fix that handles separate D3D12 vertex buffer slots and offsets in \d3d12_vulkan_device.cpp\ by assigning per-semantic Vulkan locations. Deferring to #3512 for the full end-to-end packed input solution. Closing in favor of #3512. |
|
Thanks @whattheflop for the detailed architectural review. While this PR addressed the standalone translator duplicate %vin\ ID defect on packed ISG1 containers, #3512 provides the complete end-to-end handling across both the D3D12 runtime (\d3d12_vulkan_device.cpp\ separate slot/offset binding) and translator column routing. Closing in favor of #3512. |
Summary
Fixes SHADER-644: deduplicate vertex inputs per register in
rdna2spirv.py.When an ISG1 input signature packs multiple semantic elements into the same register (e.g.
.xyasTEXCOORD0and.zwasTEXCOORD1), buildingg.vertex_inputsdirectly frominput_signature()produced duplicate entries for that register. This causedrdna2spirvto emit:%vin{reg}tokens in theOpEntryPoint Vertexinterface listOpDecorate %vin{reg} Location {reg}instructions%vin{reg} = OpVariabledeclarations%vinv{reg} = OpLoadand%vinc{reg}_{c} = OpCompositeExtractassignments, failingspirv-valwithId <id> is defined more than once.Changes
tools/rdna2spirv.py:g.vertex_inputsper register index.Unsupportedon type conflicts.tests/semantic/test_vs_packed_inputs.py:spirv-asandspirv-val.Unsupported.docs/design.md:Testing
python -m unittest tests/semantic/test_vs_packed_inputs.py -v: 2/2 tests pass.python -m unittest discover -s tests/semantic -v: all 7,324 semantic tests pass.python -m compileall -q make_game.py tools tests: 0 errors.Claimed in #3232.