Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Basis plugins to 1.15 #112

Closed
wants to merge 75 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
3bc79d8
Basis{ImageConverter,Importer}: update to basis_universal v1_15_update2
pezcode Oct 16, 2021
d83eb5b
BasisImporter: import KTX2 files
pezcode Oct 16, 2021
09f13dd
BasisImporter: import sRGB images with the appropriate format
pezcode Oct 16, 2021
75e47e7
BasisImporter: handle missing zstd gracefully
pezcode Oct 17, 2021
7b9d26a
BasisImporter: add KtxImporter alias
pezcode Oct 17, 2021
aec8e3d
BasisImageConverter: support sRGB formats
pezcode Oct 17, 2021
564f380
BasisImageConverter: support writing KTX2 files
pezcode Oct 17, 2021
256efbc
BasisImageConverter: support user-supplied mip levels
pezcode Oct 17, 2021
c603aa5
BasisImporter: import array/cube/3D images
pezcode Oct 17, 2021
e7c5843
BasisImporter: test KTX2 and sRGB support
pezcode Oct 18, 2021
b2c3c84
BasisImporter: test unsupported target format error
pezcode Oct 18, 2021
f315885
BasisImageConverter: write KTX2 orientation metadata
pezcode Oct 18, 2021
38abfea
BasisImageConverter: test KTX2 export
pezcode Oct 18, 2021
7cc5707
BasisImageConverter: fix sRGB format
pezcode Oct 18, 2021
f1c5d05
BasisImageConverter: remove separate_rg_to_color_alpha
pezcode Oct 18, 2021
015f24e
BasisImageConverter: test invalid swizzle values
pezcode Oct 18, 2021
3c4852d
BasisImageConverter: expose UASTC options
pezcode Oct 18, 2021
426da44
BasisImageConverter: fix user-supplied mipmaps
pezcode Oct 18, 2021
2bb860f
BasisImageConverter: test user-supplied mipmaps
pezcode Oct 18, 2021
1bd045b
BasisImageConverter: update image error thresholds
pezcode Oct 18, 2021
a4348cc
BasisImporter: import 3D images with mipmaps as 2D array textures
pezcode Oct 19, 2021
6f479a7
BasisImporter: fix mip level count
pezcode Oct 19, 2021
1b78acf
BasisImporter: fix cubemap array textures
pezcode Oct 19, 2021
85ffabb
BasisImporter: test all image types
pezcode Oct 19, 2021
85e46e7
BasisImporter: test start_transcoding failure for KTX2 files
pezcode Oct 19, 2021
d29a013
BasisImporter: document image types and mipmaps
pezcode Oct 19, 2021
d85bfb1
BasisImporter: mention sRGB versions of target formats
pezcode Oct 19, 2021
2d3a38e
BasisImporter: import video as separate images
pezcode Oct 21, 2021
42ea61f
BasisImporter: test opening KTX2 and basis files in the same instance
pezcode Oct 21, 2021
57865fe
BasisImageConverter: don't spam stdout with basisu debug output unles…
pezcode Oct 21, 2021
e65f438
BasisImageConverter: determine mip_gen option from the number of user…
pezcode Oct 21, 2021
a88304b
Basis{ImageConverter,Importer}: set big endian flag for basisu
pezcode Oct 21, 2021
9d7a1e1
BasisImageConverter: fix mip generation
pezcode Oct 21, 2021
fc64838
BasisImageConverter: test automatic mipgen and perceptual options
pezcode Oct 21, 2021
cc933cf
BasisImageConverter: test sRGB detection
pezcode Oct 21, 2021
d6c9dc7
BasisImporter: fix I-frame detection for KTX2 + UASTC and test it
pezcode Oct 22, 2021
2db78c8
BasisImporter: test UASTC import
pezcode Oct 22, 2021
b63e2e5
BasisImporter: validate texture type constraints
pezcode Oct 22, 2021
2ce8853
BasisImporter: print a more helpful error message if format support i…
pezcode Oct 22, 2021
0542a35
BasisImporter: comments++
pezcode Oct 22, 2021
cbb05c7
BasisImporter: cleanup
pezcode Oct 22, 2021
25bdbc3
BasisImporter: update test file conversion script
pezcode Oct 22, 2021
5cc3bbf
BasisImageConverter: add missing config options, update defaults
pezcode Oct 22, 2021
e8b48ce
BasisImageConverter: cleanup
pezcode Oct 22, 2021
3cd27aa
BasisImageConverter: warn if mip_gen config option is overridden
pezcode Oct 24, 2021
7935c91
BasisImporter: import 3D textures as 2D array textures
pezcode Oct 24, 2021
3626ca2
BasisImporter: get rid of ScopeGuard
pezcode Oct 24, 2021
36af4d8
BasisImporter: remove Bc7RGB target format
pezcode Oct 24, 2021
ed50c26
BasisImporter: mention supported basis_universal version in the docs
pezcode Oct 24, 2021
3ec1fc6
BasisImporter: cleanup
pezcode Oct 24, 2021
3d9914b
BasisImporter: mention how to turn off features/formats for smaller b…
pezcode Oct 24, 2021
d6eb04b
BasisImporter: remove KtxImporter alias
pezcode Oct 24, 2021
6f41d58
BasisImageConverter: handle KTX2 conversion through plugin alias and …
pezcode Oct 24, 2021
68bcaa9
BasisImageConverter: clearly mention that config options follow the C…
pezcode Oct 24, 2021
0f295d5
BasisImageConverter: mention supported basis_universal version in the…
pezcode Oct 24, 2021
a2e9d49
Basis{Importer,ImageConverter}: enable CMake C language support in th…
pezcode Oct 24, 2021
6594d79
Basis{Importer,ImageConverter}: add copyright notice
pezcode Oct 24, 2021
b06f6e9
BasisImageConverter: comments++
pezcode Oct 24, 2021
3e03f27
BasisImageConverter: cleanup tests
pezcode Oct 24, 2021
fef35be
Basis{Importer,ImageConverter}: fix AppVeyor basis_universal extraction
pezcode Oct 24, 2021
d191233
Basis{Importer,ImageConverter}: fix find module for CI
pezcode Oct 24, 2021
ebfb048
BasisImporter: remove all remaining traces of Bc7RGB
pezcode Oct 25, 2021
e97ed9c
BasisImporter: fix array view cast on GCC 4.8, hopefully
pezcode Oct 25, 2021
08f9abd
Basis{Importer,ImageConverter}: restrict and clarify enable_language(C)
pezcode Oct 25, 2021
be76be9
Basis{Importer,ImageConverter}: fix AppVeyor basis_universal extracti…
pezcode Oct 25, 2021
d7c50ca
Merge remote-tracking branch 'upstream/master' into basis-1_15
pezcode Oct 25, 2021
319a050
BasisImporter: fix test image treshold
pezcode Oct 25, 2021
4ff0737
Basis{Importer,ImageConverter}: don't test for endianness on CMake < 3.9
pezcode Oct 25, 2021
a5aca85
Basis{Importer,ImageConverter}: fix basis_universal download, 3rd att…
pezcode Oct 25, 2021
4597fb1
Basis{Importer,ImageConverter}: don't use VERSION_GREATER_EQUAL
pezcode Oct 25, 2021
1ac0592
Basis{Importer,ImageConverter}: fix basis_universal SHA1 in archlinux…
pezcode Oct 25, 2021
4f791ed
BasisImporter: oops
pezcode Oct 25, 2021
439a883
BasisImageConverter: accept multiple levels in doOpenFile
pezcode Oct 27, 2021
94b1798
BasisImporter: document two-channel format source
pezcode Oct 27, 2021
d1ef9ab
BasisImageConverter: disable implicit swizzle if the user supplied th…
pezcode Oct 27, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/building-plugins.dox
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ enable them, do the following:

- For @ref Trade::BasisImporter "BasisImporter" or
@ref Trade::BasisImageConverter "BasisImageConverter", [download commit
`2f43afcc` of the Basis Universal repo](https://github.com/BinomialLLC/basis_universal/archive/2f43afcc97d0a5dafdb73b4e24e123cf9687a418.tar.gz),
`77b7df8e` of the Basis Universal repo](https://github.com/BinomialLLC/basis_universal/archive/77b7df8e5df3532a42ef3c76de0c14cc005d0f65.tar.gz),
extract it into `src/external/basis-universal` (note the dash instead of an
underscore) and set `WITH_BASISIMPORTER` / `WITH_BASISIMAGECONVERTER` to
`ON` in `package/debian/rules`
Expand Down
75 changes: 71 additions & 4 deletions modules/FindBasisUniversal.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019,
# 2020, 2021 Vladimír Vondruš <[email protected]>
# Copyright © 2019 Jonathan Hale <[email protected]>
# Copyright © 2021 Pablo Escobar <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
Expand All @@ -51,13 +52,50 @@
# DEALINGS IN THE SOFTWARE.
#

# Several places in this find module assume that the C language is enabled:
# - test_big_endian() assumes C is enabled, configuration fails without.
# CMake says to call enable_language() in the highest directory using the
# language, so we can't do that here.
# - both the transcoder and encoder link to .c files that would just not be
# compiled without the language enabled, or the source file language being
# changed to CXX
# Currently both BasisImporter and BasisImageConverter call enable_language(C).

list(FIND BasisUniversal_FIND_COMPONENTS "Encoder" _index)
if(${_index} GREATER -1)
list(APPEND BasisUniversal_FIND_COMPONENTS "Transcoder")
list(REMOVE_DUPLICATES BasisUniversal_FIND_COMPONENTS)
endif()

# Figure out endianness for Basis Universal. test_big_endian() fails on
# Emscripten, but WebAssembly is always little-endian. On CMake 3.8 and below,
# test_big_endian() requires C support which breaks compilation in funny ways
# (see comment below) so we skip that.
if(NOT CORRADE_TARGET_EMSCRIPTEN AND NOT CMAKE_VERSION VERSION_LESS 3.9)
include(TestBigEndian)
test_big_endian(BIG_ENDIAN)
endif()

macro(_basis_setup_source_file source)
# Compile any .c files as C++. Otherwise the files are just ignored because
# the C language is not enabled by project() or enable_language(). Calling
# enable_language in a find module is not a good idea, and even if we do
# this higher up in one of the Basis* plugins, some compilers will require
# the C99 standard being enabled and/or complain about -std=c++11 (done by
# CORRADE_CXX_STANDARD) being set on a C compiler. Doing both (enabling C
# and setting LANGUAGE CXX) still results in static libraries compiling
# with C and producing above-mentioned errors, possibly to do with
# LINKER_LANGUAGE. What a horrible mess.
set_property(SOURCE ${source} PROPERTY LANGUAGE
CXX)

# Tell Basis if we're on a big endian system. It currently doesn't figure
# this out by itself.
if(BIG_ENDIAN)
set_property(SOURCE ${source} APPEND PROPERTY COMPILE_DEFINITIONS
BASISD_IS_BIG_ENDIAN=1)
endif()

# Basis shouldn't override the MSVC iterator debug level as it would make
# it inconsistent with the rest of the code
if(CORRADE_TARGET_WINDOWS)
Expand All @@ -73,7 +111,7 @@ macro(_basis_setup_source_file source)
" -w")
# Clang supports -w, but it doesn't have any effect on all the
# -Wall -Wold-style-cast etc flags specified before. -Wno-everything does.
# Funnily enough this is not an issue on Emscripten.;
# Funnily enough this is not an issue on Emscripten.
elseif(CMAKE_CXX_COMPILER_ID MATCHES "(Apple)?Clang" AND NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
set_property(SOURCE ${source} APPEND_STRING PROPERTY COMPILE_FLAGS
" -Wno-everything")
Expand Down Expand Up @@ -125,20 +163,30 @@ foreach(_component ${BasisUniversal_FIND_COMPONENTS})
"Set BASIS_UNIVERSAL_DIR to the root of a directory containing basis_universal source.")
endif()

