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 namespace
32 {
33 using namespace vk;
34 using namespace vkt;
35
checkSupport(Context & context,const VkFormat format)36 void checkSupport (Context& context, const VkFormat format)
37 {
38 DE_UNREF(format);
39 context.requireDeviceFunctionality(VK_KHR_FORMAT_FEATURE_FLAGS_2_EXTENSION_NAME);
40 context.requireInstanceFunctionality(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
41 }
42
test(Context & context,const VkFormat format)43 tcu::TestStatus test (Context& context, const VkFormat format)
44 {
45 const VkFormatProperties3KHR formatProperties (context.getFormatProperties(format));
46 const VkFormatProperties3KHR requiredProperties (context.getRequiredFormatProperties(format));
47
48 bool allPass = true;
49 allPass = allPass && ((formatProperties.bufferFeatures & requiredProperties.bufferFeatures) == requiredProperties.bufferFeatures);
50 allPass = allPass && ((formatProperties.linearTilingFeatures & requiredProperties.linearTilingFeatures) == requiredProperties.linearTilingFeatures);
51 allPass = allPass && ((formatProperties.optimalTilingFeatures & requiredProperties.optimalTilingFeatures) == requiredProperties.optimalTilingFeatures);
52
53 return allPass ? tcu::TestStatus::pass("") : tcu::TestStatus::fail("");
54 }
55
createTestCases(tcu::TestCaseGroup * group)56 void createTestCases (tcu::TestCaseGroup* group)
57 {
58 for (VkFormat format = VK_FORMAT_R4G4_UNORM_PACK8; format < VK_CORE_FORMAT_LAST; format = static_cast<VkFormat>(format+1))
59 {
60 std::string testName = de::toLower(std::string(getFormatName(format)).substr(10));
61 addFunctionCase(group, testName, std::string(), checkSupport, test, format);
62 }
63 }
64
65 } // namespace
66
67 namespace vkt
68 {
69 namespace api
70 {
71
createFormatPropertiesExtendedKHRTests(tcu::TestContext & testCtx)72 tcu::TestCaseGroup* createFormatPropertiesExtendedKHRTests (tcu::TestContext& testCtx)
73 {
74 return createTestGroup(testCtx, "format_feature_flags2", "VK_KHR_format_feature_flags2 tests", createTestCases);
75 }
76
77 } // api
78 } // vkt
79