etnaviv: move shader_count to etna_compiler

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>
This commit is contained in:
Christian Gmeiner 2020-06-29 12:10:55 +02:00 committed by Marge Bot
parent 5839a7d64a
commit 7ee146aad4
2 changed files with 4 additions and 2 deletions

View file

@ -49,6 +49,7 @@
* setup.
*/
struct etna_compiler {
uint32_t shader_count;
};
/* compiler output per input/output */

View 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))