Fix deadlock when loading block-compressed texture that is smaller than block size
#2057
This commit is contained in:
@@ -480,6 +480,16 @@ bool GPUTexture::Init(const GPUTextureDescription& desc)
|
||||
break;
|
||||
}
|
||||
}
|
||||
const bool isCompressed = PixelFormatExtensions::IsCompressed(desc.Format);
|
||||
if (isCompressed)
|
||||
{
|
||||
const int32 blockSize = PixelFormatExtensions::ComputeBlockSize(desc.Format);
|
||||
if (desc.Width < blockSize || desc.Height < blockSize)
|
||||
{
|
||||
LOG(Warning, "Cannot create texture. Invalid dimensions. Description: {0}", desc.ToString());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Release previous data
|
||||
ReleaseGPU();
|
||||
@@ -487,7 +497,7 @@ bool GPUTexture::Init(const GPUTextureDescription& desc)
|
||||
// Initialize
|
||||
_desc = desc;
|
||||
_sRGB = PixelFormatExtensions::IsSRGB(desc.Format);
|
||||
_isBlockCompressed = PixelFormatExtensions::IsCompressed(desc.Format);
|
||||
_isBlockCompressed = isCompressed;
|
||||
if (OnInit())
|
||||
{
|
||||
ReleaseGPU();
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user