st/glsl_to_nir: make use of nir linker for linking uniforms
authorTimothy Arceri <tarceri@itsqueeze.com>
Tue, 7 Jan 2020 03:38:14 +0000 (14:38 +1100)
committerMarge Bot <eric+marge@anholt.net>
Tue, 21 Apr 2020 01:57:34 +0000 (01:57 +0000)
Reviewed-by: Alejandro PiƱeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4395>

src/compiler/glsl/gl_nir_linker.c
src/compiler/glsl/linker.cpp
src/mesa/state_tracker/st_glsl_to_nir.cpp

index c8cb6457f9614b2c0f6949b11bb1e7fa77db2600..fb8b3e0c340967de9798aa65f86ced678cf73ba8 100644 (file)
@@ -622,6 +622,9 @@ check_image_resources(struct gl_context *ctx, struct gl_shader_program *prog)
 bool
 gl_nir_link_glsl(struct gl_context *ctx, struct gl_shader_program *prog)
 {
+   if (!gl_nir_link_uniforms(ctx, prog, true))
+      return false;
+
    link_util_calculate_subroutine_compat(prog);
    link_util_check_uniform_resources(ctx, prog);
    link_util_check_subroutine_resources(prog);
index 292da60b9d9a12963bf6ece9dc85c05c85f164ed..72713fa2e66c389cbe747c7afc2ba5e555b2e5c8 100644 (file)
@@ -4441,12 +4441,13 @@ link_and_validate_uniforms(struct gl_context *ctx,
                            struct gl_shader_program *prog)
 {
    update_array_sizes(prog);
-   link_assign_uniform_locations(prog, ctx);
-
-   if (prog->data->LinkStatus == LINKING_FAILURE)
-      return;
 
    if (!ctx->Const.UseNIRGLSLLinker) {
+      link_assign_uniform_locations(prog, ctx);
+
+      if (prog->data->LinkStatus == LINKING_FAILURE)
+         return;
+
       link_util_calculate_subroutine_compat(prog);
       link_util_check_uniform_resources(ctx, prog);
       link_util_check_subroutine_resources(prog);
index 405600828734bfe36b0cf5d9d1f082d1d0507200..cf27da7e0c7f82ebd58b9baf3abe4933f80cf2f2 100644 (file)
@@ -661,18 +661,14 @@ st_link_nir(struct gl_context *ctx,
       stp->shader_program = shader_program;
       stp->state.type = PIPE_SHADER_IR_NIR;
 
-      if (shader_program->data->spirv) {
-         prog->Parameters = _mesa_new_parameter_list();
-         /* Parameters will be filled during NIR linking. */
+      /* Parameters will be filled during NIR linking. */
+      prog->Parameters = _mesa_new_parameter_list();
 
+      if (shader_program->data->spirv) {
          prog->nir = _mesa_spirv_to_nir(ctx, shader_program, shader->Stage, options);
       } else {
          validate_ir_tree(shader->ir);
 
-         prog->Parameters = _mesa_new_parameter_list();
-         _mesa_generate_parameters_list_for_uniforms(ctx, shader_program, shader,
-                                                     prog->Parameters);
-
          if (ctx->_Shader->Flags & GLSL_DUMP) {
             _mesa_log("\n");
             _mesa_log("GLSL IR for linked %s program %d:\n",
@@ -682,9 +678,6 @@ st_link_nir(struct gl_context *ctx,
             _mesa_log("\n\n");
          }
 
-         prog->ExternalSamplersUsed = gl_external_samplers(prog);
-         _mesa_update_shader_textures_used(shader_program, prog);
-
          prog->nir = glsl_to_nir(st->ctx, shader_program, shader->Stage, options);
          st_nir_preprocess(st, prog, shader_program, shader->Stage);
       }
@@ -738,6 +731,12 @@ st_link_nir(struct gl_context *ctx,
       if (!gl_nir_link_glsl(ctx, shader_program))
          return GL_FALSE;
 
+      for (unsigned i = 0; i < num_shaders; i++) {
+         struct gl_program *prog = linked_shader[i]->Program;
+         prog->ExternalSamplersUsed = gl_external_samplers(prog);
+         _mesa_update_shader_textures_used(shader_program, prog);
+      }
+
       nir_build_program_resource_list(ctx, shader_program, false);
    }