gpu: honor console sample masks with guarded pipeline twins #31

Manually merged
github merged 2 commits from github-bot/gh-31 into gh-pr/31/base 2026-12-04 01:57:39 +00:00 AGit
Owner

@⁠oscarrc91 on GitHub · 2026-12-03 17:00 UTC · original
oscarrc91:fix/console-sample-mask → main · +881 −14 · 10 files · 2 commits · merged 2026-12-04 01:57 UTC

The newer command-list OMSetSampleMaskX slot (142 / 0x470) is currently ignored. The title uses complementary masks to fade between object LODs, so ignoring the slot lets both draws cover every pixel. This ports the per-quad coverage implementation from Mandy, including its vertex/mesh position-linkage fixes and synthetic draw tests.

  • Handle the slot on regular and thin command lists; VICTORY_SAMPLE_MASK=0 restores the previous behavior.
  • Pass each 2×2 quad's sample-0 coverage bits through a root constant. Masked pixel shaders discard excluded pixels and omit early depth testing.
  • If a pixel shader has no SV_Position, read it from the row actually written by the preceding vertex/mesh shader.
  • Keep the title shader's identity for skip lists and sampler scopes, with separate shader/PSO cache keys for masked variants and position rows. Plain shader-cache entries retain their existing keys.
  • Create masked twins through ReVIctory's guarded asynchronous compiler queue. The original pipeline is used while a twin is pending; this does not put synchronous driver compilation on the submission thread. Target-format changes reach both variants.

Validation and visual scope

  • Isolated branch based on 631b2ed4f2c3e41b7115198913c857a9310389c7.
  • cargo test --offline --locked --release -p victory-shader --lib mask -- --test-threads=1 --nocapture
  • cargo test --offline --locked --release -p victory-gpu --lib mask -- --test-threads=1 --nocapture
  • Results: shader tests 21 passed; GPU tests 6 passed, with no failures or ignored tests in either suite. These were run in a separate build directory from the reflection-history branch.
  • Synthetic tests cover complementary/empty/full masks, command-list wiring and reset, distinct cache keys, loss of early depth, and vertex/mesh-to-pixel position linkage. The draw tests execute 6 vertex cases and 12 mesh cases per device on an RX 9070 XT and WARP. VICTORY_REQUIRE_GPU_TEST=1 makes missing hardware a failure during local validation; it is not required on normal CI.
  • In the player's local build, logging confirmed that masked variants were used. This patch alone did not remove the static geometric outlines around distant mangroves. Those disappeared only after the helper-lane correction already present in #14 was added, with this mask implementation retained. That observation does not isolate whether both changes were necessary.
  • Masked variants remain demand-compiled; the existing offline warm --used catalog does not enumerate them. Temporary baseline coverage while a twin is pending is a known limitation. No FPS improvement is claimed.

Attribution and existing work

Adapted from NotRexed's ProjectLeonida/mandy commit 0807f9c, itself crediting trustno1-coder/VIctory-NVIDIA commit 0938dd9. The later Mandy synchronous first-use variant is not included: this port retains ReVIctory's guarded compilation path.

Reviewed the existing open and closed ReVIctory PRs. #14 already contains the separate helper-lane correction, and #29 changes placed views, far occlusion and UAV table copies. This PR implements the missing console sample-mask operation; it does not duplicate those changes or claim their visual results.

**@⁠oscarrc91** on GitHub · 2026-12-03 17:00 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/31) `oscarrc91:fix/console-sample-mask` → `main` · +881 −14 · 10 files · 2 commits · merged 2026-12-04 01:57 UTC The newer command-list `OMSetSampleMaskX` slot (142 / `0x470`) is currently ignored. The title uses complementary masks to fade between object LODs, so ignoring the slot lets both draws cover every pixel. This ports the per-quad coverage implementation from Mandy, including its vertex/mesh position-linkage fixes and synthetic draw tests. - Handle the slot on regular and thin command lists; `VICTORY_SAMPLE_MASK=0` restores the previous behavior. - Pass each 2×2 quad's sample-0 coverage bits through a root constant. Masked pixel shaders discard excluded pixels and omit early depth testing. - If a pixel shader has no `SV_Position`, read it from the row actually written by the preceding vertex/mesh shader. - Keep the title shader's identity for skip lists and sampler scopes, with separate shader/PSO cache keys for masked variants and position rows. Plain shader-cache entries retain their existing keys. - Create masked twins through ReVIctory's guarded asynchronous compiler queue. The original pipeline is used while a twin is pending; this does not put synchronous driver compilation on the submission thread. Target-format changes reach both variants. ### Validation and visual scope - Isolated branch based on `631b2ed4f2c3e41b7115198913c857a9310389c7`. - `cargo test --offline --locked --release -p victory-shader --lib mask -- --test-threads=1 --nocapture` - `cargo test --offline --locked --release -p victory-gpu --lib mask -- --test-threads=1 --nocapture` - Results: shader tests **21 passed**; GPU tests **6 passed**, with no failures or ignored tests in either suite. These were run in a separate build directory from the reflection-history branch. - Synthetic tests cover complementary/empty/full masks, command-list wiring and reset, distinct cache keys, loss of early depth, and vertex/mesh-to-pixel position linkage. The draw tests execute 6 vertex cases and 12 mesh cases per device on an RX 9070 XT and WARP. `VICTORY_REQUIRE_GPU_TEST=1` makes missing hardware a failure during local validation; it is not required on normal CI. - In the player's local build, logging confirmed that masked variants were used. **This patch alone did not remove the static geometric outlines around distant mangroves.** Those disappeared only after the helper-lane correction already present in #14 was added, with this mask implementation retained. That observation does not isolate whether both changes were necessary. - Masked variants remain demand-compiled; the existing offline `warm --used` catalog does not enumerate them. Temporary baseline coverage while a twin is pending is a known limitation. No FPS improvement is claimed. ### Attribution and existing work Adapted from [NotRexed's ProjectLeonida/mandy commit 0807f9c](https://github.com/ProjectLeonida/mandy/commit/0807f9cbac04cbc6a72e9a7389a2811579e9ecda), itself crediting `trustno1-coder/VIctory-NVIDIA` commit `0938dd9`. The later Mandy synchronous first-use variant is not included: this port retains ReVIctory's guarded compilation path. Reviewed the existing open and closed ReVIctory PRs. #14 already contains the separate helper-lane correction, and #29 changes placed views, far occlusion and UAV table copies. This PR implements the missing console sample-mask operation; it does not duplicate those changes or claim their visual results.
Translate OMSetSampleMaskX quad coverage on regular and thin lists.
Keep plain shader cache keys stable and link the pixel position to the
vertex or mesh output. Use the existing guarded asynchronous PSO queue.

