tu: Update prim restart state when we switch from/to indexed draw

Previously, if first draw call with wasn't indexed but pipeline
had primitive restart enabled - primitive restart would be disabled
for draw calls, even indexed, that follow.

However, prim restart index works in non-indexed draw calls, but since
we don't emit fresh PC_RESTART_INDEX for them - they may use stale
value if prim restart is enabled for non-indexed draw calls.

So we have track the switch between indexed and non-indexed draw calls
and emit PC_PRIMITIVE_CNTL_0 for them.

Fixes car rear window in Need for Speed: Most Wanted (2012)

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27821>
This commit is contained in:
Danylo Piliaiev 2024-02-27 17:59:18 +01:00 committed by Marge Bot
parent d4f3770ea2
commit 8567d02682
2 changed files with 10 additions and 0 deletions

View file

@ -4904,6 +4904,15 @@ tu6_draw_common(struct tu_cmd_buffer *cmd,
dynamic_draw_state_dirty = tu_emit_draw_state<CHIP>(cmd);
}
/* Primitive restart value works in non-indexed draws, we have to disable
* prim restart for such draws since we may read stale restart index.
*/
if (cmd->state.last_draw_indexed != indexed) {
cmd->state.last_draw_indexed = indexed;
BITSET_SET(cmd->vk.dynamic_graphics_state.dirty,
MESA_VK_DYNAMIC_IA_PRIMITIVE_RESTART_ENABLE);
}
/* Fill draw stats for autotuner */
rp->drawcall_count++;

View file

@ -513,6 +513,7 @@ struct tu_cmd_state
struct tu_draw_state lrz_and_depth_plane_state;
struct tu_vs_params last_vs_params;
bool last_draw_indexed;
struct tu_tess_params tess_params;