From 729df14e4528b70e63332e4255571729253e9791 Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Wed, 15 Sep 2021 15:38:23 -0700 Subject: [PATCH] nir: Handle volatile semantics for loading HelperInvocation builtin SPV_EXT_demote_to_helper_invocation added OpDemoteToHelperInvocation operation to turn an invocation into a helper invocation, but the value of HelperInvocation (a builtin from Input storage class) couldn't be modified dynamically without breaking compatibility. For the extension the operation OpIsHelperInvocation was added to get the dynamic value. For SPIR-V 1.6, the demote operation was promoted, but now to get the dynamic value the shader must issue a load to HelperInvocation with Volatile memory access semantics. Reviewed-by: Ian Romanick Reviewed-by: Jason Ekstrand Part-of: --- src/compiler/nir/nir_lower_system_values.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/compiler/nir/nir_lower_system_values.c b/src/compiler/nir/nir_lower_system_values.c index a78b5e6..5fdf058 100644 --- a/src/compiler/nir/nir_lower_system_values.c +++ b/src/compiler/nir/nir_lower_system_values.c @@ -197,6 +197,16 @@ lower_system_value_instr(nir_builder *b, nir_instr *instr, void *_state) return nir_load_barycentric(b, nir_intrinsic_load_barycentric_model, INTERP_MODE_NONE); + case SYSTEM_VALUE_HELPER_INVOCATION: { + /* When demote operation is used, reading the HelperInvocation + * needs to use Volatile memory access semantics to provide the + * correct (dynamic) value. See OpDemoteToHelperInvocation. + */ + if (nir_intrinsic_access(intrin) & ACCESS_VOLATILE) + return nir_is_helper_invocation(b, 1); + break; + } + default: break; } -- 2.7.4