gen8_state: Clamp sampler values to HW limitations

This commit is contained in:
Jason Ekstrand 2015-11-20 14:45:44 -08:00
parent 48228c114e
commit 1d42f773d3
2 changed files with 16 additions and 3 deletions

View File

@ -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)
{

View File

@ -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,