From 8f4b5a65c9fc29f67b1cf14be36802dbfa4f5358 Mon Sep 17 00:00:00 2001 From: Wasim Abbas Date: Wed, 13 Nov 2024 11:57:17 +0000 Subject: [PATCH] Rename astc_encode.cpp to astc_codec.cpp, use dfd model to query for ASTC --- CMakeLists.txt | 2 +- lib/{astc_encode.cpp => astc_codec.cpp} | 0 tools/ktx/metrics_utils.h | 4 +++- 3 files changed, 4 insertions(+), 2 deletions(-) rename lib/{astc_encode.cpp => astc_codec.cpp} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 96dee7e63b..0dcacdbf0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -759,7 +759,7 @@ macro(common_libktx_settings target enable_write library_type) ${target} PRIVATE lib/basis_encode.cpp - lib/astc_encode.cpp + lib/astc_codec.cpp ${BASISU_ENCODER_C_SRC} ${BASISU_ENCODER_CXX_SRC} lib/writer1.c diff --git a/lib/astc_encode.cpp b/lib/astc_codec.cpp similarity index 100% rename from lib/astc_encode.cpp rename to lib/astc_codec.cpp diff --git a/tools/ktx/metrics_utils.h b/tools/ktx/metrics_utils.h index 04c1c94b9c..e5e7677244 100644 --- a/tools/ktx/metrics_utils.h +++ b/tools/ktx/metrics_utils.h @@ -107,8 +107,10 @@ class MetricsCalculator { tSwizzleInfo.swizzle = "rgba"; ktx_error_code_e ec = KTX_SUCCESS; + // Decode the encoded texture to observe the compression losses - if (isFormatAstc((VkFormat)texture->vkFormat)) + const auto* bdfd = texture->pDfd + 1; + if (khr_df_model_e(KHR_DFDVAL(bdfd, MODEL)) == KHR_DF_MODEL_ASTC) { ec = ktxTexture2_DecodeAstc(texture, VK_FORMAT_R8G8B8A8_UNORM); }