From ca215a531544b53b069dfc33019dbea9976395bd Mon Sep 17 00:00:00 2001 From: Mark Callow Date: Mon, 17 Nov 2025 16:14:37 +0900 Subject: [PATCH 01/19] Fix licensing info so `reuse link` passes; ignore some files. Convert license info from deprecated .reuse/dep5 to REUSE.toml. Ignore CMakeUserPresets.json, build files in build and output binaries in bin. --- .gitignore | 3 +- .reuse/dep5 | 30 -------------- .../{BSD-3-clause.txt => BSD-3-Clause.txt} | 0 LICENSES/Zlib.txt | 20 ---------- REUSE.toml | 39 +++++++++++++++++++ bin/.gitignore | 7 ++++ build/.gitignore | 5 +++ 7 files changed, 53 insertions(+), 51 deletions(-) delete mode 100644 .reuse/dep5 rename LICENSES/{BSD-3-clause.txt => BSD-3-Clause.txt} (100%) delete mode 100644 LICENSES/Zlib.txt create mode 100644 REUSE.toml create mode 100644 bin/.gitignore create mode 100644 build/.gitignore diff --git a/.gitignore b/.gitignore index 93524df8..82608382 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -build/ + +CMakeUserPresets.json # VS project and working files *.vcxproj.user diff --git a/.reuse/dep5 b/.reuse/dep5 deleted file mode 100644 index cdba7ccf..00000000 --- a/.reuse/dep5 +++ /dev/null @@ -1,30 +0,0 @@ -Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: basis_universal -Source: https://github.com/BinomialLLC/basis_universal - -# We have asked Binomial about REUSE compliance for their repo, see https://github.com/BinomialLLC/basis_universal/issues/165 -Files: * -Copyright: 2019-2024 Binomial LLC - 2016 The Android Open Source Project -License: Apache-2.0 - -Files: OpenCL/* -Copyright: 2008-2020 The Khronos Group Inc. -License: Apache-2.0 - -Files: zstd/* -Copyright: 2016-present Facebook, Inc. -License: BSD-3-Clause - -Files: encoder/3rdparty/tinyexr.h -Copyright: 2014 - 2021, Syoyo Fujita and many contributors. - 2002 Industrial Light & Magic, a division of Lucas -License: BSD-3-Clause - -Files: encoder/3rdparty/qoi.h -Copyright: 2021 Dominic Szablewski - https://phoboslab.org -License: MIT - -Files: encoder/3rdparty/tinydds.h -Copyright: 2019 DeanoC -License: MIT diff --git a/LICENSES/BSD-3-clause.txt b/LICENSES/BSD-3-Clause.txt similarity index 100% rename from LICENSES/BSD-3-clause.txt rename to LICENSES/BSD-3-Clause.txt diff --git a/LICENSES/Zlib.txt b/LICENSES/Zlib.txt deleted file mode 100644 index 508a9b5b..00000000 --- a/LICENSES/Zlib.txt +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. diff --git a/REUSE.toml b/REUSE.toml new file mode 100644 index 00000000..a63c36ac --- /dev/null +++ b/REUSE.toml @@ -0,0 +1,39 @@ +version = 1 +SPDX-PackageName = "basis_universal" +SPDX-PackageDownloadLocation = "https://github.com/BinomialLLC/basis_universal" + +[[annotations]] +path = "**" +precedence = "aggregate" +SPDX-FileCopyrightText = ["2019-2024 Binomial LLC", "2016 The Android Open Source Project"] +SPDX-License-Identifier = "Apache-2.0" + +[[annotations]] +path = "OpenCL/**" +precedence = "aggregate" +SPDX-FileCopyrightText = "2008-2020 The Khronos Group Inc." +SPDX-License-Identifier = "Apache-2.0" + +[[annotations]] +path = "zstd/**" +precedence = "aggregate" +SPDX-FileCopyrightText = "2016-present Facebook, Inc." +SPDX-License-Identifier = "BSD-3-Clause" + +[[annotations]] +path = "encoder/3rdparty/tinyexr.h" +precedence = "aggregate" +SPDX-FileCopyrightText = ["2014 - 2021, Syoyo Fujita and many contributors.", "2002 Industrial Light & Magic, a division of Lucas"] +SPDX-License-Identifier = "BSD-3-Clause" + +[[annotations]] +path = "encoder/3rdparty/qoi.h" +precedence = "aggregate" +SPDX-FileCopyrightText = "2021 Dominic Szablewski - https://phoboslab.org" +SPDX-License-Identifier = "MIT" + +[[annotations]] +path = "encoder/3rdparty/tinydds.h" +precedence = "aggregate" +SPDX-FileCopyrightText = "2019 DeanoC" +SPDX-License-Identifier = "MIT" diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 00000000..ecb3b59e --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1,7 @@ + +* + +!.gitignore +!ocl_kernels.cl +!clean.bat +!readme.txt diff --git a/build/.gitignore b/build/.gitignore new file mode 100644 index 00000000..3467e412 --- /dev/null +++ b/build/.gitignore @@ -0,0 +1,5 @@ + +* + +!.gitignore +!readme.txt From 4705a19af1521a79c9d5606d9d1cc32cd397076e Mon Sep 17 00:00:00 2001 From: Mark Callow Date: Mon, 17 Nov 2025 19:49:14 +0900 Subject: [PATCH 02/19] Make CMakeProject usable as a subprojct and other fixes. * Make it usable as a subproject: - Don't use CMAKE_ global variables for compiler options. - Prefix config options with BASISU_ to avoid polluting the namespace. - Expose libbasisu_encoder's dependencies and link options in its target interface so they are automatically exported to _any_ application that links with it. * Enhancements - Support building on Android and minGW by handling potential absence of libpthread. - Support building with CLangCL. - Support building on Windows with non-MSVC-front-end compiler so CMake MSVC variable is not set. - Set CMAKE_OSX_DEPLOYMENT_TARGET so program built with latest Xcode SDK will run on build machine with pre-SDK version of macOS. * Bug Fixes - Make work with any multi-config CMake generator, not just Visual Studio. - Only set c++ compile options when compiling c++ files. - The `STATIC` option, renamed `BASISU_STATIC`, is now set to TRUE by default because the library is always built as a static library. `STATIC` is a keyword for the `add_library` command so the `STATIC` option was ignored there. (The BASISU_ prefix now makes it clear they are different.) Hence the previous default option of FALSE was incorrect. - The libraries added when `STATIC` is TRUE are only needed for MinGW and are now only added for MinGW. - The rpath setting done when `STATIC` is FALSE is pointless with a static library but was happening due to the incorrect value of `STATIC`. - .gitignore files have been added to ignore build files and binaries in `build` and `bin`, but to not ignore the handful of files in there that are tracked by git. * Bugs found but not fixed - BASISU_SSE is set `if (MSVC)` so it is incorrectly set on Windows ARM and not set in many other cases where it probably should be. - Building a dynamic library never happens so `BASISU_STATIC` is pointless. --- CMakeLists.txt | 308 ++++++++++++++++++++++--------------------------- 1 file changed, 136 insertions(+), 172 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f65dd53..d3574118 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,40 +2,60 @@ # It should also work without this option, but we do not test with it. cmake_minimum_required(VERSION 3.20) +if (NOT CMAKE_OSX_DEPLOYMENT_TARGET) + # Needed otherwise Xcode builds with the default installed SDK which can often be + # more recent than the macOS version being used. + set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0" CACHE STRING "macOS Deployment Target") +endif() + project(basisu C CXX) -set(CMAKE_CXX_STANDARD 17) -option(STATIC "static linking" FALSE) -option(SAN "sanitize" FALSE) -option(EXAMPLES "build examples" TRUE) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) +option(BASISU_TOOL "Include basisu tool in build" TRUE) +option(BASISU_EXAMPLES "Include examples in build" TRUE) + +option(BASISU_STATIC "static linking" TRUE) +option(BASISU_SAN "sanitize" FALSE) + +# Using a generator expression here prevents multi-config generators (VS, Xcode, Ninja Multi-Config) +# from appending a per-configuration subdirectory. NOTE: This means the output could be overwritten +# by a subsequent build for a different configuration. +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_SOURCE_DIR}/bin>) # For MSVC builds default to SSE enabled, and determine if it's a 64-bit (-A x64) vs. 32-bit (-A Win32) build. if (MSVC) - option(SSE "SSE 4.1 support" TRUE) - if ( CMAKE_GENERATOR_PLATFORM STREQUAL Win32 ) - set(BUILD_X64 0) + # TODO: Fix me for Windows ARM + option(BASISU_SSE "SSE 4.1 support" TRUE) + if ( CMAKE_GENERATOR_PLATFORM STREQUAL Win32 ) + set(BASISU_BUILD_X64 0) else() - set(BUILD_X64 1) + set(BASISU_BUILD_X64 1) endif() - add_compile_options(/W4) + add_compile_options(/W4) else() - option(SSE "SSE 4.1 support" FALSE) - option(BUILD_X64 "build 64-bit" TRUE) + option(BASISU_SSE "SSE 4.1 support" FALSE) + option(BASISU_BUILD_X64 "build 64-bit" TRUE) endif() -option(ZSTD "ZSTD support for KTX2 transcoding/encoding" TRUE) -option(OPENCL "OpenCL support in encoder" FALSE) +option(BASISU_ZSTD "ZSTD support for KTX2 transcoding/encoding" TRUE) +option(BASISU_OPENCL "OpenCL support in encoder" FALSE) -message("Initial BUILD_X64=${BUILD_X64}") +message("Initial BASISU_BUILD_X64=${BASISU_BUILD_X64}") message("Initial CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}") -message("Initial SSE=${SSE}") -message("Initial ZSTD=${ZSTD}") -message("Initial OPENCL=${OPENCL}") -message("Initial SAN=${SAN}") -message("Initial EXAMPLES=${EXAMPLES}") +message("Initial BASISU_SSE=${BASISU_SSE}") +message("Initial BASISU_ZSTD=${BASISU_ZSTD}") +message("Initial BASISU_OPENCL=${BASISU_OPENCL}") +message("Initial BASISU_SAN=${BASISU_SAN}") +message("initial BASISU_TOOL=${BASISU_TOOL}") +message("initial BASISU_EXAMPLES=${BASISU_EXAMPLES}") + +if(WIN32 AND MINGW) + # Check if the Threads package is provided; if using Mingw it MIGHT be + find_package(Threads) +elseif(LINUX) + find_package(Threads REQUIRED) +endif() -if ((NOT MSVC) AND OPENCL) +if ((NOT MSVC) AND BASISU_OPENCL) # With MSVC builds we use the Khronos lib/include files in the project's "OpenCL" directory, to completely avoid requiring fiddly to install vendor SDK's. # Otherwise we use the system's (if any). find_package(OpenCL) @@ -50,92 +70,57 @@ endif() message(${PROJECT_NAME} " build type: " ${CMAKE_BUILD_TYPE}) -if (BUILD_X64) +if (BASISU_BUILD_X64) message("Building 64-bit") else() message("Building 32-bit") endif() -if (SSE) +if (BASISU_SSE) message("SSE enabled") else() message("SSE disabled") endif() -if (ZSTD) +if (BASISU_ZSTD) message("Zstandard enabled") else() message("Zstandard disabled") endif() if (NOT MSVC) - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g") - set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g") - - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") - set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") - - if (SAN) - message("Enabling SAN") - - set(SANITIZE_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize=alignment") - - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${SANITIZE_FLAGS}") - set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${SANITIZE_FLAGS}") - - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${SANITIZE_FLAGS}") - set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${SANITIZE_FLAGS}") - endif() + add_compile_options(-g) + + if (BASISU_SAN) + message("Enabling SAN") - set(CMAKE_CXX_FLAGS -std=c++17) - set(GCC_COMPILE_FLAGS "-fvisibility=hidden -fPIC -fno-strict-aliasing -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 -Wall -Wextra -Wno-unused-local-typedefs -Wno-unused-value -Wno-unused-parameter -Wno-unused-variable -Wno-reorder -Wno-misleading-indentation -Wno-class-memaccess -Wno-deprecated-copy -Wno-maybe-uninitialized -Wno-unused-function -Wno-stringop-overflow -Wno-unknown-warning-option") - - if (NOT BUILD_X64) - set(GCC_COMPILE_FLAGS "${GCC_COMPILE_FLAGS} -m32") + add_compile_options(-fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize=alignment) endif() - if (EMSCRIPTEN) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -DBASISU_SUPPORT_SSE=0") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -DBASISU_SUPPORT_SSE=0") - - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_LINK_FLAGS}") - elseif (STATIC) - if (SSE) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBASISU_SUPPORT_SSE=1 -msse4.1") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBASISU_SUPPORT_SSE=1 -msse4.1") - else() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBASISU_SUPPORT_SSE=0") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBASISU_SUPPORT_SSE=0") - endif() - - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_LINK_FLAGS} -static-libgcc -static-libstdc++ -static") - else() - if (SSE) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBASISU_SUPPORT_SSE=1 -msse4.1") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBASISU_SUPPORT_SSE=1 -msse4.1") - else() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBASISU_SUPPORT_SSE=0") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBASISU_SUPPORT_SSE=0") - endif() - - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_LINK_FLAGS} -Wl,-rpath .") + # Add common non-MSVC flags excluding -fPIC. + add_compile_options(-fvisibility=hidden -fPIC -fno-strict-aliasing -D_LARGEFILE64_SOURCE=1 + -D_FILE_OFFSET_BITS=64 -Wall -Wextra -Wno-unused-local-typedefs + -Wno-unused-value -Wno-unused-parameter -Wno-unused-variable + -Wno-misleading-indentation + -Wno-maybe-uninitialized -Wno-unused-function + -Wno-stringop-overflow -Wno-unknown-warning-option) + # Add -fPIC ONLY on non-Windows platforms + if (NOT WIN32) + add_compile_options(-fPIC) endif() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GCC_COMPILE_FLAGS}") - set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${GCC_COMPILE_FLAGS}") - set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${GCC_COMPILE_FLAGS} -D_DEBUG") + # AppleClang 14 raises this warning in zstd.cpp. + add_compile_options("$<$,$,17>>:-Wno-bitwise-instead-of-logical>") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COMPILE_FLAGS}") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${GCC_COMPILE_FLAGS}") - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${GCC_COMPILE_FLAGS} -D_DEBUG") -else() - if (SSE) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBASISU_SUPPORT_SSE=1") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBASISU_SUPPORT_SSE=1") - else() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBASISU_SUPPORT_SSE=0") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBASISU_SUPPORT_SSE=0") + add_compile_options("$<$:-Wno-reorder;-Wno-class-memaccess;-Wno-deprecated-copy>") + + add_compile_options($<$>:-m32>) + add_compile_definitions($<$:_DEBUG>) + if (EMSCRIPTEN) + add_link_options("SHELL:-s ALLOW_MEMORY_GROWTH=1") endif() +else() + add_compile_options("$<$:-Wno-unused-variable;-Wno-unused-function>") endif() # Define the source files for the static library @@ -163,8 +148,10 @@ set(ENCODER_LIB_SRC_LIST encoder/3rdparty/android_astc_decomp.cpp encoder/3rdparty/tinyexr.cpp transcoder/basisu_transcoder.cpp - - encoder/basisu_astc_hdr_6x6_enc.h +) + +set(ENCODER_LIB_HDR_LIST + encoder/basisu_astc_hdr_6x6_enc.h encoder/basisu_astc_hdr_common.h encoder/basisu_backend.h encoder/basisu_basis_file.h @@ -205,92 +192,90 @@ set(ENCODER_LIB_SRC_LIST transcoder/basisu_transcoder_uastc.h transcoder/basisu_transcoder.h transcoder/basisu.h - zstd/zstd.h ) -if (ZSTD) +if (BASISU_ZSTD) set(ENCODER_LIB_SRC_LIST ${ENCODER_LIB_SRC_LIST} zstd/zstd.c) + set(ENCODER_LIB_HDR_LIST ${ENCODER_LIB_HDR_LIST} zstd/zstd.h) endif() # Create the static library -add_library(basisu_encoder STATIC ${ENCODER_LIB_SRC_LIST}) - -# Create the basisu executable and link against the static library -add_executable(basisu basisu_tool.cpp) -target_link_libraries(basisu PRIVATE basisu_encoder) - -# Create the new example executable and link against the static library -if(EXAMPLES) - add_executable(examples example/example.cpp) - target_link_libraries(examples PRIVATE basisu_encoder) -endif() - -#if (MSVC) - target_sources(basisu PRIVATE "${CMAKE_SOURCE_DIR}/basisu.manifest") - if(EXAMPLES) - target_sources(examples PRIVATE "${CMAKE_SOURCE_DIR}/basisu.manifest") - endif() -#endif() - -if (ZSTD) - target_compile_definitions(basisu PRIVATE BASISD_SUPPORT_KTX2_ZSTD=1) - if(EXAMPLES) - target_compile_definitions(examples PRIVATE BASISD_SUPPORT_KTX2_ZSTD=1) - endif() +add_library(basisu_encoder STATIC ${ENCODER_LIB_SRC_LIST} ${ENCODER_LIB_HDR_LIST}) + +target_include_directories(basisu_encoder +INTERFACE + $ + $ # So KTX-Software can use it. +) +# PUBLIC so it will be exported to dependent programs. +target_compile_features(basisu_encoder PUBLIC cxx_std_17) + +if (EMSCRIPTEN) + target_compile_definitions(basisu_encoder PRIVATE BASISU_SUPPORT_SSE=0) else() - target_compile_definitions(basisu PRIVATE BASISD_SUPPORT_KTX2_ZSTD=0) - if(EXAMPLES) - target_compile_definitions(examples PRIVATE BASISD_SUPPORT_KTX2_ZSTD=0) - endif() + target_compile_options(basisu_encoder PRIVATE + "$,-DBASISU_SUPPORT_SSE=1;$<$:-msse4.1>,-DBASISU_SUPPORT_SSE=0>" + ) endif() +target_compile_definitions(basisu_encoder PRIVATE "BASISD_SUPPORT_KTX2_ZSTD=$,1,0>") if (NOT MSVC) # For Non-Windows builds, let cmake try and find the system OpenCL headers/libs for us. - if (OPENCL AND OPENCL_FOUND) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBASISU_SUPPORT_OPENCL=1") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBASISU_SUPPORT_OPENCL=1") - - target_include_directories(basisu PRIVATE ${OpenCL_INCLUDE_DIRS}) - if(EXAMPLES) - target_include_directories(examples PRIVATE ${OpenCL_INCLUDE_DIRS}) - endif() - target_include_directories(basisu_encoder PRIVATE ${OpenCL_INCLUDE_DIRS}) - set(BASISU_EXTRA_LIBS ${OpenCL_LIBRARIES}) + if (BASISU_OPENCL AND OPENCL_FOUND) + target_compile_definitions(basisu_encoder PRIVATE BASISU_SUPPORT_OPENCL=1) + + target_include_directories(basisu_encoder INTERFACE ${OpenCL_INCLUDE_DIRS}) + target_link_libraries(basisu_encoder INTERFACE ${OpenCL_LIBRARIES}) + endif() + # Only link 'm' on non-Windows platforms (Linux, macOS) + if (NOT WIN32) + target_link_libraries(basisu_encoder INTERFACE m) + endif() + if(Threads_FOUND AND CMAKE_USE_PTHREADS_INIT) + target_link_libraries(basisu_encoder INTERFACE Threads::Threads) + elseif(LINUX) + target_link_libraries(basisu_encoder INTERFACE dl Threads::Threads) + endif() + if (BASISU_STATIC AND MINGW) + target_link_options(basisu_encoder INTERFACE -static-libgcc -static-libstdc++ -static) endif() else() # For Windows builds, we use our local copies of the OpenCL import lib and Khronos headers. - if (OPENCL) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBASISU_SUPPORT_OPENCL=1") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBASISU_SUPPORT_OPENCL=1") - - target_include_directories(basisu PRIVATE "OpenCL") - if(EXAMPLES) - target_include_directories(examples PRIVATE "OpenCL") - endif() - target_include_directories(basisu_encoder PRIVATE "OpenCL") - - if (BUILD_X64) - target_link_libraries(basisu PRIVATE "${CMAKE_SOURCE_DIR}/OpenCL/lib/OpenCL64.lib") - if(EXAMPLES) - target_link_libraries(examples PRIVATE "${CMAKE_SOURCE_DIR}/OpenCL/lib/OpenCL64.lib") - endif() + if (BASISU_OPENCL) + target_compile_definitions(basisu_encoder PRIVATE BASISU_SUPPORT_OPENCL=1) + target_include_directories(basisu_encoder INTERFACE "OpenCL") + + if (BASISU_BUILD_X64) + target_link_libraries(basisu_encoder INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/OpenCL/lib/OpenCL64.lib") else() - target_link_libraries(basisu PRIVATE "${CMAKE_SOURCE_DIR}/OpenCL/lib/OpenCL.lib") - if(EXAMPLES) - target_link_libraries(examples PRIVATE "${CMAKE_SOURCE_DIR}/OpenCL/lib/OpenCL.lib") - endif() + target_link_libraries(basisu_encoder INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/OpenCL/lib/OpenCL.lib") endif() endif() endif() -if (NOT MSVC) - target_link_libraries(basisu PRIVATE m pthread ${BASISU_EXTRA_LIBS}) - if(EXAMPLES) - target_link_libraries(examples PRIVATE m pthread ${BASISU_EXTRA_LIBS}) - endif() +macro(set_common_executable_properties target) + #if (MSVC) + target_sources(${target} PRIVATE "${CMAKE_SOURCE_DIR}/basisu.manifest") + #endif() + target_link_libraries(${target} PRIVATE basisu_encoder) + if (NOT BASISU_STATIC AND NOT EMSCRIPTEN AND NOT WIN32) + target_link_options(${target} PUBLIC -Wl,-rpath .) + endif() +endmacro() + +if (BASISU_TOOL) + # Create the basisu executable and link against the static library + add_executable(basisu basisu_tool.cpp) + set_common_executable_properties(basisu) +endif() + +if (BASISU_EXAMPLES) + # Create the new example executable and link against the static library + add_executable(examples example/example.cpp) + set_common_executable_properties(examples) endif() -if (NOT EMSCRIPTEN) +if (BASISU_TOOL AND NOT EMSCRIPTEN) if (UNIX) if (CMAKE_BUILD_TYPE STREQUAL Release) if (APPLE) @@ -303,24 +288,3 @@ if (NOT EMSCRIPTEN) endif() endif() endif() - -if (MSVC) - set_target_properties(basisu PROPERTIES - RUNTIME_OUTPUT_NAME "basisu" - RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} - RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} - RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} - RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} - ) - - if(EXAMPLES) - set_target_properties(examples PROPERTIES - RUNTIME_OUTPUT_NAME "examples" - RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} - RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} - RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} - RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} - ) - endif() -endif() - From 059a04b87a6f86d90927f2717c2888b64cfba02d Mon Sep 17 00:00:00 2001 From: Mark Callow Date: Tue, 18 Nov 2025 12:21:54 +0900 Subject: [PATCH 03/19] Address review comments from @dg0yt. Only set -g for debug config. Don't set -fPIC in base options. Quote string arguments to STREQUAL. --- CMakeLists.txt | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d3574118..378c0e76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_SOURCE_DIR}/bin>) if (MSVC) # TODO: Fix me for Windows ARM option(BASISU_SSE "SSE 4.1 support" TRUE) - if ( CMAKE_GENERATOR_PLATFORM STREQUAL Win32 ) + if ( CMAKE_GENERATOR_PLATFORM STREQUAL "Win32" ) set(BASISU_BUILD_X64 0) else() set(BASISU_BUILD_X64 1) @@ -48,7 +48,7 @@ message("Initial BASISU_SAN=${BASISU_SAN}") message("initial BASISU_TOOL=${BASISU_TOOL}") message("initial BASISU_EXAMPLES=${BASISU_EXAMPLES}") -if(WIN32 AND MINGW) +if(MINGW) # Check if the Threads package is provided; if using Mingw it MIGHT be find_package(Threads) elseif(LINUX) @@ -89,7 +89,9 @@ else() endif() if (NOT MSVC) - add_compile_options(-g) + add_compile_options($<$:-g>) + # If you want to set an optimization option for non-debug too, use this instead. + #add_compile_options($,-g,-O3>) if (BASISU_SAN) message("Enabling SAN") @@ -98,7 +100,7 @@ if (NOT MSVC) endif() # Add common non-MSVC flags excluding -fPIC. - add_compile_options(-fvisibility=hidden -fPIC -fno-strict-aliasing -D_LARGEFILE64_SOURCE=1 + add_compile_options(-fvisibility=hidden -fno-strict-aliasing -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 -Wall -Wextra -Wno-unused-local-typedefs -Wno-unused-value -Wno-unused-parameter -Wno-unused-variable -Wno-misleading-indentation @@ -224,12 +226,12 @@ if (NOT MSVC) if (BASISU_OPENCL AND OPENCL_FOUND) target_compile_definitions(basisu_encoder PRIVATE BASISU_SUPPORT_OPENCL=1) - target_include_directories(basisu_encoder INTERFACE ${OpenCL_INCLUDE_DIRS}) + target_include_directories(basisu_encoder INTERFACE ${OpenCL_INCLUDE_DIRS}) target_link_libraries(basisu_encoder INTERFACE ${OpenCL_LIBRARIES}) endif() # Only link 'm' on non-Windows platforms (Linux, macOS) if (NOT WIN32) - target_link_libraries(basisu_encoder INTERFACE m) + target_link_libraries(basisu_encoder INTERFACE m) endif() if(Threads_FOUND AND CMAKE_USE_PTHREADS_INIT) target_link_libraries(basisu_encoder INTERFACE Threads::Threads) @@ -243,7 +245,7 @@ else() # For Windows builds, we use our local copies of the OpenCL import lib and Khronos headers. if (BASISU_OPENCL) target_compile_definitions(basisu_encoder PRIVATE BASISU_SUPPORT_OPENCL=1) - target_include_directories(basisu_encoder INTERFACE "OpenCL") + target_include_directories(basisu_encoder INTERFACE "OpenCL") if (BASISU_BUILD_X64) target_link_libraries(basisu_encoder INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/OpenCL/lib/OpenCL64.lib") @@ -251,7 +253,7 @@ else() target_link_libraries(basisu_encoder INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/OpenCL/lib/OpenCL.lib") endif() endif() -endif() +endif() macro(set_common_executable_properties target) #if (MSVC) @@ -277,13 +279,13 @@ endif() if (BASISU_TOOL AND NOT EMSCRIPTEN) if (UNIX) - if (CMAKE_BUILD_TYPE STREQUAL Release) + if (CMAKE_BUILD_TYPE STREQUAL "Release") if (APPLE) add_custom_command(TARGET basisu POST_BUILD COMMAND strip -X -x ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/basisu) - #message("strip command: strip -X -x ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/basisu") + #message("strip command: strip -X -x ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/basisu") else() add_custom_command(TARGET basisu POST_BUILD COMMAND strip -g -X -x ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/basisu) - #message("strip command: strip -g -X -x ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/basisu") + #message("strip command: strip -g -X -x ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/basisu") endif() endif() endif() From 8bc19b1d5abb6eb7a5edfe7c282a4a63b715578b Mon Sep 17 00:00:00 2001 From: Mark Callow Date: Fri, 21 Nov 2025 09:23:13 +0900 Subject: [PATCH 04/19] Fix build and run with OpenCL. * Change PRIVATE to PUBLIC for SSE and OPENCL definitions to propagate them to dependent apps. Fixes failure running `basisu -opencl` when BASISU_OPENCL is set during config. * Change INTERFACE to PRIVATE for OpenCL include directory. basisu_encoder needs this. Apps don't. Fixes build failure on Windows. * Change INTERFACE to PRIVATE for OpenCL link library. Needed if basisu_encoder ever becomes a shared library. When it's a static library, CMake will cause the OpenCL library to be linked to dependent apps. * Set BASISU_SUPPORT_OPENCL=0 when OpenCL not configured. * Make finding OpenCL required for non-Windows when OpenCL configured. Removes need for later checks, allowing code simplification. * Use embedded OpenCL stuff if WIN32 not if MSVC to support use with non-MSVC-front-end compilers. --- CMakeLists.txt | 52 ++++++++++++++++++++++++++----------------------- basisu_tool.cpp | 2 +- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 378c0e76..48b15f3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,10 +55,10 @@ elseif(LINUX) find_package(Threads REQUIRED) endif() -if ((NOT MSVC) AND BASISU_OPENCL) - # With MSVC builds we use the Khronos lib/include files in the project's "OpenCL" directory, to completely avoid requiring fiddly to install vendor SDK's. +if ((NOT WIN32) AND BASISU_OPENCL) + # For Windows builds we use the Khronos lib/include files in the project's "OpenCL" directory, to completely avoid requiring fiddly to install vendor SDK's. # Otherwise we use the system's (if any). - find_package(OpenCL) + find_package(OpenCL REQUIRED) message(STATUS "OpenCL found: ${OPENCL_FOUND}") message(STATUS "OpenCL includes: ${OpenCL_INCLUDE_DIRS}") message(STATUS "OpenCL libraries: ${OpenCL_LIBRARIES}") @@ -213,22 +213,38 @@ INTERFACE target_compile_features(basisu_encoder PUBLIC cxx_std_17) if (EMSCRIPTEN) - target_compile_definitions(basisu_encoder PRIVATE BASISU_SUPPORT_SSE=0) + target_compile_definitions(basisu_encoder PUBLIC BASISU_SUPPORT_SSE=0) else() + target_compile_definitions(basisu_encoder PUBLIC + BASISU_SUPPORT_SSE=$,1,0> + ) target_compile_options(basisu_encoder PRIVATE - "$,-DBASISU_SUPPORT_SSE=1;$<$:-msse4.1>,-DBASISU_SUPPORT_SSE=0>" + "$<$,$>:-msse4.1>" ) endif() target_compile_definitions(basisu_encoder PRIVATE "BASISD_SUPPORT_KTX2_ZSTD=$,1,0>") -if (NOT MSVC) - # For Non-Windows builds, let cmake try and find the system OpenCL headers/libs for us. - if (BASISU_OPENCL AND OPENCL_FOUND) - target_compile_definitions(basisu_encoder PRIVATE BASISU_SUPPORT_OPENCL=1) - - target_include_directories(basisu_encoder INTERFACE ${OpenCL_INCLUDE_DIRS}) - target_link_libraries(basisu_encoder INTERFACE ${OpenCL_LIBRARIES}) +if (BASISU_OPENCL) + # basisu uses this to confirm the library has been compiled with OpenCL support hence PUBLIC. + target_compile_definitions(basisu_encoder PUBLIC BASISU_SUPPORT_OPENCL=1) + if (NOT WIN32) # True when the target system is Windows. + # For Non-Windows builds, use the system OpenCL headers/libs, if cmake found them. + target_include_directories(basisu_encoder PRIVATE ${OpenCL_INCLUDE_DIRS}) + target_link_libraries(basisu_encoder PRIVATE ${OpenCL_LIBRARIES}) + else() + # For Windows builds, we use our local copies of the OpenCL import lib and Khronos headers. + target_include_directories(basisu_encoder PRIVATE "OpenCL") + if (BASISU_BUILD_X64) + target_link_libraries(basisu_encoder PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/OpenCL/lib/OpenCL64.lib") + else() + target_link_libraries(basisu_encoder PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/OpenCL/lib/OpenCL.lib") + endif() endif() +else() + target_compile_definitions(basisu_encoder PUBLIC BASISU_SUPPORT_OPENCL=0) +endif() + +if (NOT MSVC) # Only link 'm' on non-Windows platforms (Linux, macOS) if (NOT WIN32) target_link_libraries(basisu_encoder INTERFACE m) @@ -241,18 +257,6 @@ if (NOT MSVC) if (BASISU_STATIC AND MINGW) target_link_options(basisu_encoder INTERFACE -static-libgcc -static-libstdc++ -static) endif() -else() - # For Windows builds, we use our local copies of the OpenCL import lib and Khronos headers. - if (BASISU_OPENCL) - target_compile_definitions(basisu_encoder PRIVATE BASISU_SUPPORT_OPENCL=1) - target_include_directories(basisu_encoder INTERFACE "OpenCL") - - if (BASISU_BUILD_X64) - target_link_libraries(basisu_encoder INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/OpenCL/lib/OpenCL64.lib") - else() - target_link_libraries(basisu_encoder INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/OpenCL/lib/OpenCL.lib") - endif() - endif() endif() macro(set_common_executable_properties target) diff --git a/basisu_tool.cpp b/basisu_tool.cpp index c6e5ff3a..63810d62 100644 --- a/basisu_tool.cpp +++ b/basisu_tool.cpp @@ -4673,7 +4673,7 @@ static int main_internal(int argc, const char **argv) #ifndef BASISU_SUPPORT_OPENCL if (use_opencl) { - fprintf(stderr, "WARNING: -opencl specified, but OpenCL support was not enabled at compile time! With cmake, use -D OPENCL=1. Falling back to CPU compression.\n"); + fprintf(stderr, "WARNING: -opencl specified, but OpenCL support was not enabled at compile time! With cmake, use -D BASISU_OPENCL=1. Falling back to CPU compression.\n"); } #endif From 22095d6eb00b7f4efc534ddb82611dfbb18a785a Mon Sep 17 00:00:00 2001 From: Mark Callow Date: Fri, 21 Nov 2025 12:56:22 +0900 Subject: [PATCH 05/19] Workaround for issue #413. Remove when issue is fixes in master. --- encoder/basisu_astc_hdr_6x6_enc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/encoder/basisu_astc_hdr_6x6_enc.cpp b/encoder/basisu_astc_hdr_6x6_enc.cpp index e7f67146..46d3049f 100644 --- a/encoder/basisu_astc_hdr_6x6_enc.cpp +++ b/encoder/basisu_astc_hdr_6x6_enc.cpp @@ -1,4 +1,5 @@ // File: basisu_astc_hdr_6x6_enc.cpp +#include #include "basisu_astc_hdr_6x6_enc.h" #include "basisu_enc.h" #include "basisu_astc_hdr_common.h" From d8abe7decb3d76eaf46064a93feb8dc986ac2274 Mon Sep 17 00:00:00 2001 From: MarkCallow Date: Fri, 21 Nov 2025 18:32:14 +0900 Subject: [PATCH 06/19] Use #if for BASISU_SUPPORT_OPENCL to match usage in the library and usage of BASISU_SUPPORT_SSE. Important now that CMakeLists.txt sets it to 0 when not supported. --- basisu_tool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basisu_tool.cpp b/basisu_tool.cpp index 63810d62..b77bd7b1 100644 --- a/basisu_tool.cpp +++ b/basisu_tool.cpp @@ -4670,7 +4670,7 @@ static int main_internal(int argc, const char **argv) opencl_force_serialization = true; } -#ifndef BASISU_SUPPORT_OPENCL +#if !BASISU_SUPPORT_OPENCL if (use_opencl) { fprintf(stderr, "WARNING: -opencl specified, but OpenCL support was not enabled at compile time! With cmake, use -D BASISU_OPENCL=1. Falling back to CPU compression.\n"); From 262fb4940e524875513122022d6565db3f6367ae Mon Sep 17 00:00:00 2001 From: Mark Callow Date: Sun, 23 Nov 2025 18:32:07 +0900 Subject: [PATCH 07/19] Change remaining CMAKE_SOURCE_DIRs to CMAKE_CURRENT_SOURCE_DIR. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 48b15f3e..3b7d698b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ option(BASISU_SAN "sanitize" FALSE) # Using a generator expression here prevents multi-config generators (VS, Xcode, Ninja Multi-Config) # from appending a per-configuration subdirectory. NOTE: This means the output could be overwritten # by a subsequent build for a different configuration. -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_SOURCE_DIR}/bin>) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_CURRENT_SOURCE_DIR}/bin>) # For MSVC builds default to SSE enabled, and determine if it's a 64-bit (-A x64) vs. 32-bit (-A Win32) build. if (MSVC) @@ -261,7 +261,7 @@ endif() macro(set_common_executable_properties target) #if (MSVC) - target_sources(${target} PRIVATE "${CMAKE_SOURCE_DIR}/basisu.manifest") + target_sources(${target} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/basisu.manifest") #endif() target_link_libraries(${target} PRIVATE basisu_encoder) if (NOT BASISU_STATIC AND NOT EMSCRIPTEN AND NOT WIN32) From 01fee3ce5efb61248ffb006584500689a646f1ed Mon Sep 17 00:00:00 2001 From: Mark Callow Date: Mon, 17 Nov 2025 16:14:37 +0900 Subject: [PATCH 08/19] Fix licensing info so `reuse link` passes; ignore some files. Convert license info from deprecated .reuse/dep5 to REUSE.toml. Ignore CMakeUserPresets.json, build files in build and output binaries in bin. --- .gitignore | 3 +- .reuse/dep5 | 30 -------------- .../{BSD-3-clause.txt => BSD-3-Clause.txt} | 0 LICENSES/Zlib.txt | 20 ---------- REUSE.toml | 39 +++++++++++++++++++ bin/.gitignore | 7 ++++ build/.gitignore | 5 +++ 7 files changed, 53 insertions(+), 51 deletions(-) delete mode 100644 .reuse/dep5 rename LICENSES/{BSD-3-clause.txt => BSD-3-Clause.txt} (100%) delete mode 100644 LICENSES/Zlib.txt create mode 100644 REUSE.toml create mode 100644 bin/.gitignore create mode 100644 build/.gitignore diff --git a/.gitignore b/.gitignore index 93524df8..82608382 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -build/ + +CMakeUserPresets.json # VS project and working files *.vcxproj.user diff --git a/.reuse/dep5 b/.reuse/dep5 deleted file mode 100644 index cdba7ccf..00000000 --- a/.reuse/dep5 +++ /dev/null @@ -1,30 +0,0 @@ -Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: basis_universal -Source: https://github.com/BinomialLLC/basis_universal - -# We have asked Binomial about REUSE compliance for their repo, see https://github.com/BinomialLLC/basis_universal/issues/165 -Files: * -Copyright: 2019-2024 Binomial LLC - 2016 The Android Open Source Project -License: Apache-2.0 - -Files: OpenCL/* -Copyright: 2008-2020 The Khronos Group Inc. -License: Apache-2.0 - -Files: zstd/* -Copyright: 2016-present Facebook, Inc. -License: BSD-3-Clause - -Files: encoder/3rdparty/tinyexr.h -Copyright: 2014 - 2021, Syoyo Fujita and many contributors. - 2002 Industrial Light & Magic, a division of Lucas -License: BSD-3-Clause - -Files: encoder/3rdparty/qoi.h -Copyright: 2021 Dominic Szablewski - https://phoboslab.org -License: MIT - -Files: encoder/3rdparty/tinydds.h -Copyright: 2019 DeanoC -License: MIT diff --git a/LICENSES/BSD-3-clause.txt b/LICENSES/BSD-3-Clause.txt similarity index 100% rename from LICENSES/BSD-3-clause.txt rename to LICENSES/BSD-3-Clause.txt diff --git a/LICENSES/Zlib.txt b/LICENSES/Zlib.txt deleted file mode 100644 index 508a9b5b..00000000 --- a/LICENSES/Zlib.txt +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. diff --git a/REUSE.toml b/REUSE.toml new file mode 100644 index 00000000..a63c36ac --- /dev/null +++ b/REUSE.toml @@ -0,0 +1,39 @@ +version = 1 +SPDX-PackageName = "basis_universal" +SPDX-PackageDownloadLocation = "https://github.com/BinomialLLC/basis_universal" + +[[annotations]] +path = "**" +precedence = "aggregate" +SPDX-FileCopyrightText = ["2019-2024 Binomial LLC", "2016 The Android Open Source Project"] +SPDX-License-Identifier = "Apache-2.0" + +[[annotations]] +path = "OpenCL/**" +precedence = "aggregate" +SPDX-FileCopyrightText = "2008-2020 The Khronos Group Inc." +SPDX-License-Identifier = "Apache-2.0" + +[[annotations]] +path = "zstd/**" +precedence = "aggregate" +SPDX-FileCopyrightText = "2016-present Facebook, Inc." +SPDX-License-Identifier = "BSD-3-Clause" + +[[annotations]] +path = "encoder/3rdparty/tinyexr.h" +precedence = "aggregate" +SPDX-FileCopyrightText = ["2014 - 2021, Syoyo Fujita and many contributors.", "2002 Industrial Light & Magic, a division of Lucas"] +SPDX-License-Identifier = "BSD-3-Clause" + +[[annotations]] +path = "encoder/3rdparty/qoi.h" +precedence = "aggregate" +SPDX-FileCopyrightText = "2021 Dominic Szablewski - https://phoboslab.org" +SPDX-License-Identifier = "MIT" + +[[annotations]] +path = "encoder/3rdparty/tinydds.h" +precedence = "aggregate" +SPDX-FileCopyrightText = "2019 DeanoC" +SPDX-License-Identifier = "MIT" diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 00000000..ecb3b59e --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1,7 @@ + +* + +!.gitignore +!ocl_kernels.cl +!clean.bat +!readme.txt diff --git a/build/.gitignore b/build/.gitignore new file mode 100644 index 00000000..3467e412 --- /dev/null +++ b/build/.gitignore @@ -0,0 +1,5 @@ + +* + +!.gitignore +!readme.txt From daf79c6ee7343f547d29c36d180331a73300607b Mon Sep 17 00:00:00 2001 From: Mark Callow Date: Sun, 23 Nov 2025 18:48:45 +0900 Subject: [PATCH 09/19] Remove our fix for upstream issue #413. --- encoder/basisu_astc_hdr_6x6_enc.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/encoder/basisu_astc_hdr_6x6_enc.cpp b/encoder/basisu_astc_hdr_6x6_enc.cpp index f2e3f403..fd1efe52 100644 --- a/encoder/basisu_astc_hdr_6x6_enc.cpp +++ b/encoder/basisu_astc_hdr_6x6_enc.cpp @@ -1,5 +1,4 @@ // File: basisu_astc_hdr_6x6_enc.cpp -#include #include "basisu_astc_hdr_6x6_enc.h" #include "basisu_enc.h" #include "basisu_astc_hdr_common.h" From ccea925dff04e486c0b1620355fc16a85b7a7879 Mon Sep 17 00:00:00 2001 From: Mark Callow Date: Mon, 17 Nov 2025 16:14:37 +0900 Subject: [PATCH 10/19] Fix licensing info so `reuse link` passes; ignore some files. Convert license info from deprecated .reuse/dep5 to REUSE.toml. Ignore CMakeUserPresets.json, build files in build and output binaries in bin. --- .gitignore | 3 +- .reuse/dep5 | 30 -------------- .../{BSD-3-clause.txt => BSD-3-Clause.txt} | 0 LICENSES/Zlib.txt | 20 ---------- REUSE.toml | 39 +++++++++++++++++++ bin/.gitignore | 7 ++++ build/.gitignore | 5 +++ 7 files changed, 53 insertions(+), 51 deletions(-) delete mode 100644 .reuse/dep5 rename LICENSES/{BSD-3-clause.txt => BSD-3-Clause.txt} (100%) delete mode 100644 LICENSES/Zlib.txt create mode 100644 REUSE.toml create mode 100644 bin/.gitignore create mode 100644 build/.gitignore diff --git a/.gitignore b/.gitignore index 93524df8..82608382 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -build/ + +CMakeUserPresets.json # VS project and working files *.vcxproj.user diff --git a/.reuse/dep5 b/.reuse/dep5 deleted file mode 100644 index cdba7ccf..00000000 --- a/.reuse/dep5 +++ /dev/null @@ -1,30 +0,0 @@ -Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: basis_universal -Source: https://github.com/BinomialLLC/basis_universal - -# We have asked Binomial about REUSE compliance for their repo, see https://github.com/BinomialLLC/basis_universal/issues/165 -Files: * -Copyright: 2019-2024 Binomial LLC - 2016 The Android Open Source Project -License: Apache-2.0 - -Files: OpenCL/* -Copyright: 2008-2020 The Khronos Group Inc. -License: Apache-2.0 - -Files: zstd/* -Copyright: 2016-present Facebook, Inc. -License: BSD-3-Clause - -Files: encoder/3rdparty/tinyexr.h -Copyright: 2014 - 2021, Syoyo Fujita and many contributors. - 2002 Industrial Light & Magic, a division of Lucas -License: BSD-3-Clause - -Files: encoder/3rdparty/qoi.h -Copyright: 2021 Dominic Szablewski - https://phoboslab.org -License: MIT - -Files: encoder/3rdparty/tinydds.h -Copyright: 2019 DeanoC -License: MIT diff --git a/LICENSES/BSD-3-clause.txt b/LICENSES/BSD-3-Clause.txt similarity index 100% rename from LICENSES/BSD-3-clause.txt rename to LICENSES/BSD-3-Clause.txt diff --git a/LICENSES/Zlib.txt b/LICENSES/Zlib.txt deleted file mode 100644 index 508a9b5b..00000000 --- a/LICENSES/Zlib.txt +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. diff --git a/REUSE.toml b/REUSE.toml new file mode 100644 index 00000000..a63c36ac --- /dev/null +++ b/REUSE.toml @@ -0,0 +1,39 @@ +version = 1 +SPDX-PackageName = "basis_universal" +SPDX-PackageDownloadLocation = "https://github.com/BinomialLLC/basis_universal" + +[[annotations]] +path = "**" +precedence = "aggregate" +SPDX-FileCopyrightText = ["2019-2024 Binomial LLC", "2016 The Android Open Source Project"] +SPDX-License-Identifier = "Apache-2.0" + +[[annotations]] +path = "OpenCL/**" +precedence = "aggregate" +SPDX-FileCopyrightText = "2008-2020 The Khronos Group Inc." +SPDX-License-Identifier = "Apache-2.0" + +[[annotations]] +path = "zstd/**" +precedence = "aggregate" +SPDX-FileCopyrightText = "2016-present Facebook, Inc." +SPDX-License-Identifier = "BSD-3-Clause" + +[[annotations]] +path = "encoder/3rdparty/tinyexr.h" +precedence = "aggregate" +SPDX-FileCopyrightText = ["2014 - 2021, Syoyo Fujita and many contributors.", "2002 Industrial Light & Magic, a division of Lucas"] +SPDX-License-Identifier = "BSD-3-Clause" + +[[annotations]] +path = "encoder/3rdparty/qoi.h" +precedence = "aggregate" +SPDX-FileCopyrightText = "2021 Dominic Szablewski - https://phoboslab.org" +SPDX-License-Identifier = "MIT" + +[[annotations]] +path = "encoder/3rdparty/tinydds.h" +precedence = "aggregate" +SPDX-FileCopyrightText = "2019 DeanoC" +SPDX-License-Identifier = "MIT" diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 00000000..ecb3b59e --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1,7 @@ + +* + +!.gitignore +!ocl_kernels.cl +!clean.bat +!readme.txt diff --git a/build/.gitignore b/build/.gitignore new file mode 100644 index 00000000..3467e412 --- /dev/null +++ b/build/.gitignore @@ -0,0 +1,5 @@ + +* + +!.gitignore +!readme.txt From f5be20d9815c9fe819bcb2f4ccb89b4b072b32b1 Mon Sep 17 00:00:00 2001 From: Mark Callow Date: Wed, 4 Feb 2026 18:36:57 +0900 Subject: [PATCH 11/19] Remove debug printf. --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bbcc525e..d15b0237 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -344,7 +344,6 @@ if (NOT MSVC AND NOT BASISU_BUILD_WASM) endif() macro(set_common_executable_properties target add_lib) - message("target = ${target}, add_lib = ${add_lib}") #if (MSVC) target_sources(${target} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/basisu.manifest") #endif() From 3d395f1a8f39566846fc647798ff7701be256084 Mon Sep 17 00:00:00 2001 From: Mark Callow Date: Wed, 4 Feb 2026 18:50:34 +0900 Subject: [PATCH 12/19] Formatting improvements. --- CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d15b0237..bf57a385 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -370,20 +370,22 @@ macro(set_common_executable_properties target add_lib) endmacro() if (BASISU_TOOL) - # Create the basisu executable and link against the static library + # Create the basisu executable add_executable(basisu basisu_tool.cpp) set_common_executable_properties(basisu TRUE) endif() if (BASISU_EXAMPLES) - # Create the new example executable and link against the static library + # Create the example executables add_executable(examples example/example.cpp) set_common_executable_properties(examples TRUE) + add_executable(example_capi example_capi/example_capi.c encoder/basisu_wasm_api.cpp encoder/basisu_wasm_transcoder_api.cpp) set_common_executable_properties(example_capi TRUE) + add_executable(example_transcoding example_transcoding/example_transcoding.cpp example_transcoding/utils.cpp zstd/zstddeclib.c transcoder/basisu_transcoder.cpp) set_common_executable_properties(example_transcoding FALSE) - # This is used by basisu_transcoder.cpp. + # Need to set these because target is not linked to basisu_encoder. target_compile_definitions(example_transcoding PRIVATE "BASISD_SUPPORT_KTX2_ZSTD=$,1,0>") target_compile_options(example_transcoding PUBLIC "$<$:-fno-exceptions -fno-rtti>" From c99d2c3b020218dbbc853abcaf6953790e9b44a3 Mon Sep 17 00:00:00 2001 From: Mark Callow Date: Wed, 4 Feb 2026 19:03:39 +0900 Subject: [PATCH 13/19] Convert remaining piece of WASM build. --- CMakeLists.txt | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bf57a385..1a0091f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -185,20 +185,14 @@ if (NOT MSVC AND NOT BASISU_BUILD_WASM) elseif (BASISU_BUILD_WASM) # _WASI_EMULATED_PROCESS_CLOCKS/-lwasi-emulated-process-clocks is only for ZStd add_compile_definitions(_WASI_EMULATED_PROCESS_CLOCKS) -# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lwasi-emulated-process-clocks") -# -# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing -fvisibility=hidden -Wall -Wextra -Wno-unknown-warning-option") -# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing -fvisibility=hidden -Wall -Wextra -Wno-unknown-warning-option") -# -# set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g") -# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g") -# -# set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2") -# set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2") -# -# # We need a few MB of stack - don't skip this or WASMTime will silently allow the stack to grow into the heap or static memory, causing corruption. -# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--stack-first -Wl,-z,stack-size=8388608") + add_link_options(-lwasi-emulated-process-clocks) + add_compile_options(-fno-strict-aliasing -fvisibility=hidden -Wall -Wextra -Wno-unknown-warning-option) + + add_compile_options($,-g,-O2>) + + # We need a few MB of stack - don't skip this or WASMTime will silently allow the stack to grow into the heap or static memory, causing corruption. + add_link_options(-Wl,--stack-first -Wl,-z,stack-size=8388608) else() add_compile_options("$<$:-Wno-unused-variable;-Wno-unused-function>") endif() From 1767afc0ad002c05858cf76966585c9cc01351e9 Mon Sep 17 00:00:00 2001 From: Mark Callow Date: Thu, 5 Feb 2026 13:13:48 +0900 Subject: [PATCH 14/19] Clean up. --- CMakeLists.txt | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a0091f6..5b0b6835 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,10 +24,10 @@ endif() set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -option(BASISU_STATIC "static linking" FALSE) # NO-OP. basisu_encoder always built as a static library. +option(BASISU_STATIC "static linking" TRUE) # NO-OP. basisu_encoder always built as a static library. option(BASISU_SAN "sanitize" FALSE) -option(BASISU_EXAMPLES "Include examples in build" TRUE) -option(BASISU_TOOL "Include basisu tool in build" TRUE) +option(BASISU_EXAMPLES "build examples" TRUE) +option(BASISU_TOOL "build basisu tool" TRUE) option(BASISU_WASM_THREADING "Enable WASI threading support" OFF) option(BASISU_BUILD_PYTHON "Build native Python module via pybind11" OFF) @@ -91,6 +91,7 @@ if (BASISU_BUILD_WASM) set(BASISU_OPENCL OFF CACHE BOOL "" FORCE) # WASM cannot use dynamic linking + # TODO: Fix this untrue statement. basisu_encoder always built as a static library. set(BASISU_STATIC OFF CACHE BOOL "" FORCE) # WASM cannot use sanitizers @@ -305,7 +306,7 @@ target_compile_definitions(basisu_encoder PRIVATE "BASISD_SUPPORT_KTX2_ZSTD=$,1,0>") target_compile_options(example_transcoding PUBLIC "$<$:-fno-exceptions -fno-rtti>" @@ -427,8 +428,6 @@ if (BASISU_BUILD_WASM) -Wl,--stack-first -Wl,-z,stack-size=8388608 ) - # Already set and exported from basisu_encoder. - #target_compile_options(${BASISU_WASM_OUTPUT_NAME} PRIVATE -fno-exceptions -fno-rtti) set_target_properties(${BASISU_WASM_OUTPUT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_CURRENT_SOURCE_DIR}/python/basisu_py/wasm> From f6798a289b3979b99062e74fe9c0db3ecfbfb9d2 Mon Sep 17 00:00:00 2001 From: Mark Callow Date: Thu, 5 Feb 2026 13:18:09 +0900 Subject: [PATCH 15/19] Fix c++20 enum to enum arithmetic depcreated warning. --- transcoder/basisu_transcoder_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transcoder/basisu_transcoder_internal.h b/transcoder/basisu_transcoder_internal.h index c830795a..8e36f4a1 100644 --- a/transcoder/basisu_transcoder_internal.h +++ b/transcoder/basisu_transcoder_internal.h @@ -2123,7 +2123,7 @@ namespace basist enum { TABLE_BITS = 8 }; // 256..1024 entries typical (8..10) enum { TABLE_SIZE = 1 << TABLE_BITS }; enum { MANT_BITS = 23 }; - enum { FRAC_BITS = MANT_BITS - TABLE_BITS }; + enum { FRAC_BITS = (int)MANT_BITS - (int)TABLE_BITS }; enum { FRAC_MASK = (1u << FRAC_BITS) - 1u }; extern bool g_initialized; From 51e2b1e7d7fdc6e8a115b463f229e2e7cb1bcd66 Mon Sep 17 00:00:00 2001 From: Mark Callow Date: Thu, 5 Feb 2026 13:19:56 +0900 Subject: [PATCH 16/19] Clean up more. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b0b6835..e5dc69cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,7 @@ option(BASISU_BUILD_PYTHON "Build native Python module via pybind11" OFF) # Using a generator expression here prevents multi-config generators (VS, Xcode, # Ninja Multi-Config) from appending a per-configuration subdirectory. This is # a MUCH simpler alternative to specifying RUNTIME_OUTPUT_DIRECTORY_ -# for each target and each config which was previously done, though only for VS. +# for each target and each config. # NOTE: This means the output will be overwritten by a subsequent build for a # different but that is true of the alternative too. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_CURRENT_SOURCE_DIR}/bin>) From d479d26319bf4e156b2c71fdbc217b93fad07e64 Mon Sep 17 00:00:00 2001 From: Mark Callow Date: Sun, 28 Dec 2025 13:45:52 +0900 Subject: [PATCH 17/19] Set compile options for uniform FP handling. --- CMakeLists.txt | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e5dc69cb..39e4d072 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,6 +150,66 @@ else() message("Zstandard disabled") endif() +####################################################################### +# Specify floating point handling +# +# For deterministic results specify FP compile options for uniform +# handling of floating point operations across platforms and compilers + +# Compiler info query helpers + +# On CMake 3.25 or older CXX_COMPILER_FRONTEND_VARIANT is not always set +if(CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "") + set(CMAKE_CXX_COMPILER_FRONTEND_VARIANT "${CMAKE_CXX_COMPILER_ID}") +endif() + +#cmake_print_variables( +# CMAKE_CXX_COMPILER_ID +# CMAKE_CXX_COMPILER_VERSION +# CMAKE_CXX_COMPILER_FRONTEND_VARIANT +#) + +# Compiler accepts MSVC-style command line options +set(is_msvc_fe "$") +# Compiler accepts GNU-style command line options +set(is_gnu_fe1 "$") +# Compiler accepts AppleClang-style command line options, which is also GNU-style +set(is_gnu_fe2 "$") +# Compiler accepts GNU-style command line options +set(is_gnu_fe "$") + +# Compiler is Visual Studio cl.exe +set(is_msvccl "$>") +# Compiler is Visual Studio clangcl.exe +set(is_clangcl "$>") +# Compiler is upstream clang with the standard frontend +set(is_clang "$>") + +# Genex debug helper. Note that CXX_COMPILER_ID can only be used in +# compilation targets so won't work in a custom target. +#if(NOT TARGET debug_isgnufe1) +# add_custom_target(debug_isgnufe1 +# COMMAND ${CMAKE_COMMAND} -E echo "is_gnufe1_exp = $" +# ) +#endif() + +# On MSVC and CLangCL, set /fp:strict and /fp:precise, on clang +# -ffp-model=precise and on GNU CC -ffp-contract=off. These result in +# precise semantics always being used and fused multiply-add never +# being used, +add_compile_options( + $<$,19.30>>:/fp:strict> + $<$,19.30>>:/fp:precise> + $<${is_clangcl}:/fp:precise> + $<$,14.0.0>>:-Xclang$-ffp-contract=off> + $<$,10.0.0>>:-ffp-model=precise> + $<${is_gnu_fe}:-ffp-contract=off> + # Hide noise from clang and clangcl 20 warning the 2nd fp option changes + # one of the settings made the first. + $<$,20.0.0>>:-Wno-overriding-option> +) +####################################################################### + if (NOT MSVC AND NOT BASISU_BUILD_WASM) add_compile_options($<$:-g>) # If you want to set an optimization option for non-debug too, use this instead. From 29e75d0f3c590ccc85d8d35534dd846cb80c7cb3 Mon Sep 17 00:00:00 2001 From: Mark Callow Date: Thu, 5 Feb 2026 16:40:33 +0900 Subject: [PATCH 18/19] Remove non-ASCII hyphen characters from comments. --- encoder/basisu_astc_ldr_common.cpp | 2 +- transcoder/basisu_transcoder_internal.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/encoder/basisu_astc_ldr_common.cpp b/encoder/basisu_astc_ldr_common.cpp index a66969a8..67073eb0 100644 --- a/encoder/basisu_astc_ldr_common.cpp +++ b/encoder/basisu_astc_ldr_common.cpp @@ -878,7 +878,7 @@ namespace astc_ldr } #endif - // TODO: Try two-step Lanczos iteration/Rayleigh–Ritz approximation in a 2-dimensional Krylov subspace method vs. power method. + // TODO: Try two-step Lanczos iteration/Rayleigh-Ritz approximation in a 2-dimensional Krylov subspace method vs. power method. static vec4F calc_pca_4D(uint32_t num_pixels, const vec4F* pPixels, const vec4F& mean_f) { float m00 = 0, m01 = 0, m02 = 0, m03 = 0; diff --git a/transcoder/basisu_transcoder_internal.h b/transcoder/basisu_transcoder_internal.h index 8e36f4a1..17844897 100644 --- a/transcoder/basisu_transcoder_internal.h +++ b/transcoder/basisu_transcoder_internal.h @@ -1758,7 +1758,7 @@ namespace basist return (int)std::round(d / (float)L); } - // L = quant step, alpha in [0,1.2] (typical 0.7–0.85) + // L = quant step, alpha in [0,1.2] (typical 0.7-0.85) if (L <= 0) return 0; From c40de6605612385cc39a6ce433343ee3d7e8b3fd Mon Sep 17 00:00:00 2001 From: Mark Callow Date: Thu, 5 Feb 2026 20:37:25 +0900 Subject: [PATCH 19/19] Fix GCC 15 waarnings by removing pointless asserts. --- encoder/basisu_astc_ldr_common.cpp | 6 +++--- transcoder/basisu_transcoder.cpp | 6 +----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/encoder/basisu_astc_ldr_common.cpp b/encoder/basisu_astc_ldr_common.cpp index 67073eb0..770966fa 100644 --- a/encoder/basisu_astc_ldr_common.cpp +++ b/encoder/basisu_astc_ldr_common.cpp @@ -1127,7 +1127,7 @@ namespace astc_ldr { BASISU_NOTE_UNUSED(weight_ise_index); - assert((ccs_index >= 0) && (ccs_index <= 3)); + assert(ccs_index <= 3); assert((total_weights <= 32) || (total_weights == 65)); uint64_t total_err = 0; @@ -4414,7 +4414,7 @@ namespace astc_ldr const cem_encode_params& enc_params, uint32_t flags) { assert(g_initialized); - assert((ccs_index >= 0) && (ccs_index <= 3)); + assert(ccs_index <= 3); assert((ps.m_num_pixels) && (ps.m_num_pixels <= ASTC_LDR_MAX_BLOCK_PIXELS)); assert(pWeights0 && pWeights1); @@ -4830,7 +4830,7 @@ namespace astc_ldr uint32_t endpoint_ise_range, uint32_t weight_ise_range, vec4F& low_endpoint, vec4F& high_endpoint, float* pWeights0, float *pWeights1, uint32_t flags) { - assert((ccs_index >= 0) && (ccs_index <= 3)); + assert(ccs_index <= 3); const uint32_t num_endpoint_levels = astc_helpers::get_ise_levels(endpoint_ise_range); // astc_helpers::BISE_64_LEVELS=raw weights ([0,64], NOT [0,63]) diff --git a/transcoder/basisu_transcoder.cpp b/transcoder/basisu_transcoder.cpp index 1321c7da..a511d8d6 100644 --- a/transcoder/basisu_transcoder.cpp +++ b/transcoder/basisu_transcoder.cpp @@ -1,4 +1,4 @@ -// basisu_transcoder.cpp +// basisu_transcoder.cpp // Copyright (C) 2019-2026 Binomial LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -32148,11 +32148,9 @@ namespace bc7f { scaledLow[i] = (xMinColor[i] << (8 - total_bits)); scaledLow[i] |= (scaledLow[i] >> total_bits); - assert(scaledLow[i] <= 255); scaledHigh[i] = (xMaxColor[i] << (8 - total_bits)); scaledHigh[i] |= (scaledHigh[i] >> total_bits); - assert(scaledHigh[i] <= 255); } float err0 = 0, err1 = 0; @@ -32222,11 +32220,9 @@ namespace bc7f { scaledLow[i] = (xMinColor[i] << (8 - total_bits)); scaledLow[i] |= (scaledLow[i] >> total_bits); - assert(scaledLow[i] <= 255); scaledHigh[i] = (xMaxColor[i] << (8 - total_bits)); scaledHigh[i] |= (scaledHigh[i] >> total_bits); - assert(scaledHigh[i] <= 255); } float err = 0;