Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
306b578
Add initial BC1 decoder
walcht May 5, 2026
12ab662
Add BC1, BC3, BC4, BC5, and BC7 decoding support to ktx extract command
walcht May 6, 2026
d3fdab2
Add BC1, BC3, BC4, BC5 and BC7 encoders and add encoder/decode tests
walcht May 7, 2026
67facb3
Merge branch 'main' into add-BCn-decoder
walcht May 7, 2026
b036239
Add BCn encoding support for CLI command encode
walcht May 8, 2026
6848b82
Merge branch 'add-BCn-decoder' of github.com:walcht/KTX-Software into…
walcht May 8, 2026
e569fc4
Fix/Suppress bc7enc_rdo warnings and point to forked CTS
walcht May 10, 2026
4a6580d
Fix/Suppress unused variables/functions compilier warnings
walcht May 10, 2026
9d0b0c2
Add BCn encoder support for command create and add additional tests
walcht May 10, 2026
bf153ca
Update CTS submodule commit pointer
walcht May 10, 2026
b2eec1b
Update CTS submodule
walcht May 10, 2026
68bb0de
Temporary pre-integration of bc7enc_rdo as a 'subrepo'
walcht May 10, 2026
7833c75
git subrepo clone --branch=changes_for_ktx https://github.com/Khronos…
walcht May 10, 2026
c04d97f
Add proper bc7enc_rdo 'subrepo' and add bc7enc_rdo to SPX reuse
walcht May 10, 2026
236cc4d
Merge branch 'KhronosGroup:main' into add-BCn-decoder
walcht May 10, 2026
389fa06
Merge branch 'add-BCn-decoder' of github.com:walcht/KTX-Software into…
walcht May 10, 2026
81c2147
Add initial RDO support for BC1, BC3, and BC7 and fix encoder
walcht May 14, 2026
8fcfe86
Remove bc7decomp_ref from external bc7enc_rdo dependency.
walcht May 14, 2026
a5a908e
Merge branch 'KhronosGroup:main' into add-BCn-decoder
walcht May 14, 2026
185e09e
Use bc7f from basis universal instead of bc7enc_rdo's BC7 encoder.
walcht May 14, 2026
a94e536
Fix BC4, BC5 decoder issues; add BC4 RDO; Refactor bcn_codec.h\.cpp
walcht May 14, 2026
39c868c
Add BC4 RDO support
walcht May 15, 2026
109f301
Add BCn encoder multithreading (no RDO MT yet).
walcht May 15, 2026
c258c17
Add RDO multithreading; remove stack-allocated struct poitners from w…
walcht May 18, 2026
be98a77
Add initial BC6HU deconding and encoding support.
walcht May 20, 2026
f45f48c
Fix error message for BC6HU encoder format.
walcht May 20, 2026
b5f5900
Cleanup and refactor code; fix docstrings; add ktxBC1UnpackParams
walcht May 20, 2026
e819fb1
Refactor code; fix BC1 decoding/encoding; remove unsupported formats;…
walcht May 23, 2026
208c52e
Remove bc7enc_rdo bc7decomp dependency and use Basisu's BC7 decoder
walcht May 23, 2026
d32bc78
Remove BC6HU/BC6HS decoders dependency and use Basisu's decoders instead
walcht May 23, 2026
2874b44
Restructure bc7enc dependency; fix unused variable warnings; add BC2 …
walcht May 25, 2026
ee5c511
Fix ktxBCnParams initialization in testsuite; Add bc6hu test case
walcht May 25, 2026
fc7ce9c
Add proper BCn arguments handling/docs for ktx create/encode
walcht May 26, 2026
0a7be33
Add RDO ultrasmooth block handling; add BC2 decoder to ktx extract
walcht May 27, 2026
192a4cf
Fix BC1 encoder; Fix encoding of non-multiple-of-4 textures; Refactor…
walcht Jun 3, 2026
a526369
Add HDR cleanup for BC6HU encoder
walcht Jun 8, 2026
8a95806
Update CTS tests
walcht Jun 8, 2026
b1b862f
Revert CTS tests submodule commit
walcht Jun 8, 2026
f66cd21
Merge branch 'main' into add-BCn-decoder
walcht Jun 8, 2026
d5bc0d9
Replace inconsistent use of size_t with uint32_t
walcht Jun 9, 2026
f7b3853
Fix Windows-related build issues
walcht Jun 10, 2026
bc7495a
Revert erroneous int to uint32_t conversion
walcht Jun 10, 2026
31c5147
Fix BC1 RDO
walcht Jun 10, 2026
5cd60a5
Update CTS submodule commit pointer
walcht Jun 10, 2026
5224758
Fix warning C4201 on Windows platforms
walcht Jun 11, 2026
a23c016
Revert "Fix warning C4201 on Windows platforms"
walcht Jun 12, 2026
4124521
Suppress warning C4201 on Windows platforms
walcht Jun 12, 2026
9f74a0c
Remove xcpretty installation from MacOS CI
walcht Jun 12, 2026
a6799e9
Merge branch 'KhronosGroup:main' into add-BCn-decoder
walcht Jun 13, 2026
2ed1708
Remove xcpretty and use "xcodebuild --quiet" instead
walcht Jun 13, 2026
b231714
Merge branch 'KhronosGroup:main' into add-BCn-decoder
walcht Jun 13, 2026
7e22b39
Suppress deprecated warnings on Windows platforms
walcht Jun 13, 2026
71d7efb
Add explicit uint64_t to uint32_t casts
walcht Jun 13, 2026
5f58b7a
Update CTS submodule commit pointer
walcht Jun 13, 2026
0903730
Fix types and update docstrings/cli docs
walcht Jun 13, 2026
18f8451
Update CTS submodule commit pointer
walcht Jun 13, 2026
57073f2
Update CTS submodule commit pointer
walcht Jun 14, 2026
f05f76f
Fix erroneous array access in RDO ultrasmooth blocks handling
walcht Jun 14, 2026
93a7f34
Disable strict aliasing for bc7enc_rdo dependency
walcht Jun 16, 2026
ec4344c
Merge branch 'KhronosGroup:main' into add-BCn-decoder
walcht Jun 16, 2026
8b18835
Add CI step to upload CTS output files if CTS fails
walcht Jun 16, 2026
4e0d183
Record BCn options in ktx encode
walcht Jun 16, 2026
905b224
Address strict aliasing violations that cause UBs
walcht Jun 16, 2026
fd08dcd
Fix BC3 RDO decoder; Disable strict aliasing
walcht Jun 16, 2026
1e600f7
Add BCn create RDO tests
walcht Jun 16, 2026
a5b8e8f
Fix ktx encode BCn threadcount option
walcht Jun 16, 2026
2a7a7bf
Increase tolerance for BCn encode-then-decode tests
walcht Jun 16, 2026
29537d8
Fix BC1 texturetests
walcht Jun 17, 2026
528fcee
Record missing options; Add ktx encode BCn documentation
walcht Jun 18, 2026
9f49a9a
Add strict aliasing compilation note
walcht Jun 18, 2026
69746fd
Fix RDO MT non determinism; Add extensive tests
walcht Jun 18, 2026
03c12e5
Merge branch 'main' into add-BCn-decoder
walcht Jun 18, 2026
d73a216
Address reviews; Fix typos; Misc cleanup/refactoring
walcht Jun 19, 2026
48c731c
Remove useless floor call
walcht Jun 19, 2026
132e275
Add missing KTX_DECOMPRESS_FAILURE error string
walcht Jun 19, 2026
ffb7719
Only add -fno-strict-aliasing to non-MSVC compilers
walcht Jun 19, 2026
0e15009
Clarify insert/extract block diagrams
walcht Jun 20, 2026
db54360
Fix upload CTS files on failure build steps
walcht Jun 21, 2026
4e93ee3
Handle pending data load in BCn decoder
walcht Jun 21, 2026
36f075a
Copy typeSize member in BCn decoder
walcht Jun 22, 2026
88e8a18
Add '--skip-kvd' to ktxdiff
walcht Jun 22, 2026
6103227
Convert BCn PNG UNORM input to linear colorspace
walcht Jun 22, 2026
dc1590e
Add ktxdiff to texturetests' BCn decode tests
walcht Jun 22, 2026
7f568f3
Add '--normal-mode' to BC5 differential test file generation
walcht Jun 23, 2026
ce1e147
Add '--bcn-rdo-m' option to disable RDO multithreading
walcht Jun 23, 2026
ad74524
Update CTS submodule commit pointer
walcht Jun 23, 2026
e152314
Merge branch 'main' into add-BCn-decoder
walcht Jun 23, 2026
c563c84
Address misc review comments
walcht Jul 4, 2026
2476fb6
Fix syntax error in texturetests and update CTS
walcht Jul 4, 2026
41ea660
Merge branch 'main' into add-BCn-decoder
walcht Jul 4, 2026
3cb6540
Update CTS submodule commit
walcht Jul 4, 2026
a4035f2
Add missing <algorithm> include
walcht Jul 4, 2026
2b41ff9
Fix texturetests issues on Windows
walcht Jul 4, 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
10 changes: 10 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,21 @@ jobs:
-Source "${{ env.NUGET_FEED_URL }}"

