BCnEncoder.NET icon indicating copy to clipboard operation
BCnEncoder.NET copied to clipboard

`DecodeAllMipMaps2D(DdsFile)` returns empty array if `dwMipMapCount` is 0 even when there is a face with mip maps

Open Crauzer opened this issue 2 years ago • 1 comments

This issue arises from the fact that mip count is handled differently in DdsFile and in DecodeInternal.

These are the relevent lines: https://github.com/Nominom/BCnEncoder.NET/blob/master/BCnEnc.Net/Decoder/BcDecoder.cs#L1161-L1164 https://github.com/Nominom/BCnEncoder.NET/blob/master/BCnEnc.Net/Shared/ImageFiles/DdsFile.cs#L57

I think the easiest way to fix this would to be assume that each file has at least 1 mipmap. Microsoft says that you shouldn't rely on the mipmap flag being set.

Crauzer avatar Jan 16 '23 22:01 Crauzer

Another reference to mip count being clamped to at least 1: https://learn.microsoft.com/en-us/windows/uwp/gaming/complete-code-for-ddstextureloader

    size_t mipCount = header->mipMapCount;
    if (0 == mipCount)
    {
        mipCount = 1;
    }

Crauzer avatar Jan 16 '23 22:01 Crauzer