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 | * |
Mark Lobodzinski | 6eda00a | 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 | 9eed289 | 2015-06-01 10:02:09 -0600 | [diff] [blame] | 11 | * |
Mark Lobodzinski | 6eda00a | 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 | 9eed289 | 2015-06-01 10:02:09 -0600 | [diff] [blame] | 14 | * |
Mark Lobodzinski | 6eda00a | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 15 | * The Materials are Confidential Information as defined by the Khronos |
| 16 | * Membership Agreement until designated non-confidential by Khronos, at which |
| 17 | * point this condition clause shall be removed. |
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 | * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
Jon Ashburn | 9eed289 | 2015-06-01 10:02:09 -0600 | [diff] [blame] | 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
Mark Lobodzinski | 6eda00a | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 22 | * |
| 23 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 24 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 25 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE |
| 26 | * USE OR OTHER DEALINGS IN THE MATERIALS |
Courtney Goeltzenleuchter | 0555952 | 2015-10-30 11:14:30 -0600 | [diff] [blame] | 27 | * |
| 28 | * Author: Tobin Ehlis <tobin@lunarg.com> |
Jon Ashburn | 9eed289 | 2015-06-01 10:02:09 -0600 | [diff] [blame] | 29 | */ |
Mark Lobodzinski | 6eda00a | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 30 | |
Jon Ashburn | 9eed289 | 2015-06-01 10:02:09 -0600 | [diff] [blame] | 31 | #pragma once |
| 32 | |
Courtney Goeltzenleuchter | 93a89cc | 2016-01-08 11:52:37 -0700 | [diff] [blame] | 33 | #include "vulkan/vulkan.h" |
Jon Ashburn | 9eed289 | 2015-06-01 10:02:09 -0600 | [diff] [blame] | 34 | #include <unordered_map> |
| 35 | |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 36 | typedef std::unordered_map<void *, VkLayerDispatchTable *> device_table_map; |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame^] | 37 | typedef std::unordered_map<void *, VkLayerInstanceDispatchTable *> |
| 38 | instance_table_map; |
| 39 | VkLayerDispatchTable *initDeviceTable(VkDevice device, |
| 40 | const PFN_vkGetDeviceProcAddr gpa, |
| 41 | device_table_map &map); |
| 42 | VkLayerDispatchTable *initDeviceTable(VkDevice device, |
| 43 | const PFN_vkGetDeviceProcAddr gpa); |
| 44 | VkLayerInstanceDispatchTable * |
| 45 | initInstanceTable(VkInstance instance, const PFN_vkGetInstanceProcAddr gpa, |
| 46 | instance_table_map &map); |
| 47 | VkLayerInstanceDispatchTable * |
| 48 | initInstanceTable(VkInstance instance, const PFN_vkGetInstanceProcAddr gpa); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 49 | |
| 50 | typedef void *dispatch_key; |
| 51 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame^] | 52 | static inline dispatch_key get_dispatch_key(const void *object) { |
| 53 | return (dispatch_key) * (VkLayerDispatchTable **)object; |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 54 | } |
Jon Ashburn | 9eed289 | 2015-06-01 10:02:09 -0600 | [diff] [blame] | 55 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame^] | 56 | VkLayerDispatchTable *device_dispatch_table(void *object); |
Jon Ashburn | 9eed289 | 2015-06-01 10:02:09 -0600 | [diff] [blame] | 57 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame^] | 58 | VkLayerInstanceDispatchTable *instance_dispatch_table(void *object); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 59 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame^] | 60 | VkLayerDispatchTable *get_dispatch_table(device_table_map &map, void *object); |
Courtney Goeltzenleuchter | e45acec | 2015-06-14 12:03:26 -0600 | [diff] [blame] | 61 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame^] | 62 | VkLayerInstanceDispatchTable *get_dispatch_table(instance_table_map &map, |
| 63 | void *object); |
Courtney Goeltzenleuchter | c08e72d | 2015-06-13 21:18:30 -0600 | [diff] [blame] | 64 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame^] | 65 | VkLayerInstanceCreateInfo * |
| 66 | get_chain_info(const VkInstanceCreateInfo *pCreateInfo, VkLayerFunction func); |
| 67 | VkLayerDeviceCreateInfo *get_chain_info(const VkDeviceCreateInfo *pCreateInfo, |
| 68 | VkLayerFunction func); |
Courtney Goeltzenleuchter | 93a89cc | 2016-01-08 11:52:37 -0700 | [diff] [blame] | 69 | |
Courtney Goeltzenleuchter | c08e72d | 2015-06-13 21:18:30 -0600 | [diff] [blame] | 70 | void destroy_device_dispatch_table(dispatch_key key); |
| 71 | void destroy_instance_dispatch_table(dispatch_key key); |
Courtney Goeltzenleuchter | 951af52 | 2016-01-15 11:58:33 -0700 | [diff] [blame] | 72 | void destroy_dispatch_table(device_table_map &map, dispatch_key key); |
| 73 | void destroy_dispatch_table(instance_table_map &map, dispatch_key key); |