From 01ccba0d8ef14da333272a8d03b32fb45fb6a392 Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Fri, 7 Apr 2023 16:39:23 -0700 Subject: [PATCH] microsoft/compiler: Don't split loads/stores that will be split by lower_explicit_io 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: --- src/microsoft/compiler/dxil_nir.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/microsoft/compiler/dxil_nir.c b/src/microsoft/compiler/dxil_nir.c index 6530914..a128ada 100644 --- a/src/microsoft/compiler/dxil_nir.c +++ b/src/microsoft/compiler/dxil_nir.c @@ -2253,9 +2253,13 @@ dxil_nir_split_unaligned_loads_stores(nir_shader *shader, nir_variable_mode mode 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; -- 2.7.4