glsl: move is_gl_identifier() to linker_util
authorTimothy Arceri <tarceri@itsqueeze.com>
Mon, 25 Sep 2023 00:16:15 +0000 (10:16 +1000)
committerMarge Bot <emma+marge@anholt.net>
Thu, 28 Sep 2023 13:55:16 +0000 (13:55 +0000)
This had started to multiply around the NIR linker. Here we move it to a
common helper shared by GLSL IR and NIR.

Reviewed-by: Alejandro PiƱeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25371>

src/compiler/glsl/ast_function.cpp
src/compiler/glsl/gl_nir_link_uniforms.c
src/compiler/glsl/gl_nir_link_varyings.c
src/compiler/glsl/gl_nir_linker.c
src/compiler/glsl/gl_nir_opt_dead_builtin_varyings.c
src/compiler/glsl/ir.h
src/compiler/glsl/ir_print_visitor.cpp
src/compiler/glsl/ir_validate.cpp
src/compiler/glsl/link_varyings.cpp
src/compiler/glsl/linker_util.h
src/compiler/glsl/opt_dead_builtin_variables.cpp

index 9ca930a..159e378 100644 (file)
@@ -25,6 +25,7 @@
 #include "ast.h"
 #include "compiler/glsl_types.h"
 #include "ir.h"
+#include "linker_util.h"
 #include "main/shader_types.h"
 #include "main/consts_exts.h"
 #include "main/shaderobj.h"
index b27f385..674b63d 100644 (file)
@@ -47,15 +47,6 @@ struct uniform_array_info {
    BITSET_WORD *indices;
 };
 
-/**
- * Built-in / reserved GL variables names start with "gl_"
- */
-static inline bool
-is_gl_identifier(const char *s)
-{
-   return s && s[0] == 'g' && s[1] == 'l' && s[2] == '_';
-}
-
 static unsigned
 uniform_storage_size(const struct glsl_type *type)
 {
index 1c05670..db33882 100644 (file)
@@ -2094,15 +2094,6 @@ varying_matches_compute_packing_order(const nir_variable *var)
 }
 
 /**
- * Built-in / reserved GL variables names start with "gl_"
- */
-static bool
-is_gl_identifier(const char *s)
-{
-   return s && s[0] == 'g' && s[1] == 'l' && s[2] == '_';
-}
-
-/**
  * Record the given producer/consumer variable pair in the list of variables
  * that should later be assigned locations.
  *
index bc83733..84f58be 100644 (file)
@@ -299,15 +299,6 @@ disable_varying_optimizations_for_sso(struct gl_shader_program *prog)
    }
 }
 
-/**
- * Built-in / reserved GL variables names start with "gl_"
- */
-static inline bool
-is_gl_identifier(const char *s)
-{
-   return s && s[0] == 'g' && s[1] == 'l' && s[2] == '_';
-}
-
 static bool
 inout_has_same_location(const nir_variable *var, unsigned stage)
 {
index 3aed5c2..02068d9 100644 (file)
@@ -45,6 +45,7 @@
 
 #include "gl_nir_link_varyings.h"
 #include "gl_nir_linker.h"
+#include "linker_util.h"
 #include "nir_builder.h"
 #include "nir_gl_types.h"
 #include "nir_types.h"
@@ -92,15 +93,6 @@ initialise_varying_info(struct varying_info *info, nir_variable_mode mode,
    memset(info->backcolor, 0, sizeof(info->backcolor));
 }
 
-/**
- * Built-in / reserved GL variables names start with "gl_"
- */
-static bool
-is_gl_identifier(const char *s)
-{
-   return s && s[0] == 'g' && s[1] == 'l' && s[2] == '_';
-}
-
 static void
 gather_info_on_varying_deref(struct varying_info *info, nir_deref_instr *deref)
 {
index 79b703b..c02fd14 100644 (file)
@@ -2468,15 +2468,6 @@ prototype_string(const glsl_type *return_type, const char *name,
 const char *
 mode_string(const ir_variable *var);
 
-/**
- * Built-in / reserved GL variables names start with "gl_"
- */
-static inline bool
-is_gl_identifier(const char *s)
-{
-   return s && s[0] == 'g' && s[1] == 'l' && s[2] == '_';
-}
-
 extern "C" {
 #endif /* __cplusplus */
 
index b6bbb81..5852340 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <inttypes.h> /* for PRIx64 macro */
 #include "ir_print_visitor.h"
+#include "linker_util.h"
 #include "compiler/glsl_types.h"
 #include "glsl_parser_extras.h"
 #include "main/macros.h"
index b959f05..165a218 100644 (file)
@@ -35,6 +35,7 @@
 
 #include "ir.h"
 #include "ir_hierarchical_visitor.h"
+#include "linker_util.h"
 #include "util/u_debug.h"
 #include "util/hash_table.h"
 #include "util/macros.h"
index 577bf54..bfd389a 100644 (file)
@@ -35,6 +35,7 @@
 #include "glsl_symbol_table.h"
 #include "ir.h"
 #include "linker.h"
+#include "linker_util.h"
 #include "link_varyings.h"
 
 
index f89b4d1..1bd9b61 100644 (file)
@@ -32,6 +32,15 @@ struct gl_constants;
 struct gl_shader_program;
 struct gl_uniform_storage;
 
+/**
+ * Built-in / reserved GL variables names start with "gl_"
+ */
+static inline bool
+is_gl_identifier(const char *s)
+{
+   return s && s[0] == 'g' && s[1] == 'l' && s[2] == '_';
+}
+
 #ifdef __cplusplus
 extern "C" {
 #endif
index 0d4e3a8..48452fc 100644 (file)
@@ -24,6 +24,7 @@
 #include "ir.h"
 #include "ir_visitor.h"
 #include "ir_optimization.h"
+#include "linker_util.h"
 
 /**
  * Pre-linking, optimize unused built-in variables