Skip to content

anv: Fix MI_ARB_CHECK calls in generated indirect draws optimization

Sviatoslav Peleshko requested to merge GL/mesa:fix_indirect_draws_opt into main

What does this MR do and why?

anv: Fix MI_ARB_CHECK calls in generated indirect draws optimization

According to PRMs, to use self-modifying code correctly we have to
disable preparser before jumping to the generated commands, and re-enable
it with a first command in that buffer.

Old implementation did it wrong: for both inplace and inring generation
it disabled preparser before running the generation shader, had it
disabled during generation, and re-enabled it just before jumping to
the generated commands.

This usually didn't cause any trouble, because the generation shader and
generated draws are in different BOs, and the jump distance is greater than
the command FIFO depth. But we allocate them from the same pool,
so there are rare cases where the end of the BO with generation commands,
and the beginning of the BO with generated draws are adjacent. In such
cases, the wrong commands might be fetched.

Cc: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10162
Signed-off-by: Sviatoslav Peleshko <sviatoslav.peleshko@globallogic.com>

cc @llandwerlin Can you please check if it actually fixes #10162 (closed) for you?

This MR seems to fix the hang for me, but it was rather rare in the first place. Plus, even though the behavior kind of matches, by looking at the batch log and dumped shaders I wasn't able to find the malformed CS shader you referenced in the issue. So I'm not 100% sure if that's even the same issue. (Also you haven't specified which version is affected, the hang happens in DX12 version in the game for me).

Merge request reports