From 0781808935e161b1731da944ffe8e2a4c681f9d6 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Tue, 8 Dec 2020 17:11:19 -0500 Subject: [PATCH] zink: Factor out zink_create_logical_device Reviewed-By: Mike Blumenkrantz Reviewed-by: Hoe Hao Cheng Part-of: --- src/gallium/drivers/zink/zink_screen.c | 58 +++++++++++++++----------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c index 2d2c0aa0a2e..b39bae6de97 100644 --- a/src/gallium/drivers/zink/zink_screen.c +++ b/src/gallium/drivers/zink/zink_screen.c @@ -943,6 +943,38 @@ zink_get_loader_version(void) return loader_version; } +static VkDevice +zink_create_logical_device(struct zink_screen *screen) +{ + VkDevice dev = VK_NULL_HANDLE; + + VkDeviceQueueCreateInfo qci = {}; + float dummy = 0.0f; + qci.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; + qci.queueFamilyIndex = screen->gfx_queue; + qci.queueCount = 1; + qci.pQueuePriorities = &dummy; + + VkDeviceCreateInfo dci = {}; + dci.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; + dci.queueCreateInfoCount = 1; + dci.pQueueCreateInfos = &qci; + /* extensions don't have bool members in pEnabledFeatures. + * this requires us to pass the whole VkPhysicalDeviceFeatures2 struct + */ + if (screen->info.feats.sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2) { + dci.pNext = &screen->info.feats; + } else { + dci.pEnabledFeatures = &screen->info.feats.features; + } + + dci.ppEnabledExtensionNames = screen->info.extensions; + dci.enabledExtensionCount = screen->info.num_extensions; + + vkCreateDevice(screen->pdev, &dci, NULL, &dev); + return dev; +} + static struct zink_screen * zink_internal_create_screen(const struct pipe_screen_config *config) { @@ -985,30 +1017,8 @@ zink_internal_create_screen(const struct pipe_screen_config *config) zink_internal_setup_moltenvk(screen); #endif - VkDeviceQueueCreateInfo qci = {}; - float dummy = 0.0f; - qci.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; - qci.queueFamilyIndex = screen->gfx_queue; - qci.queueCount = 1; - qci.pQueuePriorities = &dummy; - - VkDeviceCreateInfo dci = {}; - dci.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; - dci.queueCreateInfoCount = 1; - dci.pQueueCreateInfos = &qci; - /* extensions don't have bool members in pEnabledFeatures. - * this requires us to pass the whole VkPhysicalDeviceFeatures2 struct - */ - if (screen->info.feats.sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2) { - dci.pNext = &screen->info.feats; - } else { - dci.pEnabledFeatures = &screen->info.feats.features; - } - - dci.ppEnabledExtensionNames = screen->info.extensions; - dci.enabledExtensionCount = screen->info.num_extensions; - - if (vkCreateDevice(screen->pdev, &dci, NULL, &screen->dev) != VK_SUCCESS) + screen->dev = zink_create_logical_device(screen); + if (!screen->dev) goto fail; if (!load_device_extensions(screen)) -- 2.34.1