[Mesa-dev] [PATCH 2/2] intel: make sure hardware choose the right filter mode

Yuanhan Liu yuanhan.liu at linux.intel.com
Tue Nov 1 20:12:07 PDT 2011


On Tue, Nov 01, 2011 at 05:57:36PM +0800, Yuanhan Liu wrote:
> According to bspec, MIPCnt(was set to intelObj->_MaxLevel) was used for
> min/mag filter mode determination. For a normal case with no mipmap like
> this:
> 
>   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
>   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
> 
> hardware would always choose mag filter(GL_LINEAR) here since MIPCnt was
> set to 0 zero, then would make LOD be zero. Then according the formula:
>   MagMode = (LOD - Base <= 0)

Here are some more comments about this: LOD is a pre-computed value. if
preClamp is enabled, then LOD would be:
  LOD = min(min(MIPCnt, MAX_LOD), LOD);

So, if MIPCnt was set to 0, and preClamp was enabled, then the _final_
LOD would be 0, and hardware choose mag filter.

Thoughts?

>
> Thus hardware choose Mag filter.
> 
> This would fix all oglc filtercubemin subcase fail
> 
> Signed-off-by: Yuanhan Liu <yuanhan.liu at linux.intel.com>
> ---
>  src/mesa/drivers/dri/intel/intel_tex_validate.c |   10 ++++++++--
>  1 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/intel/intel_tex_validate.c b/src/mesa/drivers/dri/intel/intel_tex_validate.c
> index e2b8699..c06a043 100644
> --- a/src/mesa/drivers/dri/intel/intel_tex_validate.c
> +++ b/src/mesa/drivers/dri/intel/intel_tex_validate.c
> @@ -21,8 +21,14 @@ intel_update_max_level(struct intel_texture_object *intelObj,
>  {
>     struct gl_texture_object *tObj = &intelObj->base;
>  
> -   if (sampler->MinFilter == GL_NEAREST ||
> -       sampler->MinFilter == GL_LINEAR) {
> +   /*
> +    * According to Bspec vol5c 1.2.1.5 LOD Computation Pseudocode,
> +    * the MIPCnt(here intelObj->_MaxLevel) was used for min/mag
> +    * determination.
> +    */
Also it seemts that this comments insn't good enough, will update it in
the next patch.

Thanks,
Yuanhan Liu

> +   if ((sampler->MinFilter == sampler->MagFilter) &&
> +        (sampler->MinFilter == GL_NEAREST ||
> +         sampler->MinFilter == GL_LINEAR)) {
>        intelObj->_MaxLevel = tObj->BaseLevel;
>     } else {
>        intelObj->_MaxLevel = tObj->_MaxLevel;
> -- 
> 1.7.4.4


More information about the mesa-dev mailing list