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 <ian.d.romanick@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14209>
This commit is contained in:
Caio Oliveira
2021-09-15 15:38:23 -07:00
parent 49e0dd6d42
commit 729df14e45

View File

@@ -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;
}