gpu: expand console primitive topologies into host list index buffers #690
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/690"
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 Marvisak/VIctory. Originally posted by wbkepler on 2026-11-24T06:56:27Z.
Summary
Expands console-only primitive topologies (
TRIANGLE_FAN,LINE_LOOP,QUADS,QUAD_STRIP) into standard D3D12TRIANGLELIST/LINELISTscratch index buffers inprimitive.rsanddraw.rs, exposingHostPipeline::strip_cutfrompipeline/host.rs:R16_UINT/R32_UINTindex formats,base_vertex/start_indexoffsets,strip_cutprimitive restarts, consistent winding/provoking-vertex order, and degenerate tail padding.RECTANGLES.Verification
cargo clippy --workspace --all-targets— passed (zero new warnings)cargo clippy -p victory --features diagnostics --all-targets— passedcargo test --workspace— passed (hardware GPU)VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --lib primitive— passed (6/6 including live GPU/WARP backface-culled winding, strip-cut, andLINE_LOOPclosing-edge tests)cargo xtask policy— passed (151 files ok)Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T07:00:05Z.
Review: COMMENTED
Static review only (victory-gpu is Windows/D3D12; can't compile or run here):
expand_non_indexed_topologies,expand_indexed_topologies_with_strip_cuts) don't need a GPU — they only need the crate to build, which today means Windows. If the crate ever gets a portable test lane, these are the ones to ungate first.quad_strip_and_line_loop_render_on_gpu, backface-culling check) are the right shape for WARP verification on the Windows runner.once!"console topology drawn as a triangle list" fallback with realDrawIndexedInstancedthrough a scratch index buffer — the right direction, and theExpandedTopology::from_consolemapping keeps standard PC topologies untouched.One thing to confirm on Windows:
DrawIndexedInstanced(count, instances, 0, base, first_instance)—baseas BaseVertexLocation works only if the scratch indices are relative to it; the pure tests cover the index sequences, so the GPU tests should confirm end-to-end.Imported from Marvisak/VIctory. Originally posted by LAKSHYA-cmd-tech on 2026-11-24T07:13:18Z.
Review: APPROVED
Tested on Windows 11 MSVC (rustc 1.98.1):
Confirmed: BaseVertexLocation offset handling correctly addresses scratch index sequences and non-indexed topology expansions with accurate winding and primitive restart cuts.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-24T07:39:00Z.
I exercised the indexed draw path on
79a476fwith a synthetic 4×4 target, on RTX 5090 and WARP. Before the draw, a nativeCopyBufferRegionreplaces three indices in the same VIctory index-buffer shadow.On both backends, a standard triangle-list draw with that same-list copy rendered the expected 16/16 green pixels. The expanded triangle fan also matched 16/16 when the indices came from the CPU or from a GPU copy in a completed earlier submission. The expanded fan with the copy in the same list rendered all 16 pixels red, matching the old indices. After that submission the index copyback contained the new indices, even though the draw used the old triangle. The D3D12 debug layer reported no errors.
The fan expansion's deferred CPU read runs while the host prepares the list, before the preceding native copy executes. This case needs to exercise expansion from indices produced earlier on the GPU in the same list.
I tested a separate native prototype at the same head. A private indexed point-list pass with strip cut disabled captures
SV_VertexIDin order through stream output. A compute pass then expands the captured stream, applying the original restart rule, before the final indexed draw. The source stays in its ordinary IA index-buffer state.On RTX 5090 and WARP, the same-list native copy followed by this path rendered 16/16 expected pixels with both 16-bit and 32-bit fan indices. On each adapter, 64 small expansion cases matched the existing CPU output index for index across all four topologies, including restart and padding. D3D12 reported zero errors. The prototype uses a serial compute kernel for these small cases.
The chunked version now matches the CPU expansion in 112 synthetic cases per adapter, up to 262,147 input indices, including restart markers across chunk boundaries. A test-only hook in the real
State::draw_indexedpath then restored the graphics PSO, root parameters and IA topology after capture and compute. In the same R32 fan fixture, stock output was 0/16 expected pixels and the hooked path was 16/16 on both RTX 5090 and WARP. All three controls still match and D3D12 reported zero errors.The local source candidate now reuses capture, work and result buffers on the host list and preserves per-draw CPU snapshots for deferred CPU copies. I tested one closed list with two expanded fans, a following ordinary indexed draw, and two CPU-copy fan draws targeting separate regions. The R32 fan used 32,769 input indices to force scratch growth after the R16 fan. With new producer uploads, a second synchronous submission of the same list swapped the GPU-produced fan colors and still matched all 20 pixels on both adapters for both runs. The R16 case also used a nonzero start index and negative base vertex, and a graphics root constant verified restored bindings. The D3D12 debug layer reported zero errors.
The native copy fixture explicitly puts its source in index-buffer state.
I tested the UAV handoff with a source branch stacked on this PR at
79a476fand #334 ataf2aecf. The integration commitc2ce583requests #334's tracked index-read state after the private expansion buffers are ready and before the capture draw.A native compute shader wrote R32 indices through a UAV in the same list. The fixture registered the producer with the tracker, then used the guest indexed draw entry for an expanded fan and an ordinary triangle list. Each drew 8/8 expected pixels on RTX 5090 and WARP. Replaying the same closed list with new shader parameters changed both draws from green to blue and returned the new indices to CPU memory. Both runs had zero D3D12 debug-layer errors. This covers a tracked writer. Resource discovery for bindless or aliased UAVs is outside this result.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:35:27Z.
Automated triage for the maintainers.
Needs rebase. This PR does not merge cleanly into current
main(ac2525d). Conflicting files:crates/victory-gpu/src/draw.rs,crates/victory-gpu/src/primitive.rs.The content has not been reviewed yet; it will be once the branch is rebased onto
main.Generated by Claude Code
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.