vulkan: Properly update image layouts

The render pass ops were not updating the image's layout to the final
layout when a render pass ends.

Fix that.

Also make the layouts explicit arguments to the render pass op.
This commit is contained in:
Benjamin Otte 2023-07-14 23:05:19 +02:00
parent 3327a6ba08
commit 6f2fd001a0
3 changed files with 18 additions and 7 deletions

View File

@ -498,7 +498,9 @@ gsk_vulkan_render_add_node (GskVulkanRender *self,
self->clip,
&scale,
&self->viewport,
node, TRUE);
node,
VK_IMAGE_LAYOUT_UNDEFINED,
VK_IMAGE_LAYOUT_PRESENT_SRC_KHR);
gsk_vulkan_render_seal_ops (self);
gsk_vulkan_render_verbose_print (self, "start of frame");

View File

@ -158,6 +158,7 @@ struct _GskVulkanRenderPassEndOp
GskVulkanOp op;
GskVulkanImage *image;
VkImageLayout final_layout;
};
static void
@ -206,8 +207,13 @@ gsk_vulkan_render_pass_end_op_command (GskVulkanOp *op,
VkPipelineLayout pipeline_layout,
VkCommandBuffer command_buffer)
{
GskVulkanRenderPassEndOp *self = (GskVulkanRenderPassEndOp *) op;
vkCmdEndRenderPass (command_buffer);
gsk_vulkan_image_set_vk_image_layout (self->image,
self->final_layout,
gsk_vulkan_image_get_vk_access (self->image));
return op->next;
}
@ -232,7 +238,8 @@ gsk_vulkan_render_pass_op (GskVulkanRender *render,
const graphene_vec2_t *scale,
const graphene_rect_t *viewport,
GskRenderNode *node,
gboolean is_root)
VkImageLayout initial_layout,
VkImageLayout final_layout)
{
GskVulkanRenderPassOp *self;
GskVulkanRenderPassEndOp *end;
@ -240,9 +247,8 @@ gsk_vulkan_render_pass_op (GskVulkanRender *render,
self = (GskVulkanRenderPassOp *) gsk_vulkan_op_alloc (render, &GSK_VULKAN_RENDER_PASS_OP_CLASS);
self->image = image;
self->initial_layout = VK_IMAGE_LAYOUT_UNDEFINED;
self->final_layout = is_root ? VK_IMAGE_LAYOUT_PRESENT_SRC_KHR
:VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
self->initial_layout = initial_layout;
self->final_layout = final_layout;
cairo_region_get_extents (clip, &self->area);
self->viewport_size = viewport->size;
@ -260,6 +266,7 @@ gsk_vulkan_render_pass_op (GskVulkanRender *render,
end = (GskVulkanRenderPassEndOp *) gsk_vulkan_op_alloc (render, &GSK_VULKAN_RENDER_PASS_END_OP_CLASS);
end->image = g_object_ref (image);
end->final_layout = final_layout;
}
GskVulkanImage *
@ -299,7 +306,8 @@ gsk_vulkan_render_pass_op_offscreen (GskVulkanRender *render,
scale,
&view,
node,
FALSE);
VK_IMAGE_LAYOUT_UNDEFINED,
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
cairo_region_destroy (clip);

View File

@ -11,7 +11,8 @@ void gsk_vulkan_render_pass_op (GskVulk
const graphene_vec2_t *scale,
const graphene_rect_t *viewport,
GskRenderNode *node,
gboolean is_root);
VkImageLayout initial_layout,
VkImageLayout final_layout);
GskVulkanImage * gsk_vulkan_render_pass_op_offscreen (GskVulkanRender *render,
GdkVulkanContext *context,
const graphene_vec2_t *scale,