From 576b5ace9e2e90803d1c6b9f1b1728b1e5e8c4ed Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Mon, 27 Jan 2020 16:46:25 +1100 Subject: [PATCH] glsl: add support for builtins to the nir uniform linker MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Alejandro Piñeiro Part-of: --- src/compiler/glsl/gl_nir_link_uniforms.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/compiler/glsl/gl_nir_link_uniforms.c b/src/compiler/glsl/gl_nir_link_uniforms.c index 7b5c2131960..ec0c7afca55 100644 --- a/src/compiler/glsl/gl_nir_link_uniforms.c +++ b/src/compiler/glsl/gl_nir_link_uniforms.c @@ -35,6 +35,15 @@ #define UNMAPPED_UNIFORM_LOC ~0u +/** + * 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 void nir_setup_uniform_remap_tables(struct gl_context *ctx, struct gl_shader_program *prog) @@ -856,7 +865,7 @@ nir_link_uniform(struct gl_context *ctx, * implement support for their specific features, like SSBO, atomics, * etc. */ - uniform->builtin = false; + uniform->builtin = is_gl_identifier(uniform->name); uniform->atomic_buffer_index = -1; uniform->is_bindless = false; @@ -930,7 +939,7 @@ nir_link_uniform(struct gl_context *ctx, state->num_values += values; } } else { - if (!state->var_is_in_block) { + if (!state->var_is_in_block && !is_gl_identifier(uniform->name)) { state->num_shader_uniform_components += values; state->num_values += values; } -- 2.30.2