[Mesa-dev] [PATCH] intel: fix the wrong code to detect null texture.

Yuanhan Liu yuanhan.liu at linux.intel.com
Thu Sep 22 20:09:14 PDT 2011


On Thu, Sep 08, 2011 at 09:12:44PM -0700, Kenneth Graunke wrote:
> On 09/08/2011 07:56 PM, Yuanhan Liu wrote:
> > There is already comments show how to detect a null texture. Fix the
> > code to match the comments.
> > 
> > This would fix the oglc divzero(basic.texQOrWEqualsZero) and
> > divzero(basic.texTrivialPrim) test case fail.
> > 
> > Signed-off-by: Yuanhan Liu <yuanhan.liu at linux.intel.com>
> > ---
> >  src/mesa/drivers/dri/intel/intel_mipmap_tree.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> > 
> > diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
> > index f36240d..717e0ae 100644
> > --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
> > +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
> > @@ -137,7 +137,7 @@ intel_miptree_create(struct intel_context *intel,
> >     /*
> >      * pitch == 0 || height == 0  indicates the null texture
> >      */
> > -   if (!mt || !mt->total_height) {
> > +   if (!mt->total_width || !mt->total_height) {
> >        free(mt);
> >        return NULL;
> >     }
> 
> I was a bit skeptical about removing the !mt check, but I think it's
> actually okay since intel_miptree_create_internal never returns NULL.
> 
> I had to convince myself of that by writing the patch I'm about to reply
> with.  intel_miptree_create_internal has explicit "if (!ok) return NULL"
> code in it, but it turns out that ok is statically provable to always be
> true.  My patch deletes it.
> 
> The only other reason it might want to return NULL is if allocation of
> the struct intel_mipmap_tree fails, but it doesn't check for that.
> Perhaps it should?  (But, it's a tiny struct and I'm pretty sure we fail
> to check things like that all over the place, so...eh...)
> 
> Anyway, this looks right to me.  I'll defer to Eric and Ian though.

Hi Eric and Ian, does this patch looks Ok to you? If no problem
reported, I would like to push this patch with a change suggested by
Kenneth in this mail to repo next monday.

Thanks,
Yuanhan Liu

> 
> Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>


More information about the mesa-dev mailing list