nir/vec3_to_vec4: Use nir_deref_must_be

We use the same nir_deref_mode_is_in_set helper that we use in
nir_lower_vars_to_explicit_types for the same reason.  If there are any
generic pointers in play, we have to lower all generic pointer modes at
the same time or else we risk types getting out-of-sync.

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:
Jason Ekstrand 2020-11-01 17:45:26 -06:00 committed by Marge Bot
parent 8a2cda1d53
commit 379d535480
1 changed files with 10 additions and 7 deletions

View File

@ -47,10 +47,9 @@ lower_vec3_to_vec4_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))
continue;
assert(!(deref->mode & ~modes));
const struct glsl_type *vec4_type =
glsl_type_replace_vec3_with_vec4(deref->type);
if (deref->type != vec4_type) {
@ -68,7 +67,7 @@ lower_vec3_to_vec4_impl(nir_function_impl *impl, nir_variable_mode modes)
break;
nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]);
if (!(deref->mode & modes))
if (!nir_deref_mode_is_in_set(deref, modes))
break;
assert(intrin->dest.is_ssa);
@ -89,7 +88,7 @@ lower_vec3_to_vec4_impl(nir_function_impl *impl, nir_variable_mode modes)
break;
nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]);
if (!(deref->mode & modes))
if (!nir_deref_mode_is_in_set(deref, modes))
break;
assert(intrin->src[1].is_ssa);
@ -107,12 +106,16 @@ lower_vec3_to_vec4_impl(nir_function_impl *impl, nir_variable_mode modes)
}
case nir_intrinsic_copy_deref: {
ASSERTED nir_deref_instr *dst = nir_src_as_deref(intrin->src[0]);
ASSERTED nir_deref_instr *src = nir_src_as_deref(intrin->src[0]);
nir_deref_instr *dst = nir_src_as_deref(intrin->src[0]);
nir_deref_instr *src = nir_src_as_deref(intrin->src[0]);
/* If we convert once side of a copy and not the other, that
* would be very bad.
*/
assert(!(src->mode & modes) == !(dst->mode & modes));
if (nir_deref_mode_may_be(dst, modes) ||
nir_deref_mode_may_be(src, modes)) {
assert(nir_deref_mode_must_be(dst, modes));
assert(nir_deref_mode_must_be(src, modes));
}
break;
}