From 528473fa8a5dd8455bc1e58160f87a84c42a7e28 Mon Sep 17 00:00:00 2001 From: Wasim Abbas Date: Wed, 20 Nov 2024 16:36:56 +0000 Subject: [PATCH] Add check to prevent ASTC encoding from ASTC encded KTX file --- tests/cts | 2 +- tools/ktx/command_encode.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/cts b/tests/cts index 6e118962e6..4a94182783 160000 --- a/tests/cts +++ b/tests/cts @@ -1 +1 @@ -Subproject commit 6e118962e691890cd4013a945a970f61bc59578a +Subproject commit 4a941827832822fbe8df729367704f528cf65ebe diff --git a/tools/ktx/command_encode.cpp b/tools/ktx/command_encode.cpp index 91c136b207..5f8d7128b5 100644 --- a/tools/ktx/command_encode.cpp +++ b/tools/ktx/command_encode.cpp @@ -203,6 +203,9 @@ void CommandEncode::processOptions(cxxopts::Options& opts, cxxopts::ParseResult& fatal_usage("--compare-ssim can only be used with BasisLZ, UASTC or ASTC encoding."); if (options.compare_psnr && !canCompare) fatal_usage("--compare-psnr can only be used with BasisLZ, UASTC or ASTC encoding."); + + if (astcCodec) + options.encodeASTC = true; } void CommandEncode::executeEncode() { @@ -219,6 +222,10 @@ void CommandEncode::executeEncode() { fatal(rc::INVALID_FILE, "Cannot encode KTX2 file with {} supercompression.", toString(ktxSupercmpScheme(texture->supercompressionScheme))); + const auto* bdfd = texture->pDfd + 1; + if (khr_df_model_e(KHR_DFDVAL(bdfd, MODEL)) == KHR_DF_MODEL_ASTC && options.encodeASTC) + fatal_usage("Encoding from ASTC format {} to another ASTC format {} is not supported.", toString(VkFormat(texture->vkFormat)), toString(options.vkFormat)); + switch (texture->vkFormat) { case VK_FORMAT_R8_UNORM: case VK_FORMAT_R8_SRGB: