Skip to content
Open
Show file tree
Hide file tree
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 May 5, 2026
289bc14
Remove BCn and ETC encoders/decoders dependencies
walcht Jun 22, 2026
5f707f5
Merge branch 'main' into main
walcht Jun 22, 2026
dd28a48
Only build or find libktx on MSVC, Clang, or GCC
walcht Jun 22, 2026
b5e85b6
Merge branch 'main' of github.com:walcht/OpenImageIO
walcht Jun 22, 2026
3453812
Add to-native-data-format conversion
walcht Jun 29, 2026
1e60868
Override C/C++ compiler for KTX; revert CMAKE_VERSION in CI; misc ref…
walcht Jul 4, 2026
bef354e
Remove <vkformat_enum> include
walcht Jul 4, 2026
ae63741
Add alpha and ioproxy support to ktxinput/ktxoutput
walcht Jul 5, 2026
8b68531
Fix mismatching deallocation
walcht Jul 5, 2026
f1c19a9
CI: lower libktx version for 'oldest' CI runners
walcht Jul 5, 2026
7593501
Add Ktx_VERSION and use it in ktxinput
walcht Jul 5, 2026
e7c1fe3
Fix buffer cleanup using unique_ptr
walcht Jul 5, 2026
415b36d
Replace Ktx_GIT_TAG with Ktx_BUILD_VERSION
walcht Jul 5, 2026
29d45c6
Fix Intel-based MacOS libktx build issues
walcht Jul 5, 2026
a133b1f
Use set_cache() instead of set() to expose vars to CI runners
walcht Jul 5, 2026
05e3dde
Add description to set_cache()
walcht Jul 5, 2026
a7f95f6
Add support for older ktx build (v4.3.2)
walcht Jul 8, 2026
403f7f3
Add support for libktx 4.3.2
walcht Jul 8, 2026
f07af6e
Fix libktx 4.3.2 support
walcht Jul 8, 2026
9c918fc
Update libktx commit hash
walcht Jul 9, 2026
17e8f8d
Fix Ktx_VERSION and unique_ptr ktxTexture2 access
walcht Jul 9, 2026
534be09
Attempt to fix linkage issues with Intel-MacOS CI
walcht Jul 9, 2026
4822d66
Add support for libktx v0.0.0 to target main:HEAD of libktx
walcht Jul 9, 2026
7219ddf
Disable SSE4.2 for Intel-based MacOS CI
walcht Jul 10, 2026
a1ed2d3
TMP: disbable simd on Intel-MacOS and disable all other jobs
walcht Jul 10, 2026
61bee60
Remove custom libktx repository for Intel-MacOS
walcht Jul 10, 2026
e2b0c10
tmp
walcht Jul 10, 2026
f87f443
tmp
walcht Jul 10, 2026
01490b6
tmp
walcht Jul 10, 2026
a773a4c
tmp
walcht Jul 10, 2026
4bd07f9
Fix Intel-MacOS libktx linkage issues
walcht Jul 11, 2026
11034c5
Fix libktx CMAKE_ARGS lists
walcht Jul 11, 2026
c31baf0
Fix CMAKE_ARGS list
walcht Jul 11, 2026
c4134c6
tmp commit to save status
walcht Jul 17, 2026
0644e14
Add ktx input tests and remove libktx v4.3.2 support
walcht Jul 18, 2026
a883e53
Replace std::from_char with std::stol/std::stol
walcht Jul 18, 2026
b72dc17
fix: add ENABLE_KTX=0 to disable Ktx building and testing on old CIs
walcht Jul 18, 2026
68e223f
Update libktx commit hash and remove libktx 4.3.2 CMake support
walcht Jul 18, 2026
437abab
Fix UASTC/ETC1S Basis Universal attributes
walcht Jul 22, 2026
6ae4462
Replace OIIO_DASSERT* with OIIO_ASSERT
walcht Jul 22, 2026
35dbd42
Remove usage of designated initializers
walcht Jul 22, 2026
44fad0e
Merge remote-tracking branch 'oiio/main'
walcht Jul 22, 2026
0482ab5
Update libktx commit hash
walcht Jul 22, 2026
c037288
fixes: hdr support; uastc-hdr-4x4 transcoding; erroneous libktx assert
walcht Jul 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ jobs:
UHDR_CMAKE_CXX_COMPILER=g++
openjph_CMAKE_C_COMPILER=gcc
openjph_CMAKE_CXX_COMPILER=g++
# Building libuhdr with icx results in test failures
KTX_CMAKE_C_COMPILER=gcc
KTX_CMAKE_CXX_COMPILER=g++
# Building libuhdr and libktx with icx results in test failures
optional_deps_append: "LibRaw;Ptex;Qt6"
- desc: VFX2026 gcc14/C++20 py3.13 exr3.4 ocio2.5
nametag: linux-vfx2026
Expand Down Expand Up @@ -493,8 +495,10 @@ jobs:
Robinmap_GIT_COMMIT=68ff7325b3898fca267a103bad5c509e8861144d
TIFF_BUILD_VERSION=4.0.0
TIFF_GIT_COMMIT=f7b79dc7dc86ccbaabe9882e2b9ffa5ee8dac917
ENABLE_KTX=0
# OpenJPEG_BUILD_VERSION=2.2.0
# OpenJPEG_GIT_COMMIT=3d7cde5fc9fbc5618d02160900d32e02ed12a00e
# libktx > 4.3.2 requires CMake >= 3.22
optional_deps_append: 'FFmpeg;LibRaw;Ptex;Qt6'
build_local_deps: 'TIFF'
- desc: oldest clang11/C++17 py3.9 exr3.1 ocio2.3
Expand Down Expand Up @@ -525,8 +529,10 @@ jobs:
TIFF_GIT_COMMIT=f7b79dc7dc86ccbaabe9882e2b9ffa5ee8dac917
openjph_CMAKE_C_COMPILER=gcc
openjph_CMAKE_CXX_COMPILER=g++
ENABLE_KTX=0
# OpenJPEG_BUILD_VERSION=2.2.0
# OpenJPEG_GIT_COMMIT=3d7cde5fc9fbc5618d02160900d32e02ed12a00e
# libktx > 4.3.2 requires CMake >= 3.22
optional_deps_append: 'FFmpeg;LibRaw;Ptex;Qt6'
build_local_deps: 'TIFF'

