Skip to content

Commit

Permalink
Moved normalize option from codec common to create only
Browse files Browse the repository at this point in the history
  • Loading branch information
wasimabbas-arm committed Jan 27, 2025
1 parent 53f728f commit 52d9370
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
11 changes: 11 additions & 0 deletions tools/ktx/command_create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ struct OptionsCreate {
inline static const char* kRuntimeMipmap = "runtime-mipmap";
inline static const char* kGenerateMipmap = "generate-mipmap";
inline static const char* kEncode = "encode";
inline static const char* kNormalize = "normalize";
inline static const char* kSwizzle = "swizzle";
inline static const char* kInputSwizzle = "input-swizzle";
inline static const char* kAssignOetf = "assign-oetf";
Expand Down Expand Up @@ -106,6 +107,7 @@ struct OptionsCreate {
bool warnOnColorConversions = false;
bool failOnOriginChanges = false;
bool warnOnOriginChanges = false;
bool normalize = false;

void init(cxxopts::Options& opts) {
opts.add_options()
Expand Down Expand Up @@ -141,6 +143,12 @@ struct OptionsCreate {
" This option is mutually exclusive with --runtime-mipmap and cannot be used with UINT or 3D textures.")
(kEncode, "Encode the created KTX file. Case insensitive."
"\nPossible options are: basis-lz | uastc", cxxopts::value<std::string>(), "<codec>")
(kNormalize, "Normalize input normals to have a unit length. Only valid for\n"
"linear textures with 2 or more components. For 2-component inputs\n"
"2D unit normals are calculated. Do not use these 2D unit normals\n"
"to generate X+Y normals for --normal-mode. For 4-component inputs\n"
"a 3D unit normal is calculated. 1.0 is used for the value of the\n"
"4th component.\n")
(kSwizzle, "KTX swizzle metadata.", cxxopts::value<std::string>(), "[rgba01]{4}")
(kInputSwizzle, "Pre-swizzle input channels.", cxxopts::value<std::string>(), "[rgba01]{4}")
(kAssignOetf, "Force the created texture to have the specified transfer function, ignoring"
Expand Down Expand Up @@ -370,6 +378,9 @@ struct OptionsCreate {
mipmapWrap = it->second;
}

if (args[kNormalize].count())
normalize = true;

if (args[kSwizzle].count()) {
swizzle = to_lower_copy(args[kSwizzle].as<std::string>());
const auto errorFmt = "Invalid --swizzle value: \"{}\". The value must match the \"[rgba01]{{4}}\" regex.";
Expand Down
14 changes: 0 additions & 14 deletions tools/ktx/encode_utils_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,11 @@ namespace ktx {
*/
struct OptionsEncodeCommon {
inline static const char* kNormalMode = "normal-mode";
inline static const char* kNormalize = "normalize";
inline static const char* kThreads = "threads";
inline static const char* kNoSse = "no-sse";

std::string commonOptions{};
bool normalMap{false};
bool normalize{false};
ktx_uint32_t threadCount{1};
ktx_bool_t noSSE;

Expand All @@ -85,12 +83,6 @@ struct OptionsEncodeCommon {
" nml.xy = nml.xy * 2.0 - 1.0; // Unpack to [-1,1]\n"
" nml.z = sqrt(1 - dot(nml.xy, nml.xy)); // Compute Z\n"
"ETC1S / BasisLZ encoding, RDO is disabled (no selector RDO, no endpoint RDO) to provide better quality.")
(kNormalize, "Normalize input normals to have a unit length. Only valid for\n"
"linear textures with 2 or more components. For 2-component inputs\n"
"2D unit normals are calculated. Do not use these 2D unit normals\n"
"to generate X+Y normals for --normal-mode. For 4-component inputs\n"
"a 3D unit normal is calculated. 1.0 is used for the value of the\n"
"4th component.\n")
(kThreads, "Sets the number of threads to use during encoding. By default, encoding "
"will use the number of threads reported by thread::hardware_concurrency or 1 if "
"value returned is 0.", cxxopts::value<uint32_t>(), "<count>")
Expand All @@ -116,11 +108,6 @@ struct OptionsEncodeCommon {
normalMap = true;
}

if (args[kNormalize].count()) {
captureCommonOption(kNormalize);
normalize = true;
}

if (args[kThreads].count()) {
threadCount = captureCodecOption<uint32_t>(args, kThreads);
}
Expand All @@ -136,7 +123,6 @@ template <typename Options, typename Codec>
constexpr void fillOptionsCodec(Options &options) {
options.Codec::threadCount = options.OptionsEncodeCommon::threadCount;
options.Codec::normalMap = options.OptionsEncodeCommon::normalMap;
// options.Codec::normalize = options.OptionsEncodeCommon::normalize;
}

template <typename Options>
Expand Down

0 comments on commit 52d9370

Please sign in to comment.