diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp index 535c39dd27b..51712f3c058 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 4eb67d95b82..e958bedc0cc 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -648,6 +648,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. *