native: run ExecuteIndirect with a count buffer, gated on the GPU #116
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/116"
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 LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-26T17:15:43Z.
Takes "count buffers for ExecuteIndirect" from your free-to-take list, on top of
8765326.Why. D3D12 runs
min(*count, MaxCommandCount)records, with the count read on the GPU when the work runs. A culling pass usually writes it earlier in the same submission. The native host dropped every ExecuteIndirect with a count buffer.What.
NativeList::dispatch_indirect_counted,draw_indirect_counted). The count is resolved like the record, so a count at unmapped memory drops only that command (as #102 does).gfx.rs,GATE) runs before each counted record. It copies the record into a small Metal-tracked buffer, or writes zeros there when the index is not below the count. The indirect command reads that buffer, so a zeroed record dispatches no groups and draws nothing.count_offsetis applied on both the macOS and Windows paths.Why not an indirect command buffer. Encoding the converted shaders' argument-buffer bindings into an ICB is much larger than one gate per record.
Known limit (marked
shortcut:in the code). There is one gate dispatch and one small buffer per record. If a largeMaxCommandCountshows up in profiles, all records of one ExecuteIndirect can be gated in a single dispatch.Tests.
a_count_buffer_limits_the_indirect_draws_that_run,a_count_buffer_limits_the_indirect_dispatches_that_run.a_count_written_earlier_on_the_gpu_limits_the_indirect_dispatches(the count is written by a copy earlier in the same list). It fails when the gate ignores the count.victory-gpu (arm64) and victory-metal tests, Windows clippy and
cargo xtask policypass. Not checked in game.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-26T17:31:39Z.
Rebased on main for
ce35cbc(metal.rs: kept both the new failure-trace fields and the gate pipeline). victory-gpu and victory-metal tests, Windows clippy and policy pass.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T18:09:47Z.
Merged, thanks. The per-record gate is a clean fit, and the count tests pass on Metal.