Skip to content

Commit

Permalink
Add check to prevent ASTC encoding from ASTC encded KTX file
Browse files Browse the repository at this point in the history
  • Loading branch information
wasimabbas-arm committed Nov 20, 2024
1 parent 19807a7 commit 528473f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions tools/ktx/command_encode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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:
Expand Down

0 comments on commit 528473f

Please sign in to comment.