# @todo Disable file loading at compile time and get rid of the
# BMP/JPG/PNG libraries, we don't use those at all. Hopefully
# this becomes a preprocessor define upstream at some point.
# Alternatively, look into creating stubs for the library
# functions used by basis_universal.
set(BasisUniversalEncoder_SOURCES
${BasisUniversalEncoder_DIR}/apg_bmp.c
pezcode marked this conversation as resolved.
Show resolved Hide resolved
${BasisUniversalEncoder_DIR}/basisu_astc_decomp.cpp
${BasisUniversalEncoder_DIR}/basisu_backend.cpp
${BasisUniversalEncoder_DIR}/basisu_basis_file.cpp
${BasisUniversalEncoder_DIR}/basisu_bc7enc.cpp
${BasisUniversalEncoder_DIR}/basisu_comp.cpp
${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)

foreach(_file ${BasisUniversalEncoder_SOURCES})
Expand Down Expand Up @@ -173,8 +221,6 @@ foreach(_component ${BasisUniversal_FIND_COMPONENTS})
# The rest is documented in the BasisImageConverter plugin 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)
Expand Down Expand Up @@ -227,6 +273,27 @@ foreach(_component ${BasisUniversal_FIND_COMPONENTS})
set(BasisUniversalTranscoder_SOURCES
${BasisUniversalTranscoder_DIR}/basisu_transcoder.cpp)

set(BasisUniversalTranscoder_DEFINITIONS "BASISU_NO_ITERATOR_DEBUG_LEVEL")

# Not linking to zstddeclib.c because together with Encoder
# linking to zstd.c this would lead to duplicate symbol
# errors.
# @todo Unused functions *should* be removed by LTO but is
# there a better way?
find_path(BasisUniversalZstd_DIR NAMES zstd.c
HINTS "${BASIS_UNIVERSAL_DIR}/zstd" "${BASIS_UNIVERSAL_DIR}"
NO_CMAKE_FIND_ROOT_PATH)
if(BasisUniversalZstd_DIR)
list(APPEND BasisUniversalTranscoder_SOURCES
${BasisUniversalZstd_DIR}/zstd.c)
else()
# If zstd wasn't found, disable Zstandard supercompression
# support at compile time. The zstd.h include is hidden
# behind this definition as well.
list(APPEND BasisUniversalTranscoder_DEFINITIONS
"BASISD_SUPPORT_KTX2_ZSTD=0")
endif()
Comment on lines +278 to +295
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sigh... let's hope the unused functions get indeed thrown away by the linker. If the Emscripten binary size inflates a lot, we can reconsider.

One option would be to have the Encoder and Transcoder independent, but that only moves the problem one level up, to any binary that links to both of them (i.e., the BasisImageConverterTest). So that won't really help.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we turned BasisUniversal::{Encoder, Decoder} into a static library, would there be a way to make this work? Or is that bad style for a find module?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK throwing away duplicates from static libraries generally works only at the object file level -- i.e., if there would be zstdenclib.c and zstddeclib.c and then BasisUniversalTranscoder.a would contain zstddeclib.o while BasisUniversalEncoder.a having both zstdenclib.o and zstddeclib.o, then linking both to a final executable would make the linker pick only one of the two *.o copies. (And I think that could maybe work even without going through static libraries, if the *.o files get directly put into the final executable the linker could prune duplicates as well.)

But if zstddeclib.o contains symbols that are also in zstd.o, I don't think linkers can do much... except if those would be marked as weak, which is not a thing on Windows...

Another idea I had was to build & bundle our own zstdenclib.c using the same script zstd.c was made with, except for leaving out the stuff that's already in zstddeclib.c. But at that point I feel it's a much better option to just depend on the real zstd library instead, like i said below. That way integrating upstream bugfixes and improvements is also much easier, compared to relying on a bundled file that might just get upgraded never again.

But ... leave that for later. Unless @Squareys sees it's really making wasm binaries twice as huge, I don't think it's a priority :)


foreach(_file ${BasisUniversalTranscoder_SOURCES})
_basis_setup_source_file(${_file})
endforeach()
Expand All @@ -243,7 +310,7 @@ foreach(_component ${BasisUniversal_FIND_COMPONENTS})
set_property(TARGET BasisUniversal::Transcoder APPEND PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${BasisUniversalTranscoder_INCLUDE_DIR})
set_property(TARGET BasisUniversal::Transcoder APPEND PROPERTY
INTERFACE_COMPILE_DEFINITIONS "BASISU_NO_ITERATOR_DEBUG_LEVEL")
INTERFACE_COMPILE_DEFINITIONS ${BasisUniversalTranscoder_DEFINITIONS})
set_property(TARGET BasisUniversal::Transcoder APPEND PROPERTY
INTERFACE_SOURCES "${BasisUniversalTranscoder_SOURCES}")
endif()
Expand Down
8 changes: 3 additions & 5 deletions package/archlinux/magnum-plugins-git/PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Author: mosra <[email protected]>
pkgname=magnum-plugins-git
pkgver=2020.06.r119.g15b8cac9
_basis_pkgver=2f43afcc97d0a5dafdb73b4e24e123cf9687a418
_basis_pkgver=1_15_update2
pkgrel=1
pkgdesc="Plugins for the Magnum C++11/C++14 graphics engine (Git version)"
arch=('i686' 'x86_64')
Expand All @@ -12,11 +12,9 @@ makedepends=('cmake' 'git' 'ninja')
provides=('magnum-plugins')
conflicts=('magnum-plugins')
source=("git+git://github.com/mosra/magnum-plugins.git"
# A commit that's before the UASTC support (which is not implemented
# yet, because latest versions crash even on trivial tests)
"https://github.com/BinomialLLC/basis_universal/archive/${_basis_pkgver}.tar.gz")
"https://github.com/BinomialLLC/basis_universal/archive/v${_basis_pkgver}.tar.gz")
sha1sums=('SKIP'
'b8d3995292c2c0bbedea943250087b0a9a92ca96')
'b9615d48ebfc62a53f333ebf8a582558a058b0e9')

