Fix black sand and terrain in indirect mesh dispatches #45

Closed
github-bot wants to merge 1 commit from github-bot/gh-45 into main AGit
Owner

@⁠PedroRBC on GitHub · 2026-11-30 22:02 UTC · original
fix-mesh-one-dim → main · +34 −6 · 2 files · 1 commits · closed without merging

Fix black sand and terrain in indirect mesh dispatches

Problem

Sand and some terrain render black. The terrain tessellation draws are
indirect mesh dispatches, and they run with zero groups.

Cause

The terrain tessellation shader writes mesh records as (n, 0, 0, 0)
using the console's DISPATCH_MESH_X layout (a count, two reserved
words, and the payload address). Both indirect clamps, the
per-execution one (crates/victory-gpu/src/indirect.rs) and the batched
pass (crates/victory-gpu/src/indirect/batch.rs), clamp y and z with
min(…, 1u). That keeps the zeros, so n * 0 * 0 runs no groups and those
draws come out empty.

Fix

The title's mesh programs are one-dimensional, and a direct mesh dispatch
already runs as (x, 1, 1). Both clamps now treat a record with a nonzero
first count as (n, 1, 1). A record (0, y, z) stays empty. The 65,535
limit and the unfilled-slot check are unchanged.

VICTORY_MESH_ONE_DIM=0 restores the old behaviour. The switch is read
once.

Origin

Written by zeex64 for ReVIctory (f165475). The same fix is in VKtory.
This branch is a cherry-pick onto main, with zeex64's authorship and
date preserved. The port applies the one-dimensional dispatch handling
to both upstream clamps.

Testing

  • RX 6700 XT, Ryzen 5 5600, Proton-CachyOS 11.0
  • CONSOLE=series-x, 1920x1080, headless gamescope, diag profile with
    diagnostics
  • The Windows MSVC diagnostics build succeeded. The first game launch
    stopped during pipeline preparation with 79,231 native pipelines missing.
  • After reusing the pipeline cache from the first launch, the second run
    reached the world and completed the capture window. The screenshot shows
    shaded terrain in a waterfront scene. Beach sand still needs a visual
    check. The game log showed no device removal, unhandled exception, or panic.
**@⁠PedroRBC** on GitHub · 2026-11-30 22:02 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/45) `fix-mesh-one-dim` → `main` · +34 −6 · 2 files · 1 commits · closed without merging # Fix black sand and terrain in indirect mesh dispatches ## Problem Sand and some terrain render black. The terrain tessellation draws are indirect mesh dispatches, and they run with zero groups. ## Cause The terrain tessellation shader writes mesh records as `(n, 0, 0, 0)` using the console's `DISPATCH_MESH_X` layout (a count, two reserved words, and the payload address). Both indirect clamps, the per-execution one (`crates/victory-gpu/src/indirect.rs`) and the batched pass (`crates/victory-gpu/src/indirect/batch.rs`), clamp y and z with `min(…, 1u)`. That keeps the zeros, so `n * 0 * 0` runs no groups and those draws come out empty. ## Fix The title's mesh programs are one-dimensional, and a direct mesh dispatch already runs as `(x, 1, 1)`. Both clamps now treat a record with a nonzero first count as `(n, 1, 1)`. A record `(0, y, z)` stays empty. The 65,535 limit and the unfilled-slot check are unchanged. `VICTORY_MESH_ONE_DIM=0` restores the old behaviour. The switch is read once. ## Origin Written by zeex64 for ReVIctory (`f165475`). The same fix is in VKtory. This branch is a cherry-pick onto `main`, with zeex64's authorship and date preserved. The port applies the one-dimensional dispatch handling to both upstream clamps. ## Testing - RX 6700 XT, Ryzen 5 5600, Proton-CachyOS 11.0 - `CONSOLE=series-x`, 1920x1080, headless gamescope, `diag` profile with `diagnostics` - The Windows MSVC diagnostics build succeeded. The first game launch stopped during pipeline preparation with 79,231 native pipelines missing. - After reusing the pipeline cache from the first launch, the second run reached the world and completed the capture window. The screenshot shows shaded terrain in a waterfront scene. Beach sand still needs a visual check. The game log showed no device removal, unhandled exception, or panic.
The terrain tessellation's own shader stores its mesh records as
(n, 0, 0, 0), the console's DISPATCH_MESH_X layout. Both clamps (one
execution and the batched pass) took y and z at most 1, so a record
with a zero there ran no groups: those draws ran empty and the sand
was shaded black. A record with a nonzero count now runs as (n, 1, 1),
as a direct mesh dispatch always has; (0, y, z) stays empty.

From ReVIctory f165475 (also in VKtory)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 07:42:08 +00:00
Author
Owner

@⁠YaBulochka on GitHub · 2026-12-01 16:44 UTC · original

Confirmed on RDNA3: the sand is no longer black. Thank you.

