blob: 13d30047da8ade46f02ea40e6c7f1a9a04e4d9df [file] [log] [blame]
Ian Elliott54cea232015-10-30 15:28:23 -06001/*
Jon Ashburn1c75aec2016-02-02 17:47:28 -07002 * Copyright (c) 2015-2016 The Khronos Group Inc.
3 * Copyright (c) 2015-2016 Valve Corporation
4 * Copyright (c) 2015-2016 LunarG, Inc.
Ian Elliott54cea232015-10-30 15:28:23 -06005 *
Jon Ashburn4f80d672016-04-19 11:30:31 -06006 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
Ian Elliott54cea232015-10-30 15:28:23 -06009 *
Jon Ashburn4f80d672016-04-19 11:30:31 -060010 * http://www.apache.org/licenses/LICENSE-2.0
Ian Elliott54cea232015-10-30 15:28:23 -060011 *
Jon Ashburn4f80d672016-04-19 11:30:31 -060012 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
Ian Elliott54cea232015-10-30 15:28:23 -060017 *
18 * Author: Ian Elliott <ian@lunarg.com>
Jon Ashburn1c75aec2016-02-02 17:47:28 -070019 * Author: Jon Ashburn <jon@lunarg.com>
Ian Elliottb1849742015-11-19 11:58:08 -070020 * Author: Ian Elliott <ianelliott@google.com>
Jon Ashburn1c75aec2016-02-02 17:47:28 -070021 * Author: Mark Lobodzinski <mark@lunarg.com>
Ian Elliott54cea232015-10-30 15:28:23 -060022 */
23
Ian Elliott54cea232015-10-30 15:28:23 -060024#define _GNU_SOURCE
Ian Elliott0d4ffa32016-03-24 13:59:22 -060025#include <stdio.h>
Ian Elliott54cea232015-10-30 15:28:23 -060026#include <stdlib.h>
27#include <string.h>
28#include "vk_loader_platform.h"
29#include "loader.h"
30#include "wsi.h"
Ian Elliott7c352552015-11-19 13:14:05 -070031#include <vulkan/vk_icd.h>
Ian Elliott54cea232015-10-30 15:28:23 -060032
33static const VkExtensionProperties wsi_surface_extension_info = {
Jon Ashburn1c75aec2016-02-02 17:47:28 -070034 .extensionName = VK_KHR_SURFACE_EXTENSION_NAME,
35 .specVersion = VK_KHR_SURFACE_SPEC_VERSION,
Ian Elliott54cea232015-10-30 15:28:23 -060036};
37
Ian Elliottb1849742015-11-19 11:58:08 -070038#ifdef VK_USE_PLATFORM_WIN32_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060039static const VkExtensionProperties wsi_win32_surface_extension_info = {
Jon Ashburn1c75aec2016-02-02 17:47:28 -070040 .extensionName = VK_KHR_WIN32_SURFACE_EXTENSION_NAME,
41 .specVersion = VK_KHR_WIN32_SURFACE_SPEC_VERSION,
Ian Elliott54cea232015-10-30 15:28:23 -060042};
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -070043#endif // VK_USE_PLATFORM_WIN32_KHR
44
Ian Elliott5fb891a2015-10-30 17:45:05 -060045#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060046static const VkExtensionProperties wsi_mir_surface_extension_info = {
Jon Ashburn1c75aec2016-02-02 17:47:28 -070047 .extensionName = VK_KHR_MIR_SURFACE_EXTENSION_NAME,
48 .specVersion = VK_KHR_MIR_SURFACE_SPEC_VERSION,
Ian Elliott54cea232015-10-30 15:28:23 -060049};
Ian Elliott5fb891a2015-10-30 17:45:05 -060050#endif // VK_USE_PLATFORM_MIR_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060051
Ian Elliott5fb891a2015-10-30 17:45:05 -060052#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060053static const VkExtensionProperties wsi_wayland_surface_extension_info = {
Jon Ashburn1c75aec2016-02-02 17:47:28 -070054 .extensionName = VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME,
55 .specVersion = VK_KHR_WAYLAND_SURFACE_SPEC_VERSION,
Ian Elliott54cea232015-10-30 15:28:23 -060056};
Ian Elliott5fb891a2015-10-30 17:45:05 -060057#endif // VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060058
Ian Elliott5fb891a2015-10-30 17:45:05 -060059#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060060static const VkExtensionProperties wsi_xcb_surface_extension_info = {
Jon Ashburn1c75aec2016-02-02 17:47:28 -070061 .extensionName = VK_KHR_XCB_SURFACE_EXTENSION_NAME,
62 .specVersion = VK_KHR_XCB_SURFACE_SPEC_VERSION,
Ian Elliott54cea232015-10-30 15:28:23 -060063};
Ian Elliott5fb891a2015-10-30 17:45:05 -060064#endif // VK_USE_PLATFORM_XCB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060065
Ian Elliott5fb891a2015-10-30 17:45:05 -060066#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060067static const VkExtensionProperties wsi_xlib_surface_extension_info = {
Jon Ashburn1c75aec2016-02-02 17:47:28 -070068 .extensionName = VK_KHR_XLIB_SURFACE_EXTENSION_NAME,
69 .specVersion = VK_KHR_XLIB_SURFACE_SPEC_VERSION,
Ian Elliott54cea232015-10-30 15:28:23 -060070};
Ian Elliott5fb891a2015-10-30 17:45:05 -060071#endif // VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -070072
73#ifdef VK_USE_PLATFORM_ANDROID_KHR
74static const VkExtensionProperties wsi_android_surface_extension_info = {
Jon Ashburn1c75aec2016-02-02 17:47:28 -070075 .extensionName = VK_KHR_ANDROID_SURFACE_EXTENSION_NAME,
76 .specVersion = VK_KHR_ANDROID_SURFACE_REVISION,
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -070077};
78#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060079
Jon Ashburn1c75aec2016-02-02 17:47:28 -070080void wsi_create_instance(struct loader_instance *ptr_instance,
81 const VkInstanceCreateInfo *pCreateInfo) {
Ian Elliott5fb891a2015-10-30 17:45:05 -060082 ptr_instance->wsi_surface_enabled = false;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -070083
84#ifdef VK_USE_PLATFORM_WIN32_KHR
Jon Ashburncc370d02016-03-08 09:30:30 -070085 ptr_instance->wsi_win32_surface_enabled = false;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -070086#endif // VK_USE_PLATFORM_WIN32_KHR
87#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060088 ptr_instance->wsi_mir_surface_enabled = false;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -070089#endif // VK_USE_PLATFORM_MIR_KHR
90#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060091 ptr_instance->wsi_wayland_surface_enabled = false;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -070092#endif // VK_USE_PLATFORM_WAYLAND_KHR
93#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060094 ptr_instance->wsi_xcb_surface_enabled = false;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -070095#endif // VK_USE_PLATFORM_XCB_KHR
96#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060097 ptr_instance->wsi_xlib_surface_enabled = false;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -070098#endif // VK_USE_PLATFORM_XLIB_KHR
99#ifdef VK_USE_PLATFORM_ANDROID_KHR
100 ptr_instance->wsi_android_surface_enabled = false;
101#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600102
Jon Ashburncc370d02016-03-08 09:30:30 -0700103 ptr_instance->wsi_display_enabled = false;
104
Jon Ashburna0673ab2016-01-11 13:12:43 -0700105 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700106 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
107 VK_KHR_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott54cea232015-10-30 15:28:23 -0600108 ptr_instance->wsi_surface_enabled = true;
Ian Elliottb1849742015-11-19 11:58:08 -0700109 continue;
Ian Elliott54cea232015-10-30 15:28:23 -0600110 }
Ian Elliottb1849742015-11-19 11:58:08 -0700111#ifdef VK_USE_PLATFORM_WIN32_KHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700112 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
113 VK_KHR_WIN32_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott1693f592015-11-23 10:17:23 -0700114 ptr_instance->wsi_win32_surface_enabled = true;
Ian Elliottb1849742015-11-19 11:58:08 -0700115 continue;
Ian Elliott54cea232015-10-30 15:28:23 -0600116 }
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700117#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliott5fb891a2015-10-30 17:45:05 -0600118#ifdef VK_USE_PLATFORM_MIR_KHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700119 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
120 VK_KHR_MIR_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott54cea232015-10-30 15:28:23 -0600121 ptr_instance->wsi_mir_surface_enabled = true;
Ian Elliottb1849742015-11-19 11:58:08 -0700122 continue;
Ian Elliott54cea232015-10-30 15:28:23 -0600123 }
Ian Elliott5fb891a2015-10-30 17:45:05 -0600124#endif // VK_USE_PLATFORM_MIR_KHR
125#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700126 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
127 VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott54cea232015-10-30 15:28:23 -0600128 ptr_instance->wsi_wayland_surface_enabled = true;
Ian Elliottb1849742015-11-19 11:58:08 -0700129 continue;
Ian Elliott54cea232015-10-30 15:28:23 -0600130 }
Ian Elliott5fb891a2015-10-30 17:45:05 -0600131#endif // VK_USE_PLATFORM_WAYLAND_KHR
132#ifdef VK_USE_PLATFORM_XCB_KHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700133 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
134 VK_KHR_XCB_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott54cea232015-10-30 15:28:23 -0600135 ptr_instance->wsi_xcb_surface_enabled = true;
Ian Elliottb1849742015-11-19 11:58:08 -0700136 continue;
Ian Elliott54cea232015-10-30 15:28:23 -0600137 }
Ian Elliott5fb891a2015-10-30 17:45:05 -0600138#endif // VK_USE_PLATFORM_XCB_KHR
139#ifdef VK_USE_PLATFORM_XLIB_KHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700140 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
141 VK_KHR_XLIB_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott54cea232015-10-30 15:28:23 -0600142 ptr_instance->wsi_xlib_surface_enabled = true;
Ian Elliottb1849742015-11-19 11:58:08 -0700143 continue;
Ian Elliott54cea232015-10-30 15:28:23 -0600144 }
Ian Elliott5fb891a2015-10-30 17:45:05 -0600145#endif // VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700146#ifdef VK_USE_PLATFORM_ANDROID_KHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700147 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
148 VK_KHR_ANDROID_SURFACE_EXTENSION_NAME) == 0) {
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700149 ptr_instance->wsi_android_surface_enabled = true;
150 continue;
151 }
152#endif // VK_USE_PLATFORM_ANDROID_KHR
Jon Ashburncc370d02016-03-08 09:30:30 -0700153 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
154 VK_KHR_DISPLAY_EXTENSION_NAME) == 0) {
155 ptr_instance->wsi_display_enabled = true;
156 continue;
157 }
Ian Elliott54cea232015-10-30 15:28:23 -0600158 }
159}
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600160
Mark Young76b3fe02016-09-08 12:28:38 -0600161void wsi_create_device(struct loader_device *dev,
162 const VkDeviceCreateInfo *pCreateInfo) {
163 dev->loader_dispatch.enabled_known_extensions.khr_display_swapchain = 0;
164
165 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
166 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
167 VK_KHR_DISPLAY_SWAPCHAIN_EXTENSION_NAME) == 0) {
168 dev->loader_dispatch.enabled_known_extensions
169 .khr_display_swapchain = 1;
170 return;
171 }
172 }
173}
174
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600175// Linux WSI surface extensions are not always compiled into the loader. (Assume
176// for Windows the KHR_win32_surface is always compiled into loader). A given
177// Linux build environment might not have the headers required for building one
178// of the four extensions (Xlib, Xcb, Mir, Wayland). Thus, need to check if
179// the built loader actually supports the particular Linux surface extension.
180// If not supported by the built loader it will not be included in the list of
181// enumerated instance extensions. This solves the issue where an ICD or layer
182// advertises support for a given Linux surface extension but the loader was not
183// built to support the extension.
Jon Ashburnae8f1e82016-03-25 12:49:35 -0600184bool wsi_unsupported_instance_extension(const VkExtensionProperties *ext_prop) {
185#ifndef VK_USE_PLATFORM_MIR_KHR
186 if (!strcmp(ext_prop->extensionName, "VK_KHR_mir_surface"))
187 return true;
188#endif // VK_USE_PLATFORM_MIR_KHR
189#ifndef VK_USE_PLATFORM_WAYLAND_KHR
190 if (!strcmp(ext_prop->extensionName, "VK_KHR_wayland_surface"))
191 return true;
192#endif // VK_USE_PLATFORM_WAYLAND_KHR
193#ifndef VK_USE_PLATFORM_XCB_KHR
194 if (!strcmp(ext_prop->extensionName, "VK_KHR_xcb_surface"))
195 return true;
196#endif // VK_USE_PLATFORM_XCB_KHR
197#ifndef VK_USE_PLATFORM_XLIB_KHR
198 if (!strcmp(ext_prop->extensionName, "VK_KHR_xlib_surface"))
199 return true;
200#endif // VK_USE_PLATFORM_XLIB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600201
Jon Ashburnae8f1e82016-03-25 12:49:35 -0600202 return false;
203}
Ian Elliott7c352552015-11-19 13:14:05 -0700204
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600205// Functions for the VK_KHR_surface extension:
206
207// This is the trampoline entrypoint for DestroySurfaceKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700208LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
209vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface,
210 const VkAllocationCallbacks *pAllocator) {
Ian Elliottabf50662015-11-25 14:43:02 -0700211 const VkLayerInstanceDispatchTable *disp;
212 disp = loader_get_instance_dispatch(instance);
213 disp->DestroySurfaceKHR(instance, surface, pAllocator);
214}
215
Jon Ashburncc370d02016-03-08 09:30:30 -0700216// TODO probably need to lock around all the loader_get_instance() calls.
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600217
218// This is the instance chain terminator function for DestroySurfaceKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700219VKAPI_ATTR void VKAPI_CALL
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700220terminator_DestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface,
221 const VkAllocationCallbacks *pAllocator) {
Ian Elliott1693f592015-11-23 10:17:23 -0700222 struct loader_instance *ptr_instance = loader_get_instance(instance);
223
Mark Young74dd5d12016-06-30 13:02:42 -0600224 loader_instance_heap_free(ptr_instance, (void *)surface);
Ian Elliott7c352552015-11-19 13:14:05 -0700225}
226
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600227// This is the trampoline entrypoint for GetPhysicalDeviceSurfaceSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700228LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
229vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice,
230 uint32_t queueFamilyIndex,
231 VkSurfaceKHR surface,
232 VkBool32 *pSupported) {
Ian Elliott54cea232015-10-30 15:28:23 -0600233 const VkLayerInstanceDispatchTable *disp;
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700234 VkPhysicalDevice unwrapped_phys_dev =
235 loader_unwrap_physical_device(physicalDevice);
Ian Elliott54cea232015-10-30 15:28:23 -0600236 disp = loader_get_instance_dispatch(physicalDevice);
237 VkResult res = disp->GetPhysicalDeviceSurfaceSupportKHR(
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700238 unwrapped_phys_dev, queueFamilyIndex, surface, pSupported);
Ian Elliott54cea232015-10-30 15:28:23 -0600239 return res;
240}
241
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600242// This is the instance chain terminator function for
243// GetPhysicalDeviceSurfaceSupportKHR
244VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceSupportKHR(
245 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
246 VkSurfaceKHR surface, VkBool32 *pSupported) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600247 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700248 struct loader_physical_device *phys_dev =
249 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600250 struct loader_instance *ptr_instance =
251 (struct loader_instance *)phys_dev->this_icd->this_instance;
252 if (!ptr_instance->wsi_surface_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -0600253 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
254 "VK_KHR_VK_KHR_surface extension not enabled. "
255 "vkGetPhysicalDeviceSurfaceSupportKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600256 return VK_SUCCESS;
257 }
258
259 // Next, if so, proceed with the implementation of this function:
Ian Elliott54cea232015-10-30 15:28:23 -0600260 struct loader_icd *icd = phys_dev->this_icd;
261
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700262 assert(pSupported &&
263 "GetPhysicalDeviceSurfaceSupportKHR: Error, null pSupported");
Ian Elliott54cea232015-10-30 15:28:23 -0600264 *pSupported = false;
265
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700266 assert(icd->GetPhysicalDeviceSurfaceSupportKHR &&
267 "loader: null GetPhysicalDeviceSurfaceSupportKHR ICD pointer");
Ian Elliott54cea232015-10-30 15:28:23 -0600268
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700269 return icd->GetPhysicalDeviceSurfaceSupportKHR(
270 phys_dev->phys_dev, queueFamilyIndex, surface, pSupported);
Ian Elliott54cea232015-10-30 15:28:23 -0600271}
272
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600273// This is the trampoline entrypoint for GetPhysicalDeviceSurfaceCapabilitiesKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700274LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
275vkGetPhysicalDeviceSurfaceCapabilitiesKHR(
276 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
277 VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) {
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700278
Ian Elliottea666b22015-11-19 16:05:09 -0700279 const VkLayerInstanceDispatchTable *disp;
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700280 VkPhysicalDevice unwrapped_phys_dev =
281 loader_unwrap_physical_device(physicalDevice);
Ian Elliottea666b22015-11-19 16:05:09 -0700282 disp = loader_get_instance_dispatch(physicalDevice);
283 VkResult res = disp->GetPhysicalDeviceSurfaceCapabilitiesKHR(
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700284 unwrapped_phys_dev, surface, pSurfaceCapabilities);
Ian Elliottea666b22015-11-19 16:05:09 -0700285 return res;
286}
287
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600288// This is the instance chain terminator function for
289// GetPhysicalDeviceSurfaceCapabilitiesKHR
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700290VKAPI_ATTR VkResult VKAPI_CALL
291terminator_GetPhysicalDeviceSurfaceCapabilitiesKHR(
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700292 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
293 VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600294 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700295 struct loader_physical_device *phys_dev =
296 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600297 struct loader_instance *ptr_instance =
298 (struct loader_instance *)phys_dev->this_icd->this_instance;
299 if (!ptr_instance->wsi_surface_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -0600300 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
301 "VK_KHR_surface extension not enabled. "
302 "vkGetPhysicalDeviceSurfaceCapabilitiesKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600303 return VK_SUCCESS;
304 }
305
306 // Next, if so, proceed with the implementation of this function:
Ian Elliottea666b22015-11-19 16:05:09 -0700307 struct loader_icd *icd = phys_dev->this_icd;
308
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700309 assert(pSurfaceCapabilities && "GetPhysicalDeviceSurfaceCapabilitiesKHR: "
310 "Error, null pSurfaceCapabilities");
Ian Elliottea666b22015-11-19 16:05:09 -0700311
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700312 assert(icd->GetPhysicalDeviceSurfaceCapabilitiesKHR &&
313 "loader: null GetPhysicalDeviceSurfaceCapabilitiesKHR ICD pointer");
Ian Elliottea666b22015-11-19 16:05:09 -0700314
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700315 return icd->GetPhysicalDeviceSurfaceCapabilitiesKHR(
316 phys_dev->phys_dev, surface, pSurfaceCapabilities);
Ian Elliottea666b22015-11-19 16:05:09 -0700317}
318
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600319
320// This is the trampoline entrypoint for GetPhysicalDeviceSurfaceFormatsKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700321LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
322vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice,
323 VkSurfaceKHR surface,
324 uint32_t *pSurfaceFormatCount,
325 VkSurfaceFormatKHR *pSurfaceFormats) {
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700326 VkPhysicalDevice unwrapped_phys_dev =
327 loader_unwrap_physical_device(physicalDevice);
Ian Elliottea666b22015-11-19 16:05:09 -0700328 const VkLayerInstanceDispatchTable *disp;
329 disp = loader_get_instance_dispatch(physicalDevice);
330 VkResult res = disp->GetPhysicalDeviceSurfaceFormatsKHR(
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700331 unwrapped_phys_dev, surface, pSurfaceFormatCount, pSurfaceFormats);
Ian Elliottea666b22015-11-19 16:05:09 -0700332 return res;
333}
334
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600335
336// This is the instance chain terminator function for GetPhysicalDeviceSurfaceFormatsKHR
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700337VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceFormatsKHR(
338 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
339 uint32_t *pSurfaceFormatCount, VkSurfaceFormatKHR *pSurfaceFormats) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600340 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700341 struct loader_physical_device *phys_dev =
342 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600343 struct loader_instance *ptr_instance =
344 (struct loader_instance *)phys_dev->this_icd->this_instance;
345 if (!ptr_instance->wsi_surface_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -0600346 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
347 "VK_KHR_surface extension not enabled. "
348 "vkGetPhysicalDeviceSurfaceFormatsKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600349 return VK_SUCCESS;
350 }
351
352 // Next, if so, proceed with the implementation of this function:
Ian Elliottea666b22015-11-19 16:05:09 -0700353 struct loader_icd *icd = phys_dev->this_icd;
354
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700355 assert(
356 pSurfaceFormatCount &&
357 "GetPhysicalDeviceSurfaceFormatsKHR: Error, null pSurfaceFormatCount");
Ian Elliottea666b22015-11-19 16:05:09 -0700358
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700359 assert(icd->GetPhysicalDeviceSurfaceFormatsKHR &&
360 "loader: null GetPhysicalDeviceSurfaceFormatsKHR ICD pointer");
Ian Elliottea666b22015-11-19 16:05:09 -0700361
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700362 return icd->GetPhysicalDeviceSurfaceFormatsKHR(
363 phys_dev->phys_dev, surface, pSurfaceFormatCount, pSurfaceFormats);
Ian Elliottea666b22015-11-19 16:05:09 -0700364}
365
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600366// This is the trampoline entrypoint for GetPhysicalDeviceSurfacePresentModesKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700367LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
368vkGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,
369 VkSurfaceKHR surface,
370 uint32_t *pPresentModeCount,
371 VkPresentModeKHR *pPresentModes) {
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700372 VkPhysicalDevice unwrapped_phys_dev =
373 loader_unwrap_physical_device(physicalDevice);
Ian Elliottea666b22015-11-19 16:05:09 -0700374 const VkLayerInstanceDispatchTable *disp;
375 disp = loader_get_instance_dispatch(physicalDevice);
376 VkResult res = disp->GetPhysicalDeviceSurfacePresentModesKHR(
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700377 unwrapped_phys_dev, surface, pPresentModeCount, pPresentModes);
Ian Elliottea666b22015-11-19 16:05:09 -0700378 return res;
379}
380
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600381// This is the instance chain terminator function for
382// GetPhysicalDeviceSurfacePresentModesKHR
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700383VKAPI_ATTR VkResult VKAPI_CALL
384terminator_GetPhysicalDeviceSurfacePresentModesKHR(
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700385 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
386 uint32_t *pPresentModeCount, VkPresentModeKHR *pPresentModes) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600387 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700388 struct loader_physical_device *phys_dev =
389 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600390 struct loader_instance *ptr_instance =
391 (struct loader_instance *)phys_dev->this_icd->this_instance;
392 if (!ptr_instance->wsi_surface_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -0600393 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
394 "VK_KHR_surface extension not enabled. "
395 "vkGetPhysicalDeviceSurfacePresentModesKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600396 return VK_SUCCESS;
397 }
398
399 // Next, if so, proceed with the implementation of this function:
Ian Elliottea666b22015-11-19 16:05:09 -0700400 struct loader_icd *icd = phys_dev->this_icd;
401
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700402 assert(pPresentModeCount && "GetPhysicalDeviceSurfacePresentModesKHR: "
403 "Error, null pPresentModeCount");
Ian Elliottea666b22015-11-19 16:05:09 -0700404
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700405 assert(icd->GetPhysicalDeviceSurfacePresentModesKHR &&
406 "loader: null GetPhysicalDeviceSurfacePresentModesKHR ICD pointer");
Ian Elliottea666b22015-11-19 16:05:09 -0700407
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700408 return icd->GetPhysicalDeviceSurfacePresentModesKHR(
409 phys_dev->phys_dev, surface, pPresentModeCount, pPresentModes);
Ian Elliottea666b22015-11-19 16:05:09 -0700410}
411
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600412// Functions for the VK_KHR_swapchain extension:
Ian Elliott7c352552015-11-19 13:14:05 -0700413
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600414// This is the trampoline entrypoint for CreateSwapchainKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600415LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR(
416 VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
417 const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain) {
Ian Elliott9b89a472015-11-19 16:39:21 -0700418 const VkLayerDispatchTable *disp;
419 disp = loader_get_dispatch(device);
Mark Young76b3fe02016-09-08 12:28:38 -0600420 return disp->CreateSwapchainKHR(device, pCreateInfo, pAllocator,
421 pSwapchain);
Ian Elliott9b89a472015-11-19 16:39:21 -0700422}
Ian Elliott7c352552015-11-19 13:14:05 -0700423
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600424// This is the trampoline entrypoint for DestroySwapchainKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700425LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
426vkDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain,
427 const VkAllocationCallbacks *pAllocator) {
Ian Elliott9b89a472015-11-19 16:39:21 -0700428 const VkLayerDispatchTable *disp;
429 disp = loader_get_dispatch(device);
430 disp->DestroySwapchainKHR(device, swapchain, pAllocator);
431}
Ian Elliott7c352552015-11-19 13:14:05 -0700432
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600433// This is the trampoline entrypoint for GetSwapchainImagesKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700434LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
435vkGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain,
436 uint32_t *pSwapchainImageCount,
437 VkImage *pSwapchainImages) {
Ian Elliott9b89a472015-11-19 16:39:21 -0700438 const VkLayerDispatchTable *disp;
439 disp = loader_get_dispatch(device);
Mark Young76b3fe02016-09-08 12:28:38 -0600440 return disp->GetSwapchainImagesKHR(
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700441 device, swapchain, pSwapchainImageCount, pSwapchainImages);
Ian Elliott9b89a472015-11-19 16:39:21 -0700442}
443
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600444// This is the trampoline entrypoint for AcquireNextImageKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700445LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
446vkAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain,
447 uint64_t timeout, VkSemaphore semaphore, VkFence fence,
448 uint32_t *pImageIndex) {
Ian Elliott9b89a472015-11-19 16:39:21 -0700449 const VkLayerDispatchTable *disp;
450 disp = loader_get_dispatch(device);
Mark Young76b3fe02016-09-08 12:28:38 -0600451 return disp->AcquireNextImageKHR(device, swapchain, timeout,
452 semaphore, fence, pImageIndex);
Ian Elliott9b89a472015-11-19 16:39:21 -0700453}
454
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600455// This is the trampoline entrypoint for QueuePresentKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700456LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
457vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) {
Ian Elliott9b89a472015-11-19 16:39:21 -0700458 const VkLayerDispatchTable *disp;
459 disp = loader_get_dispatch(queue);
Mark Young76b3fe02016-09-08 12:28:38 -0600460 return disp->QueuePresentKHR(queue, pPresentInfo);
Ian Elliott9b89a472015-11-19 16:39:21 -0700461}
Ian Elliott7c352552015-11-19 13:14:05 -0700462
Ian Elliott7c352552015-11-19 13:14:05 -0700463#ifdef VK_USE_PLATFORM_WIN32_KHR
464
Ian Elliott7c352552015-11-19 13:14:05 -0700465
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600466// Functions for the VK_KHR_win32_surface extension:
467
468// This is the trampoline entrypoint for CreateWin32SurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600469LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR(
470 VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
471 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburn16edfa62015-11-25 17:55:49 -0700472 const VkLayerInstanceDispatchTable *disp;
473 disp = loader_get_instance_dispatch(instance);
474 VkResult res;
475
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700476 res = disp->CreateWin32SurfaceKHR(instance, pCreateInfo, pAllocator,
477 pSurface);
Jon Ashburn16edfa62015-11-25 17:55:49 -0700478 return res;
479}
480
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600481// This is the instance chain terminator function for CreateWin32SurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600482VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWin32SurfaceKHR(
483 VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
484 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600485 // First, check to ensure the appropriate extension was enabled:
Ian Elliott1693f592015-11-23 10:17:23 -0700486 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600487 if (!ptr_instance->wsi_win32_surface_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -0600488 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
489 "VK_KHR_win32_surface extension not enabled. "
490 "vkCreateWin32SurfaceKHR not executed!\n");
Jeremy Hayes0231e1c2016-06-14 11:50:02 -0600491 return VK_ERROR_EXTENSION_NOT_PRESENT;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600492 }
493
494 // Next, if so, proceed with the implementation of this function:
Ian Elliott7c352552015-11-19 13:14:05 -0700495 VkIcdSurfaceWin32 *pIcdSurface = NULL;
496
Mark Young74dd5d12016-06-30 13:02:42 -0600497 pIcdSurface =
498 loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceWin32),
499 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott7c352552015-11-19 13:14:05 -0700500 if (pIcdSurface == NULL) {
501 return VK_ERROR_OUT_OF_HOST_MEMORY;
502 }
503
504 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_WIN32;
Ian Elliott07eb3282015-12-10 17:28:50 -0700505 pIcdSurface->hinstance = pCreateInfo->hinstance;
506 pIcdSurface->hwnd = pCreateInfo->hwnd;
Ian Elliott7c352552015-11-19 13:14:05 -0700507
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700508 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliott7c352552015-11-19 13:14:05 -0700509
510 return VK_SUCCESS;
511}
Ian Elliotte851dd62015-11-24 15:39:10 -0700512
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600513// This is the trampoline entrypoint for
514// GetPhysicalDeviceWin32PresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700515LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
516vkGetPhysicalDeviceWin32PresentationSupportKHR(VkPhysicalDevice physicalDevice,
517 uint32_t queueFamilyIndex) {
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700518 VkPhysicalDevice unwrapped_phys_dev =
519 loader_unwrap_physical_device(physicalDevice);
Ian Elliotte851dd62015-11-24 15:39:10 -0700520 const VkLayerInstanceDispatchTable *disp;
521 disp = loader_get_instance_dispatch(physicalDevice);
522 VkBool32 res = disp->GetPhysicalDeviceWin32PresentationSupportKHR(
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700523 unwrapped_phys_dev, queueFamilyIndex);
Ian Elliotte851dd62015-11-24 15:39:10 -0700524 return res;
525}
526
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600527// This is the instance chain terminator function for
528// GetPhysicalDeviceWin32PresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700529VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700530terminator_GetPhysicalDeviceWin32PresentationSupportKHR(
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700531 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600532 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700533 struct loader_physical_device *phys_dev =
534 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600535 struct loader_instance *ptr_instance =
536 (struct loader_instance *)phys_dev->this_icd->this_instance;
537 if (!ptr_instance->wsi_win32_surface_enabled) {
Jon Ashburnc466da52016-04-15 09:25:03 -0600538 loader_log(
539 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
540 "VK_KHR_win32_surface extension not enabled. "
541 "vkGetPhysicalDeviceWin32PresentationSupportKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600542 return VK_SUCCESS;
543 }
544
545 // Next, if so, proceed with the implementation of this function:
Ian Elliotte851dd62015-11-24 15:39:10 -0700546 struct loader_icd *icd = phys_dev->this_icd;
547
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700548 assert(icd->GetPhysicalDeviceWin32PresentationSupportKHR &&
549 "loader: null GetPhysicalDeviceWin32PresentationSupportKHR ICD "
550 "pointer");
Ian Elliotte851dd62015-11-24 15:39:10 -0700551
552 return icd->GetPhysicalDeviceWin32PresentationSupportKHR(phys_dev->phys_dev,
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700553 queueFamilyIndex);
Ian Elliotte851dd62015-11-24 15:39:10 -0700554}
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700555#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliott7c352552015-11-19 13:14:05 -0700556
557#ifdef VK_USE_PLATFORM_MIR_KHR
558
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600559// Functions for the VK_KHR_mir_surface extension:
Ian Elliott7c352552015-11-19 13:14:05 -0700560
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600561// This is the trampoline entrypoint for CreateMirSurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600562LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateMirSurfaceKHR(
563 VkInstance instance, const VkMirSurfaceCreateInfoKHR *pCreateInfo,
564 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburn16edfa62015-11-25 17:55:49 -0700565 const VkLayerInstanceDispatchTable *disp;
566 disp = loader_get_instance_dispatch(instance);
567 VkResult res;
568
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700569 res =
570 disp->CreateMirSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
Jon Ashburn16edfa62015-11-25 17:55:49 -0700571 return res;
572}
573
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600574// This is the instance chain terminator function for CreateMirSurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600575VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateMirSurfaceKHR(
576 VkInstance instance, const VkMirSurfaceCreateInfoKHR *pCreateInfo,
577 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600578 // First, check to ensure the appropriate extension was enabled:
Ian Elliott1693f592015-11-23 10:17:23 -0700579 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600580 if (!ptr_instance->wsi_mir_surface_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -0600581 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
582 "VK_KHR_mir_surface extension not enabled. "
583 "vkCreateMirSurfaceKHR not executed!\n");
Jeremy Hayes0231e1c2016-06-14 11:50:02 -0600584 return VK_ERROR_EXTENSION_NOT_PRESENT;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600585 }
586
587 // Next, if so, proceed with the implementation of this function:
Ian Elliott7c352552015-11-19 13:14:05 -0700588 VkIcdSurfaceMir *pIcdSurface = NULL;
589
Mark Young74dd5d12016-06-30 13:02:42 -0600590 pIcdSurface =
591 loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceMir),
592 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott7c352552015-11-19 13:14:05 -0700593 if (pIcdSurface == NULL) {
594 return VK_ERROR_OUT_OF_HOST_MEMORY;
595 }
596
597 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_MIR;
Ian Elliott07eb3282015-12-10 17:28:50 -0700598 pIcdSurface->connection = pCreateInfo->connection;
599 pIcdSurface->mirSurface = pCreateInfo->mirSurface;
Ian Elliott7c352552015-11-19 13:14:05 -0700600
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700601 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliott7c352552015-11-19 13:14:05 -0700602
603 return VK_SUCCESS;
604}
Ian Elliotte851dd62015-11-24 15:39:10 -0700605
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600606// This is the trampoline entrypoint for
607// GetPhysicalDeviceMirPresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700608LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
609vkGetPhysicalDeviceMirPresentationSupportKHR(VkPhysicalDevice physicalDevice,
610 uint32_t queueFamilyIndex,
611 MirConnection *connection) {
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700612 VkPhysicalDevice unwrapped_phys_dev =
613 loader_unwrap_physical_device(physicalDevice);
Ian Elliotte851dd62015-11-24 15:39:10 -0700614 const VkLayerInstanceDispatchTable *disp;
615 disp = loader_get_instance_dispatch(physicalDevice);
616 VkBool32 res = disp->GetPhysicalDeviceMirPresentationSupportKHR(
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700617 unwrapped_phys_dev, queueFamilyIndex, connection);
Ian Elliotte851dd62015-11-24 15:39:10 -0700618 return res;
619}
620
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600621// This is the instance chain terminator function for
622// GetPhysicalDeviceMirPresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700623VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700624terminator_GetPhysicalDeviceMirPresentationSupportKHR(
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700625 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
626 MirConnection *connection) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600627 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700628 struct loader_physical_device *phys_dev =
629 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600630 struct loader_instance *ptr_instance =
631 (struct loader_instance *)phys_dev->this_icd->this_instance;
632 if (!ptr_instance->wsi_mir_surface_enabled) {
Jon Ashburnc466da52016-04-15 09:25:03 -0600633 loader_log(
634 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
635 "VK_KHR_mir_surface extension not enabled. "
636 "vkGetPhysicalDeviceMirPresentationSupportKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600637 return VK_SUCCESS;
638 }
639
640 // Next, if so, proceed with the implementation of this function:
Ian Elliotte851dd62015-11-24 15:39:10 -0700641 struct loader_icd *icd = phys_dev->this_icd;
642
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700643 assert(
644 icd->GetPhysicalDeviceMirPresentationSupportKHR &&
645 "loader: null GetPhysicalDeviceMirPresentationSupportKHR ICD pointer");
Ian Elliotte851dd62015-11-24 15:39:10 -0700646
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700647 return icd->GetPhysicalDeviceMirPresentationSupportKHR(
648 phys_dev->phys_dev, queueFamilyIndex, connection);
Ian Elliotte851dd62015-11-24 15:39:10 -0700649}
Ian Elliott7c352552015-11-19 13:14:05 -0700650#endif // VK_USE_PLATFORM_MIR_KHR
651
652#ifdef VK_USE_PLATFORM_WAYLAND_KHR
653
Ian Elliott7c352552015-11-19 13:14:05 -0700654
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600655// Functions for the VK_KHR_wayland_surface extension:
656
657// This is the trampoline entrypoint for CreateWaylandSurfaceKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700658LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
659vkCreateWaylandSurfaceKHR(VkInstance instance,
Jason Ekstrand3bfebc92016-02-12 17:25:03 -0800660 const VkWaylandSurfaceCreateInfoKHR *pCreateInfo,
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700661 const VkAllocationCallbacks *pAllocator,
662 VkSurfaceKHR *pSurface) {
Jon Ashburn16edfa62015-11-25 17:55:49 -0700663 const VkLayerInstanceDispatchTable *disp;
664 disp = loader_get_instance_dispatch(instance);
665 VkResult res;
666
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700667 res = disp->CreateWaylandSurfaceKHR(instance, pCreateInfo, pAllocator,
668 pSurface);
Jon Ashburn16edfa62015-11-25 17:55:49 -0700669 return res;
670}
671
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600672// This is the instance chain terminator function for CreateWaylandSurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600673VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWaylandSurfaceKHR(
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700674 VkInstance instance, const VkWaylandSurfaceCreateInfoKHR *pCreateInfo,
675 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600676 // First, check to ensure the appropriate extension was enabled:
Ian Elliott1693f592015-11-23 10:17:23 -0700677 struct loader_instance *ptr_instance = loader_get_instance(instance);
Jon Ashburn436d6a32016-03-24 17:26:59 -0600678 if (!ptr_instance->wsi_wayland_surface_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -0600679 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
680 "VK_KHR_wayland_surface extension not enabled. "
681 "vkCreateWaylandSurfaceKHR not executed!\n");
Jeremy Hayes0231e1c2016-06-14 11:50:02 -0600682 return VK_ERROR_EXTENSION_NOT_PRESENT;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600683 }
684
685 // Next, if so, proceed with the implementation of this function:
Ian Elliott7c352552015-11-19 13:14:05 -0700686 VkIcdSurfaceWayland *pIcdSurface = NULL;
687
Mark Young74dd5d12016-06-30 13:02:42 -0600688 pIcdSurface =
689 loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceWayland),
690 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott7c352552015-11-19 13:14:05 -0700691 if (pIcdSurface == NULL) {
692 return VK_ERROR_OUT_OF_HOST_MEMORY;
693 }
694
695 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_WAYLAND;
Ian Elliott07eb3282015-12-10 17:28:50 -0700696 pIcdSurface->display = pCreateInfo->display;
697 pIcdSurface->surface = pCreateInfo->surface;
Ian Elliott7c352552015-11-19 13:14:05 -0700698
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700699 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliott7c352552015-11-19 13:14:05 -0700700
701 return VK_SUCCESS;
702}
Ian Elliotte851dd62015-11-24 15:39:10 -0700703
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600704
705// This is the trampoline entrypoint for
706// GetPhysicalDeviceWaylandPresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700707LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
708vkGetPhysicalDeviceWaylandPresentationSupportKHR(
709 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
710 struct wl_display *display) {
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700711 VkPhysicalDevice unwrapped_phys_dev =
712 loader_unwrap_physical_device(physicalDevice);
Ian Elliotte851dd62015-11-24 15:39:10 -0700713 const VkLayerInstanceDispatchTable *disp;
714 disp = loader_get_instance_dispatch(physicalDevice);
715 VkBool32 res = disp->GetPhysicalDeviceWaylandPresentationSupportKHR(
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700716 unwrapped_phys_dev, queueFamilyIndex, display);
Ian Elliotte851dd62015-11-24 15:39:10 -0700717 return res;
718}
719
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600720// This is the instance chain terminator function for
721// GetPhysicalDeviceWaylandPresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700722VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700723terminator_GetPhysicalDeviceWaylandPresentationSupportKHR(
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700724 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
725 struct wl_display *display) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600726 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700727 struct loader_physical_device *phys_dev =
728 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600729 struct loader_instance *ptr_instance =
730 (struct loader_instance *)phys_dev->this_icd->this_instance;
Jon Ashburn436d6a32016-03-24 17:26:59 -0600731 if (!ptr_instance->wsi_wayland_surface_enabled) {
Jon Ashburnc466da52016-04-15 09:25:03 -0600732 loader_log(
733 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
734 "VK_KHR_wayland_surface extension not enabled. "
735 "vkGetPhysicalDeviceWaylandPresentationSupportKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600736 return VK_SUCCESS;
737 }
738
739 // Next, if so, proceed with the implementation of this function:
Ian Elliotte851dd62015-11-24 15:39:10 -0700740 struct loader_icd *icd = phys_dev->this_icd;
741
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700742 assert(icd->GetPhysicalDeviceWaylandPresentationSupportKHR &&
743 "loader: null GetPhysicalDeviceWaylandPresentationSupportKHR ICD "
744 "pointer");
Ian Elliotte851dd62015-11-24 15:39:10 -0700745
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700746 return icd->GetPhysicalDeviceWaylandPresentationSupportKHR(
747 phys_dev->phys_dev, queueFamilyIndex, display);
Ian Elliotte851dd62015-11-24 15:39:10 -0700748}
Ian Elliott7c352552015-11-19 13:14:05 -0700749#endif // VK_USE_PLATFORM_WAYLAND_KHR
750
751#ifdef VK_USE_PLATFORM_XCB_KHR
752
Ian Elliott7c352552015-11-19 13:14:05 -0700753
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600754// Functions for the VK_KHR_xcb_surface extension:
755
756// This is the trampoline entrypoint for CreateXcbSurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600757LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXcbSurfaceKHR(
758 VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo,
759 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburn16edfa62015-11-25 17:55:49 -0700760 const VkLayerInstanceDispatchTable *disp;
761 disp = loader_get_instance_dispatch(instance);
762 VkResult res;
763
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700764 res =
765 disp->CreateXcbSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
Jon Ashburn16edfa62015-11-25 17:55:49 -0700766 return res;
767}
768
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600769// This is the instance chain terminator function for CreateXcbSurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600770VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXcbSurfaceKHR(
771 VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo,
772 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600773 // First, check to ensure the appropriate extension was enabled:
Ian Elliott1693f592015-11-23 10:17:23 -0700774 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600775 if (!ptr_instance->wsi_xcb_surface_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -0600776 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
777 "VK_KHR_xcb_surface extension not enabled. "
778 "vkCreateXcbSurfaceKHR not executed!\n");
Jeremy Hayes0231e1c2016-06-14 11:50:02 -0600779 return VK_ERROR_EXTENSION_NOT_PRESENT;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600780 }
781
782 // Next, if so, proceed with the implementation of this function:
Ian Elliott7c352552015-11-19 13:14:05 -0700783 VkIcdSurfaceXcb *pIcdSurface = NULL;
784
Mark Young74dd5d12016-06-30 13:02:42 -0600785 pIcdSurface =
786 loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceXcb),
787 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott7c352552015-11-19 13:14:05 -0700788 if (pIcdSurface == NULL) {
789 return VK_ERROR_OUT_OF_HOST_MEMORY;
790 }
791
792 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_XCB;
Ian Elliott07eb3282015-12-10 17:28:50 -0700793 pIcdSurface->connection = pCreateInfo->connection;
794 pIcdSurface->window = pCreateInfo->window;
Ian Elliott7c352552015-11-19 13:14:05 -0700795
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700796 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliott7c352552015-11-19 13:14:05 -0700797
798 return VK_SUCCESS;
799}
Ian Elliotte851dd62015-11-24 15:39:10 -0700800
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600801// This is the trampoline entrypoint for
802// GetPhysicalDeviceXcbPresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700803LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
804vkGetPhysicalDeviceXcbPresentationSupportKHR(VkPhysicalDevice physicalDevice,
805 uint32_t queueFamilyIndex,
806 xcb_connection_t *connection,
807 xcb_visualid_t visual_id) {
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700808 VkPhysicalDevice unwrapped_phys_dev =
809 loader_unwrap_physical_device(physicalDevice);
Ian Elliotte851dd62015-11-24 15:39:10 -0700810 const VkLayerInstanceDispatchTable *disp;
811 disp = loader_get_instance_dispatch(physicalDevice);
812 VkBool32 res = disp->GetPhysicalDeviceXcbPresentationSupportKHR(
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700813 unwrapped_phys_dev, queueFamilyIndex, connection, visual_id);
Ian Elliotte851dd62015-11-24 15:39:10 -0700814 return res;
815}
816
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600817// This is the instance chain terminator function for
818// GetPhysicalDeviceXcbPresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700819VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700820terminator_GetPhysicalDeviceXcbPresentationSupportKHR(
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700821 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
822 xcb_connection_t *connection, xcb_visualid_t visual_id) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600823 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700824 struct loader_physical_device *phys_dev =
825 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600826 struct loader_instance *ptr_instance =
827 (struct loader_instance *)phys_dev->this_icd->this_instance;
828 if (!ptr_instance->wsi_xcb_surface_enabled) {
Jon Ashburnc466da52016-04-15 09:25:03 -0600829 loader_log(
830 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
831 "VK_KHR_xcb_surface extension not enabled. "
832 "vkGetPhysicalDeviceXcbPresentationSupportKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600833 return VK_SUCCESS;
834 }
835
836 // Next, if so, proceed with the implementation of this function:
Ian Elliotte851dd62015-11-24 15:39:10 -0700837 struct loader_icd *icd = phys_dev->this_icd;
838
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700839 assert(
840 icd->GetPhysicalDeviceXcbPresentationSupportKHR &&
841 "loader: null GetPhysicalDeviceXcbPresentationSupportKHR ICD pointer");
Ian Elliotte851dd62015-11-24 15:39:10 -0700842
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700843 return icd->GetPhysicalDeviceXcbPresentationSupportKHR(
844 phys_dev->phys_dev, queueFamilyIndex, connection, visual_id);
Ian Elliotte851dd62015-11-24 15:39:10 -0700845}
Ian Elliott7c352552015-11-19 13:14:05 -0700846#endif // VK_USE_PLATFORM_XCB_KHR
847
848#ifdef VK_USE_PLATFORM_XLIB_KHR
849
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600850// Functions for the VK_KHR_xlib_surface extension:
Ian Elliott7c352552015-11-19 13:14:05 -0700851
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600852// This is the trampoline entrypoint for CreateXlibSurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600853LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR(
854 VkInstance instance, const VkXlibSurfaceCreateInfoKHR *pCreateInfo,
855 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburn16edfa62015-11-25 17:55:49 -0700856 const VkLayerInstanceDispatchTable *disp;
857 disp = loader_get_instance_dispatch(instance);
858 VkResult res;
859
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700860 res =
861 disp->CreateXlibSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
Jon Ashburn16edfa62015-11-25 17:55:49 -0700862 return res;
863}
864
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600865// This is the instance chain terminator function for CreateXlibSurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600866VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXlibSurfaceKHR(
867 VkInstance instance, const VkXlibSurfaceCreateInfoKHR *pCreateInfo,
868 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600869 // First, check to ensure the appropriate extension was enabled:
Ian Elliott1693f592015-11-23 10:17:23 -0700870 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600871 if (!ptr_instance->wsi_xlib_surface_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -0600872 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
873 "VK_KHR_xlib_surface extension not enabled. "
874 "vkCreateXlibSurfaceKHR not executed!\n");
Jeremy Hayes0231e1c2016-06-14 11:50:02 -0600875 return VK_ERROR_EXTENSION_NOT_PRESENT;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600876 }
877
878 // Next, if so, proceed with the implementation of this function:
Ian Elliott7c352552015-11-19 13:14:05 -0700879 VkIcdSurfaceXlib *pIcdSurface = NULL;
880
Mark Young74dd5d12016-06-30 13:02:42 -0600881 pIcdSurface =
882 loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceXlib),
883 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott7c352552015-11-19 13:14:05 -0700884 if (pIcdSurface == NULL) {
885 return VK_ERROR_OUT_OF_HOST_MEMORY;
886 }
887
888 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_XLIB;
Ian Elliott07eb3282015-12-10 17:28:50 -0700889 pIcdSurface->dpy = pCreateInfo->dpy;
890 pIcdSurface->window = pCreateInfo->window;
Ian Elliott7c352552015-11-19 13:14:05 -0700891
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700892 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliott7c352552015-11-19 13:14:05 -0700893
894 return VK_SUCCESS;
895}
Ian Elliotte851dd62015-11-24 15:39:10 -0700896
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600897// This is the trampoline entrypoint for GetPhysicalDeviceXlibPresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700898LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
899vkGetPhysicalDeviceXlibPresentationSupportKHR(VkPhysicalDevice physicalDevice,
900 uint32_t queueFamilyIndex,
901 Display *dpy, VisualID visualID) {
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700902 VkPhysicalDevice unwrapped_phys_dev =
903 loader_unwrap_physical_device(physicalDevice);
Ian Elliotte851dd62015-11-24 15:39:10 -0700904 const VkLayerInstanceDispatchTable *disp;
905 disp = loader_get_instance_dispatch(physicalDevice);
906 VkBool32 res = disp->GetPhysicalDeviceXlibPresentationSupportKHR(
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700907 unwrapped_phys_dev, queueFamilyIndex, dpy, visualID);
Ian Elliotte851dd62015-11-24 15:39:10 -0700908 return res;
909}
910
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600911// This is the instance chain terminator function for
912// GetPhysicalDeviceXlibPresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700913VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700914terminator_GetPhysicalDeviceXlibPresentationSupportKHR(
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700915 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, Display *dpy,
916 VisualID visualID) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600917 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700918 struct loader_physical_device *phys_dev =
919 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600920 struct loader_instance *ptr_instance =
921 (struct loader_instance *)phys_dev->this_icd->this_instance;
922 if (!ptr_instance->wsi_xlib_surface_enabled) {
Jon Ashburnc466da52016-04-15 09:25:03 -0600923 loader_log(
924 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
925 "VK_KHR_xlib_surface extension not enabled. "
926 "vkGetPhysicalDeviceXlibPresentationSupportKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600927 return VK_SUCCESS;
928 }
929
930 // Next, if so, proceed with the implementation of this function:
Ian Elliotte851dd62015-11-24 15:39:10 -0700931 struct loader_icd *icd = phys_dev->this_icd;
932
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700933 assert(
934 icd->GetPhysicalDeviceXlibPresentationSupportKHR &&
935 "loader: null GetPhysicalDeviceXlibPresentationSupportKHR ICD pointer");
Ian Elliotte851dd62015-11-24 15:39:10 -0700936
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700937 return icd->GetPhysicalDeviceXlibPresentationSupportKHR(
938 phys_dev->phys_dev, queueFamilyIndex, dpy, visualID);
Ian Elliotte851dd62015-11-24 15:39:10 -0700939}
Ian Elliott7c352552015-11-19 13:14:05 -0700940#endif // VK_USE_PLATFORM_XLIB_KHR
941
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700942#ifdef VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott7c352552015-11-19 13:14:05 -0700943
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700944
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600945// Functions for the VK_KHR_android_surface extension:
946
947// This is the trampoline entrypoint for CreateAndroidSurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600948LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateAndroidSurfaceKHR(
949 VkInstance instance, ANativeWindow *window,
950 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700951 const VkLayerInstanceDispatchTable *disp;
952 disp = loader_get_instance_dispatch(instance);
953 VkResult res;
954
955 res = disp->CreateAndroidSurfaceKHR(instance, window, pAllocator, pSurface);
956 return res;
957}
958
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600959// This is the instance chain terminator function for CreateAndroidSurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600960VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateAndroidSurfaceKHR(
961 VkInstance instance, Window window, const VkAllocationCallbacks *pAllocator,
962 VkSurfaceKHR *pSurface) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600963 // First, check to ensure the appropriate extension was enabled:
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700964 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600965 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -0600966 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
967 "VK_KHR_display extension not enabled. "
968 "vkCreateAndroidSurfaceKHR not executed!\n");
Jeremy Hayes0231e1c2016-06-14 11:50:02 -0600969 return VK_ERROR_EXTENSION_NOT_PRESENT;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600970 }
971
972 // Next, if so, proceed with the implementation of this function:
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700973 VkIcdSurfaceAndroid *pIcdSurface = NULL;
974
Mark Young74dd5d12016-06-30 13:02:42 -0600975 pIcdSurface =
976 loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceAndroid),
977 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700978 if (pIcdSurface == NULL) {
979 return VK_ERROR_OUT_OF_HOST_MEMORY;
980 }
981
982 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_ANDROID;
983 pIcdSurface->dpy = dpy;
984 pIcdSurface->window = window;
985
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700986 *pSurface = (VkSurfaceKHR)pIcdSurface;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700987
988 return VK_SUCCESS;
989}
990
991#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott7c352552015-11-19 13:14:05 -0700992
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600993
994// Functions for the VK_KHR_display instance extension:
Jon Ashburncc370d02016-03-08 09:30:30 -0700995LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburnc466da52016-04-15 09:25:03 -0600996vkGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice,
997 uint32_t *pPropertyCount,
998 VkDisplayPropertiesKHR *pProperties) {
Jon Ashburncc370d02016-03-08 09:30:30 -0700999 VkPhysicalDevice unwrapped_phys_dev =
1000 loader_unwrap_physical_device(physicalDevice);
1001 const VkLayerInstanceDispatchTable *disp;
1002 disp = loader_get_instance_dispatch(physicalDevice);
1003 VkResult res = disp->GetPhysicalDeviceDisplayPropertiesKHR(
1004 unwrapped_phys_dev, pPropertyCount, pProperties);
1005 return res;
1006}
1007
Jon Ashburnc466da52016-04-15 09:25:03 -06001008VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceDisplayPropertiesKHR(
1009 VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
1010 VkDisplayPropertiesKHR *pProperties) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001011 // First, check to ensure the appropriate extension was enabled:
Jon Ashburncc370d02016-03-08 09:30:30 -07001012 struct loader_physical_device *phys_dev =
1013 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001014 struct loader_instance *ptr_instance =
1015 (struct loader_instance *)phys_dev->this_icd->this_instance;
1016 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -06001017 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1018 "VK_KHR_display extension not enabled. "
1019 "vkGetPhysicalDeviceDisplayPropertiesKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001020 return VK_SUCCESS;
1021 }
1022
1023 // Next, if so, proceed with the implementation of this function:
Jon Ashburncc370d02016-03-08 09:30:30 -07001024 struct loader_icd *icd = phys_dev->this_icd;
1025
Jon Ashburnc466da52016-04-15 09:25:03 -06001026 assert(icd->GetPhysicalDeviceDisplayPropertiesKHR &&
1027 "loader: null GetPhysicalDeviceDisplayPropertiesKHR ICD pointer");
Jon Ashburncc370d02016-03-08 09:30:30 -07001028
1029 return icd->GetPhysicalDeviceDisplayPropertiesKHR(
1030 phys_dev->phys_dev, pPropertyCount, pProperties);
1031}
1032
1033LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1034vkGetPhysicalDeviceDisplayPlanePropertiesKHR(
Jon Ashburnc466da52016-04-15 09:25:03 -06001035 VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
1036 VkDisplayPlanePropertiesKHR *pProperties) {
Jon Ashburncc370d02016-03-08 09:30:30 -07001037 VkPhysicalDevice unwrapped_phys_dev =
1038 loader_unwrap_physical_device(physicalDevice);
1039 const VkLayerInstanceDispatchTable *disp;
1040 disp = loader_get_instance_dispatch(physicalDevice);
1041 VkResult res = disp->GetPhysicalDeviceDisplayPlanePropertiesKHR(
1042 unwrapped_phys_dev, pPropertyCount, pProperties);
1043 return res;
1044}
1045
1046VKAPI_ATTR VkResult VKAPI_CALL
1047terminator_GetPhysicalDeviceDisplayPlanePropertiesKHR(
Jon Ashburnc466da52016-04-15 09:25:03 -06001048 VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
1049 VkDisplayPlanePropertiesKHR *pProperties) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001050 // First, check to ensure the appropriate extension was enabled:
Jon Ashburncc370d02016-03-08 09:30:30 -07001051 struct loader_physical_device *phys_dev =
1052 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001053 struct loader_instance *ptr_instance =
1054 (struct loader_instance *)phys_dev->this_icd->this_instance;
1055 if (!ptr_instance->wsi_display_enabled) {
Jon Ashburnc466da52016-04-15 09:25:03 -06001056 loader_log(
1057 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1058 "VK_KHR_display extension not enabled. "
1059 "vkGetPhysicalDeviceDisplayPlanePropertiesKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001060 return VK_SUCCESS;
1061 }
1062
1063 // Next, if so, proceed with the implementation of this function:
Jon Ashburncc370d02016-03-08 09:30:30 -07001064 struct loader_icd *icd = phys_dev->this_icd;
1065
1066 assert(
1067 icd->GetPhysicalDeviceDisplayPlanePropertiesKHR &&
1068 "loader: null GetPhysicalDeviceDisplayPlanePropertiesKHR ICD pointer");
1069
1070 return icd->GetPhysicalDeviceDisplayPlanePropertiesKHR(
1071 phys_dev->phys_dev, pPropertyCount, pProperties);
1072}
1073
1074LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburnc466da52016-04-15 09:25:03 -06001075vkGetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice,
1076 uint32_t planeIndex,
1077 uint32_t *pDisplayCount,
1078 VkDisplayKHR *pDisplays) {
Jon Ashburncc370d02016-03-08 09:30:30 -07001079 VkPhysicalDevice unwrapped_phys_dev =
1080 loader_unwrap_physical_device(physicalDevice);
1081 const VkLayerInstanceDispatchTable *disp;
1082 disp = loader_get_instance_dispatch(physicalDevice);
1083 VkResult res = disp->GetDisplayPlaneSupportedDisplaysKHR(
1084 unwrapped_phys_dev, planeIndex, pDisplayCount, pDisplays);
1085 return res;
1086}
1087
1088VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburnc466da52016-04-15 09:25:03 -06001089terminator_GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice,
1090 uint32_t planeIndex,
1091 uint32_t *pDisplayCount,
1092 VkDisplayKHR *pDisplays) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001093 // First, check to ensure the appropriate extension was enabled:
Jon Ashburncc370d02016-03-08 09:30:30 -07001094 struct loader_physical_device *phys_dev =
1095 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001096 struct loader_instance *ptr_instance =
1097 (struct loader_instance *)phys_dev->this_icd->this_instance;
1098 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -06001099 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1100 "VK_KHR_display extension not enabled. "
1101 "vkGetDisplayPlaneSupportedDisplaysKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001102 return VK_SUCCESS;
1103 }
1104
1105 // Next, if so, proceed with the implementation of this function:
Jon Ashburncc370d02016-03-08 09:30:30 -07001106 struct loader_icd *icd = phys_dev->this_icd;
1107
Jon Ashburnc466da52016-04-15 09:25:03 -06001108 assert(icd->GetDisplayPlaneSupportedDisplaysKHR &&
1109 "loader: null GetDisplayPlaneSupportedDisplaysKHR ICD pointer");
Jon Ashburncc370d02016-03-08 09:30:30 -07001110
1111 return icd->GetDisplayPlaneSupportedDisplaysKHR(
1112 phys_dev->phys_dev, planeIndex, pDisplayCount, pDisplays);
1113}
1114
1115LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburnc466da52016-04-15 09:25:03 -06001116vkGetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice,
1117 VkDisplayKHR display, uint32_t *pPropertyCount,
1118 VkDisplayModePropertiesKHR *pProperties) {
Jon Ashburncc370d02016-03-08 09:30:30 -07001119 VkPhysicalDevice unwrapped_phys_dev =
1120 loader_unwrap_physical_device(physicalDevice);
1121 const VkLayerInstanceDispatchTable *disp;
1122 disp = loader_get_instance_dispatch(physicalDevice);
1123 VkResult res = disp->GetDisplayModePropertiesKHR(
1124 unwrapped_phys_dev, display, pPropertyCount, pProperties);
1125 return res;
1126}
1127
Jon Ashburnc466da52016-04-15 09:25:03 -06001128VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayModePropertiesKHR(
1129 VkPhysicalDevice physicalDevice, VkDisplayKHR display,
1130 uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001131 // First, check to ensure the appropriate extension was enabled:
Jon Ashburncc370d02016-03-08 09:30:30 -07001132 struct loader_physical_device *phys_dev =
1133 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001134 struct loader_instance *ptr_instance =
1135 (struct loader_instance *)phys_dev->this_icd->this_instance;
1136 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -06001137 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1138 "VK_KHR_display extension not enabled. "
1139 "vkGetDisplayModePropertiesKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001140 return VK_SUCCESS;
1141 }
1142
1143 // Next, if so, proceed with the implementation of this function:
Jon Ashburncc370d02016-03-08 09:30:30 -07001144 struct loader_icd *icd = phys_dev->this_icd;
1145
Jon Ashburnc466da52016-04-15 09:25:03 -06001146 assert(icd->GetDisplayModePropertiesKHR &&
1147 "loader: null GetDisplayModePropertiesKHR ICD pointer");
Jon Ashburncc370d02016-03-08 09:30:30 -07001148
Jon Ashburnc466da52016-04-15 09:25:03 -06001149 return icd->GetDisplayModePropertiesKHR(phys_dev->phys_dev, display,
1150 pPropertyCount, pProperties);
Jon Ashburncc370d02016-03-08 09:30:30 -07001151}
1152
Mark Young74dd5d12016-06-30 13:02:42 -06001153LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayModeKHR(
1154 VkPhysicalDevice physicalDevice, VkDisplayKHR display,
1155 const VkDisplayModeCreateInfoKHR *pCreateInfo,
1156 const VkAllocationCallbacks *pAllocator, VkDisplayModeKHR *pMode) {
Jon Ashburncc370d02016-03-08 09:30:30 -07001157 VkPhysicalDevice unwrapped_phys_dev =
1158 loader_unwrap_physical_device(physicalDevice);
1159 const VkLayerInstanceDispatchTable *disp;
1160 disp = loader_get_instance_dispatch(physicalDevice);
Jon Ashburnc466da52016-04-15 09:25:03 -06001161 VkResult res = disp->CreateDisplayModeKHR(unwrapped_phys_dev, display,
1162 pCreateInfo, pAllocator, pMode);
Jon Ashburncc370d02016-03-08 09:30:30 -07001163 return res;
1164}
1165
Mark Young74dd5d12016-06-30 13:02:42 -06001166VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayModeKHR(
1167 VkPhysicalDevice physicalDevice, VkDisplayKHR display,
1168 const VkDisplayModeCreateInfoKHR *pCreateInfo,
1169 const VkAllocationCallbacks *pAllocator, VkDisplayModeKHR *pMode) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001170 // First, check to ensure the appropriate extension was enabled:
Jon Ashburncc370d02016-03-08 09:30:30 -07001171 struct loader_physical_device *phys_dev =
1172 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001173 struct loader_instance *ptr_instance =
1174 (struct loader_instance *)phys_dev->this_icd->this_instance;
1175 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -06001176 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1177 "VK_KHR_display extension not enabled. "
1178 "vkCreateDisplayModeKHR not executed!\n");
Jeremy Hayes0231e1c2016-06-14 11:50:02 -06001179 return VK_ERROR_EXTENSION_NOT_PRESENT;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001180 }
1181
1182 // Next, if so, proceed with the implementation of this function:
Jon Ashburncc370d02016-03-08 09:30:30 -07001183 struct loader_icd *icd = phys_dev->this_icd;
1184
Jon Ashburnc466da52016-04-15 09:25:03 -06001185 assert(icd->CreateDisplayModeKHR &&
1186 "loader: null CreateDisplayModeKHR ICD pointer");
Jon Ashburncc370d02016-03-08 09:30:30 -07001187
Jon Ashburnc466da52016-04-15 09:25:03 -06001188 return icd->CreateDisplayModeKHR(phys_dev->phys_dev, display, pCreateInfo,
1189 pAllocator, pMode);
Jon Ashburncc370d02016-03-08 09:30:30 -07001190}
1191
1192LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburnc466da52016-04-15 09:25:03 -06001193vkGetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physicalDevice,
1194 VkDisplayModeKHR mode, uint32_t planeIndex,
1195 VkDisplayPlaneCapabilitiesKHR *pCapabilities) {
Jon Ashburncc370d02016-03-08 09:30:30 -07001196 VkPhysicalDevice unwrapped_phys_dev =
1197 loader_unwrap_physical_device(physicalDevice);
1198 const VkLayerInstanceDispatchTable *disp;
1199 disp = loader_get_instance_dispatch(physicalDevice);
1200 VkResult res = disp->GetDisplayPlaneCapabilitiesKHR(
1201 unwrapped_phys_dev, mode, planeIndex, pCapabilities);
1202 return res;
1203}
1204
Jon Ashburnc466da52016-04-15 09:25:03 -06001205VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayPlaneCapabilitiesKHR(
1206 VkPhysicalDevice physicalDevice, VkDisplayModeKHR mode, uint32_t planeIndex,
1207 VkDisplayPlaneCapabilitiesKHR *pCapabilities) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001208 // First, check to ensure the appropriate extension was enabled:
Jon Ashburncc370d02016-03-08 09:30:30 -07001209 struct loader_physical_device *phys_dev =
1210 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001211 struct loader_instance *ptr_instance =
1212 (struct loader_instance *)phys_dev->this_icd->this_instance;
1213 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -06001214 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1215 "VK_KHR_display extension not enabled. "
1216 "vkGetDisplayPlaneCapabilitiesKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001217 return VK_SUCCESS;
1218 }
1219
1220 // Next, if so, proceed with the implementation of this function:
Jon Ashburncc370d02016-03-08 09:30:30 -07001221 struct loader_icd *icd = phys_dev->this_icd;
1222
Jon Ashburnc466da52016-04-15 09:25:03 -06001223 assert(icd->GetDisplayPlaneCapabilitiesKHR &&
1224 "loader: null GetDisplayPlaneCapabilitiesKHR ICD pointer");
Jon Ashburncc370d02016-03-08 09:30:30 -07001225
Jon Ashburnc466da52016-04-15 09:25:03 -06001226 return icd->GetDisplayPlaneCapabilitiesKHR(phys_dev->phys_dev, mode,
1227 planeIndex, pCapabilities);
Jon Ashburncc370d02016-03-08 09:30:30 -07001228}
1229
Mark Young74dd5d12016-06-30 13:02:42 -06001230LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayPlaneSurfaceKHR(
1231 VkInstance instance, const VkDisplaySurfaceCreateInfoKHR *pCreateInfo,
1232 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburncc370d02016-03-08 09:30:30 -07001233 const VkLayerInstanceDispatchTable *disp;
1234 disp = loader_get_instance_dispatch(instance);
1235 VkResult res;
1236
1237 res = disp->CreateDisplayPlaneSurfaceKHR(instance, pCreateInfo, pAllocator,
1238 pSurface);
1239 return res;
1240}
1241
Jon Ashburnc466da52016-04-15 09:25:03 -06001242VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayPlaneSurfaceKHR(
1243 VkInstance instance, const VkDisplaySurfaceCreateInfoKHR *pCreateInfo,
1244 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburncc370d02016-03-08 09:30:30 -07001245 struct loader_instance *inst = loader_get_instance(instance);
1246 VkIcdSurfaceDisplay *pIcdSurface = NULL;
1247
Petros Bantolasf3095862016-04-14 12:50:42 +01001248 if (!inst->wsi_surface_enabled) {
1249 loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1250 "VK_KHR_surface extension not enabled. "
1251 "vkCreateDisplayPlaneSurfaceKHR not executed!\n");
Jeremy Hayes0231e1c2016-06-14 11:50:02 -06001252 return VK_ERROR_EXTENSION_NOT_PRESENT;
Petros Bantolasf3095862016-04-14 12:50:42 +01001253 }
1254
Mark Young74dd5d12016-06-30 13:02:42 -06001255 pIcdSurface = loader_instance_heap_alloc(
1256 inst, sizeof(VkIcdSurfaceDisplay), VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Jon Ashburncc370d02016-03-08 09:30:30 -07001257 if (pIcdSurface == NULL) {
1258 return VK_ERROR_OUT_OF_HOST_MEMORY;
1259 }
1260
1261 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_DISPLAY;
1262 pIcdSurface->displayMode = pCreateInfo->displayMode;
1263 pIcdSurface->planeIndex = pCreateInfo->planeIndex;
1264 pIcdSurface->planeStackIndex = pCreateInfo->planeStackIndex;
1265 pIcdSurface->transform = pCreateInfo->transform;
1266 pIcdSurface->globalAlpha = pCreateInfo->globalAlpha;
1267 pIcdSurface->alphaMode = pCreateInfo->alphaMode;
1268 pIcdSurface->imageExtent = pCreateInfo->imageExtent;
1269
1270 *pSurface = (VkSurfaceKHR)pIcdSurface;
1271
1272 return VK_SUCCESS;
1273}
1274
Mark Youngf2eabea2016-07-01 15:18:27 -06001275// This is the trampoline entrypoint
1276// for CreateSharedSwapchainsKHR
1277LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSharedSwapchainsKHR(
1278 VkDevice device, uint32_t swapchainCount,
1279 const VkSwapchainCreateInfoKHR *pCreateInfos,
1280 const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchains) {
Mark Young76b3fe02016-09-08 12:28:38 -06001281 struct loader_dev_dispatch_table *disp = loader_get_dev_dispatch(device);
1282 if (0 == disp->enabled_known_extensions.khr_display_swapchain ||
1283 NULL == disp->core_dispatch.CreateSharedSwapchainsKHR) {
1284 return VK_ERROR_EXTENSION_NOT_PRESENT;
1285 } else {
1286 return disp->core_dispatch.CreateSharedSwapchainsKHR(
1287 device, swapchainCount, pCreateInfos, pAllocator, pSwapchains);
1288 }
Mark Youngf2eabea2016-07-01 15:18:27 -06001289}
1290
Ian Elliott54cea232015-10-30 15:28:23 -06001291bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance,
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001292 const char *name, void **addr) {
Ian Elliott54cea232015-10-30 15:28:23 -06001293 *addr = NULL;
1294
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001295 // Functions for the VK_KHR_surface extension:
Ian Elliott7c352552015-11-19 13:14:05 -07001296 if (!strcmp("vkDestroySurfaceKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001297 *addr = ptr_instance->wsi_surface_enabled ? (void *)vkDestroySurfaceKHR
1298 : NULL;
Ian Elliott7c352552015-11-19 13:14:05 -07001299 return true;
1300 }
Ian Elliott54cea232015-10-30 15:28:23 -06001301 if (!strcmp("vkGetPhysicalDeviceSurfaceSupportKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001302 *addr = ptr_instance->wsi_surface_enabled
1303 ? (void *)vkGetPhysicalDeviceSurfaceSupportKHR
1304 : NULL;
Ian Elliott54cea232015-10-30 15:28:23 -06001305 return true;
1306 }
Ian Elliottea666b22015-11-19 16:05:09 -07001307 if (!strcmp("vkGetPhysicalDeviceSurfaceCapabilitiesKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001308 *addr = ptr_instance->wsi_surface_enabled
1309 ? (void *)vkGetPhysicalDeviceSurfaceCapabilitiesKHR
1310 : NULL;
Ian Elliottea666b22015-11-19 16:05:09 -07001311 return true;
1312 }
1313 if (!strcmp("vkGetPhysicalDeviceSurfaceFormatsKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001314 *addr = ptr_instance->wsi_surface_enabled
1315 ? (void *)vkGetPhysicalDeviceSurfaceFormatsKHR
1316 : NULL;
Ian Elliottea666b22015-11-19 16:05:09 -07001317 return true;
1318 }
1319 if (!strcmp("vkGetPhysicalDeviceSurfacePresentModesKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001320 *addr = ptr_instance->wsi_surface_enabled
1321 ? (void *)vkGetPhysicalDeviceSurfacePresentModesKHR
1322 : NULL;
Ian Elliottea666b22015-11-19 16:05:09 -07001323 return true;
1324 }
Ian Elliott9b89a472015-11-19 16:39:21 -07001325
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001326 // Functions for the VK_KHR_swapchain extension:
1327
1328 // Note: This is a device extension, and its functions are statically
1329 // exported from the loader. Per Khronos decisions, the loader's GIPA
1330 // function will return the trampoline function for such device-extension
1331 // functions, regardless of whether the extension has been enabled.
Ian Elliott9b89a472015-11-19 16:39:21 -07001332 if (!strcmp("vkCreateSwapchainKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001333 *addr = (void *)vkCreateSwapchainKHR;
Ian Elliott9b89a472015-11-19 16:39:21 -07001334 return true;
1335 }
1336 if (!strcmp("vkDestroySwapchainKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001337 *addr = (void *)vkDestroySwapchainKHR;
Ian Elliott9b89a472015-11-19 16:39:21 -07001338 return true;
1339 }
1340 if (!strcmp("vkGetSwapchainImagesKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001341 *addr = (void *)vkGetSwapchainImagesKHR;
Ian Elliott9b89a472015-11-19 16:39:21 -07001342 return true;
1343 }
1344 if (!strcmp("vkAcquireNextImageKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001345 *addr = (void *)vkAcquireNextImageKHR;
Ian Elliott9b89a472015-11-19 16:39:21 -07001346 return true;
1347 }
1348 if (!strcmp("vkQueuePresentKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001349 *addr = (void *)vkQueuePresentKHR;
Ian Elliott9b89a472015-11-19 16:39:21 -07001350 return true;
1351 }
1352
Ian Elliott7c352552015-11-19 13:14:05 -07001353#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001354
1355 // Functions for the VK_KHR_win32_surface extension:
Ian Elliott7c352552015-11-19 13:14:05 -07001356 if (!strcmp("vkCreateWin32SurfaceKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001357 *addr = ptr_instance->wsi_win32_surface_enabled
1358 ? (void *)vkCreateWin32SurfaceKHR
1359 : NULL;
Ian Elliott7c352552015-11-19 13:14:05 -07001360 return true;
1361 }
Ian Elliotte851dd62015-11-24 15:39:10 -07001362 if (!strcmp("vkGetPhysicalDeviceWin32PresentationSupportKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001363 *addr = ptr_instance->wsi_win32_surface_enabled
1364 ? (void *)vkGetPhysicalDeviceWin32PresentationSupportKHR
1365 : NULL;
Ian Elliotte851dd62015-11-24 15:39:10 -07001366 return true;
1367 }
Ian Elliott7c352552015-11-19 13:14:05 -07001368#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliott7c352552015-11-19 13:14:05 -07001369#ifdef VK_USE_PLATFORM_MIR_KHR
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001370
1371 // Functions for the VK_KHR_mir_surface extension:
Ian Elliott7c352552015-11-19 13:14:05 -07001372 if (!strcmp("vkCreateMirSurfaceKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001373 *addr = ptr_instance->wsi_mir_surface_enabled
1374 ? (void *)vkCreateMirSurfaceKHR
1375 : NULL;
Ian Elliott7c352552015-11-19 13:14:05 -07001376 return true;
1377 }
Ian Elliotte851dd62015-11-24 15:39:10 -07001378 if (!strcmp("vkGetPhysicalDeviceMirPresentationSupportKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001379 *addr = ptr_instance->wsi_mir_surface_enabled
1380 ? (void *)vkGetPhysicalDeviceMirPresentationSupportKHR
1381 : NULL;
Ian Elliotte851dd62015-11-24 15:39:10 -07001382 return true;
Jason Ekstrand3bfebc92016-02-12 17:25:03 -08001383 }
Ian Elliott7c352552015-11-19 13:14:05 -07001384#endif // VK_USE_PLATFORM_MIR_KHR
1385#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001386
1387 // Functions for the VK_KHR_wayland_surface extension:
Jon Ashburnc4e9ae62016-02-26 13:14:27 -07001388 if (!strcmp("vkCreateWaylandSurfaceKHR", name)) {
1389 *addr = ptr_instance->wsi_wayland_surface_enabled
1390 ? (void *)vkCreateWaylandSurfaceKHR
1391 : NULL;
1392 return true;
1393 }
1394 if (!strcmp("vkGetPhysicalDeviceWaylandPresentationSupportKHR", name)) {
1395 *addr = ptr_instance->wsi_wayland_surface_enabled
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001396 ? (void *)vkGetPhysicalDeviceWaylandPresentationSupportKHR
1397 : NULL;
Jon Ashburnc4e9ae62016-02-26 13:14:27 -07001398 return true;
1399 }
Ian Elliott7c352552015-11-19 13:14:05 -07001400#endif // VK_USE_PLATFORM_WAYLAND_KHR
1401#ifdef VK_USE_PLATFORM_XCB_KHR
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001402
1403 // Functions for the VK_KHR_xcb_surface extension:
Jon Ashburnc4e9ae62016-02-26 13:14:27 -07001404 if (!strcmp("vkCreateXcbSurfaceKHR", name)) {
1405 *addr = ptr_instance->wsi_xcb_surface_enabled
1406 ? (void *)vkCreateXcbSurfaceKHR
1407 : NULL;
1408 return true;
1409 }
1410 if (!strcmp("vkGetPhysicalDeviceXcbPresentationSupportKHR", name)) {
1411 *addr = ptr_instance->wsi_xcb_surface_enabled
1412 ? (void *)vkGetPhysicalDeviceXcbPresentationSupportKHR
1413 : NULL;
1414 return true;
1415 }
Ian Elliott7c352552015-11-19 13:14:05 -07001416#endif // VK_USE_PLATFORM_XCB_KHR
1417#ifdef VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001418
1419 // Functions for the VK_KHR_xlib_surface extension:
Jon Ashburnc4e9ae62016-02-26 13:14:27 -07001420 if (!strcmp("vkCreateXlibSurfaceKHR", name)) {
1421 *addr = ptr_instance->wsi_xlib_surface_enabled
1422 ? (void *)vkCreateXlibSurfaceKHR
1423 : NULL;
1424 return true;
1425 }
1426 if (!strcmp("vkGetPhysicalDeviceXlibPresentationSupportKHR", name)) {
1427 *addr = ptr_instance->wsi_xlib_surface_enabled
1428 ? (void *)vkGetPhysicalDeviceXlibPresentationSupportKHR
1429 : NULL;
1430 return true;
1431 }
Ian Elliott7c352552015-11-19 13:14:05 -07001432#endif // VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -07001433#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001434
1435 // Functions for the VK_KHR_android_surface extension:
Jon Ashburnc4e9ae62016-02-26 13:14:27 -07001436 if (!strcmp("vkCreateAndroidSurfaceKHR", name)) {
1437 *addr = ptr_instance->wsi_xlib_surface_enabled
1438 ? (void *)vkCreateAndroidSurfaceKHR
1439 : NULL;
1440 return true;
1441 }
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -07001442#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott7c352552015-11-19 13:14:05 -07001443
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001444 // Functions for VK_KHR_display extension:
Jon Ashburncc370d02016-03-08 09:30:30 -07001445 if (!strcmp("vkGetPhysicalDeviceDisplayPropertiesKHR", name)) {
1446 *addr = ptr_instance->wsi_display_enabled
1447 ? (void *)vkGetPhysicalDeviceDisplayPropertiesKHR
1448 : NULL;
1449 return true;
1450 }
1451 if (!strcmp("vkGetPhysicalDeviceDisplayPlanePropertiesKHR", name)) {
1452 *addr = ptr_instance->wsi_display_enabled
1453 ? (void *)vkGetPhysicalDeviceDisplayPlanePropertiesKHR
1454 : NULL;
1455 return true;
1456 }
1457 if (!strcmp("vkGetDisplayPlaneSupportedDisplaysKHR", name)) {
1458 *addr = ptr_instance->wsi_display_enabled
1459 ? (void *)vkGetDisplayPlaneSupportedDisplaysKHR
1460 : NULL;
1461 return true;
1462 }
1463 if (!strcmp("vkGetDisplayModePropertiesKHR", name)) {
1464 *addr = ptr_instance->wsi_display_enabled
1465 ? (void *)vkGetDisplayModePropertiesKHR
1466 : NULL;
1467 return true;
1468 }
1469 if (!strcmp("vkCreateDisplayModeKHR", name)) {
1470 *addr = ptr_instance->wsi_display_enabled
1471 ? (void *)vkCreateDisplayModeKHR
1472 : NULL;
1473 return true;
1474 }
1475 if (!strcmp("vkGetDisplayPlaneCapabilitiesKHR", name)) {
1476 *addr = ptr_instance->wsi_display_enabled
1477 ? (void *)vkGetDisplayPlaneCapabilitiesKHR
1478 : NULL;
1479 return true;
1480 }
1481 if (!strcmp("vkCreateDisplayPlaneSurfaceKHR", name)) {
1482 *addr = ptr_instance->wsi_display_enabled
1483 ? (void *)vkCreateDisplayPlaneSurfaceKHR
1484 : NULL;
1485 return true;
1486 }
Mark Youngf2eabea2016-07-01 15:18:27 -06001487
1488 // Functions for KHR_display_swapchain extension:
1489 if (!strcmp("vkCreateSharedSwapchainsKHR", name)) {
1490 *addr = (void *)vkCreateSharedSwapchainsKHR;
1491 return true;
1492 }
1493
Jon Ashburnc4e9ae62016-02-26 13:14:27 -07001494 return false;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001495}