From 60f6bd4761edf2290db12d42917250544d6925fa Mon Sep 17 00:00:00 2001 From: Aitor Camacho Date: Fri, 28 Nov 2025 23:54:16 +0900 Subject: [PATCH] kk: Clamp negative array indices to 0 Required so that uint array formats don't incorrectly wrap to last array slice instead of the first one. For some reason this only happens with uint texture formats while int and float formats work as expected. Acked-by: Arcady Goldmints-Orlov Signed-off-by: Aitor Camacho Part-of: --- src/kosmickrisp/compiler/nir_to_msl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/kosmickrisp/compiler/nir_to_msl.c b/src/kosmickrisp/compiler/nir_to_msl.c index 752e2cf5b23..51cb0e18716 100644 --- a/src/kosmickrisp/compiler/nir_to_msl.c +++ b/src/kosmickrisp/compiler/nir_to_msl.c @@ -614,12 +614,12 @@ round_src_component_to_uint(struct nir_to_msl_ctx *ctx, nir_src *src, { bool is_float = msl_src_is_float(ctx, src); if (is_float) { - P(ctx, "uint(rint("); + P(ctx, "uint(max(int(rint("); } src_to_msl(ctx, src); P(ctx, ".%c", component); if (is_float) { - P(ctx, "))"); + P(ctx, ")), int(0)))"); } }