GPU: Add mesh-to-compute fallback for RDNA1 #20

Open
github-bot wants to merge 5 commits from github-bot/gh-20 into main AGit
Owner

@⁠Abdellah-Khanani on GitHub · 2026-11-25 23:38 UTC · original
Abdellah-Khanani:codex/rdna1-mesh-fallback → main · +2779 −80 · 14 files · 5 commits · draft

What this does

Adds a mesh-to-compute path for D3D12 adapters without native mesh shaders, aimed at RDNA1 GPUs such as the Radeon RX 5700 XT. The translator emits the mesh program as compute plus a vertex shader, and the host submits generated geometry through an indirect draw. The fallback uses a dedicated compute root signature and list-owned scratch buffers.

Also declares wave64 for the fallback, keeps mesh output limits intact for compute lowering, applies the host blend-state workaround for integer render targets, and makes the fallback scratch-pool limits configurable.

Local validation

  • cargo build --locked --profile diag -p victory --features diagnostics succeeds.
  • On an RX 5700 XT, VIctory reaches the Rockstar intro and loading artwork at about 30 FPS.
  • It still fails while transitioning toward gameplay: D3D12 reports an invalid host command list on close (0x80004005). The Windows D3D12 debug layer is unavailable on this machine, so the offending command is not identified yet.

This is published as a draft because the first actual gameplay scene is not verified yet.

**@⁠Abdellah-Khanani** on GitHub · 2026-11-25 23:38 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/20) `Abdellah-Khanani:codex/rdna1-mesh-fallback` → `main` · +2779 −80 · 14 files · 5 commits · draft ## What this does Adds a mesh-to-compute path for D3D12 adapters without native mesh shaders, aimed at RDNA1 GPUs such as the Radeon RX 5700 XT. The translator emits the mesh program as compute plus a vertex shader, and the host submits generated geometry through an indirect draw. The fallback uses a dedicated compute root signature and list-owned scratch buffers. Also declares wave64 for the fallback, keeps mesh output limits intact for compute lowering, applies the host blend-state workaround for integer render targets, and makes the fallback scratch-pool limits configurable. ## Local validation - `cargo build --locked --profile diag -p victory --features diagnostics` succeeds. - On an RX 5700 XT, VIctory reaches the Rockstar intro and loading artwork at about 30 FPS. - It still fails while transitioning toward gameplay: D3D12 reports an invalid host command list on close (`0x80004005`). The Windows D3D12 debug layer is unavailable on this machine, so the offending command is not identified yet. This is published as a draft because the first actual gameplay scene is not verified yet.
For hosts without mesh shaders (Pascal, RDNA1), whose mesh pipelines are
refused today. `translate_mesh_as_compute` lowers a mesh program with the
same `Lower` as `translate`, so every instruction it handles is handled
the same way. Only the four mesh output operations change; they become
raw stores to three UAVs in the new MESH_OUT_SPACE (space 2):

| mesh op | compute form |
|---|---|
| setMeshOutputCounts | dropped (the declared maxima, as the mesh form) |
| storeVertexOutput | u0: record g * max_vertices + v, 4 dwords per output element |
| emitIndices | u1: 3 indices, with the group's first vertex added; culled or unexported ones are 0, 0, 0 (no area) |
| storePrimitiveOutput | u2: record g * max_primitives + p |

It comes back as a `MeshFallback` with a `MeshLayout` and a generated
vertex shader. The vertex shader reads u0-u2 as t0-t2 and writes the mesh
program's own output signature, so the title's pixel shader (which links
by semantic) stays as it is.

* Without per-primitive outputs, it draws indexed by u1: vertex
  SV_VertexID is record SV_VertexID.
* With them, it draws unindexed, three vertices per primitive (`expanded`).
  Each corner reads its index from t1, and the primitive's record from t2
  becomes constant-interpolated outputs after the vertex rows.

`emit` and `translate` are unchanged.

Tests (emit/mesh_compute_tests.rs) use a hand-assembled three-lane mesh
program: one triangle and two culled primitives per group, optionally
with a per-primitive COLOR0.

* Both forms and the vertex shader pass dxil.dll.
* The compute form writes the expected vertices and indices for two
  groups.
* Drawn into a 32x32 target, the mesh shader and the fallback give the
  same image: within 1e-6 on WARP 1.0.22 (which has mesh shaders), and
  with the same coverage and values within 1e-3 on a GTX 1060 (which has
  none). Both cases are checked, with and without per-primitive outputs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
On a host without mesh shaders, or anywhere with VICTORY_MESH_FALLBACK=1
for comparing, a mesh pipeline is no longer refused.

Pipelines. The mesh program's `MeshFallback` is made once per shader.
The host pipeline gets:

* the mesh stage's root parameters visible to all stages;
* root UAVs u0-u2 and root SRVs t0-t2 in MESH_OUT_SPACE;
* a compute pipeline for the mesh program;
* as its graphics pipeline, the fallback vertex shader with the title's
  pixel shader and graphics state.

It is refused, with one log line, when the compute form binds otherwise
than the mesh form.

Direct mesh dispatches (x groups):

1. Bind the mesh stage with the title's graphics root arguments on the
   compute bindings. To allow that, `bind_as` separates which root
   arguments are read from where they are set.
2. Dispatch x groups into a default-heap buffer of the list's own.
3. Move the buffer to index-buffer and shader-resource state and draw as
   any draw: 3 * max_primitives * x indices, or vertices when expanded.
4. Restore the title's topology and put the buffer back to COMMON.

Each fallback draw of a list gets its own buffer, reused after the list
is reset.

Indirect mesh dispatches (mesh_indirect.rs). After the argument clamp, an
HLSL pass (compiled by the system's compiler, like the clamp) walks the
records and their count. It writes:

* compute commands: u0-u2 root UAV addresses, each record after the
  previous records' groups, then the dispatch;
* draw commands: a t0 root SRV address, then a draw starting at the
  record's first index or vertex (t1 and t2 stay at their regions'
  starts).

Two ExecuteIndirect calls follow, under command signatures made with the
pipeline's root signature. Each execution writes at most 32 MiB; records
past that run empty.

Tests:

* The argument pass runs on the GPU in mesh_indirect/tests.rs: records of
  2, 0 and 5 groups, indexed and expanded, with and without a count.
  Each gets its own addresses and draw.
* The pipeline and draw paths need the title's device. They have not run
  against the title (no game data here). The shader side is covered by
  victory-shader's mesh_compute_tests.

Not done:

* The compute form is not in the shader cache.
* There is one buffer per draw.
* A wave64 mesh program keeps its lane layout as compute, so on 32-lane
  hosts it hits what #578 refuses.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Found running the title's world through the fallback on an RX 5700 XT
(RDNA1, no mesh shaders).

Root signatures. The fallback made the mesh stage's parameters visible to
ALL so the compute pass could see them, in the same root signature as the
pixel shader. The two stages use the same registers (user data b0 in the
same space), so D3D12 refused the signature ("Shader register range of
type CBV (root parameter [2], visibility PIXEL) overlaps ... root parameter
[0], visibility ALL"): 245 world pipelines refused, their draws dropped.
Now the draw's signature keeps the mesh stage visible to the vertex
shader, and the compute pass gets its own signature with the same
parameters at the same indices: the mesh stage's visible to ALL, the pixel
stage's moved to spaces nothing reads. The bind uses it for the compute
pass, and the indirect command signatures are made on their own
signature. After: 0 refused, 513 fallback pipelines made.

Scratch. Every fallback draw took a new region, kept until the list was
reset, and every list kept its own 64 MiB chunks: thousands of draws and
dozens of lists ran the 8 GB card out of memory (1,955 E_OUTOFMEMORY in
one run). Now a draw's regions are free again once it has moved its chunk
back to UNORDERED_ACCESS (a transition that waits for its reads), chunks
are 16 MiB, go back to a pool the lists share when a list is reset, and
past 512 MiB free are released 128 list resets later. Releasing them at
once gave a GPU page fault inside a freed "mesh fallback Data" buffer in
one run, so the delay is a workaround for a lifetime I have not pinned
down. After: 0 E_OUTOFMEMORY, VRAM steady around 7.5 GB.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:31:23 +00:00
Author
Owner

@⁠delacor on GitHub · 2026-11-27 12:05 UTC · original

Linux/RDNA1 progress update from our local integration on an RX 5500 XT 8 GiB with Wine/vkd3d-proton: the opening 3D room and character geometry are now visible using the compute fallback plus additional fixes. Face/shading artifacts and dropped passes remain, so this is not an end-to-end rendering correctness claim.

Our backend accepts the state-changing indirect signatures but produces no mesh work with device-generated commands disabled. Explicit output bindings and ordinary indirect compute/draw pairs restore geometry, with each pair finishing its read before output reuse. Five actual GPU regressions pass, including multiple records whose combined storage exceeds one region. Native mesh execution keeps its existing path.

We also tested an opt-in shared Data output allocator across host lists on the single DIRECT queue. Indirect command buffers stay private; group counts, layout, capacity and write/read dependencies are preserved. Earlier size allocations remain owned after growth. The existing pool already recycles output after each draw; this addresses retention across simultaneously live lists.

Same-executable sequential comparison Private output pools Shared output storage
Final retained mesh storage 1947 MiB 95 MiB
Peak retained mesh storage 2491 MiB 97 MiB
Peak total observed VRAM usage 7.964 GiB 6.186 GiB
Mean warm frame time 199.526 ms 195.035 ms
FPS calculated from mean frame time 5.012 5.127

The application mesh-storage counter includes command buffers and free/delayed storage; it is not total GPU memory. Warm samples cover 120–410 seconds with no shader compilation (53 private, 51 shared samples). Draw counts differ (1114.42 versus 1104.31 on average), and the shared run had USB/dock hotplug messages. This supports about 95% lower final retained mesh storage, not an established FPS gain. Neither run reported an amdgpu fault/reset.

The shared-storage GPU regression records 32 lists before submission and checks reverse batched order, separate submissions, growth and exact producer/consumer output across 64 lists. It passes and retains 3 MiB in the synthetic case. Barrier/image and indirect regressions, Windows all-target checks and the app build also pass in the integration. Other GPUs, native Windows drivers and long-session behavior remain unverified.

Credit: yoraudev's alternative Marvisak #1648 already uses global intermediate storage. Our experiment adapts that idea to this fallback allocator and translator rather than introducing another emulation implementation. Its benefit is not intrinsically limited to 8-GiB GPUs, but native mesh draws bypass these buffers. No native-path 7900 XTX speedup is claimed.

These are local integration results with follow-up changes, not validation of this PR's unmodified head. The narrow follow-up patches still need extraction against the agreed fallback base; unrelated experiments and private captures/shaders/executables will be excluded. AI-assisted investigation and synthetic regression work with Codex.

Coordinating the same follow-up with Marvisak #961. This does not change the fallback dependency or establish an improvement on the native 7900 path.

**@⁠delacor** on GitHub · 2026-11-27 12:05 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/20#issuecomment-7217831606) Linux/RDNA1 progress update from our local integration on an RX 5500 XT 8 GiB with Wine/vkd3d-proton: the opening 3D room and character geometry are now visible using the compute fallback plus additional fixes. Face/shading artifacts and dropped passes remain, so this is not an end-to-end rendering correctness claim. Our backend accepts the state-changing indirect signatures but produces no mesh work with device-generated commands disabled. Explicit output bindings and ordinary indirect compute/draw pairs restore geometry, with each pair finishing its read before output reuse. Five actual GPU regressions pass, including multiple records whose combined storage exceeds one region. Native mesh execution keeps its existing path. We also tested an opt-in shared **Data output** allocator across host lists on the single DIRECT queue. Indirect command buffers stay private; group counts, layout, capacity and write/read dependencies are preserved. Earlier size allocations remain owned after growth. The existing pool already recycles output after each draw; this addresses retention across simultaneously live lists. | Same-executable sequential comparison | Private output pools | Shared output storage | |---|---:|---:| | Final retained mesh storage | 1947 MiB | 95 MiB | | Peak retained mesh storage | 2491 MiB | 97 MiB | | Peak total observed VRAM usage | 7.964 GiB | 6.186 GiB | | Mean warm frame time | 199.526 ms | 195.035 ms | | FPS calculated from mean frame time | 5.012 | 5.127 | The application mesh-storage counter includes command buffers and free/delayed storage; it is not total GPU memory. Warm samples cover 120–410 seconds with no shader compilation (53 private, 51 shared samples). Draw counts differ (1114.42 versus 1104.31 on average), and the shared run had USB/dock hotplug messages. This supports about **95% lower final retained mesh storage**, not an established FPS gain. Neither run reported an amdgpu fault/reset. The shared-storage GPU regression records 32 lists before submission and checks reverse batched order, separate submissions, growth and exact producer/consumer output across 64 lists. It passes and retains 3 MiB in the synthetic case. Barrier/image and indirect regressions, Windows all-target checks and the app build also pass in the integration. Other GPUs, native Windows drivers and long-session behavior remain unverified. Credit: yoraudev's alternative [Marvisak #1648](https://github.com/Marvisak/VIctory/pull/1648) already uses global intermediate storage. Our experiment adapts that idea to this fallback allocator and translator rather than introducing another emulation implementation. Its benefit is not intrinsically limited to 8-GiB GPUs, but native mesh draws bypass these buffers. No native-path 7900 XTX speedup is claimed. These are local integration results with follow-up changes, not validation of this PR's unmodified head. The narrow follow-up patches still need extraction against the agreed fallback base; unrelated experiments and private captures/shaders/executables will be excluded. AI-assisted investigation and synthetic regression work with Codex. Coordinating the same follow-up with [Marvisak #961](https://github.com/Marvisak/VIctory/pull/961). This does not change the fallback dependency or establish an improvement on the native 7900 path.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/draw.rs
  • crates/victory-gpu/src/host.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/20/head:github-bot/gh-20'
git switch 'github-bot/gh-20'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-20'
git switch 'github-bot/gh-20'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-20'
git switch 'github-bot/gh-20'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-20'
git switch 'main'
git merge --squash 'github-bot/gh-20'
git switch 'main'
git merge --ff-only 'github-bot/gh-20'
git switch 'main'
git merge 'github-bot/gh-20'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.