Ported and adapted from NotRexed's ProjectLeonida/mandy commit
0807f9cbac04cbc6a72e9a7389a2811579e9ecda, which credits
trustno1-coder/VIctory-NVIDIA 0938dd9 (GPL-3.0-or-later).

Include synthetic vertex/mesh draw, quad mask, command-list and cache-key
tests. This is separate from the helper-lane correction in ReVIctory #14.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-03 17:01:48 +00:00
Author
Owner

@⁠staticman256 on GitHub · 2026-12-03 17:36 UTC · original

If this was intended to fix the LOD pop in issue, it doesn't do it.

**@⁠staticman256** on GitHub · 2026-12-03 17:36 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/31#issuecomment-7386772171) If this was intended to fix the LOD pop in issue, it doesn't do it.
Author
Owner

@⁠oscarrc91 on GitHub · 2026-12-03 19:13 UTC · original

Thanks for testing, @⁠staticman256. To clarify the scope: this PR implements the missing OMSetSampleMaskX operation (slot 142 / 0x470). It applies the title's per-quad coverage masks during LOD crossfades. Ignoring those masks lets both LOD draws cover every pixel instead of respecting their complementary coverage.

The intended correction is that missing coverage behavior. It does not change when the game selects an LOD or finishes streaming an object, so it is not a general fix for LOD pop-in.

Our local RX 9070 XT results also have an important limitation: this patch alone did not remove the static geometric outlines around distant mangroves. Those disappeared after adding the separate helper-lane correction already included in #14, while keeping this patch installed. We have not isolated whether both changes were necessary. The synthetic tests validate mask coverage and vertex/mesh-to-pixel position linkage; they do not establish that general gameplay pop-in is fixed.

There is also a first-use limitation: masked pipeline variants compile asynchronously, and the original pipeline is used while a variant is pending, so coverage can temporarily remain unmasked.

Could you share a short clip or the location and build/settings for the pop-in you are seeing? That would help distinguish a coverage problem this implementation still misses from a separate LOD or streaming issue.

**@⁠oscarrc91** on GitHub · 2026-12-03 19:13 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/31#issuecomment-7389351265) Thanks for testing, @⁠staticman256. To clarify the scope: this PR implements the missing `OMSetSampleMaskX` operation (slot 142 / `0x470`). It applies the title's per-quad coverage masks during LOD crossfades. Ignoring those masks lets both LOD draws cover every pixel instead of respecting their complementary coverage. The intended correction is that missing coverage behavior. It does not change when the game selects an LOD or finishes streaming an object, so it is not a general fix for LOD pop-in. Our local RX 9070 XT results also have an important limitation: **this patch alone did not remove the static geometric outlines around distant mangroves**. Those disappeared after adding the separate helper-lane correction already included in #14, while keeping this patch installed. We have not isolated whether both changes were necessary. The synthetic tests validate mask coverage and vertex/mesh-to-pixel position linkage; they do not establish that general gameplay pop-in is fixed. There is also a first-use limitation: masked pipeline variants compile asynchronously, and the original pipeline is used while a variant is pending, so coverage can temporarily remain unmasked. Could you share a short clip or the location and build/settings for the pop-in you are seeing? That would help distinguish a coverage problem this implementation still misses from a separate LOD or streaming issue.
github-bot changed target branch from main to gh-pr/31/base 2026-12-04 01:57:38 +00:00
github manually merged commit 72d0c462dd into gh-pr/31/base 2026-12-04 01:57:39 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.