### Build ASTC Encoder Example on Linux/macOS Source: https://github.com/arm-software/astc-encoder/blob/main/Utils/Example/README.md Use these commands to build the example application on Linux or macOS using CMake and Makefiles. Ensure you are in the `./Utils/Example` directory. ```bash mkdir build cd build cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release .. make -j8 ``` -------------------------------- ### Build ASTC Encoder Example on Windows Source: https://github.com/arm-software/astc-encoder/blob/main/Utils/Example/README.md Use these commands to build the example application on Windows using CMake and NMakefiles from a Visual Studio command prompt. Ensure you are in the `./Utils/Example` directory. ```bash mkdir build cd build cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release .. nmake ``` -------------------------------- ### Build and Install with NMake Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Building.md Compile and install the ASTC encoder project on Windows after configuring the build. This command should be run from the build directory. ```shell # Run a build and install build outputs in `${CMAKE_INSTALL_PREFIX}/bin/` cd build nmake install ``` -------------------------------- ### Install Host Software for Big Endian Builds Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Building-BE.md Installs necessary host software including the cross-compiler, multi-arch libraries, and QEMU for big-endian builds. Ensure your system's package manager is configured correctly. ```bash sudo apt-get install g++-powerpc64-linux-gnu sudo apt-get install g++-multilib-powerpc64-linux-gnu sudo apt-get install qemu-user-static qemu-user-binfmt binfmt-support sudo mkdir /etc/qemu-binfmt sudo ln -s /usr/powerpc64-linux-gnu /etc/qemu-binfmt/ppc64 sudo update-binfmts --import qemu-ppc64 ``` -------------------------------- ### Run ASTC Encoder Example Source: https://github.com/arm-software/astc-encoder/blob/main/Utils/Example/README.md Execute the compiled example application from the build directory, providing input and output PNG file paths. This compresses the input image and saves the decompressed output. ```bash astcenc_example ``` -------------------------------- ### Install Python Modules in a Virtual Environment Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Building.md Sets up a Python virtual environment and installs necessary Python modules for testing and profiling. Ensure you are in the project's root directory before running. ```shell # Setup virtual environment python3 -m venv pve . ./pve/bin/activate # Test tools python3 -m pip install numpy pillow pycodestyle pylint # Profile tools python3 -m pip install gprof2dot ``` -------------------------------- ### Build and Install ASTC Encoder Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Building.md Compile the project in Release configuration and optionally install the binaries to the specified directory. ```shell cmake --build . --config Release # Optionally install the binaries to the installation directory cmake --install . --config Release ``` -------------------------------- ### Install Native Packages for Build Tools Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Building.md Installs essential build tools like clang, cmake, and git using apt. This is a prerequisite for compiling the ASTC encoder. ```shell sudo apt update # Build tools sudo apt install clang cmake git # Test tools sudo apt install imagemagick python3-pip # Profile tools sudo apt install graphviz valgrind ``` -------------------------------- ### Build and Install ASTC Encoder with Make Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Building.md After configuring the build with CMake, use Make to compile the project and install the build outputs. The executable binaries will be placed in `${CMAKE_INSTALL_PREFIX}/bin/` and libraries in `${CMAKE_INSTALL_PREFIX}/lib/`. ```shell # Run a build and install build outputs in `${CMAKE_INSTALL_PREFIX}/bin/` # for executable binaries and `${CMAKE_INSTALL_PREFIX}/lib/` for libraries cd build make install -j16 ``` -------------------------------- ### Install Docker Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/TestingOSSFuzz.md Installs Docker on a Debian-based system. You will need to log out and log back in for group changes to take effect. ```sh sudo apt install docker.io sudo usermod -aG docker $USER ``` -------------------------------- ### Run ASTC Encoder Natively (with binfmt) Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Building-BE.md Runs the cross-compiled ASTC encoder binary directly if the QEMU binfmt setup was successful, allowing it to be treated as a native binary. ```bash ./bin/astcenc-none ... ``` -------------------------------- ### Configure Windows Build with CMake Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Building.md Configure the build for Windows using CMake. Use the Visual Studio generator with ClangCL for optimized builds, or NMake Makefiles for a release build. Ensure CMAKE_INSTALL_PREFIX is set to the desired installation directory. ```shell # Create a build directory mkdir build cd build # Configure your build of choice, for example: # x86-64 using a Visual Studio solution cmake -G "Visual Studio 16 2019" -T ClangCL -DCMAKE_INSTALL_PREFIX=.. \ -DASTCENC_ISA_AVX2=ON -DASTCENC_ISA_SSE41=ON -DASTCENC_ISA_SSE2=ON .. # x86-64 using NMake cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=.. \ -DASTCENC_ISA_AVX2=ON -DASTCENC_ISA_SSE41=ON -DASTCENC_ISA_SSE2=ON .. ``` -------------------------------- ### Configure macOS Build with CMake Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Building.md Configure the build system for macOS using CMake. Ensure you are in the build directory and specify the installation prefix. ```shell # Create a build directory mkdir build cd build # Configure a universal build cmake -G Xcode -DCMAKE_INSTALL_PREFIX=../ .. ``` -------------------------------- ### Run ASTC Encoder via QEMU Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Building-BE.md Executes the cross-compiled ASTC encoder binary using QEMU for instruction set translation. This is necessary when the binfmt setup is not active or for manual execution. ```bash qemu-ppc64 ./bin/astcenc-none ... ``` -------------------------------- ### Run Python CLI Performance and Quality Tests Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Testing.md Execute image compression tests to compare PSNR against reference results. Ensure astcenc is compiled and installed in the ./bin directory. This command runs a series of image compression tests. ```sh python3 ./Test/astc_test_image.py ``` -------------------------------- ### Run Python CLI Functional Tests Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Testing.md Execute functional tests for the astcenc encoder variant. Ensure astcenc is compiled and installed in the ./bin directory. ```sh python3 ./Test/astc_test_functional.py -v --encoder ``` -------------------------------- ### Build ASTC Encoder with CMake Toolchain Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Building-BE.md Builds the ASTC encoder using CMake, specifying the release build type, installation prefix, the reference C SIMD implementation (ASTCENC_ISA_NONE), and the big-endian toolchain file for cross-compilation. ```bash cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../ -DASTCENC_ISA_NONE=ON -DCMAKE_TOOLCHAIN_FILE=../CMake-BE.toolchain .. ``` -------------------------------- ### Configure ASTC Encoder Build with CMake Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Building.md Configure the ASTC encoder build using CMake. Select your compiler and specify build options like architecture and ISA extensions. For example, configure for Arm arch64, x86-64 with specific ISA extensions, or a macOS universal binary. ```shell # Select your compiler (clang++ recommended, but g++ works) export CXX=clang++ # Create a build directory mkdir build cd build # Configure your build of choice, for example: # Arm arch64 cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../ \ -DASTCENC_ISA_NEON=ON .. # x86-64 cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../ \ -DASTCENC_ISA_AVX2=ON -DASTCENC_ISA_SSE41=ON -DASTCENC_ISA_SSE2=ON .. # macOS universal binary build cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../ .. ``` -------------------------------- ### Enable ASTC Encoder Unit Testing Source: https://github.com/arm-software/astc-encoder/blob/main/Source/CMakeLists.txt Conditionally enables unit testing if the ASTCENC_UNITTEST variable is set. Includes setup for GoogleTest and the project's unit tests. ```cmake if(${ASTCENC_UNITTEST}) set(INSTALL_GTEST OFF CACHE BOOL "" FORCE) set(CMAKE_OSX_ARCHITECTURES x86_64;arm64) add_subdirectory(GoogleTest) # Workaround GoogleTest CRT selection issue issue # See https://github.com/google/googletest/issues/4067 set_property( TARGET gtest PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") set_property( TARGET gtest_main PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") enable_testing() add_subdirectory(UnitTest) endif() ``` -------------------------------- ### Initialize and Update Git Submodules Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Building.md Fetch the googletest framework submodule dependency before building unit tests. ```shell git submodule init git submodule update ``` -------------------------------- ### Run Tests with Valgrind Memcheck Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Testing.md Build with debug information using -DCMAKE_BUILD_TYPE=RelWithDebInfo. Execute test commands through Valgrind with --tool=memcheck and --track-origins=yes. ```shell valgrind --tool=memcheck --track-origins=yes ``` -------------------------------- ### Reproduce OSS-Fuzz Testcase Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/TestingOSSFuzz.md Runs a specific testcase downloaded from OSS-Fuzz to reproduce a reported failure. Replace `` and `` with actual values. ```sh python3 infra/helper.py reproduce astc-encoder ``` -------------------------------- ### Create Universal CLI Binary for macOS Source: https://github.com/arm-software/astc-encoder/blob/main/Source/CMakeLists.txt Creates a universal ASTC CLI binary for macOS using 'lipo' by combining binaries for different architectures (x86_64, x86_64h, arm64). Requires ASTCENC_CLI and ASTCENC_UNIVERSAL_BUILD to be enabled. ```cmake add_custom_target( astc${ASTCENC_CODEC} ALL COMMAND lipo -create -output $/astc${ASTCENC_CODEC} -arch x86_64 $ -arch x86_64h $ -arch arm64 $ VERBATIM) add_dependencies( astc${ASTCENC_CODEC} astc${ASTCENC_CODEC}-sse4.1 astc${ASTCENC_CODEC}-avx2 astc${ASTCENC_CODEC}-neon) install(PROGRAMS $/astc${ASTCENC_CODEC} DESTINATION bin) ``` -------------------------------- ### Build with ASAN/UBSAN for Error Detection Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Testing.md Compile with debug information using -DCMAKE_BUILD_TYPE=RelWithDebInfo and enable either -DASTCENC_ASAN=ON or -DASTCENC_UBSAN=ON. Run tests with the generated binaries. ```shell -DCMAKE_BUILD_TYPE=RelWithDebInfo -DASTCENC_ASAN=ON ``` ```shell -DCMAKE_BUILD_TYPE=RelWithDebInfo -DASTCENC_UBSAN=ON ``` -------------------------------- ### Run Callgrind Profiling Script Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Profiling.md Execute the provided helper script to perform hotspot profiling with Callgrind. This script supports LDR input images and a single compression mode. Ensure valgrind, gprof2dot, and dot are in your PATH. ```shell python3 ./Test/astc_profile_valgrind.py --test-quality fastest ``` -------------------------------- ### Pull Docker Images Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/TestingOSSFuzz.md Downloads the standard Docker images that include the necessary tools for OSS-Fuzz testing. ```sh python3 infra/helper.py pull_images ``` -------------------------------- ### Update Reference Data for Quality and Performance Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Testing.md Build new reference CSVs for quality and performance scores by running tests against a baseline release. Ensure the baseline release is placed in the ./Binaries// directory. This process can take several hours. ```sh python3 ./Test/astc_test_image.py --encoder ref-5.3-avx2 ... ``` -------------------------------- ### Run C++ Unit Tests with CTest Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Testing.md Build unit tests by pulling the googletest submodule and configuring CMake with -DASTCENC_UNITTEST=ON. Run tests from the build directory using the ctest utility. ```shell cd build ctest --verbose ``` -------------------------------- ### Create Universal Shared Library for macOS Source: https://github.com/arm-software/astc-encoder/blob/main/Source/CMakeLists.txt Creates a universal shared library for ASTC (libastc.dylib) for macOS using 'lipo' by combining libraries for different architectures (x86_64, x86_64h, arm64). Requires ASTCENC_SHAREDLIB and ASTCENC_UNIVERSAL_BUILD to be enabled. ```cmake add_custom_target( astc${ASTCENC_CODEC}-shared ALL COMMAND lipo -create -output $/libastc${ASTCENC_CODEC}-shared.dylib -arch x86_64 $ -arch x86_64h $ -arch arm64 $ VERBATIM) add_dependencies( astc${ASTCENC_CODEC}-shared astc${ASTCENC_CODEC}-sse4.1-shared astc${ASTCENC_CODEC}-avx2-shared astc${ASTCENC_CODEC}-neon-shared) install(PROGRAMS $/libastc${ASTCENC_CODEC}-shared.dylib DESTINATION lib) ``` -------------------------------- ### Package Release Bundle Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Building.md Builds and packages the astcenc encoder for distribution. Windows uses .zip, others use .tar.gz. Use -DASTCENC_PACAKGE= to set the package architecture. ```shell cd build make package -j16 ``` -------------------------------- ### Iterate and Configure ISA for ASTC Encoder Source: https://github.com/arm-software/astc-encoder/blob/main/Source/UnitTest/CMakeLists.txt Loops through defined artifacts and configurations to set the SIMD instruction set. Includes conditional logic for macOS compatibility and specific architecture settings. ```cmake list(LENGTH ASTCENC_ARTIFACTS ASTCENC_ARTIFACTS_LEN) math(EXPR ASTCENC_ARTIFACTS_LEN "${ASTCENC_ARTIFACTS_LEN} - 1") foreach(INDEX RANGE ${ASTCENC_ARTIFACTS_LEN}) list(GET ASTCENC_ARTIFACTS ${INDEX} ASTCENC_ARTIFACT) list(GET ASTCENC_CONFIGS ${INDEX} ASTCENC_CONFIG) if(${ASTCENC_CONFIG}) set(ASTCENC_ISA_SIMD ${ASTCENC_ARTIFACT}) if(${ASTCENC_ISA_SIMD} MATCHES "sve_256") # Not supported on macOS elseif(${ASTCENC_ISA_SIMD} MATCHES "sve_128") # Not supported on macOS elseif(${ASTCENC_ISA_SIMD} MATCHES "neon") set(CMAKE_OSX_ARCHITECTURES arm64) elseif(${ASTCENC_ISA_SIMD} MATCHES "sse2") set(CMAKE_OSX_ARCHITECTURES x86_64) elseif(${ASTCENC_ISA_SIMD} MATCHES "sse4.1") set(CMAKE_OSX_ARCHITECTURES x86_64) elseif(${ASTCENC_ISA_SIMD} MATCHES "avx2") set(CMAKE_OSX_ARCHITECTURES x86_64h) elseif(${ASTCENC_ISA_SIMD} MATCHES "none") # Using "none" uses implicit architecture elseif(${ASTCENC_ISA_SIMD} MATCHES "native") # Using "native" uses implicit architecture else() message(FATAL_ERROR "'${ASTCENC_ISA_SIMD}' is unknown ISA") endif() include(cmake_core.cmake) endif() endforeach() ``` -------------------------------- ### Run ASTC Encoder Source: https://github.com/arm-software/astc-encoder/blob/main/README.md Execute the ASTC encoder program from the terminal. Use '-help' for a full list of options. ```bash ./astcenc ``` ```bash astcenc ``` -------------------------------- ### Clone OSS-Fuzz Project Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/TestingOSSFuzz.md Clones the OSS-Fuzz project repository locally. This is necessary to access the helper scripts for building and running fuzzers. ```sh git clone --depth=1 https://github.com/google/oss-fuzz.git cd oss-fuzz ``` -------------------------------- ### ASTC Command Line Options for HDR Data (RGB HDR, Alpha LDR) Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Encoding.md Command line arguments for ASTC encoding to specify HDR compression where RGB components are HDR and the Alpha component is LDR. Use the '-ch' option. ```bash astcenc input.png output.astc -ch ``` -------------------------------- ### ASTC Command Line Options for HDR Data (All HDR) Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Encoding.md Command line arguments for ASTC encoding to specify HDR compression where all components (RGB and Alpha) are treated as HDR data. Use the '-cH' option. ```bash astcenc input.png output.astc -cH ``` -------------------------------- ### Loop Reproducer Testcase Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/TestingOSSFuzz.md Runs the reproducer testcase in a loop. This is useful for intermittent failures that do not always reproduce on the first attempt. ```sh while python3 infra/helper.py reproduce astc-encoder ; do :; done ``` -------------------------------- ### ASTC Command Line Options for Normal Maps Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Encoding.md Command line arguments for the ASTC encoder to specify normal map compression. Use '-normal' for encoding and '-esw gggr' for a specific swizzle. For decompression, use '-dsw arz1'. ```bash astcenc -normal -esw gggr input.png output.astc -cs ``` ```bash astcenc -normal -dsw arz1 input.astc output.png -cs ``` -------------------------------- ### Build ASTC Encoder for Android Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Building.md Use this script to build the ASTC command line utility for Android. Ensure ANDROID_NDK is set to your NDK path. The built application can be pushed to Android devices for execution. ```shell ANDROID_ABI=arm64-v8a ANDROID_NDK=/work/tools/android/ndk/22.1.7171670 BUILD_TYPE=RelWithDebInfo BUILD_DIR=build mkdir -p ${BUILD_DIR} cd ${BUILD_DIR} cmake \ -DCMAKE_INSTALL_PREFIX=./ \ -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \ -DANDROID_ABI=${ANDROID_ABI} \ -DANDROID_ARM_NEON=ON \ -DANDROID_PLATFORM=android-21 \ -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang \ -DANDROID_TOOLCHAIN=clang \ -DANDROID_STL=c++_static \ -DARCH=aarch64 \ -DASTCENC_ISA_NEON=ON \ .. make -j16 ``` -------------------------------- ### Build Docker Image for ASTC-Encoder Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/TestingOSSFuzz.md Builds the Docker image specifically for the ASTC-Encoder project. This image contains the environment needed to build and run fuzzers. ```sh python3 infra/helper.py build_image astc-encoder ``` -------------------------------- ### ASTC Command Line Options for sRGB Data Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Encoding.md Command line arguments for ASTC encoding to specify sRGB compression. Use '-cs' for sRGB color space compression. Ensure the input texture is in sRGB color space. ```bash astcenc input.png output.astc -cs ``` -------------------------------- ### Configure ASTC ISA SIMD Settings for macOS Source: https://github.com/arm-software/astc-encoder/blob/main/Source/CMakeLists.txt Configures macOS architecture settings based on the selected ASTC ISA SIMD. Note that SVE variants are not supported on macOS. ```cmake if(${ASTCENC_ISA_SIMD} MATCHES "sve_256") # Not suported on macOS elseif(${ASTCENC_ISA_SIMD} MATCHES "sve_128") # Not suported on macOS elseif(${ASTCENC_ISA_SIMD} MATCHES "neon") set(CMAKE_OSX_ARCHITECTURES arm64) elseif(${ASTCENC_ISA_SIMD} MATCHES "sse2") set(CMAKE_OSX_ARCHITECTURES x86_64) elseif(${ASTCENC_ISA_SIMD} MATCHES "sse4.1") set(CMAKE_OSX_ARCHITECTURES x86_64) elseif(${ASTCENC_ISA_SIMD} MATCHES "avx2") set(CMAKE_OSX_ARCHITECTURES x86_64h) elseif(${ASTCENC_ISA_SIMD} MATCHES "none") # Using "none" uses implicit architecture elseif(${ASTCENC_ISA_SIMD} MATCHES "native") # Using "native" uses implicit architecture else() message(FATAL_ERROR "'${ASTCENC_ISA_SIMD}' is unknown ISA") endif() ``` -------------------------------- ### Generate Disassembly with objdump Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Profiling.md Use objdump to generate standard x86-64 disassembly with Intel syntax, excluding raw opcodes, and including source code where available. Redirect output to a file for analysis. ```shell objdump -C -M intel --no-show-raw -d -S > dis.txt ``` -------------------------------- ### Define ASTC Encoder Artifacts and Configurations Source: https://github.com/arm-software/astc-encoder/blob/main/Source/UnitTest/CMakeLists.txt Sets a list of build artifacts and their corresponding ISA configurations. This is used to manage different build targets for the ASTC encoder. ```cmake set(ASTCENC_ARTIFACTS native none sve_256 sve_128 neon avx2 sse4.1 sse2) set(ASTCENC_CONFIGS ${ASTCENC_ISA_NATIVE} ${ASTCENC_ISA_NONE} ${ASTCENC_ISA_SVE_256} ${ASTCENC_ISA_SVE_128} ${ASTCENC_ISA_NEON} ${ASTCENC_ISA_AVX2} ${ASTCENC_ISA_SSE41} ${ASTCENC_ISA_SSE2}) ``` -------------------------------- ### Compress Image with ASTC Source: https://github.com/arm-software/astc-encoder/blob/main/README.md Compress an image using LDR color profile and a specified block footprint. The '-medium' preset offers a balance between quality and speed. Use '-decode_unorm8' if targeting UNORM8 precision. ```bash astcenc -cl example.png example.astc 6x6 -medium ``` -------------------------------- ### ASTC Command Line Option for RGBA8 Rounding Rules Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Encoding.md Use the '-decode_unorm8' command line option when compressing textures that will be decompressed into RGBA8. This optimizes for RGBA8 rounding rules and can improve image quality. ```bash astcenc input.png output.astc -decode_unorm8 ``` -------------------------------- ### Set LTO Flags for GNU Source: https://github.com/arm-software/astc-encoder/blob/main/Source/CMakeLists.txt Sets the Link-Time Optimization (LTO) flags to '-flto=auto' when using the GNU compiler and ASTCENC_CLI is enabled. This can improve performance. ```cmake if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND ${ASTCENC_CLI}) set(CMAKE_CXX_COMPILE_OPTIONS_IPO "-flto=auto") endif() ``` -------------------------------- ### Build Fuzzers for ASTC-Encoder Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/TestingOSSFuzz.md Builds the fuzzers for the ASTC-Encoder project. Fuzzers are built for a specific sanitizer (e.g., ASAN, UBSAN). You may need to build multiple times for different sanitizers. ```sh # Build using clean checkout in the container python3 infra/helper.py build_fuzzers astc-encoder # Build using local checkout mounted into the container python3 infra/helper.py build_fuzzers astc-encoder /mnt/c/work/projects/astcenc/Source --sanitizer ``` -------------------------------- ### Cross-compile ASTC Encoder for RISC-V with VLEN=256 Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Building.md Cross-compile the ASTC encoder for RISC-V with the VLEN=256 Vector backend enabled. This requires setting specific CXX and CXXFLAGS environment variables. Ensure your toolchain supports the specified architecture and vector extensions. ```bash export CXX=riscv64-linux-gnu-g++ export CXXFLAGS="-march=rv64gcv_zvl256b -mrvv-vector-bits=zvl" cmake -B build -DCMAKE_BUILD_TYPE=Release -DASTCENC_ISA_NONE=ON .. cmake --build build -j$(nproc) ``` -------------------------------- ### Set LTO Flags for Clang Source: https://github.com/arm-software/astc-encoder/blob/main/Source/CMakeLists.txt Sets the Link-Time Optimization (LTO) flags to '-flto' when using the Clang compiler and ASTCENC_CLI is enabled. This can improve performance. ```cmake if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND ${ASTCENC_CLI}) set(CMAKE_CXX_COMPILE_OPTIONS_IPO "-flto") endif() ``` -------------------------------- ### CMake Toolchain File for Big Endian Cross-Compilation Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/Building-BE.md Configures CMake for cross-compiling to a big-endian Linux system. Sets the target system, cross-compilers, root path, static linkage flags, and build options for big-endian support and the reference C SIMD implementation. ```cmake # Operating system set(CMAKE_SYSTEM_NAME Linux) # Cross-compilers for C and C++ set(CMAKE_C_COMPILER powerpc64-linux-gnu-gcc) set(CMAKE_CXX_COMPILER powerpc64-linux-gnu-g++) # Compiler environment set(CMAKE_FIND_ROOT_PATH /usr/powerpc64-linux-gnu) set(CMAKE_C_FLAGS_INIT -static) set(CMAKE_CXX_FLAGS_INIT -static) set(CMAKE_EXE_LINKER_FLAGS_INIT -static) set(CMAKE_SHARED_LINKER_FLAGS_INIT -static) set(CMAKE_MODULE_LINKER_FLAGS_INIT -static) # Build options set(ASTCENC_BIG_ENDIAN ON) # Never match host tools set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) # Only match headers and libraries in the compiler environment set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) ``` -------------------------------- ### Measure ASTC Compression Quality Source: https://github.com/arm-software/astc-encoder/blob/main/README.md Measure compression quality by compressing and decompressing an image, saving the result, and printing quality metrics. Uses LDR color profile and a 5x5 block size with the '-thorough' preset. ```bash astcenc -tl example.png example.tga 5x5 -thorough ``` -------------------------------- ### ASTC Image Dimension Decoding Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/FileFormat.md Illustrates how to reconstruct the 24-bit unsigned image dimension from the stored byte values in the .astc header. This method is used for each of the X, Y, and Z dimensions. ```c decoded_dim = dim[0] + (dim[1] << 8) + (dim[2] << 16); ``` -------------------------------- ### ASTC Header Structure Definition Source: https://github.com/arm-software/astc-encoder/blob/main/Docs/FileFormat.md Defines the 16-byte header structure for the .astc file format. This structure stores essential metadata about the compressed texture. ```c struct astc_header { uint8_t magic[4]; uint8_t block_x; uint8_t block_y; uint8_t block_z; uint8_t dim_x[3]; uint8_t dim_y[3]; uint8_t dim_z[3]; }; ```