From de141077417444a91c784c0ef8d94bcd921cb4a1 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Sat, 16 Mar 2019 18:50:40 +0000 Subject: [PATCH] vulkan/overlay: properly register layer object with loader MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This is required by the validation layers if we want to validate the commands inserted by the overlay layer. Signed-off-by: Lionel Landwerlin Reviewed-by: Tapani Pälli --- src/vulkan/overlay-layer/overlay.cpp | 33 ++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/vulkan/overlay-layer/overlay.cpp b/src/vulkan/overlay-layer/overlay.cpp index 19a4de27997..2cb9fdc8afa 100644 --- a/src/vulkan/overlay-layer/overlay.cpp +++ b/src/vulkan/overlay-layer/overlay.cpp @@ -58,6 +58,8 @@ struct queue_data; struct device_data { struct instance_data *instance; + PFN_vkSetDeviceLoaderData set_device_loader_data; + struct vk_device_dispatch_table vtable; VkPhysicalDevice physical_device; VkDevice device; @@ -198,6 +200,14 @@ static void unmap_object(void *obj) /**/ +static void check_vk_result(VkResult err) +{ + if (err != VK_SUCCESS) + printf("ERROR!\n"); +} + +/**/ + static VkLayerInstanceCreateInfo *get_instance_chain_info(const VkInstanceCreateInfo *pCreateInfo, VkLayerFunction func) { @@ -316,6 +326,10 @@ static void device_map_queues(struct device_data *data, data->vtable.GetDeviceQueue(data->device, pCreateInfo->pQueueCreateInfos[i].queueFamilyIndex, j, &queue); + + VkResult err = data->set_device_loader_data(data->device, queue); + check_vk_result(err); + data->queues[queue_index++] = new_queue_data(queue, &family_props[pCreateInfo->pQueueCreateInfos[i].queueFamilyIndex], pCreateInfo->pQueueCreateInfos[i].queueFamilyIndex, data); @@ -337,12 +351,6 @@ static void destroy_device_data(struct device_data *data) ralloc_free(data); } -static void check_vk_result(VkResult err) -{ - if (err != VK_SUCCESS) - printf("ERROR!\n"); -} - /**/ static struct swapchain_data *new_swapchain_data(VkSwapchainKHR swapchain, struct device_data *device_data) @@ -1314,9 +1322,13 @@ static void setup_swapchain_data(struct swapchain_data *data, cmd_bufs); check_vk_result(err); - for (uint32_t i = 0; i < ARRAY_SIZE(data->frame_data); i++) - data->frame_data[i].command_buffer = cmd_bufs[i]; + for (uint32_t i = 0; i < ARRAY_SIZE(data->frame_data); i++) { + err = device_data->set_device_loader_data(device_data->device, + cmd_bufs[i]); + check_vk_result(err); + data->frame_data[i].command_buffer = cmd_bufs[i]; + } /* Submission fence */ VkFenceCreateInfo fence_info = {}; @@ -1325,7 +1337,6 @@ static void setup_swapchain_data(struct swapchain_data *data, err = device_data->vtable.CreateFence(device_data->device, &fence_info, NULL, &data->fence); check_vk_result(err); - } static void shutdown_swapchain_data(struct swapchain_data *data) @@ -1692,6 +1703,10 @@ VKAPI_ATTR VkResult VKAPI_CALL overlay_CreateDevice( instance_data->vtable.GetPhysicalDeviceProperties(device_data->physical_device, &device_data->properties); + VkLayerDeviceCreateInfo *load_data_info = + get_device_chain_info(pCreateInfo, VK_LOADER_DATA_CALLBACK); + device_data->set_device_loader_data = load_data_info->u.pfnSetDeviceLoaderData; + device_map_queues(device_data, pCreateInfo); return result; -- 2.30.2