Add VK_EXT_pci_bus_info tests
authorRicardo Garcia <rgarcia@igalia.com>
Mon, 1 Apr 2019 10:57:34 +0000 (12:57 +0200)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 11 Apr 2019 11:52:52 +0000 (07:52 -0400)
Add test to verify values returned as the physical device PCI bus info
properties make sense and are not invalid.

Affected tests:

dEQP-VK.api.info.get_physical_device_properties2.properties

Components: Vulkan
VK-GL-CTS issue: 1690

Change-Id: I737d1be7f0727db8a45de6a4286fa00e305157d5

external/vulkancts/framework/vulkan/vkBasicTypes.inl
external/vulkancts/framework/vulkan/vkGetStructureTypeImpl.inl
external/vulkancts/framework/vulkan/vkStrUtil.inl
external/vulkancts/framework/vulkan/vkStrUtilImpl.inl
external/vulkancts/framework/vulkan/vkStructTypes.inl
external/vulkancts/framework/vulkan/vkVulkan_c.inl
external/vulkancts/modules/vulkan/api/vktApiFeatureInfo.cpp
external/vulkancts/scripts/gen_framework.py
external/vulkancts/scripts/src/vulkan.h.in

index 7cba36c15c7dffaac0d4650f2e13e9e86a3b280d..5192ffe87631827111b527443a95fbe6ddda5d66 100644 (file)
@@ -351,6 +351,7 @@ enum VkStructureType
        VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES_KHR                  = 1000199000,
        VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE_KHR                                 = 1000199001,
        VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES_KHR                              = 1000211000,
+       VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT                                   = 1000212000,
        VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES_EXT                              = 1000221000,
        VK_STRUCTURE_TYPE_SURFACE_PROTECTED_CAPABILITIES_KHR                                                    = 1000239000,
        VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_EXT                    = 1000244000,
@@ -2294,3 +2295,4 @@ VK_DEFINE_PLATFORM_TYPE(RROutput,                                 void*);
 #define VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_ADDRESS_FEATURES_EXT VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_EXT
 #define VK_NV_COOPERATIVE_MATRIX_SPEC_VERSION 1
 #define VK_EXT_HOST_QUERY_RESET_SPEC_VERSION 1
+#define VK_EXT_PCI_BUS_INFO_SPEC_VERSION 2
index da5aabbdf2d0f9e3326537733370ba49b448d772..6cac6706b359f0fab2b5b856ab48a666f882b389 100644 (file)
@@ -1301,3 +1301,8 @@ template<> VkStructureType getStructureType<VkPhysicalDeviceHostQueryResetFeatur
        return VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES_EXT;
 }
 
+template<> VkStructureType getStructureType<VkPhysicalDevicePCIBusInfoPropertiesEXT> (void)
+{
+       return VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT;
+}
+
index 153f91447db8cbad3a61f15a04e6fb82de17cd7e..1015fb889a479ad42e32a66ee129363e27ed4d72 100644 (file)
@@ -639,3 +639,4 @@ std::ostream&       operator<<      (std::ostream& s, const VkCooperativeMatrixPropertiesNV
 std::ostream&  operator<<      (std::ostream& s, const VkPhysicalDeviceCooperativeMatrixPropertiesNV& value);
 std::ostream&  operator<<      (std::ostream& s, const VkPhysicalDeviceCooperativeMatrixFeaturesNV& value);
 std::ostream&  operator<<      (std::ostream& s, const VkPhysicalDeviceHostQueryResetFeaturesEXT& value);
+std::ostream&  operator<<      (std::ostream& s, const VkPhysicalDevicePCIBusInfoPropertiesEXT& value);
index bf2083fcf4442ba1bc86f3b54e3ae82b338ff332..7990ec9f496fd792b9400fa9466da48ceb395ce0 100644 (file)
@@ -360,6 +360,7 @@ const char* getStructureTypeName (VkStructureType value)
                case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES_KHR:                    return "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES_KHR";
                case VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE_KHR:                                   return "VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE_KHR";
                case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES_KHR:                                return "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES_KHR";
+               case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT:                                             return "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT";
                case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES_EXT:                                return "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES_EXT";
                case VK_STRUCTURE_TYPE_SURFACE_PROTECTED_CAPABILITIES_KHR:                                                              return "VK_STRUCTURE_TYPE_SURFACE_PROTECTED_CAPABILITIES_KHR";
                case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_EXT:                              return "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_EXT";
@@ -6782,3 +6783,16 @@ std::ostream& operator<< (std::ostream& s, const VkPhysicalDeviceHostQueryResetF
        s << '}';
        return s;
 }
+
+std::ostream& operator<< (std::ostream& s, const VkPhysicalDevicePCIBusInfoPropertiesEXT& value)
+{
+       s << "VkPhysicalDevicePCIBusInfoPropertiesEXT = {\n";
+       s << "\tsType = " << value.sType << '\n';
+       s << "\tpNext = " << value.pNext << '\n';
+       s << "\tpciDomain = " << value.pciDomain << '\n';
+       s << "\tpciBus = " << value.pciBus << '\n';
+       s << "\tpciDevice = " << value.pciDevice << '\n';
+       s << "\tpciFunction = " << value.pciFunction << '\n';
+       s << '}';
+       return s;
+}
index 37fa5caf57386aab1e8e44ef4abf9581967446b6..cd819a257bd5d78302407ca188fef08dc33a5c3d 100644 (file)
@@ -3313,6 +3313,16 @@ struct VkPhysicalDeviceHostQueryResetFeaturesEXT
        VkBool32                hostQueryReset;
 };
 
+struct VkPhysicalDevicePCIBusInfoPropertiesEXT
+{
+       VkStructureType sType;
+       void*                   pNext;
+       deUint32                pciDomain;
+       deUint32                pciBus;
+       deUint32                pciDevice;
+       deUint32                pciFunction;
+};
+
 
 
 
index e28ed1aab6cea27019b9654616a82baf8e627721..e49123a943d045a23fea9b99dc0707e9f99471f5 100644 (file)
@@ -415,6 +415,7 @@ typedef enum VkStructureType {
     VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES_KHR = 1000199000,
     VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE_KHR = 1000199001,
     VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES_KHR = 1000211000,
+    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT = 1000212000,
     VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES_EXT = 1000221000,
     VK_STRUCTURE_TYPE_SURFACE_PROTECTED_CAPABILITIES_KHR = 1000239000,
     VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_EXT = 1000244000,
@@ -8291,6 +8292,21 @@ VKAPI_ATTR void VKAPI_CALL vkResetQueryPoolEXT(
     deUint32                                    queryCount);
 #endif
 
+
+#define VK_EXT_pci_bus_info 1
+#define VK_EXT_PCI_BUS_INFO_SPEC_VERSION  2
+#define VK_EXT_PCI_BUS_INFO_EXTENSION_NAME "VK_EXT_pci_bus_info"
+
+typedef struct VkPhysicalDevicePCIBusInfoPropertiesEXT {
+    VkStructureType    sType;
+    void*              pNext;
+    deUint32           pciDomain;
+    deUint32           pciBus;
+    deUint32           pciDevice;
+    deUint32           pciFunction;
+} VkPhysicalDevicePCIBusInfoPropertiesEXT;
+
+
 #ifdef __cplusplus
 }
 #endif
index 8ef92d790cf30f97254dcf2bb2f4e696e7693470..3bfa0939c3a234f3d340688bfda730fe7bcb8f4d 100644 (file)
@@ -51,6 +51,7 @@
 #include <vector>
 #include <set>
 #include <string>
