freedreno: Fix data race on making the shader's id.
authorEric Anholt <eric@anholt.net>
Thu, 25 Jul 2019 20:26:01 +0000 (13:26 -0700)
committerEric Anholt <eric@anholt.net>
Mon, 29 Jul 2019 19:50:49 +0000 (12:50 -0700)
The value is only used for IR3_DBG_DISASM, but it cleans up the
helgrind output.

Reviewed-by: Rob Clark <robdclark@gmail.com>
src/freedreno/ir3/ir3_shader.c

index bbe27ce4dbb753cc8f2f79909679c96e3d0a5ad9..7c686f0ee2a3a735640337fb507f1d2e3407a2bf 100644 (file)
@@ -24,6 +24,7 @@
  *    Rob Clark <robclark@freedesktop.org>
  */
 
+#include "util/u_atomic.h"
 #include "util/u_string.h"
 #include "util/u_memory.h"
 #include "util/u_format.h"
@@ -278,7 +279,7 @@ ir3_shader_from_nir(struct ir3_compiler *compiler, nir_shader *nir)
 
        mtx_init(&shader->variants_lock, mtx_plain);
        shader->compiler = compiler;
-       shader->id = ++shader->compiler->shader_count;
+       shader->id = p_atomic_inc_return(&shader->compiler->shader_count);
        shader->type = nir->info.stage;
 
        NIR_PASS_V(nir, nir_lower_io, nir_var_all, ir3_glsl_type_size,