remove final imports.h and imports.c bits
[mesa.git] / src / compiler / glsl / linker.cpp
index d69dff7bbd9dd0f22de5d09fcd07a35aba218ad2..8a876fcecee66354a71c70fdbc46e12b3bb4a62a 100644 (file)
@@ -86,7 +86,7 @@
 #include "util/u_string.h"
 #include "util/u_math.h"
 
-#include "main/imports.h"
+
 #include "main/shaderobj.h"
 #include "main/enums.h"
 #include "main/mtypes.h"
@@ -1816,6 +1816,40 @@ link_bindless_layout_qualifiers(struct gl_shader_program *prog,
    }
 }
 
+/**
+ * Check for conflicting viewport_relative settings across shaders, and sets
+ * the value for the linked shader.
+ */
+static void
+link_layer_viewport_relative_qualifier(struct gl_shader_program *prog,
+                                       struct gl_program *gl_prog,
+                                       struct gl_shader **shader_list,
+                                       unsigned num_shaders)
+{
+   unsigned i;
+
+   /* Find first shader with explicit layer declaration */
+   for (i = 0; i < num_shaders; i++) {
+      if (shader_list[i]->redeclares_gl_layer) {
+         gl_prog->info.layer_viewport_relative =
+            shader_list[i]->layer_viewport_relative;
+         break;
+      }
+   }
+
+   /* Now make sure that each subsequent shader's explicit layer declaration
+    * matches the first one's.
+    */
+   for (; i < num_shaders; i++) {
+      if (shader_list[i]->redeclares_gl_layer &&
+          shader_list[i]->layer_viewport_relative !=
+          gl_prog->info.layer_viewport_relative) {
+         linker_error(prog, "all gl_Layer redeclarations must have identical "
+                      "viewport_relative settings");
+      }
+   }
+}
+
 /**
  * Performs the cross-validation of tessellation control shader vertices and
  * layout qualifiers for the attached tessellation control shaders,
@@ -2461,6 +2495,8 @@ link_intrastage_shaders(void *mem_ctx,
 
    link_bindless_layout_qualifiers(prog, shader_list, num_shaders);
 
+   link_layer_viewport_relative_qualifier(prog, gl_prog, shader_list, num_shaders);
+
    populate_symbol_table(linked, shader_list[0]->symbols);
 
    /* The pointer to the main function in the final linked shader (i.e., the
@@ -4040,8 +4076,10 @@ build_program_resource_list(struct gl_context *ctx,
          return;
    }
 
-   if (add_packed_varyings_only)
+   if (add_packed_varyings_only) {
+      _mesa_set_destroy(resource_set, NULL);
       return;
+   }
 
    if (!add_fragdata_arrays(ctx, shProg, resource_set))
       return;
@@ -4403,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);