Skip to content

Commit

Permalink
Disallow ASTC options when format is not ASTC (#809)
Browse files Browse the repository at this point in the history
Fixes #808.
  • Loading branch information
aqnuep authored Dec 7, 2023
1 parent f8220ec commit d3ef5ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions tools/ktx/command_create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,11 @@ struct OptionsASTC : public ktxAstcParams {
inline static const char* kAstcQuality = "astc-quality";
inline static const char* kAstcPerceptual = "astc-perceptual";

inline static const char* kAstcOptions[] = {
kAstcQuality,
kAstcPerceptual
};

std::string astcOptions{};
bool encodeASTC = false;
ClampedOption<ktx_uint32_t> qualityLevel{ktxAstcParams::qualityLevel, 0, KTX_PACK_ASTC_QUALITY_LEVEL_MAX};
Expand Down Expand Up @@ -902,6 +907,12 @@ void CommandCreate::processOptions(cxxopts::Options& opts, cxxopts::ParseResult&
options.inputFilepaths.size(), expectedInputImages);
}

if (!isFormatAstc(options.vkFormat)) {
for (const char* astcOption : OptionsASTC::kAstcOptions)
if (args[astcOption].count())
fatal_usage("--{} can only be used with ASTC formats.", astcOption);
}

if (options.codec == EncodeCodec::BasisLZ) {
if (options.zstd.has_value())
fatal_usage("Cannot encode to BasisLZ and supercompress with Zstd.");
Expand Down

0 comments on commit d3ef5ed

Please sign in to comment.