- name: script
id: buildstep
env:
VCPKG_BINARY_SOURCES: clear;nuget,${{ env.NUGET_FEED_URL }},readwrite
run: |
./scripts/build_linux.sh

# Currently this runs if build_linux fails for any reason whatsoever (because detecting
# that the CTS tests have failed requires some changes to build_linux)
# - name: Upload generated CTS output files if CTS tests fail
# if: failure() && matrix.options.tools_cts == 'ON' && steps.buildstep.outcome == 'failure'
# uses: actions/upload-artifact@v7
# with:
# name: cts_failure_artifacts_${{ github.sha }}
# path: tests/cts/clitests/output

- name: Sanitize release notes
if: matrix.options.package == 'YES' && github.event_name == 'push' && github.ref_type == 'tag'
run: |
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ jobs:
scripts/smudge_date.sh

- name: script
id: buildstep
env:
VCPKG_BINARY_SOURCES: clear;nuget,${{ env.NUGET_FEED_URL }},readwrite
run: |
Expand All @@ -284,6 +285,15 @@ jobs:
fi
set +e

# Currently this runs if build_macos fails for any reason whatsoever (because detecting
# that the CTS tests have failed requires some changes to build_macos)
# - name: Upload generated CTS output files if CTS tests fail
# if: failure() && matrix.options.tools_cts == 'ON' && steps.buildstep.outcome == 'failure'
Comment thread
walcht marked this conversation as resolved.
# uses: actions/upload-artifact@v7
# with:
# name: cts_failure_artifacts_${{ github.sha }}
# path: tests/cts/clitests/output

# Re. packaging, note that the build script only creates packages for
# the Release configuration. If this is changed work will be needed
# here to prevent failures from uploading same-named artifacts from both
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/mingw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,15 @@ jobs:
- name: Build Mingw x64 Release
run: cmake --build build --config Release
- name: Test Mingw build
id: teststep
run: ctest --output-on-failure --test-dir build -C Release
# - name: Upload generated CTS output files if CTS tests fail
# if: failure() && matrix.options.tools_cts == 'ON' && steps.teststep.outcome == 'failure'
# uses: actions/upload-artifact@v7
# with:
# name: cts_failure_artifacts_${{ github.sha }}
# path: tests/cts/clitests/output

# - name: Upload test log
# shell: pwsh
# if: ${{ failure() }}
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,18 @@ jobs:
run: scripts/check_mkvk.ps1

- name: Test Windows build
id: teststep
# Tests built for arm64 can't be run as the CI runners are all x64.
if: matrix.options.tests == 'ON'
run: ctest --output-on-failure --test-dir $env:BUILD_DIR -C Release

# - name: Upload generated CTS output files if CTS tests fail
# if: failure() && matrix.options.tools_cts == 'ON' && steps.teststep.outcome == 'failure'
# uses: actions/upload-artifact@v7
# with:
# name: cts_failure_artifacts_${{ github.sha }}
# path: tests/cts/clitests/output

# - name: Upload test log
# if: ${{ failure() }}
# run: scripts/on_failure.ps1
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ the_khronos_group_inc.p12

# Place for random developer test files.
/testground/

# clangd compile commands (used by LSPs)
Comment thread
walcht marked this conversation as resolved.
compile_commands.json
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

[submodule "tests/cts"]
path = tests/cts
url = https://github.com/KhronosGroup/KTX-Software-CTS.git
url = https://github.com/walcht/KTX-Software-CTS.git
branch = main
6 changes: 6 additions & 0 deletions REUSE.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ precedence = "aggregate"
SPDX-FileCopyrightText = "Copyright (c) 2004, Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd."
SPDX-License-Identifier = "BSD-3-Clause"

[[annotations]]
path = "tests/resources/input/exr/rgb16_sfloat_bc6hu.exr"
precedence = "aggregate"
SPDX-FileCopyrightText = "2026 The Khronos Group Inc."
SPDX-License-Identifier = "Apache-2.0"

[[annotations]]
path = "tests/resources/ktx2/Desk_uastc_hdr4x4_zstd_15.ktx2"
precedence = "aggregate"
Expand Down
22 changes: 22 additions & 0 deletions external/bc7enc_rdo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2019-2020 The Khronos Group Inc.
# SPDX-License-Identifier: Apache-2.0

add_library(bc7enc_rdo)
target_compile_features(bc7enc_rdo PUBLIC cxx_std_17)

# original bc7enc_rdo disables strict aliasing (see https://github.com/richgel999/bc7enc_rdo/blob/master/CMakeLists.txt)
# basisu also emphasises on compiling with '-fno-strict-aliasing'
if (NOT MSVC)
target_compile_options(bc7enc_rdo PRIVATE -fno-strict-aliasing)
endif()

target_sources(bc7enc_rdo
PRIVATE
${CMAKE_CURRENT_LIST_DIR}/rgbcx.cpp # BC1, BC3, BC4 and BC5 encoders/decoders
${CMAKE_CURRENT_LIST_DIR}/ert.cpp # RDO post processing step and some utils
)

target_include_directories(bc7enc_rdo
PUBLIC
${CMAKE_CURRENT_LIST_DIR}/
)
19 changes: 19 additions & 0 deletions external/bc7enc_rdo/LICENSES/MIT.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
MIT License Copyright (c) <year> <copyright holders>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
88 changes: 88 additions & 0 deletions external/bc7enc_rdo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# About

This branch of bc7enc_rdo forked from [bc7enc_rdo][bc7enc_rdo] contains two
components used by KTX-Software with some changes:

- rgbcx: BC1, BC3, BC4, and BC5 encoders/decoders (+ added BC2 decoder).
- ert: rate distortion optimization (RDO) (agnostic to encoders/decoders).

Changes:

- added [[maybe_unused]] to silence compiler warnings about unused variables

Essentially: only what is absolutely necessary and not already provided by Basis
Universal is left. The following components have been removed:

- bc7 encoder/decoder. See [Notes][#Notes] below.
- CLI components.
- utils.h/cpp because it relies on some heavy classes.

Currently, the remaining two components are compiled together under a single
STATIC library bc7enc_rdo (if the need arises where only the RDO component is needed,
this will be separated into multiple libraries).

## Building

This is intended to be built as a static library dependency (see minimal
CMakeLists.txt).

Somewhere in your project's CMakeLists:

```bash
# Make sure bc7enc_rdo is built as a STATIC library
set(BUILD_SHARED_LIBS OFF)
add_subdirectory(path-to-bc7enc_rdo)
set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_RESET})

# Then append it to your target's link dependencies
target_link_libraries(your_target PRIVATE bc7enc_rdo)
```

## Notes

BC2 encoder is currently not implemented because practically it is very rarely
used (if at all) and can almost always be replaced with the more capable BC3
format (which offers same color RGB block encoding as BC1 but with added alpha
support that is usually better than the one implemented by BC2).

BC6HU/BC6HS HDR formats are already originally not supported by this repo.
Basis Universal provides bc6hu (emphasis on the **u**) encoder and bc6hu/bc6hs decoders.

BC7 encoder/decoder is not included because Basis Universal already provides a
much more capable encoder (bc7f).

Notes about choice with BC1 vs. BC3 vs. BC7 (from Basisu wiki):

> bc7f encodes so rapidly (on average), that apart from lower VRAM consumption
> (4bpp vs. 8bpp) and better GPU texture cache efficiency, there's little need
> to use BC1 now. BC3 still has an advantage vs. BC7, because it very strongly
> separates how RGB is encoded from the alpha channel, in a predictable way.

## Compilation Notes

**Makes sure to compile with `-fno-strict-aliasing`** since the original
bc7enc_rdo repo was mainly developed and tested on MSVC (which doesn't do
excessive optimizations including strict aliasing).

There are pointer conversions all over the place and if strict aliasing is
enabled, these conversions are most likely UB (see strict aliasing rule or type
punning).

This can be re-written a way that complies with strict aliasing but a lot of
`memcpy`s have to be added which will result in the code being significantly
less readable (also questionable if there is any benefit to this whatsoever).

## TODOs

There are some features that I'd like to add (from most important to least):

1. [] HDR RDO (this is possible but need to be extremely careful when changing
ert.cpp/h code to handle uint16_t instead of chars/uint8_t)
1. [] BC2 encoder (even though it is seldom used)
1. [] BC6HS encoder

## License

MIT License Rich Geldreich.

[bc7enc_rdo]: https://github.com/richgel999/bc7enc_rdo.git)
9 changes: 9 additions & 0 deletions external/bc7enc_rdo/REUSE.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version = 1
SPDX-PackageName = "bc7enc_rdo"
SPDX-PackageDownloadLocation = "https://github.com/richgel999/bc7enc_rdo"

[[annotations]]
path = "**"
precedence = "aggregate"
SPDX-FileCopyrightText = "2020-2021 Richard Geldreich, Jr. <richgel99@gmail.com>"
SPDX-License-Identifier = "MIT"
Loading
Loading