diff --git a/src/compiler/nir/nir_lower_var_copies.c b/src/compiler/nir/nir_lower_var_copies.c index 8a748982431..c7a3a67a41a 100644 --- a/src/compiler/nir/nir_lower_var_copies.c +++ b/src/compiler/nir/nir_lower_var_copies.c @@ -164,6 +164,8 @@ nir_lower_var_copies(nir_shader *shader) { bool progress = false; + shader->info.var_copies_lowered = true; + nir_foreach_function(function, shader) { if (function->impl) progress |= lower_var_copies_impl(function->impl); diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index 4ff72977053..5e778109a73 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -643,6 +643,12 @@ validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state) validate_assert(state, glsl_get_bare_type(dst->type) == glsl_get_bare_type(src->type)); validate_assert(state, !nir_deref_mode_may_be(dst, nir_var_read_only_modes)); + /* FIXME: now that we track if the var copies were lowered, it would be + * good to validate here that no new copy derefs were added. Right now + * we can't as there are some specific cases where copies are added even + * after the lowering. One example is the Intel compiler, that calls + * nir_lower_io_to_temporaries when linking some shader stages. + */ break; } diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h index 806f4bdc2d1..fd673d135d5 100644 --- a/src/compiler/shader_info.h +++ b/src/compiler/shader_info.h @@ -297,6 +297,11 @@ typedef struct shader_info { */ bool io_lowered:1; + /** Has nir_lower_var_copies called. To avoid calling any + * lowering/optimization that would introduce any copy_deref later. + */ + bool var_copies_lowered:1; + /* Whether the shader writes memory, including transform feedback. */ bool writes_memory:1;