glsl: use nir linker to link atomics
authorTimothy Arceri <tarceri@itsqueeze.com>
Mon, 23 Dec 2019 00:37:57 +0000 (11:37 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Mon, 6 Jan 2020 22:50:57 +0000 (09:50 +1100)
Reviewed-by: Alejandro PiƱeiro <apinheiro@igalia.com>
src/compiler/glsl/linker.cpp
src/mesa/state_tracker/st_context.c
src/mesa/state_tracker/st_glsl_to_nir.cpp

index 63f4b46bd6b00921c98bc4909225190ddeedb410..cc770c4d7b188c90370e5fa9583a1b0ce9856de0 100644 (file)
@@ -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
index 992f9fe00c9e52b751af7b7f9cd1edc2900e4b3f..72e1a50bca34bc9df3964cf394b074be5611a9f2 100644 (file)
@@ -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;
index 11b6db490b94268580f01718682e5b77f755fc23..c92b1c365a7707aba1e78c9d07dc3d35e7046cd6 100644 (file)
@@ -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];