From 615ba115632c602d2a77535c1d52024f827a0ace Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicolai=20H=C3=A4hnle?= Date: Wed, 8 Jun 2016 13:22:52 +0200 Subject: [PATCH] st/mesa: add readpix_cache structure MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Marek Olšák --- src/mesa/state_tracker/st_cb_readpixels.c | 8 ++++++++ src/mesa/state_tracker/st_context.c | 3 +++ src/mesa/state_tracker/st_context.h | 11 +++++++++++ 3 files changed, 22 insertions(+) diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index ef575baca9d..a501b7b3ee4 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -218,6 +218,14 @@ fail: return success; } +/* Invalidate the readpixels cache to ensure we don't read stale data. + */ +void st_invalidate_readpix_cache(struct st_context *st) +{ + pipe_resource_reference(&st->readpix_cache.src, NULL); + pipe_resource_reference(&st->readpix_cache.cache, NULL); +} + /** * Create a staging texture and blit the requested region to it. */ diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 308094a43ac..472121581eb 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -184,6 +184,9 @@ st_destroy_context_priv(struct st_context *st) free(st->drawpix_cache.image); pipe_resource_reference(&st->drawpix_cache.texture, NULL); + /* free glReadPixels cache data */ + st_invalidate_readpix_cache(st); + cso_destroy_context(st->cso_context); free( st ); } diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index e3bee60d4d7..cc25e06111e 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -228,6 +228,16 @@ struct st_context struct pipe_resource *texture; } drawpix_cache; + /** for glReadPixels */ + struct { + struct pipe_resource *src; + struct pipe_resource *cache; + enum pipe_format dst_format; + unsigned level; + unsigned layer; + unsigned hits; + } readpix_cache; + /** for glClear */ struct { struct pipe_rasterizer_state raster; @@ -306,6 +316,7 @@ extern void st_init_driver_functions(struct pipe_screen *screen, void st_invalidate_state(struct gl_context * ctx, GLbitfield new_state); +void st_invalidate_readpix_cache(struct st_context *st); #define Y_0_TOP 1 -- 2.30.2