blob: eb7efd37aebea41271852defc06b5a71ae4011b3 [file] [log] [blame]
Mark Lobodzinski288e4f72016-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 Ashburn5a10d212015-06-01 10:02:09 -06004 *
Mark Lobodzinski288e4f72016-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 Ashburn5a10d212015-06-01 10:02:09 -060011 *
Mark Lobodzinski288e4f72016-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 Ashburn5a10d212015-06-01 10:02:09 -060014 *
Mark Lobodzinski288e4f72016-02-02 15:55:36 -070015 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Jon Ashburn5a10d212015-06-01 10:02:09 -060016 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Mark Lobodzinski288e4f72016-02-02 15:55:36 -070017 * 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 Goeltzenleuchter96cd7952015-10-30 11:14:30 -060023 *
24 * Author: Tobin Ehlis <tobin@lunarg.com>
Jon Ashburn5a10d212015-06-01 10:02:09 -060025 */
Mark Lobodzinski288e4f72016-02-02 15:55:36 -070026
Jon Ashburn5a10d212015-06-01 10:02:09 -060027#pragma once
28
Courtney Goeltzenleuchtercfbccd82016-01-08 11:52:37 -070029#include "vulkan/vulkan.h"
Jon Ashburn5a10d212015-06-01 10:02:09 -060030#include <unordered_map>
31
Courtney Goeltzenleuchter1f1fbbd2015-06-14 12:03:26 -060032typedef std::unordered_map<void *, VkLayerDispatchTable *> device_table_map;
Mark Lobodzinskib838dc02016-02-03 09:57:14 -070033typedef std::unordered_map<void *, VkLayerInstanceDispatchTable *> instance_table_map;
Jon Ashburn491a3cd2016-03-08 17:48:44 -070034VkLayerDispatchTable *initDeviceTable(VkDevice device, const PFN_vkGetDeviceProcAddr gpa, device_table_map &map);
35VkLayerDispatchTable *initDeviceTable(VkDevice device, const PFN_vkGetDeviceProcAddr gpa);
36VkLayerInstanceDispatchTable *initInstanceTable(VkInstance instance, const PFN_vkGetInstanceProcAddr gpa, instance_table_map &map);
37VkLayerInstanceDispatchTable *initInstanceTable(VkInstance instance, const PFN_vkGetInstanceProcAddr gpa);
Courtney Goeltzenleuchter1f1fbbd2015-06-14 12:03:26 -060038
39typedef void *dispatch_key;
40
Jon Ashburn491a3cd2016-03-08 17:48:44 -070041static inline dispatch_key get_dispatch_key(const void *object) { return (dispatch_key) * (VkLayerDispatchTable **)object; }
Jon Ashburn5a10d212015-06-01 10:02:09 -060042
Jon Ashburn491a3cd2016-03-08 17:48:44 -070043VkLayerDispatchTable *device_dispatch_table(void *object);
Jon Ashburn5a10d212015-06-01 10:02:09 -060044
Jon Ashburn491a3cd2016-03-08 17:48:44 -070045VkLayerInstanceDispatchTable *instance_dispatch_table(void *object);
Courtney Goeltzenleuchter1f1fbbd2015-06-14 12:03:26 -060046
Jon Ashburn491a3cd2016-03-08 17:48:44 -070047VkLayerDispatchTable *get_dispatch_table(device_table_map &map, void *object);
Courtney Goeltzenleuchter1f1fbbd2015-06-14 12:03:26 -060048
Jon Ashburn491a3cd2016-03-08 17:48:44 -070049VkLayerInstanceDispatchTable *get_dispatch_table(instance_table_map &map, void *object);
Courtney Goeltzenleuchterfde3a532015-06-13 21:18:30 -060050
Mark Lobodzinskib838dc02016-02-03 09:57:14 -070051VkLayerInstanceCreateInfo *get_chain_info(const VkInstanceCreateInfo *pCreateInfo, VkLayerFunction func);
52VkLayerDeviceCreateInfo *get_chain_info(const VkDeviceCreateInfo *pCreateInfo, VkLayerFunction func);
Courtney Goeltzenleuchtercfbccd82016-01-08 11:52:37 -070053
Courtney Goeltzenleuchterfde3a532015-06-13 21:18:30 -060054void destroy_device_dispatch_table(dispatch_key key);
55void destroy_instance_dispatch_table(dispatch_key key);
Courtney Goeltzenleuchtercc9db232016-01-15 11:58:33 -070056void destroy_dispatch_table(device_table_map &map, dispatch_key key);
57void destroy_dispatch_table(instance_table_map &map, dispatch_key key);