From e28f24fbf2128f17b0aca9d6144545d7e7ea77e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tapani=20P=C3=A4lli?= Date: Thu, 23 Jan 2025 15:06:07 +0200 Subject: [PATCH] mesa/st: take pixelmaps in to account in drawpixels cache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise we might use cache item with different mapping. Cc: mesa-stable Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12492 Signed-off-by: Tapani Pälli Reviewed-by: Adam Jackson Reviewed-by: Marek Olšák Part-of: --- src/mesa/state_tracker/st_cb_drawpixels.c | 6 ++++++ src/mesa/state_tracker/st_context.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 8b593719426..aff4ae81b60 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -485,6 +485,10 @@ search_drawpixels_cache(struct st_context *st, entry->image) { assert(entry->texture); + if (memcmp(&entry->pixelmaps, &st->ctx->PixelMaps, + sizeof(struct gl_pixelmaps)) != 0) + continue; + /* check if the pixel data is the same */ if (memcmp(pixels, entry->image, width * height * bpp) == 0) { /* Success - found a cache match */ @@ -555,6 +559,8 @@ cache_drawpixels_image(struct st_context *st, entry->height = height; entry->format = format; entry->type = type; + memcpy(&entry->pixelmaps, &st->ctx->PixelMaps, + sizeof(struct gl_pixelmaps)); entry->user_pointer = pixels; free(entry->image); entry->image = malloc(width * height * bpp); diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 5787b6adb29..fca561316fd 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -93,6 +93,7 @@ struct drawpix_cache_entry { GLsizei width, height; GLenum format, type; + struct gl_pixelmaps pixelmaps; const void *user_pointer; /**< Last user 'pixels' pointer */ void *image; /**< Copy of the glDrawPixels image data */ struct pipe_resource *texture;