Mesa (master): turnip: clamp sampler minLod/maxLod

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jun 8 20:12:17 UTC 2020


Module: Mesa
Branch: master
Commit: 88d5917cc1c5bd0dec26147a8779b50e94e56dd1
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=88d5917cc1c5bd0dec26147a8779b50e94e56dd1

Author: Jonathan Marek <jonathan at marek.ca>
Date:   Sat Jun  6 22:08:41 2020 -0400

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 <jonathan at marek.ca>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5375>

---

 src/freedreno/vulkan/tu_device.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c
index 5bf3d1d6c39..c471117e5ed 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



More information about the mesa-commit mailing list