Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Crauzer opened this issue Jan 16, 2023 · 1 comment · May be fixed by #65

Comments

@Crauzer
Copy link

Crauzer commented Jan 16, 2023

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
Copy link
Author

Crauzer commented Jan 16, 2023

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 Crauzer linked a pull request Jan 16, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant