summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2017-04-09 16:39:39 +0200
committerMarek Olšák <[email protected]>2017-04-20 20:11:35 +0200
commit69423dcf232a2cb6c9672ce95f684afa1d3842d2 (patch)
tree2be99ff4ece7af22a6c9377109750f98b3c45ba0
parent7cd6e2df65de9e2f0d77022a64c4e48ca2ebcb33 (diff)
st/mesa: inline and optimize st_invalidate_readpix_cache
Reviewed-by: Ilia Mirkin <[email protected]> Reviewed-by: Brian Paul <[email protected]>
-rw-r--r--src/mesa/state_tracker/st_cb_readpixels.c8
-rw-r--r--src/mesa/state_tracker/st_context.h13
2 files changed, 11 insertions, 10 deletions
diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
index 795519d0a7e..0bcf2eb4fdf 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/src/mesa/state_tracker/st_cb_readpixels.c
@@ -251,14 +251,6 @@ 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.h b/src/mesa/state_tracker/st_context.h
index bb003843659..dfee9275657 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -29,10 +29,10 @@
#define ST_CONTEXT_H
#include "main/mtypes.h"
-#include "pipe/p_state.h"
#include "state_tracker/st_api.h"
#include "main/fbobject.h"
#include "state_tracker/st_atom.h"
+#include "util/u_inlines.h"
#ifdef __cplusplus
@@ -287,7 +287,16 @@ 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);
+/* Invalidate the readpixels cache to ensure we don't read stale data.
+ */
+static inline void
+st_invalidate_readpix_cache(struct st_context *st)
+{
+ if (unlikely(st->readpix_cache.src)) {
+ pipe_resource_reference(&st->readpix_cache.src, NULL);
+ pipe_resource_reference(&st->readpix_cache.cache, NULL);
+ }
+}
#define Y_0_TOP 1