blob: 793281b8f8401fbaf579bf104aa7a1bd3b816439 [file] [log] [blame]
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -06001/*
2 * Vulkan
3 *
4 * Copyright (C) 2014 LunarG, Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *
24 * Authors:
25 * Courtney Goeltzenleuchter <courtney@lunarg.com>
26 */
27
28#ifndef GENERIC_H
29#define GENERIC_H
Courtney Goeltzenleuchter79d8d2c2015-07-07 17:51:45 -060030#include "vk_layer.h"
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -060031
32/*
33 * This file contains static functions for the generated layer Generic
34 */
35
Courtney Goeltzenleuchter79d8d2c2015-07-07 17:51:45 -060036static const VkLayerProperties globalLayerProps[] = {
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -060037 {
38 "Generic",
39 VK_API_VERSION, // specVersion
40 VK_MAKE_VERSION(0, 1, 0), // implVersion
41 "layer: Generic",
42 }
43};
44
Courtney Goeltzenleuchter79d8d2c2015-07-07 17:51:45 -060045static const VkLayerProperties deviceLayerProps[] = {
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -060046 {
47 "Generic",
48 VK_API_VERSION, // specVersion
49 VK_MAKE_VERSION(0, 1, 0), // implVersion
50 "layer: Generic",
51 }
52};
53
Jon Ashburnd3e4a762015-09-17 15:28:12 -060054struct devExts {
55 bool wsi_enabled;
56};
57struct instExts {
58 bool wsi_enabled;
59};
60static std::unordered_map<void *, struct devExts> deviceExtMap;
61static std::unordered_map<void *, struct instExts> instanceExtMap;
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -060062
Jon Ashburnd3e4a762015-09-17 15:28:12 -060063static void createDeviceRegisterExtensions(const VkDeviceCreateInfo* pCreateInfo, VkDevice device)
64{
65 uint32_t i;
66 VkLayerDispatchTable *pDisp = device_dispatch_table(device);
67 PFN_vkGetDeviceProcAddr gpa = pDisp->GetDeviceProcAddr;
68 pDisp->GetSurfacePropertiesKHR = (PFN_vkGetSurfacePropertiesKHR) gpa(device, "vkGetSurfacePropertiesKHR");
69 pDisp->GetSurfaceFormatsKHR = (PFN_vkGetSurfaceFormatsKHR) gpa(device, "vkGetSurfaceFormatsKHR");
70 pDisp->GetSurfacePresentModesKHR = (PFN_vkGetSurfacePresentModesKHR) gpa(device, "vkGetSurfacePresentModesKHR");
71 pDisp->CreateSwapchainKHR = (PFN_vkCreateSwapchainKHR) gpa(device, "vkCreateSwapchainKHR");
72 pDisp->DestroySwapchainKHR = (PFN_vkDestroySwapchainKHR) gpa(device, "vkDestroySwapchainKHR");
73 pDisp->GetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR) gpa(device, "vkGetSwapchainImagesKHR");
74 pDisp->AcquireNextImageKHR = (PFN_vkAcquireNextImageKHR) gpa(device, "vkAcquireNextImageKHR");
75 pDisp->QueuePresentKHR = (PFN_vkQueuePresentKHR) gpa(device, "vkQueuePresentKHR");
76
77 deviceExtMap[pDisp].wsi_enabled = false;
78 for (i = 0; i < pCreateInfo->extensionCount; i++) {
79 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_KHR_DEVICE_SWAPCHAIN_EXTENSION_NAME) == 0)
80 deviceExtMap[pDisp].wsi_enabled = true;
81
82 }
83}
84
85static void createInstanceRegisterExtensions(const VkInstanceCreateInfo* pCreateInfo, VkInstance instance)
86{
87 uint32_t i;
88 VkLayerInstanceDispatchTable *pDisp = instance_dispatch_table(instance);
89 PFN_vkGetInstanceProcAddr gpa = pDisp->GetInstanceProcAddr;
90 pDisp->GetPhysicalDeviceSurfaceSupportKHR = (PFN_vkGetPhysicalDeviceSurfaceSupportKHR) gpa(instance, "vkGetPhysicalDeviceSurfaceSupportKHR");
91 instanceExtMap[pDisp].wsi_enabled = false;
92 for (i = 0; i < pCreateInfo->extensionCount; i++) {
93 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_KHR_SWAPCHAIN_EXTENSION_NAME) == 0)
94 instanceExtMap[pDisp].wsi_enabled = true;
95
96 }
97}
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -060098#endif // GENERIC_H
99