Skip to content

Shaders: lower SV_RenderTargetArrayIndex and SV_ViewportArrayIndex exports - #137

Open
davi713albano-coder wants to merge 1 commit into
fxceless:mainfrom
davi713albano-coder:shader/rt-viewport-index-exports
Open

davi713albano-coder wants to merge 1 commit into
fxceless:mainfrom
davi713albano-coder:shader/rt-viewport-index-exports

Conversation

@davi713albano-coder

Copy link
Copy Markdown

Summary

Lowers SV_RenderTargetArrayIndex (kind = 4) and SV_ViewportArrayIndex (kind = 5) from GFX10/RDNA2 exp pos1 (pos1.z & 0xFFFF for render-target array index, pos1.z >> 16 for viewport array index), shifting clip/cull distance exports to pos2..=pos3 when pos1 carries the misc vector.

Changes

  • crates/victory-shader/src/emit/lower.rs:
    • Unpack SV_RenderTargetArrayIndex (low 16 bits) and SV_ViewportArrayIndex (high 16 bits) from pos1.z when the output signature declares either semantic, and shift clip/cull distance exports (kind 6/7) to pos2..=pos3.
    • Set flags::VIEWPORT_RT_INDEX when a non-mesh stage exports kind 4 or 5.
  • crates/victory-shader/src/emit/shader.rs:
    • Add flags::VIEWPORT_RT_INDEX = 1 << 9 in DXIL ShaderFlags metadata and map it to 0x2000 (D3D_SHADER_FEATURE_VIEWPORT_AND_RT_ARRAY_INDEX_FROM_ANY_SHADER_FEEDING_RASTERIZER) in SFI0.
  • crates/victory-shader/src/emit/mod.rs:
    • Declare Constant (1) interpolation mode for kind 4 and 5 alongside SV_IsFrontFace (13).
  • crates/victory-shader/src/emit/valu_tests.rs:
    • Add synthetic vertex-shader test vs_rt_and_viewport_index_exports_validate_and_create_pso covering RT-index-only, viewport-index-only, and combined RT+viewport+clip-distance (pos2) exports against dxil.dll validation, SFI0 (0x2000), and D3D12 graphics PSO creation on WARP.

Verification

  • Fork CI (windows-latest): https://github.com/davi713albano-coder/victory-fork/actions/runs/45492377876
    • cargo clippy --workspace --all-targets --locked -- -D warnings: passed
    • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passed
    • cargo test --workspace --locked (including xtask asset-policy check, dxil.dll validation, and D3D12 WARP PSO creation): 497 passed, 0 failed (emit::valu_tests::vs_rt_and_viewport_index_exports_validate_and_create_pso ... ok)

(No title data used. AI-assisted.)

JustDownTV pushed a commit to JustDownTV/victory-gta6 that referenced this pull request Nov 24, 2026
@HAL9000RELOADED

Copy link
Copy Markdown

RX 7900 XTX (RDNA3), Windows 10 + #402 for SM 6.6, main d510ee4: the new test vs_rt_and_viewport_index_exports_validate_and_create_pso passes on the card with this PR, and fails with the test alone on the base. No other test changed. Run table: #129 (#129 (comment)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants