From: Jason Ekstrand Date: Fri, 20 Nov 2015 22:45:44 +0000 (-0800) Subject: gen8_state: Clamp sampler values to HW limitations X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1d42f773d3f236656f84a2ee6d1c726b9668104f;p=mesa.git gen8_state: Clamp sampler values to HW limitations --- diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index 9f76363c764..a3e63e4c0c0 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -100,6 +100,19 @@ anv_minify(uint32_t n, uint32_t levels) return MAX(n >> levels, 1); } +static inline float +anv_clamp_f(float f, float min, float max) +{ + assert(min < max); + + if (f > max) + return max; + else if (f < min) + return min; + else + return f; +} + static inline bool anv_clear_mask(uint32_t *inout_mask, uint32_t clear_mask) { diff --git a/src/vulkan/gen8_state.c b/src/vulkan/gen8_state.c index 94972d20490..4e441797523 100644 --- a/src/vulkan/gen8_state.c +++ b/src/vulkan/gen8_state.c @@ -316,10 +316,10 @@ VkResult gen8_CreateSampler( .MipModeFilter = vk_to_gen_mipmap_mode[pCreateInfo->mipMode], .MagModeFilter = mag_filter, .MinModeFilter = min_filter, - .TextureLODBias = pCreateInfo->mipLodBias * 256, + .TextureLODBias = anv_clamp_f(pCreateInfo->mipLodBias, -16, 15.996), .AnisotropicAlgorithm = EWAApproximation, - .MinLOD = pCreateInfo->minLod, - .MaxLOD = pCreateInfo->maxLod, + .MinLOD = anv_clamp_f(pCreateInfo->minLod, 0, 14), + .MaxLOD = anv_clamp_f(pCreateInfo->maxLod, 0, 14), .ChromaKeyEnable = 0, .ChromaKeyIndex = 0, .ChromaKeyMode = 0,