From bf8d0409bfb328db6934dddbffe99a4317342239 Mon Sep 17 00:00:00 2001 From: Taylor Richards Date: Wed, 23 Jul 2025 13:21:18 -0400 Subject: [PATCH] fix mipmap resizing bug The if statement wouldn't trigger as defined which caused the incorrect data offsets to be used. This resulted in corrupted textures and invalid memory reads of uncompressed textures if the hardware texture detail slider was set to anything other than max. --- code/graphics/opengl/gropengltexture.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/code/graphics/opengl/gropengltexture.cpp b/code/graphics/opengl/gropengltexture.cpp index 6407df36a47..76f540f78c8 100644 --- a/code/graphics/opengl/gropengltexture.cpp +++ b/code/graphics/opengl/gropengltexture.cpp @@ -673,8 +673,10 @@ static int opengl_texture_set_level(int bitmap_handle, int bitmap_type, int bmap auto mipmap_w = tex_w; auto mipmap_h = tex_h; - // should never have mipmap levels if we also have to manually resize - if ((mipmap_levels > 1) && resize) { + // if we are doing mipmap resizing we need to account for adjusted tex size + // (we can end up with only one mipmap level if base_level is high enough so don't check it) + if (base_level > 0) { + Assertion(resize == false, "Cannot use manual and mipmap resizing at the same time!"); Assert(texmem == nullptr); // If we have mipmaps then tex_w/h are already adjusted for the base level but that will cause problems with