From 0fe41a9f9b12523e71fbc5ef8614abadfbedc9c9 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sat, 17 Jul 2010 19:27:34 +0100 Subject: [PATCH] intel: Check that we recognise the texture before generate a miptree Reference: Bug 27098 - [wine] Left 4 Dead causes a crash in intel_miptree_pitch_align https://bugs.freedesktop.org/show_bug.cgi?id=27098 The game is trying to use a compressed texture, DXT1, but for some reason we are failing to appropriately handle the format at miptree creation time: #1 0x7cfa1c63 in intel_miptree_create (intel=0x7cdefc78, target=3553, base_format=6408, internal_format=35917, first_level=0, last_level=0, width0=1024, height0=1024, depth0=1, cpp=0, compress_byte=0, expect_accelerated_upload=0 '\000') at intel_mipmap_tree.c:143 Note that both cpp and compress_byte are 0, implying that the format is unknown. This patch causes us to fallback in this case rather than crash. Signed-off-by: Chris Wilson --- src/mesa/drivers/dri/intel/intel_tex_validate.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_tex_validate.c b/src/mesa/drivers/dri/intel/intel_tex_validate.c index ed5c5d8..669f819 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_validate.c +++ b/src/mesa/drivers/dri/intel/intel_tex_validate.c @@ -171,6 +171,11 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit) else cpp = _mesa_get_format_bytes(firstImage->base.TexFormat); + if (cpp == 0) { + /* Weirdness prevails */ + return GL_FALSE; + } + /* Check tree can hold all active levels. Check tree matches * target, imageFormat, etc. * -- 1.7.1