Skip to content

basis_universal: Update to 1.60 #103968

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

Merged
merged 1 commit into from
Apr 28, 2025

Conversation

Chubercik
Copy link
Contributor

@Chubercik Chubercik commented Mar 11, 2025


Due to the update changing a plethora of things, here's a recap:

  • Compression parameters were renamed, as seen in modules/basis_universal/image_compress_basisu.cpp
  • Because libktx makes use of the bundled basis_universal library, I had to change the type of one variable, as seen in thirdparty/libktx/patches/0003-basisu-1.60.patch (new patch for libktx)
  • thirdparty/basis_universal/encoder/basisu_astc_hdr_6x6_enc.h, which is a new file, had a superscript two symbol in a comment - this is all good and nice, but due to, I guess, UTF-8 non-complience, it generated a warning that was treated as an error by one Windows CI job; I changed the symbol to ^2, as seen in thirdparty/basis_universal/patches/0005-windows-illegal-character.patch (also see: Change ² (U+00B2) to ^2 BinomialLLC/basis_universal#394)
  • clang sanitizers didn't like the ambiguity of 1ULL, as it could be treated as a 32-bit or a 64-bit integer, due to an implicit conversion; patched in thirdparty/basis_universal/patches/0006-ambiguous-calls.patch (also see: Fix ambiguous calls to safe_shift_left() in basisu_containers.h BinomialLLC/basis_universal#387)
  • Other patches have been regenerated, notably another change to jpeg_decoder flags had to be added in thirdparty/basis_universal/patches/0002-external-jpgd.patch

Speaking of patches, wouldn't simply prepending function bodies in thirdparty/basis_universal/patches/0004-remove-tinydds-qoi.patch with return false; be an easier change that achieves the same result? Or would something in the build system throw a tantrum over unreachable code?

@Chubercik Chubercik force-pushed the basis_universal-1.60 branch from 7d72c9a to f34056e Compare March 11, 2025 12:41
@Chubercik Chubercik marked this pull request as ready for review March 11, 2025 12:41
@Chubercik Chubercik requested review from a team as code owners March 11, 2025 12:41
@Chubercik Chubercik changed the title Basis universal 1.60 basis_universal: Update to 1.60 Mar 11, 2025
Copy link
Contributor

@BlueCube3310 BlueCube3310 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with https://polyhaven.com/a/cambridge (8192x4096, 13 mipmaps, compression = BasisUniversal):

4.4-stable This PR
16.5s 4.2s

The encoding process is about 4x faster. I wasn't able to spot any regressions in terms of quality either

@fire
Copy link
Member

fire commented Apr 24, 2025

Can you help upstream? This is non blocking for approving this pr.

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, it works as expected.

Benchmark

PC specifications
  • CPU: Intel Core i9-13900K
  • GPU: NVIDIA GeForce RTX 4090
  • RAM: 64 GB (2×32 GB DDR5-5800 C30)
  • SSD: Solidigm P44 Pro 2 TB
  • OS: Linux (Fedora 42)

Using an optimized editor build (production=yes lto=full). BasisU encode times for https://polyhaven.com/a/cambridge in .hdr format with Basis Universal compression (mipmap generation disabled):

  1K 2K 4K 8K 16K 17K*
master 143 ms 622 ms 2282 ms 9563 ms 9406 ms 36502 ms
This PR 37 ms 166 ms 645 ms 2488 ms 7845 ms 10158 ms

*: While testing this, I noticed the downscaling logic has an issue (at least with HDRIs or Basis Universal compression). The 17K HDRI will be downsized to 16K, but the resulting texture is pure black. This occurs both before and after this PR.

WARNING: res://cambridge_17k.hdr: Texture was downsized on import as its width (17858 pixels) exceeded the importable size limit (16384 pixels).
     at: import (./editor/import/resource_importer_texture.cpp:599)

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thirdparty code integration wise, this looks good to me.

@akien-mga
Copy link
Member

thirdparty/basis_universal/encoder/basisu_astc_hdr_6x6_enc.h, which is a new file, had a superscript two symbol in a comment - this is all good and nice, but due to, I guess, UTF-8 non-complience, it generated a warning that was treated as an error by one Windows CI job; I changed the symbol to ^2, as seen in thirdparty/basis_universal/patches/0005-windows-illegal-character.patch

This one would be worth PR'ing upstream too.

@Repiteo
Copy link
Contributor

Repiteo commented Apr 25, 2025

Got a PR that'll fix the CI issue, #105756

@Repiteo Repiteo merged commit be994d5 into godotengine:master Apr 28, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Apr 28, 2025

Thanks!

@DanielKinsman
Copy link
Contributor

After this was merged the patches in thirdparty/basis_universal/patches do not get us to the current state of master, when starting from the basis universal commit mentioned in thirdparty/README. So we've made some changes but have no idea what they are. The build fails without these changes.

It makes rebasing my current PR on master which touches the same code difficult.

@akien-mga
Copy link
Member

The problem seems to be the "illegal character" patch, which is not cross-platform. It likely works on Windows but fails for me on Linux.

@akien-mga
Copy link
Member

@Chubercik Chubercik deleted the basis_universal-1.60 branch April 29, 2025 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants