Module: Mesa Branch: main Commit: ea5925461b2858f20392853298d014ee91054c97 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ea5925461b2858f20392853298d014ee91054c97
Author: Jesse Natalie <jenat...@microsoft.com> Date: Mon Nov 20 09:56:05 2023 -0800 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> --- src/microsoft/compiler/nir_to_dxil.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/microsoft/compiler/nir_to_dxil.c b/src/microsoft/compiler/nir_to_dxil.c index cd574eb9301..49554168788 100644 --- a/src/microsoft/compiler/nir_to_dxil.c +++ b/src/microsoft/compiler/nir_to_dxil.c @@ -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), }; }