Jon Ashburn | 07daee7 | 2015-05-21 18:13:33 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Vulkan |
| 3 | * |
| 4 | * Copyright (C) 2015 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 | * Jon Ashburn <jon@lunarg.com> |
| 26 | * Courtney Goeltzenleuchter <courtney@lunarg.com> |
| 27 | */ |
| 28 | |
| 29 | #include <string.h> |
Tobin Ehlis | b835d1b | 2015-07-03 10:34:49 -0600 | [diff] [blame^] | 30 | #include "vk_loader_platform.h" |
Jon Ashburn | 07daee7 | 2015-05-21 18:13:33 -0600 | [diff] [blame] | 31 | #include "loader.h" |
| 32 | #include "wsi_lunarg.h" |
| 33 | |
| 34 | /************ Trampoline entrypoints *******************/ |
| 35 | /* since one entrypoint is instance level will make available all entrypoints */ |
Jon Ashburn | 07daee7 | 2015-05-21 18:13:33 -0600 | [diff] [blame] | 36 | |
| 37 | VkResult wsi_lunarg_CreateSwapChainWSI( |
| 38 | VkDevice device, |
| 39 | const VkSwapChainCreateInfoWSI* pCreateInfo, |
| 40 | VkSwapChainWSI* pSwapChain) |
| 41 | { |
| 42 | const VkLayerDispatchTable *disp; |
| 43 | VkResult res; |
| 44 | |
| 45 | disp = loader_get_dispatch(device); |
| 46 | |
| 47 | res = disp->CreateSwapChainWSI(device, pCreateInfo, pSwapChain); |
| 48 | if (res == VK_SUCCESS) { |
| 49 | loader_init_dispatch(*pSwapChain, disp); |
| 50 | } |
| 51 | |
| 52 | return res; |
| 53 | } |
| 54 | |
| 55 | VkResult wsi_lunarg_DestroySwapChainWSI( |
| 56 | VkSwapChainWSI swapChain) |
| 57 | { |
| 58 | const VkLayerDispatchTable *disp; |
| 59 | |
| 60 | disp = loader_get_dispatch(swapChain); |
| 61 | |
| 62 | return disp->DestroySwapChainWSI(swapChain); |
| 63 | } |
| 64 | |
| 65 | static VkResult wsi_lunarg_GetSwapChainInfoWSI( |
| 66 | VkSwapChainWSI swapChain, |
| 67 | VkSwapChainInfoTypeWSI infoType, |
| 68 | size_t* pDataSize, |
| 69 | void* pData) |
| 70 | { |
| 71 | const VkLayerDispatchTable *disp; |
| 72 | |
| 73 | disp = loader_get_dispatch(swapChain); |
| 74 | |
| 75 | return disp->GetSwapChainInfoWSI(swapChain, infoType, pDataSize, pData); |
| 76 | } |
| 77 | |
| 78 | static VkResult wsi_lunarg_QueuePresentWSI( |
| 79 | VkQueue queue, |
| 80 | const VkPresentInfoWSI* pPresentInfo) |
| 81 | { |
| 82 | const VkLayerDispatchTable *disp; |
| 83 | |
| 84 | disp = loader_get_dispatch(queue); |
| 85 | |
| 86 | return disp->QueuePresentWSI(queue, pPresentInfo); |
| 87 | } |
| 88 | |
Jon Ashburn | 07daee7 | 2015-05-21 18:13:33 -0600 | [diff] [blame] | 89 | |
Jon Ashburn | 07daee7 | 2015-05-21 18:13:33 -0600 | [diff] [blame] | 90 | |
| 91 | void *wsi_lunarg_GetInstanceProcAddr( |
| 92 | VkInstance instance, |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 93 | const char* pName) |
Jon Ashburn | 07daee7 | 2015-05-21 18:13:33 -0600 | [diff] [blame] | 94 | { |
| 95 | if (instance == VK_NULL_HANDLE) |
| 96 | return NULL; |
| 97 | |
Jon Ashburn | 922c8f6 | 2015-06-18 09:05:37 -0600 | [diff] [blame] | 98 | // TODO once WSI is pure device extension with no special trampoline code remove this function |
Jon Ashburn | b19ddbf | 2015-06-16 12:44:51 -0600 | [diff] [blame] | 99 | /* since one of these entrypoints must be loader handled will report all */ |
Jon Ashburn | 07daee7 | 2015-05-21 18:13:33 -0600 | [diff] [blame] | 100 | if (!strcmp(pName, "vkCreateSwapChainWSI")) |
| 101 | return (void*) wsi_lunarg_CreateSwapChainWSI; |
| 102 | if (!strcmp(pName, "vkDestroySwapChainWSI")) |
| 103 | return (void*) wsi_lunarg_DestroySwapChainWSI; |
| 104 | if (!strcmp(pName, "vkGetSwapChainInfoWSI")) |
| 105 | return (void*) wsi_lunarg_GetSwapChainInfoWSI; |
| 106 | if (!strcmp(pName, "vkQueuePresentWSI")) |
| 107 | return (void*) wsi_lunarg_QueuePresentWSI; |
| 108 | |
| 109 | return NULL; |
| 110 | } |
| 111 | |
| 112 | void *wsi_lunarg_GetDeviceProcAddr( |
| 113 | VkDevice device, |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 114 | const char* name) |
Jon Ashburn | 07daee7 | 2015-05-21 18:13:33 -0600 | [diff] [blame] | 115 | { |
| 116 | if (device == VK_NULL_HANDLE) |
| 117 | return NULL; |
| 118 | |
Jon Ashburn | 922c8f6 | 2015-06-18 09:05:37 -0600 | [diff] [blame] | 119 | // TODO make sure WSI is enabled, but eventually this function goes away |
Jon Ashburn | 07daee7 | 2015-05-21 18:13:33 -0600 | [diff] [blame] | 120 | /* only handle device entrypoints that are loader special cases */ |
| 121 | if (!strcmp(name, "vkCreateSwapChainWSI")) |
| 122 | return (void*) wsi_lunarg_CreateSwapChainWSI; |
| 123 | |
| 124 | return NULL; |
| 125 | } |