Shaders: lower SV_RenderTargetArrayIndex and SV_ViewportArrayIndex exports #137

Open
github-bot wants to merge 1 commit from github-bot/gh-137 into main AGit
Owner

@⁠davi713albano-coder on GitHub · 2026-11-24 21:46 UTC · original
davi713albano-coder:shader/rt-viewport-index-exports → main · +303 −30 · 4 files · 1 commits · open

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.)

**@⁠davi713albano-coder** on GitHub · 2026-11-24 21:46 UTC · [original](https://github.com/fxceless/victory-fork/pull/137) `davi713albano-coder:shader/rt-viewport-index-exports` → `main` · +303 −30 · 4 files · 1 commits · open ### 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.)*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:36:48 +00:00
Author
Owner

@⁠HAL9000RELOADED on GitHub · 2026-11-25 19:29 UTC · original

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).

**@⁠HAL9000RELOADED** on GitHub · 2026-11-25 19:29 UTC · [original](https://github.com/fxceless/victory-fork/pull/137#issuecomment-7172377392) 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 (https://git.gtahub.st/github/fxceless--victory-fork/pulls/129).
This pull request has changes conflicting with the target branch.
  • crates/victory-shader/src/emit/valu_tests.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/137/head:github-bot/gh-137'
git switch 'github-bot/gh-137'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-137'
git switch 'github-bot/gh-137'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-137'
git switch 'github-bot/gh-137'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-137'
git switch 'main'
git merge --squash 'github-bot/gh-137'
git switch 'main'
git merge --ff-only 'github-bot/gh-137'
git switch 'main'
git merge 'github-bot/gh-137'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.