Cut a mesh fallback draw's workgroup count that the GPU wrote to what the fallback's buffers hold before a dispatch reads it.

The record's copies put the count the game's culling pass wrote into the first dispatch and, without a task stage, into the draw's instances as it was. A garbage count launched up to millions of workgroups that write nothing and instances that draw nothing, enough to keep the GPU past the driver's timeout; with the fallback now the default on AMD's driver for RDNA 1 and 2, such a count would have moved a hang there instead of removing it. A single-thread compute pass (shaders/meshfb_clamp.comp) cuts the count to the buffers' room, which changes nothing that is drawn; the report word keeps the count asked for, so record_check still logs a mesh-only draw that asked for more than the buffers hold. On for every device that uses the fallback: one dispatch and one barrier per indirect fallback draw.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-13 12:32:02 -05:00
parent 46d71da8aa
commit edd5d04e8c
4 changed files with 68 additions and 3 deletions

View File

@@ -6042,7 +6042,7 @@ static void mfb_draw(VkExec *ex, uint32_t count, const VkMemSpan *ind) {
if (!vs || !vk_meshfb_init()) { draw_skipped(ex, 1, SK_PIPE_FAILED); return; }
uint32_t verts = c->mi.maxp * c->mi.ipp, slot_words = meshfb_slot_words(&c->mi);
uint32_t most = vk_ctx()->props.limits.maxComputeWorkGroupCount[0];
if (count > most) count = most; // a count the GPU wrote is not looked at here: the dispatch reads it as it is
if (count > most) count = most; // a count the GPU wrote is cut on the GPU, below
VkBuffer rec;
int cmds;
vk_exec_barrier(ex); // ends the pass; the culling's record and the last draw's reads come before what follows
@@ -6050,6 +6050,12 @@ static void mfb_draw(VkExec *ex, uint32_t count, const VkMemSpan *ind) {
verts, slot_words, &rec, &cmds);
ex->recorded += (uint32_t)cmds;
vk_exec_barrier(ex);
if (ind) { // to what the buffers hold, before a dispatch reads it (meshfb_clamp.comp)
vk_meshfb_clamp(ex->cb, at, ts ? c->ti.payload_bytes / 4 : 0);
cx->B.pipe[1] = VK_NULL_HANDLE; // the clamp bound its own
ex->recorded += 4;
vk_exec_barrier(ex);
}
if (ts) {
if (!mfb_dispatch(ex, c->cs_task, NVN_STAGE_TASK, rec, at)) { draw_skipped(ex, 1, SK_PIPE_FAILED); return; }
vk_exec_barrier(ex);