[Mesa-dev] [PATCH mesa 2/2] anv: use Mesa's u_atomic.h header

Kenneth Graunke kenneth at whitecape.org
Mon Jun 26 16:36:33 UTC 2017


On Monday, June 26, 2017 5:59:40 AM PDT Eric Engestrom wrote:
> Signed-off-by: Eric Engestrom <eric.engestrom at imgtec.com>
> ---
>  src/intel/vulkan/anv_private.h | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
> index e5d88f2815..8079378ae6 100644
> --- a/src/intel/vulkan/anv_private.h
> +++ b/src/intel/vulkan/anv_private.h
> @@ -46,6 +46,7 @@
>  #include "compiler/brw_compiler.h"
>  #include "util/macros.h"
>  #include "util/list.h"
> +#include "util/u_atomic.h"
>  #include "util/u_vector.h"
>  #include "vk_alloc.h"
>  
> @@ -1862,14 +1863,14 @@ static inline void
>  anv_shader_bin_ref(struct anv_shader_bin *shader)
>  {
>     assert(shader && shader->ref_cnt >= 1);
> -   __sync_fetch_and_add(&shader->ref_cnt, 1);
> +   p_atomic_inc(&shader->ref_cnt);

p_atomic_inc is __sync_add_and_fetch, but since we don't use the return
value, either order works just fine...

>  }
>  
>  static inline void
>  anv_shader_bin_unref(struct anv_device *device, struct anv_shader_bin *shader)
>  {
>     assert(shader && shader->ref_cnt >= 1);
> -   if (__sync_fetch_and_add(&shader->ref_cnt, -1) == 1)
> +   if (p_atomic_dec_zero(&shader->ref_cnt))

and this is __sync_sub_and_fetch, which does the subtract before returning,
but you adjusted the comparison value from 1 to 0...so this works too.

Both patches are:
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

>        anv_shader_bin_destroy(device, shader);
>  }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170626/73560522/attachment.sig>


More information about the mesa-dev mailing list