nir/lower_io: Fix array length of buffers larger than INT32_MAX.
Before, if the ssbo is too large this would always return 0. Also, this code is easier to optimize, so the common case of offset 0 and pot stride results in one ushr instead of 5+ instructions. Signed-off-by: Georg Lehmann <dadschoorse@gmail.com> Reviewed-by: Emma Anholt <emma@anholt.net> Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17468>
This commit is contained in:
parent
d9fb1b05eb
commit
90a8fb0355
|
@ -2128,8 +2128,8 @@ lower_explicit_io_array_length(nir_builder *b, nir_intrinsic_instr *intrin,
|
|||
unsigned access = nir_intrinsic_access(intrin);
|
||||
|
||||
nir_ssa_def *arr_size = nir_get_ssbo_size(b, index, .access=access);
|
||||
arr_size = nir_imax(b, nir_isub(b, arr_size, offset), nir_imm_int(b, 0u));
|
||||
arr_size = nir_idiv(b, arr_size, nir_imm_int(b, stride));
|
||||
arr_size = nir_usub_sat(b, arr_size, offset);
|
||||
arr_size = nir_udiv_imm(b, arr_size, stride);
|
||||
|
||||
nir_ssa_def_rewrite_uses(&intrin->dest.ssa, arr_size);
|
||||
nir_instr_remove(&intrin->instr);
|
||||
|
|
Loading…
Reference in New Issue