shader/gpu: add compute-to-draw fallback for mesh shaders #246
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/246"
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?
Imported from DexNom/VIctory. Originally posted by rudy-07 on 2026-11-30T17:30:39Z.
GPUs without D3D12 mesh shader support (e.g. AMD RDNA1 / Feature Level 12_1) currently have all mesh pipelines refused in
victory-gpu. This adds a compute-to-draw fallback path when!host.mesh_shaders().Changes:
crates/victory-shader:SLOT_MESH_FALLBACK(251) and addmesh_fallbackcompute lowering (cs_6_6) inlower.rs/shader.rsso mesh shaders write triangle indices, per-vertex outputs, and per-primitive outputs into a per-group scratch buffer instead of callingsetMeshOutputCounts/emitIndices/storeVertexOutput.emit/mesh_fallback.rs(emit_mesh_fallback,mesh_fallback_vs) to generate the matchingvs_6_6pass-through shader readingSV_VertexIDfrom the scratch buffer and forwardingOSG1outputs to the pixel shader.translate_mesh_fallback,Root::Viewsupport inHost::draw, andINPUT_PATHSregistration inlib.rs.crates/victory-gpu:Translated::mesh_fallbackinpipeline.rswhen the host lacks mesh shaders.MeshFallbackPipeline(CS + VS/PS PSOs) inpipeline/host.rsinstead of refusing the pipeline.dispatch_mesh_fallbackindraw.rsto allocate a scratch UAV buffer, dispatch the compute kernel, transition UAV -> SRV, and drawx * max_primitives * 3vertices.Tested on Windows 11 x64 (AMD Radeon RX 5600M, driver 32.0.21043.19003):
cargo test -p victory-shader --locked mesh_fallback: 1 passed (DXIL validation + compute dispatch + VS/PS draw, including edge flags and culling)cargo test -p victory-shader --locked source_tests: 1 passedcargo test -p xtask --locked: 4 passedcargo clippy --workspace --all-targets --locked -- -D warnings: passcargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passImported from DexNom/VIctory. Originally posted by Zippp69 on 2026-11-30T18:04:37Z.
The mesh fallback test needs a writable scratch buffer and a visible pixel output. My Windows run on
fad0bcdfailed withmissing root UAV output. The test bindsRoot::Uav(0)but passes aView::BufferSRV. Usingviews: &[View::RawUavData(&scratch_words)]got through dispatch, and readback contained the expected indices and positions. The next assertion failed becausestub_ps()writes zero to red while the test counts pixels with red greater than 0.5. After making the pixel stub write 1.0 to red, the test passed for the triangle, edge flags, and cull cases. Test fixture · Pixel stubPer-primitive outputs are still unhandled. The compute path reserves and writes per-primitive data, but the generated VS builds its output signature from
fallback.outputsand reads only vertex records. Mesh pipelines that need the primitive outputs cannot receive them through this fallback. The passing triangle fixture has no per-primitive outputs. Forward those outputs or refuse the fallback for affected shaders until it supports them. This finding is from static inspection. Generated VSImported from DexNom/VIctory. Originally posted by rudy-07 on 2026-11-30T18:21:46Z.
Addressed both points in
crates/victory-shader/src/emit/mesh_fallback.rs:mesh_fallback_validates_and_draws_triangleto bindView::RawUavData(&scratch_words)for the compute scratch UAV and use a localsolid_red_ps()(sincestub_ps()writes zeros).emit_mesh_fallbackwhenPSG1has per-primitive outputs (with a unit testemit_mesh_fallback_refuses_per_primitive_outputs) until the fallback VS forwards them.Re-verified
cargo test -p victory-shader --locked mesh_fallback(2 passed),clippy(default &--all-features), andcargo xtask policy --staged.Imported from DexNom/VIctory. Originally posted by Zippp69 on 2026-11-30T18:30:46Z.
Verified the follow-up on
bd28d77. I rerancargo test --locked --offline -p victory-shader --lib mesh_fallback -- --nocaptureon Windows. The triangle/edge-flag/cull test and the new per-primitive rejection test both passed. The new guard safely refuses unsupported per-primitive attributes while the fallback VS lacks forwarding for them. Thanks for addressing both points.Imported from DexNom/VIctory. Originally posted by rudy-07 on 2026-11-30T19:34:30Z.
No probs
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.