v3dv: be more careful when restoring dirty state after meta operations

So far we have been only restoring dirty dynamic states used by meta
pipelines however, static state from meta pipelines will also clear
dirty flags, preventing follow-up draw calls in the command buffer
to honor these if they are flagged as dynamic states in their
pipelines. Fix this by always resetting all dirty state flags after
a meta operation so we re-emit all the state we need with the next draw
call.

Fixes:
dEQP-VK.dynamic_state.monolithic.image.clear

cc: mesa-stable

Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20356>
This commit is contained in:
Iago Toral Quiroga 2022-12-16 12:31:27 +01:00 committed by Marge Bot
parent 3cc863649f
commit df8611e816
6 changed files with 12 additions and 25 deletions

View file

@ -2522,7 +2522,6 @@ v3dv_cmd_buffer_meta_state_push(struct v3dv_cmd_buffer *cmd_buffer,
*/
void
v3dv_cmd_buffer_meta_state_pop(struct v3dv_cmd_buffer *cmd_buffer,
uint32_t dirty_dynamic_state,
bool needs_subpass_resume)
{
struct v3dv_cmd_buffer_state *state = &cmd_buffer->state;
@ -2565,10 +2564,9 @@ v3dv_cmd_buffer_meta_state_pop(struct v3dv_cmd_buffer *cmd_buffer,
state->gfx.pipeline = NULL;
}
if (dirty_dynamic_state) {
memcpy(&state->dynamic, &state->meta.dynamic, sizeof(state->dynamic));
state->dirty |= dirty_dynamic_state;
}
/* Restore dynamic state */
memcpy(&state->dynamic, &state->meta.dynamic, sizeof(state->dynamic));
state->dirty = ~0;
if (state->meta.has_descriptor_state) {
if (state->meta.gfx.descriptor_state.valid != 0) {

View file

@ -514,7 +514,7 @@ cmd_buffer_emit_set_event(struct v3dv_cmd_buffer *cmd_buffer,
vk_common_CmdDispatch(commandBuffer, 1, 1, 1);
v3dv_cmd_buffer_meta_state_pop(cmd_buffer, 0, false);
v3dv_cmd_buffer_meta_state_pop(cmd_buffer, false);
}
static void
@ -544,7 +544,7 @@ cmd_buffer_emit_wait_event(struct v3dv_cmd_buffer *cmd_buffer,
vk_common_CmdDispatch(commandBuffer, 1, 1, 1);
v3dv_cmd_buffer_meta_state_pop(cmd_buffer, 0, false);
v3dv_cmd_buffer_meta_state_pop(cmd_buffer, false);
}
VKAPI_ATTR void VKAPI_CALL

View file

@ -1026,8 +1026,6 @@ emit_subpass_color_clear_rects(struct v3dv_cmd_buffer *cmd_buffer,
VK_PIPELINE_BIND_POINT_GRAPHICS,
pipeline->pipeline);
uint32_t dynamic_states = V3DV_CMD_DIRTY_VIEWPORT | V3DV_CMD_DIRTY_SCISSOR;
for (uint32_t i = 0; i < rect_count; i++) {
const VkViewport viewport = {
.x = rects[i].rect.offset.x,
@ -1064,7 +1062,7 @@ emit_subpass_color_clear_rects(struct v3dv_cmd_buffer *cmd_buffer,
cmd_buffer, (uintptr_t)pipeline,
(v3dv_cmd_buffer_private_obj_destroy_cb) destroy_color_clear_pipeline);
v3dv_cmd_buffer_meta_state_pop(cmd_buffer, dynamic_states, false);
v3dv_cmd_buffer_meta_state_pop(cmd_buffer, false);
}
/* Emits a scissored quad, clearing the depth aspect by writing to gl_FragDepth
@ -1116,7 +1114,6 @@ emit_subpass_ds_clear_rects(struct v3dv_cmd_buffer *cmd_buffer,
VK_PIPELINE_BIND_POINT_GRAPHICS,
pipeline->pipeline);
uint32_t dynamic_states = V3DV_CMD_DIRTY_VIEWPORT | V3DV_CMD_DIRTY_SCISSOR;
if (aspects & VK_IMAGE_ASPECT_STENCIL_BIT) {
v3dv_CmdSetStencilReference(cmd_buffer_handle,
VK_STENCIL_FACE_FRONT_AND_BACK,
@ -1125,9 +1122,6 @@ emit_subpass_ds_clear_rects(struct v3dv_cmd_buffer *cmd_buffer,
VK_STENCIL_FACE_FRONT_AND_BACK, 0xff);
v3dv_CmdSetStencilCompareMask(cmd_buffer_handle,
VK_STENCIL_FACE_FRONT_AND_BACK, 0xff);
dynamic_states |= VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK |
VK_DYNAMIC_STATE_STENCIL_WRITE_MASK |
VK_DYNAMIC_STATE_STENCIL_REFERENCE;
}
for (uint32_t i = 0; i < rect_count; i++) {
@ -1156,7 +1150,7 @@ emit_subpass_ds_clear_rects(struct v3dv_cmd_buffer *cmd_buffer,
}
}
v3dv_cmd_buffer_meta_state_pop(cmd_buffer, dynamic_states, false);
v3dv_cmd_buffer_meta_state_pop(cmd_buffer, false);
}
static void

View file

@ -2094,7 +2094,6 @@ texel_buffer_shader_copy(struct v3dv_cmd_buffer *cmd_buffer,
/* Push command buffer state before starting meta operation */
v3dv_cmd_buffer_meta_state_push(cmd_buffer, true);
uint32_t dirty_dynamic_state = 0;
/* Bind common state for all layers and regions */
VkCommandBuffer _cmd_buffer = v3dv_cmd_buffer_to_handle(cmd_buffer);
@ -2221,7 +2220,6 @@ texel_buffer_shader_copy(struct v3dv_cmd_buffer *cmd_buffer,
}
/* For each region */
dirty_dynamic_state = V3DV_CMD_DIRTY_VIEWPORT | V3DV_CMD_DIRTY_SCISSOR;
for (uint32_t r = 0; r < region_count; r++) {
const VkBufferImageCopy2 *region = &regions[r];
@ -2279,7 +2277,7 @@ texel_buffer_shader_copy(struct v3dv_cmd_buffer *cmd_buffer,
} /* For each layer */
fail:
v3dv_cmd_buffer_meta_state_pop(cmd_buffer, dirty_dynamic_state, true);
v3dv_cmd_buffer_meta_state_pop(cmd_buffer, true);
return handled;
}
@ -3803,7 +3801,6 @@ blit_shader(struct v3dv_cmd_buffer *cmd_buffer,
{
bool handled = true;
VkResult result;
uint32_t dirty_dynamic_state = 0;
/* We don't support rendering to linear depth/stencil, this should have
* been rewritten to a compatible color blit by the caller.
@ -4204,11 +4201,10 @@ blit_shader(struct v3dv_cmd_buffer *cmd_buffer,
};
v3dv_CmdEndRenderPass2(_cmd_buffer, &sp_end_info);
dirty_dynamic_state = V3DV_CMD_DIRTY_VIEWPORT | V3DV_CMD_DIRTY_SCISSOR;
}
fail:
v3dv_cmd_buffer_meta_state_pop(cmd_buffer, dirty_dynamic_state, true);
v3dv_cmd_buffer_meta_state_pop(cmd_buffer, true);
return handled;
}

View file

@ -1679,7 +1679,6 @@ void v3dv_cmd_buffer_subpass_finish(struct v3dv_cmd_buffer *cmd_buffer);
void v3dv_cmd_buffer_meta_state_push(struct v3dv_cmd_buffer *cmd_buffer,
bool push_descriptor_state);
void v3dv_cmd_buffer_meta_state_pop(struct v3dv_cmd_buffer *cmd_buffer,
uint32_t dirty_dynamic_state,
bool needs_subpass_resume);
void v3dv_cmd_buffer_begin_query(struct v3dv_cmd_buffer *cmd_buffer,

View file

@ -887,7 +887,7 @@ v3dv_cmd_buffer_emit_set_query_availability(struct v3dv_cmd_buffer *cmd_buffer,
0, sizeof(push_data), &push_data);
cmd_buffer_emit_dispatch_queries(cmd_buffer, count);
v3dv_cmd_buffer_meta_state_pop(cmd_buffer, 0, false);
v3dv_cmd_buffer_meta_state_pop(cmd_buffer, false);
}
static void
@ -936,7 +936,7 @@ cmd_buffer_emit_reset_occlusion_query_pool(struct v3dv_cmd_buffer *cmd_buffer,
cmd_buffer_emit_dispatch_queries(cmd_buffer, count);
v3dv_cmd_buffer_meta_state_pop(cmd_buffer, 0, false);
v3dv_cmd_buffer_meta_state_pop(cmd_buffer, false);
/* Ensure future work in the graphics queue using the queries doesn't start
* before the reset completed.
@ -1217,7 +1217,7 @@ cmd_buffer_emit_copy_query_pool_results(struct v3dv_cmd_buffer *cmd_buffer,
cmd_buffer_emit_dispatch_queries(cmd_buffer, count);
v3dv_cmd_buffer_meta_state_pop(cmd_buffer, 0, false);
v3dv_cmd_buffer_meta_state_pop(cmd_buffer, false);
}
static void