Files
mandy/runtime/test/glsl/cs_group_marker.comp
Tyrannys 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

17 lines
838 B
Plaintext

// indirect_clamp_test's marker: every workgroup adds 1 to its own word, so a dispatch whose groups all ran exactly
// once leaves 1 in each of its words. Only one dimension of a test dispatch is larger than 1, so x + y + z names the
// group; a group past `groups` (which the dispatch should never run) counts in the word after them.
// SPIR-V: runtime/test/cs_group_marker_spv.h (glslangValidator -V --target-env vulkan1.2 -Os).
#version 460
#extension GL_EXT_buffer_reference : require
layout(local_size_x = 1) in;
layout(buffer_reference, std430, buffer_reference_align = 4) buffer Marks { uint data[]; };
layout(push_constant) uniform Params {
Marks marks;
uint groups;
} p;
void main() {
const uint group = gl_WorkGroupID.x + gl_WorkGroupID.y + gl_WorkGroupID.z;
atomicAdd(p.marks.data[min(group, p.groups)], 1u);
}