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

Use NVTT to support BCn texture compression #23

Open
LPGhatguy opened this issue Apr 21, 2023 · 3 comments
Open

Use NVTT to support BCn texture compression #23

LPGhatguy opened this issue Apr 21, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@LPGhatguy
Copy link
Collaborator

The Nvidia Texture Tools are an awesome way to produce KTX2 files with block compression and supercompression. It would be very helpful to use them when a user asks for BCn compressed textures, or potentially for GPU-accelerating ASTC compression.

Sadly, the tools' KTX2 output is only available through its UI, and not via the SDK or CLI tool currently: https://forums.developer.nvidia.com/t/how-to-export-ktx2-by-nvtt3-sdk/235164

@LPGhatguy LPGhatguy added the enhancement New feature or request label Apr 21, 2023
@kanerogers
Copy link
Contributor

I had to wait a whole minute today to compress some images on desktop so I'm now super motivated to fix this!

What would be required to make this happen? Does the ktx2 crate need to be modified?

@LPGhatguy
Copy link
Collaborator Author

We have a few different ways we could approach this problem.

  1. We could submit a PR for KTX2 support to the NVTT CLI. This might be the most direct solution to the problem, but it might involve mucking with their build system to move some of their dependencies around. Nvidia has expressed interested in this happening but I don't know whether it's prioritized. Because their GUI already supports KTX2, this might be straightforward.

  2. We could submit a PR to support BCn compression in the Khronos Texture Tools. I don't know how much work it is to encode these formats efficiently. It seems like this is within scope of the tools.

  3. We could submit a PR to the Khronos Texture Tools to support taking in DDS files containing BCn data. I don't know if toktx has any support for passing through data that's already GPU compressed.

  4. We could integrate a DDS parser into squisher, use NVTT's DDS output, and construct our own KTX2 files. This sounds fine in theory and should involve the least amount of code, but has limited impact. We would only be solving this problem for squisher. I worry that producing writing KTX2 files is a little complicated. This PR that I opened on the ktx2 repo makes things a little easier and I have some code we can reference.

Option 2 is the best for us, since it keeps squisher depending on only toktx. Option 1 also seems good and might be the highest performance choice. Option 3 feels like a bit of a longshot. Option 4 is a last resort if both NVTT and KTT are inscrutable or contribution unfriendly.

@LPGhatguy
Copy link
Collaborator Author

LPGhatguy commented Dec 1, 2023

Good news, everyone! Our strategy of just waiting and doing nothing has paid off.

nvtt_export from NVTT can now export KTX2 files that are supercompressed and have GPU compression in all sorts of formats! It's also super duper fast it looks like.

One hangup is that NVTT doesn't support RGB8 or RGBA8 output, which stops us from adopting it completely. I opened a forum thread with a request for the tool to support them: https://forums.developer.nvidia.com/t/rgb-rgba-format-export-option/274632

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants