Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow ASTC options when format is not ASTC #809

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading