Shaders: lower SV_RenderTargetArrayIndex and SV_ViewportArrayIndex exports #1416
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1417"
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?
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-24T17:54:16Z.
Fixes #914.
Summary
SV_RenderTargetArrayIndex(bits 0..15,kind == 4) andSV_ViewportArrayIndex(bits 16..31,kind == 5) from RDNA2'sexp pos1.zmisc vector when declared in the output signature.SV_ClipDistanceandSV_CullDistanceexports topos2..=pos3whenever the misc vector is present (first_clip = 2).Constant(interp = 1) in signatures and set DXILVIEWPORT_RT_INDEX(ShaderFlagsbit 9,SFI00x2000) for non-mesh rasterizer stages.Verification
Texture2DArrayRTV + dual-viewport draw readback tests covering standaloneRTAI, standaloneVPAI, packedRTAI + VPAI + shifted SV_ClipDistance0(+1.0pass /-1.0clipped):dxil.dllvalidation: passedcargo clippy --workspace --all-featuresandcargo xtask policy: passed.Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T17:59:32Z.
Independent verification of \
3296002\ on Windows 11 / AMD Radeon RX 9060 XT (RDNA4, \gfx1200) / Rust 1.98.1 MSVC:AI-assisted; synthetic tests only, no game files.
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T19:25:08Z.
Review: COMMENTED
Static review only — this is a large change (host.rs test infrastructure enumerating all SM 6.6 adapters, MRT draw support,
SV_RenderTargetArrayIndex/SV_ViewportArrayIndexexports packed into bits 0..15/16..31 of a system value) and none of it can run on macOS:cargo test -p victory-shader --lockedstays at 96 passed with no new coverage here. The packing matches the D3D12 semantic (two independent 16-bit fields) and the feature check gates onD3D12_OPTIONSsupport, which is the right call. Before merge I'd want: (1) the Windows CI leg green on the new adapter-enumeration tests, (2) at least one hardware run of the MRT/array-index cases (WARP may not exercise the SV path the same way), and (3) a note on how this interacts with the mesh pipeline linking work in #1563 (both touch export/system-value plumbing).Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-24T20:44:02Z.
Offline measurement on a retail dump, and the shader tests on Ada
Result: no count change against
main.Offline. I merged head
3296002ontomainffe310e(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 21,724 onmain, 21,724 with this PR.No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on
main. The count shows that the change rejects nothing. It does not show whether the output is right.Tests: with the same merge,
cargo test --locked -p victory-shader --libpassed 121, failed 0. The bitcode benchmark is ignored, as onmain, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, withVICTORY_WARPunset.No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:26:43Z.
Automated triage for the maintainers.
Merge candidate. It now merges cleanly with
main. Main refused vertex-stage exports ofSV_RenderTargetArrayIndex/SV_ViewportArrayIndex("render-target or viewport index exports").emit/lower.rsnow takes them from the misc vectorexp pos1.z(layer in the low 16 bits, viewport index in the high 16) and shifts clip/cull distances topos2..pos3when that vector is present.emit/mod.rsandshader.rsmark both semantics constant-interpolated and set theVIEWPORT_RT_INDEXshader flag. The misc-vector packing and the position-export shift match what Mesa's public RDNA export code does, and other channels ofpos1(point size) are still refused rather than guessed. The tests draw into aTexture2DArraywith two viewports and read back each slice. The newHostDevice::adaptersenumeration is test-only.CI: passing (
check).Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:12:52Z.
Automated triage for the maintainers, second look (a review against current
main, with builds and tests where they could change the verdict).Closing because it does not translate what the console compiler emits. Two vertex shaders writing
SV_RenderTargetArrayIndex(one alsoSV_ViewportArrayIndexand a clip distance), compiled with the console compiler, pack(viewport << 16) | layerinto pos1.z as assumed here, but export pos1 with all four channels enabled (zeros in x, y and w). TheTarget::Position(1) if has_miscarm refuses any channel but z, so both containers still fail with this PR; only the refusal reason changes. The GPU test passes because it hand-writes an export with only z enabled. No title program reaches this path onmain.If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T03:01:05Z.
I reproduced the full-mask case from the closing review with a synthetic vertex shader. The fixture enables all four
pos1channels and writes(0, 0, packed, 0). On2a60d82, translation stops at that export with the clip, cull or point-size error.f7c2aac extends that exact head and keeps its Git author. It accepts the other enabled channels only when proven zero. The same test still rejects a nonzero constant and an unknown vertex input in those channels.
Six paired Windows/WARP runs agreed. The patched shader draws into slice 2/viewport 0 for layer only, slice 0/viewport 1 for viewport only, and slice 1/viewport 1 for both. A negative clip distance still leaves all slices clear. The same test passes with the branch merged onto
63bcca4. The VALU, semantics and lowerer suites and strict shader Clippy passed.Could you revisit #1417 with this case? Please retain the follow-up's Git author if you cherry-pick it. If you combine the fix or fixture with another commit, please include:
Co-authored-by: andrewpozdnakov7-jpg [email protected]
AI-assisted with Codex. Synthetic inputs only.
Pull request closed