mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-27 21:20:12 +01:00
zink: improve barrier helper for buffer resources and add check for barrier need
now we've got the ability to add fine-grained barriers for buffer resources, so we can also have a utility function to check whether we need to use barriers and then skip them when we don't 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
49ee821eb9
commit
aedde2d60d
2 changed files with 18 additions and 3 deletions
|
|
@ -1159,10 +1159,22 @@ pipeline_access_stage(VkAccessFlags flags)
|
|||
return VK_PIPELINE_STAGE_TRANSFER_BIT;
|
||||
}
|
||||
|
||||
bool
|
||||
zink_resource_buffer_needs_barrier(struct zink_resource *res, VkAccessFlags flags, VkPipelineStageFlags pipeline)
|
||||
{
|
||||
if (!pipeline)
|
||||
pipeline = pipeline_access_stage(flags);
|
||||
return (res->access_stage & pipeline) != pipeline || (res->access & flags) != flags ||
|
||||
(zink_resource_access_is_write(flags) && util_bitcount(flags) > 1);
|
||||
}
|
||||
|
||||
void
|
||||
zink_resource_buffer_barrier(VkCommandBuffer cmdbuf, struct zink_resource *res, VkAccessFlags flags, VkPipelineStageFlags pipeline)
|
||||
{
|
||||
/* TODO: maybe make this more flexible using flags? */
|
||||
if (!pipeline)
|
||||
pipeline = pipeline_access_stage(flags);
|
||||
if (!zink_resource_buffer_needs_barrier(res, flags, pipeline))
|
||||
return;
|
||||
VkBufferMemoryBarrier bmb = {
|
||||
VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
|
||||
NULL,
|
||||
|
|
@ -1178,14 +1190,14 @@ zink_resource_buffer_barrier(VkCommandBuffer cmdbuf, struct zink_resource *res,
|
|||
vkCmdPipelineBarrier(
|
||||
cmdbuf,
|
||||
res->access_stage ? res->access_stage : pipeline_access_stage(res->access),
|
||||
pipeline ? pipeline : pipeline_access_stage(flags),
|
||||
pipeline,
|
||||
0,
|
||||
0, NULL,
|
||||
1, &bmb,
|
||||
0, NULL
|
||||
);
|
||||
res->access = flags;
|
||||
res->access_stage = pipeline ? pipeline : pipeline_access_stage(flags);
|
||||
res->access_stage = pipeline;
|
||||
}
|
||||
|
||||
VkShaderStageFlagBits
|
||||
|
|
|
|||
|
|
@ -195,6 +195,9 @@ zink_wait_on_batch(struct zink_context *ctx, int batch_id);
|
|||
bool
|
||||
zink_resource_access_is_write(VkAccessFlags flags);
|
||||
|
||||
bool
|
||||
zink_resource_buffer_needs_barrier(struct zink_resource *res, VkAccessFlags flags, VkPipelineStageFlags pipeline);
|
||||
|
||||
void
|
||||
zink_resource_buffer_barrier(VkCommandBuffer cmdbuf, struct zink_resource *res, VkAccessFlags flags, VkPipelineStageFlags pipeline);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue