Add more tests to dEQP-VK.info
authorPyry Haulos <phaulos@google.com>
Fri, 9 Oct 2015 17:32:04 +0000 (10:32 -0700)
committerPyry Haulos <phaulos@google.com>
Mon, 12 Oct 2015 16:46:33 +0000 (09:46 -0700)
This adds queries for physical device properties and features, layers,
and extensions.

Change-Id: Icd04751174fbb426ae09c4c7e79e5e2a35df7025

external/vulkancts/framework/vulkan/vkQueryUtil.cpp
external/vulkancts/framework/vulkan/vkQueryUtil.hpp
external/vulkancts/modules/vulkan/vktInfo.cpp

index 389d4abc506857946218ec2e957c03b97659a399..5c903e63dd2f2f294cb2b27d4cb7311f4096d4d5 100644 (file)
 namespace vk
 {
 
-std::vector<VkPhysicalDevice> enumeratePhysicalDevices (const InstanceInterface& vk, VkInstance instance)
+using std::vector;
+
+vector<VkPhysicalDevice> enumeratePhysicalDevices (const InstanceInterface& vk, VkInstance instance)
 {
-       deUint32                                                numDevices      = 0;
-       std::vector<VkPhysicalDevice>   devices;
+       deUint32                                        numDevices      = 0;
+       vector<VkPhysicalDevice>        devices;
 
        VK_CHECK(vk.enumeratePhysicalDevices(instance, &numDevices, DE_NULL));
 
@@ -57,10 +59,10 @@ std::vector<VkPhysicalDevice> enumeratePhysicalDevices (const InstanceInterface&
        return devices;
 }
 
-std::vector<VkQueueFamilyProperties> getPhysicalDeviceQueueFamilyProperties (const InstanceInterface& vk, VkPhysicalDevice physicalDevice)
+vector<VkQueueFamilyProperties> getPhysicalDeviceQueueFamilyProperties (const InstanceInterface& vk, VkPhysicalDevice physicalDevice)
 {
-       deUint32                                                                numQueues       = 0;
-       std::vector<VkQueueFamilyProperties>    properties;
+       deUint32                                                numQueues       = 0;
+       vector<VkQueueFamilyProperties> properties;
 
        VK_CHECK(vk.getPhysicalDeviceQueueFamilyProperties(physicalDevice, &numQueues, DE_NULL));
 
@@ -99,4 +101,72 @@ VkMemoryRequirements getImageMemoryRequirements (const DeviceInterface& vk, VkDe
        return req;
 }
 
+vector<VkLayerProperties> enumerateInstanceLayerProperties (const PlatformInterface& vkp)
+{
+       vector<VkLayerProperties>       properties;
+       deUint32                                        numLayers       = 0;
+
+       VK_CHECK(vkp.enumerateInstanceLayerProperties(&numLayers, DE_NULL));
+
+       if (numLayers > 0)
+       {
+               properties.resize(numLayers);
+               VK_CHECK(vkp.enumerateInstanceLayerProperties(&numLayers, &properties[0]));
+               TCU_CHECK((size_t)numLayers == properties.size());
+       }
+
+       return properties;
+}
+
+vector<VkExtensionProperties> enumerateInstanceExtensionProperties (const PlatformInterface& vkp, const char* layerName)
+{
+       vector<VkExtensionProperties>   properties;
+       deUint32                                                numExtensions   = 0;
+
+       VK_CHECK(vkp.enumerateInstanceExtensionProperties(layerName, &numExtensions, DE_NULL));
+
+       if (numExtensions > 0)
+       {
+               properties.resize(numExtensions);
+               VK_CHECK(vkp.enumerateInstanceExtensionProperties(layerName, &numExtensions, &properties[0]));
+               TCU_CHECK((size_t)numExtensions == properties.size());
+       }
+
+       return properties;
+}
+
+vector<VkLayerProperties> enumerateDeviceLayerProperties (const InstanceInterface& vki, VkPhysicalDevice physicalDevice)
+{
+       vector<VkLayerProperties>       properties;
+       deUint32                                        numLayers       = 0;
+
+       VK_CHECK(vki.enumerateDeviceLayerProperties(physicalDevice, &numLayers, DE_NULL));
+
+       if (numLayers > 0)
+       {
+               properties.resize(numLayers);
+               VK_CHECK(vki.enumerateDeviceLayerProperties(physicalDevice, &numLayers, &properties[0]));
+               TCU_CHECK((size_t)numLayers == properties.size());
+       }
+
+       return properties;
+}
+
+vector<VkExtensionProperties> enumerateDeviceExtensionProperties (const InstanceInterface& vki, VkPhysicalDevice physicalDevice, const char* layerName)
+{
+       vector<VkExtensionProperties>   properties;
+       deUint32                                                numExtensions   = 0;
+
+       VK_CHECK(vki.enumerateDeviceExtensionProperties(physicalDevice, layerName, &numExtensions, DE_NULL));
+
+       if (numExtensions > 0)
+       {
+               properties.resize(numExtensions);
+               VK_CHECK(vki.enumerateDeviceExtensionProperties(physicalDevice, layerName, &numExtensions, &properties[0]));
+               TCU_CHECK((size_t)numExtensions == properties.size());
+       }
+
+       return properties;
+}
+
 } // vk
index e58b09e0a89fe7dd2b6b3af70f1f3859e55a60da..b576a9d0b32e34aaa220cf956cfb062258f7bb29 100644 (file)
@@ -48,6 +48,11 @@ VkPhysicalDeviceMemoryProperties             getPhysicalDeviceMemoryProperties               (const Inst
 VkMemoryRequirements                                   getBufferMemoryRequirements                             (const DeviceInterface& vk, VkDevice device, VkBuffer buffer);
 VkMemoryRequirements                                   getImageMemoryRequirements                              (const DeviceInterface& vk, VkDevice device, VkImage image);
 
+std::vector<VkLayerProperties>                 enumerateInstanceLayerProperties                (const PlatformInterface& vkp);
+std::vector<VkExtensionProperties>             enumerateInstanceExtensionProperties    (const PlatformInterface& vkp, const char* layerName);
+std::vector<VkLayerProperties>                 enumerateDeviceLayerProperties                  (const InstanceInterface& vki, VkPhysicalDevice physicalDevice);
+std::vector<VkExtensionProperties>             enumerateDeviceExtensionProperties              (const InstanceInterface& vki, VkPhysicalDevice physicalDevice, const char* layerName);
+
 } // vk
 
 #endif // _VKQUERYUTIL_HPP
index 955171fbd6b772a8a1b288336e986b97831d8551..0d3c05e4b2a9715ac740a2c0320a9aa901a3827e 100644 (file)
@@ -46,6 +46,7 @@
 #include "tcuFormatUtil.hpp"
 
 #include "deUniquePtr.hpp"
+#include "deMemory.h"
 
 namespace vkt
 {
@@ -56,11 +57,12 @@ using namespace vk;
 using std::vector;
 using std::string;
 using tcu::TestLog;
+using tcu::ScopedLogSection;
 
 tcu::TestStatus enumeratePhysicalDevices (Context& context)
 {
        TestLog&                                                log             = context.getTestContext().getLog();
-       const vector<VkPhysicalDevice>  devices = vk::enumeratePhysicalDevices(context.getInstanceInterface(), context.getInstance());
+       const vector<VkPhysicalDevice>  devices = enumeratePhysicalDevices(context.getInstanceInterface(), context.getInstance());
 
        log << TestLog::Integer("NumDevices", "Number of devices", "", QP_KEY_TAG_NONE, deInt64(devices.size()));
 
@@ -70,7 +72,115 @@ tcu::TestStatus enumeratePhysicalDevices (Context& context)
        return tcu::TestStatus::pass("Enumerating devices succeeded");
 }
 
-tcu::TestStatus queueProperties (Context& context)
+tcu::TestStatus enumerateInstanceLayers (Context& context)
+{
+       TestLog&                                                log                     = context.getTestContext().getLog();
+       const vector<VkLayerProperties> properties      = enumerateInstanceLayerProperties(context.getPlatformInterface());
+
+       for (size_t ndx = 0; ndx < properties.size(); ndx++)
+               log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage;
+
+       return tcu::TestStatus::pass("Enumerating layers succeeded");
+}
+
+tcu::TestStatus enumerateInstanceExtensions (Context& context)
+{
+       TestLog&        log             = context.getTestContext().getLog();
+
+       {
+               const ScopedLogSection                          section         (log, "Global", "Global Extensions");
+               const vector<VkExtensionProperties>     properties      = enumerateInstanceExtensionProperties(context.getPlatformInterface(), DE_NULL);
+
+               for (size_t ndx = 0; ndx < properties.size(); ndx++)
+                       log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage;
+       }
+
+       {
+               const vector<VkLayerProperties> layers  = enumerateInstanceLayerProperties(context.getPlatformInterface());
+
+               for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
+               {
+                       const ScopedLogSection                          section         (log, layer->layerName, string("Layer: ") + layer->layerName);
+                       const vector<VkExtensionProperties>     properties      = enumerateInstanceExtensionProperties(context.getPlatformInterface(), layer->layerName);
+
+                       for (size_t extNdx = 0; extNdx < properties.size(); extNdx++)
+                               log << TestLog::Message << extNdx << ": " << properties[extNdx] << TestLog::EndMessage;
+               }
+       }
+
+       return tcu::TestStatus::pass("Enumerating extensions succeeded");
+}
+
+tcu::TestStatus enumerateDeviceLayers (Context& context)
+{
+       TestLog&                                                log                     = context.getTestContext().getLog();
+       const vector<VkLayerProperties> properties      = vk::enumerateDeviceLayerProperties(context.getInstanceInterface(), context.getPhysicalDevice());
+
+       for (size_t ndx = 0; ndx < properties.size(); ndx++)
+               log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage;
+
+       return tcu::TestStatus::pass("Enumerating layers succeeded");
+}
+
+tcu::TestStatus enumerateDeviceExtensions (Context& context)
+{
+       TestLog&        log             = context.getTestContext().getLog();
+
+       {
+               const ScopedLogSection                          section         (log, "Global", "Global Extensions");
+               const vector<VkExtensionProperties>     properties      = enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), DE_NULL);
+
+               for (size_t ndx = 0; ndx < properties.size(); ndx++)
+                       log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage;
+       }
+
+       {
+               const vector<VkLayerProperties> layers  = enumerateDeviceLayerProperties(context.getInstanceInterface(), context.getPhysicalDevice());
+
+               for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
+               {
+                       const ScopedLogSection                          section         (log, layer->layerName, string("Layer: ") + layer->layerName);
+                       const vector<VkExtensionProperties>     properties      = enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), layer->layerName);
+
+                       for (size_t extNdx = 0; extNdx < properties.size(); extNdx++)
+                               log << TestLog::Message << extNdx << ": " << properties[extNdx] << TestLog::EndMessage;
+               }
+       }
+
+       return tcu::TestStatus::pass("Enumerating extensions succeeded");
+}
+
+tcu::TestStatus deviceFeatures (Context& context)
+{
+       TestLog&                                                log                     = context.getTestContext().getLog();
+       VkPhysicalDeviceFeatures                features;
+
+       deMemset(&features, 0, sizeof(features));
+
+       VK_CHECK(context.getInstanceInterface().getPhysicalDeviceFeatures(context.getPhysicalDevice(), &features));
+
+       log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage
+               << TestLog::Message << features << TestLog::EndMessage;
+
+       return tcu::TestStatus::pass("Query succeeded");
+}
+
+tcu::TestStatus deviceProperties (Context& context)
+{
+       TestLog&                                                log                     = context.getTestContext().getLog();
+       VkPhysicalDeviceProperties              props;
+
+       deMemset(&props, 0, sizeof(props));
+
+       VK_CHECK(context.getInstanceInterface().getPhysicalDeviceProperties(context.getPhysicalDevice(), &props));
+
+       log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage
+               << TestLog::Message << props << TestLog::EndMessage;
+
+       return tcu::TestStatus::pass("Query succeeded");
+}
+
+tcu::TestStatus deviceQueueFamilyProperties (Context& context)
 {
        TestLog&                                                                log                                     = context.getTestContext().getLog();
        const vector<VkQueueFamilyProperties>   queueProperties         = getPhysicalDeviceQueueFamilyProperties(context.getInstanceInterface(), context.getPhysicalDevice());
@@ -83,7 +193,7 @@ tcu::TestStatus queueProperties (Context& context)
        return tcu::TestStatus::pass("Querying queue properties succeeded");
 }
 
