| 871 | } |
| 872 | |
| 873 | void ValidationContext::validateDFDBasic(uint32_t blockIndex, const uint32_t* dfd, const BDFD& block, const std::vector<SampleType>& samples) { |
| 874 | |
| 875 | numSamples = static_cast<uint32_t>(samples.size()); |
| 876 | |
| 877 | parsedColorModel = khr_df_model_e(block.model); |
| 878 | parsedTransferFunction = khr_df_transfer_e(block.transfer); |
| 879 | parsedBlockByteLength = block.bytesPlanes[0]; |
| 880 | parsedBlockDimension0 = static_cast<uint8_t>(block.texelBlockDimension0); |
| 881 | parsedBlockDimension1 = static_cast<uint8_t>(block.texelBlockDimension1); |
| 882 | parsedBlockDimension2 = static_cast<uint8_t>(block.texelBlockDimension2); |
| 883 | |
| 884 | // Validate versionNumber |
| 885 | if (block.versionNumber != KHR_DF_VERSIONNUMBER_1_3) |
| 886 | error(DFD::BasicVersionNotSupported, blockIndex, toString(khr_df_versionnumber_e(block.versionNumber))); |
| 887 | |
| 888 | // Validate transferFunction |
| 889 | if (block.transfer > KHR_DF_TRANSFER_HLG_UNNORMALIZED_OETF) |
| 890 | error(DFD::BasicInvalidTransferFunction, blockIndex, block.transfer); |
| 891 | |
| 892 | // No test for VK_FORMAT_UNDEFINED is needed here because: |
| 893 | // - any transfer function is allowed when vkFormat is UNDEFINED as with, |
| 894 | // e.g., some Basis Universal formats; |
| 895 | // - the following tests return false for VK_FORMAT_UNDEFINED. |
| 896 | if (isFormatSRGB(VkFormat(header.vkFormat)) && block.transfer != KHR_DF_TRANSFER_SRGB) |
| 897 | error(DFD::BasicSRGBMismatch, blockIndex, toString(khr_df_transfer_e(block.transfer)), toString(VkFormat(header.vkFormat))); |
| 898 | |
| 899 | if (isFormatNotSRGBButHasSRGBVariant(VkFormat(header.vkFormat)) && block.transfer == KHR_DF_TRANSFER_SRGB) |
| 900 | error(DFD::BasicNotSRGBMismatch, blockIndex, toString(VkFormat(header.vkFormat))); |
| 901 | |
| 902 | // Validate colorModel |
| 903 | if (isFormat422(VkFormat(header.vkFormat))) { |
| 904 | if (!isProhibitedFormat(VkFormat(header.vkFormat))) |
| 905 | if (block.model != KHR_DF_MODEL_YUVSDA) |
| 906 | error(DFD::IncorrectModelFor422, blockIndex, toString(khr_df_model_e(block.model)), toString(VkFormat(header.vkFormat))); |
| 907 | |
| 908 | } else if (isFormatBlockCompressed(VkFormat(header.vkFormat))) { |
| 909 | const auto expectedBCColorModel = getColorModelForBlockCompressedFormat(VkFormat(header.vkFormat)); |
| 910 | if (khr_df_model_e(block.model) != expectedBCColorModel) |
| 911 | error(DFD::IncorrectModelForBlock, blockIndex, toString(khr_df_model_e(block.model)), toString(VkFormat(header.vkFormat)), toString(expectedBCColorModel)); |
| 912 | |
| 913 | } else if (header.vkFormat != VK_FORMAT_UNDEFINED) { |
| 914 | if (block.model != KHR_DF_MODEL_RGBSDA) |
| 915 | error(DFD::IncorrectModelForRGB, blockIndex, toString(khr_df_model_e(block.model)), toString(VkFormat(header.vkFormat))); |
| 916 | } |
| 917 | |
| 918 | if (header.supercompressionScheme == KTX_SS_BASIS_LZ) |
| 919 | if (block.model != KHR_DF_MODEL_ETC1S) |
| 920 | error(DFD::IncorrectModelForBLZE, blockIndex, toString(khr_df_model_e(block.model))); |
| 921 | |
| 922 | // Check GLTF KHR_texture_basisu specific errors |
| 923 | if (checkGLTFBasisU) { |
| 924 | switch (block.model) { |
| 925 | case KHR_DF_MODEL_ETC1S: |
| 926 | // Supercompression already verified above, only need to check samples. |
| 927 | if (samples.size() > 0) { |
| 928 | switch (samples[0].channelType) { |
| 929 | case KHR_DF_CHANNEL_ETC1S_RGB: |
| 930 | if (samples.size() > 1 && samples[1].channelType != KHR_DF_CHANNEL_ETC1S_AAA) |
nothing calls this directly
no test coverage detected