gallium/u_inlines: improve pipe_reference_described perf for debug builds
authorMarek Olšák <marek.olsak@amd.com>
Sat, 1 Sep 2018 05:22:08 +0000 (01:22 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 10 Sep 2018 18:53:01 +0000 (14:53 -0400)
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
src/gallium/auxiliary/util/u_inlines.h

index 83013df53f110a4f278391744a88414a0c6df015..820d3080a5cb2548f4daeb18fc5127f23e9b33c5 100644 (file)
@@ -79,14 +79,15 @@ pipe_reference_described(struct pipe_reference *dst,
    if (dst != src) {
       /* bump the src.count first */
       if (src) {
-         assert(pipe_is_referenced(src));
-         p_atomic_inc(&src->count);
+         MAYBE_UNUSED int count = p_atomic_inc_return(&src->count);
+         assert(count != 1); /* src had to be referenced */
          debug_reference(src, get_desc, 1);
       }
 
       if (dst) {
-         assert(pipe_is_referenced(dst));
-         if (p_atomic_dec_zero(&dst->count))
+         int count = p_atomic_dec_return(&dst->count);
+         assert(count != -1); /* dst had to be referenced */
+         if (!count)
             destroy = TRUE;
 
          debug_reference(dst, get_desc, -1);