1/*------------------------------------------------------------------------- 2* Vulkan Conformance Tests 3* ------------------------ 4* 5* Copyright (c) 2021 The Khronos Group Inc. 6* Copyright (c) 2016 The Android Open Source Project 7* 8* Licensed under the Apache License, Version 2.0 (the "License"); 9* you may not use this file except in compliance with the License. 10* You may obtain a copy of the License at 11* 12* http://www.apache.org/licenses/LICENSE-2.0 13* 14* Unless required by applicable law or agreed to in writing, software 15* distributed under the License is distributed on an "AS IS" BASIS, 16* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17* See the License for the specific language governing permissions and 18* limitations under the License. 19* 20*//*! 21* \file 22* \brief VK_KHR_format_feature_flags2 Tests. 23*//*--------------------------------------------------------------------*/ 24 25#include "vktApiFormatPropertiesExtendedKHRtests.hpp" 26#include "vktTestCase.hpp" 27#include "vktTestCaseUtil.hpp" 28#include "vktTestGroupUtil.hpp" 29#include "vkStrUtil.hpp" 30 31#include <iostream> 32#include <iomanip> 33 34namespace 35{ 36using namespace vk; 37using namespace vkt; 38 39void checkSupport (Context& context, const VkFormat format) 40{ 41 DE_UNREF(format); 42 context.requireDeviceFunctionality(VK_KHR_FORMAT_FEATURE_FLAGS_2_EXTENSION_NAME); 43 context.requireInstanceFunctionality(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); 44} 45 46void checkFlags (VkFlags64 reportedFlags, VkFlags64 requestedFlags, const char* setName) 47{ 48 const auto andMask = (reportedFlags & requestedFlags); 49 if (andMask != requestedFlags) 50 { 51 // Find which bits are missing. 52 const auto missingBits = (andMask ^ requestedFlags); 53 std::ostringstream msg; 54 msg << setName << ": missing flags 0x" << std::hex << std::setw(16) << std::setfill('0') << missingBits; 55 TCU_FAIL(msg.str()); 56 } 57} 58 59tcu::TestStatus test (Context& context, const VkFormat format) 60{ 61 const VkFormatProperties3 formatProperties (context.getFormatProperties(format)); 62 const VkFormatProperties3 requiredProperties (context.getRequiredFormatProperties(format)); 63 64 checkFlags(formatProperties.bufferFeatures, requiredProperties.bufferFeatures, "Buffer features"); 65 checkFlags(formatProperties.linearTilingFeatures, requiredProperties.linearTilingFeatures, "Linear tiling features"); 66 checkFlags(formatProperties.optimalTilingFeatures, requiredProperties.optimalTilingFeatures, "Optimal tiling features"); 67 68 return tcu::TestStatus::pass("Pass"); 69} 70 71void createTestCases (tcu::TestCaseGroup* group) 72{ 73 for (VkFormat format = VK_FORMAT_R4G4_UNORM_PACK8; format < VK_CORE_FORMAT_LAST; format = static_cast<VkFormat>(format+1)) 74 { 75 std::string testName = de::toLower(std::string(getFormatName(format)).substr(10)); 76 addFunctionCase(group, testName, checkSupport, test, format); 77 } 78} 79 80} // namespace 81 82namespace vkt 83{ 84namespace api 85{ 86 87tcu::TestCaseGroup* createFormatPropertiesExtendedKHRTests (tcu::TestContext& testCtx) 88{ 89 return createTestGroup(testCtx, "format_feature_flags2", createTestCases); 90} 91 92} // api 93} // vkt 94