[Mesa-dev] [PATCH] mesa: remove samplerobj inlined comparison

Timothy Arceri t_arceri at yahoo.com.au
Fri Aug 7 22:39:35 PDT 2015


In all cases the comparison is either alreay done, or in the case
of deletes comparing against NULL.

gcc wasn't optimising it away either
---
 src/mesa/main/samplerobj.c | 13 ++++++-------
 src/mesa/main/samplerobj.h | 11 +----------
 2 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c
index 32180fb1..98bced7 100644
--- a/src/mesa/main/samplerobj.c
+++ b/src/mesa/main/samplerobj.c
@@ -77,9 +77,9 @@ lookup_samplerobj_locked(struct gl_context *ctx, GLuint name)
  * Handle reference counting.
  */
 void
-_mesa_reference_sampler_object_(struct gl_context *ctx,
-                                struct gl_sampler_object **ptr,
-                                struct gl_sampler_object *samp)
+_mesa_reference_sampler_object(struct gl_context *ctx,
+                               struct gl_sampler_object **ptr,
+                               struct gl_sampler_object *samp)
 {
    assert(*ptr != samp); /* The inline wrapper should prevent no-op calls */
 
@@ -312,11 +312,10 @@ _mesa_BindSampler(GLuint unit, GLuint sampler)
    
    if (ctx->Texture.Unit[unit].Sampler != sampObj) {
       FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+      /* bind new sampler */
+      _mesa_reference_sampler_object(ctx, &ctx->Texture.Unit[unit].Sampler,
+                                     sampObj);
    }
-
-   /* bind new sampler */
-   _mesa_reference_sampler_object(ctx, &ctx->Texture.Unit[unit].Sampler,
-                                  sampObj);
 }
 
 
diff --git a/src/mesa/main/samplerobj.h b/src/mesa/main/samplerobj.h
index 7bea911..438509e 100644
--- a/src/mesa/main/samplerobj.h
+++ b/src/mesa/main/samplerobj.h
@@ -58,18 +58,9 @@ _mesa_is_mipmap_filter(const struct gl_sampler_object *samp)
 
 
 extern void
-_mesa_reference_sampler_object_(struct gl_context *ctx,
-                                struct gl_sampler_object **ptr,
-                                struct gl_sampler_object *samp);
-
-static inline void
 _mesa_reference_sampler_object(struct gl_context *ctx,
                                struct gl_sampler_object **ptr,
-                               struct gl_sampler_object *samp)
-{
-   if (*ptr != samp)
-      _mesa_reference_sampler_object_(ctx, ptr, samp);
-}
+                               struct gl_sampler_object *samp);
 
 extern struct gl_sampler_object *
 _mesa_lookup_samplerobj(struct gl_context *ctx, GLuint name);
-- 
2.4.3



More information about the mesa-dev mailing list