From a40e0a9ffd47da0bbb3aaff74dced667e6dd5fe9 Mon Sep 17 00:00:00 2001 From: Courtney Goeltzenleuchter Date: Fri, 8 Jan 2016 11:52:37 -0700 Subject: layers: Add utility functions for new layer init These utilities will find the appropriate CreateInfo extension that defines the layer link information. --- layers/vk_layer_table.cpp | 20 ++++++++++++++++++++ layers/vk_layer_table.h | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/layers/vk_layer_table.cpp b/layers/vk_layer_table.cpp index 1c4fa133..93d2fbf4 100644 --- a/layers/vk_layer_table.cpp +++ b/layers/vk_layer_table.cpp @@ -125,6 +125,26 @@ VkLayerInstanceDispatchTable *get_dispatch_table(instance_table_map &map, void* return it->second; } +VkLayerInstanceCreateInfo *get_chain_info(const VkInstanceCreateInfo *pCreateInfo) +{ + VkLayerInstanceCreateInfo *chain_info = (VkLayerInstanceCreateInfo *) pCreateInfo->pNext; + while (chain_info && chain_info->sType != VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO) { + chain_info = (VkLayerInstanceCreateInfo *) chain_info->pNext; + } + assert(chain_info != NULL); + return chain_info; +} + +VkLayerDeviceCreateInfo *get_chain_info(const VkDeviceCreateInfo *pCreateInfo) +{ + VkLayerDeviceCreateInfo *chain_info = (VkLayerDeviceCreateInfo *) pCreateInfo->pNext; + while (chain_info && chain_info->sType != VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO) { + chain_info = (VkLayerDeviceCreateInfo *) chain_info->pNext; + } + assert(chain_info != NULL); + return chain_info; +} + /* Various dispatchable objects will use the same underlying dispatch table if they * are created from that "parent" object. Thus use pointer to dispatch table * as the key to these table maps. diff --git a/layers/vk_layer_table.h b/layers/vk_layer_table.h index bccd7364..816b6a69 100644 --- a/layers/vk_layer_table.h +++ b/layers/vk_layer_table.h @@ -24,6 +24,7 @@ */ #pragma once +#include "vulkan/vulkan.h" #include typedef std::unordered_map device_table_map; @@ -48,5 +49,8 @@ VkLayerDispatchTable *get_dispatch_table(device_table_map &map, void* object); VkLayerInstanceDispatchTable *get_dispatch_table(instance_table_map &map, void* object); +VkLayerInstanceCreateInfo *get_chain_info(const VkInstanceCreateInfo *pCreateInfo); +VkLayerDeviceCreateInfo *get_chain_info(const VkDeviceCreateInfo *pCreateInfo); + void destroy_device_dispatch_table(dispatch_key key); void destroy_instance_dispatch_table(dispatch_key key); -- cgit v1.2.3