Shaders: lower SV_RenderTargetArrayIndex and SV_ViewportArrayIndex exports (exp pos1) #914
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 davi713albano-coder on 2026-11-24T14:02:49Z.
Summary
Implements lowering for vertex shader
SV_RenderTargetArrayIndex(kind == 4) andSV_ViewportArrayIndex(kind == 5) exports from RDNA2'sexp pos1misc vector, and shifts clip/cull distance exports topos2..=pos3when the misc vector is present.Because external PR creation is restricted (
collaborators_only), the CI-green branch is ready on my fork:1060727(based onmainffe310e, 4 files, +307/-30)Changes
crates/victory-shader/src/emit/mod.rs: setsConstant(1) interpolation mode onkind == 4(SV_RenderTargetArrayIndex) andkind == 5(SV_ViewportArrayIndex) signature elements, matching DXC.crates/victory-shader/src/emit/shader.rs: addsflags::VIEWPORT_RT_INDEX(1 << 9in DXILShaderFlagsmetadata, mapped to0x2000inSFI0forSHADER_FEATURE_VIEWPORT_AND_RT_ARRAY_INDEX_FROM_ANY_SHADER_FEEDING_RASTERIZER).crates/victory-shader/src/emit/lower.rs:outputsdeclaresSV_RenderTargetArrayIndexand/orSV_ViewportArrayIndex, treatsexp pos1as the GFX9+/RDNA2 misc vector and extractsSV_RenderTargetArrayIndexfrompos1.z & 0xFFFFandSV_ViewportArrayIndexfrompos1.z >> 16, settingflags::VIEWPORT_RT_INDEXfor non-mesh outputs.pos1..=pos2topos2..=pos3when the misc vector is present.crates/victory-shader/src/emit/valu_tests.rs: addsvs_rt_and_viewport_index_exports_validate_and_create_pso.Tests & Verification
vs_rt_and_viewport_index_exports_validate_and_create_psolowers three synthetic GFX10 vertex shaders (RT array index only, viewport array index only, and both packed inpos1.ztogether withSV_ClipDistanceinpos2.x) plus a minimal pixel shader:dxil.dllvalidation with matching container hashes andSFI0 & 0x2000 != 0.Host::pipeline).Verified on GitHub Actions (
windows-latest) using upstreamci.yml(cargo clippy --workspace --all-targets --locked -- -D warnings,--all-features, andcargo test --workspace --lockedincludingxtaskasset-policy check):victory-shader: 121 passed, 0 failed (full workspace: 343 passed, 0 failed, 6 ignored)Not tested: live title execution or multi-slice draw readback.
No game data used. AI-assisted.
Imported from Marvisak/VIctory. Originally posted by DaniiL35 on 2026-11-24T14:07:26Z.
Independent Verification Review: davi713albano-coder:shader/rt-viewport-index-exports (
1060727)Audited RDNA2 misc position vector export lowering and DXIL feature flag emission:
1. RDNA2 Misc Vector & Clip Distance Shift Semantics
SV_RenderTargetArrayIndexandSV_ViewportArrayIndex), they target theexp pos1position slot.pos1.zconforms to RDNA2 hardware specification:Extract::Low16,pos1.z & 0xFFFF):SV_RenderTargetArrayIndex(kind == 4).Extract::High16,pos1.z >> 16via logical shiftBin::LShr):SV_ViewportArrayIndex(kind == 5).has_misc == true), clip/cull distance exports correctly shift frompos1..=pos2topos2..=pos3(first_clip = 2). Channel index computationk = usize::from(n - first_clip) * 4 + usize::from(ch)guarantees correct indexing intoPA_CL_VS_OUT_CNTLdistance allocations.2. DXIL Feature Flag & Container Metadata
crates/victory-shader/src/emit/shader.rs:flags::VIEWPORT_RT_INDEXcorrectly sets bit 9 in DXIL shader flags and maps to0x2000(SHADER_FEATURE_VIEWPORT_AND_RT_ARRAY_INDEX_FROM_ANY_SHADER_FEEDING_RASTERIZER) inSFI0part.crates/victory-shader/src/emit/mod.rs: Setsinterp = 1(Constant) on kind 4 and 5 signature elements, matching DXC signature layouts.3. Test Suite & Policy Invariants
vs_rt_and_viewport_index_exports_validate_and_create_psocovers:pos1.zalongsideSV_ClipDistanceinpos2.xvop1andexp_insthelper byte streams without binary blobs or external files (Rule #1 compliant). DXIL containers validate againstdxil.dlland D3D12 PSO creation succeeds.Ready to merge cleanly onto
main.Imported from Marvisak/VIctory. Originally posted by MichaelSmithAI on 2026-11-24T14:08:52Z.
Multi-slice readback now passes on RTX 4090 under Wine/GE 3.2. On an 8×4 target with two slices, the layer-only shader drew red in the left viewport of slice 1, the viewport-only shader in the right viewport of slice 0, and the combined shader in the right viewport of slice 1. All other pixels matched the clear value. With negative clip distance the selected slice stayed clear. Microsoft DXIL validation passed. Wine mapped the WARP request to the same GPU, so this is one hardware result. The readback regression is on the author branch for review.
On native Windows 10, andrewpozdnakov7-jpg reported that all pixel assertions passed on 4e9847d for the layer-only, viewport-only and combined exports, including negative clip distance. All 14 tests in the VALU group passed. The test executable included Agility 1.620.2 loader exports and used Microsoft’s DXIL validator. Both adapter labels ran on the same forced WARP 1.0.22 software adapter. Reviewer’s native WARP result
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T06:53:57Z.
Automated triage for the maintainers.
This lowers vertex-shader
SV_RenderTargetArrayIndexandSV_ViewportArrayIndexexports fromexp pos1. Onmain(63bcca4) theTarget::Position(1..=2)arm of export lowering incrates/victory-shader/src/emit/lower.rsstill refuses them ("render-target or viewport index exports").PR #1417, which carried this change, was closed without merging on 2026-11-25: the console compiler exports
pos1with all four channels enabled (zeros in x, y and w), and #1417 refused any channel but z, so real programs still failed. The maintainer review also notes that no title program reaches this path onmain.The 2026-11-26 comment offers a follow-up on a fork (
f7c2aac, on #1417's head) that accepts the otherpos1channels only when they are provably zero, with WARP readback tests passing and a clean merge onto63bcca4. No open pull request carries it. Pull requests are open to everyone, so please open one againstmainwith that commit (keeping the original author) rather than asking for #1417 to be reopened; the decision is left to the maintainers.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T03:01:06Z.
The full-mask case from #1417 now has a synthetic before-and-after check. On
2a60d82, all four enabledpos1channels cause translation to stop even when X/Y/W are zero.f7c2aacpasses six WARP readback runs for the layer, viewport and clip-distance cases and also passes on a clean merge with upstream63bcca4. The tested commit is offered in the existing PR discussion.Please retain the follow-up's Git author if you cherry-pick it, or include this trailer if you fold in the fix or tests.
Co-authored-by: andrewpozdnakov7-jpg [email protected]
AI-assisted with Codex.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T08:35:43Z.
Opened #3489 with the full-mask fix and the original authorship preserved. The same synthetic shader fails on
2a60d82and renders into the expected slices and viewports on7987ba8(main63bcca4). The new PR has the results and the current CI.