Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1 | /* |
| 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 | */ |
Jon Ashburn | d3e4a76 | 2015-09-17 15:28:12 -0600 | [diff] [blame^] | 27 | #pragma once |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 28 | |
Jon Ashburn | d3e4a76 | 2015-09-17 15:28:12 -0600 | [diff] [blame^] | 29 | #include "vk_layer.h" |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 30 | |
| 31 | /* |
| 32 | * This file contains static functions for the generated layer Generic |
| 33 | */ |
| 34 | |
| 35 | #define LAYER_PROPS_ARRAY_SIZE 1 |
| 36 | static const VkLayerProperties layerProps[LAYER_PROPS_ARRAY_SIZE] = { |
| 37 | { |
| 38 | "Generic", |
| 39 | VK_API_VERSION, // specVersion |
| 40 | VK_MAKE_VERSION(0, 1, 0), // implVersion |
Courtney Goeltzenleuchter | a3eb0c1 | 2015-07-06 21:29:58 -0600 | [diff] [blame] | 41 | "layer: APIDump", |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 42 | } |
| 43 | }; |
| 44 | |
| 45 | #define LAYER_DEV_PROPS_ARRAY_SIZE 1 |
| 46 | static const VkLayerProperties layerDevProps[LAYER_DEV_PROPS_ARRAY_SIZE] = { |
| 47 | { |
| 48 | "Generic", |
| 49 | VK_API_VERSION, // specVersion |
| 50 | VK_MAKE_VERSION(0, 1, 0), // implVersion |
Courtney Goeltzenleuchter | a3eb0c1 | 2015-07-06 21:29:58 -0600 | [diff] [blame] | 51 | "layer: APIDump", |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 52 | } |
| 53 | }; |
| 54 | |
Jon Ashburn | d3e4a76 | 2015-09-17 15:28:12 -0600 | [diff] [blame^] | 55 | struct devExts { |
| 56 | bool wsi_enabled; |
| 57 | }; |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 58 | |
Jon Ashburn | d3e4a76 | 2015-09-17 15:28:12 -0600 | [diff] [blame^] | 59 | struct instExts { |
| 60 | bool wsi_enabled; |
| 61 | }; |
| 62 | |
| 63 | static std::unordered_map<void *, struct devExts> deviceExtMap; |
| 64 | static std::unordered_map<void *, struct instExts> instanceExtMap; |
| 65 | |
| 66 | static void createDeviceRegisterExtensions(const VkDeviceCreateInfo* pCreateInfo, VkDevice device) |
| 67 | { |
| 68 | uint32_t i; |
| 69 | VkLayerDispatchTable *pDisp = device_dispatch_table(device); |
| 70 | PFN_vkGetDeviceProcAddr gpa = pDisp->GetDeviceProcAddr; |
| 71 | pDisp->GetSurfacePropertiesKHR = (PFN_vkGetSurfacePropertiesKHR) gpa(device, "vkGetSurfacePropertiesKHR"); |
| 72 | pDisp->GetSurfaceFormatsKHR = (PFN_vkGetSurfaceFormatsKHR) gpa(device, "vkGetSurfaceFormatsKHR"); |
| 73 | pDisp->GetSurfacePresentModesKHR = (PFN_vkGetSurfacePresentModesKHR) gpa(device, "vkGetSurfacePresentModesKHR"); |
| 74 | pDisp->CreateSwapchainKHR = (PFN_vkCreateSwapchainKHR) gpa(device, "vkCreateSwapchainKHR"); |
| 75 | pDisp->DestroySwapchainKHR = (PFN_vkDestroySwapchainKHR) gpa(device, "vkDestroySwapchainKHR"); |
| 76 | pDisp->GetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR) gpa(device, "vkGetSwapchainImagesKHR"); |
| 77 | pDisp->AcquireNextImageKHR = (PFN_vkAcquireNextImageKHR) gpa(device, "vkAcquireNextImageKHR"); |
| 78 | pDisp->QueuePresentKHR = (PFN_vkQueuePresentKHR) gpa(device, "vkQueuePresentKHR"); |
| 79 | |
| 80 | deviceExtMap[pDisp].wsi_enabled = false; |
| 81 | for (i = 0; i < pCreateInfo->extensionCount; i++) { |
| 82 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_KHR_DEVICE_SWAPCHAIN_EXTENSION_NAME) == 0) |
| 83 | deviceExtMap[pDisp].wsi_enabled = true; |
| 84 | |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | static void createInstanceRegisterExtensions(const VkInstanceCreateInfo* pCreateInfo, VkInstance instance) |
| 89 | { |
| 90 | uint32_t i; |
| 91 | VkLayerInstanceDispatchTable *pDisp = instance_dispatch_table(instance); |
| 92 | PFN_vkGetInstanceProcAddr gpa = pDisp->GetInstanceProcAddr; |
| 93 | pDisp->GetPhysicalDeviceSurfaceSupportKHR = (PFN_vkGetPhysicalDeviceSurfaceSupportKHR) gpa(instance, "vkGetPhysicalDeviceSurfaceSupportKHR"); |
| 94 | instanceExtMap[pDisp].wsi_enabled = false; |
| 95 | for (i = 0; i < pCreateInfo->extensionCount; i++) { |
| 96 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_KHR_SWAPCHAIN_EXTENSION_NAME) == 0) |
| 97 | instanceExtMap[pDisp].wsi_enabled = true; |
| 98 | |
| 99 | } |
| 100 | } |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 101 | |