From 7ee146aad49bc9e724cc93033298195ad1d9e162 Mon Sep 17 00:00:00 2001 From: Christian Gmeiner Date: Mon, 29 Jun 2020 12:10:55 +0200 Subject: [PATCH] etnaviv: move shader_count to etna_compiler Also fix data race on making the shader's id. Signed-off-by: Christian Gmeiner Reviewed-by: Lucas Stach Part-of: --- src/gallium/drivers/etnaviv/etnaviv_compiler.h | 1 + src/gallium/drivers/etnaviv/etnaviv_shader.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.h b/src/gallium/drivers/etnaviv/etnaviv_compiler.h index 40409c68d34..af979766ef3 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_compiler.h +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.h @@ -49,6 +49,7 @@ * setup. */ struct etna_compiler { + uint32_t shader_count; }; /* compiler output per input/output */ diff --git a/src/gallium/drivers/etnaviv/etnaviv_shader.c b/src/gallium/drivers/etnaviv/etnaviv_shader.c index 173a4681cb2..44ab8eda363 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_shader.c +++ b/src/gallium/drivers/etnaviv/etnaviv_shader.c @@ -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)) -- 2.30.2