microsoft/compiler: Fix lower_mem_access_bit_size callback result

When given (e.g.) 3x 16-bit components to store on a device that
isn't  using native 16-bit loads and stores, we should be lowering
that into one 32-bit store and one masked store. Instead, the logic
here ends up returning that the best we can do is one 8-byte store,
which is clearly wrong. Stores should round down, loads should
round up.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26293>
This commit is contained in:
Jesse Natalie
2023-11-20 09:56:05 -08:00
committed by Marge Bot
parent c69ca8c5c1
commit ea5925461b
+5 -2
View File
@@ -6187,7 +6187,7 @@ lower_mem_access_bit_sizes_cb(nir_intrinsic_op intrin,
/* Unaligned load/store, use the minimum bit size, up to 4 components */
unsigned ideal_num_components = intrin == nir_intrinsic_load_ssbo ?
DIV_ROUND_UP(bytes * 8, min_bit_size) :
(bytes * 8 / min_bit_size);
(32 / min_bit_size);
return (nir_mem_access_size_align) {
.align = min_bit_size / 8,
.bit_size = min_bit_size,
@@ -6204,10 +6204,13 @@ lower_mem_access_bit_sizes_cb(nir_intrinsic_op intrin,
bit_size *= 2;
/* This is the best we can do */
unsigned num_components = intrin == nir_intrinsic_load_ssbo ?
DIV_ROUND_UP(bytes * 8, bit_size) :
MAX2(1, (bytes * 8 / bit_size));
return (nir_mem_access_size_align) {
.align = bit_size / 8,
.bit_size = bit_size,
.num_components = MIN2(4, DIV_ROUND_UP(bytes * 8, bit_size)),
.num_components = MIN2(4, num_components),
};
}