From: Jonathan Marek Date: Sun, 7 Jun 2020 02:08:41 +0000 (-0400) Subject: turnip: clamp sampler minLod/maxLod X-Git-Tag: upstream/21.0.0~8995 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=88d5917cc1c5bd0dec26147a8779b50e94e56dd1;p=platform%2Fupstream%2Fmesa.git turnip: clamp sampler minLod/maxLod Otherwise A6XX_TEX_SAMP_1_{MIN,MAX}_LOD silently overflows. This fixes these tests: dEQP-VK.texture.explicit_lod.2d.derivatives.* Signed-off-by: Jonathan Marek Part-of: --- diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c index 5bf3d1d..c471117 100644 --- a/src/freedreno/vulkan/tu_device.c +++ b/src/freedreno/vulkan/tu_device.c @@ -2186,6 +2186,8 @@ tu_init_sampler(struct tu_device *device, unsigned aniso = pCreateInfo->anisotropyEnable ? util_last_bit(MIN2((uint32_t)pCreateInfo->maxAnisotropy >> 1, 8)) : 0; bool miplinear = (pCreateInfo->mipmapMode == VK_SAMPLER_MIPMAP_MODE_LINEAR); + float min_lod = CLAMP(pCreateInfo->minLod, 0.0f, 4095.0f / 256.0f); + float max_lod = CLAMP(pCreateInfo->maxLod, 0.0f, 4095.0f / 256.0f); sampler->descriptor[0] = COND(miplinear, A6XX_TEX_SAMP_0_MIPFILTER_LINEAR_NEAR) | @@ -2199,8 +2201,8 @@ tu_init_sampler(struct tu_device *device, sampler->descriptor[1] = /* COND(!cso->seamless_cube_map, A6XX_TEX_SAMP_1_CUBEMAPSEAMLESSFILTOFF) | */ COND(pCreateInfo->unnormalizedCoordinates, A6XX_TEX_SAMP_1_UNNORM_COORDS) | - A6XX_TEX_SAMP_1_MIN_LOD(pCreateInfo->minLod) | - A6XX_TEX_SAMP_1_MAX_LOD(pCreateInfo->maxLod) | + A6XX_TEX_SAMP_1_MIN_LOD(min_lod) | + A6XX_TEX_SAMP_1_MAX_LOD(max_lod) | COND(pCreateInfo->compareEnable, A6XX_TEX_SAMP_1_COMPARE_FUNC(tu6_compare_func(pCreateInfo->compareOp))); /* This is an offset into the border_color BO, which we fill with all the