| 1296 | } |
| 1297 | |
| 1298 | void CommandCreate::processOptions(cxxopts::Options& opts, cxxopts::ParseResult& args) { |
| 1299 | options.process(opts, args, *this); |
| 1300 | |
| 1301 | numLevels = options.levels.value_or(1); |
| 1302 | numLayers = options.layers.value_or(1); |
| 1303 | numFaces = options.cubemap ? 6 : 1; |
| 1304 | baseDepth = options.depth.value_or(1u); |
| 1305 | |
| 1306 | if (options.raw) { |
| 1307 | // options.levels <= max for dimensions was checked in CreateOptions::process |
| 1308 | checkNumInputImages(); |
| 1309 | } |
| 1310 | |
| 1311 | if (!isFormatAstc(options.vkFormat)) { |
| 1312 | for (const char* astcOption : OptionsEncodeASTC::kAstcOptions) |
| 1313 | if (args[astcOption].count()) |
| 1314 | fatal_usage("--{} can only be used with ASTC formats.", astcOption); |
| 1315 | } else { |
| 1316 | fillOptionsCodecAstc<decltype(options)>(options); |
| 1317 | if (options.OptionsEncodeCommon::noSSE) |
| 1318 | fatal_usage("--{} is not allowed with ASTC encode", OptionsEncodeCommon::kNoSse); |
| 1319 | } |
| 1320 | |
| 1321 | if (options.codec == BasisCodec::BasisLZ) { |
| 1322 | if (options.zstd.has_value()) |
| 1323 | fatal_usage("Cannot encode to BasisLZ and supercompress with Zstd."); |
| 1324 | |
| 1325 | if (options.zlib.has_value()) |
| 1326 | fatal_usage("Cannot encode to BasisLZ and supercompress with ZLIB."); |
| 1327 | } |
| 1328 | |
| 1329 | if (options.codec != BasisCodec::NONE) { |
| 1330 | switch (options.vkFormat) { |
| 1331 | case VK_FORMAT_R8_UNORM: |
| 1332 | case VK_FORMAT_R8_SRGB: |
| 1333 | case VK_FORMAT_R8G8_UNORM: |
| 1334 | case VK_FORMAT_R8G8_SRGB: |
| 1335 | case VK_FORMAT_R8G8B8_UNORM: |
| 1336 | case VK_FORMAT_R8G8B8_SRGB: |
| 1337 | case VK_FORMAT_R8G8B8A8_UNORM: |
| 1338 | case VK_FORMAT_R8G8B8A8_SRGB: |
| 1339 | // Allowed formats |
| 1340 | break; |
| 1341 | default: |
| 1342 | fatal_usage("Only R8, RG8, RGB8, or RGBA8 UNORM and SRGB formats can be encoded, " |
| 1343 | "but format is {}.", toString(VkFormat(options.vkFormat))); |
| 1344 | break; |
| 1345 | } |
| 1346 | } |
| 1347 | |
| 1348 | const auto basisCodec = options.codec == BasisCodec::BasisLZ || options.codec == BasisCodec::UASTC; |
| 1349 | const auto astcCodec = isFormatAstc(options.vkFormat); |
| 1350 | const auto canCompare = basisCodec || astcCodec; |
| 1351 | |
| 1352 | if (basisCodec) |
| 1353 | fillOptionsCodecBasis<decltype(options)>(options); |
| 1354 | |
| 1355 | if (options.compare_ssim && !canCompare) |