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/22630>
This commit is contained in:
Samuel Pitoiset 2023-04-18 14:01:51 +02:00 committed by Eric Engestrom
parent 3b465a15bb
commit d6761f54b5
3 changed files with 11 additions and 3 deletions

View file

@ -598,7 +598,7 @@
"description": "radv: track DB_COUNT_CONTROL changes to avoid context rolls",
"nominated": false,
"nomination_type": null,
"resolution": 4,
"resolution": 1,
"main_sha": null,
"because_sha": null
},

View file

@ -3660,9 +3660,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
@ -5841,6 +5845,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 |
@ -7657,6 +7662,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;