Expand Down Expand Up @@ -564,6 +570,8 @@ jobs:
Robinmap_GIT_COMMIT=68ff7325b3898fca267a103bad5c509e8861144d
TIFF_BUILD_VERSION=4.0.0
TIFF_GIT_COMMIT=f7b79dc7dc86ccbaabe9882e2b9ffa5ee8dac917
ENABLE_KTX=0
# libktx > 4.3.2 requires CMake >= 3.22
required_deps: none
build_local_deps: 'TIFF'

Expand Down Expand Up @@ -625,6 +633,9 @@ jobs:
ctest_test_timeout: 1200
setenvs: export MACOSX_DEPLOYMENT_TARGET=12.0
INSTALL_QT=0 INSTALL_OPENCV=0 INSTALL_OPENVDB=0
Ktx_ASTCENC_ISA=ASTCENC_ISA_SSE41
# Intel-based MacOS runners don't support AVX2 SIMD which is the
# default set by libktx. Explicitly set to SSE4.1 (2nd fastest after AVX2)
optional_deps_append: 'OpenCV;OpenVDB;Qt5;Qt6'
benchmark: 1
- desc: MacOS-14-ARM aclang15/C++20/py3.13
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ gastest.o
/*.jxl
/*.tx
/*.log
/*.ktx2

# AI coding tool directories — generated locally by .agents/setup-agent
.claude/
Expand Down
91 changes: 91 additions & 0 deletions src/cmake/build_Ktx.cmake
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 ()
14 changes: 14 additions & 0 deletions src/cmake/externalpackages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,20 @@ else ()
get_target_property(FMT_INCLUDE_DIR fmt::fmt-header-only INTERFACE_INCLUDE_DIRECTORIES)
endif ()

# Note for Ktx plugin developers:
# set VERSION_MIN to 0.0.0 if you have a locally-built tracking HEAD:main of
# KTX-Software because building non-tagged libktx sets the version to 0.0.0.
#
# libktx 5.0.0 requires CMake >= 3.22. libktx v4.3.2 supports CMake v3.18 which
# is used in "oldest gcc" CIs but supporting two versions of libktx is very
# cumbersome.
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.22")
checked_find_package (Ktx
# VERSION_MIN 5.0.0
VERSION_MIN 0.0.0 # If you target main branch of KTX-Software (versionless)
BUILD_LOCAL missing
)
endif()

###########################################################################

Expand Down
8 changes: 6 additions & 2 deletions src/cmake/testing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
oiio_get_test_data (openexr-images
REPO https://github.com/AcademySoftwareFoundation/openexr-images.git
BRANCH main)
Expand Down
Loading