[Mesa-dev] [PATCH 3/4] st/mesa: Clamp min_lod and max_lod to BaseLevel and MaxLevel

Christoph Bumiller e0425955 at student.tuwien.ac.at
Wed Mar 30 09:27:07 PDT 2011


On 03/30/2011 05:41 PM, Fabian Bieler wrote:
> The problem ist that if BaseLevel + MinLod is bigger than MaxLevel, min_lod 
> becomes bigger than max_lod, so the code below swaps min_lod and max_lod and 
> we send a max_lod to the driver that is bigger than MaxLevel.
> 
> This could also be fixed by adding a condition like
> if (sampler->min_lod > texobj->MaxLevel)
>   sampler->min_lod = texobj->MaxLevel;
> 

How about using the base and max level parameters in the sampler view ?
According to the GL4.1 spec, 3.24:

d = (levelbase + lambda + 0.5) - 1

where d is the mipmap array and lambda is the level of detail parameter

lambda' = log2(rho(x,y)) + clamp(bias_texobj + bias_shader)
lambda  = clamp(lambda', lod_min, lod_max)

where rho(x,y) is determined from texture coordinate derivatives.

The base level need not affect the calculation of lambda (i.e. influence
lod_min/lod_max) but is applied afterwards.

If d ends up > the max level, results are undefined.

Well, I hope this is somewhat correct.
Christoph

> 
> 
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev



More information about the mesa-dev mailing list