etnaviv: move shader_count to etna_compiler
authorChristian Gmeiner <christian.gmeiner@gmail.com>
Mon, 29 Jun 2020 10:10:55 +0000 (12:10 +0200)
committerMarge Bot <eric+marge@anholt.net>
Fri, 24 Jul 2020 20:01:04 +0000 (20:01 +0000)
Also fix data race on making the shader's id.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5996>

src/gallium/drivers/etnaviv/etnaviv_compiler.h
src/gallium/drivers/etnaviv/etnaviv_shader.c

index 40409c68d3491e5c3d2a250ba3660160fa85c130..af979766ef30facabe03e92b3752ace00a91df9b 100644 (file)
@@ -49,6 +49,7 @@
  * setup.
  */
 struct etna_compiler {
+   uint32_t shader_count;
 };
 
 /* compiler output per input/output */
index 173a4681cb217b631c7db1e1f3335744016addd7..44ab8eda36300d329d82e918d9fea2bbfcb33b92 100644 (file)
@@ -34,6 +34,7 @@
 
 #include "tgsi/tgsi_parse.h"
 #include "nir/tgsi_to_nir.h"
+#include "util/u_atomic.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
 
@@ -395,13 +396,13 @@ etna_create_shader_state(struct pipe_context *pctx,
 {
    struct etna_context *ctx = etna_context(pctx);
    struct etna_screen *screen = ctx->screen;
+   struct etna_compiler *compiler = screen->compiler;
    struct etna_shader *shader = CALLOC_STRUCT(etna_shader);
 
    if (!shader)
       return NULL;
 
-   static uint32_t id;
-   shader->id = id++;
+   shader->id = p_atomic_inc_return(&compiler->shader_count);
    shader->specs = &screen->specs;
 
    if (DBG_ENABLED(ETNA_DBG_NIR))