blob: 45b8f6e1770bb3580163d9105279d29b200e8e5b [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 *
Jon Ashburn3ebf1252016-04-19 11:30:31 -06005 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
Jon Ashburn9eed2892015-06-01 10:02:09 -06008 *
Jon Ashburn3ebf1252016-04-19 11:30:31 -06009 * http://www.apache.org/licenses/LICENSE-2.0
Jon Ashburn9eed2892015-06-01 10:02:09 -060010 *
Jon Ashburn3ebf1252016-04-19 11:30:31 -060011 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
Courtney Goeltzenleuchter05559522015-10-30 11:14:30 -060016 *
17 * Author: Tobin Ehlis <tobin@lunarg.com>
Jon Ashburn9eed2892015-06-01 10:02:09 -060018 */
Mark Lobodzinski6eda00a2016-02-02 15:55:36 -070019
Jon Ashburn9eed2892015-06-01 10:02:09 -060020#pragma once
21
Tobin Ehlis2d9deec2016-04-21 14:19:26 -060022#include "vulkan/vk_layer.h"
Courtney Goeltzenleuchter93a89cc2016-01-08 11:52:37 -070023#include "vulkan/vulkan.h"
Jon Ashburn9eed2892015-06-01 10:02:09 -060024#include <unordered_map>
25
Courtney Goeltzenleuchtere45acec2015-06-14 12:03:26 -060026typedef std::unordered_map<void *, VkLayerDispatchTable *> device_table_map;
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -070027typedef std::unordered_map<void *, VkLayerInstanceDispatchTable *> instance_table_map;
Jon Ashburn5484e0c2016-03-08 17:48:44 -070028VkLayerDispatchTable *initDeviceTable(VkDevice device, const PFN_vkGetDeviceProcAddr gpa, device_table_map &map);
29VkLayerDispatchTable *initDeviceTable(VkDevice device, const PFN_vkGetDeviceProcAddr gpa);
30VkLayerInstanceDispatchTable *initInstanceTable(VkInstance instance, const PFN_vkGetInstanceProcAddr gpa, instance_table_map &map);
31VkLayerInstanceDispatchTable *initInstanceTable(VkInstance instance, const PFN_vkGetInstanceProcAddr gpa);
Courtney Goeltzenleuchtere45acec2015-06-14 12:03:26 -060032
33typedef void *dispatch_key;
34
Jon Ashburn5484e0c2016-03-08 17:48:44 -070035static inline dispatch_key get_dispatch_key(const void *object) { return (dispatch_key) * (VkLayerDispatchTable **)object; }
Jon Ashburn9eed2892015-06-01 10:02:09 -060036
Jon Ashburn5484e0c2016-03-08 17:48:44 -070037VkLayerDispatchTable *device_dispatch_table(void *object);
Jon Ashburn9eed2892015-06-01 10:02:09 -060038
Jon Ashburn5484e0c2016-03-08 17:48:44 -070039VkLayerInstanceDispatchTable *instance_dispatch_table(void *object);
Courtney Goeltzenleuchtere45acec2015-06-14 12:03:26 -060040
Jon Ashburn5484e0c2016-03-08 17:48:44 -070041VkLayerDispatchTable *get_dispatch_table(device_table_map &map, void *object);
Courtney Goeltzenleuchtere45acec2015-06-14 12:03:26 -060042
Jon Ashburn5484e0c2016-03-08 17:48:44 -070043VkLayerInstanceDispatchTable *get_dispatch_table(instance_table_map &map, void *object);
Courtney Goeltzenleuchterc08e72d2015-06-13 21:18:30 -060044
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -070045VkLayerInstanceCreateInfo *get_chain_info(const VkInstanceCreateInfo *pCreateInfo, VkLayerFunction func);
46VkLayerDeviceCreateInfo *get_chain_info(const VkDeviceCreateInfo *pCreateInfo, VkLayerFunction func);
Courtney Goeltzenleuchter93a89cc2016-01-08 11:52:37 -070047
Courtney Goeltzenleuchterc08e72d2015-06-13 21:18:30 -060048void destroy_device_dispatch_table(dispatch_key key);
49void destroy_instance_dispatch_table(dispatch_key key);
Courtney Goeltzenleuchter951af522016-01-15 11:58:33 -070050void destroy_dispatch_table(device_table_map &map, dispatch_key key);
51void destroy_dispatch_table(instance_table_map &map, dispatch_key key);