1 /*-------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2018 Advanced Micro Devices, Inc.
6 * Copyright (c) 2018 The Khronos Group Inc.
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 * \brief VK_KHR_driver_properties tests
23 *//*--------------------------------------------------------------------*/
25 #include "vktApiDriverPropertiesTests.hpp"
26 #include "vktTestGroupUtil.hpp"
27 #include "vktTestCaseUtil.hpp"
28 #include "vkQueryUtil.hpp"
29 #include "vkTypeUtil.hpp"
40 static const deUint32 knownDriverIds[] =
42 // Specified in the Vulkan registry (vk.xml)
43 1, // author = "Advanced Micro Devices, Inc." comment = "AMD proprietary driver"
44 2, // author = "Advanced Micro Devices, Inc." comment = "AMD open-source driver"
45 3, // author = "Mesa open source project" comment = "Mesa RADV driver"
46 4, // author = "NVIDIA Corporation" comment = "NVIDIA proprietary driver"
47 5, // author = "Intel Corporation" comment = "Intel proprietary Windows driver"
48 6, // author = "Intel Corporation" comment = "Intel open-source Mesa driver"
49 7, // author = "Imagination Technologies" comment = "Imagination proprietary driver"
50 8, // author = "Qualcomm Technologies, Inc." comment = "Qualcomm proprietary driver"
51 9, // author = "Arm Limited" comment = "Arm proprietary driver"
54 static const VkConformanceVersionKHR knownConformanceVersions[] =
56 makeConformanceVersionKHR(1, 1, 3, 1),
57 makeConformanceVersionKHR(1, 1, 3, 0),
58 makeConformanceVersionKHR(1, 1, 2, 3),
59 makeConformanceVersionKHR(1, 1, 2, 2),
60 makeConformanceVersionKHR(1, 1, 2, 1),
61 makeConformanceVersionKHR(1, 1, 2, 0),
62 makeConformanceVersionKHR(1, 1, 1, 3),
63 makeConformanceVersionKHR(1, 1, 1, 2),
64 makeConformanceVersionKHR(1, 1, 1, 1),
65 makeConformanceVersionKHR(1, 1, 1, 0),
66 makeConformanceVersionKHR(1, 1, 0, 3),
67 makeConformanceVersionKHR(1, 0, 2, 6),
68 makeConformanceVersionKHR(1, 0, 2, 5),
69 makeConformanceVersionKHR(1, 0, 2, 4),
70 makeConformanceVersionKHR(1, 0, 2, 3),
71 makeConformanceVersionKHR(1, 0, 2, 2),
72 makeConformanceVersionKHR(1, 0, 2, 1),
73 makeConformanceVersionKHR(1, 0, 2, 0),
76 DE_INLINE bool isNullTerminated(const char* str, const deUint32 maxSize)
78 return deStrnlen(str, maxSize) < maxSize;
81 DE_INLINE bool operator==(const VkConformanceVersionKHR& a, const VkConformanceVersionKHR& b)
83 return ((a.major == b.major) &&
84 (a.minor == b.minor) &&
85 (a.subminor == b.subminor) &&
86 (a.patch == b.patch));
89 tcu::TestStatus testQueryProperties (Context& context)
91 // Check extension support
93 if (!isDeviceExtensionSupported(context.getUsedApiVersion(), context.getDeviceExtensions(), "VK_KHR_driver_properties"))
94 TCU_THROW(NotSupportedError, "Unsupported extension: VK_KHR_driver_properties");
96 // Query the driver properties
98 const VkPhysicalDevice physDevice = context.getPhysicalDevice();
99 const int memsetPattern = 0xaa;
100 VkPhysicalDeviceProperties2 deviceProperties2;
101 VkPhysicalDeviceDriverPropertiesKHR deviceDriverProperties;
103 deMemset(&deviceDriverProperties, memsetPattern, sizeof(deviceDriverProperties));
104 deviceDriverProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES_KHR;
105 deviceDriverProperties.pNext = DE_NULL;
107 deMemset(&deviceProperties2, memsetPattern, sizeof(deviceProperties2));
108 deviceProperties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
109 deviceProperties2.pNext = &deviceDriverProperties;
111 context.getInstanceInterface().getPhysicalDeviceProperties2(physDevice, &deviceProperties2);
113 // Verify the returned values
117 for (const deUint32* pDriverId = knownDriverIds; (pDriverId != DE_ARRAY_END(knownDriverIds)) && !match; ++pDriverId)
119 if (deviceDriverProperties.driverID == *pDriverId)
123 if (!isNullTerminated(deviceDriverProperties.driverName, VK_MAX_DRIVER_NAME_SIZE_KHR))
124 TCU_FAIL("Driver name is not a null-terminated string");
126 if (deviceDriverProperties.driverName[0] == 0)
127 TCU_FAIL("Driver name is empty");
129 if (!isNullTerminated(deviceDriverProperties.driverInfo, VK_MAX_DRIVER_INFO_SIZE_KHR))
130 TCU_FAIL("Driver info is not a null-terminated string");
132 bool conformanceVersionMatch = false;
134 for (const VkConformanceVersionKHR* pConformanceVersion = knownConformanceVersions;
135 pConformanceVersion != DE_ARRAY_END(knownConformanceVersions);
136 ++pConformanceVersion)
138 if (deviceDriverProperties.conformanceVersion == *pConformanceVersion)
140 conformanceVersionMatch = true;
145 if (!conformanceVersionMatch)
146 TCU_FAIL("Wrong driver conformance version");
151 TCU_FAIL("Driver ID did not match any known driver");
153 return tcu::TestStatus::pass("Pass");
156 void createTestCases (tcu::TestCaseGroup* group)
158 addFunctionCase(group, "properties", "Query VkPhysicalDeviceDriverPropertiesKHR and check its values", testQueryProperties);
163 tcu::TestCaseGroup* createDriverPropertiesTests(tcu::TestContext& testCtx)
165 return createTestGroup(testCtx, "driver_properties", "VK_KHR_driver_properties tests", createTestCases);