From 33b54effd2b305a633aa946ad1e36ac0e2a12e42 Mon Sep 17 00:00:00 2001 From: David Rose Date: Sat, 16 Aug 2008 00:23:15 +0000 Subject: [PATCH] work around egregious driver bug --- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index b02bd69666..e3a61b805e 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -7772,7 +7772,15 @@ extract_texture_image(PTA_uchar &image, size_t &page_size, GLP(GetTexLevelParameteriv)(target, n, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &image_size); page_size = image_size / tex->get_z_size(); image = PTA_uchar::empty_array(image_size); - _glGetCompressedTexImage(target, n, image.p()); + + // Some drivers (ATI!) seem to try to overstuff more bytes in the + // array than they asked us to allocate (that is, more bytes than + // GL_TEXTURE_COMPRESSED_IMAGE_SIZE), requiring us to overallocate + // and then copy the result into our final buffer. Sheesh. + + unsigned char *buffer = (unsigned char *)alloca(image_size + 32); + _glGetCompressedTexImage(target, n, buffer); + memcpy(image.p(), buffer, image_size); } // Now see if we were successful.