blob: bccd7364787de82b2d16418835eced6a163b3a75 [file] [log] [blame]
Jon Ashburn9eed2892015-06-01 10:02:09 -06001/*
Jon Ashburn9eed2892015-06-01 10:02:09 -06002 *
Courtney Goeltzenleuchterfcbe16f2015-10-29 13:50:34 -06003 * Copyright (C) 2015 Valve Corporation
Jon Ashburn9eed2892015-06-01 10:02:09 -06004 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
Courtney Goeltzenleuchter05559522015-10-30 11:14:30 -060022 *
23 * Author: Tobin Ehlis <tobin@lunarg.com>
Jon Ashburn9eed2892015-06-01 10:02:09 -060024 */
25#pragma once
26
27#include <unordered_map>
28
Courtney Goeltzenleuchtere45acec2015-06-14 12:03:26 -060029typedef std::unordered_map<void *, VkLayerDispatchTable *> device_table_map;
30typedef std::unordered_map<void *, VkLayerInstanceDispatchTable *> instance_table_map;
Jon Ashburn9eed2892015-06-01 10:02:09 -060031VkLayerDispatchTable * initDeviceTable(const VkBaseLayerObject *devw);
Courtney Goeltzenleuchtere45acec2015-06-14 12:03:26 -060032VkLayerDispatchTable * initDeviceTable(device_table_map &map, const VkBaseLayerObject *devw);
Jon Ashburn9eed2892015-06-01 10:02:09 -060033VkLayerInstanceDispatchTable * initInstanceTable(const VkBaseLayerObject *instancew);
Courtney Goeltzenleuchtere45acec2015-06-14 12:03:26 -060034VkLayerInstanceDispatchTable * initInstanceTable(instance_table_map &map, const VkBaseLayerObject *instancew);
35
36typedef void *dispatch_key;
37
Tony Barboura05dbaa2015-07-09 17:31:46 -060038static inline dispatch_key get_dispatch_key(const void* object)
Courtney Goeltzenleuchtere45acec2015-06-14 12:03:26 -060039{
40 return (dispatch_key) *(VkLayerDispatchTable **) object;
41}
Jon Ashburn9eed2892015-06-01 10:02:09 -060042
Tony Barbour1d2cd3f2015-07-03 10:33:54 -060043VkLayerDispatchTable *device_dispatch_table(void* object);
Jon Ashburn9eed2892015-06-01 10:02:09 -060044
Tony Barbour1d2cd3f2015-07-03 10:33:54 -060045VkLayerInstanceDispatchTable *instance_dispatch_table(void* object);
Courtney Goeltzenleuchtere45acec2015-06-14 12:03:26 -060046
Tony Barbour1d2cd3f2015-07-03 10:33:54 -060047VkLayerDispatchTable *get_dispatch_table(device_table_map &map, void* object);
Courtney Goeltzenleuchtere45acec2015-06-14 12:03:26 -060048
Tony Barbour1d2cd3f2015-07-03 10:33:54 -060049VkLayerInstanceDispatchTable *get_dispatch_table(instance_table_map &map, void* object);
Courtney Goeltzenleuchterc08e72d2015-06-13 21:18:30 -060050
51void destroy_device_dispatch_table(dispatch_key key);
52void destroy_instance_dispatch_table(dispatch_key key);