blob: e68680ddd79a5474d6b262440047e71c499189f7 [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;
Mark Lobodzinskib39d9e62016-02-02 17:06:29 -070037typedef std::unordered_map<void *, VkLayerInstanceDispatchTable *>
38 instance_table_map;
39VkLayerDispatchTable *initDeviceTable(VkDevice device,
40 const PFN_vkGetDeviceProcAddr gpa,
41 device_table_map &map);
42VkLayerDispatchTable *initDeviceTable(VkDevice device,
43 const PFN_vkGetDeviceProcAddr gpa);
44VkLayerInstanceDispatchTable *
45initInstanceTable(VkInstance instance, const PFN_vkGetInstanceProcAddr gpa,
46 instance_table_map &map);
47VkLayerInstanceDispatchTable *
48initInstanceTable(VkInstance instance, const PFN_vkGetInstanceProcAddr gpa);
Courtney Goeltzenleuchtere45acec2015-06-14 12:03:26 -060049
50typedef void *dispatch_key;
51
Mark Lobodzinskib39d9e62016-02-02 17:06:29 -070052static inline dispatch_key get_dispatch_key(const void *object) {
53 return (dispatch_key) * (VkLayerDispatchTable **)object;
Courtney Goeltzenleuchtere45acec2015-06-14 12:03:26 -060054}
Jon Ashburn9eed2892015-06-01 10:02:09 -060055
Mark Lobodzinskib39d9e62016-02-02 17:06:29 -070056VkLayerDispatchTable *device_dispatch_table(void *object);
Jon Ashburn9eed2892015-06-01 10:02:09 -060057
Mark Lobodzinskib39d9e62016-02-02 17:06:29 -070058VkLayerInstanceDispatchTable *instance_dispatch_table(void *object);
Courtney Goeltzenleuchtere45acec2015-06-14 12:03:26 -060059
Mark Lobodzinskib39d9e62016-02-02 17:06:29 -070060VkLayerDispatchTable *get_dispatch_table(device_table_map &map, void *object);
Courtney Goeltzenleuchtere45acec2015-06-14 12:03:26 -060061
Mark Lobodzinskib39d9e62016-02-02 17:06:29 -070062VkLayerInstanceDispatchTable *get_dispatch_table(instance_table_map &map,
63 void *object);
Courtney Goeltzenleuchterc08e72d2015-06-13 21:18:30 -060064
Mark Lobodzinskib39d9e62016-02-02 17:06:29 -070065VkLayerInstanceCreateInfo *
66get_chain_info(const VkInstanceCreateInfo *pCreateInfo, VkLayerFunction func);
67VkLayerDeviceCreateInfo *get_chain_info(const VkDeviceCreateInfo *pCreateInfo,
68 VkLayerFunction func);
Courtney Goeltzenleuchter93a89cc2016-01-08 11:52:37 -070069
Courtney Goeltzenleuchterc08e72d2015-06-13 21:18:30 -060070void destroy_device_dispatch_table(dispatch_key key);
71void destroy_instance_dispatch_table(dispatch_key key);
Courtney Goeltzenleuchter951af522016-01-15 11:58:33 -070072void destroy_dispatch_table(device_table_map &map, dispatch_key key);
73void destroy_dispatch_table(instance_table_map &map, dispatch_key key);