Fix deadlock when loading block-compressed texture that is smaller than block size

#2057
This commit is contained in:
Wojtek Figat
2023-12-14 15:14:49 +01:00
parent 014c811903
commit 60202a3add
2 changed files with 13 additions and 3 deletions

View File

@@ -114,9 +114,9 @@ bool StreamingTexture::Create(const TextureHeader& header)
{
// Ensure that streaming doesn't go too low because the hardware expects the texture to be min in size of compressed texture block
int32 lastMip = header.MipLevels - 1;
while ((header.Width >> lastMip) < 4 && (header.Height >> lastMip) < 4)
while ((header.Width >> lastMip) < 4 && (header.Height >> lastMip) < 4 && lastMip > 0)
lastMip--;
_minMipCountBlockCompressed = header.MipLevels - lastMip + 1;
_minMipCountBlockCompressed = Math::Min(header.MipLevels - lastMip + 1, header.MipLevels);
}
// Request resource streaming