Module: Mesa Branch: main Commit: 00206e01a47e2a3d4596f3b6b29da1a1c23b7237 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=00206e01a47e2a3d4596f3b6b29da1a1c23b7237
Author: Mike Blumenkrantz <[email protected]> Date: Wed Oct 4 15:17:24 2023 -0400 zink: handle unsynchronized image maps from tc Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25624> --- src/gallium/drivers/zink/zink_context.c | 8 ++++++++ src/gallium/drivers/zink/zink_resource.c | 23 +++++++++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index f8e742fc9cf..f8940cd534a 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -4898,6 +4898,13 @@ zink_context_is_resource_busy(struct pipe_screen *pscreen, struct pipe_resource { struct zink_screen *screen = zink_screen(pscreen); struct zink_resource *res = zink_resource(pres); + if (!res->obj->is_buffer && usage & PIPE_MAP_UNSYNCHRONIZED) { + if (zink_is_swapchain(res)) + return true; + if (!(res->obj->vkusage & VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT) && + (!res->linear || !res->obj->host_visible)) + return true; + } uint32_t check_usage = 0; if (usage & PIPE_MAP_READ) check_usage |= ZINK_RESOURCE_ACCESS_WRITE; @@ -5518,6 +5525,7 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags) .is_resource_busy = zink_context_is_resource_busy, .driver_calls_flush_notify = !screen->driver_workarounds.track_renderpasses, .unsynchronized_get_device_reset_status = true, + .unsynchronized_texture_subdata = true, .parse_renderpass_info = screen->driver_workarounds.track_renderpasses, .dsa_parse = zink_tc_parse_dsa, .fs_parse = zink_tc_parse_fs, diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c index 02ed8b86a5d..1ba8be0b56d 100644 --- a/src/gallium/drivers/zink/zink_resource.c +++ b/src/gallium/drivers/zink/zink_resource.c @@ -2302,13 +2302,16 @@ zink_image_map(struct pipe_context *pctx, zink_kopper_acquire(ctx, res, 0); void *ptr; - if (usage & PIPE_MAP_WRITE && !(usage & PIPE_MAP_READ)) - /* this is like a blit, so we can potentially dump some clears or maybe we have to */ - zink_fb_clears_apply_or_discard(ctx, pres, zink_rect_from_box(box), false); - else if (usage & PIPE_MAP_READ) - /* if the map region intersects with any clears then we have to apply them */ - zink_fb_clears_apply_region(ctx, pres, zink_rect_from_box(box)); + if (!(usage & PIPE_MAP_UNSYNCHRONIZED)) { + if (usage & PIPE_MAP_WRITE && !(usage & PIPE_MAP_READ)) + /* this is like a blit, so we can potentially dump some clears or maybe we have to */ + zink_fb_clears_apply_or_discard(ctx, pres, zink_rect_from_box(box), false); + else if (usage & PIPE_MAP_READ) + /* if the map region intersects with any clears then we have to apply them */ + zink_fb_clears_apply_region(ctx, pres, zink_rect_from_box(box)); + } if (!res->linear || !res->obj->host_visible) { + assert(!(usage & PIPE_MAP_UNSYNCHRONIZED)); enum pipe_format format = pres->format; if (usage & PIPE_MAP_DEPTH_ONLY) format = util_format_get_depth_only(pres->format); @@ -2353,6 +2356,7 @@ zink_image_map(struct pipe_context *pctx, if (!ptr) goto fail; if (zink_resource_has_usage(res)) { + assert(!(usage & PIPE_MAP_UNSYNCHRONIZED)); if (usage & PIPE_MAP_WRITE) zink_fence_wait(pctx); else @@ -2389,8 +2393,10 @@ zink_image_map(struct pipe_context *pctx, if (!ptr) goto fail; if (usage & PIPE_MAP_WRITE) { - if (!res->valid && res->fb_bind_count) + if (!res->valid && res->fb_bind_count) { + assert(!(usage & PIPE_MAP_UNSYNCHRONIZED)); ctx->rp_loadop_changed = true; + } res->valid = true; } @@ -2420,7 +2426,8 @@ zink_image_subdata(struct pipe_context *pctx, struct zink_resource *res = zink_resource(pres); /* flush clears to avoid subdata conflict */ - if (res->obj->vkusage & VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT) + if (!(usage & TC_TRANSFER_MAP_THREADED_UNSYNC) && + (res->obj->vkusage & VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT)) zink_fb_clears_apply_or_discard(ctx, pres, zink_rect_from_box(box), false); /* only use HIC if supported on image and no pending usage */ while (res->obj->vkusage & VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT &&
