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

Encode astc support #952

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

wasimabbas-arm
Copy link
Contributor

@wasimabbas-arm wasimabbas-arm commented Oct 19, 2024

Updated version of #810.

Since #810 was adding a separate tool. Its easier to start another cleaner PR.

This PR has:
Commit to add --format option and make it exclusive with --codec
Add ASTC support to encode

Copy link
Collaborator

@MarkCallow MarkCallow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @wasimabbas-arm. Can you now get metrics for ASTC compressed files?

You will need to add tests of the new functionality to the tools CTS and possibly need to update some existing tests.

tools/ktx/metrics_utils.h Outdated Show resolved Hide resolved
lib/astc_encode.cpp Show resolved Hide resolved
abbaswasim added a commit to abbaswasim/KTX-Software-CTS that referenced this pull request Nov 13, 2024
MarkCallow pushed a commit to KhronosGroup/KTX-Software-CTS that referenced this pull request Nov 14, 2024
Copy link
Collaborator

@MarkCallow MarkCallow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nits.

(kFormat, "KTX format enum that specifies the KTX file output format."
" The enum names are matching the VkFormats without the VK_FORMAT_ prefix."
" The VK_FORMAT_ prefix is ignored if present."
"\nIt can't be used with --codec and is only valid for ASTC encoding."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete "is only valid for ASTC encoding" as the start of the next sentence basically repeats this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't think so. This says --codec and --format are mutualy exclusive options. The following says:

                  "\nThe format must be an ASTC format. When specified the ASTC encoder specific"
                  " options becomes valid."

This to me just says the format must be ASTC format, it doesn't talk about mutual exclusion with --codec

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I am not suggesting you remove "It can't be used with --codec", only the latter half of the sentence, which is what is repeated in the next sentence.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Happy to remove what you suggest.

Just adding my 2ps. I still think saying that the --format is only valid for ASTC encoding is still useful. Because here we are talking about the "option" itself while later we are talking about the "value" of the option. I am sure one can deduce this from "format needs to be only ASTC format means its not relevant for anything else bit" but thinking about someone who doesn't know this could trip on that.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I read it, it feels duplicative. The whole piece is talking about the --format option.

Change "The format must be" to "The value must be". I think then it is fine.

} else {
ret = ktxTexture2_CompressBasisEx(texture, &options);
if (ret != KTX_SUCCESS)
fatal(rc::IO_FAILURE, "Failed to encode KTX2 file with codec \"{}\". KTX Error: {}", ktxErrorString(ret));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The codec type argument is missing.

options.mode = KTX_PACK_ASTC_ENCODER_MODE_LDR; // TODO: Fix me for HDR textures
ret = ktxTexture2_CompressAstcEx(texture, &options);
if (ret != KTX_SUCCESS)
fatal(rc::IO_FAILURE, "Failed to encode KTX2 file with codec \"{}\". KTX Error: {}", ktxErrorString(ret));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is for ASTC the message should say '... encode KTX2 file to "{}"'. Also the codec type (in this case format type) argument is missing.

@MarkCallow
Copy link
Collaborator

I've merged the CTS changes. They only update some messages. Please add tests that use encode to encode KTX2 files to ASTC.

@abbaswasim
Copy link
Contributor

@MarkCallow thanks. I will make the rest of the changes.

Can I just ask. I know you have mentioned

Thanks @wasimabbas-arm. Can you now get metrics for ASTC compressed files?

You will need to add tests of the new functionality to the tools CTS and possibly need to update some existing tests.

But every time I have come back to this PR I wasn't sure how many things needs doing (apart from fixing those tests of course). And thats put me off a bit, and ended up procrastinating.

Is there a complete list of things that I need to do for this? I am hoping to go through all at once to reduce lots of back and forth.

At the moment I have

  1. Write tests for new functionality (How many tests are enough? It's already tested in a way, as PR#31 in CTS). Please provide details of what else needs testing.
  2. Get metrics for ASTC compress files (Could you describe what this exactly means?)
  3. what else needs doing? (Maybe the doxygen docs are wrong?)

@wasimabbas-arm wasimabbas-arm changed the title WIP: Encode astc support Encode astc support Nov 14, 2024
@MarkCallow
Copy link
Collaborator

Write tests for new functionality (How many tests are enough? It's already tested in a way, as PR#31 in CTS).

That only modifies 2 golden files to account for the changes in the text of some messages. We need to test the functionality of encoding to ASTC with ktx encode. Look at the tests for encoding UASTC and the tests for ASTC in ktx create to see the kinds of things to test. Test encoding from all valid input input types (R8, etc) encoding to various block dimensions. Probably, but please check, the tests of ASTC encoding in ktx create test the encoder sufficiently (various output block dimensions, etc) so we only need to test a few output types. Test invalid input types, e.g. R32 and make sure the errors are handled correctly. Also test invalid command line options, e.g --codec and --format, and make sure they are handled as expected. You should be able to find suitable input files, and maybe some golden files, in the existing collection under clitests/input.

I'll address the rest of the questions in your comment tomorrow. It's late here now.

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.

3 participants