浏览代码

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

clementlandrin 2 年之前
父节点
当前提交
b1786a87df
共有 1 个文件被更改,包括 2 次插入1 次删除
  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--;