glsl-optimizer: avoid adding location to built-in variables (#2969)

This commit is contained in:
Christophe Dehais 2022-11-17 00:48:56 +01:00 committed by GitHub
parent c69097adfe
commit f26fbaf1b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -449,7 +449,9 @@ void ir_print_glsl_visitor::visit(ir_variable *ir)
const char *const interp[] = { "", "smooth ", "flat ", "noperspective " };
if (this->state->language_version >= 300 && ir->data.explicit_location)
bool built_in = (strstr(ir->name, "gl_") == ir->name);
if (this->state->language_version >= 300 && ir->data.explicit_location && !built_in)
{
const int binding_base = (this->state->stage == MESA_SHADER_VERTEX ? (int)VERT_ATTRIB_GENERIC0 : (int)FRAG_RESULT_DATA0);
const int location = ir->data.location - binding_base;
@ -488,7 +490,7 @@ void ir_print_glsl_visitor::visit(ir_variable *ir)
}
// keep invariant declaration for builtin variables
if (strstr(ir->name, "gl_") == ir->name) {
if (built_in) {
buffer.asprintf_append ("%s", inv);
print_var_name (ir);
return;