intel/nir: Limit unaligned loads to vec4
authorFaith Ekstrand <faith.ekstrand@collabora.com>
Sat, 25 Feb 2023 00:04:49 +0000 (18:04 -0600)
committerMarge Bot <emma+marge@anholt.net>
Fri, 3 Mar 2023 02:00:39 +0000 (02:00 +0000)
This probably doesn't affect Vulkan or GL because they can't have
anything bigger than a vec4 anyway unless it's a u64vec4 and those have
to be at least 8B aligned.  This may affect CL apps if they use
__attribute__((packed)) on something with big vectors, depending on how
LLVM decides to translate that.

Fixes: f8aa83f0c86e ("intel/nir: Use nir_lower_mem_access_bit_sizes()")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21524>

src/intel/compiler/brw_nir.c

index 71f8e10..7a0c765 100644 (file)
@@ -1279,7 +1279,7 @@ get_mem_access_size_align(nir_intrinsic_op intrin, uint8_t bytes,
       if (align < 4 && offset_is_const) {
          assert(util_is_power_of_two_nonzero(align_mul) && align_mul >= 4);
          const unsigned pad = align_offset % 4;
-         const unsigned comps32 = DIV_ROUND_UP(bytes + pad, 4);
+         const unsigned comps32 = MIN2(DIV_ROUND_UP(bytes + pad, 4), 4);
          return (nir_mem_access_size_align) {
             .bit_size = 32,
             .num_components = comps32,