turnip: re-emit vertex params after they are invalidated

Constants could be invalidated via HLSQ_INVALIDATE_CMD which is
emitted when new pipeline is bound and in CmdClearAttachments.
Also they become invalid after secondary cmd execution.

Fixes geometry flickering in Genshin Impact
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5313

Fixes: 815a85dd7c "turnip: do not re-emit same vs params"

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12684>
This commit is contained in:
Danylo Piliaiev 2021-09-01 20:21:21 +03:00 committed by Marge Bot
parent 27f2c9dc2e
commit 9ab4bfcb53
2 changed files with 8 additions and 10 deletions

View File

@ -1540,10 +1540,6 @@ tu_BeginCommandBuffer(VkCommandBuffer commandBuffer,
memset(&cmd_buffer->state, 0, sizeof(cmd_buffer->state));
cmd_buffer->state.index_size = 0xff; /* dirty restart index */
cmd_buffer->state.last_vs_params.first_instance = -1;
cmd_buffer->state.last_vs_params.params_offset = -1;
cmd_buffer->state.last_vs_params.vertex_offset = -1;
tu_cache_init(&cmd_buffer->state.cache);
tu_cache_init(&cmd_buffer->state.renderpass_cache);
cmd_buffer->usage_flags = pBeginInfo->flags;
@ -2137,7 +2133,8 @@ tu_CmdBindPipeline(VkCommandBuffer commandBuffer,
assert(pipelineBindPoint == VK_PIPELINE_BIND_POINT_GRAPHICS);
cmd->state.pipeline = pipeline;
cmd->state.dirty |= TU_CMD_DIRTY_DESC_SETS_LOAD | TU_CMD_DIRTY_SHADER_CONSTS | TU_CMD_DIRTY_LRZ;
cmd->state.dirty |= TU_CMD_DIRTY_DESC_SETS_LOAD | TU_CMD_DIRTY_SHADER_CONSTS |
TU_CMD_DIRTY_LRZ | TU_CMD_DIRTY_VS_PARAMS;
/* note: this also avoids emitting draw states before renderpass clears,
* which may use the 3D clear path (for MSAA cases)
@ -4036,14 +4033,17 @@ tu6_emit_vs_params(struct tu_cmd_buffer *cmd,
uint32_t vertex_offset,
uint32_t first_instance)
{
uint32_t offset = vs_params_offset(cmd);
if (offset == cmd->state.last_vs_params.params_offset &&
/* Beside re-emitting params when they are changed, we should re-emit
* them after constants are invalidated via HLSQ_INVALIDATE_CMD.
*/
if (!(cmd->state.dirty & (TU_CMD_DIRTY_DRAW_STATE | TU_CMD_DIRTY_VS_PARAMS)) &&
vertex_offset == cmd->state.last_vs_params.vertex_offset &&
first_instance == cmd->state.last_vs_params.first_instance) {
return;
}
uint32_t offset = vs_params_offset(cmd);
struct tu_cs cs;
VkResult result = tu_cs_begin_sub_stream(&cmd->sub_cs, 3 + (offset ? 8 : 0), &cs);
if (result != VK_SUCCESS) {
@ -4071,7 +4071,6 @@ tu6_emit_vs_params(struct tu_cmd_buffer *cmd,
tu_cs_emit(&cs, 0);
}
cmd->state.last_vs_params.params_offset = offset;
cmd->state.last_vs_params.vertex_offset = vertex_offset;
cmd->state.last_vs_params.first_instance = first_instance;

View File

@ -932,7 +932,6 @@ struct tu_lrz_state
};
struct tu_vs_params {
uint32_t params_offset;
uint32_t vertex_offset;
uint32_t first_instance;
};