Module: Mesa
Branch: master
Commit: ef68f740a67fd1824e44a67d1023e7937fce0cf3
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ef68f740a67fd1824e44a67d1023e7937fce0cf3

Author: Jason Ekstrand <[email protected]>
Date:   Thu Oct  8 02:27:24 2020 -0500

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 <[email protected]>
Reviewed-by: Dave Airlie <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7069>

---

 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;

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to