zink: add a util function for optimizing TRANSFER_DST image barriers

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21397>
This commit is contained in:
Mike Blumenkrantz 2023-02-23 08:30:09 -05:00 committed by Marge Bot
parent fa6e6545b1
commit 4ad64552b8
2 changed files with 11 additions and 0 deletions

View file

@ -3742,6 +3742,15 @@ zink_resource_image_barrier2(struct zink_context *ctx, struct zink_resource *res
zink_resource_copies_reset(res);
}
void
zink_resource_image_transfer_dst_barrier(struct zink_context *ctx, struct zink_resource *res, unsigned level, const struct pipe_box *box)
{
/* skip TRANSFER_DST barrier if no intersection from previous copies */
if (res->layout != VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL || zink_resource_copy_box_intersects(res, level, box))
zink_screen(ctx->base.screen)->image_barrier(ctx, res, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
zink_resource_copy_box_add(res, level, box);
}
VkPipelineStageFlags
zink_pipeline_flags_from_stage(VkShaderStageFlagBits stage)

View file

@ -115,6 +115,8 @@ zink_resource_image_barrier2(struct zink_context *ctx, struct zink_resource *res
bool
zink_resource_needs_barrier(struct zink_resource *res, VkImageLayout layout, VkAccessFlags flags, VkPipelineStageFlags pipeline);
void
zink_resource_image_transfer_dst_barrier(struct zink_context *ctx, struct zink_resource *res, unsigned level, const struct pipe_box *box);
void
zink_update_descriptor_refs(struct zink_context *ctx, bool compute);
void
zink_init_vk_sample_locations(struct zink_context *ctx, VkSampleLocationsInfoEXT *loc);