-tcu::TestStatus memoryProperties (Context& context)
+tcu::TestStatus deviceMemoryProperties (Context& context)
 {
        TestLog&        log             = context.getTestContext().getLog();
 
@@ -102,9 +212,28 @@ tcu::TestCaseGroup* createInfoTests (tcu::TestContext& testCtx)
 {
        de::MovePtr<tcu::TestCaseGroup> infoTests       (new tcu::TestCaseGroup(testCtx, "info", "Platform Information Tests"));
 
-       addFunctionCase(infoTests.get(), "physical_devices",    "Physical devices",             enumeratePhysicalDevices);
-       addFunctionCase(infoTests.get(), "queue_properties",    "Queue properties",             queueProperties);
-       addFunctionCase(infoTests.get(), "memory_properties",   "Memory properties",    memoryProperties);
+       {
+               de::MovePtr<tcu::TestCaseGroup> instanceInfoTests       (new tcu::TestCaseGroup(testCtx, "instance", "Instance Information Tests"));
+
+               addFunctionCase(instanceInfoTests.get(), "physical_devices",            "Physical devices",                     enumeratePhysicalDevices);
+               addFunctionCase(instanceInfoTests.get(), "layers",                                      "Layers",                                       enumerateInstanceLayers);
+               addFunctionCase(instanceInfoTests.get(), "extensions",                          "Extensions",                           enumerateInstanceExtensions);
+
+               infoTests->addChild(instanceInfoTests.release());
+       }
+
+       {
+               de::MovePtr<tcu::TestCaseGroup> deviceInfoTests (new tcu::TestCaseGroup(testCtx, "device", "Device Information Tests"));
+
+               addFunctionCase(deviceInfoTests.get(), "features",                                      "Device Features",                      deviceFeatures);
+               addFunctionCase(deviceInfoTests.get(), "properties",                            "Device Properties",            deviceProperties);
+               addFunctionCase(deviceInfoTests.get(), "queue_family_properties",       "Queue family properties",      deviceQueueFamilyProperties);
+               addFunctionCase(deviceInfoTests.get(), "memory_properties",                     "Memory properties",            deviceMemoryProperties);
+               addFunctionCase(deviceInfoTests.get(), "layers",                                        "Layers",                                       enumerateDeviceLayers);
+               addFunctionCase(deviceInfoTests.get(), "extensions",                            "Extensions",                           enumerateDeviceExtensions);
+
+               infoTests->addChild(deviceInfoTests.release());
+       }
 
        return infoTests.release();
 }