Module: Mesa Branch: main Commit: 729df14e4528b70e63332e4255571729253e9791 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=729df14e4528b70e63332e4255571729253e9791
Author: Caio Oliveira <[email protected]> Date: Wed Sep 15 15:38:23 2021 -0700 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 <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14209> --- 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 a78b5e6c954..5fdf0587d8e 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; }
