Mesa (master): radv: use Mesa's u_atomic.h header

Eric Engeström eric_engestrom at kemper.freedesktop.org
Mon Jun 26 17:24:59 UTC 2017


Module: Mesa
Branch: master
Commit: a2ae2d1fb00cf8c0edf392e1c666ee6e8ced9a82
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a2ae2d1fb00cf8c0edf392e1c666ee6e8ced9a82

Author: Eric Engestrom <eric.engestrom at imgtec.com>
Date:   Mon Jun 26 12:14:37 2017 +0100

radv: use Mesa's u_atomic.h header

Signed-off-by: Eric Engestrom <eric.engestrom at imgtec.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/amd/vulkan/radv_pipeline.c       | 3 ++-
 src/amd/vulkan/radv_pipeline_cache.c | 7 ++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
index 0c262799f0..efe641dc0b 100644
--- a/src/amd/vulkan/radv_pipeline.c
+++ b/src/amd/vulkan/radv_pipeline.c
@@ -26,6 +26,7 @@
  */
 
 #include "util/mesa-sha1.h"
+#include "util/u_atomic.h"
 #include "radv_private.h"
 #include "nir/nir.h"
 #include "nir/nir_builder.h"
@@ -374,7 +375,7 @@ static void radv_dump_pipeline_stats(struct radv_device *device, struct radv_pip
 void radv_shader_variant_destroy(struct radv_device *device,
                                  struct radv_shader_variant *variant)
 {
-	if (__sync_fetch_and_sub(&variant->ref_count, 1) != 1)
+	if (!p_atomic_dec_zero(&variant->ref_count))
 		return;
 
 	device->ws->buffer_destroy(variant->bo);
diff --git a/src/amd/vulkan/radv_pipeline_cache.c b/src/amd/vulkan/radv_pipeline_cache.c
index 0ab4d2a26e..e57c99b8e9 100644
--- a/src/amd/vulkan/radv_pipeline_cache.c
+++ b/src/amd/vulkan/radv_pipeline_cache.c
@@ -23,6 +23,7 @@
 
 #include "util/mesa-sha1.h"
 #include "util/debug.h"
+#include "util/u_atomic.h"
 #include "radv_private.h"
 
 #include "ac_nir_to_llvm.h"
@@ -184,7 +185,7 @@ radv_create_shader_variant_from_pipeline_cache(struct radv_device *device,
 		entry->variant = variant;
 	}
 
-	__sync_fetch_and_add(&entry->variant->ref_count, 1);
+	p_atomic_inc(&entry->variant->ref_count);
 	return entry->variant;
 }
 
@@ -276,7 +277,7 @@ radv_pipeline_cache_insert_shader(struct radv_pipeline_cache *cache,
 		} else {
 			entry->variant = variant;
 		}
-		__sync_fetch_and_add(&variant->ref_count, 1);
+		p_atomic_inc(&variant->ref_count);
 		pthread_mutex_unlock(&cache->mutex);
 		return variant;
 	}
@@ -296,7 +297,7 @@ radv_pipeline_cache_insert_shader(struct radv_pipeline_cache *cache,
 	entry->rsrc2 = variant->rsrc2;
 	entry->code_size = code_size;
 	entry->variant = variant;
-	__sync_fetch_and_add(&variant->ref_count, 1);
+	p_atomic_inc(&variant->ref_count);
 
 	radv_pipeline_cache_add_entry(cache, entry);
 




More information about the mesa-commit mailing list