Shaders: lower full-mask pos1 layer and viewport exports #3489

Open
github-bot wants to merge 3 commits from github-bot/gh-3489 into main AGit
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-27 08:34 UTC · original
andrewpozdnakov7-jpg:codex2/pos1-viewport-layer-exports → main · +542 −72 · 5 files · 3 commits · open

Change

Handle vertex shaders that export render-target layer and viewport index in pos1.z while enabling all four channels. The console compiler uses zero padding in X, Y and W in the two cases reported in #1417. Accept the padding only if the lowering proves that it is zero. Decode the two indices as before and keep clip/cull data in pos2 and pos3 when the misc export is present.

Fixes #914. This replaces the closed #1417 and retains the original implementation commit and author. Closing review and prior verification

Verification

  • The same synthetic full-mask test fails on the closed PR head 2a60d82 at pos1. With the follow-up on main 63bcca4 it passes on app-local WARP with DXIL validation.
  • Pixel readback covers layer only (slice 2, viewport 0), viewport only (slice 0, viewport 1), and both (slice 1, viewport 1). A negative clip distance leaves all slices clear. Nonzero and unknown values in the padding channels still fail lowering.
  • The VALU, lowerer and container groups passed (36, 33 and 1 tests). Strict shader Clippy passed in default and all-features configurations. The asset policy passed.

Please retain the original Git authors if reusing these commits. If folding the full-mask follow-up into another commit, please add Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

AI-assisted with Codex. Synthetic shaders and textures only.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-27 08:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/3489) `andrewpozdnakov7-jpg:codex2/pos1-viewport-layer-exports` → `main` · +542 −72 · 5 files · 3 commits · open ## Change Handle vertex shaders that export render-target layer and viewport index in `pos1.z` while enabling all four channels. The console compiler uses zero padding in X, Y and W in the two cases reported in #1417. Accept the padding only if the lowering proves that it is zero. Decode the two indices as before and keep clip/cull data in `pos2` and `pos3` when the misc export is present. Fixes #914. This replaces the closed #1417 and retains the original implementation commit and author. [Closing review and prior verification](https://git.gtahub.st/github/Marvisak--VIctory/pulls/1417) ## Verification - The same synthetic full-mask test fails on the closed PR head `2a60d82` at `pos1`. With the follow-up on `main` `63bcca4` it passes on app-local WARP with DXIL validation. - Pixel readback covers layer only (slice 2, viewport 0), viewport only (slice 0, viewport 1), and both (slice 1, viewport 1). A negative clip distance leaves all slices clear. Nonzero and unknown values in the padding channels still fail lowering. - The VALU, lowerer and container groups passed (36, 33 and 1 tests). Strict shader Clippy passed in default and all-features configurations. The asset policy passed. Please retain the original Git authors if reusing these commits. If folding the full-mask follow-up into another commit, please add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`. AI-assisted with Codex. Synthetic shaders and textures only.
Extract SV_RenderTargetArrayIndex (bits 0..15) and SV_ViewportArrayIndex (bits 16..31) from RDNA2's exp pos1.z misc vector when declared in the output signature, shift clip and cull distance exports to pos2..=pos3, mark both semantics Constant in signatures, and declare the DXIL VIEWPORT_RT_INDEX feature flag (ShaderFlags bit 9, SFI0 0x2000) for non-mesh rasterizer stages.

Add multi-slice Texture2DArray RTV and multi-viewport draw readback tests across SM 6.6 hardware adapters and WARP.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 08:35:01 +00:00
Author
Owner

@⁠oni-swr on GitHub · 2026-11-27 09:37 UTC · original

Independent Windows/WARP verification of #3489 at 7987ba80ebcafb7c6d6a78336b9652af4e89eca8

