From 20978004a7ad1d469635c0d7b0988e8084978106 Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Fri, 22 Mar 2024 10:55:57 +1100 Subject: [PATCH] glsl: don't remove redefined per vertex block MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 719bf3016550 added this removal code with the following justification: "The GLSL 4.10 rules for redeclaration of built-in interface blocks (which we've chosen to regard as clarifications of GLSL 1.50) only require gl_PerVertex blocks to match in shaders that actually use those blocks. The easiest way to implement this is to detect situations where a compiled shader doesn't refer to any elements of gl_PerVertex, and remove all the associated ir_variables from the shader at the end of ast-to-ir conversion." However the intention is to avoid matching a redeclared block with gl's default block if unused. We are still required to do block matching in the shader should the block be redeclared, even if unused. So with this change we only remove the block if it is both unused and not redeclared. The existing glsl IR code managed to avoid failing CTS tests for this due to seemingly magical or hacky use of the symbol table but fixing it will make things much clearer, and also allow a nir version of this validation in a following patch. Acked-by: Marek Olšák Part-of: --- src/compiler/glsl/ast_to_hir.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp index 3b371ba7af8..1d751ff323f 100644 --- a/src/compiler/glsl/ast_to_hir.cpp +++ b/src/compiler/glsl/ast_to_hir.cpp @@ -9216,7 +9216,8 @@ remove_per_vertex_blocks(exec_list *instructions, foreach_in_list_safe(ir_instruction, node, instructions) { ir_variable *const var = node->as_variable(); if (var != NULL && var->get_interface_type() == per_vertex && - var->data.mode == mode) { + var->data.mode == mode && + var->data.how_declared == ir_var_declared_implicitly) { state->symbols->disable_variable(var->name); var->remove(); }