From d5b05d53e4b9b5a3f497699f4345cca90309be5c Mon Sep 17 00:00:00 2001 From: Aitor Camacho Date: Mon, 8 Dec 2025 20:24:03 +0900 Subject: [PATCH] kk: Expose shaderImageGatherExtended Limit gather offsets to hardware's limit [-8, 7]. Reviewed-By: Arcady Goldmints-Orlov Signed-off-by: Aitor Camacho Part-of: --- src/kosmickrisp/compiler/nir_to_msl.c | 13 +++++++++---- src/kosmickrisp/vulkan/kk_physical_device.c | 5 +++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/kosmickrisp/compiler/nir_to_msl.c b/src/kosmickrisp/compiler/nir_to_msl.c index a8a7d3fef0c..9b561f34b55 100644 --- a/src/kosmickrisp/compiler/nir_to_msl.c +++ b/src/kosmickrisp/compiler/nir_to_msl.c @@ -1683,11 +1683,16 @@ tex_to_msl(struct nir_to_msl_ctx *ctx, nir_tex_instr *tex) P(ctx, ", "); src_to_msl(ctx, comparator); } - P(ctx, ", "); - if (offset) + + /* SPIR-V does not allow offsets for cube samplers (neither does MSL). + * nir_opt_constant_folding will remove offsets that are 0, so we need to + * add them here. */ + if (offset) { + P(ctx, ", "); src_to_msl(ctx, offset); - else - P(ctx, "int2(0)"); + } else if (tex->sampler_dim != GLSL_SAMPLER_DIM_CUBE) { + P(ctx, ", int2(0)"); + } /* Non-depth textures require component */ if (!comparator) { diff --git a/src/kosmickrisp/vulkan/kk_physical_device.c b/src/kosmickrisp/vulkan/kk_physical_device.c index a8df4c3fdf3..b9494595c87 100644 --- a/src/kosmickrisp/vulkan/kk_physical_device.c +++ b/src/kosmickrisp/vulkan/kk_physical_device.c @@ -170,6 +170,7 @@ kk_get_device_features( .multiViewport = true, .robustBufferAccess = true, .samplerAnisotropy = true, + .shaderImageGatherExtended = true, .shaderInt16 = true, .shaderInt64 = true, .shaderResourceMinLod = true, @@ -410,8 +411,8 @@ kk_get_device_properties(const struct kk_physical_device *pdev, .minStorageBufferOffsetAlignment = KK_MIN_SSBO_ALIGNMENT, .minTexelOffset = -8, .maxTexelOffset = 7, - .minTexelGatherOffset = -32, - .maxTexelGatherOffset = 31, + .minTexelGatherOffset = -8, + .maxTexelGatherOffset = 7, .minInterpolationOffset = -0.5, .maxInterpolationOffset = 0.4375, .subPixelInterpolationOffsetBits = 4,