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

Basis Universal support #660

Closed
tlf30 opened this issue Jul 12, 2021 · 12 comments
Closed

Basis Universal support #660

tlf30 opened this issue Jul 12, 2021 · 12 comments

Comments

@tlf30
Copy link
Contributor

tlf30 commented Jul 12, 2021

It would be great to get Basis Universal support in LWJGL for texture compression.
https://github.com/BinomialLLC/basis_universal
More information can be found here: https://www.khronos.org/assets/uploads/apis/KTX-2.0-Launch-Overview-Apr21_.pdf

Thanks,
Trevor

@Spasi
Copy link
Member

Spasi commented Jul 13, 2021

I've been following Basis for a while and it would indeed be nice to have in LWJGL. Unfortunately, there's no C API available yet.

@tlf30
Copy link
Contributor Author

tlf30 commented Jul 13, 2021

Thanks for the response @Spasi. Perhaps once we get C++ support with Panama we will be good to go (crossing my fingers that it happens within our lifetime).

@Illithidek
Copy link

@tlf30
What advantages does it have compared to: https://github.com/KhronosGroup/KTX-Software? I think it could be a good replacement. And it has bindings for C(interface/basisu_c_binding) and even Java(interface/java_binding).

@tlf30
Copy link
Contributor Author

tlf30 commented Apr 15, 2022

@Illithidek I was not aware that KTX-Software had JNI bindings, thank you for bringing it to my attention. Looking at the repo it looks like a very recent addition: KhronosGroup/KTX-Software#556. Do you know if the bindings are complete and released? Or if they are going to be included into a release in the near future?

@Illithidek
Copy link

Illithidek commented Apr 15, 2022

Well I was going to test these bindings in near future, but I can share what I've been able to determine :).

From what I've seen the releases are pretty slow(last one was 1 year ago).
That's why these freshly bindings aren't available in the release and you have to build them yourself according to the instructions: https://github.com/KhronosGroup/KTX-Software/tree/master/interface/java_binding.

When it comes to bindings, I don't think there's big misses when it comes to base usage. You can just look over https://github.com/KhronosGroup/KTX-Software/blob/master/include/ktx.h (probably methods with prefixes ktxTexture2_ will mostly interest you), and corresponding bindings in the https://github.com/KhronosGroup/KTX-Software/tree/master/interface/java_binding/src/main/cpp (for methods with ktxTexture2_, JNI version is KtxTexture2.cpp).
Anyway, adding bindings is rather trivial as far as I can see, so it shouldn't be too much trouble to fill some gaps.

@tlf30
Copy link
Contributor Author

tlf30 commented Apr 15, 2022

Great, thank you for the information. I can dive in deeper when I get home in a week. I am currently at work (I work at a remote location in the artic circle). This does look like it will be a good alternative to adding the bindings to LWJGL.

@Illithidek
Copy link

I finally returned to the topic, today quite quickly I managed to build a project from the master branch with result of 3 files:
libktx.so, libktx_jni.so, libktx-4.1.0.jar.
After that I detected a few errors with JNI during testing, so I just pushed a proper fix:
KhronosGroup/KTX-Software#621

For testing I used PVRTexTool to convert *.png to BASIS UASTC(Basis Universal format), and saved it in *.ktx2.
Then I transcoded *.ktx2 to use it on Vulkan, it seems to work pretty well, so as long as there are no memory leaks or JNI problems this should be a good solution :).

@Spasi Spasi moved this to Media in Bindings Sep 3, 2022
@Spasi Spasi added this to Bindings Sep 3, 2022
@tlf30
Copy link
Contributor Author

tlf30 commented Sep 16, 2022

I am currently working with Khronos on getting the jni bindings published to maven central. There is an issue open for it over in their repo if anyone would like to comment.

@Spasi
Copy link
Member

Spasi commented Sep 16, 2022

Hey @tlf30, @Illithidek,

I somehow missed this discussion about KTX. Had a quick look now and it seems that Basis is nicely integrated into KTX and there's a (fully featured?) C API exposed for it. Am I wrong? If that's the case, I'd much rather add bindings for KTX, instead of just Basis.

Note that this would make sense even in the presence of an official binding. (LWJGL-style API + javadoc, snapshot builds, easy download / Maven artifacts, jlink-able modules, etc.)

@tlf30
Copy link
Contributor Author

tlf30 commented Sep 16, 2022

@Spasi they are working on an official JNI binding, but I personally think that an LWJGL style binding would be better. I have not evaluated the C api yet. My understanding is that Universal Basis support is included, along with other formats such as jpg, png, and other compressed/encoded formats, but for the use of KTX files (AFAIK Univeral Basis was created as part of the KTX format, or vice versa).

Perhaps it would make more sense for them to drop the jni binding they are working on and just have LWJGL, and you have more experience with properly bundling the natives and automating binding generation.

Tagging @MarkCallow from Khronos.

@MarkCallow
Copy link

I'll address a few points...

Do you know if the bindings are complete and released? Or if they are going to be included into a release in the near future?

The binding is complete and will be in the 4.1.0 release. I am waiting for a new code-signing certificate for signing the windows binaries and installers. Once I have that I'll make the 4.1.0 release. The release will include KhronosGroup/KTX-Software#621.

The binding was contributed so I am not deeply familiar with it.

I am currently working with Khronos on getting the jni bindings published to maven central.

I plan to work on this once 4.1.0 is released.

And it has bindings for C(interface/basisu_c_binding)

This is a binding to the included basisu software used for the sole purpose of creating a test comparing the result of decoding a basisu file vs a KTX v2.0 file with the same content. It is not complete and definitely not intended for use outside the KTX project.

but I personally think that an LWJGL style binding would be better.

I am not familar with LWJGL. The name suggests it has something to do with OpenGL. The only part of libktx that is OpenGL related is the ktxTexture_GLUpload function. So I'm not sure LWJGL is the right binding.

My understanding is that Universal Basis support is included, along with other formats such as jpg, png, and other compressed/encoded formats, but for the use of KTX files (AFAIK Univeral Basis was created as part of the KTX format, or vice versa).

KTX and libktx only support formats supported by GPUs (i.e. uncompressed and block-compressed formats) plus the transcodable Basis Universal formats so it does not support jpp, png or anything similar. toktx can be used to create KTX files from jpg and png files.

Basis Universal and KTX v2.0 evolved together. Transcodable formats are the invention of Rich Geldreich at Binomial. When we started KTX v2 we planned to use some of Rich's earlier attempts but, thanks to funding from Google, Rich was able to open source Basis Universal so we incorporated that.

@Spasi Spasi closed this as completed in 836dca5 Nov 4, 2022
@Spasi
Copy link
Member

Spasi commented Nov 4, 2022

The latest build (3.3.2-snapshot+6) now includes KTX bindings.

Both the full library (write/encode support) and the ktx_read version (read/transcode only) are supported. The build included with LWJGL is the full library. Note that all SIMD encoding back-ends are enabled, please let me know if writing/encoding does not work for you.

@Spasi Spasi removed this from Bindings Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants