Skip to content

Commit 9718e70

Browse files
fix mipmap resizing bug (#6895)
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.
1 parent ab43811 commit 9718e70

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

code/graphics/opengl/gropengltexture.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,8 +673,10 @@ static int opengl_texture_set_level(int bitmap_handle, int bitmap_type, int bmap
673673
auto mipmap_w = tex_w;
674674
auto mipmap_h = tex_h;
675675

676-
// should never have mipmap levels if we also have to manually resize
677-
if ((mipmap_levels > 1) && resize) {
676+
// if we are doing mipmap resizing we need to account for adjusted tex size
677+
// (we can end up with only one mipmap level if base_level is high enough so don't check it)
678+
if (base_level > 0) {
679+
Assertion(resize == false, "Cannot use manual and mipmap resizing at the same time!");
678680
Assert(texmem == nullptr);
679681

680682
// If we have mipmaps then tex_w/h are already adjusted for the base level but that will cause problems with

0 commit comments

Comments
 (0)