-
Notifications
You must be signed in to change notification settings - Fork 690
feat(ktx): add initial ktx input/output support. #5185
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
Open
walcht
wants to merge
45
commits into
AcademySoftwareFoundation:main
Choose a base branch
from
walcht:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
3c374a8
feat(ktx): add initial ktx input/output support.
walcht 289bc14
Remove BCn and ETC encoders/decoders dependencies
walcht 5f707f5
Merge branch 'main' into main
walcht dd28a48
Only build or find libktx on MSVC, Clang, or GCC
walcht b5e85b6
Merge branch 'main' of github.com:walcht/OpenImageIO
walcht 3453812
Add to-native-data-format conversion
walcht 1e60868
Override C/C++ compiler for KTX; revert CMAKE_VERSION in CI; misc ref…
walcht bef354e
Remove <vkformat_enum> include
walcht ae63741
Add alpha and ioproxy support to ktxinput/ktxoutput
walcht 8b68531
Fix mismatching deallocation
walcht f1c19a9
CI: lower libktx version for 'oldest' CI runners
walcht 7593501
Add Ktx_VERSION and use it in ktxinput
walcht e7c1fe3
Fix buffer cleanup using unique_ptr
walcht 415b36d
Replace Ktx_GIT_TAG with Ktx_BUILD_VERSION
walcht 29d45c6
Fix Intel-based MacOS libktx build issues
walcht a133b1f
Use set_cache() instead of set() to expose vars to CI runners
walcht 05e3dde
Add description to set_cache()
walcht a7f95f6
Add support for older ktx build (v4.3.2)
walcht 403f7f3
Add support for libktx 4.3.2
walcht f07af6e
Fix libktx 4.3.2 support
walcht 9c918fc
Update libktx commit hash
walcht 17e8f8d
Fix Ktx_VERSION and unique_ptr ktxTexture2 access
walcht 534be09
Attempt to fix linkage issues with Intel-MacOS CI
walcht 4822d66
Add support for libktx v0.0.0 to target main:HEAD of libktx
walcht 7219ddf
Disable SSE4.2 for Intel-based MacOS CI
walcht a1ed2d3
TMP: disbable simd on Intel-MacOS and disable all other jobs
walcht 61bee60
Remove custom libktx repository for Intel-MacOS
walcht e2b0c10
tmp
walcht f87f443
tmp
walcht 01490b6
tmp
walcht a773a4c
tmp
walcht 4bd07f9
Fix Intel-MacOS libktx linkage issues
walcht 11034c5
Fix libktx CMAKE_ARGS lists
walcht c31baf0
Fix CMAKE_ARGS list
walcht c4134c6
tmp commit to save status
walcht 0644e14
Add ktx input tests and remove libktx v4.3.2 support
walcht a883e53
Replace std::from_char with std::stol/std::stol
walcht b72dc17
fix: add ENABLE_KTX=0 to disable Ktx building and testing on old CIs
walcht 68e223f
Update libktx commit hash and remove libktx 4.3.2 CMake support
walcht 437abab
Fix UASTC/ETC1S Basis Universal attributes
walcht 6ae4462
Replace OIIO_DASSERT* with OIIO_ASSERT
walcht 35dbd42
Remove usage of designated initializers
walcht 44fad0e
Merge remote-tracking branch 'oiio/main'
walcht 0482ab5
Update libktx commit hash
walcht c037288
fixes: hdr support; uastc-hdr-4x4 transcoding; erroneous libktx assert
walcht File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| # Copyright Contributors to the OpenImageIO project. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # https://github.com/AcademySoftwareFoundation/OpenImageIO | ||
|
|
||
| # TODO: revert this before merging! I set this to my own PR branch that includes | ||
| # BCn and that will be merged (as per the reviewer) | ||
| set_cache (Ktx_BUILD_VERSION add-BCn-decoder "Ktx version for local builds") | ||
| set (Ktx_GIT_REPOSITORY "https://github.com/walcht/KTX-Software.git") | ||
| set_cache (Ktx_GIT_TAG "${Ktx_BUILD_VERSION}" "Git branch or tag") | ||
| set_cache (Ktx_GIT_COMMIT "77075ec1d5125df4b938e2f5d96565b10189b1f3" | ||
| "commit hash to verify tag/branch against") | ||
| set_cache (Ktx_BUILD_SHARED_LIBS OFF #${LOCAL_BUILD_SHARED_LIBS_DEFAULT} | ||
| DOC "Should a local Ktx build, if necessary, build shared libraries" ADVANCED) | ||
|
|
||
| # TODO: if libktx is built as a shared library, astcenc have to be linked-against. | ||
| # I don't know how to 'cleanly' do this in OIIO CMake (yet). | ||
| # Even though all CIs pass, do not merge before addressing this! | ||
|
|
||
| string (MAKE_C_IDENTIFIER ${Ktx_BUILD_VERSION} Ktx_VERSION_IDENT) | ||
|
|
||
| # Override C/C++ compiler (useful when running CI with unsupported Intel's compiler ICX) | ||
| set_cache (KTX_CMAKE_C_COMPILER ${CMAKE_C_COMPILER} "libktx build C compiler override" ADVANCED) | ||
| set_cache (KTX_CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER} "libktx build C++ compiler override" ADVANCED) | ||
|
|
||
| # The only tested libktx versions are: | ||
| # - v0.0.0 (main:HEAD which is versionless) | ||
| # - v5.0.0-rc1 (newest supported) | ||
| # | ||
| # for detailed build instructions, see: | ||
| # https://github.com/KhronosGroup/KTX-Software/blob/main/BUILDING.md | ||
| # | ||
| # KTX-Software not only provides Ktx but also a set of CLI tools and load | ||
| # test applications that we do not need. We only need the libktx component | ||
| # without any GPU texture loading functionalities. | ||
| # | ||
| # On x86_64, libktx defaults to using AVX2 for ASTC. For Intel-based MacOS, the | ||
| # default AVX2 requires x86_64h which may not be available (e.g., Intel-based | ||
| # MacOS Github Actions CIs). For ARM64 libktx defaults to using Neon. For | ||
| # 'unknown' CPUs, SIMD is disabled (see KTX-Software/lib/CMakeLists.txt for details). | ||
| # | ||
| # Possible values: | ||
| # - "": default, let libktx decide | ||
| # - ASTCENC_ISA_NATIVE: native SIMD | ||
| # - ASTCENC_ISA_NONE: disable SIMD | ||
| # - ASTCENC_ISA_SVE_256: slowest on Arm | ||
| # - ASTCENC_ISA_SVE_128: 2nd fastest on Arm | ||
| # - ASTCENC_ISA_NEON: fasted on Arm | ||
| # - ASTCENC_ISA_AVX2: fastest on x86_64 (may not be supported on Intel-based MacOS runners) | ||
| # - ASTCENC_ISA_SSE41: 2nd fastest on x86_64 (guaranteed to be supported) | ||
| # - ASTCENC_ISA_SSE2: slowest on x86_64 (guaranteed to be supported) | ||
| # | ||
| set_cache (Ktx_ASTCENC_ISA "" "ASTC specific SIMD instruction set. See astc-encoder/CMakeLists.txt for more details" ADVANCED) | ||
|
|
||
| set(CMAKE_ARGS_LIST | ||
| -DCMAKE_POSITION_INDEPENDENT_CODE=ON | ||
| -DCMAKE_C_COMPILER=${KTX_CMAKE_C_COMPILER} | ||
| -DCMAKE_CXX_COMPILER=${KTX_CMAKE_CXX_COMPILER} | ||
| -DBUILD_SHARED_LIBS=${Ktx_BUILD_SHARED_LIBS} | ||
| -DCMAKE_INSTALL_LIBDIR=lib | ||
| -DLIBKTX_VERSION_READ_ONLY=OFF | ||
| -DLIBKTX_VERSION_FULL=ON | ||
| -DLIBKTX_FEATURE_KTX1=ON # Setting this to OFF causes linker issues | ||
| -DLIBKTX_FEATURE_KTX2=ON | ||
| -DLIBKTX_FEATURE_VK_UPLOAD=OFF | ||
| -DLIBKTX_FEATURE_GL_UPLOAD=OFF | ||
| -DLIBKTX_FEATURE_ETC_UNPACK=OFF # This has some weird licensing and I don't feel comfortable including it ... | ||
| ) | ||
|
|
||
| if(Ktx_ASTCENC_ISA) | ||
| list(APPEND CMAKE_ARGS_LIST -D${Ktx_ASTCENC_ISA}=ON) | ||
| endif() | ||
|
|
||
| build_dependency_with_cmake(Ktx | ||
| VERSION ${Ktx_BUILD_VERSION} | ||
| GIT_REPOSITORY ${Ktx_GIT_REPOSITORY} | ||
| GIT_TAG ${Ktx_GIT_TAG} | ||
| GIT_COMMIT ${Ktx_GIT_COMMIT} | ||
| SOURCE_SUBDIR lib # To only build Ktx, cmake has to point to: KTX-Software/lib | ||
| CMAKE_ARGS ${CMAKE_ARGS_LIST} | ||
| ) | ||
|
|
||
| # Set some things up that we'll need for a subsequent find_package to work | ||
| set (Ktx_ROOT ${Ktx_LOCAL_INSTALL_DIR}) | ||
|
|
||
| # Signal to caller that we need to find again at the installed location | ||
| set (Ktx_REFIND TRUE) | ||
| set (Ktx_REFIND_ARGS CONFIG) | ||
|
|
||
| if (Ktx_BUILD_SHARED_LIBS) | ||
| install_local_dependency_libs (Ktx ktx) # notice libname is lowercase | ||
| endif () |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -337,6 +337,9 @@ macro (oiio_add_all_tests) | |
| oiio_add_tests (dpx | ||
| ENABLEVAR ENABLE_DPX | ||
| IMAGEDIR oiio-images/dpx URL "Recent checkout of OpenImageIO-images") | ||
| oiio_add_tests (ktx | ||
| ENABLEVAR ENABLE_KTX | ||
| IMAGEDIR oiio-images/ktx2) | ||
| oiio_add_tests (dds | ||
| ENABLEVAR ENABLE_DDS | ||
| IMAGEDIR oiio-images/dds URL "Recent checkout of OpenImageIO-images") | ||
|
|
@@ -545,9 +548,10 @@ function (oiio_get_test_data name) | |
| endfunction() | ||
|
|
||
| function (oiio_setup_test_data) | ||
| # TODO: revert this after accepting OpenImageIO-images PR and before merging (just so that the CI passes) | ||
| oiio_get_test_data (oiio-images | ||
| REPO https://github.com/AcademySoftwareFoundation/OpenImageIO-images.git | ||
| BRANCH dev-${OpenImageIO_VERSION_MAJOR}.${OpenImageIO_VERSION_MINOR}) | ||
| REPO https://github.com/walcht/OpenImageIO-images.git | ||
| BRANCH add-ktx2-images) | ||
|
Comment on lines
+553
to
+554
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll want to actually make a PR against OpenImageIO-images that adds the ktx test images, and change this to refer to that. |
||
| oiio_get_test_data (openexr-images | ||
| REPO https://github.com/AcademySoftwareFoundation/openexr-images.git | ||
| BRANCH main) | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a separate PR #5394 that will raise the cmake minimum for OIIO 3.2 to cmake 3.22. So I think you can remove this bit of complexity.