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

Update ASTC version #951

Merged
merged 1 commit into from
Mar 5, 2024
Merged

Update ASTC version #951

merged 1 commit into from
Mar 5, 2024

Conversation

jherico
Copy link
Contributor

@jherico jherico commented Feb 27, 2024

Description

  • Update the astcenc library version to the most recent release.
    • Detect SIMD support and build the corresponding atscenc variant
    • Fixes a number of potential memory leaks caused by the non-thread-safe code in the previous version of astcenc
  • Update the mipmap generation code to allocate the required memory for all mips at once instead of mip by mip (less fragmentation, and should be faster)

Performance

Ran the command_buffer_usage sample 5 times against this branch and against the current main branch, recording the Time spent loading images log line for each run. The target machine is a Ryzen Threadripper 1950X with 32 logical processor and for which the AVX2 ISA was detected and used.

branch average load time standard deviation
main 5.6638216 0.07
astc 3.3971104 0.06

This represents a 40% increase in ASTC image decompression performance.

Note that the only caveat for this is that the modules being used to detect the SIMD instruction set were only found under the license embedded in the added CMake files, which is a slight variant of the BSD-3 license. Hopefully this shouldn't be a problem.

General Checklist:

Please ensure the following points are checked:

  • My code follows the coding style
  • I have reviewed file licenses
  • I have commented any added functions (in line with Doxygen)
  • I have commented any code that could be hard to understand
  • My changes do not add any new compiler warnings
    • Strictly speaking there may be new or different compiler warnings inside the ASTC build, but that seems out of scope.
  • My changes do not add any new validation layer errors or warnings
  • I have used existing framework/helper functions where possible
  • My changes do not add any regressions
  • I have tested every sample to ensure everything runs correctly
  • This PR describes the scope and expected impact of the changes I am making

Note: The Samples CI runs a number of checks including:

  • I have updated the header Copyright to reflect the current year (CI build will fail if Copyright is out of date)
  • My changes build on Windows, Linux, macOS and Android. Otherwise I have documented any exceptions

@gary-sweet
Copy link
Contributor

Is this PR also suffering from the CRLF issue? Whole files appear different.

@jherico jherico force-pushed the astc branch 4 times, most recently from 6a8aaef to 8ed788a Compare February 28, 2024 00:26
@jherico jherico changed the title WIP: Update ASTC version Update ASTC version Feb 28, 2024
@jherico jherico marked this pull request as ready for review February 28, 2024 06:04
@tomadamatkinson tomadamatkinson requested a review from a team February 28, 2024 10:57
gary-sweet
gary-sweet previously approved these changes Feb 28, 2024
Copy link
Collaborator

@tomadamatkinson tomadamatkinson left a comment

Choose a reason for hiding this comment

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

Good improvement. Thanks for performance testing!

@SaschaWillems
Copy link
Collaborator

Note that the only caveat for this is that the modules being used to detect the SIMD instruction set were only found under the license embedded in the added CMake files, which is a slight variant of the BSD-3 license. Hopefully this shouldn't be a problem.

We probably need to check this internally. @marty-johnson59: Maybe something to put on next calls agenda? Or forward to Legal at Khronos. It's a different license, so we need to make sure that we can use it and that we don't block any current user from using our samples by that new license.

Copy link
Collaborator

@SaschaWillems SaschaWillems left a comment

Choose a reason for hiding this comment

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

LGTM aside from the legal stuff. I only have some minor remarks regarding some comments.

framework/CMakeLists.txt Outdated Show resolved Hide resolved
third_party/CMakeLists.txt Outdated Show resolved Hide resolved
Copy link
Collaborator

@SaschaWillems SaschaWillems left a comment

Choose a reason for hiding this comment

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

Code LGTM.

We still need to check on licenses before merging.

@tomadamatkinson
Copy link
Collaborator

@marty-johnson59 is a licence check needed on this?

@marty-johnson59
Copy link
Contributor

ATSC is under Apache 2 license, so we're OK with that. Merging with 3..

@marty-johnson59 marty-johnson59 merged commit 8ba37b4 into KhronosGroup:main Mar 5, 2024
25 checks passed
@jherico jherico deleted the astc branch March 5, 2024 19:44
@SaschaWillems
Copy link
Collaborator

Looks like this broke builds on recent Apple devices (e.g. M1), see #965

@kanavin
Copy link
Contributor

kanavin commented Mar 12, 2024

@jherico @SaschaWillems there's another issue here: the newly added cmake modules check whether the compiler can produce the instructions, by trying various command line flags, and then forcibly enable them if so.

This doesn't work when the build is intended for a machine that doesn't actually support those instructions; the checks should either try only the default compiler settings (e.g. no additional options), or have a switch to forcibly override ASTC_ARCH from cmake command line.

This was exposed by trying to build for 32 bit x86 (yes, it's still a valid architecture in 2024) - the checks happily enable AVX2 because 32bit x86 compiler can do it if you ask, even though the overall build is configured for a mid 2000s x86 CPU model that can't possibly have that.

@jherico
Copy link
Contributor Author

jherico commented Mar 12, 2024

@kanavin is it critical that this be automatic, or would it be sufficient if you could force the ISA from the command line, like for instance cmake -Bbuild -DASTC_ARCH=NONE?

If the latter is sufficient, then I have a PR up that should allow you to build: #978

@kanavin
Copy link
Contributor

kanavin commented Mar 12, 2024

@kanavin is it critical that this be automatic, or would it be sufficient if you could force the ISA from the command line, like for instance cmake -Bbuild -DASTC_ARCH=NONE?

If the latter is sufficient, then I have a PR up that should allow you to build: #978

Something like this should work, yes. I've tested a local patch that does something similar, and was going to open a pull request:

kanavin@41090ff

While you're at it, SSE41 should become sse4.1 (with a dot), when lowercased, as that's how astc defines the target.

@jherico
Copy link
Contributor Author

jherico commented Mar 12, 2024

Ugh, you're right... 🤦

image

I'm just going to exclude it for now. It's a relatively narrow window of processors that support SSE 4.1 and NOT AVX2.

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.

7 participants