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

Open
andrewpozdnakov7-jpg wants to merge 3 commits from upstream-pr/3489 into main
andrewpozdnakov7-jpg commented 2026-11-27 08:34:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T08:34:46Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5523635565 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3489). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-27T08:34:46Z. --- ## 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://github.com/Marvisak/VIctory/pull/1417#issuecomment-7181320996) ## 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.
oni-swr commented 2026-11-27 09:37:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-27T09:37:34Z.


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: https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7214169025

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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7214901796 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3489#issuecomment-7214901796). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-27T09:37:34Z. --- **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://github.com/Marvisak/VIctory/issues/1633#issuecomment-7214169025 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.
AurumCarlos commented 2026-11-27 14:06:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AurumCarlos on 2026-11-27T14:06:05Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:Marvisak/VIctory:review:6089339131 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3489#pullrequestreview-6089339131). Originally posted by [AurumCarlos](https://github.com/AurumCarlos) on 2026-11-27T14:06:05Z. **Review:** COMMENTED --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3489:upstream-pr/3489'
git switch 'upstream-pr/3489'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3489'
git switch 'upstream-pr/3489'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3489'
git switch 'upstream-pr/3489'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3489'
git switch 'main'
git merge --squash 'upstream-pr/3489'
git switch 'main'
git merge --ff-only 'upstream-pr/3489'
git switch 'main'
git merge 'upstream-pr/3489'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!3489
No description provided.