mesa: make _mesa_reference_sampler_object() an inline function
authorBrian Paul <brianp@vmware.com>
Sat, 17 Mar 2012 22:30:03 +0000 (16:30 -0600)
committerBrian Paul <brianp@vmware.com>
Tue, 20 Mar 2012 14:23:32 +0000 (08:23 -0600)
To make the no-change case faster, as we do for the other object-reference
functions.

Reviewed-by: José Fonseca <jfonseca@vmware.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/main/samplerobj.c
src/mesa/main/samplerobj.h

index 7cf0654ada28a681154038e5163c972ae1550e1b..5d1b2adbb080019b0e83dc925aef2136d56a260a 100644 (file)
@@ -55,12 +55,11 @@ _mesa_lookup_samplerobj(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)
 {
-   if (*ptr == samp)
-      return;
+   assert(*ptr != samp); /* The inline wrapper should prevent no-op calls */
 
    if (*ptr) {
       /* Unreference the old sampler */
index fe7d5a7d3b6be972a2c9d6a7906863c924794f45..c22d025dfdfe4184a92cb46de7811ae7cc6b93ed 100644 (file)
@@ -38,9 +38,19 @@ _mesa_get_samplerobj(struct gl_context *ctx, GLuint unit)
 }
 
 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);
+                               struct gl_sampler_object *samp)
+{
+   if (*ptr != samp)
+      _mesa_reference_sampler_object_(ctx, ptr, samp);
+}
+
 
 extern void
 _mesa_init_sampler_object(struct gl_sampler_object *sampObj, GLuint name);