From: Timothy Arceri Date: Mon, 23 Dec 2019 00:37:57 +0000 (+1100) Subject: glsl: use nir linker to link atomics X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a853de0c95d5dce7aee983efd243377ffe3a6e91;p=mesa.git glsl: use nir linker to link atomics Reviewed-by: Alejandro PiƱeiro --- diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp index 63f4b46bd6b..cc770c4d7b1 100644 --- a/src/compiler/glsl/linker.cpp +++ b/src/compiler/glsl/linker.cpp @@ -4537,8 +4537,11 @@ link_and_validate_uniforms(struct gl_context *ctx, check_resources(ctx, prog); check_subroutine_resources(prog); check_image_resources(ctx, prog); - link_assign_atomic_counter_resources(ctx, prog); - link_check_atomic_counter_resources(ctx, prog); + + if (!ctx->Const.UseNIRGLSLLinker) { + link_assign_atomic_counter_resources(ctx, prog); + link_check_atomic_counter_resources(ctx, prog); + } } static bool diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 992f9fe00c9..72e1a50bca3 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -765,6 +765,11 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe, ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].PositionAlwaysInvariant = options->vs_position_always_invariant; + enum pipe_shader_ir preferred_ir = (enum pipe_shader_ir) + screen->get_shader_param(screen, PIPE_SHADER_VERTEX, + PIPE_SHADER_CAP_PREFERRED_IR); + ctx->Const.UseNIRGLSLLinker = preferred_ir == PIPE_SHADER_IR_NIR; + if (ctx->Const.GLSLVersion < 400) { for (i = 0; i < MESA_SHADER_STAGES; i++) ctx->Const.ShaderCompilerOptions[i].EmitNoIndirectSampler = true; diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp index 11b6db490b9..c92b1c365a7 100644 --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp @@ -736,8 +736,12 @@ st_link_nir(struct gl_context *ctx, if (num_shaders == 1) st_nir_opts(linked_shader[0]->Program->nir); - if (!shader_program->data->spirv) + if (!shader_program->data->spirv) { + if (!gl_nir_link_glsl(ctx, shader_program)) + return GL_FALSE; + nir_build_program_resource_list(ctx, shader_program, false); + } for (unsigned i = 0; i < num_shaders; i++) { struct gl_linked_shader *shader = linked_shader[i];