Skip to content

Proper handling of --uastc-quality and --uastc-hdr-6x6i-level option values #1149

Merged
MarkCallow merged 13 commits intoKhronosGroup:mainfrom
phasmatic3d:development
Mar 26, 2026
Merged

Proper handling of --uastc-quality and --uastc-hdr-6x6i-level option values #1149
MarkCallow merged 13 commits intoKhronosGroup:mainfrom
phasmatic3d:development

Conversation

@ViNeek
Copy link
Copy Markdown
Contributor

@ViNeek ViNeek commented Mar 17, 2026

This PR fixes #1146. The values are properly forwarded to the basis encoder.

@MarkCallow
Copy link
Copy Markdown
Collaborator

MarkCallow commented Mar 17, 2026

Thank you for this. Please make a PR in KTX-Software-CTS with the regenerated golden files.

@MarkCallow
Copy link
Copy Markdown
Collaborator

MarkCallow commented Mar 19, 2026

Please rebase on current main. Following PR #1151 it has fixes back ported from basis_universal 2.1 including the fix for the assertion failure here. #1151 also removed the workaround for the uninitialized astc_helper tables since the fix for it is one of those back ported. Lastly it includes the fix to ktxdiff to pick a valid transcode target when comparing HDR payloads.

You should be able to regenerate the golden images after which this PR should work. While making the CTS PR, please add a case with level = 2 to tests/create/encode_uastc_hdr6x6i_params.json and also remove the space-filled blank line 11 in that file.

You can regenerate the images using either gcc or clang. You will need to specify --primary when regenerating the images by manually running clitest.py as it cannot detect what compiler was used to build the tools. Because some of the tests have an outputTolerance, the golden images will only be regenerated if --primary is specified.

for compilers supporting std::filesystem and for HDR.
Fixes KhronosGroup#1145.

Additional fixes:
- Adds `num_layers` property that was curiously missing.
- Exposes ktxTexture[12]_IsHDR in the c API.
- Reformats documentation comments for UASTC HDR ktxBasisParams to
   reduce line width.
These are:
- Critical fixes for extreme inputs/outputs
- Compiler warning
- Fix parsing of uint64 in KTX2 header
- Fix initialization of astc_helper tables for transcoding.

Remove our workaround for the astc_helper tables not being initialized.

Fix ktxdiff to choose correct transcode target when comparing HDR
payloads.
@MarkCallow
Copy link
Copy Markdown
Collaborator

Please rebase this to get the basisu fixes.

@MarkCallow
Copy link
Copy Markdown
Collaborator

Aarrgh! It is still failing on Linux and Windows. On Linux, because it is the canonical platform for the golden files, an exact match is expected. It is failing create.encode_uastc_hdr4x4_params. It looks like the golden files for this test were not updated with the fix in place or not updated using a ktx executable compiled with GCC (or Clang).

On Windows create.encode_uastc_hdr6x6i_params is failing. In this case ktxdiff is used and a tolerance is applied as this is not the canonical platform. Since this test is passing on macOS and Linux that suggests the tolerance is not enough for the level 12 case. Before adjusting the tolerance please do a visual check on the golden file and the output file to make sure the differences are not visible. Since only the level 12 case is failing see if you an adjust the tolerance only for that case.

@MarkCallow
Copy link
Copy Markdown
Collaborator

MarkCallow commented Mar 24, 2026

In the interest of saving time, I have been checking the golden files. Indeed the files for the uastc_hdr4x4_params tests have not been updated after the code fix hence the failures on the primary platform.

I am still investigating the Windows failure. Even with quite a large tolerance it still fails. Only the level 12 case is failing.

@MarkCallow
Copy link
Copy Markdown
Collaborator

ktxdiff does not work for the new HDR formats. If the input is transcoded, it assumes its Unorm8. This case must be the only one in the HDR tests where a perfect comparison fails so that ktxdiff is invoked. Please work on the other 2 issues while I fix ktxdiff.

@MarkCallow
Copy link
Copy Markdown
Collaborator

Here is a fixed ktxdiff. Please regenerate the golden files for the uastc_hdr4x4_params tests, open a PR for them in the CTS repo then update the reference in this PR. Then add the fixed ktxdiff to the source branch of this PR. Hopefully the PR will finally go green.

ktxdiff_main.cpp.zip

@MarkCallow
Copy link
Copy Markdown
Collaborator

@ViNeek I just saw your e-mail. Thanks. Please revert the tolerance change in the CTS and add the fixed ktxdiff here.

@MarkCallow
Copy link
Copy Markdown
Collaborator

I merged KhronosGroup/KTX-Software-CTS#65 after checking the uastc_hdr4x4_params test is fixed. However inclusion of the fixed ktxdiff here and reversion of the outputTolerance change in uastc_hdr6x6i_params is still needed. The latter requires a further reference change. Make another PR with that and update the CTS reference here to point at it. I will be able to merge that change without changing the commit hash so no further CTS reference update will be required.

Let's finally get this fixed today.

@MarkCallow
Copy link
Copy Markdown
Collaborator

MarkCallow commented Mar 25, 2026

There was a bug in the new compareSFloat16 function in ktxdiff. . Here is a fixed version.

ktxdiff_main.cpp.zip

With this, the level 12 case fails with differences > 1.4 on some pixels near the end of the texture. I am puzzled because visually the textures don't look that much different especially in the lower right. I don't want to hold up this PR any more for such an edge case, so I have pushed a modified test to the CTS repo which sets the tolerance to 0.08 for all but level 12 and 1.0, which effectively disables the image comparison, for level 12. I'll investigate the level 12 case more when I have time.

Set the reference here to the latest CTS top of main and add the updated ktxdiff_main.cpp to this PR and this should be good to go.

@MarkCallow
Copy link
Copy Markdown
Collaborator

Please update this PR. It will only take a couple of minutes.

@MarkCallow MarkCallow merged commit de9a41a into KhronosGroup:main Mar 26, 2026
41 checks passed
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.

--uastc-quality and --uastc-hdr-6x6i-level option values not passed to basisu_encoder

2 participants