Mesh fallback for GPUs without mesh shaders #1555

Open
github-bot wants to merge 15 commits from github-bot/gh-1555 into main AGit
Owner

@⁠tarekmania on GitHub · 2026-11-28 21:39 UTC · original
tarekmania:station/mesh-fallback → main · +2022 −23 · 13 files · 15 commits · open

On GPUs without mesh shaders (GTX 10, RX 5000 and older) mesh pipelines were refused, so most world geometry was missing (#1201).

The mesh program now runs there as a compute shader that writes its vertices and primitives to a buffer, and a vertex shader draws them with the title's pixel shader. Covers direct and indirect mesh dispatches. On by default when the GPU has no mesh shaders; VICTORY_MESH_FALLBACK=1 forces it, 0 turns it off. Details in docs/mesh-fallback.md.

Tests: on WARP the fallback draws what the mesh shader draws; layout and vertex shader unit tests.

Also fixes two clippy lints in victory-shader (an unused colour, a manual checked division).

**@⁠tarekmania** on GitHub · 2026-11-28 21:39 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1555) `tarekmania:station/mesh-fallback` → `main` · +2022 −23 · 13 files · 15 commits · open On GPUs without mesh shaders (GTX 10, RX 5000 and older) mesh pipelines were refused, so most world geometry was missing (#1201). The mesh program now runs there as a compute shader that writes its vertices and primitives to a buffer, and a vertex shader draws them with the title's pixel shader. Covers direct and indirect mesh dispatches. On by default when the GPU has no mesh shaders; `VICTORY_MESH_FALLBACK=1` forces it, `0` turns it off. Details in `docs/mesh-fallback.md`. Tests: on WARP the fallback draws what the mesh shader draws; layout and vertex shader unit tests. Also fixes two clippy lints in victory-shader (an unused `colour`, a manual checked division).
translate_mesh_as_compute lowers a console mesh program as a compute
shader with the same group: vertex and primitive outputs and indices go
to the root UAV u251 (SLOT_MESH_OUT), one record per group, every
primitive culled first; the record layout travels in a PRIV part.
mesh_fallback_vs builds the vertex shader that draws those records,
three vertices per primitive slot, its outputs laid out as the pixel
shader's inputs. Tests: layout round trip, output matching, translation,
and on Windows a draw through the fallback compared with the mesh
shader's picture.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013bCj55u6XG2pjC4gd5kuv5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013bCj55u6XG2pjC4gd5kuv5
On a host without mesh shaders (or with VICTORY_MESH_FALLBACK=1) a mesh
pipeline becomes the mesh program as a compute pipeline plus a graphics
pipeline of the fallback vertex shader and the title's pixel shader.
A mesh dispatch binds the compute half with the mesh stage's root
arguments, writes the records into a per-list buffer, then draws them;
large dispatches go in parts. Indirect mesh records are clamped as
before and turned into an indirect dispatch and draw each.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013bCj55u6XG2pjC4gd5kuv5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013bCj55u6XG2pjC4gd5kuv5
An unused colour flag left beside the one #428 brought, and a manual
checked division.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013bCj55u6XG2pjC4gd5kuv5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013bCj55u6XG2pjC4gd5kuv5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013bCj55u6XG2pjC4gd5kuv5
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 21:43:09 +00:00
Every record of an indirect mesh draw was its own dispatch, barrier and
draw, over all slots up to the title's maximum, so a draw of thousands of
slots stalled the GPU for seconds (a GTX 1080 Ti froze at the end of
loading, #1201). The argument pass now scans the records' group counts so
each record writes at its own place in the output buffer
(USER_MESH_RECORD_BASE, set per record by the command signature), and
all records run as one indirect dispatch, one barrier and one indirect
draw.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013bCj55u6XG2pjC4gd5kuv5
On a GTX 1080 Ti the batched records (one dispatch call, one draw call)
stopped the first frame that draws them, while records one after the
other drew the world at 1 to 2 fps until a command list ran out of
memory. One after the other is the default again, leaner: both halves are
bound once and each record adds only the two pipelines, two barriers and
its two indirect calls. The batched form stays for testing behind
VICTORY_MESH_BATCH=1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013bCj55u6XG2pjC4gd5kuv5
Every host list that drew mesh programs kept its own output buffer (32
MiB for any indirect mesh draw) for as long as it lived, and the host
makes over a thousand lists: on a GTX 1080 Ti 17 GB of the card's memory
was in use for its 11 when a list failed to close (E_OUTOFMEMORY), and
the frames before stalled on memory moved to the PC. A list now gives its
buffers back when it is reset or dropped, for the next list that draws
mesh programs (up to 256 MiB kept), and the output buffer holds 8 MiB at
most (indirect records asked for some 300 groups at most).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013bCj55u6XG2pjC4gd5kuv5
Resolved against main: the masked pixel translations, the pair-miss and
view-address root views, the three-dimensional mesh grid (the fallback
draws a dispatch's first row: the program reads only that dimension),
the clamp's wait. The fallback's output buffer moves to slot 249, off
SLOT_SAMPLED's 251. The argument pass is made aside like the clamps.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013bCj55u6XG2pjC4gd5kuv5
A draw that covers no pixel and stores nothing changes nothing, so the
fallback's dispatch, barrier and draw for it are saved. Ported from
PascalRebirth's can_discard_clipped_ngg. VICTORY_MESH_DISCARD_EMPTY=0
keeps them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013bCj55u6XG2pjC4gd5kuv5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013bCj55u6XG2pjC4gd5kuv5
Under a sample mask prepare_for binds the pipeline's masked twin, whose
root signature differs. The loop then set the plain pipeline's state
under it (debug layer id 201 at ExecuteIndirect), and the card was lost
seconds after the first masked twin was made.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013bCj55u6XG2pjC4gd5kuv5
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host.rs
  • crates/victory-gpu/src/pipeline/host.rs
  • crates/victory-shader/src/emit/mod.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/1555/head:github-bot/gh-1555'
git switch 'github-bot/gh-1555'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1555'
git switch 'github-bot/gh-1555'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1555'
git switch 'github-bot/gh-1555'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1555'
git switch 'main'
git merge --squash 'github-bot/gh-1555'
git switch 'main'
git merge --ff-only 'github-bot/gh-1555'
git switch 'main'
git merge 'github-bot/gh-1555'
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/trustno1-coder--VIctory-NVIDIA!1555
No description provided.