From f2e87c5c28677eff5795d68d1f5ab53df3b62192 Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Mon, 25 Sep 2023 10:37:05 +1000 Subject: [PATCH] nir: add used field to nir variables MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Will be use in a following path by the glsl nir based linker. Reviewed-by: Alejandro Piñeiro Part-of: --- src/compiler/glsl/glsl_to_nir.cpp | 1 + src/compiler/nir/nir.h | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp index 535c39d..51712f3 100644 --- a/src/compiler/glsl/glsl_to_nir.cpp +++ b/src/compiler/glsl/glsl_to_nir.cpp @@ -561,6 +561,7 @@ nir_visitor::visit(ir_variable *ir) var->data.matrix_layout = ir->data.matrix_layout; var->data.from_named_ifc_block = ir->data.from_named_ifc_block; var->data.compact = false; + var->data.used = ir->data.used; switch(ir->data.mode) { case ir_var_auto: diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 4eb67d9..e958bed 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -649,6 +649,15 @@ typedef struct nir_variable { unsigned must_be_shader_input : 1; /** + * Has this variable been used for reading or writing? + * + * Several GLSL semantic checks require knowledge of whether or not a + * variable has been used. For example, it is an error to redeclare a + * variable as invariant after it has been used. + */ + unsigned used:1; + + /** * How the variable was declared. See nir_var_declaration_type. * * This is used to detect variables generated by the compiler, so should -- 2.7.4