Remove handwritten array from the driver properties test
authorVihanakangas <venni.ihanakangas@siru.fi>
Wed, 17 Jun 2020 10:26:21 +0000 (13:26 +0300)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Fri, 26 Jun 2020 11:16:03 +0000 (07:16 -0400)
Replace knownDriverIds in vktApiDriverProperties.cpp with
an array generated from the header.

Affects:
dEQP-VK.api.driver_properties.*

Components: Vulkan, Framework

VK-GL-CTS Issue: 2368

Change-Id: Ib67a417e8dfaa4a03ef426dc8dd2655df45b85d5

external/vulkancts/framework/vulkan/vkKnownDriverIds.inl [new file with mode: 0644]
external/vulkancts/modules/vulkan/api/vktApiDriverPropertiesTests.cpp
external/vulkancts/scripts/gen_framework.py

diff --git a/external/vulkancts/framework/vulkan/vkKnownDriverIds.inl b/external/vulkancts/framework/vulkan/vkKnownDriverIds.inl
new file mode 100644 (file)
index 0000000..0d9a64a
--- /dev/null
@@ -0,0 +1,36 @@
+/* WARNING: This is auto-generated file. Do not modify, since changes will
+ * be lost! Modify the generating script instead.
+ */
+static const struct
+{
+       std::string driver;
+       deUint32 id;
+} driverIds [] =
+{
+       {"VK_DRIVER_ID_AMD_PROPRIETARY", 1},
+       {"VK_DRIVER_ID_AMD_OPEN_SOURCE", 2},
+       {"VK_DRIVER_ID_MESA_RADV", 3},
+       {"VK_DRIVER_ID_NVIDIA_PROPRIETARY", 4},
+       {"VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS", 5},
+       {"VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA", 6},
+       {"VK_DRIVER_ID_IMAGINATION_PROPRIETARY", 7},
+       {"VK_DRIVER_ID_QUALCOMM_PROPRIETARY", 8},
+       {"VK_DRIVER_ID_ARM_PROPRIETARY", 9},
+       {"VK_DRIVER_ID_GOOGLE_SWIFTSHADER", 10},
+       {"VK_DRIVER_ID_GGP_PROPRIETARY", 11},
+       {"VK_DRIVER_ID_BROADCOM_PROPRIETARY", 12},
+       {"VK_DRIVER_ID_MESA_LLVMPIPE", 13},
+       {"VK_DRIVER_ID_AMD_PROPRIETARY_KHR", 1},        // VK_DRIVER_ID_AMD_PROPRIETARY
+       {"VK_DRIVER_ID_AMD_OPEN_SOURCE_KHR", 2},        // VK_DRIVER_ID_AMD_OPEN_SOURCE
+       {"VK_DRIVER_ID_MESA_RADV_KHR", 3},      // VK_DRIVER_ID_MESA_RADV
+       {"VK_DRIVER_ID_NVIDIA_PROPRIETARY_KHR", 4},     // VK_DRIVER_ID_NVIDIA_PROPRIETARY
+       {"VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS_KHR", 5},      // VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS
+       {"VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA_KHR", 6}, // VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA
+       {"VK_DRIVER_ID_IMAGINATION_PROPRIETARY_KHR", 7},        // VK_DRIVER_ID_IMAGINATION_PROPRIETARY
+       {"VK_DRIVER_ID_QUALCOMM_PROPRIETARY_KHR", 8},   // VK_DRIVER_ID_QUALCOMM_PROPRIETARY
+       {"VK_DRIVER_ID_ARM_PROPRIETARY_KHR", 9},        // VK_DRIVER_ID_ARM_PROPRIETARY
+       {"VK_DRIVER_ID_GOOGLE_SWIFTSHADER_KHR", 10},    // VK_DRIVER_ID_GOOGLE_SWIFTSHADER
+       {"VK_DRIVER_ID_GGP_PROPRIETARY_KHR", 11},       // VK_DRIVER_ID_GGP_PROPRIETARY
+       {"VK_DRIVER_ID_BROADCOM_PROPRIETARY_KHR", 12},  // VK_DRIVER_ID_BROADCOM_PROPRIETARY
+       {"VK_DRIVER_ID_MAX_ENUM", 0x7FFFFFFF}
+};
index 1585c04..bf76c77 100644 (file)
@@ -27,6 +27,7 @@
 #include "vktTestCaseUtil.hpp"
 #include "vkQueryUtil.hpp"
 #include "vkTypeUtil.hpp"
+#include "vkKnownDriverIds.inl"
 
 using namespace vk;
 
@@ -46,23 +47,6 @@ enum TestType
        TEST_TYPE_VERSION,
 };
 