pkgver() {
cd "$srcdir/${pkgname%-git}"
Expand Down
9 changes: 3 additions & 6 deletions package/ci/appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,9 @@ install:
- 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=8565af680d1bd2ad56ab227ca7d96c56dfbe93ed
- IF NOT EXIST %APPVEYOR_BUILD_FOLDER%\basis_universal-%BASIS_VERSION%.zip appveyor DownloadFile https://github.com/BinomialLLC/basis_universal/archive/%BASIS_VERSION%.zip
- 7z x %BASIS_VERSION%.zip && ren basis_universal-%BASIS_VERSION% basis_universal
# https://github.com/BinomialLLC/basis_universal/pull/106
# TODO: remove once we update to UASTC-enabled Basis
- bash -c "cd basis_universal && patch -p1 < ../package/ci/basisu-msvc2019-16.6.patch"
- 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

# SPIRV-Tools, for MSVC 2019, 2017 and clang-cl only
# This line REQUIRES the COMPILER variable to be set on rt builds, otherwise it
Expand Down
12 changes: 0 additions & 12 deletions package/ci/basisu-msvc2019-16.6.patch

This file was deleted.

3 changes: 1 addition & 2 deletions package/ci/circleci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,8 @@ commands:
steps:
- run:
name: Install Basis Universal
# Version before UASTC is a thing, as our tests crash with the new one
command: |
export BASIS_VERSION=8565af680d1bd2ad56ab227ca7d96c56dfbe93ed
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
Expand Down
2 changes: 1 addition & 1 deletion package/ci/travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ install:
- if [ "$TRAVIS_OS_NAME" == "linux" ] && [ "$TARGET" == "desktop-sanitizers" ]; then cd $HOME ; wget https://ci.magnum.graphics/spirv-tools-2020.4-ubuntu-16.04-gcc5.zip && cd $HOME/deps && unzip $HOME/spirv-tools-2020.4-ubuntu-16.04-gcc5.zip && cd $TRAVIS_BUILD_DIR ; fi

# Basis Universal
- export BASIS_VERSION=8565af680d1bd2ad56ab227ca7d96c56dfbe93ed && wget -nc https://github.com/BinomialLLC/basis_universal/archive/$BASIS_VERSION.zip && unzip -q $BASIS_VERSION; mv basis_universal-$BASIS_VERSION $HOME/basis_universal
- export BASIS_VERSION=1_15_update2 && wget -nc https://github.com/BinomialLLC/basis_universal/archive/v$BASIS_VERSION.zip && unzip -q v$BASIS_VERSION; mv basis_universal-$BASIS_VERSION $HOME/basis_universal

script:
- if [ "$TRAVIS_OS_NAME" == "linux" ] && ( [ "$TARGET" == "desktop" ] || [ "$TARGET" == "desktop-sanitizers" ] ); then ./package/ci/unix-desktop.sh; fi
Expand Down
15 changes: 10 additions & 5 deletions package/homebrew/magnum-plugins.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,16 @@ class MagnumPlugins < Formula
depends_on "spirv-tools" => :recommended

def install
# Bundle Basis Universal, a commit that's before the UASTC support (which
# is not implemented yet). 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?!
system "curl", "-L", "https://github.com/BinomialLLC/basis_universal/archive/2f43afcc97d0a5dafdb73b4e24e123cf9687a418.tar.gz", "-o", "src/external/basis-universal.tar.gz"
# Bundle Basis Universal, v1_15_update2 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"
else
system "curl", "-L", "https://github.com/BinomialLLC/basis_universal/archive/2f43afcc97d0a5dafdb73b4e24e123cf9687a418.tar.gz", "-o", "src/external/basis-universal.tar.gz"
end
cd "src/external" do
system "mkdir", "basis-universal"
system "tar", "xzvf", "basis-universal.tar.gz", "-C", "basis-universal", "--strip-components=1"
Expand Down
50 changes: 41 additions & 9 deletions src/MagnumPlugins/BasisImageConverter/BasisImageConverter.conf
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
provides=BasisKtxImageConverter

# [configuration_]
[configuration]
# All following options correspond to options of the basisu tool, grouped in
# the same way. Names follow the Basis C++ API and may differ from what the
# tool exposes.
# All following options correspond to parameters of the `basis_compressor` C++
# API and may differ from what the basisu tool exposes.

# Options
quality_level=128
# sRGB images should have this enabled, turn this flag off for linear images
perceptual=true
# Treat images as sRGB color data, rather than linear intensity. Leave blank to
# determine from the image format.
perceptual=
debug=false
validate=false
debug_images=false
compute_stats=false
compression_level=1
compression_level=2

# More options
max_endpoint_clusters=512
Expand All @@ -21,7 +24,14 @@ y_flip=true
# `mip_srgb` and enabling `no_selector_rdo` & `no_endpoint_rdo`
check_for_alpha=true
force_alpha=false
separate_rg_to_color_alpha=false
# Remap color channels before compression. Must be empty or 4 characters long,
# valid characters are r,g,b,a. This replaced separate_rg_to_color_alpha,
# for the same effect use 'rrrg'.
swizzle=
renormalize=false
resample_width=
resample_height=
resample_factor=
# Number of threads Basis should use during compression, 0 sets it to the
# value returned by std::thread::hardware_concurrency(), 1 disables
# multithreading. This value is clamped to std::thread::hardware_concurrency()
Expand All @@ -30,13 +40,18 @@ threads=1
disable_hierarchical_endpoint_codebooks=false

# Mipmap generation options
# Generate mipmaps from the base image. If you pass custom mip levels into
# openData, this option will be ignored. Leave blank to determine from the
# number of levels passed to convertToData.
mip_gen=false
# Generate mipmaps assuming sRGB input, turn this flag off for linear images
mip_srgb=true
# Filter mipmaps assuming sRGB color data, rather than linear intensity. Leave
# blank to determine from the image format.
mip_srgb=
mip_scale=1.0
mip_filter=kaiser
mip_renormalize=false
mip_wrapping=true
mip_fast=true
mip_smallest_dimension=1

# Backend endpoint/selector RDO codec options
Expand All @@ -53,6 +68,23 @@ global_palette_bits=8
global_modifier_bits=8
hybrid_selector_codebook_quality_threshold=2.0

# UASTC options
uastc=false
pack_uastc_level=2
pack_uastc_flags=
rdo_uastc=false
rdo_uastc_quality_scalar=1.0
rdo_uastc_dict_size=4096
rdo_uastc_max_smooth_block_error_scale=10.0
rdo_uastc_smooth_block_max_std_dev=18.0
rdo_uastc_max_allowed_rms_increase_ratio=10.0
rdo_uastc_skip_block_rms_threshold=8.0
rdo_uastc_favor_simpler_modes_in_rdo_mode=true

# KTX2 options
ktx2_uastc_supercompression=true
ktx2_zstd_supercompression_level=6

# Set various fields in the Basis file header
userdata0=0
userdata1=0
Expand Down
Loading