mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 19:30:11 +01:00
zink: add barrier helper for buffer resources
Reviewed-by: Hoe Hao Cheng <haochengho12907@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8669>
This commit is contained in:
parent
718c4726f3
commit
37cd4070e8
3 changed files with 45 additions and 1 deletions
|
|
@ -1112,6 +1112,44 @@ zink_resource_barrier(VkCommandBuffer cmdbuf, struct zink_resource *res,
|
|||
res->layout = new_layout;
|
||||
}
|
||||
|
||||
|
||||
static VkPipelineStageFlags
|
||||
pipeline_access_stage(VkAccessFlags flags)
|
||||
{
|
||||
switch (flags) {
|
||||
default:
|
||||
return VK_PIPELINE_STAGE_TRANSFER_BIT;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
zink_resource_buffer_barrier(VkCommandBuffer cmdbuf, struct zink_resource *res, VkAccessFlags flags)
|
||||
{
|
||||
/* TODO: maybe make this more flexible using flags? */
|
||||
VkBufferMemoryBarrier bmb = {
|
||||
VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
|
||||
NULL,
|
||||
res->access,
|
||||
flags,
|
||||
VK_QUEUE_FAMILY_IGNORED,
|
||||
VK_QUEUE_FAMILY_IGNORED,
|
||||
res->buffer,
|
||||
res->offset,
|
||||
res->base.width0
|
||||
};
|
||||
|
||||
vkCmdPipelineBarrier(
|
||||
cmdbuf,
|
||||
pipeline_access_stage(res->access),
|
||||
pipeline_access_stage(flags),
|
||||
0,
|
||||
0, NULL,
|
||||
1, &bmb,
|
||||
0, NULL
|
||||
);
|
||||
res->access = flags;
|
||||
}
|
||||
|
||||
VkShaderStageFlagBits
|
||||
zink_shader_stage(enum pipe_shader_type type)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -192,6 +192,9 @@ zink_fence_wait(struct pipe_context *ctx);
|
|||
void
|
||||
zink_wait_on_batch(struct zink_context *ctx, int batch_id);
|
||||
|
||||
void
|
||||
zink_resource_buffer_barrier(VkCommandBuffer cmdbuf, struct zink_resource *res, VkAccessFlags flags);
|
||||
|
||||
void
|
||||
zink_resource_barrier(VkCommandBuffer cmdbuf, struct zink_resource *res,
|
||||
VkImageAspectFlags aspect, VkImageLayout new_layout);
|
||||
|
|
|
|||
|
|
@ -41,7 +41,10 @@ struct zink_resource {
|
|||
enum pipe_format internal_format:16;
|
||||
|
||||
union {
|
||||
VkBuffer buffer;
|
||||
struct {
|
||||
VkAccessFlags access;
|
||||
VkBuffer buffer;
|
||||
};
|
||||
struct {
|
||||
VkFormat format;
|
||||
VkImage image;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue