Browse Source

Prevent driver crash using compressed textures with dimensions not divisible by 4 because of MIPMAP_MAX_SIZE parameter.

clementlandrin 2 years ago
parent
commit
b1786a87df
1 changed files with 2 additions and 1 deletions
  1. 2 1
      hxd/res/Image.hx

+ 2 - 1
hxd/res/Image.hx

@@ -272,7 +272,8 @@ class Image extends Resource {
 			throw "Unsupported internal format ("+entry.path+")";
 
 		if( MIPMAP_MAX_SIZE != 0 && inf.mipLevels > 1 ) {
-			while( (inf.width|inf.height) & 1 == 0 && inf.width >> 1 >= MIPMAP_MAX_SIZE && inf.height >> 1 >= MIPMAP_MAX_SIZE ) {
+			// Check next miplevel dimensions are divisible by 4.
+			while( (inf.width|inf.height) & 7 == 0 && inf.width >> 1 >= MIPMAP_MAX_SIZE && inf.height >> 1 >= MIPMAP_MAX_SIZE ) {
 				inf.width >>= 1;
 				inf.height >>= 1;
 				inf.mipLevels--;