KTX2 transcoder: build with BASISD_SUPPORT_KTX2 disabled

Two things prevented the transcoder from compiling with
BASISD_SUPPORT_KTX2 set to 0:

- ktx2_image_level_info was defined inside the #if BASISD_SUPPORT_KTX2
  block, but dds_transcoder::get_image_level_info() takes it by
  reference and is compiled unconditionally. Move the struct ahead of
  that block so it is always defined; it has no KTX2-specific members.

- The "#include ../zstd/zstd.h" was nested inside #if BASISD_SUPPORT_KTX2,
  but the Zstd decompressor (zstd_decompress()) is compiled whenever
  BASISD_SUPPORT_KTX2_ZSTD is set, independent of KTX2 (Zstd is also used
  by other codecs). With KTX2 off but Zstd on, the ZSTD_* symbols were
  referenced without the header being included. Gate the include on
  BASISD_SUPPORT_KTX2_ZSTD alone, matching where the symbols are used.

BASISD_SUPPORT_KTX2_ZSTD still defaults to 1 (unchanged). The default
build (KTX2 and Zstd both enabled) is unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Richard Geldreich
2026-07-18 17:12:51 -04:00
parent 3454230543
commit f2497f14d6
2 changed files with 41 additions and 41 deletions

View File

@@ -171,13 +171,11 @@
#define BASISD_ENABLE_DEBUG_FLAGS 0
#endif
// If KTX2 support is enabled, we may need Zstd for decompression of supercompressed UASTC files. Include this header.
#if BASISD_SUPPORT_KTX2
// If BASISD_SUPPORT_KTX2_ZSTD is 0, UASTC files compressed with Zstd cannot be loaded.
#if BASISD_SUPPORT_KTX2_ZSTD
// We only use two Zstd API's: ZSTD_decompress() and ZSTD_isError()
#include "../zstd/zstd.h"
#endif
// Zstd is used both for KTX2 supercompressed UASTC files and for Zstd-compressed data in other codecs (independent of KTX2 support), so include the header whenever Zstd usage is enabled -- not just when KTX2 is enabled.
// If BASISD_SUPPORT_KTX2_ZSTD is 0, data compressed with Zstd cannot be loaded.
#if BASISD_SUPPORT_KTX2_ZSTD
// We only use these Zstd API's: ZSTD_decompress(), ZSTD_isError() and ZSTD_getFrameContentSize()
#include "../zstd/zstd.h"
#endif
#if BASISD_SUPPORT_UASTC_HDR