Mark Lobodzinski | 288e4f7 | 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 | 5a10d21 | 2015-06-01 10:02:09 -0600 | [diff] [blame] | 4 | * |
Mark Lobodzinski | 288e4f7 | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 | * of this software and/or associated documentation files (the "Materials"), to |
| 7 | * deal in the Materials without restriction, including without limitation the |
| 8 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 9 | * sell copies of the Materials, and to permit persons to whom the Materials |
| 10 | * are furnished to do so, subject to the following conditions: |
Jon Ashburn | 5a10d21 | 2015-06-01 10:02:09 -0600 | [diff] [blame] | 11 | * |
Mark Lobodzinski | 288e4f7 | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 12 | * The above copyright notice(s) and this permission notice shall be included |
| 13 | * in all copies or substantial portions of the Materials. |
Jon Ashburn | 5a10d21 | 2015-06-01 10:02:09 -0600 | [diff] [blame] | 14 | * |
Mark Lobodzinski | 288e4f7 | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 15 | * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
Jon Ashburn | 5a10d21 | 2015-06-01 10:02:09 -0600 | [diff] [blame] | 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
Mark Lobodzinski | 288e4f7 | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 18 | * |
| 19 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 20 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 21 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE |
| 22 | * USE OR OTHER DEALINGS IN THE MATERIALS |
Courtney Goeltzenleuchter | 96cd795 | 2015-10-30 11:14:30 -0600 | [diff] [blame] | 23 | * |
| 24 | * Author: Tobin Ehlis <tobin@lunarg.com> |
Jon Ashburn | 5a10d21 | 2015-06-01 10:02:09 -0600 | [diff] [blame] | 25 | */ |
Mark Lobodzinski | 288e4f7 | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 26 | |
Jon Ashburn | 5a10d21 | 2015-06-01 10:02:09 -0600 | [diff] [blame] | 27 | #pragma once |
| 28 | |
Courtney Goeltzenleuchter | cfbccd8 | 2016-01-08 11:52:37 -0700 | [diff] [blame] | 29 | #include "vulkan/vulkan.h" |
Jon Ashburn | 5a10d21 | 2015-06-01 10:02:09 -0600 | [diff] [blame] | 30 | #include <unordered_map> |
| 31 | |
Courtney Goeltzenleuchter | 1f1fbbd | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 32 | typedef std::unordered_map<void *, VkLayerDispatchTable *> device_table_map; |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 33 | typedef std::unordered_map<void *, VkLayerInstanceDispatchTable *> instance_table_map; |
Jon Ashburn | 491a3cd | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 34 | VkLayerDispatchTable *initDeviceTable(VkDevice device, const PFN_vkGetDeviceProcAddr gpa, device_table_map &map); |
| 35 | VkLayerDispatchTable *initDeviceTable(VkDevice device, const PFN_vkGetDeviceProcAddr gpa); |
| 36 | VkLayerInstanceDispatchTable *initInstanceTable(VkInstance instance, const PFN_vkGetInstanceProcAddr gpa, instance_table_map &map); |
| 37 | VkLayerInstanceDispatchTable *initInstanceTable(VkInstance instance, const PFN_vkGetInstanceProcAddr gpa); |
Courtney Goeltzenleuchter | 1f1fbbd | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 38 | |
| 39 | typedef void *dispatch_key; |
| 40 | |
Jon Ashburn | 491a3cd | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 41 | static inline dispatch_key get_dispatch_key(const void *object) { return (dispatch_key) * (VkLayerDispatchTable **)object; } |
Jon Ashburn | 5a10d21 | 2015-06-01 10:02:09 -0600 | [diff] [blame] | 42 | |
Jon Ashburn | 491a3cd | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 43 | VkLayerDispatchTable *device_dispatch_table(void *object); |
Jon Ashburn | 5a10d21 | 2015-06-01 10:02:09 -0600 | [diff] [blame] | 44 | |
Jon Ashburn | 491a3cd | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 45 | VkLayerInstanceDispatchTable *instance_dispatch_table(void *object); |
Courtney Goeltzenleuchter | 1f1fbbd | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 46 | |
Jon Ashburn | 491a3cd | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 47 | VkLayerDispatchTable *get_dispatch_table(device_table_map &map, void *object); |
Courtney Goeltzenleuchter | 1f1fbbd | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 48 | |
Jon Ashburn | 491a3cd | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 49 | VkLayerInstanceDispatchTable *get_dispatch_table(instance_table_map &map, void *object); |
Courtney Goeltzenleuchter | fde3a53 | 2015-06-13 21:18:30 -0600 | [diff] [blame] | 50 | |
Mark Lobodzinski | b838dc0 | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 51 | VkLayerInstanceCreateInfo *get_chain_info(const VkInstanceCreateInfo *pCreateInfo, VkLayerFunction func); |
| 52 | VkLayerDeviceCreateInfo *get_chain_info(const VkDeviceCreateInfo *pCreateInfo, VkLayerFunction func); |
Courtney Goeltzenleuchter | cfbccd8 | 2016-01-08 11:52:37 -0700 | [diff] [blame] | 53 | |
Courtney Goeltzenleuchter | fde3a53 | 2015-06-13 21:18:30 -0600 | [diff] [blame] | 54 | void destroy_device_dispatch_table(dispatch_key key); |
| 55 | void destroy_instance_dispatch_table(dispatch_key key); |
Courtney Goeltzenleuchter | cc9db23 | 2016-01-15 11:58:33 -0700 | [diff] [blame] | 56 | void destroy_dispatch_table(device_table_map &map, dispatch_key key); |
| 57 | void destroy_dispatch_table(instance_table_map &map, dispatch_key key); |