GPU: mesh shaders emulated as compute + unpack vertex on SM 6.6 cards without a mesh tier #1648
No reviewers
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!1648
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1648"
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?
@yoraudev on GitHub · 2026-11-24 20:27 UTC · original
yoraudev:gpu/mesh-emulation→main· +5487 −664 · 27 files · 5 commits · openSummary
Cards that support Shader Model 6.6 but report
D3D12_MESH_SHADER_TIER_NOT_SUPPORTED(Polaris/Vega/RDNA1, Pascal, Xe-LP, WARP, …) can now run mesh stages. Nothing is vendor-specific: the path is picked fromD3D12_FEATURE_SHADER_MODELandD3D12_OPTIONS7::MeshShaderTier, and can be forced withVICTORY_MESH_EMULATION=1(or disabled with=0).A mesh stage is lowered to a
cs_6_6that writes packed vertices and primitives into a shared UAV, followed by a generatedvs_6_6that reads them back bySV_VertexIDand drawn as a plain triangle list.victory-shader
MeshMode::Emulate:HwStage::Mslowers to[numthreads(n,1,1)]cs_6_6with LDS instead ofms_6_6. Emulation resources live inspace 2(MESH_EMU_SPACE):u0intermediateRWByteAddressBuffer,b0base_group/INDIRECT_SLOT_MAP_FLAG,t0slot map / unpack input.emit_indices_emuwrites packed indices and the cull flag; vertex (OSG1) and per-primitive (PSG1) outputs are stored as contiguous 4-dword groups.Input::MeshGroupreadsbase_group + local_group, orslot_map[local_group]for indirect dispatches.unpack_vertex_shaderbuilds thevs_6_6container: culled primitives get a quiet-NaNSV_Position, and the PS input signature /PSV0linkage (incl.nointerpolationper-primitive data and depth-only passes) is preserved.victory-gpu
MeshSupport::{Native, Emulate, Unsupported}detection inhost.rs.mesh_emu.rs: shared VRAM intermediate buffer (VICTORY_MESH_BUFFER_MB, default 128 MiB with a 16 MiB fallback), slot map, indirect args, and acs_5_1prep pass that sums/clamps group counts acrossExecuteIndirect(MESH)records and builds the slot map.EmulatedMeshPipeline: cached CS + cached VS/PS graphics PSO pair.draw.rs:dispatch_mesh_emulatedchunks directDispatchMeshbygroup_cap(CS → UAV→SRV barrier →DrawInstanced→ SRV→UAV);execute_indirect_mesh_emulateddoes clamp → prep → indirect dispatch → indirect draw. Topology and root/pipeline cache state are restored afterwards.VSH2with a separateshader.dxil.mesh-emuconverter key.CLI / docs
apps/victory translatepicksMeshMode::Emulatewhen forced or when the device lacks mesh shaders, validates both the CS and the unpack VS, and test-builds the pipelines.docs/architecture.mddocument the path and env vars.Testing
cargo clippy --workspace --all-targets --locked -- -D warnings✅cargo clippy --workspace --all-targets --all-features --locked -- -D warnings✅cargo test --workspace --locked✅cargo test -p victory-shader mesh_emu: 5 passed — triangle draws on a hardware GPU and WARP, bit-31 and unexported-primitive culling,base_group/ slot-map indexing,PSG1per-primitivenointerpolation, LDS +s_barrier+ds_swizzle_b32.cargo test -p victory-gpu mesh_emu: indirect prep shader builds and runs on GPU.cargo xtask policy✅Note:
dxil.dllwasn't available locally, so static validation was skipped; PSO creation and execution were verified on real hardware and WARP. The full in-gamedraw.rsflow wasn't exercised since game files aren't in the repo.70564ae) into gpu/mesh-emulation f1324e8ea54118f33) into gpu/mesh-emulation 7fe7d0e08d940d32f) into gpu/mesh-emulation d62ba28ccd@EduBertozzi on GitHub · 2026-11-24 20:43 UTC · original
Ran this on the hardware it targets: GTX 1060 6 GB (Pascal, SM 6.6 through the Agility runtime, no mesh shader tier), Windows 10 19045. I merged
9bfe067ontomainffe310e(with #486 so the tests get SM 6.6 on Windows 10).victory-shader: 125 passed / 0 failed (main120).victory-gpu: 51 passed / 0 failed.mesh_emutests pass on hardware with no mesh shaders, includingemulated_mesh_draws_triangle_and_culls_bit31_and_unexported,…supports_lds_barrier_and_quad_swizzleandprep_shader_builds_and_runs_indirect.For reviewers: #961 (towards #3) covers the same ground, a mesh program lowered to
cs_6_6plus a generated VS. It has been run against the title on GPUs without mesh shaders, and that turned up problems any such path meets. Here's how they line up with this PR as I read it:max_primitives> threads (stale triangles from reused scratch)b0/s<n>/root views, so D3D12 refuses the root signature (165 refusals on an RX 470)VICTORY_MESH_BUFFER_MB)Both approaches work. Since they would conflict, it may help to settle on one and fold the other's useful parts into it. I'm glad to help whichever way the maintainers prefer. Disclosure: I wrote #961.
AI-assisted (Claude Code).
@yoraudev on GitHub · 2026-11-24 20:51 UTC · original
Thanks for running this on the Pascal card — that's exactly the class of machine it targets, and good to see the suite green there.
Confirming the table from this side:
bit 31(culled) into every primitive index word of the group slice before any lane exports, so a group that lands on scratch an earlier chunk of the shared buffer used cannot leak its triangles — also whenmax_primitives > threads. Vertex slots past the export are zeroed rather than left stale.u0/b0/t0in a dedicated register space), and the graphics half carries the pixel stage plus a vertex-visiblet0for the unpack VS. The title's mesh bindings never share a signature with the pixel stage.VICTORY_MESH_BUFFER_MB), sliced per group by the program's declaredmax_vertices/max_primitives, and dispatches are chunked bygroup_cap(min(fits, 65535) groups) so one draw never depends on a worst-case-size allocation.On the #189 row — I checked, and there are two concrete interaction points, both real:
shader.dxil.mesh-emuvsshader.dxil) keyed by build + container; that is what keeps an emulated run from serving native entries today. #189 adds the wave64 mode as a runtime choice, and the build fingerprint only covers rebuilds — so once it lands, the mode has to go into the converter id/input the same way, or switchingVICTORY_WAVE64_EMULATEat run time will serve a translation emitted for the other mode.lower.rsstill setsWaveSize(64)from the console program's wave64 flag when lane numbering or single-wave LDS is involved (console_lanes || one_wave && lds). On a 32-lane host that compute PSO is refused atCreateComputePipelineState, so the emulated mesh pipeline drops with a warning instead of running — the same rejection #189 removes for plain compute. When the two are combined,emit_withshould take both modes and the mesh-emu path should lower through #189's wave64 handling. That is the "lane numbering follows the mode" case in the table, and it is where the two PRs genuinely need each other on 32-lane cards.On settling on one approach — that's the maintainers' call, and happy to help either way. From this PR, the parts that would survive a fold-in regardless of direction: the GPU side (group-cap chunking, the ExecuteIndirect prep pass and slot map, the shared output buffer and its UAV/SRV state machine), and the VSH2 cache split. If #189 lands first I'm glad to rebase on it and wire the two modes together.
@yoraudev on GitHub · 2026-11-24 21:39 UTC · original
Root cause found for the world-entry crash on a mesh-less card ("a host command list did not close (Unspecified error (0x80004005)): a command recorded into it was invalid", frame 29347 on an RX 580, this branch's first emulated mesh frame), and fixed in
c6ec4ad.Diagnosis. That message was read as "an invalid command was recorded", but D3D12's
Closereturns E_FAIL for an already-closed list as well (the docs list both causes; our failure text only named one). The failing frame closes a sealed command list a second time — the title's re-close after its frame accounting sees the first-use dispatch drop, as far as I can tell — and the secondCloseended the run.How it was pinned down. The exact shader pair from the log (
mesh d4111a6e6ea49d91+pixel c0a7fe77b1862e10,MSNC_VS_BakeDecorations/PS_BakeDecorations) was pulled out of the title'sshaders.rpf(newextract_containerstest, local-only), the cached translation decoded to check its real bindings (newdump_cached_mesh_entriestest), and the full emulated pipeline + dispatch replayed on the same GPU (newemulated_mesh_dispatch_closestest): the direct and indirect emulated dispatches record and close cleanly, retail and with the debug layer — closing the list a second time reproduces the run's error verbatim.Fix.
HostListnow tracks closed-ness: a secondclosewarns once (a host command list closed twice; the second close does nothing, counted for the frame line) and is a no-op, andresetreopens. The console API tolerates re-closing a sealed list; the host now does too. Genuinely invalid recorded commands still fail as before.The three new tests are
#[ignore]d and need local title files, so CI stays hermetic and the asset policy is untouched (cargo xtask policy: 156 files ok).cargo test -p victory-gpu -p victoryand clippy pass. A re-run of the world entry on the RX 580 should now get past this point; the new warn line will tell us if the title re-closes per frame.@Marvisak on GitHub · 2026-11-25 03:32 UTC · original · edited 2026-11-25 15:54 UTC
Automated triage for the maintainers.
This pull request no longer merges cleanly into
main(conflicts incrates/victory-gpu/src/draw.rs,crates/victory-gpu/src/host.rs,crates/victory-gpu/src/indirect.rs,crates/victory-shader/src/emit/lower.rs,crates/victory-shader/src/emit/mod.rs,crates/victory-shader/src/emit/shader.rs). It will be reviewed once it is rebased onto the currentmain. The earlier verdict (needs work) was for an older state ofmain.Generated by Claude Code
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.Merge
Merge the changes and update on Forgejo.