compute shaders fallback #3
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory#3
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@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)?
call [r9+0x30]at the account-picker → world transition; a second crash overruns a 24-byte-stride table; crash-log appends interleave #2025victory_gpu::timelinefail-open GPU memory wait timeout immediately precedes title0xc0000005crash (afterretired host resource queueepoch pinning) #2174@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
Loweras today. Only the four mesh output ops change: they become raw-buffer stores, and the program is emitted ascs_6_6with the same thread group:setMeshOutputCountsstoreVertexOutputu0: vertexg * max_vertices + v, 4 dwords per output elementemitIndicesu1: 3 indices per primitive, with the group's first vertex added. Culled or unexported ones are0, 0, 0(no area)storePrimitiveOutputu2: per-primitive recordsAll three are in a new
MESH_OUT_SPACE(space 2). A generated vertex shader reads recordSV_VertexIDfromt0and writes it out with the mesh program's own output signature, so the title's pixel shader links unchanged.DispatchMesh(x)becomes:Dispatch(x);DrawIndexedInstanced(3 * max_primitives * x).In
victory-gpu:VICTORY_MESH_FALLBACK=1for comparing.bindis split into "which title roots to read" and "which host bindings to set".What's verified
dxil.dllvalidation (emit/mesh_compute_tests.rs).cargo test --workspace, clippy (with and withoutdiagnostics) andcargo xtask policyare clean.What isn't
victory-gpuside is checked only by compiling and review.SV_PrimitiveIDwould be the next step.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.mesh programs run as compute;host mesh pipeline, run as compute;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.VICTORY_MESH_FALLBACK=1on a mesh-capable GPU, aVICTORY_CAPTUREof 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: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 fromt1and the primitive's record fromt2, 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.COLOR0is 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:u0-u2root UAV addresses, placed after the previous records' groups, then the dispatch;t0root SRV address, then a draw starting at the record's first index or vertex.Two
ExecuteIndirectcalls follow, with command signatures made under the fallback pipeline's root signature.ExecuteIndirectcalls have no test, because they need victory-gpu's host device.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:
mesh_prologue, which the fallback shares.DispatchMeshXto 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.
@fuzeofficlal on GitHub · 2026-11-24 12:21 UTC · original
I verified the two native
ExecuteIndirectcalls throughState::execute_indirecton your prototype at6c5d2c2. 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.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.
@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 throughtranslate_mesh_as_compute, validated the compute shader and the generated vertex shader withdxil.dll, and created both pipelines on the Vega 7: the compute one, and the vertex shader with a stub pixel shader. Root signatures wereroot_signature_forplus youru0-u2/t0-t2inMESH_OUT_SPACE. It's a local probe, not a commit.mainffe310emainvertex plus primitive output size is greater than 32768(MS_VS_PedTransformFire,MS_VS_PedTransform_Decals,MS_VS_*Spatter_Fire_AlphaPrepassand 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.expandedwas false for all 8,205), so the title only needs the indexed path.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.
@EduBertozzi on GitHub · 2026-11-24 13:31 UTC · original
Thank you both, these are exactly the tests I couldn't run.
State::execute_indirectmatching 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.Two things follow from your numbers:
MS_VS_PedTransformFire, the*Spatter_Fire_AlphaPrepassfamily, ...) 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.v_readfirstlaneof values that aren't uniform over the console wave. So my "halves skip ans_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'smainplus the fallback, its shader-cache entry, pooled scratch memory andvictory 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:42 UTC · original
Done, as promised above:
4cdbb15onpr/mesh-compute-fallback(also merged intoproto/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 computewith 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: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
2704a57onpr/mesh-compute-fallback, an ignored test with no game data: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:
victory-gpurecords today: compute pass, transition to read, draw, transition back.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 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-censusand the per-frame benchmark. The questions still open (batching the compute passes, wave64 on 32-lane hosts) are listed there.AI-assisted (Claude Code).
@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
mainsuch pipelines are refused incrates/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