Repository navigation
rdna2spirv: a pixel shader's k-th colour export goes to its k-th declared SV_Target (SHADER-210, SHADER-213) - #4033
Conversation
|
Tested
|
|
Tested Sparse color exports passed on Linux, RTX 5090, driver 595.99.02, at The SPIR-V passed Vulkan 1.2 validation. A temporary adaptation of the head's draw harness attached one RGBA32F image at the selected output location per draw, with preceding locations unused. This checked each location separately across ten draws. AI-assisted verification. |
|
Tested
AI-assisted (Claude). No game files. |
|
Tested 0b00efc (base Setup: CachyOS, kernel 7.3.5, Mesa 26.3.1, llvm-mc 23.1.5; test programs built from this head. The PR changes only the translator, so the programs are the same as on
The 14 skips are the usual ones on these cards ( CPU:
Not covered: the GPU fixtures are hand-written listings without an OSG1, so on hardware they exercise the unchanged "no OSG1, AI-assisted (Claude Code). No game files. |
|
Tested 0b00efc (PR #4033 head, on top of main aa2988c) on NVIDIA GeForce RTX 5080, driver 580.65.06, Ubuntu 22.04.5 (Linux, Vulkan 1.4.363.1 SDK, llvm-mc 21): pass. The PR only changes Commands and results:
I did not run the full 7,461-test semantic suite or the 1.0.2.1 corpus counts from the PR body (no game data here). AI-assisted run. |
|
Tested
None of the ctest failures come from this PR:
Same limit as @AwkGrep256 noted: the pixel-shader fixtures carry no SV_Target OSG1 ( AI-assisted (Claude Code). No game files. |
|
Whole-corpus check with my own 1.0.2.1 copy (Apple M4, Python 3.15, SPIRV-Tools from Homebrew): pass. Your counts hold exactly, and the rest of the PS corpus is byte-identical, not only an 800-module slice. Method. I ran
So no shader with consecutive targets changes, and the 10,500 in your text is the number of PS that declare an SV_Target. The other 1,601 have none, keep the no-OSG1 path, and are identical. No game data (counts only). AI-assisted. |
slopradish
left a comment
There was a problem hiding this comment.
CPU verification: checked out pull/4033/head in an isolated worktree and ran pytest -q tests/semantic/test_sparse_sv_target.py: 5 passed.
This fixes a real correctness bug with strong evidence: the corpus count (221 PS with non-consecutive SV_Target declarations, all exporting packed mrt0..mrt(k-1)) makes the old mapping unambiguously wrong, and the 5 synthetic tests cover sparse target sets {0,2}, {1,3}, {0,7}, the consecutive case, and the export-past-declarations refusal. The fallback for listings without OSG1 preserves existing GPU fixtures.
The change is properly scoped: it reads the OSG1 through the existing output_signature_full helper rather than adding a second signature parser. Contract table updated with the count and the reasoning. No GPU run from me; hardware behaviour remains the author's measurement. No game files involved.
…ared SV_Target (SHADER-213) Colour exports are packed: a pixel shader that declares SV_Target0 and SV_Target2 exports mrt0 and mrt1. The translator decorated exp mrtN with Location N, so the second value went to render target 1 instead of 2. It now reads the shader's OSG1 (system value 64, SV_Target n in register n) and maps export K to the K-th declared target. The index's outputs list follows, so it names render targets. - Without an OSG1 (hand-written listings, run_gpu_tests.py fixtures), mrtK stays location K. - An export past the declared targets is Unsupported. tests/semantic/test_sparse_sv_target.py covers gaps at 2, 3 and 7, consecutive targets, no signature, and an export past the declared ones. It runs the [0, 2] case through the interpreter. With the old translator, 3 of its 5 tests fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…R-210) The Inputs and outputs row said exp mrtN goes to location N. Counted over the 1.0.2.1 corpus (counts only): - 10,500 pixel shaders have SV_Target outputs, and every one of the 29,290 targets keeps register = semantic index. - 221 of them declare non-consecutive targets, and all 221 export mrt0..mrt(k-1). The k-th export is the k-th declared target, never register N. The row now states the rule, the count and the test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0b00efc to
396c2c7
Compare
|
Rebased onto |
|
Tested Checked sparse color locations with an actual Vulkan readback using the PR’s AI-assisted verification with synthetic inputs. |
|
Tested 396c2c7 on NVIDIA RTX 4080, driver 610.88, Windows 11: pass This is the rebased head on
At the earlier head AI-assisted. |
|
Independent Apple Silicon / MoltenVK check of head
This PR adds no GPU fixture of its own, so the pixel-export behaviour is checked here only by the semantic tests, not on hardware. No code changes, no game data; counts only. AI-assisted. |
Closes SHADER-210 and SHADER-213 (claim: #3918 (comment)).
What was wrong
A pixel shader's colour exports are packed.
exp mrtKwrites the K-th SV_Target the shader declares, not render target K. For example, a shader that declaresSV_Target0andSV_Target2exportsmrt0andmrt1. The translator decoratedmrt1withLocation 1, so the second colour went to render target 1 instead of render target 2.The change
tools/rdna2spirv.py: for a pixel shader,translatereads the sorted SV_Target indices from the OSG1 chunk, using the existingoutput_signature_full(sysv 64). ExportmrtKnow becomes%out_mrt<target>withLocation <target>.Unsupported), rather than guessed.run_gpu_tests.pyfixtures),mrtKstays render target K, as before.tests/semantic/test_sparse_sv_target.py: 5 tests on hand-built OSG1 containers and listings (no game data):{0,2}(run through the fragment emulator: the 2.0 value lands in%out_mrt2),{1,3}and{0,7};3 of the 5 fail on
main.docs/design.md: the "Inputs and outputs" row says exports are packed and gives the corpus count below (SHADER-210).Measured on the 1.0.2.1 corpus (counts only)
mrt0..mrtk-1, one per declared target; none exports past them.spirv-val, and their output locations change in all 221.mainhas today (test_loop_ballot_barrier,test_cmp_class_f64(TEST-853),test_vcmp16_opsel,test_mutations).Note for #3544
@Vonsek's #3544 indexes
mrt_typesby the export index. With this PR, the output name and location use the declared target. If both land, the type lookup should use the same target (self.mrt_targets[k]). Whichever merges second needs a one-line adjustment, and I'm happy to do it.🤖 Generated with Claude Code