From bf6d6a0934d4c63a7db136cc0c60f8c406ccfa2d Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Fri, 4 Aug 2023 06:28:19 -0500 Subject: [PATCH] Revert "compiler: Combine duplicated implementation of is_gl_identifier into glsl_types.h" This reverts commit f9860a84b3cf1735ece78bc5907b2be4e2878f8e. It's a bit annoying having this scattered around but it's 100% a GLSL thing and there's no reason why it should go in glsl_types.h. The fact that glsl_print_type() even uses it is a bit sketchy. Part-of: --- src/compiler/glsl/gl_nir_link_uniforms.c | 9 +++++++++ src/compiler/glsl/gl_nir_link_varyings.c | 9 +++++++++ src/compiler/glsl/gl_nir_linker.c | 9 +++++++++ src/compiler/glsl/gl_nir_opt_dead_builtin_varyings.c | 9 +++++++++ src/compiler/glsl/ir.h | 9 +++++++++ src/compiler/glsl_types.cpp | 6 ++++++ src/compiler/glsl_types.h | 9 --------- 7 files changed, 51 insertions(+), 9 deletions(-) diff --git a/src/compiler/glsl/gl_nir_link_uniforms.c b/src/compiler/glsl/gl_nir_link_uniforms.c index c6e0cb582ee..fb032be1e72 100644 --- a/src/compiler/glsl/gl_nir_link_uniforms.c +++ b/src/compiler/glsl/gl_nir_link_uniforms.c @@ -47,6 +47,15 @@ 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) { diff --git a/src/compiler/glsl/gl_nir_link_varyings.c b/src/compiler/glsl/gl_nir_link_varyings.c index b1c84d1f972..3ff80c7d5f9 100644 --- a/src/compiler/glsl/gl_nir_link_varyings.c +++ b/src/compiler/glsl/gl_nir_link_varyings.c @@ -1777,6 +1777,15 @@ 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. diff --git a/src/compiler/glsl/gl_nir_linker.c b/src/compiler/glsl/gl_nir_linker.c index c870d1b1edd..e9be3a9bf0c 100644 --- a/src/compiler/glsl/gl_nir_linker.c +++ b/src/compiler/glsl/gl_nir_linker.c @@ -299,6 +299,15 @@ 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) { diff --git a/src/compiler/glsl/gl_nir_opt_dead_builtin_varyings.c b/src/compiler/glsl/gl_nir_opt_dead_builtin_varyings.c index f2cda28245b..b527af323b6 100644 --- a/src/compiler/glsl/gl_nir_opt_dead_builtin_varyings.c +++ b/src/compiler/glsl/gl_nir_opt_dead_builtin_varyings.c @@ -92,6 +92,15 @@ 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) { diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h index 3360b16b089..1a3721838c6 100644 --- a/src/compiler/glsl/ir.h +++ b/src/compiler/glsl/ir.h @@ -2483,6 +2483,15 @@ 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 */ diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp index e33a5b44f25..af8f2e9d02e 100644 --- a/src/compiler/glsl_types.cpp +++ b/src/compiler/glsl_types.cpp @@ -3353,6 +3353,12 @@ glsl_get_sampler_dim_coordinate_components(enum glsl_sampler_dim dim) } } +static inline bool +is_gl_identifier(const char *s) +{ + return s && s[0] == 'g' && s[1] == 'l' && s[2] == '_'; +} + void glsl_print_type(FILE *f, const glsl_type *t) { diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h index 70c8e6ede54..4c11bbb35f4 100644 --- a/src/compiler/glsl_types.h +++ b/src/compiler/glsl_types.h @@ -289,15 +289,6 @@ enum { GLSL_PRECISION_LOW }; -/** - * 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