glsl: move check_subroutine_resources() into the shared util code
authorTimothy Arceri <tarceri@itsqueeze.com>
Mon, 6 Jan 2020 23:08:15 +0000 (10:08 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Fri, 10 Jan 2020 00:41:20 +0000 (00:41 +0000)
We will make use of this in the nir linker in the following patch.

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
src/compiler/glsl/linker.cpp
src/compiler/glsl/linker_util.cpp
src/compiler/glsl/linker_util.h

index bf41337e479d52b56df4b6df547e48df443a2e01..f2ea266c9d6bdec6cad5ad1d74ea31a539bbbeb5 100644 (file)
@@ -3436,20 +3436,6 @@ link_calculate_subroutine_compat(struct gl_shader_program *prog)
    }
 }
 
-static void
-check_subroutine_resources(struct gl_shader_program *prog)
-{
-   unsigned mask = prog->data->linked_stages;
-   while (mask) {
-      const int i = u_bit_scan(&mask);
-      struct gl_program *p = prog->_LinkedShaders[i]->Program;
-
-      if (p->sh.NumSubroutineUniformRemapTable > MAX_SUBROUTINE_UNIFORM_LOCATIONS) {
-         linker_error(prog, "Too many %s shader subroutine uniforms\n",
-                      _mesa_shader_stage_to_string(i));
-      }
-   }
-}
 /**
  * Validate shader image resources.
  */
@@ -4535,7 +4521,7 @@ link_and_validate_uniforms(struct gl_context *ctx,
 
    link_calculate_subroutine_compat(prog);
    check_resources(ctx, prog);
-   check_subroutine_resources(prog);
+   link_util_check_subroutine_resources(prog);
 
    if (!ctx->Const.UseNIRGLSLLinker) {
       check_image_resources(ctx, prog);
index 99e3693b5480dd3bdb428166e31688d6acbd802a..32bc4cb33a5b6f81d25c09076a50d171123e4904 100644 (file)
@@ -23,6 +23,7 @@
  */
 #include "main/mtypes.h"
 #include "linker_util.h"
+#include "util/bitscan.h"
 #include "util/set.h"
 #include "ir_uniform.h" /* for gl_uniform_storage */
 
@@ -154,3 +155,18 @@ link_util_update_empty_uniform_locations(struct gl_shader_program *prog)
       }
    }
 }
+
+void
+link_util_check_subroutine_resources(struct gl_shader_program *prog)
+{
+   unsigned mask = prog->data->linked_stages;
+   while (mask) {
+      const int i = u_bit_scan(&mask);
+      struct gl_program *p = prog->_LinkedShaders[i]->Program;
+
+      if (p->sh.NumSubroutineUniformRemapTable > MAX_SUBROUTINE_UNIFORM_LOCATIONS) {
+         linker_error(prog, "Too many %s shader subroutine uniforms\n",
+                      _mesa_shader_stage_to_string(i));
+      }
+   }
+}
index 20a7b97527a68d8898cd735e0da48b98c5d64002..90ee200545ace61521413a7d402620a6ff6aaedc 100644 (file)
@@ -70,6 +70,9 @@ link_util_find_empty_block(struct gl_shader_program *prog,
 void
 link_util_update_empty_uniform_locations(struct gl_shader_program *prog);
 
+void
+link_util_check_subroutine_resources(struct gl_shader_program *prog);
+
 #ifdef __cplusplus
 }
 #endif