st/mesa: inline and optimize st_invalidate_readpix_cache
authorMarek Olšák <marek.olsak@amd.com>
Sun, 9 Apr 2017 14:39:39 +0000 (16:39 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 20 Apr 2017 18:11:35 +0000 (20:11 +0200)
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/state_tracker/st_cb_readpixels.c
src/mesa/state_tracker/st_context.h

index 795519d0a7e2a2a6f30acaebeaba879b25327670..0bcf2eb4fdfabbee160791007d98f61306a76d9e 100644 (file)
@@ -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.
  */
index bb00384365916a8698d68eb7e9bbcf6f2ea88f06..dfee9275657bc899fb9f2bc4baf4c74fc28a9061 100644 (file)
 #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