diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c index a11b53fe74b..b2159bcbc23 100644 --- a/src/gallium/drivers/zink/zink_batch.c +++ b/src/gallium/drivers/zink/zink_batch.c @@ -14,6 +14,8 @@ #include "util/u_debug.h" #include "util/set.h" +#include "wsi_common.h" + void zink_reset_batch(struct zink_context *ctx, struct zink_batch *batch) { @@ -135,6 +137,16 @@ zink_end_batch(struct zink_context *ctx, struct zink_batch *batch) si.commandBufferCount = 1; si.pCommandBuffers = &batch->cmdbuf; + struct wsi_memory_signal_submit_info mem_signal = { + .sType = VK_STRUCTURE_TYPE_WSI_MEMORY_SIGNAL_SUBMIT_INFO_MESA, + .pNext = si.pNext, + }; + + if (batch->flush_res) { + mem_signal.memory = batch->flush_res->mem; + si.pNext = &mem_signal; + } + if (vkQueueSubmit(ctx->queue, 1, &si, batch->fence->fence) != VK_SUCCESS) { debug_printf("ZINK: vkQueueSubmit() failed\n"); ctx->is_device_lost = true; @@ -144,6 +156,7 @@ zink_end_batch(struct zink_context *ctx, struct zink_batch *batch) } } batch->submitted = true; + batch->flush_res = NULL; } /* returns either the compute batch id or 0 (gfx batch id) based on whether a resource diff --git a/src/gallium/drivers/zink/zink_batch.h b/src/gallium/drivers/zink/zink_batch.h index d5b902d7a2d..0554931afa3 100644 --- a/src/gallium/drivers/zink/zink_batch.h +++ b/src/gallium/drivers/zink/zink_batch.h @@ -46,6 +46,8 @@ struct zink_batch { VkCommandPool cmdpool; VkCommandBuffer cmdbuf; + struct zink_resource *flush_res; + unsigned short descs_used; //number of descriptors currently allocated struct zink_fence *fence; diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 6917af476c9..eed7d06766a 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -1621,6 +1621,8 @@ zink_flush(struct pipe_context *pctx, zink_resource_image_barrier(ctx, batch, ctx->fb_state.cbufs[i] ? zink_resource(ctx->fb_state.cbufs[i]->texture) : NULL, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, 0, 0); + if (zink_screen(pctx->screen)->needs_mesa_flush_wsi && ctx->fb_state.cbufs[0]) + batch->flush_res = zink_resource(ctx->fb_state.cbufs[0]->texture); } flush_batch(ctx);