mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 17:20:10 +01:00
nir/lower_io: Use nir_deref_mode_* helpers
For non-explicit nir_lower_io, we use nir_deref_mode_is because there's no way it works for generic pointers. For nir_lower_vars_to_explicit_types, and nir_lower_explicit_io, we use nir_deref_mode_is_in_set to ensure we never get type confusion. For generic pointers, this means that they must be called with the full set of generic pointer modes. Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6332>
This commit is contained in:
parent
9ae87a6c31
commit
9f3e3dfd2f
1 changed files with 12 additions and 8 deletions
|
|
@ -619,10 +619,7 @@ nir_lower_io_block(nir_block *block,
|
|||
}
|
||||
|
||||
nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]);
|
||||
|
||||
nir_variable_mode mode = deref->mode;
|
||||
assert(util_is_power_of_two_nonzero(mode));
|
||||
if ((state->modes & mode) == 0)
|
||||
if (!nir_deref_mode_is_one_of(deref, state->modes))
|
||||
continue;
|
||||
|
||||
nir_variable *var = nir_deref_instr_get_variable(deref);
|
||||
|
|
@ -1716,7 +1713,7 @@ nir_lower_explicit_io_impl(nir_function_impl *impl, nir_variable_mode modes,
|
|||
switch (instr->type) {
|
||||
case nir_instr_type_deref: {
|
||||
nir_deref_instr *deref = nir_instr_as_deref(instr);
|
||||
if (deref->mode & modes) {
|
||||
if (nir_deref_mode_is_in_set(deref, modes)) {
|
||||
lower_explicit_io_deref(&b, deref, addr_format);
|
||||
progress = true;
|
||||
}
|
||||
|
|
@ -1743,7 +1740,7 @@ nir_lower_explicit_io_impl(nir_function_impl *impl, nir_variable_mode modes,
|
|||
case nir_intrinsic_deref_atomic_fmax:
|
||||
case nir_intrinsic_deref_atomic_fcomp_swap: {
|
||||
nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]);
|
||||
if (deref->mode & modes) {
|
||||
if (nir_deref_mode_is_in_set(deref, modes)) {
|
||||
lower_explicit_io_access(&b, intrin, addr_format);
|
||||
progress = true;
|
||||
}
|
||||
|
|
@ -1752,7 +1749,7 @@ nir_lower_explicit_io_impl(nir_function_impl *impl, nir_variable_mode modes,
|
|||
|
||||
case nir_intrinsic_deref_buffer_array_length: {
|
||||
nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]);
|
||||
if (deref->mode & modes) {
|
||||
if (nir_deref_mode_is_in_set(deref, modes)) {
|
||||
lower_explicit_io_array_length(&b, intrin, addr_format);
|
||||
progress = true;
|
||||
}
|
||||
|
|
@ -1802,6 +1799,9 @@ nir_lower_explicit_io_impl(nir_function_impl *impl, nir_variable_mode modes,
|
|||
* The one exception to the simple algorithm described above is for handling
|
||||
* row-major matrices in which case we may look down one additional level of
|
||||
* the deref chain.
|
||||
*
|
||||
* If nir_lower_explicit_io is called on any shader that contains generic
|
||||
* pointers, it must either be used on all of the generic modes or none.
|
||||
*/
|
||||
bool
|
||||
nir_lower_explicit_io(nir_shader *shader, nir_variable_mode modes,
|
||||
|
|
@ -1831,7 +1831,7 @@ nir_lower_vars_to_explicit_types_impl(nir_function_impl *impl,
|
|||
continue;
|
||||
|
||||
nir_deref_instr *deref = nir_instr_as_deref(instr);
|
||||
if (!(deref->mode & modes))
|
||||
if (!nir_deref_mode_is_in_set(deref, modes))
|
||||
continue;
|
||||
|
||||
unsigned size, alignment;
|
||||
|
|
@ -1927,6 +1927,10 @@ lower_vars_to_explicit(nir_shader *shader,
|
|||
return progress;
|
||||
}
|
||||
|
||||
/* If nir_lower_vars_to_explicit_types is called on any shader that contains
|
||||
* generic pointers, it must either be used on all of the generic modes or
|
||||
* none.
|
||||
*/
|
||||
bool
|
||||
nir_lower_vars_to_explicit_types(nir_shader *shader,
|
||||
nir_variable_mode modes,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue