From: Timothy Arceri Date: Mon, 27 Jan 2020 05:46:25 +0000 (+1100) Subject: glsl: add support for builtins to the nir uniform linker X-Git-Tag: upstream/20.1.8~2730 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=576b5ace9e2e90803d1c6b9f1b1728b1e5e8c4ed;p=platform%2Fupstream%2Fmesa.git glsl: add support for builtins to the nir uniform linker Reviewed-by: Alejandro PiƱeiro Part-of: --- diff --git a/src/compiler/glsl/gl_nir_link_uniforms.c b/src/compiler/glsl/gl_nir_link_uniforms.c index 7b5c213..ec0c7af 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; }