nir/lower_io: Assert non-zero power-of-two alignments

The way the ALIGN_POT macro works, an alignment of 0 may cause
ALIGN_POT(x, 0) to return 0 for any x.  Throw in an assert to guard
against this case.

Reviewed-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7069>
This commit is contained in:
Jason Ekstrand 2020-10-08 02:27:24 -05:00 committed by Karol Herbst
parent 589d918a4f
commit ef68f740a6

View file

@ -1889,6 +1889,7 @@ lower_vars_to_explicit(nir_shader *shader,
if (explicit_type != var->type)
var->type = explicit_type;
assert(util_is_power_of_two_nonzero(align));
var->data.driver_location = ALIGN_POT(offset, align);
offset = var->data.driver_location + size;
progress = true;