radv: track DB_COUNT_CONTROL changes to avoid context rolls

This can be really noticeable for the BeginQuery/Draw/EndQuery pattern.
It seems to improve a depth-only pass by +35% in one upcoming game
because this removes a bunch of context rolls.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22556>
This commit is contained in:
Samuel Pitoiset 2023-04-18 14:01:51 +02:00 committed by Marge Bot
parent 02443d752e
commit c1d32880f7
2 changed files with 10 additions and 2 deletions

View file

@ -3661,9 +3661,13 @@ radv_flush_occlusion_query_state(struct radv_cmd_buffer *cmd_buffer)
}
}
radeon_set_context_reg(cmd_buffer->cs, R_028004_DB_COUNT_CONTROL, db_count_control);
if (db_count_control != cmd_buffer->state.last_db_count_control) {
radeon_set_context_reg(cmd_buffer->cs, R_028004_DB_COUNT_CONTROL, db_count_control);
cmd_buffer->state.context_roll_without_scissor_emitted = true;
cmd_buffer->state.context_roll_without_scissor_emitted = true;
cmd_buffer->state.last_db_count_control = db_count_control;
}
}
unsigned
@ -5842,6 +5846,7 @@ radv_BeginCommandBuffer(VkCommandBuffer commandBuffer, const VkCommandBufferBegi
cmd_buffer->state.last_vrs_rates = -1;
cmd_buffer->state.last_vrs_rates_sgpr_idx = -1;
cmd_buffer->state.last_pa_sc_binner_cntl_0 = -1;
cmd_buffer->state.last_db_count_control = -1;
cmd_buffer->usage_flags = pBeginInfo->flags;
cmd_buffer->state.dirty |= RADV_CMD_DIRTY_DYNAMIC_ALL | RADV_CMD_DIRTY_GUARDBAND |
@ -7651,6 +7656,7 @@ radv_CmdExecuteCommands(VkCommandBuffer commandBuffer, uint32_t commandBufferCou
primary->state.last_first_instance = -1;
primary->state.last_drawid = -1;
primary->state.last_vertex_offset = -1;
primary->state.last_db_count_control = -1;
}
static void

View file

@ -1627,6 +1627,8 @@ struct radv_cmd_state {
uint32_t last_sx_blend_opt_epsilon;
uint32_t last_sx_blend_opt_control;
uint32_t last_db_count_control;
/* Whether CP DMA is busy/idle. */
bool dma_is_busy;