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

Yuanhan Liu yuanhan.liu at linux.intel.com
Thu Sep 8 03:16:44 PDT 2011


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>
---
 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) {
+      /*
+       * 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;
    intel_get_texture_alignment_unit(mt->format, &align_w, &align_h);
 
-- 
1.7.4.4



More information about the mesa-dev mailing list