[Mesa-dev] [PATCH] intel: fix null 1D texture handling

Ian Romanick idr at freedesktop.org
Thu Sep 8 13:16:23 PDT 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 09/08/2011 03:16 AM, Yuanhan Liu wrote:
> If user call glTexImage1D with width = 0 and height = 0(the last
> level) like this: glTexImage1D(GL_TEXTURE_1D, level, interfomart,
> 0, 0, format, type, pixel)
> 
> It would generate a SIGSEGV fault. As i945_miptree_layout_2d didn't
> handle this special case. More info are commented in line in this
> patch.
> 
> 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>

This feels like a band-aid.  Can this problem also occur on pre-i945
hardware (that use i915_miptree_layout_2d)?

> --- src/mesa/drivers/dri/intel/intel_tex_layout.c |   12
> ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/intel/intel_tex_layout.c
> b/src/mesa/drivers/dri/intel/intel_tex_layout.c index
> 9d81523..4ec71c2 100644 ---
> a/src/mesa/drivers/dri/intel/intel_tex_layout.c +++
> b/src/mesa/drivers/dri/intel/intel_tex_layout.c @@ -61,6 +61,18 @@
> void i945_miptree_layout_2d(struct intel_context *intel, GLuint
> width = mt->width0; GLuint height = mt->height0;
> 
> +   if (width == 0 && _mesa_get_texture_dimensions(mt->target) ==
> 1) {

Does the dimensionality of the texture target actually matter?  It
seems like we would want to bailout whenever width (or height) is zero.
If the dimensionality does matter, calling
_mesa_get_texture_dimensions is wrong.  It will return 2 for
GL_TEXTURE_1D_ARRAY, and I think we want to treat 1D texture arrays
the same as non-array 1D textures.

> +      /* +       * This is the _real_ last level of 1D texture
> with width equal +       * to 0. Just simply set total_height to 0
> to indicate this is +       * a NULL texture. Or it will get a
> value of ALIGN(1, aligh_h), +       * which equals to 2, as mesa
> would set the value of _height_ +       * to 1 in 1D texture. +
> */ +      mt->total_height = 0; +      return; +   } + 
> mt->total_width = mt->width0;

I see that mt->total_height gets set to zero below.  I'm move that
assignment and the mt->total_width = mt->width0 assignment above the
'if (width == 0)' condition.

> intel_get_texture_alignment_unit(mt->format, &align_w, &align_h);
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk5pIpcACgkQX1gOwKyEAw9RogCcDK8vXR2bfcjHS4sb24SS8g54
8nQAnRcISXoA+oeNkNqoxEvgzOpmJ8Wa
=nT5n
-----END PGP SIGNATURE-----


More information about the mesa-dev mailing list