+#include <limits>
 
 namespace vkt
 {
@@ -68,6 +69,8 @@ using std::string;
 using tcu::TestLog;
 using tcu::ScopedLogSection;
 
+const deUint32 DEUINT32_MAX = std::numeric_limits<deUint32>::max();
+
 enum
 {
        GUARD_SIZE                                                              = 0x20,                 //!< Number of bytes to check
@@ -2611,6 +2614,19 @@ tcu::TestStatus imageFormatProperties (Context& context, const VkFormat format,
 
 // VK_KHR_get_physical_device_properties2
 
+string toString(const VkPhysicalDevicePCIBusInfoPropertiesEXT& value)
+{
+       std::ostringstream  s;
+       s << "VkPhysicalDevicePCIBusInfoPropertiesEXT = {\n";
+       s << "\tsType = " << value.sType << '\n';
+       s << "\tpciDomain = " << value.pciDomain << '\n';
+       s << "\tpciBus = " << value.pciBus << '\n';
+       s << "\tpciDevice = " << value.pciDevice << '\n';
+       s << "\tpciFunction = " << value.pciFunction << '\n';
+       s << '}';
+       return s.str();
+}
+
 bool checkExtension (vector<VkExtensionProperties>& properties, const char* extension)
 {
        for (size_t ndx = 0; ndx < properties.size(); ++ndx)
@@ -3041,6 +3057,54 @@ tcu::TestStatus deviceProperties2 (Context& context)
                log << TestLog::Message << dsResolveProperties[0] << TestLog::EndMessage;
        }
 
+       if (isExtensionSupported(extensions, RequiredExtension("VK_EXT_pci_bus_info", 2, 2)))
+       {
+               VkPhysicalDevicePCIBusInfoPropertiesEXT pciBusInfoProperties[count];
+
+               for (int ndx = 0; ndx < count; ++ndx)
+               {
+                       // Each PCI device is identified by an 8-bit domain number, 5-bit
+                       // device number and 3-bit function number[1][2].
+                       //
+                       // In addition, because PCI systems can be interconnected and
+                       // divided in segments, Linux assigns a 16-bit number to the device
+                       // as the "domain". In Windows, the segment or domain is stored in
+                       // the higher 24-bit section of the bus number.
+                       //
+                       // This means the maximum unsigned 32-bit integer for these members
+                       // are invalid values and should change after querying properties.
+                       //
+                       // [1] https://en.wikipedia.org/wiki/PCI_configuration_space
+                       // [2] PCI Express Base Specification Revision 3.0, section 2.2.4.2.
+                       deMemset(pciBusInfoProperties + ndx, 0, sizeof(pciBusInfoProperties[ndx]));
+                       pciBusInfoProperties[ndx].pciDomain   = DEUINT32_MAX;
+                       pciBusInfoProperties[ndx].pciBus      = DEUINT32_MAX;
+                       pciBusInfoProperties[ndx].pciDevice   = DEUINT32_MAX;
+                       pciBusInfoProperties[ndx].pciFunction = DEUINT32_MAX;
+
+                       pciBusInfoProperties[ndx].sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT;
+                       pciBusInfoProperties[ndx].pNext = DE_NULL;
+
+                       extProperties.pNext = pciBusInfoProperties + ndx;
+                       vki.getPhysicalDeviceProperties2(physicalDevice, &extProperties);
+               }
+
+               if (deMemCmp(pciBusInfoProperties + 0, pciBusInfoProperties + 1, sizeof(pciBusInfoProperties[0])) != 0)
+               {
+                       TCU_FAIL("Mismatch in VkPhysicalDevicePCIBusInfoPropertiesEXT");
+               }
+
+               log << TestLog::Message << toString(pciBusInfoProperties[0]) << TestLog::EndMessage;
+
+               if (pciBusInfoProperties[0].pciDomain   == DEUINT32_MAX ||
+                   pciBusInfoProperties[0].pciBus      == DEUINT32_MAX ||
+                   pciBusInfoProperties[0].pciDevice   == DEUINT32_MAX ||
+                   pciBusInfoProperties[0].pciFunction == DEUINT32_MAX)
+               {
+                   TCU_FAIL("Invalid information in VkPhysicalDevicePCIBusInfoPropertiesEXT");
+               }
+       }
+
        return tcu::TestStatus::pass("Querying device properties succeeded");
 }
 
index 88d6b0aa39311abe10530f8a946370052e446da2..079a697faa31eb77093f8bb5a8206c7f650e0d29 100644 (file)
@@ -138,6 +138,7 @@ def prefixName (prefix, name):
        name = name.replace("VIEWPORT_W", "VIEWPORT_W_")
        name = name.replace("_IDPROPERTIES", "_ID_PROPERTIES")
        name = name.replace("PHYSICAL_DEVICE_FLOAT_16_INT_8_FEATURES", "PHYSICAL_DEVICE_FLOAT16_INT8_FEATURES")
+       name = name.replace("_PCIBUS_", "_PCI_BUS_")
 
        return prefix + name
 
index c99d797df1b4db9464edbdb988d8780b184971f2..ee6a9876afb29c37761aca78673a3b8993d0893e 100755 (executable)
@@ -412,6 +412,7 @@ typedef enum VkStructureType {
     VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES_KHR = 1000199000,
     VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE_KHR = 1000199001,
     VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES_KHR = 1000211000,
+    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT = 1000212000,
     VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES_EXT = 1000221000,
     VK_STRUCTURE_TYPE_SURFACE_PROTECTED_CAPABILITIES_KHR = 1000239000,
     VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_EXT = 1000244000,
@@ -8288,6 +8289,21 @@ VKAPI_ATTR void VKAPI_CALL vkResetQueryPoolEXT(
     uint32_t                                    queryCount);
 #endif
 
+
+#define VK_EXT_pci_bus_info 1
+#define VK_EXT_PCI_BUS_INFO_SPEC_VERSION  2
+#define VK_EXT_PCI_BUS_INFO_EXTENSION_NAME "VK_EXT_pci_bus_info"
+
+typedef struct VkPhysicalDevicePCIBusInfoPropertiesEXT {
+    VkStructureType    sType;
+    void*              pNext;
+    uint32_t           pciDomain;
+    uint32_t           pciBus;
+    uint32_t           pciDevice;
+    uint32_t           pciFunction;
+} VkPhysicalDevicePCIBusInfoPropertiesEXT;
+
+
 #ifdef __cplusplus
 }
 #endif