Mesa (main): zink: split deferring of barriers to image and buffer functions
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jun 24 23:23:49 UTC 2021
Module: Mesa
Branch: main
Commit: d3b7b355840531db9e122530504664d319c01c39
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d3b7b355840531db9e122530504664d319c01c39
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Mon May 10 16:51:49 2021 -0400
zink: split deferring of barriers to image and buffer functions
make this more explicit
Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11590>
---
src/gallium/drivers/zink/zink_context.c | 33 ++++++++++++++++++++++++++++++---
1 file changed, 30 insertions(+), 3 deletions(-)
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index f3530d462d3..1c26e599940 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -2164,8 +2164,9 @@ is_shader_pipline_stage(VkPipelineStageFlags pipeline)
}
static void
-resource_check_defer_barrier(struct zink_context *ctx, struct zink_resource *res, VkPipelineStageFlags pipeline)
+resource_check_defer_buffer_barrier(struct zink_context *ctx, struct zink_resource *res, VkPipelineStageFlags pipeline)
{
+ assert(res->obj->is_buffer);
if (res->bind_count[0]) {
if ((res->obj->is_buffer && res->vbo_bind_count && !(pipeline & VK_PIPELINE_STAGE_VERTEX_INPUT_BIT)) ||
((!res->obj->is_buffer || res->vbo_bind_count != res->bind_count[0]) && !is_shader_pipline_stage(pipeline)))
@@ -2191,6 +2192,32 @@ get_cmdbuf(struct zink_context *ctx, struct zink_resource *res)
return ctx->batch.state->barrier_cmdbuf;
}
+static void
+resource_check_defer_image_barrier(struct zink_context *ctx, struct zink_resource *res, VkImageLayout layout, VkPipelineStageFlags pipeline)
+{
+ assert(!res->obj->is_buffer);
+
+ bool is_compute = pipeline == VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
+ /* if this is a non-shader barrier and there are binds, always queue a shader barrier */
+ bool is_shader = is_shader_pipline_stage(pipeline);
+ if ((is_shader || !res->bind_count[is_compute]) &&
+ /* if no layout change is needed between gfx and compute, do nothing */
+ !res->bind_count[!is_compute] && (!is_compute || !res->fb_binds))
+ return;
+
+ if (res->bind_count[!is_compute] && is_shader) {
+ /* if the layout is the same between gfx and compute, do nothing */
+ if (layout == zink_descriptor_util_image_layout_eval(res, !is_compute))
+ return;
+ }
+ /* queue a layout change if a layout change will be needed */
+ if (res->bind_count[!is_compute])
+ _mesa_set_add(ctx->need_barriers[!is_compute], res);
+ /* also queue a layout change if this is a non-shader layout */
+ if (res->bind_count[is_compute] && !is_shader)
+ _mesa_set_add(ctx->need_barriers[is_compute], res);
+}
+
void
zink_resource_image_barrier(struct zink_context *ctx, struct zink_batch *batch, struct zink_resource *res,
VkImageLayout new_layout, VkAccessFlags flags, VkPipelineStageFlags pipeline)
@@ -2217,7 +2244,7 @@ zink_resource_image_barrier(struct zink_context *ctx, struct zink_batch *batch,
1, &imb
);
- resource_check_defer_barrier(ctx, res, pipeline);
+ resource_check_defer_image_barrier(ctx, res, new_layout, pipeline);
if (res->unordered_barrier) {
res->access |= imb.dstAccessMask;
@@ -2314,7 +2341,7 @@ zink_resource_buffer_barrier(struct zink_context *ctx, struct zink_batch *batch,
0, NULL
);
- resource_check_defer_barrier(ctx, res, pipeline);
+ resource_check_defer_buffer_barrier(ctx, res, pipeline);
if (res->unordered_barrier) {
res->access |= bmb.dstAccessMask;
More information about the mesa-commit
mailing list