diff --git a/doc/building-plugins.dox b/doc/building-plugins.dox index f84f5832d..b97654747 100644 --- a/doc/building-plugins.dox +++ b/doc/building-plugins.dox @@ -226,10 +226,11 @@ thus the Magnum Plugins package doesn't have it enabled by default. In order to enable them, do the following: - For @ref Trade::BasisImporter "BasisImporter" or - @ref Trade::BasisImageConverter "BasisImageConverter", [download the - `v1_15_update2` tag of the Basis Universal repo](https://github.com/BinomialLLC/basis_universal/archive/v1_15_update2.tar.gz), - extract it into `src/external/basis-universal` (note the dash instead of an - underscore) and set `MAGNUM_WITH_BASISIMPORTER` / + @ref Trade::BasisImageConverter "BasisImageConverter", download the + [`v1_50_0_2`](https://github.com/BinomialLLC/basis_universal/archive/v1_50_0_2.tar.gz) + `1.16.4` or `v1_15_update2` tag of the Basis Universal repo, extract it + into `src/external/basis-universal` (note the dash instead of an + underscore) set `MAGNUM_WITH_BASISIMPORTER` / `MAGNUM_WITH_BASISIMAGECONVERTER` to `ON` in `package/debian/rules` - For @ref Trade::MeshOptimizerSceneConverter "MeshOptimizerSceneConverter", [clone the MeshOptimizer repo](https://github.com/zeux/meshoptimizer) to diff --git a/modules/FindBasisUniversal.cmake b/modules/FindBasisUniversal.cmake index 875837d9d..9a5369748 100644 --- a/modules/FindBasisUniversal.cmake +++ b/modules/FindBasisUniversal.cmake @@ -87,6 +87,8 @@ macro(_basis_setup_source_file source) # Basis shouldn't override the MSVC iterator debug level as it would make # it inconsistent with the rest of the code + # Only needed until 1.15, in later versions this doesn't do + # anything anymore. if(CORRADE_TARGET_WINDOWS) set_property(SOURCE ${source} APPEND PROPERTY COMPILE_DEFINITIONS BASISU_NO_ITERATOR_DEBUG_LEVEL) @@ -161,8 +163,6 @@ foreach(_component ${BasisUniversal_FIND_COMPONENTS}) # Alternatively, look into creating stubs for the library # functions used by basis_universal. set(BasisUniversalEncoder_SOURCES - ${BasisUniversalEncoder_DIR}/apg_bmp.c - ${BasisUniversalEncoder_DIR}/basisu_astc_decomp.cpp ${BasisUniversalEncoder_DIR}/basisu_backend.cpp ${BasisUniversalEncoder_DIR}/basisu_basis_file.cpp ${BasisUniversalEncoder_DIR}/basisu_bc7enc.cpp @@ -170,21 +170,74 @@ foreach(_component ${BasisUniversal_FIND_COMPONENTS}) ${BasisUniversalEncoder_DIR}/basisu_enc.cpp ${BasisUniversalEncoder_DIR}/basisu_etc.cpp ${BasisUniversalEncoder_DIR}/basisu_frontend.cpp - ${BasisUniversalEncoder_DIR}/basisu_global_selector_palette_helpers.cpp ${BasisUniversalEncoder_DIR}/basisu_gpu_texture.cpp ${BasisUniversalEncoder_DIR}/basisu_kernels_sse.cpp ${BasisUniversalEncoder_DIR}/basisu_pvrtc1_4.cpp ${BasisUniversalEncoder_DIR}/basisu_resampler.cpp ${BasisUniversalEncoder_DIR}/basisu_resample_filters.cpp ${BasisUniversalEncoder_DIR}/basisu_ssim.cpp - ${BasisUniversalEncoder_DIR}/basisu_uastc_enc.cpp - ${BasisUniversalEncoder_DIR}/jpgd.cpp - ${BasisUniversalEncoder_DIR}/lodepng.cpp) + ${BasisUniversalEncoder_DIR}/basisu_uastc_enc.cpp) + + # Files not present in all supported basis versions, treat them + # as optional and do nothing if not found. + foreach(_file + # Removed in 1.16 + basisu_astc_decomp.cpp + basisu_global_selector_palette_helpers.cpp + # Added in 1.16 + basisu_opencl.cpp + # Added in 1.50 + basisu_astc_hdr_enc.cpp + 3rdparty/android_astc_decomp.cpp) + # Disable the find root path here, it overrides the + # CMAKE_FIND_ROOT_PATH_MODE_INCLUDE setting potentially set in + # toolchains. + find_file(BasisUniversalEncoder_${_file}_SOURCE NAMES ${_file} + HINTS ${BasisUniversalEncoder_DIR} NO_CMAKE_FIND_ROOT_PATH) + + if(BasisUniversalEncoder_${_file}_SOURCE) + list(APPEND BasisUniversalEncoder_SOURCES + ${BasisUniversalEncoder_${_file}_SOURCE}) + endif() + endforeach() + + # The encoder unconditionally calls assert() for all OpenCL + # errors, including a non-fatal error when falling back to a + # CPU device: https://github.com/BinomialLLC/basis_universal/issues/378 + # To allow testing on CPU OpenCL implementations, disable + # asserts in this specific file. + if(BasisUniversalEncoder_basisu_opencl.cpp_SOURCE) + set_property(SOURCE ${BasisUniversalEncoder_basisu_opencl.cpp_SOURCE} + APPEND PROPERTY COMPILE_DEFINITIONS NDEBUG) + endif() + + # Source files for image file loading are not added here. + # BasisImageConverter provides stubs for all used functions. + # See src/external/basis-uncrapifier for more info. foreach(_file ${BasisUniversalEncoder_SOURCES}) _basis_setup_source_file(${_file}) endforeach() + set(BasisUniversalEncoder_DEFINITIONS "BASISU_NO_ITERATOR_DEBUG_LEVEL") + + # Basis already checks for GCC < 5 to work around missing + # std::is_trivially_copyable but then uses the wrong built-in. + # So close, yet so far. + # Needs to be transitive because it's used in a header file. + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0") + list(APPEND BasisUniversalEncoder_DEFINITIONS + "__is_trivially_copyable=__has_trivial_copy") + endif() + + # Try to find an external OpenCL library and enable support for + # it in basis if found. + find_package(OpenCL) + if(OpenCL_FOUND) + list(APPEND BasisUniversalEncoder_DEFINITIONS + "BASISU_SUPPORT_OPENCL=1") + endif() + # Disable the find root path here, it overrides the # CMAKE_FIND_ROOT_PATH_MODE_INCLUDE setting potentially set in # toolchains. @@ -196,8 +249,16 @@ foreach(_component ${BasisUniversal_FIND_COMPONENTS}) add_library(BasisUniversal::Encoder INTERFACE IMPORTED) set_property(TARGET BasisUniversal::Encoder APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${BasisUniversalEncoder_INCLUDE_DIR}) + set_property(TARGET BasisUniversal::Encoder APPEND PROPERTY + INTERFACE_COMPILE_DEFINITIONS ${BasisUniversalEncoder_DEFINITIONS}) set_property(TARGET BasisUniversal::Encoder APPEND PROPERTY INTERFACE_SOURCES "${BasisUniversalEncoder_SOURCES}") + if(OpenCL_FOUND) + set_property(TARGET BasisUniversal::Encoder APPEND PROPERTY + INTERFACE_INCLUDE_DIRECTORIES ${OpenCL_INCLUDE_DIRS}) + set_property(TARGET BasisUniversal::Encoder APPEND PROPERTY + INTERFACE_LINK_LIBRARIES ${OpenCL_LIBRARIES}) + endif() # Explicitly *not* linking this to Threads::Threads because # when done like that, std::thread creation will die on a null # function pointer call (inside __gthread_create, which weakly @@ -214,8 +275,6 @@ foreach(_component ${BasisUniversal_FIND_COMPONENTS}) # itself. set_property(TARGET BasisUniversal::Encoder APPEND PROPERTY INTERFACE_LINK_LIBRARIES BasisUniversal::Transcoder) - set_property(TARGET BasisUniversal::Encoder APPEND PROPERTY - INTERFACE_COMPILE_DEFINITIONS "BASISU_NO_ITERATOR_DEBUG_LEVEL") endif() else() set(BasisUniversal_Encoder_FOUND TRUE) @@ -273,6 +332,11 @@ foreach(_component ${BasisUniversal_FIND_COMPONENTS}) set(BasisUniversalTranscoder_DEFINITIONS "BASISU_NO_ITERATOR_DEBUG_LEVEL") + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0") + list(APPEND BasisUniversalTranscoder_DEFINITIONS + "__is_trivially_copyable=__has_trivial_copy") + endif() + # Try to find an external Zstandard library because that's the # sanest and most flexible option. # diff --git a/package/archlinux/magnum-plugins-git/PKGBUILD b/package/archlinux/magnum-plugins-git/PKGBUILD index 8958b8bc8..f3ced37dc 100644 --- a/package/archlinux/magnum-plugins-git/PKGBUILD +++ b/package/archlinux/magnum-plugins-git/PKGBUILD @@ -1,7 +1,7 @@ # Author: mosra pkgname=magnum-plugins-git pkgver=2020.06.r1061.g24295477 -_basis_pkgver=1_15_update2 +_basis_pkgver=1_50_0_2 pkgrel=1 pkgdesc="Plugins for the Magnum C++11/C++14 graphics engine (Git version)" arch=('i686' 'x86_64') @@ -14,7 +14,7 @@ conflicts=('magnum-plugins') source=("git+https://github.com/mosra/magnum-plugins.git" "https://github.com/BinomialLLC/basis_universal/archive/v${_basis_pkgver}.tar.gz") sha1sums=('SKIP' - 'b9615d48ebfc62a53f333ebf8a582558a058b0e9') + '4946d685424556efb07376b97e95a4cbb3245e40') pkgver() { cd "$srcdir/${pkgname%-git}" diff --git a/package/ci/appveyor-desktop.bat b/package/ci/appveyor-desktop.bat index 4627b9d23..8ce6d2350 100644 --- a/package/ci/appveyor-desktop.bat +++ b/package/ci/appveyor-desktop.bat @@ -20,6 +20,9 @@ IF "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2015" set EXCEPT_MSVC2015=O IF "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2015" set EXCEPT_MSVC2017=OFF IF "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2017" set EXCEPT_MSVC2017=OFF +set ONLY_MSVC2019=OFF +IF "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2019" set ONLY_MSVC2019=ON + rem Build Corrade git clone --depth 1 https://github.com/mosra/corrade.git || exit /b cd corrade || exit /b @@ -65,6 +68,8 @@ cd .. && cd .. rem Build. MAGNUM_BUILD_GL_TESTS is enabled just to be sure, it should not be rem needed by any plugin. +rem OpenCL is disabled on MSVC 2019 to get some test coverage for +rem BasisImageConverter without OpenCL support compiled in. mkdir build && cd build || exit /b cmake .. ^ -DCMAKE_BUILD_TYPE=Debug ^ @@ -72,6 +77,7 @@ cmake .. ^ -DCMAKE_PREFIX_PATH=%APPVEYOR_BUILD_FOLDER%/openal;%APPVEYOR_BUILD_FOLDER%/libwebp;%APPVEYOR_BUILD_FOLDER%/devil;C:/Tools/vcpkg/installed/x64-windows ^ -DMAGNUM_WITH_ASSIMPIMPORTER=%EXCEPT_MSVC2015% ^ -DMAGNUM_WITH_ASTCIMPORTER=ON ^ + -DCMAKE_DISABLE_FIND_PACKAGE_OpenCL=%ONLY_MSVC2019% ^ -DMAGNUM_WITH_BASISIMAGECONVERTER=%EXCEPT_MSVC2015% ^ -DMAGNUM_WITH_BASISIMPORTER=%EXCEPT_MSVC2015% -DBASIS_UNIVERSAL_DIR=%APPVEYOR_BUILD_FOLDER%/basis_universal ^ -DMAGNUM_WITH_BCDECIMAGECONVERTER=ON ^ diff --git a/package/ci/appveyor.yml b/package/ci/appveyor.yml index f9bf2aa1d..6cea82a71 100644 --- a/package/ci/appveyor.yml +++ b/package/ci/appveyor.yml @@ -121,10 +121,20 @@ install: - IF "%TARGET%" == "desktop" IF "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2019" IF "%COMPILER:~0,4%" == "msvc" appveyor DownloadFile https://ci.magnum.graphics/freetype-2.10.4-windows-2019.zip && 7z x freetype-2.10.4-windows-2019.zip -o%APPVEYOR_BUILD_FOLDER%\deps - IF "%TARGET%" == "desktop" IF "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2017" IF "%COMPILER:~0,4%" == "msvc" appveyor DownloadFile https://ci.magnum.graphics/freetype-2.10.4-windows-2016.zip && 7z x freetype-2.10.4-windows-2016.zip -o%APPVEYOR_BUILD_FOLDER%\deps -# Basis Universal -- set BASIS_VERSION=1_15_update2 -- IF NOT EXIST %APPVEYOR_BUILD_FOLDER%\v%BASIS_VERSION%.zip appveyor DownloadFile https://github.com/BinomialLLC/basis_universal/archive/v%BASIS_VERSION%.zip -- 7z x v%BASIS_VERSION%.zip && ren basis_universal-%BASIS_VERSION% basis_universal +# Basis Universal, all the recent supported versions. Default to latest and +# use a few older versions on 2017 and 2019. +- set BASIS_VERSION=v1_50_0_2 +- IF "%TARGET%" == "desktop" IF "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2019" IF "%COMPILER%" == "msvc" set BASIS_VERSION=1.16.4 +- IF "%TARGET%" == "desktop" IF "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2017" IF "%COMPILER%" == "msvc" set BASIS_VERSION=v1_15_update2 +# Basis plugins aren't built on MSVC 2015 +- IF "%TARGET%" == "rt" set BASIS_VERSION=1.16.4 +- IF NOT EXIST %APPVEYOR_BUILD_FOLDER%\%BASIS_VERSION%.zip appveyor DownloadFile https://github.com/BinomialLLC/basis_universal/archive/%BASIS_VERSION%.zip +# Github removes the v prefix in the folder name. 7zip has no way to skip the +# topmost folder so strip it manually. +- set BASIS_FOLDER=%BASIS_VERSION% +- IF "%BASIS_FOLDER:~0,1%" == "v" set BASIS_FOLDER=%BASIS_FOLDER:~1% +- set BASIS_FOLDER=basis_universal-%BASIS_FOLDER% +- 7z x %BASIS_VERSION%.zip && ren %BASIS_FOLDER% basis_universal # We want to use the external Zstd instead of this - rmdir /s /q basis_universal\zstd diff --git a/package/ci/circleci.yml b/package/ci/circleci.yml index 644c94459..7857c22df 100644 --- a/package/ci/circleci.yml +++ b/package/ci/circleci.yml @@ -224,14 +224,17 @@ commands: ninja install install-basis: + parameters: + tag: + type: string + default: "v1_50_0_2" steps: - run: - name: Install Basis Universal + name: Install Basis Universal << parameters.tag >> command: | - export BASIS_VERSION=v1_15_update2 mkdir -p $HOME/basis_universal && cd $HOME/basis_universal - wget -nc https://github.com/BinomialLLC/basis_universal/archive/$BASIS_VERSION.tar.gz - tar --strip-components 1 -xzf $BASIS_VERSION.tar.gz + wget -nc https://github.com/BinomialLLC/basis_universal/archive/<< parameters.tag >>.tar.gz + tar --strip-components 1 -xzf << parameters.tag >>.tar.gz # We want to use the external Zstd instead of this rm -r zstd @@ -338,9 +341,14 @@ jobs: CMAKE_CXX_FLAGS: --coverage LCOV_EXTRA_OPTS: --gcov-tool /usr/bin/gcov-4.8 CONFIGURATION: Debug + # Testing building BasisImageConverter with OpenCL present on the system, + # but explicitly turned off via CMAKE_DISABLE_FIND_PACKAGE_OpenCL + DISABLE_OPENCL: "ON" steps: - install-base-linux: - extra: libfaad-dev libfreetype6-dev libjpeg-dev libopenal-dev libpng-dev libdevil-dev libharfbuzz-dev libassimp-dev libwebp-dev libzstd-dev wget + # We want the OpenCL headers and ICD loader libraries to test disabling + # find_package(), but don't need the actual ICD + extra: libfaad-dev libfreetype6-dev libjpeg-dev libopenal-dev libpng-dev libdevil-dev libharfbuzz-dev libassimp-dev libwebp-dev libzstd-dev ocl-icd-opencl-dev wget # Crashes or gets stuck with the default setting, only on GCC. 24 is not # enough, probably due to compatibility includes. - cap-ninja-jobs: @@ -348,7 +356,8 @@ jobs: - install-gcc-4_8 - install-cmake: version: "3.5.2" - - install-basis + - install-basis: + tag: "1.16.4" - install-meshoptimizer - install-libspng # In repos only since 20.04, but even then would probably hit the GCC 4.8 / @@ -374,8 +383,9 @@ jobs: # speed up. These are tested more than enough on other jobs, plus here we # have a fresher Ubuntu so we can take them directly from the repos. - install-base-linux-arm64: - extra: libfaad-dev libfreetype6-dev libjpeg-dev libopenal-dev libpng-dev libdevil-dev libharfbuzz-dev libassimp-dev libzstd-dev glslang-dev libopenexr-dev libwebp-dev spirv-tools - - install-basis + extra: libfaad-dev libfreetype6-dev libjpeg-dev libopenal-dev libpng-dev libdevil-dev libharfbuzz-dev libassimp-dev libzstd-dev ocl-icd-opencl-dev pocl-opencl-icd glslang-dev libopenexr-dev libwebp-dev spirv-tools + - install-basis: + tag: "1.16.4" - install-meshoptimizer - install-libspng - build: @@ -392,6 +402,7 @@ jobs: CONFIGURATION: Debug steps: - install-base-linux: + # Basis 1.15 doesn't support OpenCL, so those packages aren't needed extra: libfaad-dev libfreetype6-dev libjpeg-dev libopenal-dev libpng-dev libdevil-dev libharfbuzz-dev libassimp-dev libwebp-dev libzstd-dev wget # Crashes or gets stuck with the default setting, only on GCC. 24 is not # enough. @@ -400,7 +411,8 @@ jobs: - install-gcc-4_8 - install-cmake: version: "3.5.2" - - install-basis + - install-basis: + tag: "v1_15_update2" - install-meshoptimizer - install-libspng # These two are in repos only since 20.04, but even then would probably hit @@ -425,7 +437,7 @@ jobs: CONFIGURATION: Release steps: - install-base-linux: - extra: libfaad-dev libfreetype6-dev libjpeg-dev libopenal-dev libpng-dev libdevil-dev libharfbuzz-dev libassimp-dev libwebp-dev libzstd-dev wget + extra: libfaad-dev libfreetype6-dev libjpeg-dev libopenal-dev libpng-dev libdevil-dev libharfbuzz-dev libassimp-dev libwebp-dev libzstd-dev ocl-icd-opencl-dev pocl-opencl-icd wget # Crashes or gets stuck with the default setting, only on GCC - cap-ninja-jobs - install-gcc-4_8 @@ -455,6 +467,10 @@ jobs: BUILD_APPLICATIONS: "OFF" CMAKE_CXX_FLAGS: -fsanitize=address CONFIGURATION: Debug + # Basis, or the OpenCL ICD loader, or PoCL cause sanitizer errors when + # encoding with OpenCL. We're not installing any OpenCL packages, but + # better to be sure in case the image comes with it. + DISABLE_OPENCL: "ON" steps: - install-base-linux: extra: libfaad-dev libfreetype6-dev libjpeg-dev libopenal-dev libpng-dev libdevil-dev libharfbuzz-dev libassimp-dev libwebp-dev libzstd-dev wget @@ -488,6 +504,8 @@ jobs: BUILD_APPLICATIONS: "OFF" CMAKE_CXX_FLAGS: -fsanitize=thread CONFIGURATION: Debug + # See linux-sanitizers for why this is necessary + DISABLE_OPENCL: "ON" steps: - install-base-linux: extra: libfaad-dev libfreetype6-dev libjpeg-dev libopenal-dev libpng-dev libdevil-dev libharfbuzz-dev libassimp-dev libopenexr-dev libwebp-dev libzstd-dev wget @@ -510,6 +528,7 @@ jobs: environment: CMAKE_CXX_FLAGS: --coverage CONFIGURATION: Debug + DISABLE_OPENCL: "ON" steps: - install-base-macos: extra: faad2 harfbuzz assimp devil spirv-tools glslang openexr webp wget zstd libspng @@ -529,7 +548,8 @@ jobs: steps: - install-base-macos: extra: faad2 harfbuzz assimp devil spirv-tools glslang openexr webp wget zstd libspng - - install-basis + - install-basis: + tag: "1.16.4" - install-meshoptimizer - build: script: unix-desktop.sh diff --git a/package/ci/unix-desktop.sh b/package/ci/unix-desktop.sh index 46d8f1aaa..9c2feec4b 100755 --- a/package/ci/unix-desktop.sh +++ b/package/ci/unix-desktop.sh @@ -54,6 +54,7 @@ cmake .. \ -DCMAKE_INSTALL_PREFIX=$HOME/deps \ -DCMAKE_INSTALL_RPATH=$HOME/deps/lib \ -DCMAKE_BUILD_TYPE=$CONFIGURATION \ + -DCMAKE_DISABLE_FIND_PACKAGE_OpenCL=${DISABLE_OPENCL:-OFF} \ -DMAGNUM_WITH_ASSIMPIMPORTER=ON \ -DMAGNUM_WITH_ASTCIMPORTER=ON \ -DMAGNUM_WITH_BASISIMAGECONVERTER=ON \ diff --git a/package/homebrew/magnum-plugins.rb b/package/homebrew/magnum-plugins.rb index e728ab316..55020596b 100644 --- a/package/homebrew/magnum-plugins.rb +++ b/package/homebrew/magnum-plugins.rb @@ -30,13 +30,13 @@ class MagnumPlugins < Formula depends_on "webp" => :recommended def install - # Bundle Basis Universal, v1_15_update2 for HEAD builds, a commit that's + # Bundle Basis Universal, v1_50_0_2 for HEAD builds, a commit that's # before the UASTC support (which was not implemented yet) on 2020.06. # The repo has massive useless files in its history, so we're downloading # just a snapshot instead of a git clone. Also, WHY THE FUCK curl needs -L # and -o?! why can't it just work?! if build.head? - system "curl", "-L", "https://github.com/BinomialLLC/basis_universal/archive/v1_15_update2.tar.gz", "-o", "src/external/basis-universal.tar.gz" + system "curl", "-L", "https://github.com/BinomialLLC/basis_universal/archive/v1_50_0_2.tar.gz", "-o", "src/external/basis-universal.tar.gz" else system "curl", "-L", "https://github.com/BinomialLLC/basis_universal/archive/2f43afcc97d0a5dafdb73b4e24e123cf9687a418.tar.gz", "-o", "src/external/basis-universal.tar.gz" end diff --git a/src/MagnumPlugins/BasisImageConverter/BasisImageConverter.conf b/src/MagnumPlugins/BasisImageConverter/BasisImageConverter.conf index d2b8665d8..88cf2ed09 100644 --- a/src/MagnumPlugins/BasisImageConverter/BasisImageConverter.conf +++ b/src/MagnumPlugins/BasisImageConverter/BasisImageConverter.conf @@ -77,6 +77,10 @@ rdo_uastc_favor_simpler_modes_in_rdo_mode=true ktx2_uastc_supercompression=true ktx2_zstd_supercompression_level=6 +# OpenCL acceleration. Falls back to CPU encoding if OpenCL isn't supported or +# fails during encoding. +use_opencl=false + # Set various fields in the Basis file header userdata0=0 userdata1=0 diff --git a/src/MagnumPlugins/BasisImageConverter/BasisImageConverter.cpp b/src/MagnumPlugins/BasisImageConverter/BasisImageConverter.cpp index 406b84962..054ca3a26 100644 --- a/src/MagnumPlugins/BasisImageConverter/BasisImageConverter.cpp +++ b/src/MagnumPlugins/BasisImageConverter/BasisImageConverter.cpp @@ -46,6 +46,9 @@ #include #include #include +#if BASISU_LIB_VERSION >= 116 +#include +#endif namespace Magnum { namespace Trade { @@ -139,7 +142,11 @@ template Containers::Optional> c PARAM_CONFIG(quality_level, int); PARAM_CONFIG(perceptual, bool); PARAM_CONFIG(debug, bool); + #if BASISU_LIB_VERSION >= 116 + PARAM_CONFIG_FIX_NAME(validate_etc1s, bool, "validate"); + #else PARAM_CONFIG(validate, bool); + #endif PARAM_CONFIG(debug_images, bool); PARAM_CONFIG(compute_stats, bool); PARAM_CONFIG(compression_level, int); @@ -243,6 +250,16 @@ template Containers::Optional> c keyValue.m_key.append(reinterpret_cast(OrientationKey), sizeof(OrientationKey)); keyValue.m_key.append(reinterpret_cast(orientationValue), sizeof(orientationValue)); + /* OpenCL */ + #if BASISU_LIB_VERSION >= 116 + PARAM_CONFIG(use_opencl, bool); + + if(params.m_use_opencl && !basisu::opencl_is_available()) { + Warning{} << "Trade::BasisImageConverter::convertToData(): OpenCL not supported, falling back to CPU encoding"; + params.m_use_opencl = false; + } + #endif + /* Set various fields in the Basis file header */ PARAM_CONFIG(userdata0, int); PARAM_CONFIG(userdata1, int); @@ -257,7 +274,11 @@ template Containers::Optional> c /* If these are enabled, the library reads BMPs/JPGs/PNGs/TGAs from the filesystem and then writes basis files there also. DO NOT WANT. */ params.m_read_source_images = false; + #if BASISU_LIB_VERSION >= 150 + params.m_write_output_basis_or_ktx2_files = false; + #else params.m_write_output_basis_files = false; + #endif /* One image per slice. The base mip is in m_source_images, mip 1 and higher go into m_source_mipmap_images. */ const UnsignedInt numImages = Vector3i::pad(baseSize, 1).z(); @@ -359,6 +380,9 @@ template Containers::Optional> c /* process() will have printed additional error information to stderr */ Error{} << "Trade::BasisImageConverter::convertToData(): frontend processing failed"; return {}; + case basisu::basis_compressor::error_code::cECFailedFontendExtract: + Error{} << "Trade::BasisImageConverter::convertToData(): frontend extraction failed"; + return {}; case basisu::basis_compressor::error_code::cECFailedBackend: Error{} << "Trade::BasisImageConverter::convertToData(): encoding failed"; return {}; @@ -374,8 +398,11 @@ template Containers::Optional> c return {}; /* LCOV_EXCL_START */ - case basisu::basis_compressor::error_code::cECFailedFontendExtract: - /* This error will actually never be raised from basis_universal code */ + #if BASISU_LIB_VERSION >= 116 + case basisu::basis_compressor::error_code::cECFailedInitializing: + /* This error is returned by the parallel compression API if + basis_compressor::init() returns false */ + #endif case basisu::basis_compressor::error_code::cECFailedWritingOutput: /* We do not write any files, just data */ default: @@ -383,6 +410,15 @@ template Containers::Optional> c /* LCOV_EXCL_STOP */ } + #if BASISU_LIB_VERSION >= 116 + /* If OpenCL fails at any stage of encoding, Basis falls back to encoding + on the CPU. It also spams stderr but printing to Warning is still useful + for anyone parsing or redirecting it. */ + if(params.m_use_opencl && basis.get_opencl_failed()) { + Warning{} << "Trade::BasisImageConverter::convertToData(): OpenCL encoding failed, fell back to CPU encoding"; + } + #endif + const basisu::uint8_vec& out = params.m_create_ktx2_file ? basis.get_output_ktx2_file() : basis.get_output_basis_file(); Containers::Array fileData{NoInit, out.size()}; @@ -408,7 +444,17 @@ template Containers::Optional> c } void BasisImageConverter::initialize() { + #if BASISU_LIB_VERSION >= 116 + basisu::basisu_encoder_init(true); + #else basisu::basisu_encoder_init(); + #endif +} + +void BasisImageConverter::finalize() { + #if BASISU_LIB_VERSION >= 116 + basisu::basisu_encoder_deinit(); + #endif } BasisImageConverter::BasisImageConverter(Format format): _format{format} { diff --git a/src/MagnumPlugins/BasisImageConverter/BasisImageConverter.h b/src/MagnumPlugins/BasisImageConverter/BasisImageConverter.h index 7b2689f36..18e6c7cfe 100644 --- a/src/MagnumPlugins/BasisImageConverter/BasisImageConverter.h +++ b/src/MagnumPlugins/BasisImageConverter/BasisImageConverter.h @@ -90,8 +90,9 @@ libraries and is built if `MAGNUM_WITH_BASISIMAGECONVERTER` is enabled when building Magnum Plugins. To use as a dynamic plugin, load @cpp "BasisImageConverter" @ce via @ref Corrade::PluginManager::Manager. Current version of the plugin is tested against the -[`v1_15_update2` tag](https://github.com/BinomialLLC/basis_universal/tree/v1_15_update2), -but could possibly compile against newer versions as well. +[`v1_50_0_2`](https://github.com/BinomialLLC/basis_universal/tree/v1_50_0_2) +`1.16.4` and `v1_15_update2` tags, but could possibly compile against newer +versions as well. Additionally, if you're using Magnum as a CMake subproject, bundle the [magnum-plugins](https://github.com/mosra/magnum-plugins), @@ -122,6 +123,13 @@ add_subdirectory(magnum-plugins EXCLUDE_FROM_ALL) add_dependencies(your-app MagnumPlugins::BasisImageConverter) @endcode +When compiling Basis from source with `BASIS_UNIVERSAL_DIR`, Basis will be +built with OpenCL support if the [OpenCL package](https://cmake.org/cmake/help/v3.1/module/FindOpenCL.html) +is found. To build Basis without a hard dependency on OpenCL, pass +`-DCMAKE_DISABLE_FIND_PACKAGE_OpenCL=ON` to CMake, or @cmake set() @ce it +before the @cmake add_subdirectory() @ce call if using Magnum Plugins as a +subproject. + To use as a static plugin or as a dependency of another plugin with CMake, put [FindMagnumPlugins.cmake](https://github.com/mosra/magnum-plugins/blob/master/modules/FindMagnumPlugins.cmake) and [FindBasisUniversal.cmake](https://github.com/mosra/magnum-plugins/blob/master/modules/FindBasisUniversal.cmake) @@ -232,7 +240,7 @@ loaded while being already used from another thread. Basis compression can be configured to produce better quality or reduce encoding time. Configuration options are equivalent to parameters of the C++ encoder API in `basis_compressor`. The `basisu` tool options mostly match the -encoder API parameters and its [help text](https://github.com/BinomialLLC/basis_universal/blob/v1_15_update2/basisu_tool.cpp#L76) +encoder API parameters and its [help text](https://github.com/BinomialLLC/basis_universal/blob/v1_50_0_2/basisu_tool.cpp#L100) provides useful descriptions of most of the parameters, their ranges and the impact on quality/speed. The full form of the configuration is shown below: @@ -268,6 +276,16 @@ class MAGNUM_BASISIMAGECONVERTER_EXPORT BasisImageConverter: public AbstractImag */ static void initialize(); + /** + * @brief Finalize Basis encoder + * @m_since_latest + * + * If the class is instantiated directly (not through a plugin + * manager), this function has to be called explicitly after + * destroying the last instance. + */ + static void finalize(); + /** * @brief Default constructor * diff --git a/src/MagnumPlugins/BasisImageConverter/CMakeLists.txt b/src/MagnumPlugins/BasisImageConverter/CMakeLists.txt index 2616aa09d..955a384cc 100644 --- a/src/MagnumPlugins/BasisImageConverter/CMakeLists.txt +++ b/src/MagnumPlugins/BasisImageConverter/CMakeLists.txt @@ -63,7 +63,11 @@ target_include_directories(BasisImageConverter PUBLIC ${PROJECT_BINARY_DIR}/src # Turns #include "../zstd/zstd.h" into an actual external zstd.h include. # See the README in that directory for details. - ${PROJECT_SOURCE_DIR}/src/external/basis-zstd-include-uncrapifier/put-this-on-include-path) + ${PROJECT_SOURCE_DIR}/src/external/basis-uncrapifier/put-this-on-include-path) +# Adds empty definitions for unused image loading library functions. +# See the README in that directory for details. +target_sources(BasisImageConverter PRIVATE + ${PROJECT_SOURCE_DIR}/src/external/basis-uncrapifier/image-loading-stubs.cpp) target_link_libraries(BasisImageConverter PUBLIC Magnum::Trade PRIVATE BasisUniversal::Encoder) diff --git a/src/MagnumPlugins/BasisImageConverter/Test/BasisImageConverterTest.cpp b/src/MagnumPlugins/BasisImageConverter/Test/BasisImageConverterTest.cpp index 502f0dc8d..28eaa8d43 100644 --- a/src/MagnumPlugins/BasisImageConverter/Test/BasisImageConverterTest.cpp +++ b/src/MagnumPlugins/BasisImageConverter/Test/BasisImageConverterTest.cpp @@ -50,6 +50,8 @@ #include #include +#include /* BASISU_LIB_VERSION */ + #include "configure.h" namespace Magnum { namespace Trade { namespace Test { namespace { @@ -90,6 +92,8 @@ struct BasisImageConverterTest: TestSuite::Tester { void ktx(); void swizzle(); + void openCL(); + /* Explicitly forbid system-wide plugin dependencies */ PluginManager::Manager _converterManager{"nonexistent"}; @@ -343,6 +347,8 @@ BasisImageConverterTest::BasisImageConverterTest() { addInstancedTests({&BasisImageConverterTest::swizzle}, Containers::arraySize(SwizzleData)); + addTests({&BasisImageConverterTest::openCL}); + /* Pull in the AnyImageImporter dependency for image comparison */ _manager.load("AnyImageImporter"); /* Reset the plugin dir after so it doesn't load anything else from the @@ -1425,6 +1431,70 @@ void BasisImageConverterTest::swizzle() { TestSuite::Compare::around(Vector4i{2})); } +void BasisImageConverterTest::openCL() { + #if BASISU_LIB_VERSION < 116 + CORRADE_SKIP("OpenCL not used in version 1.15 yet."); + #endif + + if(_manager.loadState("PngImporter") == PluginManager::LoadState::NotFound) + CORRADE_SKIP("PngImporter plugin not found, cannot test contents"); + + Containers::Pointer pngImporter = _manager.instantiate("PngImporter"); + CORRADE_VERIFY(pngImporter->openFile(Utility::Path::join(BASISIMPORTER_TEST_DIR, "rgba-31x13.png"))); + Containers::Optional original = pngImporter->image2D(0); + CORRADE_VERIFY(original); + + Containers::Pointer converter = _converterManager.instantiate("BasisImageConverter"); + /* Default is off */ + CORRADE_COMPARE(converter->configuration().value("use_opencl"), false); + converter->configuration().setValue("use_opencl", true); + + std::ostringstream out; + Containers::Optional> compressedData; + { + Warning redirectWarning{&out}; + compressedData = converter->convertToData(*original); + } + + /* If built without OpenCL, converting falls back to CPU and still succeeds */ + #ifndef OpenCL_FOUND + CORRADE_WARN("OpenCL is not available."); + CORRADE_COMPARE(out.str(), "Trade::BasisImageConverter::convertToData(): OpenCL not supported, falling back to CPU encoding\n"); + #else + CORRADE_INFO("OpenCL is available."); + { + #ifdef _BASISIMAGECONVERTER_EXPECT_OPENCL_FRAMEWORK_FAILURE + CORRADE_EXPECT_FAIL("Apple OpenCL implementation is used, which likely doesn't work anymore."); + #endif + CORRADE_COMPARE(out.str(), ""); + } + #endif + CORRADE_VERIFY(compressedData); + + if(_manager.loadState("BasisImporter") == PluginManager::LoadState::NotFound) + CORRADE_SKIP("BasisImporter plugin not found, cannot test"); + + Containers::Pointer importer = _manager.instantiate("BasisImporterRGBA8"); + CORRADE_VERIFY(importer->openData(*compressedData)); + CORRADE_COMPARE(importer->image2DCount(), 1); + + /* There are moderately significant compression artifacts. With OpenCL + slightly higher so. */ + #ifndef OpenCL_FOUND + constexpr Float MaxThreshold = 81.0f; + constexpr Float MeanThreshold = 14.31f; + #else + constexpr Float MaxThreshold = 82.0f; + constexpr Float MeanThreshold = 14.709f; + #endif + + const auto result = importer->image2D(0); + CORRADE_VERIFY(result); + CORRADE_COMPARE_WITH(*result, + Utility::Path::join(BASISIMPORTER_TEST_DIR, "rgba-31x13.png"), + (DebugTools::CompareImageToFile{_manager, MaxThreshold, MeanThreshold})); +} + }}}} CORRADE_TEST_MAIN(Magnum::Trade::Test::BasisImageConverterTest) diff --git a/src/MagnumPlugins/BasisImageConverter/Test/CMakeLists.txt b/src/MagnumPlugins/BasisImageConverter/Test/CMakeLists.txt index 0b0aeefe8..5ff28594d 100644 --- a/src/MagnumPlugins/BasisImageConverter/Test/CMakeLists.txt +++ b/src/MagnumPlugins/BasisImageConverter/Test/CMakeLists.txt @@ -47,6 +47,11 @@ find_package(Magnum COMPONENTS AnyImageImporter) set(THREADS_PREFER_PTHREAD_FLAG TRUE) find_package(Threads REQUIRED) +# FindBasisUniversal, when building from source with BASIS_UNIVERSAL_DIR, +# builds with OpenCL support if it finds the package. Pass OpenCL_FOUND to +# configure.h so the test knows if OpenCL is supported. +find_package(OpenCL QUIET) + if(CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_ANDROID) set(BASISIMAGECONVERTER_TEST_OUTPUT_DIR "write") else() @@ -71,6 +76,13 @@ if(NOT MAGNUM_BASISIMAGECONVERTER_BUILD_STATIC) endif() endif() +# On Mac OpenCL can be found but the runtime implementation could fail, listing +# zero usable devices. The test assumes that OpenCL being found means encoding +# with OpenCL succeeds, let it know to expect failure in this case. +if(CORRADE_TARGET_APPLE AND OpenCL_LIBRARY MATCHES "System/Library/Frameworks/OpenCL\\.framework") + set(_BASISIMAGECONVERTER_EXPECT_OPENCL_FRAMEWORK_FAILURE ON) +endif() + # First replace ${} variables, then $<> generator expressions configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/configure.h.in) @@ -86,7 +98,16 @@ corrade_add_test(BasisImageConverterTest BasisImageConverterTest.cpp FILES ${PROJECT_SOURCE_DIR}/src/MagnumPlugins/BasisImporter/Test/rgb-63x27.png ${PROJECT_SOURCE_DIR}/src/MagnumPlugins/BasisImporter/Test/rgba-63x27.png) -target_include_directories(BasisImageConverterTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/$) +target_include_directories(BasisImageConverterTest PRIVATE + ${CMAKE_CURRENT_BINARY_DIR}/$ + # The test needs BASISU_LIB_VERSION from basisu_comp.h + ${BasisUniversalEncoder_INCLUDE_DIR}) +# BasisUniversalEncoder_DEFINITIONS isn't exported by find_package, so we need +# to grab it from the target +get_target_property(BasisUniversalEncoder_DEFINITIONS BasisUniversal::Encoder + INTERFACE_COMPILE_DEFINITIONS) +set_property(TARGET BasisImageConverterTest APPEND PROPERTY + COMPILE_DEFINITIONS ${BasisUniversalEncoder_DEFINITIONS}) if(MAGNUM_BASISIMAGECONVERTER_BUILD_STATIC) target_link_libraries(BasisImageConverterTest PRIVATE BasisImageConverter) if(Magnum_AnyImageImporter_FOUND) diff --git a/src/MagnumPlugins/BasisImageConverter/Test/configure.h.cmake b/src/MagnumPlugins/BasisImageConverter/Test/configure.h.cmake index dc0b13554..2d6bdc8ac 100644 --- a/src/MagnumPlugins/BasisImageConverter/Test/configure.h.cmake +++ b/src/MagnumPlugins/BasisImageConverter/Test/configure.h.cmake @@ -28,5 +28,7 @@ #cmakedefine BASISIMAGECONVERTER_PLUGIN_FILENAME "${BASISIMAGECONVERTER_PLUGIN_FILENAME}" #cmakedefine BASISIMPORTER_PLUGIN_FILENAME "${BASISIMPORTER_PLUGIN_FILENAME}" #cmakedefine STBIMAGEIMPORTER_PLUGIN_FILENAME "${STBIMAGEIMPORTER_PLUGIN_FILENAME}" +#cmakedefine OpenCL_FOUND +#cmakedefine _BASISIMAGECONVERTER_EXPECT_OPENCL_FRAMEWORK_FAILURE #define BASISIMPORTER_TEST_DIR "${BASISIMPORTER_TEST_DIR}" #define BASISIMAGECONVERTER_TEST_OUTPUT_DIR "${BASISIMAGECONVERTER_TEST_OUTPUT_DIR}" diff --git a/src/MagnumPlugins/BasisImporter/BasisImporter.cpp b/src/MagnumPlugins/BasisImporter/BasisImporter.cpp index b4eb5a6f6..70c23e249 100644 --- a/src/MagnumPlugins/BasisImporter/BasisImporter.cpp +++ b/src/MagnumPlugins/BasisImporter/BasisImporter.cpp @@ -137,8 +137,11 @@ template<> struct ConfigurationValue namespace Magnum { namespace Trade { struct BasisImporter::State { + /* Basis 1.16 got rid of global selector palettes */ + #if BASISD_LIB_VERSION < 116 /* There is only this type of codebook */ basist::etc1_global_selector_codebook codebook; + #endif /* One transcoder for each supported file type, and of course they have wildly different interfaces. ktx2_transcoder is only defined if @@ -172,8 +175,11 @@ struct BasisImporter::State { bool noTranscodeFormatWarningPrinted = false; bool yFlipNotPossibleWarningPrinted = false; - explicit State(): codebook(basist::g_global_selector_cb_size, - basist::g_global_selector_cb) {} + explicit State() + #if BASISD_LIB_VERSION < 116 + : codebook(basist::g_global_selector_cb_size, basist::g_global_selector_cb) + #endif + {} }; void BasisImporter::initialize() { @@ -267,7 +273,11 @@ void BasisImporter::doOpenData(Containers::Array&& data, DataFlags dataFla #if BASISD_SUPPORT_KTX2 if(isKTX2) { - state->ktx2Transcoder.emplace(&state->codebook); + state->ktx2Transcoder.emplace( + #if BASISD_LIB_VERSION < 116 + &state->codebook + #endif + ); /* init() handles all the validation checks, there's no extra function for that */ @@ -340,7 +350,11 @@ void BasisImporter::doOpenData(Containers::Array&& data, DataFlags dataFla #endif { /* .basis file */ - state->basisTranscoder.emplace(&state->codebook); + state->basisTranscoder.emplace( + #if BASISD_LIB_VERSION < 116 + &state->codebook + #endif + ); if(!state->basisTranscoder->validate_header(state->in.data(), state->in.size())) { Error{} << "Trade::BasisImporter::openData(): invalid basis header"; diff --git a/src/MagnumPlugins/BasisImporter/BasisImporter.h b/src/MagnumPlugins/BasisImporter/BasisImporter.h index 60628f077..9aca009d2 100644 --- a/src/MagnumPlugins/BasisImporter/BasisImporter.h +++ b/src/MagnumPlugins/BasisImporter/BasisImporter.h @@ -97,8 +97,9 @@ This plugin depends on the @ref Trade and [Basis Universal](https://github.com/b libraries and is built if `MAGNUM_WITH_BASISIMPORTER` is enabled when building Magnum Plugins. To use as a dynamic plugin, load @cpp "BasisImporter" @ce via @ref Corrade::PluginManager::Manager. Current version of the plugin is tested -against the [`v1_15_update2` tag](https://github.com/BinomialLLC/basis_universal/tree/v1_15_update2), -but could possibly compile against newer versions as well. +against the [`v1_50_0_2`](https://github.com/BinomialLLC/basis_universal/tree/v1_50_0_2) +`1.16.4` and `v1_15_update2` tags, but could possibly compile against newer +versions as well. Additionally, if you're using Magnum as a CMake subproject, bundle the [magnum-plugins](https://github.com/mosra/magnum-plugins), diff --git a/src/MagnumPlugins/BasisImporter/CMakeLists.txt b/src/MagnumPlugins/BasisImporter/CMakeLists.txt index 7b29fdafc..e9de1b64f 100644 --- a/src/MagnumPlugins/BasisImporter/CMakeLists.txt +++ b/src/MagnumPlugins/BasisImporter/CMakeLists.txt @@ -65,7 +65,7 @@ target_include_directories(BasisImporter ${PROJECT_BINARY_DIR}/src # Turns #include "../zstd/zstd.h" into an actual external zstd.h include. # See the README in that directory for details. - ${PROJECT_SOURCE_DIR}/src/external/basis-zstd-include-uncrapifier/put-this-on-include-path) + ${PROJECT_SOURCE_DIR}/src/external/basis-uncrapifier/put-this-on-include-path) target_link_libraries(BasisImporter PUBLIC Magnum::Trade PRIVATE BasisUniversal::Transcoder) diff --git a/src/external/basis-uncrapifier/README.md b/src/external/basis-uncrapifier/README.md new file mode 100644 index 000000000..563060a59 --- /dev/null +++ b/src/external/basis-uncrapifier/README.md @@ -0,0 +1,38 @@ +### Zstd include path workaround + +The `zstd` and `put-this-on-include-path` directories exist in order to make +this Basis Universal insanity + +```cpp +#include "../zstd/zstd.h" +``` + +actually include an external Zstd installation. I.e., an up-to-date version +with all SECURITY FIXES and OPTIMIZATIONS that happened since the original file +was put in the Basis repository in April 2021. The `put-this-on-include-path/` +subdirectory is added to the include path, which then makes `../zstd/zstd.h` +point to the `zstd.h` file in the `zstd/` subdirectory here. That file then +uses `#include ` (with `<>` instead of `""`) to include the external +`zstd.h` instead of the bundled file. + +The real fix is in https://github.com/BinomialLLC/basis_universal/pull/228, +waiting to get some attention since December 2021. Haha. + +### Image loading stubs + +The Basis encoder unconditionally includes code for loading image files from +disk (.png, .exr, etc.), but BasisImageConverter always supplies image data +in memory. So the code path using the disk loading is never run, wasting size +and increasing compile time needlessly. + +There's no way to remove it through a preprocessor define so instead all +required functions are provided as empty stubs in image-loading-stubs.cpp. + +The issue is tracked at https://github.com/BinomialLLC/basis_universal/issues/269. + +The following library sources are stubbed: +jpgd.cpp +apg_bmp.c // Removed in 1.16 +lodepng.cpp // Removed in 1.16 +pvpngreader.cpp // Added in 1.16 +3rdparty/tinyexr.cpp // Added in 1.50 diff --git a/src/external/basis-uncrapifier/image-loading-stubs.cpp b/src/external/basis-uncrapifier/image-loading-stubs.cpp new file mode 100644 index 000000000..6e1de4f0a --- /dev/null +++ b/src/external/basis-uncrapifier/image-loading-stubs.cpp @@ -0,0 +1,122 @@ +#include + +#include +#include + +/* jpgd, present in all supported versions */ + +namespace jpgd { + +unsigned char* decompress_jpeg_image_from_file(const char*, int*, int*, int*, int, uint32_t) { + CORRADE_INTERNAL_ASSERT_UNREACHABLE(); +} + +} + +/* apg_bmp, removed in 1.16 */ + +extern "C" { + +unsigned char* apg_bmp_read(const char*, int*, int*, unsigned int*) { + CORRADE_INTERNAL_ASSERT_UNREACHABLE(); +} + +void apg_bmp_free(unsigned char*) { + CORRADE_INTERNAL_ASSERT_UNREACHABLE(); +} + +} + +/* lodepng, removed in 1.16 */ + +/* Can't forward-declare since it has no explicit underlying type */ +typedef enum LodePNGColorType { + LCT_GREY = 0, + LCT_RGB = 2, + LCT_PALETTE = 3, + LCT_GREY_ALPHA = 4, + LCT_RGBA = 6 +} LodePNGColorType; + +typedef struct LodePNGState LodePNGState; + +namespace lodepng { + +class State { +public: + State(); + virtual ~State(); +}; + +State::State() { + CORRADE_INTERNAL_ASSERT_UNREACHABLE(); +} + +State::~State() { + CORRADE_INTERNAL_ASSERT_UNREACHABLE(); +} + +unsigned decode(std::vector&, unsigned&, unsigned&, const unsigned char*, size_t, LodePNGColorType, unsigned) { + CORRADE_INTERNAL_ASSERT_UNREACHABLE(); +} + +unsigned encode(std::vector&, const unsigned char*, unsigned, unsigned, LodePNGColorType, unsigned) { + CORRADE_INTERNAL_ASSERT_UNREACHABLE(); +} + +unsigned load_file(std::vector&, const std::string&) { + CORRADE_INTERNAL_ASSERT_UNREACHABLE(); +} + +unsigned save_file(const std::vector&, const std::string&) { + CORRADE_INTERNAL_ASSERT_UNREACHABLE(); +} + +} + +unsigned lodepng_inspect(unsigned*, unsigned*, LodePNGState*, const unsigned char*, size_t) { + CORRADE_INTERNAL_ASSERT_UNREACHABLE(); +} + +/* pvpng, added in 1.16 */ + +namespace pv_png { + +void* load_png(const void*, size_t, uint32_t, uint32_t&, uint32_t&, uint32_t&) { + CORRADE_INTERNAL_ASSERT_UNREACHABLE(); +} + +} + +/* tinyexr, added in 1.50 */ + +extern "C" { + +int LoadEXRWithLayer(float **, int*, int*, const char*, const char*, const char**, int*) { + CORRADE_INTERNAL_ASSERT_UNREACHABLE(); +} + +typedef struct TEXRHeader EXRHeader; +typedef struct TEXRImage EXRImage; + +void InitEXRHeader(EXRHeader*) { + CORRADE_INTERNAL_ASSERT_UNREACHABLE(); +} + +void InitEXRImage(EXRImage*) { + CORRADE_INTERNAL_ASSERT_UNREACHABLE(); +} + +void FreeEXRErrorMessage(const char*) { + CORRADE_INTERNAL_ASSERT_UNREACHABLE(); +} + +int SaveEXRImageToFile(const EXRImage*, const EXRHeader*, const char*, const char**) { + CORRADE_INTERNAL_ASSERT_UNREACHABLE(); +} + +int LoadEXRFromMemory(float**, int*, int*, const unsigned char*, size_t, const char**) { + CORRADE_INTERNAL_ASSERT_UNREACHABLE(); +} + +} diff --git a/src/external/basis-zstd-include-uncrapifier/put-this-on-include-path/dummy b/src/external/basis-uncrapifier/put-this-on-include-path/dummy similarity index 100% rename from src/external/basis-zstd-include-uncrapifier/put-this-on-include-path/dummy rename to src/external/basis-uncrapifier/put-this-on-include-path/dummy diff --git a/src/external/basis-zstd-include-uncrapifier/zstd/zstd.h b/src/external/basis-uncrapifier/zstd/zstd.h similarity index 100% rename from src/external/basis-zstd-include-uncrapifier/zstd/zstd.h rename to src/external/basis-uncrapifier/zstd/zstd.h diff --git a/src/external/basis-zstd-include-uncrapifier/README.md b/src/external/basis-zstd-include-uncrapifier/README.md deleted file mode 100644 index 433fcb2a3..000000000 --- a/src/external/basis-zstd-include-uncrapifier/README.md +++ /dev/null @@ -1,16 +0,0 @@ -These directories exist in order to make this Basis Universal insanity - -```cpp -#include "../zstd/zstd.h" -``` - -actually include an external Zstd installation. I.e., an up-to-date version -with all SECURITY FIXES and OPTIMIZATIONS that happened since the original file -was put in the Basis repository in April 2021. The `put-this-on-include-path/` -subdirectory is added to the include path, which then makes `../zstd/zstd.h` -point to the `zstd.h` file in the `zstd/` subdirectory here. That file then -uses `#include ` (with `<>` instead of `""`) to include the external -`zstd.h` instead of the bundled file. - -The real fix is in https://github.com/BinomialLLC/basis_universal/pull/228, -waiting to get some attention since December 2021. Haha.