Skip to content

Update Java bindings for HDR support#1147

Merged
MarkCallow merged 18 commits intoKhronosGroup:mainfrom
javagl:update-java-bindings-for-hdr
Apr 20, 2026
Merged

Update Java bindings for HDR support#1147
MarkCallow merged 18 commits intoKhronosGroup:mainfrom
javagl:update-java-bindings-for-hdr

Conversation

@javagl
Copy link
Copy Markdown
Contributor

@javagl javagl commented Mar 11, 2026

The PR #1100 added HDR support.

This PR updates the Java bindings accordingly so fixes #1144.

What it does:

  • Adds the UASTC_HDR_6X6_INTERMEDIATE supercompression scheme enum value
  • Adds the RGBA_HALF/ASTC_HDR_4x4_RGBA/ASTC_HDR_6x6_RGBA transcode format enum values
  • Adds a new KtxBasisCodec class, corresponding to the codec enum, as requested in a review comment
  • Adds the new fields that have been added to ktxBasisParams (like uastcHDRUltraQuant etc) to the KtxBasisParams class
  • (Minor corresponding cleanups)
  • Wires the new fields to the native side accordingly, e.g. initialize and fills the native struct
  • Adds native versions of the
    KTX_API ktx_bool_t KTX_APIENTRY ktxTexture1_IsTranscodable(ktxTexture1* This);
    functions (for KtxTexture1 and KtxTexture2)
  • Adds getColorModel, getTransferFunction, isHDR.
  • Adds a couple of tests.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 11, 2026

CLA assistant check
All committers have signed the CLA.

@MarkCallow
Copy link
Copy Markdown
Collaborator

  • There seem to be further methods: getColorModel, getTransferFunction, isHDR ... ? Not yet looked at the details

The first two are not specific to HDR. getTransferFunction has been around for a while and even longer, at least in native, with a different name, getOETF or something like that. Please add all of these to the Java binding.

@MarkCallow
Copy link
Copy Markdown
Collaborator

I have just create PR #1150 to add everything to the Python binding. Letting you know as it may be helpful.

@javagl
Copy link
Copy Markdown
Contributor Author

javagl commented Mar 19, 2026

I'll have a closer look at the changes and will try add any changes that might be missing here.
(Hopefully, during the weekend or early next week)

@javagl
Copy link
Copy Markdown
Contributor Author

javagl commented Apr 1, 2026

Most of the updates that are specific for the added HDR support should be done now.

(I stumbled over the missing ktxTexture2_IsHDR API entry, but that was fixed in a recent PR - I only had to pull this)

I'll add some further tests for the new functionality.


One thing that is "unrelated" to the HDR changes: I noticed that the bindings for

KTX_API khr_df_model_e KTX_APIENTRY
ktxTexture2_GetColorModel_e(ktxTexture2* This);

KTX_API khr_df_primaries_e KTX_APIENTRY
ktxTexture2_GetPrimaries_e(ktxTexture2* This);

are missing, including the corresponding enum equivalents. I've seen that they have been added in your Python binding update PR as well, so I assume that they should also be part of the Java bindings.

I'll try to allocate some time to add them (this could be a new PR, but 🤷‍♂️ it probably makes sense to just add them here...).

Copy link
Copy Markdown
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.

Looks good. Thanks. Some test coverage using the new tokens would be great, if time allows.

I am waiting for fixes to two other issues. I will hold off on merging this until those arrive to give you a window for adding ktxTexture2_GetColorModel_e and ktxTexture2_GetPrimaries_e to this PR. They should indeed be included in the Java wrapper.

@MarkCallow
Copy link
Copy Markdown
Collaborator

A PR has been submitted with the fixes I mentioned. I plan to merge this PR after that PR is merged. I expect to do so within the next 3 days. Please add ktxTexture2_GetColorModel_e and ktxTexture2_GetPrimaries_e. Also remove the rec2020 field from KtxBasisParams as it will be removed from native by the just-submitted PR. I decided to follow the same model we have for sRGB which is that ktxTexture2_CompressBasisEx sets the flag based on the transfer function of the ktxTexture2 being encoded. The rec2020 flag will be set based on the primaries.

@javagl
Copy link
Copy Markdown
Contributor Author

javagl commented Apr 16, 2026

@MarkCallow There currently seem to be two PRs, #1155 #1157 , that might affect the API or the Java bindings.

I'm in no way deeply enough involved to know what's going on there. Much of that (more than I'd like) just consists of "looking at the code, and mimicking that in Java".

However: When I manage to allocate the time for the remaining update, I'll look at 'the current state (at that time)' and do the update accordingly, but will keep in mind that theye PRs may be merged in the next few days and the update here may have to take them into account.

@MarkCallow
Copy link
Copy Markdown
Collaborator

#1155 is a name change. It will only affect this PR if the DFD's channelType is exposed in the Java wrapper. It is not exposed in the Python wrapper so I think it is not exposed in Java either. It is a very low level thing.

The only part of #1157 will affect this is the removal of the rec2020 field. The rest of it is new functionality in command_create.cpp and command_extract.cpp. You could remove rec2020 from the wrapper now and the PR will still build with the current library. Then it will be ready for me to merge as soon as #1157 is merged.

I'd prefer to prepare this for #1157 now. After #1157 and this are merged I will rebase #1155 and take care of any necessary fixes in the wrappers. Since I didn't need any in Python or JavaScript I'll be surprised to find any in Java.

@MarkCallow
Copy link
Copy Markdown
Collaborator

I've just merged #1157. Please remove the rec2020 field from this and remove the draft status so I can merge it.

@javagl
Copy link
Copy Markdown
Contributor Author

javagl commented Apr 17, 2026

remove the draft status so I can merge it.

I think the remaining tasks here are

  • add ktxTexture2_GetColorModel_e and ktxTexture2_GetPrimaries_e
  • remove the rec2020 field

and I'll try to do this "soon" (maybe during the weekend), and drop a note here when it's done.

@MarkCallow
Copy link
Copy Markdown
Collaborator

I think the remaining tasks here are

* add ktxTexture2_GetColorModel_e and ktxTexture2_GetPrimaries_e

* remove the rec2020 field

Agreed.

@javagl
Copy link
Copy Markdown
Contributor Author

javagl commented Apr 19, 2026

The last commits...

  • Add functions getColorModel and getPrimaries to the KtxTexture2 class
  • Add KhrDfModel and KhrDfPrimaries classes that carry the corresponding enum values
  • Remove the rec2020 from the KtxBasisParams class

I wanted to add some test that at least "touch" the new HDR functionality in some way. The commit 73db397 adds a test that reads HDR input and checks for the isHDR flag (and the VK format). Similarly, one test runs compressBasis with UASTC_HDR_4X4 and checks the HDR/VkFormat of the result. I hope that this makes some sense (given that it could be difficult to port the CTS to Java 😬 ).


Unrelated note:

@return A @c khr_df_transfer enum value specifying the color model.
should be
@return A @c khr_df_model enum value specifying the color model.

at

* @return A @c khr_df_transfer enum value specifying the color model.

Given that it's only a minor comment fix, I can change this as part of this PR, if that's OK.

@javagl javagl marked this pull request as ready for review April 19, 2026 13:54
@MarkCallow MarkCallow merged commit 459c0a9 into KhronosGroup:main Apr 20, 2026
41 checks passed
@MarkCallow
Copy link
Copy Markdown
Collaborator

MarkCallow commented Apr 20, 2026

Thank you very much for your hard work on this.

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.

Add HDR support to Java binding

3 participants