compute shaders fallback #3

Open
opened 2026-11-26 03:46:09 +00:00 by github-bot · 9 comments
Owner

@⁠Shoro123456789 on GitHub · 2026-11-23 22:36 UTC · original

After you are done with the main project do you plan to add compute shader fallback to compensate for GPUs that can not compute mesh shaders (such as Rx 5700 xt)?

**@⁠Shoro123456789** on GitHub · 2026-11-23 22:36 UTC · [original](https://github.com/Marvisak/VIctory/issues/3) After you are done with the main project do you plan to add compute shader fallback to compensate for GPUs that can not compute mesh shaders (such as Rx 5700 xt)?
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:46:09 +00:00
Author
Owner

@⁠EduBertozzi on GitHub · 2026-11-24 09:21 UTC · original

I've started a prototype of this on a fork: EduBertozzi/VIctory @ proto/mesh-compute-fallback. It's an experiment and not a PR. I'm posting it here to ask whether the approach is wanted, and for help testing it on the real title, since I don't have a PC dump.

How it works

The mesh program is lowered by the same Lower as today. Only the four mesh output ops change: they become raw-buffer stores, and the program is emitted as cs_6_6 with the same thread group:

mesh op compute form
setMeshOutputCounts dropped (counts are the declared maxima, as today)
storeVertexOutput u0: vertex g * max_vertices + v, 4 dwords per output element
emitIndices u1: 3 indices per primitive, with the group's first vertex added. Culled or unexported ones are 0, 0, 0 (no area)
storePrimitiveOutput u2: per-primitive records

All three are in a new MESH_OUT_SPACE (space 2). A generated vertex shader reads record SV_VertexID from t0 and writes it out with the mesh program's own output signature, so the title's pixel shader links unchanged. DispatchMesh(x) becomes:

  1. Dispatch(x);
  2. a transition barrier;
  3. DrawIndexedInstanced(3 * max_primitives * x).

In victory-gpu:

  • The fallback is used when the host has no mesh shaders, or everywhere with VICTORY_MESH_FALLBACK=1 for comparing.
  • The mesh stage's root parameters become visible to all stages, and its graphics root arguments are set on the compute bindings. For that, bind is split into "which title roots to read" and "which host bindings to set".
  • Each fallback draw gets its own default-heap buffer in the list.

What's verified

  • On a synthetic mesh program (hand-assembled GFX10), both forms pass dxil.dll validation (emit/mesh_compute_tests.rs).
  • On a GTX 1060 (Pascal, no mesh shaders, Windows 10 with the Agility SDK runtime), the compute form writes the expected vertices and indices.
  • Drawing the triangle both ways gives the same image:
    • WARP 1.0.22's mesh shader and its fallback match within 1e-6;
    • the GTX 1060's fallback has the same coverage as WARP's mesh shader, and values within 1e-3.
  • cargo test --workspace, clippy (with and without diagnostics) and cargo xtask policy are clean.

What isn't

  • Never run against the title. The victory-gpu side is checked only by compiling and review.
  • Mesh programs with per-primitive outputs are refused, because a vertex shader cannot pass them on. Using a GS or SV_PrimitiveID would be the next step.
  • Indirect mesh dispatches are dropped.
  • The compute translation isn't in the shader cache yet.
  • One buffer per draw, sized for the declared maxima. Expect it to be slow and memory-hungry.

How to test it

You need the title and a GPU without mesh shaders (RX 5700 XT / RDNA1, GTX 10xx), or any GPU with VICTORY_MESH_FALLBACK=1.

  • The branch carries the #719 test fix and #486 so the GPU tests run on Windows 10. On Windows 10, the app itself still needs the Agility SDK runtime (#175/#463).
  • In the log, look for:
    • mesh programs run as compute;
    • host mesh pipeline, run as compute;
    • refusals: the mesh shader does not translate as compute, per-primitive mesh outputs are not drawn without mesh shaders, the mesh program binds otherwise when run as compute.
  • With VICTORY_MESH_FALLBACK=1 on a mesh-capable GPU, a VICTORY_CAPTURE of the same frame with and without the fallback would show whether the two paths match.

Counts are the most useful result: how many mesh pipelines take the fallback, and how many are refused and why. Screenshots of what renders help too.

AI-assisted (Claude Code). The GPU results above are real runs on my machine.

**@⁠EduBertozzi** on GitHub · 2026-11-24 09:21 UTC · [original](https://github.com/Marvisak/VIctory/issues/3#issuecomment-7127293917) I've started a prototype of this on a fork: [`EduBertozzi/VIctory` @ `proto/mesh-compute-fallback`](https://github.com/EduBertozzi/VIctory/tree/proto/mesh-compute-fallback). It's an experiment and not a PR. I'm posting it here to ask whether the approach is wanted, and for help testing it on the real title, since I don't have a PC dump. ## How it works The mesh program is lowered by the same `Lower` as today. Only the four mesh output ops change: they become raw-buffer stores, and the program is emitted as `cs_6_6` with the same thread group: | mesh op | compute form | |---|---| | `setMeshOutputCounts` | dropped (counts are the declared maxima, as today) | | `storeVertexOutput` | `u0`: vertex `g * max_vertices + v`, 4 dwords per output element | | `emitIndices` | `u1`: 3 indices per primitive, with the group's first vertex added. Culled or unexported ones are `0, 0, 0` (no area) | | `storePrimitiveOutput` | `u2`: per-primitive records | All three are in a new `MESH_OUT_SPACE` (space 2). A generated vertex shader reads record `SV_VertexID` from `t0` and writes it out with the mesh program's own output signature, so the title's pixel shader links unchanged. `DispatchMesh(x)` becomes: 1. `Dispatch(x)`; 2. a transition barrier; 3. `DrawIndexedInstanced(3 * max_primitives * x)`. In `victory-gpu`: - The fallback is used when the host has no mesh shaders, or everywhere with `VICTORY_MESH_FALLBACK=1` for comparing. - The mesh stage's root parameters become visible to all stages, and its graphics root arguments are set on the compute bindings. For that, `bind` is split into "which title roots to read" and "which host bindings to set". - Each fallback draw gets its own default-heap buffer in the list. ## What's verified - On a synthetic mesh program (hand-assembled GFX10), both forms pass `dxil.dll` validation (`emit/mesh_compute_tests.rs`). - On a GTX 1060 (Pascal, no mesh shaders, Windows 10 with the Agility SDK runtime), the compute form writes the expected vertices and indices. - Drawing the triangle both ways gives the same image: - WARP 1.0.22's mesh shader and its fallback match within 1e-6; - the GTX 1060's fallback has the same coverage as WARP's mesh shader, and values within 1e-3. - `cargo test --workspace`, clippy (with and without `diagnostics`) and `cargo xtask policy` are clean. ## What isn't - **Never run against the title.** The `victory-gpu` side is checked only by compiling and review. - Mesh programs with per-primitive outputs are refused, because a vertex shader cannot pass them on. Using a GS or `SV_PrimitiveID` would be the next step. - Indirect mesh dispatches are dropped. - The compute translation isn't in the shader cache yet. - One buffer per draw, sized for the declared maxima. Expect it to be slow and memory-hungry. ## How to test it You need the title and a GPU without mesh shaders (RX 5700 XT / RDNA1, GTX 10xx), or any GPU with `VICTORY_MESH_FALLBACK=1`. - The branch carries the #719 test fix and #486 so the GPU tests run on Windows 10. On Windows 10, the app itself still needs the Agility SDK runtime (#175/#463). - In the log, look for: - `mesh programs run as compute`; - `host mesh pipeline, run as compute`; - refusals: `the mesh shader does not translate as compute`, `per-primitive mesh outputs are not drawn without mesh shaders`, `the mesh program binds otherwise when run as compute`. - With `VICTORY_MESH_FALLBACK=1` on a mesh-capable GPU, a `VICTORY_CAPTURE` of the same frame with and without the fallback would show whether the two paths match. Counts are the most useful result: how many mesh pipelines take the fallback, and how many are refused and why. Screenshots of what renders help too. AI-assisted (Claude Code). The GPU results above are real runs on my machine.
Author
Owner

@⁠EduBertozzi on GitHub · 2026-11-24 09:46 UTC · original

Update on the fallback branch (proto/mesh-compute-fallback). The two gaps from my last comment are closed:

  • Per-primitive outputs (351895b). These programs were refused before. Now they are drawn unindexed, three vertices per primitive. The vertex shader reads the corner's index from t1 and the primitive's record from t2, and writes that record as constant-interpolated outputs after the vertex rows. The pixel shader links by semantic, so the title's PS is unchanged.

    • Tested with a synthetic program whose per-primitive COLOR0 is read by the PS. WARP's mesh shader and the fallback give the same image (1e-6). The GTX 1060's fallback has the same coverage, with values within 1e-3.
  • Indirect mesh dispatches (a4d1797). These were dropped before. Now, after the argument clamp, an HLSL pass (compiled like the clamp) walks the records and their count. For each record it writes:

    • a compute command: u0-u2 root UAV addresses, placed after the previous records' groups, then the dispatch;
    • a draw command: a t0 root SRV address, then a draw starting at the record's first index or vertex.

    Two ExecuteIndirect calls follow, with command signatures made under the fallback pipeline's root signature.

    • The pass is tested on the GPU: records of 2, 0 and 5 groups, indexed and expanded, with and without a count.
    • The two ExecuteIndirect calls have no test, because they need victory-gpu's host device.
    • Each execution writes at most 32 MiB; records past that run empty.

Still untested against the title. Of the cases my first comment listed as refused, only the shader-cache entry for the compute form is still missing. Performance is the open question: one buffer per draw, and a single-thread argument pass.

Open PRs on the mesh path that would meet this branch:

  • #586 (honor the allocation counts) changes mesh_prologue, which the fallback shares.
  • #587 (output bounds) affects both paths the same way.
  • #24 sends DispatchMeshX to indirect execution, which the fallback now handles.

I'll rebase on whichever of them land.

AI-assisted (Claude Code). The GPU results are real runs on my machine.

**@⁠EduBertozzi** on GitHub · 2026-11-24 09:46 UTC · [original](https://github.com/Marvisak/VIctory/issues/3#issuecomment-7127875264) Update on the fallback branch ([`proto/mesh-compute-fallback`](https://github.com/EduBertozzi/VIctory/tree/proto/mesh-compute-fallback)). The two gaps from my last comment are closed: - **Per-primitive outputs** (`351895b`). These programs were refused before. Now they are drawn unindexed, three vertices per primitive. The vertex shader reads the corner's index from `t1` and the primitive's record from `t2`, and writes that record as constant-interpolated outputs after the vertex rows. The pixel shader links by semantic, so the title's PS is unchanged. - Tested with a synthetic program whose per-primitive `COLOR0` is read by the PS. WARP's mesh shader and the fallback give the same image (1e-6). The GTX 1060's fallback has the same coverage, with values within 1e-3. - **Indirect mesh dispatches** (`a4d1797`). These were dropped before. Now, after the argument clamp, an HLSL pass (compiled like the clamp) walks the records and their count. For each record it writes: - a compute command: `u0`-`u2` root UAV addresses, placed after the previous records' groups, then the dispatch; - a draw command: a `t0` root SRV address, then a draw starting at the record's first index or vertex. Two `ExecuteIndirect` calls follow, with command signatures made under the fallback pipeline's root signature. - The pass is tested on the GPU: records of 2, 0 and 5 groups, indexed and expanded, with and without a count. - The two `ExecuteIndirect` calls have no test, because they need victory-gpu's host device. - Each execution writes at most 32 MiB; records past that run empty. Still untested against the title. Of the cases my first comment listed as refused, only the shader-cache entry for the compute form is still missing. Performance is the open question: one buffer per draw, and a single-thread argument pass. Open PRs on the mesh path that would meet this branch: - #586 (honor the allocation counts) changes `mesh_prologue`, which the fallback shares. - #587 (output bounds) affects both paths the same way. - #24 sends `DispatchMeshX` to indirect execution, which the fallback now handles. I'll rebase on whichever of them land. AI-assisted (Claude Code). The GPU results are real runs on my machine.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-24 12:21 UTC · original

I verified the two native ExecuteIndirect calls through State::execute_indirect on your prototype at 6c5d2c2. I used the existing synthetic triangle shaders, the real fallback pipeline and command signatures, and a 32×32 FP16 render target with additive blending. I forced the compute fallback on RTX 5090 and WARP.

Indirect records Count buffer Green inside the triangle
2, 0, 5 groups Absent 7.0
2, 0, 5 groups 2 2.0
2, 0, 5 groups 0 0.0

Both backends passed for indexed and expanded output, including per-primitive output in the expanded variant. For the two nonzero cases, all 1,024 green samples matched the corresponding direct fallback draws pixel for pixel, with 512 covered pixels and 512 background pixels. The zero-count case left the full target clear. This exercises the CPU-seeded argument upload, clamp, conversion, indirect compute, and indirect draw through the production state path.

**@⁠fuzeofficlal** on GitHub · 2026-11-24 12:21 UTC · [original](https://github.com/Marvisak/VIctory/issues/3#issuecomment-7131315363) I verified the two native `ExecuteIndirect` calls through `State::execute_indirect` on your prototype at [`6c5d2c2`](https://github.com/EduBertozzi/VIctory/commit/6c5d2c295d9173cfba0bef83bc94ec5fd5832cd0). I used the existing synthetic triangle shaders, the real fallback pipeline and command signatures, and a 32×32 FP16 render target with additive blending. I forced the compute fallback on RTX 5090 and WARP. | Indirect records | Count buffer | Green inside the triangle | | --- | --- | ---: | | 2, 0, 5 groups | Absent | 7.0 | | 2, 0, 5 groups | 2 | 2.0 | | 2, 0, 5 groups | 0 | 0.0 | Both backends passed for indexed and expanded output, including per-primitive output in the expanded variant. For the two nonzero cases, all 1,024 green samples matched the corresponding direct fallback draws pixel for pixel, with 512 covered pixels and 512 background pixels. The zero-count case left the full target clear. This exercises the CPU-seeded argument upload, clamp, conversion, indirect compute, and indirect draw through the production state path.
Author
Owner

@⁠permadiego on GitHub · 2026-11-24 13:25 UTC · original

Test against the title's shaders, on a GPU without mesh shaders: AMD Radeon Vega 7 (Ryzen 5 5500U iGPU, Windows 10 19045, Agility SDK 1.620.2), your branch at 6c5d2c2.

I took every mesh container in the title's shaders.rpf (8,765) and ran each through translate_mesh_as_compute, validated the compute shader and the generated vertex shader with dxil.dll, and created both pipelines on the Vega 7: the compute one, and the vertex shader with a stub pixel shader. Root signatures were root_signature_for plus your u0-u2 / t0-t2 in MESH_OUT_SPACE. It's a local probe, not a commit.

containers fallback: translated, both validated, both PSOs created
mesh form validates on main ffe310e 8,152 8,152
mesh form fails on main 613 53
  • No program that works as a mesh shader is lost in the compute form, and the Vega 7's driver compiles all of them. 3 min 20 s for all 8,765 with 6 threads.
  • The 53 extra programs are all refused in the mesh form by vertex plus primitive output size is greater than 32768 (MS_VS_PedTransformFire, MS_VS_PedTransform_Decals, MS_VS_*Spatter_Fire_AlphaPrepass and a few others, 5 of each). The compute form has no such limit, so these could take the fallback even on hosts with mesh shaders.
  • None of the working programs has per-primitive outputs (expanded was false for all 8,205), so the title only needs the indexed path.
  • The other 560 fail in the shared lowering with the same reasons as the mesh form (385 "a scalar memory read as data", 103 "a lane mask read as data", 34 "a descriptor read from the first lane of computed VGPRs", ...). 9 fail validation in the generated vertex shader, and their mesh forms fail with the same signature error (COLOR ... interpolation mode that differs, Program Output Signature does not match), so they're not specific to the fallback.

Not tested: drawing with the title's bindings (I only have the shaders, not a full dump), and performance.

AI-assisted (Claude Code); I ran it on my machine.

**@⁠permadiego** on GitHub · 2026-11-24 13:25 UTC · [original](https://github.com/Marvisak/VIctory/issues/3#issuecomment-7132809980) Test against the title's shaders, on a GPU without mesh shaders: AMD Radeon Vega 7 (Ryzen 5 5500U iGPU, Windows 10 19045, Agility SDK 1.620.2), your branch at `6c5d2c2`. I took every mesh container in the title's `shaders.rpf` (8,765) and ran each through `translate_mesh_as_compute`, validated the compute shader and the generated vertex shader with `dxil.dll`, and created both pipelines on the Vega 7: the compute one, and the vertex shader with a stub pixel shader. Root signatures were `root_signature_for` plus your `u0`-`u2` / `t0`-`t2` in `MESH_OUT_SPACE`. It's a local probe, not a commit. | | containers | fallback: translated, both validated, both PSOs created | |---|---:|---:| | mesh form validates on `main` ffe310e | 8,152 | **8,152** | | mesh form fails on `main` | 613 | 53 | - No program that works as a mesh shader is lost in the compute form, and the Vega 7's driver compiles all of them. 3 min 20 s for all 8,765 with 6 threads. - The 53 extra programs are all refused in the mesh form by `vertex plus primitive output size is greater than 32768` (`MS_VS_PedTransformFire`, `MS_VS_PedTransform_Decals`, `MS_VS_*Spatter_Fire_AlphaPrepass` and a few others, 5 of each). The compute form has no such limit, so these could take the fallback even on hosts with mesh shaders. - None of the working programs has per-primitive outputs (`expanded` was false for all 8,205), so the title only needs the indexed path. - The other 560 fail in the shared lowering with the same reasons as the mesh form (385 "a scalar memory read as data", 103 "a lane mask read as data", 34 "a descriptor read from the first lane of computed VGPRs", ...). 9 fail validation in the generated vertex shader, and their mesh forms fail with the same signature error (`COLOR ... interpolation mode that differs`, `Program Output Signature does not match`), so they're not specific to the fallback. Not tested: drawing with the title's bindings (I only have the shaders, not a full dump), and performance. AI-assisted (Claude Code); I ran it on my machine.
Author
Owner

@⁠EduBertozzi on GitHub · 2026-11-24 13:31 UTC · original

Thank you both, these are exactly the tests I couldn't run.

  • @⁠fuzeofficlal: the indirect path through State::execute_indirect matching the direct draws pixel for pixel on an RTX 5090 and WARP is the part I had only checked as far as the argument pass. Indexed, expanded, with and without a count, and a zero count clearing nothing. That covers it.
  • @⁠permadiego: every one of the 8,152 containers that work as mesh shaders also translates, validates and gets both pipelines on a GPU without mesh shaders. So the compute form loses nothing, and the indexed path is the one that matters, since no working program has per-primitive outputs.

Two things follow from your numbers:

  1. The 53 programs refused for D3D12's 32 KiB mesh output limit (MS_VS_PedTransformFire, the *Spatter_Fire_AlphaPrepass family, ...) could take the compute form on every host, mesh shaders or not, since it writes to buffers and has no such limit. Next, I'll make the host pipeline fall back to compute when the mesh form is refused for that reason alone.
  2. Correcting what I said on #778: @⁠KenzoPortela's analysis there shows the translated wave64 mesh programs have no barriers or ballots. The NVIDIA world hangs look like loop guards on nested loops, plus v_readfirstlane of values that aren't uniform over the console wave. So my "halves skip an s_barrier" explanation doesn't hold for these programs, and this fallback isn't the way to fix 32-lane hosts. Its purpose stays the original one: GPUs without mesh shaders, and now the over-limit programs.

The clean version for review, when pull requests open up again, is pr/mesh-compute-fallback: today's main plus the fallback, its shader-cache entry, pooled scratch memory and victory mesh-census, without the Windows 10 test helpers. Drawing with the title's own bindings and performance are still open, as you noted.

AI-assisted (Claude Code).

**@⁠EduBertozzi** on GitHub · 2026-11-24 13:31 UTC · [original](https://github.com/Marvisak/VIctory/issues/3#issuecomment-7132964160) Thank you both, these are exactly the tests I couldn't run. - **@⁠fuzeofficlal:** the indirect path through `State::execute_indirect` matching the direct draws pixel for pixel on an RTX 5090 and WARP is the part I had only checked as far as the argument pass. Indexed, expanded, with and without a count, and a zero count clearing nothing. That covers it. - **@⁠permadiego:** every one of the 8,152 containers that work as mesh shaders also translates, validates and gets both pipelines on a GPU without mesh shaders. So the compute form loses nothing, and the indexed path is the one that matters, since no working program has per-primitive outputs. Two things follow from your numbers: 1. **The 53 programs refused for D3D12's 32 KiB mesh output limit** (`MS_VS_PedTransformFire`, the `*Spatter_Fire_AlphaPrepass` family, ...) could take the compute form on *every* host, mesh shaders or not, since it writes to buffers and has no such limit. Next, I'll make the host pipeline fall back to compute when the mesh form is refused for that reason alone. 2. **Correcting what I said on #778:** @⁠KenzoPortela's analysis there shows the translated wave64 mesh programs have no barriers or ballots. The NVIDIA world hangs look like loop guards on nested loops, plus `v_readfirstlane` of values that aren't uniform over the console wave. So my "halves skip an `s_barrier`" explanation doesn't hold for these programs, and this fallback isn't the way to fix 32-lane hosts. Its purpose stays the original one: GPUs without mesh shaders, and now the over-limit programs. The clean version for review, when pull requests open up again, is [`pr/mesh-compute-fallback`](https://github.com/EduBertozzi/VIctory/tree/pr/mesh-compute-fallback): today's `main` plus the fallback, its shader-cache entry, pooled scratch memory and `victory mesh-census`, without the Windows 10 test helpers. Drawing with the title's own bindings and performance are still open, as you noted. AI-assisted (Claude Code).
Author
Owner

@⁠EduBertozzi on GitHub · 2026-11-24 13:42 UTC · original

Done, as promised above: 4cdbb15 on pr/mesh-compute-fallback (also merged into proto/mesh-compute-fallback).

A pipeline whose mesh program outputs more than D3D12's 32 KiB per group now takes the compute fallback on every host, with or without mesh shaders, and logs mesh shader outputs more than D3D12 allows; it runs as compute with the byte count. The size follows the spec's rule: 4 bytes per component of every vertex output times the vertex maximum rounded up to 32, plus the same for the primitive outputs (without the primitive id and cull flag, as the translation declares them).

Tested here only with unit tests at the boundary, plus the existing fallback tests. @⁠permadiego, if you still have your list of the 53, it would help to know whether they now get a pipeline on a mesh-capable GPU (and draw).

AI-assisted (Claude Code).

**@⁠EduBertozzi** on GitHub · 2026-11-24 13:42 UTC · [original](https://github.com/Marvisak/VIctory/issues/3#issuecomment-7133227531) Done, as promised above: [`4cdbb15`](https://github.com/EduBertozzi/VIctory/commit/4cdbb151c58b63627d33c9d95f32dd03a4fde036) on `pr/mesh-compute-fallback` (also merged into `proto/mesh-compute-fallback`). A pipeline whose mesh program outputs more than D3D12's 32 KiB per group now takes the compute fallback on every host, with or without mesh shaders, and logs `mesh shader outputs more than D3D12 allows; it runs as compute` with the byte count. The size follows the spec's rule: 4 bytes per component of every vertex output times the vertex maximum rounded up to 32, plus the same for the primitive outputs (without the primitive id and cull flag, as the translation declares them). Tested here only with unit tests at the boundary, plus the existing fallback tests. @⁠permadiego, if you still have your list of the 53, it would help to know whether they now get a pipeline on a mesh-capable GPU (and draw). AI-assisted (Claude Code).
Author
Owner

@⁠EduBertozzi on GitHub · 2026-11-24 13:57 UTC · original

I measured what the fallback costs per frame on a GPU without mesh shaders. The result: it isn't the shaders, it's how the draws are recorded.

The benchmark is 2704a57 on pr/mesh-compute-fallback, an ignored test with no game data:

cargo test -p victory-shader --lib fallback_frame_cost -- --ignored --nocapture

It draws a synthetic mesh program (32-lane groups, so 4 of them per 128-thread group of the title's; position plus one attribute; triangles under a pixel, so the raster costs little) in frames of 1,000 to 7,000 draws. Each frame is recorded three ways and timed with GPU timestamps (median of 7). GTX 1060 6 GB, Windows 10, Agility SDK 1.620.2:

frame per draw (today) computes batched draws only
1,000 draws × 32 groups (1.0M triangles) 7.13 ms 1.60 ms 0.47 ms
2,000 draws × 16 groups (1.0M triangles) 12.05 ms 1.42 ms 0.41 ms
7,000 draws × 4 groups (0.9M triangles) 32.86 ms 1.87 ms 0.35 ms
7,000 draws × 16 groups (3.6M triangles) 34.82 ms 4.40 ms 1.27 ms
  • Per draw is what victory-gpu records today: compute pass, transition to read, draw, transition back.
  • Batched puts every draw's compute pass first, then one transition, then every draw.
  • Draws only is the same draws from buffers already written: what drawing these triangles with a vertex shader costs.

So the per-draw cost is about 4.5 µs whatever the draw holds. At the ~7,000 draws per frame reported in #841, that's ~33 ms before anything else is drawn.

It isn't the barriers. I also timed (and didn't keep, because it races) the same per-draw recording with the compute writing to a buffer nobody reads and no transitions: 29.06 ms instead of 31.10 ms for 7,000 × 4. What costs is switching between compute and graphics work on every draw, which Pascal pays with a drain each time.

What would fix it, and why I haven't done it. The compute passes would have to run ahead of the draws, in batches: for example, recorded into a list that runs before the draws' list, the way HostList's prelude already runs before it. That is only correct when nothing earlier in the same list writes what the mesh program reads: a compute pass or copy that fills a buffer it reads, or a render target it samples later in the frame. I can't tell how often the title does that without a capture. A conservative rule would be to batch only until the list's first dispatch, copy or UAV-writing draw, and record per draw after that.

@⁠permadiego (Vega 7) and anyone else with a GPU that has no mesh shaders (Pascal, Polaris, Vega): numbers from that test on your hardware would show whether this is Pascal alone or every pre-mesh GPU. Before I build the batching, I'd like a maintainer's view on whether the ordering rule above is the right one.

AI-assisted (Claude Code).

**@⁠EduBertozzi** on GitHub · 2026-11-24 13:57 UTC · [original](https://github.com/Marvisak/VIctory/issues/3#issuecomment-7133598748) I measured what the fallback costs per frame on a GPU without mesh shaders. The result: **it isn't the shaders, it's how the draws are recorded.** The benchmark is [`2704a57`](https://github.com/EduBertozzi/VIctory/commit/2704a570560b91e5d33ef74b7bb325518f642c1e) on `pr/mesh-compute-fallback`, an ignored test with no game data: ``` cargo test -p victory-shader --lib fallback_frame_cost -- --ignored --nocapture ``` It draws a synthetic mesh program (32-lane groups, so 4 of them per 128-thread group of the title's; position plus one attribute; triangles under a pixel, so the raster costs little) in frames of 1,000 to 7,000 draws. Each frame is recorded three ways and timed with GPU timestamps (median of 7). GTX 1060 6 GB, Windows 10, Agility SDK 1.620.2: | frame | per draw (today) | computes batched | draws only | |---|---:|---:|---:| | 1,000 draws × 32 groups (1.0M triangles) | 7.13 ms | 1.60 ms | 0.47 ms | | 2,000 draws × 16 groups (1.0M triangles) | 12.05 ms | 1.42 ms | 0.41 ms | | 7,000 draws × 4 groups (0.9M triangles) | 32.86 ms | 1.87 ms | 0.35 ms | | 7,000 draws × 16 groups (3.6M triangles) | 34.82 ms | 4.40 ms | 1.27 ms | - **Per draw** is what `victory-gpu` records today: compute pass, transition to read, draw, transition back. - **Batched** puts every draw's compute pass first, then one transition, then every draw. - **Draws only** is the same draws from buffers already written: what drawing these triangles with a vertex shader costs. So the per-draw cost is about 4.5 µs whatever the draw holds. At the ~7,000 draws per frame reported in #841, that's ~33 ms before anything else is drawn. **It isn't the barriers.** I also timed (and didn't keep, because it races) the same per-draw recording with the compute writing to a buffer nobody reads and no transitions: 29.06 ms instead of 31.10 ms for 7,000 × 4. What costs is switching between compute and graphics work on every draw, which Pascal pays with a drain each time. **What would fix it, and why I haven't done it.** The compute passes would have to run ahead of the draws, in batches: for example, recorded into a list that runs before the draws' list, the way `HostList`'s prelude already runs before it. That is only correct when nothing earlier in the same list writes what the mesh program reads: a compute pass or copy that fills a buffer it reads, or a render target it samples later in the frame. I can't tell how often the title does that without a capture. A conservative rule would be to batch only until the list's first dispatch, copy or UAV-writing draw, and record per draw after that. @⁠permadiego (Vega 7) and anyone else with a GPU that has no mesh shaders (Pascal, Polaris, Vega): numbers from that test on your hardware would show whether this is Pascal alone or every pre-mesh GPU. Before I build the batching, I'd like a maintainer's view on whether the ordering rule above is the right one. AI-assisted (Claude Code).
Author
Owner

@⁠EduBertozzi on GitHub · 2026-11-24 14:29 UTC · original

Pull requests are open again, so the fallback is now #961. It holds everything from this thread: the compute form, indirect dispatches, the shader-cache entry, pooled scratch, routing of over-limit programs, mesh-census and the per-frame benchmark. The questions still open (batching the compute passes, wave64 on 32-lane hosts) are listed there.

AI-assisted (Claude Code).

**@⁠EduBertozzi** on GitHub · 2026-11-24 14:29 UTC · [original](https://github.com/Marvisak/VIctory/issues/3#issuecomment-7134466188) Pull requests are open again, so the fallback is now #961. It holds everything from this thread: the compute form, indirect dispatches, the shader-cache entry, pooled scratch, routing of over-limit programs, `mesh-census` and the per-frame benchmark. The questions still open (batching the compute passes, wave64 on 32-lane hosts) are listed there. AI-assisted (Claude Code).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:44 UTC · original · edited 2026-11-25 01:50 UTC

Automated triage for the maintainers.

This is a feature request that fits the project's scope (Windows hosts, this title): drawing mesh pipelines on GPUs without mesh shaders. On main such pipelines are refused in crates/victory-gpu/src/pipeline/host.rs (HostPipeline::new, "the host GPU has no mesh shaders (or no shader model 6.6)"), and the README lists mesh shaders as a requirement for the world.

The compute fallback prototyped in this thread is now open as pull request #961 (it currently needs a rebase). Open questions recorded there: per-draw cost on pre-mesh GPUs (batching the compute passes needs an ordering rule a maintainer should confirm), wave64 on 32-lane hosts, and no end-to-end in-game run yet. Whether to take it is left to the maintainers; review continues on #961.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:44 UTC · [original](https://github.com/Marvisak/VIctory/issues/3#issuecomment-7149899341) · edited 2026-11-25 01:50 UTC <!-- victory-issue-triage v1 verdict=tracked seen=2026-11-24T14:29:41Z at=2026-11-25T01:44:24Z --> Automated triage for the maintainers. This is a feature request that fits the project's scope (Windows hosts, this title): drawing mesh pipelines on GPUs without mesh shaders. On `main` such pipelines are refused in `crates/victory-gpu/src/pipeline/host.rs` (`HostPipeline::new`, "the host GPU has no mesh shaders (or no shader model 6.6)"), and the README lists mesh shaders as a requirement for the world. The compute fallback prototyped in this thread is now open as pull request #961 (it currently needs a rebase). Open questions recorded there: per-draw cost on pre-mesh GPUs (batching the compute passes needs an ordering rule a maintainer should confirm), wave64 on 32-lane hosts, and no end-to-end in-game run yet. Whether to take it is left to the maintainers; review continues on #961. --- _Generated by [Claude Code](https://claude.ai/code)_
This discussion has been locked. Commenting is limited to contributors.
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/Marvisak--VIctory#3
No description provided.