-static const deUint32 knownDriverIds[] =
-{
-       // Specified in the Vulkan registry (vk.xml)
-       1,      // author = "Advanced Micro Devices, Inc."   comment = "AMD proprietary driver"
-       2,      // author = "Advanced Micro Devices, Inc."   comment = "AMD open-source driver"
-       3,      // author = "Mesa open source project"       comment = "Mesa RADV driver"
-       4,      // author = "NVIDIA Corporation"             comment = "NVIDIA proprietary driver"
-       5,      // author = "Intel Corporation"              comment = "Intel proprietary Windows driver"
-       6,      // author = "Intel Corporation"              comment = "Intel open-source Mesa driver"
-       7,      // author = "Imagination Technologies"       comment = "Imagination proprietary driver"
-       8,      // author = "Qualcomm Technologies, Inc."    comment = "Qualcomm proprietary driver"
-       9,      // author = "Arm Limited"                    comment = "Arm proprietary driver"
-       10,     // <enum value="10"      name="VK_DRIVER_ID_GOOGLE_SWIFTSHADER_KHR"        comment="Google LLC"/>
-       11,     // <enum value="11"      name="VK_DRIVER_ID_GGP_PROPRIETARY_KHR"           comment="Google LLC"/>
-       12,     // <enum value="12"      name="VK_DRIVER_ID_BROADCOM_PROPRIETARY_KHR"      comment="Broadcom Inc."/>
-};
-
 static const VkConformanceVersionKHR knownConformanceVersions[] =
 {
        makeConformanceVersion(1, 2, 3, 0),
@@ -111,9 +95,9 @@ void checkSupport (Context& context, const TestType config)
 
 void testDriverMatch (const VkPhysicalDeviceDriverPropertiesKHR& deviceDriverProperties)
 {
-       for (const deUint32* pDriverId = knownDriverIds; pDriverId != DE_ARRAY_END(knownDriverIds); ++pDriverId)
+       for (deUint32 driverNdx = 0; driverNdx < DE_LENGTH_OF_ARRAY(driverIds); driverNdx++)
        {
-               if (deviceDriverProperties.driverID == *pDriverId)
+               if (deviceDriverProperties.driverID == driverIds[driverNdx].id)
                        return;
        }
 
index 3a59624..11d9baf 100644 (file)
@@ -1444,6 +1444,44 @@ def writeTypeUtil (api, filename):
 
        writeInlFile(filename, INL_HEADER, gen())
 
+def writeDriverIds(filename):
+
+       driverIdsString = []
+       driverIdsString.append("static const struct\n"
+                                        "{\n"
+                                        "\tstd::string driver;\n"
+                                        "\tdeUint32 id;\n"
+                                        "} driverIds [] =\n"
+                                        "{")
+
+       vulkanCore = readFile(os.path.join(VULKAN_H_DIR, "vulkan_core.h"))
+
+       items = re.search(r'(?:typedef\s+enum\s+VkDriverId\s*{)((.*\n)*)(?:}\s*VkDriverId\s*;)', vulkanCore).group(1).split(',')
+       driverItems = dict()
+       for item in items:
+               item.strip()
+               splitted = item.split('=')
+               key = splitted[0].strip()
+               value_str = splitted[1].strip()
+               try: # is this previously defined value?
+                       value = driverItems[value_str]
+               except:
+                       value = value_str
+                       value_str = ""
+               if value_str:
+                       value_str = "\t// " + value_str
+               driverItems[key] = value
+               if not item == items[-1]:
+                       driverIdsString.append("\t{\"" + key + "\"" + ", " + value + "}," + value_str)
+               else:
+                       driverIdsString.append("\t{\"" + key + "\"" + ", " + value + "}" + value_str)
+               driverItems[key] = value
+
+       driverIdsString.append("};")
+
+       writeInlFile(filename, INL_HEADER, driverIdsString)
+
+
 def writeSupportedExtenions(api, filename):
 
        def writeExtensionsForVersions(map):
@@ -2216,3 +2254,4 @@ if __name__ == "__main__":
        writeMandatoryFeatures                                  (     os.path.join(VULKAN_DIR, "vkMandatoryFeatures.inl"))
        writeExtensionList                                              (     os.path.join(VULKAN_DIR, "vkInstanceExtensions.inl"),                             'INSTANCE')
        writeExtensionList                                              (     os.path.join(VULKAN_DIR, "vkDeviceExtensions.inl"),                               'DEVICE')
+       writeDriverIds                                                  (     os.path.join(VULKAN_DIR, "vkKnownDriverIds.inl"))