Environment: Windows 11 Pro build 10.0.26200, rustc 1.98.1, no physical GPU: VICTORY_WARP=1 and VICTORY_D3D12_WARP=1 (WARP only), dxil.dll 1.8.2502.11 from the Windows SDK 10.0.26100.0. (An older 10.0.19041 dxil.dll rejects SM 6.6: the new test fails with Unknown shader model 'ps_6_6' and many GPU tests crash with an access violation; those runs are discarded.) Base is main 63bcca43c6; all three PR heads (#3487, #3488, #3489) sit directly on it. --locked, separate worktrees for base and head. Claim: #1633

AI-assisted (Claude); I read the diff and the logs before posting. No game files were used. WARP is not hardware, so this says nothing about driver behaviour on AMD or NVIDIA.

Result: no regression found on WARP; the new render test passes and actually draws. I ran every victory-shader lib test in its own process (--exact, 4 at a time, same dxil.dll) on both sides:

  • base: 298 ok, 4 failed, 3 ignored (305 tests).
  • head: 299 ok, 4 failed, 3 ignored (306 tests). The only difference between the two lists is the new emit::valu_tests::vs_rt_and_viewport_array_index_exports_render_across_slices_and_viewports, which passes. WARP reports supported=true for VP/RT array index from a VS, so the test takes the draw path (3 slices, 2 viewports) instead of skipping.
  • The 4 failures are identical on base and head, so none is new: synthetic_tests::a_mask_joined_with_data_at_a_uniform_loop_is_its_number, gathers_at_a_level_match_the_hardware, permutes_mask_high_address_bits_and_divergent_branches, permutes_read_the_lane_named_and_zero_from_lanes_left_out. They concern lane/wave behaviour on WARP, which this PR does not touch.
  • tests/resource_tracking.rs passes on both (3 passed, 1 ignored).

Diff read (no defect found): pos1.z is split into render-target index (low 16 bits) and viewport index (high 16 bits) and sets a new VIEWPORT_RT_INDEX flag (shader feature bit 0x2000) for non-mesh stages. Clip/cull exports move from pos1/pos2 to pos2/pos3 when the misc vector exists. A non-zero pos1.x/y/w still returns "clip, cull or point-size exports" (the test asserts it), so a point-size export stays unsupported, as before. Hosts without VPAndRTArrayIndexFromAnyShaderFeedingRasterizerSupportedWithoutGSEmulation are skipped by the test, and a real AMD or NVIDIA driver was not checked here; that needs hardware.

**@⁠oni-swr** on GitHub · 2026-11-27 09:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/3489#issuecomment-7214901796) **Independent Windows/WARP verification of #3489 at `7987ba80ebcafb7c6d6a78336b9652af4e89eca8`** Environment: Windows 11 Pro build 10.0.26200, rustc 1.98.1, no physical GPU: `VICTORY_WARP=1` and `VICTORY_D3D12_WARP=1` (WARP only), `dxil.dll` 1.8.2502.11 from the Windows SDK 10.0.26100.0. (An older 10.0.19041 `dxil.dll` rejects SM 6.6: the new test fails with `Unknown shader model 'ps_6_6'` and many GPU tests crash with an access violation; those runs are discarded.) Base is `main` 63bcca43c6a00a758510398fa43096ce7e4f7df0; all three PR heads (#3487, #3488, #3489) sit directly on it. `--locked`, separate worktrees for base and head. Claim: https://git.gtahub.st/github/Marvisak--VIctory/issues/1633 AI-assisted (Claude); I read the diff and the logs before posting. No game files were used. WARP is not hardware, so this says nothing about driver behaviour on AMD or NVIDIA. **Result: no regression found on WARP; the new render test passes and actually draws.** I ran every `victory-shader` lib test in its own process (`--exact`, 4 at a time, same `dxil.dll`) on both sides: - base: 298 ok, 4 failed, 3 ignored (305 tests). - head: 299 ok, 4 failed, 3 ignored (306 tests). The only difference between the two lists is the new `emit::valu_tests::vs_rt_and_viewport_array_index_exports_render_across_slices_and_viewports`, which passes. WARP reports `supported=true` for VP/RT array index from a VS, so the test takes the draw path (3 slices, 2 viewports) instead of skipping. - The 4 failures are identical on base and head, so none is new: `synthetic_tests::a_mask_joined_with_data_at_a_uniform_loop_is_its_number`, `gathers_at_a_level_match_the_hardware`, `permutes_mask_high_address_bits_and_divergent_branches`, `permutes_read_the_lane_named_and_zero_from_lanes_left_out`. They concern lane/wave behaviour on WARP, which this PR does not touch. - `tests/resource_tracking.rs` passes on both (3 passed, 1 ignored). **Diff read (no defect found):** `pos1.z` is split into render-target index (low 16 bits) and viewport index (high 16 bits) and sets a new `VIEWPORT_RT_INDEX` flag (shader feature bit `0x2000`) for non-mesh stages. Clip/cull exports move from `pos1/pos2` to `pos2/pos3` when the misc vector exists. A non-zero `pos1.x/y/w` still returns `"clip, cull or point-size exports"` (the test asserts it), so a point-size export stays unsupported, as before. Hosts without `VPAndRTArrayIndexFromAnyShaderFeedingRasterizerSupportedWithoutGSEmulation` are skipped by the test, and a real AMD or NVIDIA driver was not checked here; that needs hardware.
Author
Owner

@⁠AurumCarlos on GitHub · 2026-11-27 14:06 UTC · original · reviewed

The full-mask handling is right: the padding is accepted only when konst proves it zero, pos1.z splits into layer (low 16) and viewport (high 16), and the clip/cull distances move to pos2/pos3 with the misc vector. But #1417 was closed for two reasons, and only the first is answered here. The triage's second one still holds: "No title program reaches this path on main." The new evidence is again synthetic (WARP readback of a hand-written export), so this is likely to be closed the same way.

Suggested next step, which settles it either way: on 63bcca4, run the translator over the title's shaders and look for main's refusal for this path (lower.rs:10002):

victory translate <game dir>

and look for render-target or viewport index exports in the summary (or per program with --list). If it is there, quote the count (and a container hash from --list) in the description and the triage objection goes away. If it is absent, nothing in the title needs this yet, and it would be better parked until a program does.

**@⁠AurumCarlos** on GitHub · 2026-11-27 14:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/3489#pullrequestreview-6089339131) · **reviewed** The full-mask handling is right: the padding is accepted only when `konst` proves it zero, `pos1.z` splits into layer (low 16) and viewport (high 16), and the clip/cull distances move to `pos2`/`pos3` with the misc vector. But #1417 was closed for two reasons, and only the first is answered here. The triage's second one still holds: "No title program reaches this path on `main`." The new evidence is again synthetic (WARP readback of a hand-written export), so this is likely to be closed the same way. Suggested next step, which settles it either way: on `63bcca4`, run the translator over the title's shaders and look for `main`'s refusal for this path (`lower.rs:10002`): ``` victory translate <game dir> ``` and look for `render-target or viewport index exports` in the summary (or per program with `--list`). If it is there, quote the count (and a container hash from `--list`) in the description and the triage objection goes away. If it is absent, nothing in the title needs this yet, and it would be better parked until a program does.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3489'
git switch 'github-bot/gh-3489'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3489'
git switch 'github-bot/gh-3489'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3489'
git switch 'main'
git merge --squash 'github-bot/gh-3489'
git switch 'main'
git merge --ff-only 'github-bot/gh-3489'
git switch 'main'
git merge 'github-bot/gh-3489'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3489
No description provided.