Commit Graph

5 Commits

Author SHA1 Message Date
359ba968d5 indirect clamp: count dispatch records by width and log them (RT-INDIRECT-DISPATCH-COUNTERS)
#2230 bounds a dispatch record by the device's maxComputeWorkGroupCount instead of 65 535. Nothing said how wide
the title's dispatches are, nor when a device's own limit still cuts one (llvmpipe allows 65 535 in x; RADV 2^32 - 1),
which its review asked for. The title's tile passes ask for 67 440 groups in x at 2560x1440 (found in the
VIctory-Belobug-AMD fork of VIctory, crates/victory-gpu/src/indirect.rs; no code of it is used).

- indirect_clamp.comp: stats words 12-15 count dispatch records that run wider than 65 535 groups in x, the widest
  x that runs, those cut at the device's limits (and still running), and all of them.
- vulkan_indirect_clamp.h: the counters, read with the others (16 words a slot, words 8-15 zeroed before the pass),
  and a line every 10 s while dispatch records are clamped: `indirect clamp dispatch: N records, W wider than 65535
  groups in x, widest x X, C cut at the device's limits (x x y x z)`.
- indirect_clamp_spv.h regenerated from the .comp as its header says (glslangValidator 16.6.0).
- docs/d3d12_vulkan.md section 4.7: the device's bound per dimension (it still said 65 535), the line, and the test.

Tests: indirect_clamp_test's cases 6b and 6c check the counters (70 000 x 1 x 1: wider than 65 535 where the device
runs it, cut at its limit and counted where not). tests/test_indirect_clamp_telemetry.py checks the new atomics.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 16:43:28 -05:00
595b1325d9 Merge main (fac8b4bb9) into #2230: keep the device-bound dispatch limit and #2378's unfilled draw records
main's #2378 (a draw record of 2^23 vertices or more runs empty and charges nothing) changed indirect_clamp.comp
next to this branch's dispatch bound. The .comp, vulkan_indirect_clamp.h and indirect_clamp_test.cpp merged without
conflicts and keep both changes. The only conflict was the generated indirect_clamp_spv.h: it is regenerated from the
merged indirect_clamp.comp as its header comment says (glslangValidator 16.6.0, -V --target-env vulkan1.2 -Os
--spirv-val; spirv-val passes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 15:05:45 -05:00
f324b94a72 indirect clamp: a draw record of 2^23 vertices or more runs empty and free (RT-INDIRECT-DRAW-UNFILLED-COUNT)
The clamp cut a garbage draw count to 2^24 vertices and charged it against the
list's 2^27-unit budget. Only records whose words are all 0xFFFFFFFF were
treated as unfilled. A slot with a garbage count but other words set therefore
cost 2^24 units, so eight such records used up the budget and every real draw
after them in the list ran empty.

A census in codec-d/cool_fox's fork of VIctory found 90 records of 2^24
vertices in one list, and that fork treats 2^23 vertices an instance or more as
unfilled. Here such a record now runs empty, keeps its locations and charges
nothing. Draws under 2^23 are unchanged.

indirect_clamp_test: the old garbage cases now expect an empty record. New
cases check the 2^23 edge and 16 garbage counts ahead of a real draw, which ran
empty with the old shader and runs with this one. The list-budget case uses a
real 2^22 x 16 draw. indirect_clamp_spv.h was regenerated with glslangValidator
15.1.0 (-V --target-env vulkan1.2 -Os).

Tested: full ctest (108 tests) on Linux with Mesa lavapipe (llvmpipe, LLVM 19.1.7).

Changes made by Claude Code (AI-assisted).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JPqXc6svM4pbBagTsVEYA3
2026-11-26 13:29:11 +00:00
7a761696dc indirect clamp: bound dispatch records by the device's maxComputeWorkGroupCount
The ExecuteIndirect argument clamp (indirect_clamp.comp) cut every dispatch
record at a fixed 65,535 groups per dimension, Vulkan's guaranteed minimum.
Devices report far more in x (NVIDIA: 2^31 - 1), so a one-dimensional
indirect dispatch of more than 65,535 groups ran only its first 65,535
groups; the rest never wrote their output.

The clamp now takes the device's maxComputeWorkGroupCount per axis in its
push constants (88 bytes, was 72) and bounds dispatch records by that. The
2^20 groups-per-dispatch cap, the list budget and LEONIDA_INDIRECT_GROUP_BUDGET
are unchanged; the product check now divides instead of multiplying, since x
alone may exceed 65,535. Mesh dispatches keep 65,535 in x.

indirect_clamp_test runs real indirect dispatches through the clamped
scratch with a marker shader (one atomic per group): 70,000 x 1 x 1 ran
65,535 groups and left 4,465 unrun on main, and runs all 70,000 exactly once
now; 65,535 x 1 x 1 and 1 x 65,535 x 1 (at the old limit) run exactly once
on both. A size past the device's own limit is skipped.

Idea from codec-d/cool_fox docs/findings.md ("Blocky patches: indirect
dispatches cut at 65,535 groups"); idea only, no code taken.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 02:27:26 -06:00
ba626820ec Integrate post-story-load memory, queue and Vulkan runtime changes
Preserve physical window aliases across remaps, order console list values,
and replay bounded indirect graphics with captured draw state. Coordinate
pipeline lifetime, texture refresh and queue teardown. Add synthetic CPU
and GPU coverage for the integrated paths.

Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com>
Co-authored-by: ivanepsilondelta <264061546+ivanepsilondelta@users.noreply.github.com>
2026-11-25 03:44:43 -06:00