Mark Lobodzinski | 6eda00a | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2015-2016 The Khronos Group Inc. |
| 2 | * Copyright (c) 2015-2016 Valve Corporation |
| 3 | * Copyright (c) 2015-2016 LunarG, Inc. |
Jon Ashburn | 9eed289 | 2015-06-01 10:02:09 -0600 | [diff] [blame] | 4 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 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 |
Jon Ashburn | 9eed289 | 2015-06-01 10:02:09 -0600 | [diff] [blame] | 8 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
Jon Ashburn | 9eed289 | 2015-06-01 10:02:09 -0600 | [diff] [blame] | 10 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 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. |
Courtney Goeltzenleuchter | 0555952 | 2015-10-30 11:14:30 -0600 | [diff] [blame] | 16 | * |
| 17 | * Author: Tobin Ehlis <tobin@lunarg.com> |
Jon Ashburn | 9eed289 | 2015-06-01 10:02:09 -0600 | [diff] [blame] | 18 | */ |
Mark Lobodzinski | 6eda00a | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 19 | |
Jon Ashburn | 9eed289 | 2015-06-01 10:02:09 -0600 | [diff] [blame] | 20 | #pragma once |
| 21 | |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 22 | #include "vulkan/vk_layer.h" |
Courtney Goeltzenleuchter | 93a89cc | 2016-01-08 11:52:37 -0700 | [diff] [blame] | 23 | #include "vulkan/vulkan.h" |
Jon Ashburn | 9eed289 | 2015-06-01 10:02:09 -0600 | [diff] [blame] | 24 | #include <unordered_map> |
| 25 | |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 26 | typedef std::unordered_map<void *, VkLayerDispatchTable *> device_table_map; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 27 | typedef std::unordered_map<void *, VkLayerInstanceDispatchTable *> instance_table_map; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 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); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 32 | |
| 33 | typedef void *dispatch_key; |
| 34 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 35 | static inline dispatch_key get_dispatch_key(const void *object) { return (dispatch_key) * (VkLayerDispatchTable **)object; } |
Jon Ashburn | 9eed289 | 2015-06-01 10:02:09 -0600 | [diff] [blame] | 36 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 37 | VkLayerDispatchTable *device_dispatch_table(void *object); |
Jon Ashburn | 9eed289 | 2015-06-01 10:02:09 -0600 | [diff] [blame] | 38 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 39 | VkLayerInstanceDispatchTable *instance_dispatch_table(void *object); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 40 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 41 | VkLayerDispatchTable *get_dispatch_table(device_table_map &map, void *object); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 42 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 43 | VkLayerInstanceDispatchTable *get_dispatch_table(instance_table_map &map, void *object); |
Courtney Goeltzenleuchter | c08e72d | 2015-06-13 21:18:30 -0600 | [diff] [blame] | 44 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 45 | VkLayerInstanceCreateInfo *get_chain_info(const VkInstanceCreateInfo *pCreateInfo, VkLayerFunction func); |
| 46 | VkLayerDeviceCreateInfo *get_chain_info(const VkDeviceCreateInfo *pCreateInfo, VkLayerFunction func); |
Courtney Goeltzenleuchter | 93a89cc | 2016-01-08 11:52:37 -0700 | [diff] [blame] | 47 | |
Courtney Goeltzenleuchter | c08e72d | 2015-06-13 21:18:30 -0600 | [diff] [blame] | 48 | void destroy_device_dispatch_table(dispatch_key key); |
| 49 | void destroy_instance_dispatch_table(dispatch_key key); |
Courtney Goeltzenleuchter | 951af52 | 2016-01-15 11:58:33 -0700 | [diff] [blame] | 50 | void destroy_dispatch_table(device_table_map &map, dispatch_key key); |
| 51 | void destroy_dispatch_table(instance_table_map &map, dispatch_key key); |