r600: reference glsl type system during translation
authorGert Wollny <gert.wollny@collabora.com>
Sun, 20 Nov 2022 16:32:21 +0000 (17:32 +0100)
committerMarge Bot <emma+marge@anholt.net>
Mon, 21 Nov 2022 10:43:51 +0000 (10:43 +0000)
VL doesn't initialize the type systen, but creates shaders in TGSI.
When these are translated to NIR and then compiled in the driver
we need to have a reference to the glsl type system.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7453

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19883>

src/gallium/drivers/r600/r600_shader.c

index a6b9f94..532c25e 100644 (file)
@@ -195,6 +195,8 @@ int r600_pipe_shader_create(struct pipe_context *ctx,
                        goto error;
                }
        } else {
+               glsl_type_singleton_init_or_ref();
+
                if (sel->ir_type == PIPE_SHADER_IR_TGSI) {
                        if (sel->nir)
                                ralloc_free(sel->nir);
@@ -216,6 +218,9 @@ int r600_pipe_shader_create(struct pipe_context *ctx,
                nir_tgsi_scan_shader(sel->nir, &sel->info, true);
 
                r = r600_shader_from_nir(rctx, shader, &key);
+
+               glsl_type_singleton_decref();
+
                if (r) {
                        fprintf(stderr, "--Failed shader--------------------------------------------------\n");