• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (c) 2015-2016 The Khronos Group Inc.
2  * Copyright (c) 2015-2016 Valve Corporation
3  * Copyright (c) 2015-2016 LunarG, Inc.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * Author: Tobin Ehlis <tobin@lunarg.com>
18  */
19 
20 #pragma once
21 
22 #include "vulkan/vk_layer.h"
23 #include "vulkan/vulkan.h"
24 #include <unordered_map>
25 
26 typedef std::unordered_map<void *, VkLayerDispatchTable *> device_table_map;
27 typedef std::unordered_map<void *, VkLayerInstanceDispatchTable *> instance_table_map;
28 VkLayerDispatchTable *initDeviceTable(VkDevice device, const PFN_vkGetDeviceProcAddr gpa, device_table_map &map);
29 VkLayerDispatchTable *initDeviceTable(VkDevice device, const PFN_vkGetDeviceProcAddr gpa);
30 VkLayerInstanceDispatchTable *initInstanceTable(VkInstance instance, const PFN_vkGetInstanceProcAddr gpa, instance_table_map &map);
31 VkLayerInstanceDispatchTable *initInstanceTable(VkInstance instance, const PFN_vkGetInstanceProcAddr gpa);
32 
33 typedef void *dispatch_key;
34 
get_dispatch_key(const void * object)35 static inline dispatch_key get_dispatch_key(const void *object) { return (dispatch_key) * (VkLayerDispatchTable **)object; }
36 
37 VkLayerDispatchTable *device_dispatch_table(void *object);
38 
39 VkLayerInstanceDispatchTable *instance_dispatch_table(void *object);
40 
41 VkLayerDispatchTable *get_dispatch_table(device_table_map &map, void *object);
42 
43 VkLayerInstanceDispatchTable *get_dispatch_table(instance_table_map &map, void *object);
44 
45 VkLayerInstanceCreateInfo *get_chain_info(const VkInstanceCreateInfo *pCreateInfo, VkLayerFunction func);
46 VkLayerDeviceCreateInfo *get_chain_info(const VkDeviceCreateInfo *pCreateInfo, VkLayerFunction func);
47 
48 void destroy_device_dispatch_table(dispatch_key key);
49 void destroy_instance_dispatch_table(dispatch_key key);
50 void destroy_dispatch_table(device_table_map &map, dispatch_key key);
51 void destroy_dispatch_table(instance_table_map &map, dispatch_key key);
52