Józef Kucia : vulkan-1/tests: Introduce for_each_device() helper.
Module: wine Branch: master Commit: d36ecbe8dfb7a7b3f1b9a3e3ccc29b36d2b73f0b URL: https://source.winehq.org/git/wine.git/?a=commit;h=d36ecbe8dfb7a7b3f1b9a3e3c... Author: Józef Kucia <jkucia(a)codeweavers.com> Date: Thu Jul 12 11:39:44 2018 +0200 vulkan-1/tests: Introduce for_each_device() helper. Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/vulkan-1/tests/vulkan.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/dlls/vulkan-1/tests/vulkan.c b/dlls/vulkan-1/tests/vulkan.c index 67da880..25e5c01 100644 --- a/dlls/vulkan-1/tests/vulkan.c +++ b/dlls/vulkan-1/tests/vulkan.c @@ -38,10 +38,23 @@ static VkResult create_instance(uint32_t extension_count, return vkCreateInstance(&create_info, NULL, vk_instance); } -static void test_enumerate_physical_devices(void) +static void enumerate_physical_device(VkPhysicalDevice vk_physical_device) { - VkPhysicalDevice *vk_physical_devices; VkPhysicalDeviceProperties properties; + + vkGetPhysicalDeviceProperties(vk_physical_device, &properties); + + trace("Device '%s', %#x:%#x, driver version %u.%u.%u (%#x), api version %u.%u.%u.\n", + properties.deviceName, properties.vendorID, properties.deviceID, + VK_VERSION_MAJOR(properties.driverVersion), VK_VERSION_MINOR(properties.driverVersion), + VK_VERSION_PATCH(properties.driverVersion), properties.driverVersion, + VK_VERSION_MAJOR(properties.apiVersion), VK_VERSION_MINOR(properties.apiVersion), + VK_VERSION_PATCH(properties.apiVersion)); +} + +static void for_each_device(void (*test_func)(VkPhysicalDevice)) +{ + VkPhysicalDevice *vk_physical_devices; VkInstance vk_instance; unsigned int i; uint32_t count; @@ -63,23 +76,13 @@ static void test_enumerate_physical_devices(void) return; } - trace("Got %u physical device(s).\n", count); vk_physical_devices = heap_calloc(count, sizeof(*vk_physical_devices)); ok(!!vk_physical_devices, "Failed to allocate memory.\n"); vr = vkEnumeratePhysicalDevices(vk_instance, &count, vk_physical_devices); ok(vr == VK_SUCCESS, "Got unexpected VkResult %d.\n", vr); for (i = 0; i < count; ++i) - { - vkGetPhysicalDeviceProperties(vk_physical_devices[i], &properties); - - trace("Device '%s', %#x:%#x, driver version %u.%u.%u (%#x), api version %u.%u.%u.\n", - properties.deviceName, properties.vendorID, properties.deviceID, - VK_VERSION_MAJOR(properties.driverVersion), VK_VERSION_MINOR(properties.driverVersion), - VK_VERSION_PATCH(properties.driverVersion), properties.driverVersion, - VK_VERSION_MAJOR(properties.apiVersion), VK_VERSION_MINOR(properties.apiVersion), - VK_VERSION_PATCH(properties.apiVersion)); - } + test_func(vk_physical_devices[i]); heap_free(vk_physical_devices); @@ -88,5 +91,5 @@ static void test_enumerate_physical_devices(void) START_TEST(vulkan) { - test_enumerate_physical_devices(); + for_each_device(enumerate_physical_device); }
participants (1)
-
Alexandre Julliard