gpu: expand console primitive topologies into host list index buffers #690
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!690
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@wbkepler on GitHub · 2026-11-24 06:56 UTC · original
wbkepler:gpu/primitive-topology-expansion→main· +2318 −33 · 4 files · 2 commits · openSummary
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)@fuzeofficlal on GitHub · 2026-11-24 07:39 UTC · original · edited 2026-11-24 08:45 UTC
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.
@Marvisak on GitHub · 2026-11-25 00:35 UTC · original
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
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.