KTX-Software

repository·main·Indexed 23 days ago

https://github.com/khronosgroup/ktx-software

Official implementation of the Khronos KTX (Khronos Texture) container, providing tools and libraries to manage texture data for GPU APIs like Vulkan and OpenGL. It includes support for compression formats such as Basis Universal (LZ/ETC1S and UASTC) and the astcenc command-line tool for Arm Adaptive Scalable Texture Compression (ASTC). The suite provides utilities for compressing, decompressing, and measuring image quality, as well as Python bindings (basisu-py v0.2.0) for the Basis Universal encoder/transcoder.

Tokens
55.2K
Snippets
164
Records
337
Agent score
80%

What's inside KTX-Software

  1. Overview of the {fmt} library API components

    main

    The {fmt} library is organized into several headers providing specialized functionality. All functions and types reside in the fmt namespace, and macros are prefixed with FMT_.

    Key components include:

    • fmt/base.h: Base API for char/UTF-8 with C++20 compile-time checks. Provides formatter specializations for basic types (int, float, bool, etc.).
    • fmt/format.h: Main formatting functions like fmt::format and locale support.
    • fmt/ranges.h: Formatting for ranges and tuples (e.g., std::vector).
    • fmt/chrono.h: Date and time formatting.
    • fmt/std.h: Formatters for standard library types.
    • fmt/compile.h: Format string compilation.
    • fmt/color.h: Terminal colors and text styles.
    • fmt/os.h: System APIs.
    • fmt/ostream.h: std::ostream support.
    • fmt/args.h: Dynamic argument lists.
    • fmt/printf.h: Safe printf implementation.
    • fmt/xchar.h: Optional wchar_t support.
  2. Overview of KTX Software components

    main

    KTX (Khronos Texture) is a lightweight container for textures used with OpenGL, Vulkan, and other GPU APIs. The software repository provides several ways to interact with KTX files depending on your environment:

    • libktx: A C++ library for reading/writing KTX files and instantiating textures in OpenGL and Vulkan.
    • Web (JS/Wasm): libktx.{js,wasm} provides a WebAssembly version of the library with a JavaScript wrapper. Additionally, msc_basis_transcoder.{js,wasm} is available for transcoding Basis Universal formats in JS-based KTX parsers.
    • Java: libktx.jar and libktx-jni provide a Java wrapper and native interface.
    • Python: pyktx is a Python wrapper for the library.
    • CLI Tool (ktx): A command-line utility for managing KTX2 files.
  3. Overview of the ASTC Encoder (astcenc)

    main

    astcenc is a command-line tool for compressing and decompressing images using the Arm® Adaptive Scalable Texture Compression (ASTC) standard. It supports both Low Dynamic Range (LDR) and High Dynamic Range (HDR) profiles, as well as 2D and 3D data.

    Supported Input/Output

    • Compression Inputs: BMP, JPEG, PNG, TGA, EXR, HDR, and data wrapped in DDS or KTX containers.
    • Compression Outputs: ASTC or KTX format.
    • Decompression Outputs: BMP, PNG, TGA, EXR, HDR, DDS, or KTX.

    Key Features

    • Flexible Bitrates: Supports block sizes ranging from 0.89 bits/pixel up to 8 bits/pixel.
    • Quality Control: Adjustable encoding presets from -fastest to -exhaustive.
    • Analysis: Reports compression time and Peak Signal-to-Noise Ratio (PSNR).
  4. Overview of Basis Universal v2.1

    main

    Basis Universal™ v2.1 is an open source supercompressed LDR/HDR GPU compressed texture interchange system. It is designed to provide portable texture data that can be rapidly transcoded to virtually any compressed GPU texture format.

    It supports two intermediate file formats:

    1. .KTX2: The Khronos Group open standard.
    2. .basis: The proprietary Basis Universal file format.
  5. Overview of {fmt} library

    main

    ```{fmt}** is an open-source C++ formatting library that provides a fast and safe alternative to C stdio and C++ iostreams. It implements the C++20 std::format and C++23 std::print standards and uses a format string syntax similar to Python's format method.

    Key Features

    • High Performance: Faster than printf, iostreams, to_string, and to_chars.
    • Type Safety: Fully type-safe with compile-time error reporting for invalid format specifiers (in C++20).
    • Extensibility: Supports user-defined types.
    • Unicode & Portability: Portable Unicode support and consistent output across platforms.
    • Small Footprint: Small compiled code size and minimal source code requirements.
    • Header-only option: Can be used as a header-only library by defining the FMT_HEADER_ONLY macro.
  6. Overview of the ktx unified toolset

    main

    The KTX software provides a unified command-line interface via the ktx command. This single front end replaces several legacy tools and provides a consistent way to manage KTX2 files.

    Key capabilities include:

    • Conversion & Creation: Convert existing texture files to KTX2 (ktx convert) or create KTX2 files from raw inputs (ktx create).
    • Information & Validation: Inspect KTX metadata (ktx info) and validate files against the KTX 2.0 specification (ktx validate).
    • Processing: Compare files (ktx compare), deflate/supercompress files (ktx deflate or ktx encode), extract images (ktx extract), transcode files (ktx transcode), and encode files (ktx encode).
  7. Overview of the {fmt} library

    main

    The {fmt} library is a modern C++ formatting library designed to provide a fast, safe, and easy-to-use alternative to printf and iostreams. It combines the performance and concise syntax of printf with the type safety and support for user-defined types found in iostreams.

    Key advantages include:

    • Performance: Significantly faster than Boost Format and iostreams.
    • Safety: Provides type-safe formatting, avoiding the common pitfalls of printf.
    • Features: Supports positional arguments (useful for i18n), leading zeros, padding, and various encoding formats (octal/hexadecimal) which some other fast libraries lack.
    • Low Overhead: Designed to minimize compile times and code bloat compared to heavy libraries like Boost Format.
  8. Overview of the {fmt} formatting library

    main

    The {fmt} library is a modern C++ formatting library designed as a safe, fast, and extensible replacement for the printf family of functions and C++ iostreams.

    Key features include:

    • Safety: Provides compile-time checks for format strings to prevent errors (e.g., mismatched type specifiers) and uses automatic memory management to prevent buffer overflows.
    • Extensibility: Supports standard types, containers, dates, and times out-of-the-box. Users can also define custom formatting for user-defined types (UDTs).
    • Performance: Significantly faster than iostreams and sprintf, particularly for numeric formatting, by minimizing dynamic memory allocations.
    • Unicode Support: Provides portable UTF-8 and char string support across Linux, macOS, and Windows.
    • Fast Compilation & Small Footprint: Uses type erasure to minimize template bloat and reduce compilation times. The core consists of just three headers with no external dependencies.
    • Portability: Requires only a minimal subset of C++11 (supported by GCC 4.9, Clang 3.6, MSVC 19.10, and later).
  9. Overview of Khronos Data Format Descriptor Utilities

    main

    The dfdutils directory provides helper utilities for creating and interpreting Data Format Descriptors (DFD) as specified in the Khronos Data Format Specification (KDFS) 1.4. These descriptors are embedded in .ktx2 files.

    Important Usage Notes:

    • Not for Production: These utilities are provided as examples and are not robust to all possible inputs. They are intended to work with the subset of descriptors used in .ktx2 files.
    • Vulkan Dependency: The utilities require access to vulkan_core.h to access VkFormat enums. A temporary version is provided within the repository.
    • Limitations: Only common color and depth formats are supported; multi-planar formats are not supported.
  10. Overview of ASTC (Adaptive Scalable Texture Compression)

    main

    Adaptive Scalable Texture Compression (ASTC) is a lossy texture compression technology used in OpenGL, OpenGL ES, and Vulkan. It is designed to provide high image quality and extreme flexibility in bit rates and channel counts.

    Key Advantages:

    • Format Flexibility: Supports 1 to 4 channels (e.g., RGB+A) and handles correlated/non-correlated data.
    • Bit Rate Flexibility: Offers fine-grained bit rates ranging from 0.89 to 8 bits per texel (bpt), independent of the color format.
    • Advanced Support: Supports Low Dynamic Range (LDR), LDR sRGB, High Dynamic Range (HDR), and 3D volumetric textures.
    • High Quality: Outperforms legacy formats like ETC2, PVRTC, and BC formats at equivalent bit rates.
  11. Identify the tools included with libktx

    main

    When installing libktx, the following command-line tools are provided as part of the KTX tool suite. The ktx command acts as a unified front end for these subcommands:

    • create: Create KTX v2 files.
    • compare: Compare KTX v2 files.
    • convert: Convert another container format to a KTX v2 file.
    • deflate: Apply Zstd or ZLIB compression to a KTX v2 file.
    • encode: Encode a KTX v2 file to Basis Universal or ASTC.
    • extract: Extract an image from a KTX v2 file.
    • info: Display info about a KTX file.
    • transcode: Transcode a KTX v2 file.
    • validate: Validate a KTX v2 file.