Skip to content

Commit 28186f5

Browse files
committed
Disallow ASTC options when format is not ASTC
1 parent 97feeae commit 28186f5

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

tools/ktx/command_create.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,11 @@ struct OptionsASTC : public ktxAstcParams {
555555
inline static const char* kAstcQuality = "astc-quality";
556556
inline static const char* kAstcPerceptual = "astc-perceptual";
557557

558+
inline static const char* kAstcOptions[] = {
559+
kAstcQuality,
560+
kAstcPerceptual
561+
};
562+
558563
std::string astcOptions{};
559564
bool encodeASTC = false;
560565
ClampedOption<ktx_uint32_t> qualityLevel{ktxAstcParams::qualityLevel, 0, KTX_PACK_ASTC_QUALITY_LEVEL_MAX};
@@ -902,6 +907,12 @@ void CommandCreate::processOptions(cxxopts::Options& opts, cxxopts::ParseResult&
902907
options.inputFilepaths.size(), expectedInputImages);
903908
}
904909

910+
if (!isFormatAstc(options.vkFormat)) {
911+
for (const char* astcOption : OptionsASTC::kAstcOptions)
912+
if (args[astcOption].count())
913+
fatal_usage("--{} can only be used with ASTC formats.", astcOption);
914+
}
915+
905916
if (options.codec == EncodeCodec::BasisLZ) {
906917
if (options.zstd.has_value())
907918
fatal_usage("Cannot encode to BasisLZ and supercompress with Zstd.");

0 commit comments

Comments
 (0)