blob: d51108d9471c74d7cca02ce31880b0d5ba165037 [file] [log] [blame]
Mark Lobodzinski6eda00a2016-02-02 15:55:36 -07001/* Copyright (c) 2015-2016 The Khronos Group Inc.
2 * Copyright (c) 2015-2016 Valve Corporation
3 * Copyright (c) 2015-2016 LunarG, Inc.
Jon Ashburn9eed2892015-06-01 10:02:09 -06004 *
Mark Lobodzinski6eda00a2016-02-02 15:55:36 -07005 * 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 Ashburn9eed2892015-06-01 10:02:09 -060011 *
Mark Lobodzinski6eda00a2016-02-02 15:55:36 -070012 * The above copyright notice(s) and this permission notice shall be included
13 * in all copies or substantial portions of the Materials.
Jon Ashburn9eed2892015-06-01 10:02:09 -060014 *
Mark Lobodzinski6eda00a2016-02-02 15:55:36 -070015 * 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 Ashburn9eed2892015-06-01 10:02:09 -060018 *
Mark Lobodzinski6eda00a2016-02-02 15:55:36 -070019 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Jon Ashburn9eed2892015-06-01 10:02:09 -060020 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Mark Lobodzinski6eda00a2016-02-02 15:55:36 -070021 * 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 Goeltzenleuchter05559522015-10-30 11:14:30 -060027 *
28 * Author: Tobin Ehlis <tobin@lunarg.com>
Jon Ashburn9eed2892015-06-01 10:02:09 -060029 */
Mark Lobodzinski6eda00a2016-02-02 15:55:36 -070030
Jon Ashburn9eed2892015-06-01 10:02:09 -060031#pragma once
32
Courtney Goeltzenleuchter93a89cc2016-01-08 11:52:37 -070033#include "vulkan/vulkan.h"
Jon Ashburn9eed2892015-06-01 10:02:09 -060034#include <unordered_map>
35
Courtney Goeltzenleuchtere45acec2015-06-14 12:03:26 -060036typedef std::unordered_map<void *, VkLayerDispatchTable *> device_table_map;
37typedef std::unordered_map<void *, VkLayerInstanceDispatchTable *> instance_table_map;
Courtney Goeltzenleuchter00150eb2016-01-08 12:18:43 -070038VkLayerDispatchTable * initDeviceTable(VkDevice device, const PFN_vkGetDeviceProcAddr gpa, device_table_map &map);
39VkLayerDispatchTable * initDeviceTable(VkDevice device, const PFN_vkGetDeviceProcAddr gpa);
40VkLayerInstanceDispatchTable * initInstanceTable(VkInstance instance, const PFN_vkGetInstanceProcAddr gpa, instance_table_map &map);
41VkLayerInstanceDispatchTable * initInstanceTable(VkInstance instance, const PFN_vkGetInstanceProcAddr gpa);
42
Courtney Goeltzenleuchtere45acec2015-06-14 12:03:26 -060043
44typedef void *dispatch_key;
45
Tony Barboura05dbaa2015-07-09 17:31:46 -060046static inline dispatch_key get_dispatch_key(const void* object)
Courtney Goeltzenleuchtere45acec2015-06-14 12:03:26 -060047{
48 return (dispatch_key) *(VkLayerDispatchTable **) object;
49}
Jon Ashburn9eed2892015-06-01 10:02:09 -060050
Tony Barbour1d2cd3f2015-07-03 10:33:54 -060051VkLayerDispatchTable *device_dispatch_table(void* object);
Jon Ashburn9eed2892015-06-01 10:02:09 -060052
Tony Barbour1d2cd3f2015-07-03 10:33:54 -060053VkLayerInstanceDispatchTable *instance_dispatch_table(void* object);
Courtney Goeltzenleuchtere45acec2015-06-14 12:03:26 -060054
Tony Barbour1d2cd3f2015-07-03 10:33:54 -060055VkLayerDispatchTable *get_dispatch_table(device_table_map &map, void* object);
Courtney Goeltzenleuchtere45acec2015-06-14 12:03:26 -060056
Tony Barbour1d2cd3f2015-07-03 10:33:54 -060057VkLayerInstanceDispatchTable *get_dispatch_table(instance_table_map &map, void* object);
Courtney Goeltzenleuchterc08e72d2015-06-13 21:18:30 -060058
Courtney Goeltzenleuchter00150eb2016-01-08 12:18:43 -070059VkLayerInstanceCreateInfo *get_chain_info(const VkInstanceCreateInfo *pCreateInfo, VkLayerFunction func);
60VkLayerDeviceCreateInfo *get_chain_info(const VkDeviceCreateInfo *pCreateInfo, VkLayerFunction func);
Courtney Goeltzenleuchter93a89cc2016-01-08 11:52:37 -070061
Courtney Goeltzenleuchterc08e72d2015-06-13 21:18:30 -060062void destroy_device_dispatch_table(dispatch_key key);
63void destroy_instance_dispatch_table(dispatch_key key);
Courtney Goeltzenleuchter951af522016-01-15 11:58:33 -070064void destroy_dispatch_table(device_table_map &map, dispatch_key key);
65void destroy_dispatch_table(instance_table_map &map, dispatch_key key);