From 25b97a3a96aa5937fbbbe5ac114f73b1340ff49e Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 6 Aug 2025 15:03:54 -0400 Subject: [PATCH] mesa/st: mark internal texture map calls as UNSYNCHRONIZED MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit these are new textures with empty contents which are immediately unmapped after a strided memcpy, so there's no reason to force the driver (or tc) to sync Reviewed-by: Marek Olšák Part-of: --- src/mesa/state_tracker/st_atom_pixeltransfer.c | 2 +- src/mesa/state_tracker/st_cb_bitmap.c | 8 ++++---- src/mesa/state_tracker/st_cb_drawpixels.c | 10 +++++----- src/mesa/state_tracker/st_cb_texture.c | 3 ++- src/mesa/state_tracker/st_texcompress_compute.c | 4 ++-- src/mesa/state_tracker/st_texture.c | 2 +- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c b/src/mesa/state_tracker/st_atom_pixeltransfer.c index 423310d7d04..1beb2dcb66b 100644 --- a/src/mesa/state_tracker/st_atom_pixeltransfer.c +++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c @@ -55,7 +55,7 @@ load_color_map_texture(struct gl_context *ctx, struct pipe_resource *pt) uint i, j; dest = (uint *) pipe_texture_map(pipe, - pt, 0, 0, PIPE_MAP_WRITE, + pt, 0, 0, PIPE_MAP_WRITE | PIPE_MAP_UNSYNCHRONIZED, 0, 0, texSize, texSize, &transfer); /* Pack four 1D maps into a 2D texture: diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index d60505254df..a1f05f342a4 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -140,7 +140,7 @@ st_make_bitmap_texture(struct gl_context *ctx, GLsizei width, GLsizei height, * Create texture to hold bitmap pattern. */ pt = st_texture_create(st, st->internal_target, st->bitmap.tex_format, - 0, width, height, 1, 1, 0, 0, + 0, width, height, 1, 1, 0, PIPE_RESOURCE_FLAG_MAP_UNSYNCHRONIZED, PIPE_BIND_SAMPLER_VIEW, false, PIPE_COMPRESSION_FIXED_RATE_NONE); if (!pt) { @@ -149,7 +149,7 @@ st_make_bitmap_texture(struct gl_context *ctx, GLsizei width, GLsizei height, } dest = pipe_texture_map(st->pipe, pt, 0, 0, - PIPE_MAP_WRITE, + PIPE_MAP_WRITE | PIPE_MAP_UNSYNCHRONIZED, 0, 0, width, height, &transfer); /* Put image into texture transfer */ @@ -373,7 +373,7 @@ reset_cache(struct st_context *st) cache->texture = st_texture_create(st, st->internal_target, st->bitmap.tex_format, 0, BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT, - 1, 1, 0, 0, + 1, 1, 0, PIPE_RESOURCE_FLAG_MAP_UNSYNCHRONIZED, PIPE_BIND_SAMPLER_VIEW, false, PIPE_COMPRESSION_FIXED_RATE_NONE); @@ -416,7 +416,7 @@ create_cache_trans(struct st_context *st) * Subsequent glBitmap calls will write into the texture image. */ cache->buffer = pipe_texture_map(pipe, cache->texture, 0, 0, - PIPE_MAP_WRITE, 0, 0, + PIPE_MAP_WRITE | PIPE_MAP_UNSYNCHRONIZED, 0, 0, BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT, &cache->trans); diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 46761b52838..e82a685c810 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -439,12 +439,12 @@ internal_format(struct gl_context *ctx, GLenum format, GLenum type) */ static struct pipe_resource * alloc_texture(struct st_context *st, GLsizei width, GLsizei height, - enum pipe_format texFormat, unsigned bind) + enum pipe_format texFormat, unsigned flags, unsigned bind) { struct pipe_resource *pt; pt = st_texture_create(st, st->internal_target, texFormat, 0, - width, height, 1, 1, 0, 0, bind, false, + width, height, 1, 1, 0, flags, bind, false, PIPE_COMPRESSION_FIXED_RATE_NONE); return pt; @@ -631,7 +631,7 @@ make_texture(struct st_context *st, return NULL; /* alloc temporary texture */ - pt = alloc_texture(st, width, height, pipeFormat, PIPE_BIND_SAMPLER_VIEW); + pt = alloc_texture(st, width, height, pipeFormat, PIPE_RESOURCE_FLAG_MAP_UNSYNCHRONIZED, PIPE_BIND_SAMPLER_VIEW); if (!pt) { _mesa_unmap_pbo_source(ctx, unpack); return NULL; @@ -647,7 +647,7 @@ make_texture(struct st_context *st, /* map texture transfer */ dest = pipe_texture_map(pipe, pt, 0, 0, - PIPE_MAP_WRITE | PIPE_MAP_DISCARD_WHOLE_RESOURCE, + PIPE_MAP_WRITE | PIPE_MAP_DISCARD_WHOLE_RESOURCE | PIPE_MAP_UNSYNCHRONIZED, 0, 0, width, height, &transfer); if (!dest) { pipe_resource_reference(&pt, NULL); @@ -1833,7 +1833,7 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy, readH = MAX2(0, readH); /* Allocate the temporary texture. */ - pt = alloc_texture(st, width, height, srcFormat, srcBind); + pt = alloc_texture(st, width, height, srcFormat, 0, srcBind); if (!pt) return; diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 35d5209de0a..75f3803cb74 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -2284,6 +2284,7 @@ st_TexSubImage(struct gl_context *ctx, GLuint dims, memset(&src_templ, 0, sizeof(src_templ)); src_templ.target = gl_target_to_pipe(gl_target); src_templ.format = src_format; + src_templ.flags = PIPE_RESOURCE_FLAG_MAP_UNSYNCHRONIZED; src_templ.bind = PIPE_BIND_SAMPLER_VIEW; src_templ.usage = PIPE_USAGE_STAGING; @@ -2328,7 +2329,7 @@ st_TexSubImage(struct gl_context *ctx, GLuint dims, height = 1; } - map = pipe_texture_map_3d(pipe, src, 0, PIPE_MAP_WRITE, 0, 0, 0, + map = pipe_texture_map_3d(pipe, src, 0, PIPE_MAP_WRITE | PIPE_MAP_UNSYNCHRONIZED, 0, 0, 0, width, height, depth, &transfer); if (!map) { _mesa_unmap_teximage_pbo(ctx, unpack); diff --git a/src/mesa/state_tracker/st_texcompress_compute.c b/src/mesa/state_tracker/st_texcompress_compute.c index 2f198b19d56..c0bfb083cec 100644 --- a/src/mesa/state_tracker/st_texcompress_compute.c +++ b/src/mesa/state_tracker/st_texcompress_compute.c @@ -481,7 +481,7 @@ sw_decode_astc(struct st_context *st, /* Create the destination */ struct pipe_resource *rgba8_tex = st_texture_create(st, PIPE_TEXTURE_2D, PIPE_FORMAT_R8G8B8A8_UNORM, 0, - width_px, height_px, 1, 1, 0, 0, + width_px, height_px, 1, 1, 0, PIPE_RESOURCE_FLAG_MAP_UNSYNCHRONIZED, PIPE_BIND_SAMPLER_VIEW, false, PIPE_COMPRESSION_FIXED_RATE_NONE); if (!rgba8_tex) @@ -490,7 +490,7 @@ sw_decode_astc(struct st_context *st, /* Temporarily map the destination and decode into the returned pointer */ struct pipe_transfer *rgba8_xfer; void *rgba8_map = pipe_texture_map(st->pipe, rgba8_tex, 0, 0, - PIPE_MAP_WRITE, 0, 0, + PIPE_MAP_WRITE | PIPE_MAP_UNSYNCHRONIZED, 0, 0, width_px, height_px, &rgba8_xfer); if (!rgba8_map) { pipe_resource_reference(&rgba8_tex, NULL); diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index db4c395a77d..18f44e6e3da 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -446,7 +446,7 @@ st_create_color_map_texture(struct gl_context *ctx) /* create texture for color map/table */ pt = st_texture_create(st, PIPE_TEXTURE_2D, format, 0, - texSize, texSize, 1, 1, 0, 0, PIPE_BIND_SAMPLER_VIEW, false, + texSize, texSize, 1, 1, 0, PIPE_RESOURCE_FLAG_MAP_UNSYNCHRONIZED, PIPE_BIND_SAMPLER_VIEW, false, PIPE_COMPRESSION_FIXED_RATE_NONE); return pt; }