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

Merged
merged 19 commits into from
Nov 28, 2024
Merged

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.

tools/ktx/command_encode.cpp Outdated Show resolved Hide resolved
tools/ktx/command_encode.cpp Outdated Show resolved Hide resolved
tools/ktx/command_encode.cpp Outdated Show resolved Hide resolved
@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.

@wasimabbas-arm
Copy link
Contributor Author

Not sure if the last commit is correct or not. Maybe I need to wait for the KhronosGroup/KTX-Software-CTS#33 to be merged before I can update the submodule

@MarkCallow
Copy link
Collaborator

Not sure if the last commit is correct or not. Maybe I need to wait for the KhronosGroup/KTX-Software-CTS#33 to be merged before I can update the submodule

If you updated the submodule reference to the commit that is in the PR, it should be fine.

@MarkCallow
Copy link
Collaborator

I'll address the rest of the questions in your comment tomorrow.

Sorry. It's two days later. Back to your questions.

Get metrics for ASTC compress files (Could you describe what this exactly means?)

I was asking if you had implemented the feature of printing metrics on the loss from the encoding. Looking at the code, you seem to have done so. The important thing is decoding the ASTC-compressed images so they can be compared with the reference images. You've done that. The rest of the code in metrics_utils.h is the same regardless whether the images came from BasisU or ASTC encoding. We need tests though. Please add tests that encode to ASTC and print out the metrics. (It is possible you have done so and I missed them when reviewing the CTS PR.)

what else needs doing? (Maybe the doxygen docs are wrong?)

At the moment I do not think there is anything else beyond addressing the issues here and in the CTS PR. I'll review the docs again but what I looked at so far seemed fine.

@MarkCallow
Copy link
Collaborator

Please add tests that encode to ASTC and print out the metrics.

Please modify command_create.cpp as necessary so the metrics options work for ASTC as well as BasisU and add tests for the functionality. It previously only supported metrics for BasisU.

@MarkCallow
Copy link
Collaborator

I just found one more thing that needs to be done. The documentation for --normal-mode in encode_utils_common.h says "use --normalize if unsure that the input has unit normals". However there is no normalize option (that I could find. Something weird is going on with my Xcode find at present). The image class has implementations so it should just be a question of adding the option and when set calling the function on the image.

@MarkCallow
Copy link
Collaborator

MarkCallow commented Nov 18, 2024

List to track the requests I've made that aren't comments on existing code.

  • Uncomment references in ktx create documentation to encode being able to encode to ASTC, now that it is.
  • Enable printing metrics when encoding to ASTC in ktx create
  • Add --normalize option to ktx create
  • Add test to ensure passing an ASTC encoded KTX2 file to ktx encode is a no-op.

@wasimabbas-arm
Copy link
Contributor Author

* [ ]  Add `--normalize` option to `ktx create`

@MarkCallow Please refer to #812. Its currently is still the case that both create and encode has lost the option.

I would argue this is out of scope for this PR. Lets conclude 812 before we proceed.

@MarkCallow
Copy link
Collaborator

The reuse issue has cleared up on its own. I've no idea what happened. The latest version ran fine for me locally.

@MarkCallow
Copy link
Collaborator

* [ ]  Add `--normalize` option to `ktx create`

@MarkCallow Please refer to #812. Its currently is still the case that both create and encode has lost the option.

I would argue this is out of scope for this PR. Lets conclude 812 before we proceed.

I agree it is out of scope for this PR. I've pinged Alexey again in #812. My view is normalize should be restored.

@MarkCallow
Copy link
Collaborator

Please update the CTS reference then I can merge this.

@wasimabbas-arm
Copy link
Contributor Author

Please update the CTS reference then I can merge this.

Done.

@MarkCallow MarkCallow merged commit d1ad5cd into KhronosGroup:main Nov 28, 2024
17 checks passed
@MarkCallow
Copy link
Collaborator

Thanks @wasimabbas-arm.

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