From e4e806503f64620a9c8cb585a5a26ec1e423acf9 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 6 Aug 2025 15:02:56 -0400 Subject: [PATCH] tc: don't sync on internal UNSYNCHRONIZED texture_map calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this can be used for expert-mode optimizations in the frontend when textures are explicitly created for this usage Reviewed-by: Marek Olšák Part-of: --- src/gallium/auxiliary/util/u_threaded_context.c | 17 ++++++++++++----- src/gallium/include/pipe/p_defines.h | 3 ++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c index 68ad8f022e1..7507bb3dfab 100644 --- a/src/gallium/auxiliary/util/u_threaded_context.c +++ b/src/gallium/auxiliary/util/u_threaded_context.c @@ -2835,21 +2835,28 @@ tc_texture_map(struct pipe_context *_pipe, struct threaded_context *tc = threaded_context(_pipe); struct threaded_resource *tres = threaded_resource(resource); struct pipe_context *pipe = tc->pipe; + bool is_internal_unsynchronized = usage & PIPE_MAP_UNSYNCHRONIZED && + resource->flags & PIPE_RESOURCE_FLAG_MAP_UNSYNCHRONIZED; if (tc->options.parse_renderpass_info && TC_RENDERPASS_INFO_HAS_WORK(tc->renderpass_info_recording->data32[0])) tc_check_fb_access(tc, NULL, resource); - tc_sync_msg(tc, "texture"); - tc_set_driver_thread(tc); - /* block all unsync texture subdata during map */ - tc_set_resource_batch_usage_persistent(tc, resource, true); + /* this can only be hit for internal use */ + if (is_internal_unsynchronized) { + usage |= TC_TRANSFER_MAP_THREADED_UNSYNC; + } else { + tc_sync_msg(tc, "texture"); + tc_set_driver_thread(tc); + /* block all unsync texture subdata during map */ + tc_set_resource_batch_usage_persistent(tc, resource, true); + } tc->bytes_mapped_estimate += box->width; void *ret = pipe->texture_map(pipe, tres->latest ? tres->latest : resource, level, usage, box, transfer); - if (!(usage & TC_TRANSFER_MAP_THREADED_UNSYNC)) + if (is_internal_unsynchronized && !(usage & TC_TRANSFER_MAP_THREADED_UNSYNC)) tc_clear_driver_thread(tc); return ret; diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index 6acd4b3e0a8..ae0fdba1a9c 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -518,7 +518,8 @@ enum pipe_flush_flags #define PIPE_RESOURCE_FLAG_UNMAPPABLE (1 << 8) /* implies staging transfers due to VK interop */ #define PIPE_RESOURCE_FLAG_FIXED_ADDRESS (1 << 9) /* virtual memory address never changes */ #define PIPE_RESOURCE_FLAG_FRONTEND_VM (1 << 10) /* the frontend assigns addresses */ -#define PIPE_RESOURCE_FLAG_DRV_PRIV (1 << 11) /* driver/winsys private */ +#define PIPE_RESOURCE_FLAG_MAP_UNSYNCHRONIZED (1 << 11) /* the texture can be mapped UNSYNCHRONIZED */ +#define PIPE_RESOURCE_FLAG_DRV_PRIV (1 << 12) /* driver/winsys private */ #define PIPE_RESOURCE_FLAG_FRONTEND_PRIV (1 << 24) /* gallium frontend private */ /**