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

Fix ktxTexture2_DecodeAstc error returns and document them. #961

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MarkCallow
Copy link
Collaborator

@MarkCallow MarkCallow commented Nov 29, 2024

This started due to a warning when building documentation that astc_encode.cpp was not being found. After fixing that I noticed issues with the documentation for ktxTexture2_DecodeAstc which I fixed in c16537c. That commit also fixed an issue where the function would fail with KTX_INVALID_OPERATION if a zlib or zstd supercompressed file had been opened without specifying the LOAD_DATA flag by removing the check for KTX_SS_NONE.

Subsequently I realized there still some supercompression scheme situations that need to be guarded against and I realized the function documentation was not listing the possible return values. While fixing these I spotted a write to stdout that this PR comments out. Libraries potentially used by GUI apps should not write to stdout. We could potentially add a flag parameter to request the ouput.

@wasimabbas-arm please review this PR.

Why do decoder failures return KTX_INVALID_OPERATION? Could you analyze the astcenc error and potentially map to other KTX_ errors? Alternatively should we add a new error such as KTX_ASTC_DECODE_FAILED? KTX_INVALID_OPERATION is intended for cases where the application has set things up in way that is invalid for the operation it is requesting.

Adding unit tests for this function to texturetests would be a good thing. Tests of the encode function would be good too, if not already existing.

@wasimabbas-arm
Copy link
Contributor

I have always had problem with the right KTX_errors. For example in astcenc_context_alloc there are quite a lot of different ASTC enoder specific errors returned. But at call site:

    astc_error  = astcenc_context_alloc(&astc_config, threadCount, &astc_context);

    if (astc_error != ASTCENC_SUCCESS)
        return KTX_INVALID_OPERATION;

I can only turn that into KTX_INVALID_OPERATION. So I could never workout how verbose do we have to be about these errors. A rule of thumb could be that if a user can do something about an error it should provide enough context for them to be able to.

In this case astc_context_alloc has many different errors that I have to fix in the KtxTexture2_DecodeAstc but for the user a KTX_INVALID_OPERATION is sufficient. Otherwise we are gonna have to translate all encoder messages into KTX message/errors.

At a minimum creating generic KTX_ENCODE_ERROR and KTX_DECODE_ERROR makes sense. So something like the attached patch would make sense.

diff.patch

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 this pull request may close these issues.

2 participants