lwjgl3
lwjgl3 copied to clipboard
Basis Universal support
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
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.
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).
@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).
@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: https://github.com/KhronosGroup/KTX-Software/pull/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?
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.
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.
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: https://github.com/KhronosGroup/KTX-Software/pull/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 :).
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.
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.)
@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.
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 https://github.com/KhronosGroup/KTX-Software/pull/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.
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.