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