Otherwise we can end up splitting push constant loads, which currently require
an unbroken (no-cast) deref chain up to the variable.
Fixes:
4c527f4f ("spirv2dxil: Lower unaligned loads and stores")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22371>
val = intrin->src[1].ssa;
}
- unsigned natural_alignment =
- val->bit_size / 8 *
+ unsigned scalar_byte_size = glsl_type_is_boolean(deref->type) ? 4 : glsl_get_bit_size(deref->type) / 8;
+ unsigned num_components =
+ /* If the vector stride is larger than the scalar size, lower_explicit_io will
+ * turn this into multiple scalar loads anyway, so we don't have to split it here. */
+ glsl_get_explicit_stride(deref->type) > scalar_byte_size ? 1 :
(val->num_components == 3 ? 4 : val->num_components);
+ unsigned natural_alignment = scalar_byte_size * num_components;
if (alignment >= natural_alignment)
continue;