From ef68f740a67fd1824e44a67d1023e7937fce0cf3 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Thu, 8 Oct 2020 02:27:24 -0500 Subject: [PATCH] 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 Reviewed-by: Dave Airlie Part-of: --- src/compiler/nir/nir_lower_io.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c index 9d9e3200f89..318e2a020fc 100644 --- a/src/compiler/nir/nir_lower_io.c +++ b/src/compiler/nir/nir_lower_io.c @@ -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;