Setup. RX 7600 XT 8 GB (RDNA3), Ryzen 5 9600X, 30 GB, RADV 26.3.1, GE-Proton11-16, series-s, VICTORY_FSR_HOST=1, VICTORY_OUTPUT=1920x1080, VICTORY_BVH_HARDWARE=0, ray tracing otherwise on. Merged on top of our branch (4cea493 + #67 + our local switches VICTORY_SHADER_OPT=0xffffffff, VICTORY_LOW_MEMORY=0, VICTORY_PROCESS_PRIORITY=high).

Before: on the beach the sand read as a flat black surface, and the same happened to stretches of terrain further out; it looked like a missing texture rather than lighting. After merging this: sand is sand, terrain is there, no black patches in the same spot.

How it was checked: same save, same beach, on foot and in the boat, one run before and one after, switching only this merge (the rest of the tree unchanged). No other switch involved.

For the record, the two things that did not change with it here: the blocky band that appears under a distant boat on the water, and the confetti on clothes. Those are separate in our tree.

No game files, screenshots or captures included.

**@⁠YaBulochka** on GitHub · 2026-12-01 16:44 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/45#issuecomment-7318129745) Confirmed on RDNA3: the sand is no longer black. Thank you. **Setup.** RX 7600 XT 8 GB (RDNA3), Ryzen 5 9600X, 30 GB, RADV 26.3.1, GE-Proton11-16, `series-s`, `VICTORY_FSR_HOST=1`, `VICTORY_OUTPUT=1920x1080`, `VICTORY_BVH_HARDWARE=0`, ray tracing otherwise on. Merged on top of our branch (`4cea493` + #67 + our local switches `VICTORY_SHADER_OPT=0xffffffff`, `VICTORY_LOW_MEMORY=0`, `VICTORY_PROCESS_PRIORITY=high`). **Before:** on the beach the sand read as a flat black surface, and the same happened to stretches of terrain further out; it looked like a missing texture rather than lighting. After merging this: sand is sand, terrain is there, no black patches in the same spot. **How it was checked:** same save, same beach, on foot and in the boat, one run before and one after, switching only this merge (the rest of the tree unchanged). No other switch involved. For the record, the two things that did **not** change with it here: the blocky band that appears under a distant boat on the water, and the confetti on clothes. Those are separate in our tree. No game files, screenshots or captures included.
Author
Owner

@⁠YaBulochka on GitHub · 2026-12-01 17:28 UTC · original

The sand fix works here, but it takes character meshes with it — a controlled revert points straight at this change.

Setup. RX 7600 XT 8 GB (RDNA3), Ryzen 5 9600X, 30 GB, RADV 26.3.1, GE-Proton11-16, series-s, VICTORY_FSR_HOST=1, VICTORY_OUTPUT=1920x1080, VICTORY_BVH_HARDWARE=0, ray tracing otherwise on. Tree: our branch with #67 and #31 merged, plus VICTORY_SHADER_OPT=0xffffffff, VICTORY_LOW_MEMORY=0, VICTORY_PROCESS_PRIORITY=high.

With this merged. The sand and terrain are correct — no more black beach, which is what the PR is for. But characters' meshes explode: triangles shoot out of arms, torso and legs into spikes, on pedestrians in a crowd scene and on the player character close up. It is geometry, not interpolation: visible standing still, no frame generation involved.

With this reverted (git revert -m 1 of the merge, same build, same save, same spot, everything else untouched): meshes are intact again and the sand is black again. Two runs each way.

So on this card the two effects are the same switch, and the mesh explosion is worse than the black sand.

Guess, not measured. Both indirect clamps now keep a one-dimensional count instead of clamping y and z to 1, which is right for the terrain's (n, 0, 0, 0) records. If another of the title's mesh programs writes a genuinely two- or three-dimensional record, that change would now let its y and z through as written, and a wrong group count in a tessellated mesh program is exactly what turns a character into spikes.

If you want more, I can run with VICL-style frame counters — say which switch to watch and I will capture the group counts for the meshes that break.

No game files, screenshots or captures included.

**@⁠YaBulochka** on GitHub · 2026-12-01 17:28 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/45#issuecomment-7319363334) The sand fix works here, but it takes character meshes with it — a controlled revert points straight at this change. **Setup.** RX 7600 XT 8 GB (RDNA3), Ryzen 5 9600X, 30 GB, RADV 26.3.1, GE-Proton11-16, `series-s`, `VICTORY_FSR_HOST=1`, `VICTORY_OUTPUT=1920x1080`, `VICTORY_BVH_HARDWARE=0`, ray tracing otherwise on. Tree: our branch with #67 and #31 merged, plus `VICTORY_SHADER_OPT=0xffffffff`, `VICTORY_LOW_MEMORY=0`, `VICTORY_PROCESS_PRIORITY=high`. **With this merged.** The sand and terrain are correct — no more black beach, which is what the PR is for. But characters' meshes explode: triangles shoot out of arms, torso and legs into spikes, on pedestrians in a crowd scene and on the player character close up. It is geometry, not interpolation: visible standing still, no frame generation involved. **With this reverted** (`git revert -m 1` of the merge, same build, same save, same spot, everything else untouched): meshes are intact again and the sand is black again. Two runs each way. So on this card the two effects are the same switch, and the mesh explosion is worse than the black sand. **Guess, not measured.** Both indirect clamps now keep a one-dimensional count instead of clamping y and z to 1, which is right for the terrain's `(n, 0, 0, 0)` records. If another of the title's mesh programs writes a genuinely two- or three-dimensional record, that change would now let its y and z through as written, and a wrong group count in a tessellated mesh program is exactly what turns a character into spikes. If you want more, I can run with `VICL`-style frame counters — say which switch to watch and I will capture the group counts for the meshes that break. No game files, screenshots or captures included.
github-bot closed this pull request 2026-12-01 19:07:22 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.