blob: b3df510c71cbd5ccf09413334a6fc28244d48c52 [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
Mark Young5467d672016-06-28 10:52:43 -060033// The first ICD/Loader interface that support querying the SurfaceKHR from
34// the ICDs.
35#define ICD_VER_SUPPORTS_ICD_SURFACE_KHR 3
36
Jon Ashburn1c75aec2016-02-02 17:47:28 -070037void wsi_create_instance(struct loader_instance *ptr_instance,
38 const VkInstanceCreateInfo *pCreateInfo) {
Ian Elliott5fb891a2015-10-30 17:45:05 -060039 ptr_instance->wsi_surface_enabled = false;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -070040
41#ifdef VK_USE_PLATFORM_WIN32_KHR
Jon Ashburncc370d02016-03-08 09:30:30 -070042 ptr_instance->wsi_win32_surface_enabled = false;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -070043#endif // VK_USE_PLATFORM_WIN32_KHR
44#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060045 ptr_instance->wsi_mir_surface_enabled = false;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -070046#endif // VK_USE_PLATFORM_MIR_KHR
47#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060048 ptr_instance->wsi_wayland_surface_enabled = false;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -070049#endif // VK_USE_PLATFORM_WAYLAND_KHR
50#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060051 ptr_instance->wsi_xcb_surface_enabled = false;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -070052#endif // VK_USE_PLATFORM_XCB_KHR
53#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060054 ptr_instance->wsi_xlib_surface_enabled = false;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -070055#endif // VK_USE_PLATFORM_XLIB_KHR
56#ifdef VK_USE_PLATFORM_ANDROID_KHR
57 ptr_instance->wsi_android_surface_enabled = false;
58#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060059
Jon Ashburncc370d02016-03-08 09:30:30 -070060 ptr_instance->wsi_display_enabled = false;
61
Jon Ashburna0673ab2016-01-11 13:12:43 -070062 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -070063 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
64 VK_KHR_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott54cea232015-10-30 15:28:23 -060065 ptr_instance->wsi_surface_enabled = true;
Ian Elliottb1849742015-11-19 11:58:08 -070066 continue;
Ian Elliott54cea232015-10-30 15:28:23 -060067 }
Ian Elliottb1849742015-11-19 11:58:08 -070068#ifdef VK_USE_PLATFORM_WIN32_KHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -070069 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
70 VK_KHR_WIN32_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott1693f592015-11-23 10:17:23 -070071 ptr_instance->wsi_win32_surface_enabled = true;
Ian Elliottb1849742015-11-19 11:58:08 -070072 continue;
Ian Elliott54cea232015-10-30 15:28:23 -060073 }
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -070074#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliott5fb891a2015-10-30 17:45:05 -060075#ifdef VK_USE_PLATFORM_MIR_KHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -070076 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
77 VK_KHR_MIR_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott54cea232015-10-30 15:28:23 -060078 ptr_instance->wsi_mir_surface_enabled = true;
Ian Elliottb1849742015-11-19 11:58:08 -070079 continue;
Ian Elliott54cea232015-10-30 15:28:23 -060080 }
Ian Elliott5fb891a2015-10-30 17:45:05 -060081#endif // VK_USE_PLATFORM_MIR_KHR
82#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -070083 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
84 VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott54cea232015-10-30 15:28:23 -060085 ptr_instance->wsi_wayland_surface_enabled = true;
Ian Elliottb1849742015-11-19 11:58:08 -070086 continue;
Ian Elliott54cea232015-10-30 15:28:23 -060087 }
Ian Elliott5fb891a2015-10-30 17:45:05 -060088#endif // VK_USE_PLATFORM_WAYLAND_KHR
89#ifdef VK_USE_PLATFORM_XCB_KHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -070090 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
91 VK_KHR_XCB_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott54cea232015-10-30 15:28:23 -060092 ptr_instance->wsi_xcb_surface_enabled = true;
Ian Elliottb1849742015-11-19 11:58:08 -070093 continue;
Ian Elliott54cea232015-10-30 15:28:23 -060094 }
Ian Elliott5fb891a2015-10-30 17:45:05 -060095#endif // VK_USE_PLATFORM_XCB_KHR
96#ifdef VK_USE_PLATFORM_XLIB_KHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -070097 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
98 VK_KHR_XLIB_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott54cea232015-10-30 15:28:23 -060099 ptr_instance->wsi_xlib_surface_enabled = true;
Ian Elliottb1849742015-11-19 11:58:08 -0700100 continue;
Ian Elliott54cea232015-10-30 15:28:23 -0600101 }
Ian Elliott5fb891a2015-10-30 17:45:05 -0600102#endif // VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700103#ifdef VK_USE_PLATFORM_ANDROID_KHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700104 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
105 VK_KHR_ANDROID_SURFACE_EXTENSION_NAME) == 0) {
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700106 ptr_instance->wsi_android_surface_enabled = true;
107 continue;
108 }
109#endif // VK_USE_PLATFORM_ANDROID_KHR
Jon Ashburncc370d02016-03-08 09:30:30 -0700110 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
111 VK_KHR_DISPLAY_EXTENSION_NAME) == 0) {
112 ptr_instance->wsi_display_enabled = true;
113 continue;
114 }
Ian Elliott54cea232015-10-30 15:28:23 -0600115 }
116}
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600117
118// Linux WSI surface extensions are not always compiled into the loader. (Assume
119// for Windows the KHR_win32_surface is always compiled into loader). A given
120// Linux build environment might not have the headers required for building one
121// of the four extensions (Xlib, Xcb, Mir, Wayland). Thus, need to check if
122// the built loader actually supports the particular Linux surface extension.
123// If not supported by the built loader it will not be included in the list of
124// enumerated instance extensions. This solves the issue where an ICD or layer
125// advertises support for a given Linux surface extension but the loader was not
126// built to support the extension.
Jon Ashburnae8f1e82016-03-25 12:49:35 -0600127bool wsi_unsupported_instance_extension(const VkExtensionProperties *ext_prop) {
128#ifndef VK_USE_PLATFORM_MIR_KHR
129 if (!strcmp(ext_prop->extensionName, "VK_KHR_mir_surface"))
130 return true;
131#endif // VK_USE_PLATFORM_MIR_KHR
132#ifndef VK_USE_PLATFORM_WAYLAND_KHR
133 if (!strcmp(ext_prop->extensionName, "VK_KHR_wayland_surface"))
134 return true;
135#endif // VK_USE_PLATFORM_WAYLAND_KHR
136#ifndef VK_USE_PLATFORM_XCB_KHR
137 if (!strcmp(ext_prop->extensionName, "VK_KHR_xcb_surface"))
138 return true;
139#endif // VK_USE_PLATFORM_XCB_KHR
140#ifndef VK_USE_PLATFORM_XLIB_KHR
141 if (!strcmp(ext_prop->extensionName, "VK_KHR_xlib_surface"))
142 return true;
143#endif // VK_USE_PLATFORM_XLIB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600144
Jon Ashburnae8f1e82016-03-25 12:49:35 -0600145 return false;
146}
Ian Elliott7c352552015-11-19 13:14:05 -0700147
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600148// Functions for the VK_KHR_surface extension:
149
150// This is the trampoline entrypoint for DestroySurfaceKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700151LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
152vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface,
153 const VkAllocationCallbacks *pAllocator) {
Ian Elliottabf50662015-11-25 14:43:02 -0700154 const VkLayerInstanceDispatchTable *disp;
155 disp = loader_get_instance_dispatch(instance);
156 disp->DestroySurfaceKHR(instance, surface, pAllocator);
157}
158
Jon Ashburncc370d02016-03-08 09:30:30 -0700159// TODO probably need to lock around all the loader_get_instance() calls.
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600160
161// This is the instance chain terminator function for DestroySurfaceKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700162VKAPI_ATTR void VKAPI_CALL
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700163terminator_DestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface,
164 const VkAllocationCallbacks *pAllocator) {
Ian Elliott1693f592015-11-23 10:17:23 -0700165 struct loader_instance *ptr_instance = loader_get_instance(instance);
166
Mark Young5467d672016-06-28 10:52:43 -0600167 VkIcdSurface *icd_surface = (VkIcdSurface *)(surface);
Mark Young11e9d472016-10-17 12:27:36 -0600168 if (NULL != icd_surface) {
169 if (NULL != icd_surface->real_icd_surfaces) {
170 for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
171 if (ptr_instance->icd_libs.list[i].interface_version >=
172 ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
173 struct loader_icd *icd = &ptr_instance->icds[i];
174 if (NULL != icd->DestroySurfaceKHR &&
175 NULL != (void *)icd_surface->real_icd_surfaces[i]) {
176 icd->DestroySurfaceKHR(
177 icd->instance, icd_surface->real_icd_surfaces[i],
178 pAllocator);
179 icd_surface->real_icd_surfaces[i] = (VkSurfaceKHR)NULL;
180 }
181 } else {
182 // The real_icd_surface for any ICD not supporting the
183 // proper interface version should be NULL. If not, then
184 // we have a problem.
185 assert(NULL == (void *)icd_surface->real_icd_surfaces[i]);
Mark Young5467d672016-06-28 10:52:43 -0600186 }
Mark Young5467d672016-06-28 10:52:43 -0600187 }
Mark Young11e9d472016-10-17 12:27:36 -0600188 loader_instance_heap_free(ptr_instance,
189 icd_surface->real_icd_surfaces);
Mark Young5467d672016-06-28 10:52:43 -0600190 }
Mark Young5467d672016-06-28 10:52:43 -0600191
Mark Young11e9d472016-10-17 12:27:36 -0600192 loader_instance_heap_free(ptr_instance, (void *)surface);
193 }
Ian Elliott7c352552015-11-19 13:14:05 -0700194}
195
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600196// This is the trampoline entrypoint for GetPhysicalDeviceSurfaceSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700197LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
198vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice,
199 uint32_t queueFamilyIndex,
200 VkSurfaceKHR surface,
201 VkBool32 *pSupported) {
Ian Elliott54cea232015-10-30 15:28:23 -0600202 const VkLayerInstanceDispatchTable *disp;
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700203 VkPhysicalDevice unwrapped_phys_dev =
204 loader_unwrap_physical_device(physicalDevice);
Ian Elliott54cea232015-10-30 15:28:23 -0600205 disp = loader_get_instance_dispatch(physicalDevice);
206 VkResult res = disp->GetPhysicalDeviceSurfaceSupportKHR(
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700207 unwrapped_phys_dev, queueFamilyIndex, surface, pSupported);
Ian Elliott54cea232015-10-30 15:28:23 -0600208 return res;
209}
210
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600211// This is the instance chain terminator function for
212// GetPhysicalDeviceSurfaceSupportKHR
213VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceSupportKHR(
214 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
215 VkSurfaceKHR surface, VkBool32 *pSupported) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600216 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700217 struct loader_physical_device *phys_dev =
218 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600219 struct loader_instance *ptr_instance =
220 (struct loader_instance *)phys_dev->this_icd->this_instance;
221 if (!ptr_instance->wsi_surface_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -0600222 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
223 "VK_KHR_VK_KHR_surface extension not enabled. "
224 "vkGetPhysicalDeviceSurfaceSupportKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600225 return VK_SUCCESS;
226 }
227
228 // Next, if so, proceed with the implementation of this function:
Ian Elliott54cea232015-10-30 15:28:23 -0600229 struct loader_icd *icd = phys_dev->this_icd;
230
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700231 assert(pSupported &&
232 "GetPhysicalDeviceSurfaceSupportKHR: Error, null pSupported");
Ian Elliott54cea232015-10-30 15:28:23 -0600233 *pSupported = false;
234
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700235 assert(icd->GetPhysicalDeviceSurfaceSupportKHR &&
236 "loader: null GetPhysicalDeviceSurfaceSupportKHR ICD pointer");
Ian Elliott54cea232015-10-30 15:28:23 -0600237
Mark Young5467d672016-06-28 10:52:43 -0600238 VkIcdSurface *icd_surface = (VkIcdSurface *)(surface);
239 if (NULL != icd_surface->real_icd_surfaces &&
240 NULL != (void *)icd_surface->real_icd_surfaces[phys_dev->icd_index]) {
241 return icd->GetPhysicalDeviceSurfaceSupportKHR(
242 phys_dev->phys_dev, queueFamilyIndex,
243 icd_surface->real_icd_surfaces[phys_dev->icd_index], pSupported);
244 }
Mark Young5467d672016-06-28 10:52:43 -0600245
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700246 return icd->GetPhysicalDeviceSurfaceSupportKHR(
247 phys_dev->phys_dev, queueFamilyIndex, surface, pSupported);
Ian Elliott54cea232015-10-30 15:28:23 -0600248}
249
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600250// This is the trampoline entrypoint for GetPhysicalDeviceSurfaceCapabilitiesKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700251LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
252vkGetPhysicalDeviceSurfaceCapabilitiesKHR(
253 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
254 VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) {
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700255
Ian Elliottea666b22015-11-19 16:05:09 -0700256 const VkLayerInstanceDispatchTable *disp;
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700257 VkPhysicalDevice unwrapped_phys_dev =
258 loader_unwrap_physical_device(physicalDevice);
Ian Elliottea666b22015-11-19 16:05:09 -0700259 disp = loader_get_instance_dispatch(physicalDevice);
260 VkResult res = disp->GetPhysicalDeviceSurfaceCapabilitiesKHR(
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700261 unwrapped_phys_dev, surface, pSurfaceCapabilities);
Ian Elliottea666b22015-11-19 16:05:09 -0700262 return res;
263}
264
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600265// This is the instance chain terminator function for
266// GetPhysicalDeviceSurfaceCapabilitiesKHR
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700267VKAPI_ATTR VkResult VKAPI_CALL
268terminator_GetPhysicalDeviceSurfaceCapabilitiesKHR(
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700269 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
270 VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600271 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700272 struct loader_physical_device *phys_dev =
273 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600274 struct loader_instance *ptr_instance =
275 (struct loader_instance *)phys_dev->this_icd->this_instance;
276 if (!ptr_instance->wsi_surface_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -0600277 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
278 "VK_KHR_surface extension not enabled. "
279 "vkGetPhysicalDeviceSurfaceCapabilitiesKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600280 return VK_SUCCESS;
281 }
282
283 // Next, if so, proceed with the implementation of this function:
Ian Elliottea666b22015-11-19 16:05:09 -0700284 struct loader_icd *icd = phys_dev->this_icd;
285
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700286 assert(pSurfaceCapabilities && "GetPhysicalDeviceSurfaceCapabilitiesKHR: "
287 "Error, null pSurfaceCapabilities");
Ian Elliottea666b22015-11-19 16:05:09 -0700288
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700289 assert(icd->GetPhysicalDeviceSurfaceCapabilitiesKHR &&
290 "loader: null GetPhysicalDeviceSurfaceCapabilitiesKHR ICD pointer");
Ian Elliottea666b22015-11-19 16:05:09 -0700291
Mark Young5467d672016-06-28 10:52:43 -0600292 VkIcdSurface *icd_surface = (VkIcdSurface *)(surface);
293 if (NULL != icd_surface->real_icd_surfaces &&
294 NULL != (void *)icd_surface->real_icd_surfaces[phys_dev->icd_index]) {
295 return icd->GetPhysicalDeviceSurfaceCapabilitiesKHR(
296 phys_dev->phys_dev,
297 icd_surface->real_icd_surfaces[phys_dev->icd_index],
298 pSurfaceCapabilities);
299 }
Mark Young5467d672016-06-28 10:52:43 -0600300
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700301 return icd->GetPhysicalDeviceSurfaceCapabilitiesKHR(
302 phys_dev->phys_dev, surface, pSurfaceCapabilities);
Ian Elliottea666b22015-11-19 16:05:09 -0700303}
304
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600305
306// This is the trampoline entrypoint for GetPhysicalDeviceSurfaceFormatsKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700307LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
308vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice,
309 VkSurfaceKHR surface,
310 uint32_t *pSurfaceFormatCount,
311 VkSurfaceFormatKHR *pSurfaceFormats) {
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700312 VkPhysicalDevice unwrapped_phys_dev =
313 loader_unwrap_physical_device(physicalDevice);
Ian Elliottea666b22015-11-19 16:05:09 -0700314 const VkLayerInstanceDispatchTable *disp;
315 disp = loader_get_instance_dispatch(physicalDevice);
316 VkResult res = disp->GetPhysicalDeviceSurfaceFormatsKHR(
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700317 unwrapped_phys_dev, surface, pSurfaceFormatCount, pSurfaceFormats);
Ian Elliottea666b22015-11-19 16:05:09 -0700318 return res;
319}
320
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600321
322// This is the instance chain terminator function for GetPhysicalDeviceSurfaceFormatsKHR
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700323VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceFormatsKHR(
324 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
325 uint32_t *pSurfaceFormatCount, VkSurfaceFormatKHR *pSurfaceFormats) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600326 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700327 struct loader_physical_device *phys_dev =
328 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600329 struct loader_instance *ptr_instance =
330 (struct loader_instance *)phys_dev->this_icd->this_instance;
331 if (!ptr_instance->wsi_surface_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -0600332 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
333 "VK_KHR_surface extension not enabled. "
334 "vkGetPhysicalDeviceSurfaceFormatsKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600335 return VK_SUCCESS;
336 }
337
338 // Next, if so, proceed with the implementation of this function:
Ian Elliottea666b22015-11-19 16:05:09 -0700339 struct loader_icd *icd = phys_dev->this_icd;
340
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700341 assert(
342 pSurfaceFormatCount &&
343 "GetPhysicalDeviceSurfaceFormatsKHR: Error, null pSurfaceFormatCount");
Ian Elliottea666b22015-11-19 16:05:09 -0700344
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700345 assert(icd->GetPhysicalDeviceSurfaceFormatsKHR &&
346 "loader: null GetPhysicalDeviceSurfaceFormatsKHR ICD pointer");
Ian Elliottea666b22015-11-19 16:05:09 -0700347
Mark Young5467d672016-06-28 10:52:43 -0600348 VkIcdSurface *icd_surface = (VkIcdSurface *)(surface);
349 if (NULL != icd_surface->real_icd_surfaces &&
350 NULL != (void *)icd_surface->real_icd_surfaces[phys_dev->icd_index]) {
351 return icd->GetPhysicalDeviceSurfaceFormatsKHR(
352 phys_dev->phys_dev,
353 icd_surface->real_icd_surfaces[phys_dev->icd_index],
354 pSurfaceFormatCount, pSurfaceFormats);
355 }
Mark Young5467d672016-06-28 10:52:43 -0600356
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700357 return icd->GetPhysicalDeviceSurfaceFormatsKHR(
358 phys_dev->phys_dev, surface, pSurfaceFormatCount, pSurfaceFormats);
Ian Elliottea666b22015-11-19 16:05:09 -0700359}
360
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600361// This is the trampoline entrypoint for GetPhysicalDeviceSurfacePresentModesKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700362LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
363vkGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,
364 VkSurfaceKHR surface,
365 uint32_t *pPresentModeCount,
366 VkPresentModeKHR *pPresentModes) {
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700367 VkPhysicalDevice unwrapped_phys_dev =
368 loader_unwrap_physical_device(physicalDevice);
Ian Elliottea666b22015-11-19 16:05:09 -0700369 const VkLayerInstanceDispatchTable *disp;
370 disp = loader_get_instance_dispatch(physicalDevice);
371 VkResult res = disp->GetPhysicalDeviceSurfacePresentModesKHR(
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700372 unwrapped_phys_dev, surface, pPresentModeCount, pPresentModes);
Ian Elliottea666b22015-11-19 16:05:09 -0700373 return res;
374}
375
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600376// This is the instance chain terminator function for
377// GetPhysicalDeviceSurfacePresentModesKHR
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700378VKAPI_ATTR VkResult VKAPI_CALL
379terminator_GetPhysicalDeviceSurfacePresentModesKHR(
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700380 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
381 uint32_t *pPresentModeCount, VkPresentModeKHR *pPresentModes) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600382 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700383 struct loader_physical_device *phys_dev =
384 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600385 struct loader_instance *ptr_instance =
386 (struct loader_instance *)phys_dev->this_icd->this_instance;
387 if (!ptr_instance->wsi_surface_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -0600388 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
389 "VK_KHR_surface extension not enabled. "
390 "vkGetPhysicalDeviceSurfacePresentModesKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600391 return VK_SUCCESS;
392 }
393
394 // Next, if so, proceed with the implementation of this function:
Ian Elliottea666b22015-11-19 16:05:09 -0700395 struct loader_icd *icd = phys_dev->this_icd;
396
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700397 assert(pPresentModeCount && "GetPhysicalDeviceSurfacePresentModesKHR: "
398 "Error, null pPresentModeCount");
Ian Elliottea666b22015-11-19 16:05:09 -0700399
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700400 assert(icd->GetPhysicalDeviceSurfacePresentModesKHR &&
401 "loader: null GetPhysicalDeviceSurfacePresentModesKHR ICD pointer");
Ian Elliottea666b22015-11-19 16:05:09 -0700402
Mark Young5467d672016-06-28 10:52:43 -0600403 VkIcdSurface *icd_surface = (VkIcdSurface *)(surface);
404 if (NULL != icd_surface->real_icd_surfaces &&
405 NULL != (void *)icd_surface->real_icd_surfaces[phys_dev->icd_index]) {
406 return icd->GetPhysicalDeviceSurfacePresentModesKHR(
407 phys_dev->phys_dev,
408 icd_surface->real_icd_surfaces[phys_dev->icd_index],
409 pPresentModeCount, pPresentModes);
410 }
Mark Young5467d672016-06-28 10:52:43 -0600411
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700412 return icd->GetPhysicalDeviceSurfacePresentModesKHR(
413 phys_dev->phys_dev, surface, pPresentModeCount, pPresentModes);
Ian Elliottea666b22015-11-19 16:05:09 -0700414}
415
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600416// Functions for the VK_KHR_swapchain extension:
Ian Elliott7c352552015-11-19 13:14:05 -0700417
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600418// This is the trampoline entrypoint for CreateSwapchainKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600419LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR(
420 VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
421 const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain) {
Ian Elliott9b89a472015-11-19 16:39:21 -0700422 const VkLayerDispatchTable *disp;
423 disp = loader_get_dispatch(device);
Mark Young76b3fe02016-09-08 12:28:38 -0600424 return disp->CreateSwapchainKHR(device, pCreateInfo, pAllocator,
425 pSwapchain);
Ian Elliott9b89a472015-11-19 16:39:21 -0700426}
Ian Elliott7c352552015-11-19 13:14:05 -0700427
Mark Young5467d672016-06-28 10:52:43 -0600428VKAPI_ATTR VkResult VKAPI_CALL terminator_vkCreateSwapchainKHR(
429 VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
430 const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain) {
431 uint32_t icd_index = 0;
432 struct loader_device *dev;
433 struct loader_icd *icd = loader_get_icd_and_device(device, &dev, &icd_index);
Mark Young5467d672016-06-28 10:52:43 -0600434 if (NULL != icd &&
435 NULL != icd->CreateSwapchainKHR) {
Mark Young5467d672016-06-28 10:52:43 -0600436 VkIcdSurface *icd_surface = (VkIcdSurface *)(pCreateInfo->surface);
437 if (NULL != icd_surface->real_icd_surfaces) {
438 if (NULL != (void *)icd_surface->real_icd_surfaces[icd_index]) {
439 // We found the ICD, and there is an ICD KHR surface
440 // associated with it, so copy the CreateInfo struct
441 // and point it at the ICD's surface.
442 VkSwapchainCreateInfoKHR *pCreateCopy =
443 loader_stack_alloc(sizeof(VkSwapchainCreateInfoKHR));
444 if (NULL == pCreateCopy) {
445 return VK_ERROR_OUT_OF_HOST_MEMORY;
446 }
Piers Daniell1ad59912016-09-14 11:24:36 -0600447 memcpy(pCreateCopy, pCreateInfo, sizeof(VkSwapchainCreateInfoKHR));
Mark Young5467d672016-06-28 10:52:43 -0600448 pCreateCopy->surface =
449 icd_surface->real_icd_surfaces[icd_index];
450 return icd->CreateSwapchainKHR(device, pCreateCopy, pAllocator, pSwapchain);
451 }
452 }
Mark Young5467d672016-06-28 10:52:43 -0600453 return icd->CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain);
454 }
455 return VK_SUCCESS;
456}
457
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600458// This is the trampoline entrypoint for DestroySwapchainKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700459LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
460vkDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain,
461 const VkAllocationCallbacks *pAllocator) {
Ian Elliott9b89a472015-11-19 16:39:21 -0700462 const VkLayerDispatchTable *disp;
463 disp = loader_get_dispatch(device);
464 disp->DestroySwapchainKHR(device, swapchain, pAllocator);
465}
Ian Elliott7c352552015-11-19 13:14:05 -0700466
Mark Young5467d672016-06-28 10:52:43 -0600467/*
468 * This is the trampoline entrypoint
469 * for GetSwapchainImagesKHR
470 */
471LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR(
472 VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount,
473 VkImage *pSwapchainImages) {
Ian Elliott9b89a472015-11-19 16:39:21 -0700474 const VkLayerDispatchTable *disp;
475 disp = loader_get_dispatch(device);
Mark Young76b3fe02016-09-08 12:28:38 -0600476 return disp->GetSwapchainImagesKHR(
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700477 device, swapchain, pSwapchainImageCount, pSwapchainImages);
Ian Elliott9b89a472015-11-19 16:39:21 -0700478}
479
Mark Young5467d672016-06-28 10:52:43 -0600480/*
481 * This is the trampoline entrypoint
482 * for AcquireNextImageKHR
483 */
484LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImageKHR(
485 VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
486 VkSemaphore semaphore, VkFence fence, uint32_t *pImageIndex) {
Ian Elliott9b89a472015-11-19 16:39:21 -0700487 const VkLayerDispatchTable *disp;
488 disp = loader_get_dispatch(device);
Mark Young76b3fe02016-09-08 12:28:38 -0600489 return disp->AcquireNextImageKHR(device, swapchain, timeout,
490 semaphore, fence, pImageIndex);
Ian Elliott9b89a472015-11-19 16:39:21 -0700491}
492
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600493// This is the trampoline entrypoint for QueuePresentKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700494LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
495vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) {
Ian Elliott9b89a472015-11-19 16:39:21 -0700496 const VkLayerDispatchTable *disp;
497 disp = loader_get_dispatch(queue);
Mark Young76b3fe02016-09-08 12:28:38 -0600498 return disp->QueuePresentKHR(queue, pPresentInfo);
Ian Elliott9b89a472015-11-19 16:39:21 -0700499}
Ian Elliott7c352552015-11-19 13:14:05 -0700500
Mark Youngf27962c2016-09-16 10:18:42 -0600501static VkIcdSurface *AllocateIcdSurfaceStruct(struct loader_instance *instance,
502 size_t base_size,
503 size_t platform_size,
504 bool create_icd_surfs) {
505 // Next, if so, proceed with the implementation of this function:
506 VkIcdSurface *pIcdSurface = loader_instance_heap_alloc(
507 instance, sizeof(VkIcdSurface), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
508 if (pIcdSurface != NULL) {
509 // Setup the new sizes and offsets so we can grow the structures in the
510 // future without having problems
511 pIcdSurface->base_size = (uint32_t)base_size;
512 pIcdSurface->platform_size = (uint32_t)platform_size;
513 pIcdSurface->non_platform_offset = (uint32_t)(
514 (uint8_t *)(&pIcdSurface->base_size) - (uint8_t *)pIcdSurface);
515 pIcdSurface->entire_size = sizeof(VkIcdSurface);
516
517 if (create_icd_surfs) {
518 pIcdSurface->real_icd_surfaces = loader_instance_heap_alloc(
519 instance, sizeof(VkSurfaceKHR) * instance->total_icd_count,
520 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
521 if (pIcdSurface->real_icd_surfaces == NULL) {
522 loader_instance_heap_free(instance, pIcdSurface);
523 pIcdSurface = NULL;
524 } else {
525 memset(pIcdSurface->real_icd_surfaces, 0,
526 sizeof(VkSurfaceKHR) * instance->total_icd_count);
527 }
528 } else {
529 pIcdSurface->real_icd_surfaces = NULL;
530 }
531 }
532 return pIcdSurface;
533}
534
Ian Elliott7c352552015-11-19 13:14:05 -0700535#ifdef VK_USE_PLATFORM_WIN32_KHR
536
Ian Elliott7c352552015-11-19 13:14:05 -0700537
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600538// Functions for the VK_KHR_win32_surface extension:
539
540// This is the trampoline entrypoint for CreateWin32SurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600541LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR(
542 VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
543 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburn16edfa62015-11-25 17:55:49 -0700544 const VkLayerInstanceDispatchTable *disp;
545 disp = loader_get_instance_dispatch(instance);
546 VkResult res;
547
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700548 res = disp->CreateWin32SurfaceKHR(instance, pCreateInfo, pAllocator,
549 pSurface);
Jon Ashburn16edfa62015-11-25 17:55:49 -0700550 return res;
551}
552
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600553// This is the instance chain terminator function for CreateWin32SurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600554VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWin32SurfaceKHR(
555 VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
556 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Mark Young5467d672016-06-28 10:52:43 -0600557 VkResult vkRes = VK_SUCCESS;
Mark Youngd7fb1592016-10-12 14:18:44 -0600558 VkIcdSurface *pIcdSurface = NULL;
Mark Youngf27962c2016-09-16 10:18:42 -0600559 // Initialize pSurface to NULL just to be safe.
560 *pSurface = VK_NULL_HANDLE;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600561 // First, check to ensure the appropriate extension was enabled:
Ian Elliott1693f592015-11-23 10:17:23 -0700562 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600563 if (!ptr_instance->wsi_win32_surface_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -0600564 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
565 "VK_KHR_win32_surface extension not enabled. "
566 "vkCreateWin32SurfaceKHR not executed!\n");
Mark Young5467d672016-06-28 10:52:43 -0600567 vkRes = VK_ERROR_EXTENSION_NOT_PRESENT;
568 goto out;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600569 }
570
571 // Next, if so, proceed with the implementation of this function:
Mark Youngd7fb1592016-10-12 14:18:44 -0600572 pIcdSurface = AllocateIcdSurfaceStruct(
Mark Youngf27962c2016-09-16 10:18:42 -0600573 ptr_instance, sizeof(pIcdSurface->win_surf.base),
574 sizeof(pIcdSurface->win_surf), true);
Ian Elliott7c352552015-11-19 13:14:05 -0700575 if (pIcdSurface == NULL) {
Mark Young5467d672016-06-28 10:52:43 -0600576 vkRes = VK_ERROR_OUT_OF_HOST_MEMORY;
577 goto out;
Ian Elliott7c352552015-11-19 13:14:05 -0700578 }
579
Mark Young5467d672016-06-28 10:52:43 -0600580 pIcdSurface->win_surf.base.platform = VK_ICD_WSI_PLATFORM_WIN32;
581 pIcdSurface->win_surf.hinstance = pCreateInfo->hinstance;
582 pIcdSurface->win_surf.hwnd = pCreateInfo->hwnd;
Ian Elliott7c352552015-11-19 13:14:05 -0700583
Mark Young5467d672016-06-28 10:52:43 -0600584 // Loop through each ICD and determine if they need to create a surface
585 for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
586 if (ptr_instance->icd_libs.list[i].interface_version >=
587 ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
588 struct loader_icd *icd = &ptr_instance->icds[i];
589 if (NULL != icd->CreateWin32SurfaceKHR) {
590 vkRes = icd->CreateWin32SurfaceKHR(
Piers Daniell1ad59912016-09-14 11:24:36 -0600591 icd->instance, pCreateInfo, pAllocator,
Mark Young5467d672016-06-28 10:52:43 -0600592 &pIcdSurface->real_icd_surfaces[i]);
593 if (VK_SUCCESS != vkRes) {
594 goto out;
595 }
596 }
597 }
598 }
599
600 *pSurface = (VkSurfaceKHR)(pIcdSurface);
601
602out:
603
604 if (VK_SUCCESS != vkRes && NULL != pIcdSurface) {
605 if (NULL != pIcdSurface->real_icd_surfaces) {
606 for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
607 struct loader_icd *icd = &ptr_instance->icds[i];
Mark Youngf27962c2016-09-16 10:18:42 -0600608 if (NULL != (void*)pIcdSurface->real_icd_surfaces[i] &&
Mark Young5467d672016-06-28 10:52:43 -0600609 NULL != icd->DestroySurfaceKHR) {
610 icd->DestroySurfaceKHR(
Piers Daniell1ad59912016-09-14 11:24:36 -0600611 icd->instance, pIcdSurface->real_icd_surfaces[i], pAllocator);
Mark Young5467d672016-06-28 10:52:43 -0600612 }
613 }
614 loader_instance_heap_free(ptr_instance, pIcdSurface->real_icd_surfaces);
615 }
616 loader_instance_heap_free(ptr_instance, pIcdSurface);
617 }
618
619 return vkRes;
Ian Elliott7c352552015-11-19 13:14:05 -0700620}
Ian Elliotte851dd62015-11-24 15:39:10 -0700621
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600622// This is the trampoline entrypoint for
623// GetPhysicalDeviceWin32PresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700624LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
625vkGetPhysicalDeviceWin32PresentationSupportKHR(VkPhysicalDevice physicalDevice,
626 uint32_t queueFamilyIndex) {
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700627 VkPhysicalDevice unwrapped_phys_dev =
628 loader_unwrap_physical_device(physicalDevice);
Ian Elliotte851dd62015-11-24 15:39:10 -0700629 const VkLayerInstanceDispatchTable *disp;
630 disp = loader_get_instance_dispatch(physicalDevice);
631 VkBool32 res = disp->GetPhysicalDeviceWin32PresentationSupportKHR(
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700632 unwrapped_phys_dev, queueFamilyIndex);
Ian Elliotte851dd62015-11-24 15:39:10 -0700633 return res;
634}
635
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600636// This is the instance chain terminator function for
637// GetPhysicalDeviceWin32PresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700638VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700639terminator_GetPhysicalDeviceWin32PresentationSupportKHR(
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700640 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600641 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700642 struct loader_physical_device *phys_dev =
643 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600644 struct loader_instance *ptr_instance =
645 (struct loader_instance *)phys_dev->this_icd->this_instance;
646 if (!ptr_instance->wsi_win32_surface_enabled) {
Jon Ashburnc466da52016-04-15 09:25:03 -0600647 loader_log(
648 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
649 "VK_KHR_win32_surface extension not enabled. "
650 "vkGetPhysicalDeviceWin32PresentationSupportKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600651 return VK_SUCCESS;
652 }
653
654 // Next, if so, proceed with the implementation of this function:
Ian Elliotte851dd62015-11-24 15:39:10 -0700655 struct loader_icd *icd = phys_dev->this_icd;
656
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700657 assert(icd->GetPhysicalDeviceWin32PresentationSupportKHR &&
658 "loader: null GetPhysicalDeviceWin32PresentationSupportKHR ICD "
659 "pointer");
Ian Elliotte851dd62015-11-24 15:39:10 -0700660
661 return icd->GetPhysicalDeviceWin32PresentationSupportKHR(phys_dev->phys_dev,
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700662 queueFamilyIndex);
Ian Elliotte851dd62015-11-24 15:39:10 -0700663}
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700664#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliott7c352552015-11-19 13:14:05 -0700665
666#ifdef VK_USE_PLATFORM_MIR_KHR
667
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600668// Functions for the VK_KHR_mir_surface extension:
Ian Elliott7c352552015-11-19 13:14:05 -0700669
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600670// This is the trampoline entrypoint for CreateMirSurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600671LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateMirSurfaceKHR(
672 VkInstance instance, const VkMirSurfaceCreateInfoKHR *pCreateInfo,
673 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburn16edfa62015-11-25 17:55:49 -0700674 const VkLayerInstanceDispatchTable *disp;
675 disp = loader_get_instance_dispatch(instance);
676 VkResult res;
677
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700678 res =
679 disp->CreateMirSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
Jon Ashburn16edfa62015-11-25 17:55:49 -0700680 return res;
681}
682
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600683// This is the instance chain terminator function for CreateMirSurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600684VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateMirSurfaceKHR(
685 VkInstance instance, const VkMirSurfaceCreateInfoKHR *pCreateInfo,
686 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Mark Young5467d672016-06-28 10:52:43 -0600687 VkResult vkRes = VK_SUCCESS;
Mark Youngd7fb1592016-10-12 14:18:44 -0600688 VkIcdSurface *pIcdSurface = NULL;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600689 // First, check to ensure the appropriate extension was enabled:
Ian Elliott1693f592015-11-23 10:17:23 -0700690 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600691 if (!ptr_instance->wsi_mir_surface_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -0600692 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
693 "VK_KHR_mir_surface extension not enabled. "
694 "vkCreateMirSurfaceKHR not executed!\n");
Mark Young5467d672016-06-28 10:52:43 -0600695 vkRes = VK_ERROR_EXTENSION_NOT_PRESENT;
696 goto out;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600697 }
698
699 // Next, if so, proceed with the implementation of this function:
Mark Youngd7fb1592016-10-12 14:18:44 -0600700 pIcdSurface = AllocateIcdSurfaceStruct(
Mark Youngf27962c2016-09-16 10:18:42 -0600701 ptr_instance, sizeof(pIcdSurface->mir_surf.base),
702 sizeof(pIcdSurface->mir_surf), true);
Ian Elliott7c352552015-11-19 13:14:05 -0700703 if (pIcdSurface == NULL) {
Mark Young5467d672016-06-28 10:52:43 -0600704 vkRes = VK_ERROR_OUT_OF_HOST_MEMORY;
705 goto out;
Ian Elliott7c352552015-11-19 13:14:05 -0700706 }
707
Mark Young5467d672016-06-28 10:52:43 -0600708 pIcdSurface->mir_surf.base.platform = VK_ICD_WSI_PLATFORM_MIR;
709 pIcdSurface->mir_surf.connection = pCreateInfo->connection;
710 pIcdSurface->mir_surf.mirSurface = pCreateInfo->mirSurface;
711
Mark Young5467d672016-06-28 10:52:43 -0600712 // Loop through each ICD and determine if they need to create a surface
713 for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
714 if (ptr_instance->icd_libs.list[i].interface_version >=
715 ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
716 struct loader_icd *icd = &ptr_instance->icds[i];
717 if (NULL != icd->CreateMirSurfaceKHR) {
718 vkRes = icd->CreateMirSurfaceKHR(
Piers Daniell1ad59912016-09-14 11:24:36 -0600719 icd->instance, pCreateInfo, pAllocator,
Mark Young5467d672016-06-28 10:52:43 -0600720 &pIcdSurface->real_icd_surfaces[i]);
721 if (VK_SUCCESS != vkRes) {
722 goto out;
723 }
724 }
725 }
726 }
Ian Elliott7c352552015-11-19 13:14:05 -0700727
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700728 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliott7c352552015-11-19 13:14:05 -0700729
Mark Young5467d672016-06-28 10:52:43 -0600730out:
731
732 if (VK_SUCCESS != vkRes && NULL != pIcdSurface) {
733 if (NULL != pIcdSurface->real_icd_surfaces) {
734 for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
735 struct loader_icd *icd = &ptr_instance->icds[i];
736 if (NULL != pIcdSurface->real_icd_surfaces[i] &&
737 NULL != icd->DestroySurfaceKHR) {
738 icd->DestroySurfaceKHR(
Piers Daniell1ad59912016-09-14 11:24:36 -0600739 icd->instance, pIcdSurface->real_icd_surfaces[i], pAllocator);
Mark Young5467d672016-06-28 10:52:43 -0600740 }
741 }
742 loader_instance_heap_free(ptr_instance, pIcdSurface->real_icd_surfaces);
743 }
744 loader_instance_heap_free(ptr_instance, pIcdSurface);
745 }
746
747 return vkRes;
Ian Elliott7c352552015-11-19 13:14:05 -0700748}
Ian Elliotte851dd62015-11-24 15:39:10 -0700749
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600750// This is the trampoline entrypoint for
751// GetPhysicalDeviceMirPresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700752LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
753vkGetPhysicalDeviceMirPresentationSupportKHR(VkPhysicalDevice physicalDevice,
754 uint32_t queueFamilyIndex,
755 MirConnection *connection) {
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700756 VkPhysicalDevice unwrapped_phys_dev =
757 loader_unwrap_physical_device(physicalDevice);
Ian Elliotte851dd62015-11-24 15:39:10 -0700758 const VkLayerInstanceDispatchTable *disp;
759 disp = loader_get_instance_dispatch(physicalDevice);
760 VkBool32 res = disp->GetPhysicalDeviceMirPresentationSupportKHR(
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700761 unwrapped_phys_dev, queueFamilyIndex, connection);
Ian Elliotte851dd62015-11-24 15:39:10 -0700762 return res;
763}
764
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600765// This is the instance chain terminator function for
766// GetPhysicalDeviceMirPresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700767VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700768terminator_GetPhysicalDeviceMirPresentationSupportKHR(
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700769 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
770 MirConnection *connection) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600771 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700772 struct loader_physical_device *phys_dev =
773 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600774 struct loader_instance *ptr_instance =
775 (struct loader_instance *)phys_dev->this_icd->this_instance;
776 if (!ptr_instance->wsi_mir_surface_enabled) {
Jon Ashburnc466da52016-04-15 09:25:03 -0600777 loader_log(
778 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
779 "VK_KHR_mir_surface extension not enabled. "
780 "vkGetPhysicalDeviceMirPresentationSupportKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600781 return VK_SUCCESS;
782 }
783
784 // Next, if so, proceed with the implementation of this function:
Ian Elliotte851dd62015-11-24 15:39:10 -0700785 struct loader_icd *icd = phys_dev->this_icd;
786
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700787 assert(
788 icd->GetPhysicalDeviceMirPresentationSupportKHR &&
789 "loader: null GetPhysicalDeviceMirPresentationSupportKHR ICD pointer");
Ian Elliotte851dd62015-11-24 15:39:10 -0700790
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700791 return icd->GetPhysicalDeviceMirPresentationSupportKHR(
792 phys_dev->phys_dev, queueFamilyIndex, connection);
Ian Elliotte851dd62015-11-24 15:39:10 -0700793}
Ian Elliott7c352552015-11-19 13:14:05 -0700794#endif // VK_USE_PLATFORM_MIR_KHR
795
796#ifdef VK_USE_PLATFORM_WAYLAND_KHR
797
Mark Young5467d672016-06-28 10:52:43 -0600798/*
799 * This is the trampoline entrypoint
800 * for CreateWaylandSurfaceKHR
801 */
802LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateWaylandSurfaceKHR(
803 VkInstance instance, const VkWaylandSurfaceCreateInfoKHR *pCreateInfo,
804 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburn16edfa62015-11-25 17:55:49 -0700805 const VkLayerInstanceDispatchTable *disp;
806 disp = loader_get_instance_dispatch(instance);
807 VkResult res;
808
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700809 res = disp->CreateWaylandSurfaceKHR(instance, pCreateInfo, pAllocator,
810 pSurface);
Jon Ashburn16edfa62015-11-25 17:55:49 -0700811 return res;
812}
813
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600814// This is the instance chain terminator function for CreateWaylandSurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600815VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWaylandSurfaceKHR(
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700816 VkInstance instance, const VkWaylandSurfaceCreateInfoKHR *pCreateInfo,
817 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Mark Young5467d672016-06-28 10:52:43 -0600818 VkResult vkRes = VK_SUCCESS;
Mark Youngd7fb1592016-10-12 14:18:44 -0600819 VkIcdSurface *pIcdSurface = NULL;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600820 // First, check to ensure the appropriate extension was enabled:
Ian Elliott1693f592015-11-23 10:17:23 -0700821 struct loader_instance *ptr_instance = loader_get_instance(instance);
Jon Ashburn436d6a32016-03-24 17:26:59 -0600822 if (!ptr_instance->wsi_wayland_surface_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -0600823 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
824 "VK_KHR_wayland_surface extension not enabled. "
825 "vkCreateWaylandSurfaceKHR not executed!\n");
Mark Young5467d672016-06-28 10:52:43 -0600826 vkRes = VK_ERROR_EXTENSION_NOT_PRESENT;
827 goto out;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600828 }
829
830 // Next, if so, proceed with the implementation of this function:
Mark Youngd7fb1592016-10-12 14:18:44 -0600831 pIcdSurface = AllocateIcdSurfaceStruct(
Mark Youngf27962c2016-09-16 10:18:42 -0600832 ptr_instance, sizeof(pIcdSurface->wayland_surf.base),
833 sizeof(pIcdSurface->wayland_surf), true);
Ian Elliott7c352552015-11-19 13:14:05 -0700834 if (pIcdSurface == NULL) {
Mark Young5467d672016-06-28 10:52:43 -0600835 vkRes = VK_ERROR_OUT_OF_HOST_MEMORY;
836 goto out;
Ian Elliott7c352552015-11-19 13:14:05 -0700837 }
838
Mark Young5467d672016-06-28 10:52:43 -0600839 pIcdSurface->wayland_surf.base.platform = VK_ICD_WSI_PLATFORM_WAYLAND;
840 pIcdSurface->wayland_surf.display = pCreateInfo->display;
841 pIcdSurface->wayland_surf.surface = pCreateInfo->surface;
842
Mark Young5467d672016-06-28 10:52:43 -0600843 // Loop through each ICD and determine if they need to create a surface
844 for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
845 if (ptr_instance->icd_libs.list[i].interface_version >=
846 ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
847 struct loader_icd *icd = &ptr_instance->icds[i];
848 if (NULL != icd->CreateWaylandSurfaceKHR) {
849 vkRes = icd->CreateWaylandSurfaceKHR(
Piers Daniell1ad59912016-09-14 11:24:36 -0600850 icd->instance, pCreateInfo, pAllocator,
Mark Young5467d672016-06-28 10:52:43 -0600851 &pIcdSurface->real_icd_surfaces[i]);
852 if (VK_SUCCESS != vkRes) {
853 goto out;
854 }
855 }
856 }
857 }
Ian Elliott7c352552015-11-19 13:14:05 -0700858
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700859 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliott7c352552015-11-19 13:14:05 -0700860
Mark Young5467d672016-06-28 10:52:43 -0600861out:
862
863 if (VK_SUCCESS != vkRes && NULL != pIcdSurface) {
864 if (NULL != pIcdSurface->real_icd_surfaces) {
865 for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
866 struct loader_icd *icd = &ptr_instance->icds[i];
867 if (NULL != pIcdSurface->real_icd_surfaces[i] &&
868 NULL != icd->DestroySurfaceKHR) {
869 icd->DestroySurfaceKHR(
Piers Daniell1ad59912016-09-14 11:24:36 -0600870 icd->instance, pIcdSurface->real_icd_surfaces[i], pAllocator);
Mark Young5467d672016-06-28 10:52:43 -0600871 }
872 }
873 loader_instance_heap_free(ptr_instance, pIcdSurface->real_icd_surfaces);
874 }
875 loader_instance_heap_free(ptr_instance, pIcdSurface);
876 }
877
878 return vkRes;
Ian Elliott7c352552015-11-19 13:14:05 -0700879}
Ian Elliotte851dd62015-11-24 15:39:10 -0700880
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600881
882// This is the trampoline entrypoint for
883// GetPhysicalDeviceWaylandPresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700884LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
885vkGetPhysicalDeviceWaylandPresentationSupportKHR(
886 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
887 struct wl_display *display) {
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700888 VkPhysicalDevice unwrapped_phys_dev =
889 loader_unwrap_physical_device(physicalDevice);
Ian Elliotte851dd62015-11-24 15:39:10 -0700890 const VkLayerInstanceDispatchTable *disp;
891 disp = loader_get_instance_dispatch(physicalDevice);
892 VkBool32 res = disp->GetPhysicalDeviceWaylandPresentationSupportKHR(
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700893 unwrapped_phys_dev, queueFamilyIndex, display);
Ian Elliotte851dd62015-11-24 15:39:10 -0700894 return res;
895}
896
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600897// This is the instance chain terminator function for
898// GetPhysicalDeviceWaylandPresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700899VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700900terminator_GetPhysicalDeviceWaylandPresentationSupportKHR(
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700901 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
902 struct wl_display *display) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600903 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700904 struct loader_physical_device *phys_dev =
905 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600906 struct loader_instance *ptr_instance =
907 (struct loader_instance *)phys_dev->this_icd->this_instance;
Jon Ashburn436d6a32016-03-24 17:26:59 -0600908 if (!ptr_instance->wsi_wayland_surface_enabled) {
Jon Ashburnc466da52016-04-15 09:25:03 -0600909 loader_log(
910 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
911 "VK_KHR_wayland_surface extension not enabled. "
912 "vkGetPhysicalDeviceWaylandPresentationSupportKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600913 return VK_SUCCESS;
914 }
915
916 // Next, if so, proceed with the implementation of this function:
Ian Elliotte851dd62015-11-24 15:39:10 -0700917 struct loader_icd *icd = phys_dev->this_icd;
918
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700919 assert(icd->GetPhysicalDeviceWaylandPresentationSupportKHR &&
920 "loader: null GetPhysicalDeviceWaylandPresentationSupportKHR ICD "
921 "pointer");
Ian Elliotte851dd62015-11-24 15:39:10 -0700922
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700923 return icd->GetPhysicalDeviceWaylandPresentationSupportKHR(
924 phys_dev->phys_dev, queueFamilyIndex, display);
Ian Elliotte851dd62015-11-24 15:39:10 -0700925}
Ian Elliott7c352552015-11-19 13:14:05 -0700926#endif // VK_USE_PLATFORM_WAYLAND_KHR
927
928#ifdef VK_USE_PLATFORM_XCB_KHR
929
Ian Elliott7c352552015-11-19 13:14:05 -0700930
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600931// Functions for the VK_KHR_xcb_surface extension:
932
933// This is the trampoline entrypoint for CreateXcbSurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600934LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXcbSurfaceKHR(
935 VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo,
936 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburn16edfa62015-11-25 17:55:49 -0700937 const VkLayerInstanceDispatchTable *disp;
938 disp = loader_get_instance_dispatch(instance);
939 VkResult res;
940
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700941 res =
942 disp->CreateXcbSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
Jon Ashburn16edfa62015-11-25 17:55:49 -0700943 return res;
944}
945
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600946// This is the instance chain terminator function for CreateXcbSurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600947VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXcbSurfaceKHR(
948 VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo,
949 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Mark Young5467d672016-06-28 10:52:43 -0600950 VkResult vkRes = VK_SUCCESS;
Mark Youngd7fb1592016-10-12 14:18:44 -0600951 VkIcdSurface *pIcdSurface = NULL;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600952 // First, check to ensure the appropriate extension was enabled:
Ian Elliott1693f592015-11-23 10:17:23 -0700953 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600954 if (!ptr_instance->wsi_xcb_surface_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -0600955 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
956 "VK_KHR_xcb_surface extension not enabled. "
957 "vkCreateXcbSurfaceKHR not executed!\n");
Mark Young5467d672016-06-28 10:52:43 -0600958 vkRes = VK_ERROR_EXTENSION_NOT_PRESENT;
959 goto out;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600960 }
961
962 // Next, if so, proceed with the implementation of this function:
Mark Youngd7fb1592016-10-12 14:18:44 -0600963 pIcdSurface = AllocateIcdSurfaceStruct(
Mark Youngf27962c2016-09-16 10:18:42 -0600964 ptr_instance, sizeof(pIcdSurface->xcb_surf.base),
965 sizeof(pIcdSurface->xcb_surf), true);
Ian Elliott7c352552015-11-19 13:14:05 -0700966 if (pIcdSurface == NULL) {
Mark Young5467d672016-06-28 10:52:43 -0600967 vkRes = VK_ERROR_OUT_OF_HOST_MEMORY;
968 goto out;
Ian Elliott7c352552015-11-19 13:14:05 -0700969 }
970
Mark Young5467d672016-06-28 10:52:43 -0600971 pIcdSurface->xcb_surf.base.platform = VK_ICD_WSI_PLATFORM_XCB;
972 pIcdSurface->xcb_surf.connection = pCreateInfo->connection;
973 pIcdSurface->xcb_surf.window = pCreateInfo->window;
974
Mark Young5467d672016-06-28 10:52:43 -0600975 // Loop through each ICD and determine if they need to create a surface
976 for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
977 if (ptr_instance->icd_libs.list[i].interface_version >=
978 ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
979 struct loader_icd *icd = &ptr_instance->icds[i];
980 if (NULL != icd->CreateXcbSurfaceKHR) {
981 vkRes = icd->CreateXcbSurfaceKHR(
Piers Daniell1ad59912016-09-14 11:24:36 -0600982 icd->instance, pCreateInfo, pAllocator,
Mark Young5467d672016-06-28 10:52:43 -0600983 &pIcdSurface->real_icd_surfaces[i]);
984 if (VK_SUCCESS != vkRes) {
985 goto out;
986 }
987 }
988 }
989 }
Ian Elliott7c352552015-11-19 13:14:05 -0700990
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700991 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliott7c352552015-11-19 13:14:05 -0700992
Mark Young5467d672016-06-28 10:52:43 -0600993out:
994
995 if (VK_SUCCESS != vkRes && NULL != pIcdSurface) {
996 if (NULL != pIcdSurface->real_icd_surfaces) {
997 for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
998 struct loader_icd *icd = &ptr_instance->icds[i];
999 if (NULL != pIcdSurface->real_icd_surfaces[i] &&
1000 NULL != icd->DestroySurfaceKHR) {
1001 icd->DestroySurfaceKHR(
Piers Daniell1ad59912016-09-14 11:24:36 -06001002 icd->instance, pIcdSurface->real_icd_surfaces[i], pAllocator);
Mark Young5467d672016-06-28 10:52:43 -06001003 }
1004 }
1005 loader_instance_heap_free(ptr_instance, pIcdSurface->real_icd_surfaces);
1006 }
1007 loader_instance_heap_free(ptr_instance, pIcdSurface);
1008 }
1009
1010 return vkRes;
Ian Elliott7c352552015-11-19 13:14:05 -07001011}
Ian Elliotte851dd62015-11-24 15:39:10 -07001012
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001013// This is the trampoline entrypoint for
1014// GetPhysicalDeviceXcbPresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001015LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
1016vkGetPhysicalDeviceXcbPresentationSupportKHR(VkPhysicalDevice physicalDevice,
1017 uint32_t queueFamilyIndex,
1018 xcb_connection_t *connection,
1019 xcb_visualid_t visual_id) {
Jon Ashburnfd02a0f2016-03-01 19:51:07 -07001020 VkPhysicalDevice unwrapped_phys_dev =
1021 loader_unwrap_physical_device(physicalDevice);
Ian Elliotte851dd62015-11-24 15:39:10 -07001022 const VkLayerInstanceDispatchTable *disp;
1023 disp = loader_get_instance_dispatch(physicalDevice);
1024 VkBool32 res = disp->GetPhysicalDeviceXcbPresentationSupportKHR(
Jon Ashburnfd02a0f2016-03-01 19:51:07 -07001025 unwrapped_phys_dev, queueFamilyIndex, connection, visual_id);
Ian Elliotte851dd62015-11-24 15:39:10 -07001026 return res;
1027}
1028
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001029// This is the instance chain terminator function for
1030// GetPhysicalDeviceXcbPresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001031VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburnc4e9ae62016-02-26 13:14:27 -07001032terminator_GetPhysicalDeviceXcbPresentationSupportKHR(
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001033 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
1034 xcb_connection_t *connection, xcb_visualid_t visual_id) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001035 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001036 struct loader_physical_device *phys_dev =
1037 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001038 struct loader_instance *ptr_instance =
1039 (struct loader_instance *)phys_dev->this_icd->this_instance;
1040 if (!ptr_instance->wsi_xcb_surface_enabled) {
Jon Ashburnc466da52016-04-15 09:25:03 -06001041 loader_log(
1042 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1043 "VK_KHR_xcb_surface extension not enabled. "
1044 "vkGetPhysicalDeviceXcbPresentationSupportKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001045 return VK_SUCCESS;
1046 }
1047
1048 // Next, if so, proceed with the implementation of this function:
Ian Elliotte851dd62015-11-24 15:39:10 -07001049 struct loader_icd *icd = phys_dev->this_icd;
1050
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001051 assert(
1052 icd->GetPhysicalDeviceXcbPresentationSupportKHR &&
1053 "loader: null GetPhysicalDeviceXcbPresentationSupportKHR ICD pointer");
Ian Elliotte851dd62015-11-24 15:39:10 -07001054
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001055 return icd->GetPhysicalDeviceXcbPresentationSupportKHR(
1056 phys_dev->phys_dev, queueFamilyIndex, connection, visual_id);
Ian Elliotte851dd62015-11-24 15:39:10 -07001057}
Ian Elliott7c352552015-11-19 13:14:05 -07001058#endif // VK_USE_PLATFORM_XCB_KHR
1059
1060#ifdef VK_USE_PLATFORM_XLIB_KHR
1061
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001062// Functions for the VK_KHR_xlib_surface extension:
Ian Elliott7c352552015-11-19 13:14:05 -07001063
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001064// This is the trampoline entrypoint for CreateXlibSurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -06001065LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR(
1066 VkInstance instance, const VkXlibSurfaceCreateInfoKHR *pCreateInfo,
1067 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburn16edfa62015-11-25 17:55:49 -07001068 const VkLayerInstanceDispatchTable *disp;
1069 disp = loader_get_instance_dispatch(instance);
1070 VkResult res;
1071
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001072 res =
1073 disp->CreateXlibSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
Jon Ashburn16edfa62015-11-25 17:55:49 -07001074 return res;
1075}
1076
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001077// This is the instance chain terminator function for CreateXlibSurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -06001078VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXlibSurfaceKHR(
1079 VkInstance instance, const VkXlibSurfaceCreateInfoKHR *pCreateInfo,
1080 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Mark Young5467d672016-06-28 10:52:43 -06001081 VkResult vkRes = VK_SUCCESS;
Mark Youngd7fb1592016-10-12 14:18:44 -06001082 VkIcdSurface *pIcdSurface = NULL;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001083 // First, check to ensure the appropriate extension was enabled:
Ian Elliott1693f592015-11-23 10:17:23 -07001084 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001085 if (!ptr_instance->wsi_xlib_surface_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -06001086 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1087 "VK_KHR_xlib_surface extension not enabled. "
1088 "vkCreateXlibSurfaceKHR not executed!\n");
Mark Young5467d672016-06-28 10:52:43 -06001089 vkRes = VK_ERROR_EXTENSION_NOT_PRESENT;
1090 goto out;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001091 }
1092
1093 // Next, if so, proceed with the implementation of this function:
Mark Youngd7fb1592016-10-12 14:18:44 -06001094 pIcdSurface = AllocateIcdSurfaceStruct(
Mark Youngf27962c2016-09-16 10:18:42 -06001095 ptr_instance, sizeof(pIcdSurface->xlib_surf.base),
1096 sizeof(pIcdSurface->xlib_surf), true);
Ian Elliott7c352552015-11-19 13:14:05 -07001097 if (pIcdSurface == NULL) {
Mark Young5467d672016-06-28 10:52:43 -06001098 vkRes = VK_ERROR_OUT_OF_HOST_MEMORY;
1099 goto out;
Ian Elliott7c352552015-11-19 13:14:05 -07001100 }
1101
Mark Young5467d672016-06-28 10:52:43 -06001102 pIcdSurface->xlib_surf.base.platform = VK_ICD_WSI_PLATFORM_XLIB;
1103 pIcdSurface->xlib_surf.dpy = pCreateInfo->dpy;
1104 pIcdSurface->xlib_surf.window = pCreateInfo->window;
1105
Mark Young5467d672016-06-28 10:52:43 -06001106 // Loop through each ICD and determine if they need to create a surface
1107 for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
1108 if (ptr_instance->icd_libs.list[i].interface_version >=
1109 ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
1110 struct loader_icd *icd = &ptr_instance->icds[i];
1111 if (NULL != icd->CreateXlibSurfaceKHR) {
1112 vkRes = icd->CreateXlibSurfaceKHR(
Piers Daniell1ad59912016-09-14 11:24:36 -06001113 icd->instance, pCreateInfo, pAllocator,
Mark Young5467d672016-06-28 10:52:43 -06001114 &pIcdSurface->real_icd_surfaces[i]);
1115 if (VK_SUCCESS != vkRes) {
1116 goto out;
1117 }
1118 }
1119 }
1120 }
Ian Elliott7c352552015-11-19 13:14:05 -07001121
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001122 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliott7c352552015-11-19 13:14:05 -07001123
Mark Young5467d672016-06-28 10:52:43 -06001124out:
1125
1126 if (VK_SUCCESS != vkRes && NULL != pIcdSurface) {
1127 if (NULL != pIcdSurface->real_icd_surfaces) {
1128 for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
1129 struct loader_icd *icd = &ptr_instance->icds[i];
1130 if (NULL != pIcdSurface->real_icd_surfaces[i] &&
1131 NULL != icd->DestroySurfaceKHR) {
1132 icd->DestroySurfaceKHR(
Piers Daniell1ad59912016-09-14 11:24:36 -06001133 icd->instance, pIcdSurface->real_icd_surfaces[i], pAllocator);
Mark Young5467d672016-06-28 10:52:43 -06001134 }
1135 }
1136 loader_instance_heap_free(ptr_instance, pIcdSurface->real_icd_surfaces);
1137 }
1138 loader_instance_heap_free(ptr_instance, pIcdSurface);
1139 }
1140
1141 return vkRes;
Ian Elliott7c352552015-11-19 13:14:05 -07001142}
Ian Elliotte851dd62015-11-24 15:39:10 -07001143
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001144// This is the trampoline entrypoint for GetPhysicalDeviceXlibPresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001145LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
1146vkGetPhysicalDeviceXlibPresentationSupportKHR(VkPhysicalDevice physicalDevice,
1147 uint32_t queueFamilyIndex,
1148 Display *dpy, VisualID visualID) {
Jon Ashburnfd02a0f2016-03-01 19:51:07 -07001149 VkPhysicalDevice unwrapped_phys_dev =
1150 loader_unwrap_physical_device(physicalDevice);
Ian Elliotte851dd62015-11-24 15:39:10 -07001151 const VkLayerInstanceDispatchTable *disp;
1152 disp = loader_get_instance_dispatch(physicalDevice);
1153 VkBool32 res = disp->GetPhysicalDeviceXlibPresentationSupportKHR(
Jon Ashburnfd02a0f2016-03-01 19:51:07 -07001154 unwrapped_phys_dev, queueFamilyIndex, dpy, visualID);
Ian Elliotte851dd62015-11-24 15:39:10 -07001155 return res;
1156}
1157
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001158// This is the instance chain terminator function for
1159// GetPhysicalDeviceXlibPresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001160VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburnc4e9ae62016-02-26 13:14:27 -07001161terminator_GetPhysicalDeviceXlibPresentationSupportKHR(
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001162 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, Display *dpy,
1163 VisualID visualID) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001164 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001165 struct loader_physical_device *phys_dev =
1166 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001167 struct loader_instance *ptr_instance =
1168 (struct loader_instance *)phys_dev->this_icd->this_instance;
1169 if (!ptr_instance->wsi_xlib_surface_enabled) {
Jon Ashburnc466da52016-04-15 09:25:03 -06001170 loader_log(
1171 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1172 "VK_KHR_xlib_surface extension not enabled. "
1173 "vkGetPhysicalDeviceXlibPresentationSupportKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001174 return VK_SUCCESS;
1175 }
1176
1177 // Next, if so, proceed with the implementation of this function:
Ian Elliotte851dd62015-11-24 15:39:10 -07001178 struct loader_icd *icd = phys_dev->this_icd;
1179
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001180 assert(
1181 icd->GetPhysicalDeviceXlibPresentationSupportKHR &&
1182 "loader: null GetPhysicalDeviceXlibPresentationSupportKHR ICD pointer");
Ian Elliotte851dd62015-11-24 15:39:10 -07001183
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001184 return icd->GetPhysicalDeviceXlibPresentationSupportKHR(
1185 phys_dev->phys_dev, queueFamilyIndex, dpy, visualID);
Ian Elliotte851dd62015-11-24 15:39:10 -07001186}
Ian Elliott7c352552015-11-19 13:14:05 -07001187#endif // VK_USE_PLATFORM_XLIB_KHR
1188
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -07001189#ifdef VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott7c352552015-11-19 13:14:05 -07001190
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -07001191
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001192// Functions for the VK_KHR_android_surface extension:
1193
1194// This is the trampoline entrypoint for CreateAndroidSurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -06001195LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateAndroidSurfaceKHR(
1196 VkInstance instance, ANativeWindow *window,
1197 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -07001198 const VkLayerInstanceDispatchTable *disp;
1199 disp = loader_get_instance_dispatch(instance);
1200 VkResult res;
1201
1202 res = disp->CreateAndroidSurfaceKHR(instance, window, pAllocator, pSurface);
1203 return res;
1204}
1205
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001206// This is the instance chain terminator function for CreateAndroidSurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -06001207VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateAndroidSurfaceKHR(
1208 VkInstance instance, Window window, const VkAllocationCallbacks *pAllocator,
1209 VkSurfaceKHR *pSurface) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001210 // First, check to ensure the appropriate extension was enabled:
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -07001211 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001212 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -06001213 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1214 "VK_KHR_display extension not enabled. "
1215 "vkCreateAndroidSurfaceKHR not executed!\n");
Jeremy Hayes0231e1c2016-06-14 11:50:02 -06001216 return VK_ERROR_EXTENSION_NOT_PRESENT;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001217 }
1218
1219 // Next, if so, proceed with the implementation of this function:
Mark Young5467d672016-06-28 10:52:43 -06001220 VkIcdSurfaceAndroid *pIcdSurface =
Mark Young74dd5d12016-06-30 13:02:42 -06001221 loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceAndroid),
Mark Young5467d672016-06-28 10:52:43 -06001222 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -07001223 if (pIcdSurface == NULL) {
1224 return VK_ERROR_OUT_OF_HOST_MEMORY;
1225 }
1226
1227 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_ANDROID;
1228 pIcdSurface->dpy = dpy;
1229 pIcdSurface->window = window;
1230
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001231 *pSurface = (VkSurfaceKHR)pIcdSurface;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -07001232
1233 return VK_SUCCESS;
1234}
1235
1236#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott7c352552015-11-19 13:14:05 -07001237
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001238
1239// Functions for the VK_KHR_display instance extension:
Jon Ashburncc370d02016-03-08 09:30:30 -07001240LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburnc466da52016-04-15 09:25:03 -06001241vkGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice,
1242 uint32_t *pPropertyCount,
1243 VkDisplayPropertiesKHR *pProperties) {
Jon Ashburncc370d02016-03-08 09:30:30 -07001244 VkPhysicalDevice unwrapped_phys_dev =
1245 loader_unwrap_physical_device(physicalDevice);
1246 const VkLayerInstanceDispatchTable *disp;
1247 disp = loader_get_instance_dispatch(physicalDevice);
1248 VkResult res = disp->GetPhysicalDeviceDisplayPropertiesKHR(
1249 unwrapped_phys_dev, pPropertyCount, pProperties);
1250 return res;
1251}
1252
Jon Ashburnc466da52016-04-15 09:25:03 -06001253VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceDisplayPropertiesKHR(
1254 VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
1255 VkDisplayPropertiesKHR *pProperties) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001256 // First, check to ensure the appropriate extension was enabled:
Jon Ashburncc370d02016-03-08 09:30:30 -07001257 struct loader_physical_device *phys_dev =
1258 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001259 struct loader_instance *ptr_instance =
1260 (struct loader_instance *)phys_dev->this_icd->this_instance;
1261 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -06001262 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1263 "VK_KHR_display extension not enabled. "
1264 "vkGetPhysicalDeviceDisplayPropertiesKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001265 return VK_SUCCESS;
1266 }
1267
1268 // Next, if so, proceed with the implementation of this function:
Jon Ashburncc370d02016-03-08 09:30:30 -07001269 struct loader_icd *icd = phys_dev->this_icd;
1270
Jon Ashburnc466da52016-04-15 09:25:03 -06001271 assert(icd->GetPhysicalDeviceDisplayPropertiesKHR &&
1272 "loader: null GetPhysicalDeviceDisplayPropertiesKHR ICD pointer");
Jon Ashburncc370d02016-03-08 09:30:30 -07001273
1274 return icd->GetPhysicalDeviceDisplayPropertiesKHR(
1275 phys_dev->phys_dev, pPropertyCount, pProperties);
1276}
1277
1278LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1279vkGetPhysicalDeviceDisplayPlanePropertiesKHR(
Jon Ashburnc466da52016-04-15 09:25:03 -06001280 VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
1281 VkDisplayPlanePropertiesKHR *pProperties) {
Jon Ashburncc370d02016-03-08 09:30:30 -07001282 VkPhysicalDevice unwrapped_phys_dev =
1283 loader_unwrap_physical_device(physicalDevice);
1284 const VkLayerInstanceDispatchTable *disp;
1285 disp = loader_get_instance_dispatch(physicalDevice);
1286 VkResult res = disp->GetPhysicalDeviceDisplayPlanePropertiesKHR(
1287 unwrapped_phys_dev, pPropertyCount, pProperties);
1288 return res;
1289}
1290
1291VKAPI_ATTR VkResult VKAPI_CALL
1292terminator_GetPhysicalDeviceDisplayPlanePropertiesKHR(
Jon Ashburnc466da52016-04-15 09:25:03 -06001293 VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
1294 VkDisplayPlanePropertiesKHR *pProperties) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001295 // First, check to ensure the appropriate extension was enabled:
Jon Ashburncc370d02016-03-08 09:30:30 -07001296 struct loader_physical_device *phys_dev =
1297 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001298 struct loader_instance *ptr_instance =
1299 (struct loader_instance *)phys_dev->this_icd->this_instance;
1300 if (!ptr_instance->wsi_display_enabled) {
Jon Ashburnc466da52016-04-15 09:25:03 -06001301 loader_log(
1302 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1303 "VK_KHR_display extension not enabled. "
1304 "vkGetPhysicalDeviceDisplayPlanePropertiesKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001305 return VK_SUCCESS;
1306 }
1307
1308 // Next, if so, proceed with the implementation of this function:
Jon Ashburncc370d02016-03-08 09:30:30 -07001309 struct loader_icd *icd = phys_dev->this_icd;
1310
1311 assert(
1312 icd->GetPhysicalDeviceDisplayPlanePropertiesKHR &&
1313 "loader: null GetPhysicalDeviceDisplayPlanePropertiesKHR ICD pointer");
1314
1315 return icd->GetPhysicalDeviceDisplayPlanePropertiesKHR(
1316 phys_dev->phys_dev, pPropertyCount, pProperties);
1317}
1318
1319LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburnc466da52016-04-15 09:25:03 -06001320vkGetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice,
1321 uint32_t planeIndex,
1322 uint32_t *pDisplayCount,
1323 VkDisplayKHR *pDisplays) {
Jon Ashburncc370d02016-03-08 09:30:30 -07001324 VkPhysicalDevice unwrapped_phys_dev =
1325 loader_unwrap_physical_device(physicalDevice);
1326 const VkLayerInstanceDispatchTable *disp;
1327 disp = loader_get_instance_dispatch(physicalDevice);
1328 VkResult res = disp->GetDisplayPlaneSupportedDisplaysKHR(
1329 unwrapped_phys_dev, planeIndex, pDisplayCount, pDisplays);
1330 return res;
1331}
1332
Mark Young5467d672016-06-28 10:52:43 -06001333VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayPlaneSupportedDisplaysKHR(
1334 VkPhysicalDevice physicalDevice, uint32_t planeIndex,
1335 uint32_t *pDisplayCount, VkDisplayKHR *pDisplays) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001336 // First, check to ensure the appropriate extension was enabled:
Jon Ashburncc370d02016-03-08 09:30:30 -07001337 struct loader_physical_device *phys_dev =
1338 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001339 struct loader_instance *ptr_instance =
1340 (struct loader_instance *)phys_dev->this_icd->this_instance;
1341 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -06001342 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1343 "VK_KHR_display extension not enabled. "
1344 "vkGetDisplayPlaneSupportedDisplaysKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001345 return VK_SUCCESS;
1346 }
1347
1348 // Next, if so, proceed with the implementation of this function:
Jon Ashburncc370d02016-03-08 09:30:30 -07001349 struct loader_icd *icd = phys_dev->this_icd;
1350
Jon Ashburnc466da52016-04-15 09:25:03 -06001351 assert(icd->GetDisplayPlaneSupportedDisplaysKHR &&
1352 "loader: null GetDisplayPlaneSupportedDisplaysKHR ICD pointer");
Jon Ashburncc370d02016-03-08 09:30:30 -07001353
1354 return icd->GetDisplayPlaneSupportedDisplaysKHR(
1355 phys_dev->phys_dev, planeIndex, pDisplayCount, pDisplays);
1356}
1357
Mark Young5467d672016-06-28 10:52:43 -06001358LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayModePropertiesKHR(
1359 VkPhysicalDevice physicalDevice, VkDisplayKHR display,
1360 uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties) {
Jon Ashburncc370d02016-03-08 09:30:30 -07001361 VkPhysicalDevice unwrapped_phys_dev =
1362 loader_unwrap_physical_device(physicalDevice);
1363 const VkLayerInstanceDispatchTable *disp;
1364 disp = loader_get_instance_dispatch(physicalDevice);
1365 VkResult res = disp->GetDisplayModePropertiesKHR(
1366 unwrapped_phys_dev, display, pPropertyCount, pProperties);
1367 return res;
1368}
1369
Jon Ashburnc466da52016-04-15 09:25:03 -06001370VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayModePropertiesKHR(
1371 VkPhysicalDevice physicalDevice, VkDisplayKHR display,
1372 uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001373 // First, check to ensure the appropriate extension was enabled:
Jon Ashburncc370d02016-03-08 09:30:30 -07001374 struct loader_physical_device *phys_dev =
1375 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001376 struct loader_instance *ptr_instance =
1377 (struct loader_instance *)phys_dev->this_icd->this_instance;
1378 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -06001379 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1380 "VK_KHR_display extension not enabled. "
1381 "vkGetDisplayModePropertiesKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001382 return VK_SUCCESS;
1383 }
1384
1385 // Next, if so, proceed with the implementation of this function:
Jon Ashburncc370d02016-03-08 09:30:30 -07001386 struct loader_icd *icd = phys_dev->this_icd;
1387
Jon Ashburnc466da52016-04-15 09:25:03 -06001388 assert(icd->GetDisplayModePropertiesKHR &&
1389 "loader: null GetDisplayModePropertiesKHR ICD pointer");
Jon Ashburncc370d02016-03-08 09:30:30 -07001390
Jon Ashburnc466da52016-04-15 09:25:03 -06001391 return icd->GetDisplayModePropertiesKHR(phys_dev->phys_dev, display,
1392 pPropertyCount, pProperties);
Jon Ashburncc370d02016-03-08 09:30:30 -07001393}
1394
Mark Young74dd5d12016-06-30 13:02:42 -06001395LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayModeKHR(
1396 VkPhysicalDevice physicalDevice, VkDisplayKHR display,
1397 const VkDisplayModeCreateInfoKHR *pCreateInfo,
1398 const VkAllocationCallbacks *pAllocator, VkDisplayModeKHR *pMode) {
Jon Ashburncc370d02016-03-08 09:30:30 -07001399 VkPhysicalDevice unwrapped_phys_dev =
1400 loader_unwrap_physical_device(physicalDevice);
1401 const VkLayerInstanceDispatchTable *disp;
1402 disp = loader_get_instance_dispatch(physicalDevice);
Jon Ashburnc466da52016-04-15 09:25:03 -06001403 VkResult res = disp->CreateDisplayModeKHR(unwrapped_phys_dev, display,
1404 pCreateInfo, pAllocator, pMode);
Jon Ashburncc370d02016-03-08 09:30:30 -07001405 return res;
1406}
1407
Mark Young74dd5d12016-06-30 13:02:42 -06001408VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayModeKHR(
1409 VkPhysicalDevice physicalDevice, VkDisplayKHR display,
1410 const VkDisplayModeCreateInfoKHR *pCreateInfo,
1411 const VkAllocationCallbacks *pAllocator, VkDisplayModeKHR *pMode) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001412 // First, check to ensure the appropriate extension was enabled:
Jon Ashburncc370d02016-03-08 09:30:30 -07001413 struct loader_physical_device *phys_dev =
1414 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001415 struct loader_instance *ptr_instance =
1416 (struct loader_instance *)phys_dev->this_icd->this_instance;
1417 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -06001418 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1419 "VK_KHR_display extension not enabled. "
1420 "vkCreateDisplayModeKHR not executed!\n");
Jeremy Hayes0231e1c2016-06-14 11:50:02 -06001421 return VK_ERROR_EXTENSION_NOT_PRESENT;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001422 }
1423
1424 // Next, if so, proceed with the implementation of this function:
Jon Ashburncc370d02016-03-08 09:30:30 -07001425 struct loader_icd *icd = phys_dev->this_icd;
1426
Jon Ashburnc466da52016-04-15 09:25:03 -06001427 assert(icd->CreateDisplayModeKHR &&
1428 "loader: null CreateDisplayModeKHR ICD pointer");
Jon Ashburncc370d02016-03-08 09:30:30 -07001429
Jon Ashburnc466da52016-04-15 09:25:03 -06001430 return icd->CreateDisplayModeKHR(phys_dev->phys_dev, display, pCreateInfo,
1431 pAllocator, pMode);
Jon Ashburncc370d02016-03-08 09:30:30 -07001432}
1433
Mark Young5467d672016-06-28 10:52:43 -06001434LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayPlaneCapabilitiesKHR(
1435 VkPhysicalDevice physicalDevice, VkDisplayModeKHR mode, uint32_t planeIndex,
1436 VkDisplayPlaneCapabilitiesKHR *pCapabilities) {
Jon Ashburncc370d02016-03-08 09:30:30 -07001437 VkPhysicalDevice unwrapped_phys_dev =
1438 loader_unwrap_physical_device(physicalDevice);
1439 const VkLayerInstanceDispatchTable *disp;
1440 disp = loader_get_instance_dispatch(physicalDevice);
1441 VkResult res = disp->GetDisplayPlaneCapabilitiesKHR(
1442 unwrapped_phys_dev, mode, planeIndex, pCapabilities);
1443 return res;
1444}
1445
Jon Ashburnc466da52016-04-15 09:25:03 -06001446VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayPlaneCapabilitiesKHR(
1447 VkPhysicalDevice physicalDevice, VkDisplayModeKHR mode, uint32_t planeIndex,
1448 VkDisplayPlaneCapabilitiesKHR *pCapabilities) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001449 // First, check to ensure the appropriate extension was enabled:
Jon Ashburncc370d02016-03-08 09:30:30 -07001450 struct loader_physical_device *phys_dev =
1451 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001452 struct loader_instance *ptr_instance =
1453 (struct loader_instance *)phys_dev->this_icd->this_instance;
1454 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -06001455 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1456 "VK_KHR_display extension not enabled. "
1457 "vkGetDisplayPlaneCapabilitiesKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001458 return VK_SUCCESS;
1459 }
1460
1461 // Next, if so, proceed with the implementation of this function:
Jon Ashburncc370d02016-03-08 09:30:30 -07001462 struct loader_icd *icd = phys_dev->this_icd;
1463
Jon Ashburnc466da52016-04-15 09:25:03 -06001464 assert(icd->GetDisplayPlaneCapabilitiesKHR &&
1465 "loader: null GetDisplayPlaneCapabilitiesKHR ICD pointer");
Jon Ashburncc370d02016-03-08 09:30:30 -07001466
Jon Ashburnc466da52016-04-15 09:25:03 -06001467 return icd->GetDisplayPlaneCapabilitiesKHR(phys_dev->phys_dev, mode,
1468 planeIndex, pCapabilities);
Jon Ashburncc370d02016-03-08 09:30:30 -07001469}
1470
Mark Young74dd5d12016-06-30 13:02:42 -06001471LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayPlaneSurfaceKHR(
1472 VkInstance instance, const VkDisplaySurfaceCreateInfoKHR *pCreateInfo,
1473 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburncc370d02016-03-08 09:30:30 -07001474 const VkLayerInstanceDispatchTable *disp;
1475 disp = loader_get_instance_dispatch(instance);
1476 VkResult res;
1477
1478 res = disp->CreateDisplayPlaneSurfaceKHR(instance, pCreateInfo, pAllocator,
1479 pSurface);
1480 return res;
1481}
1482
Jon Ashburnc466da52016-04-15 09:25:03 -06001483VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayPlaneSurfaceKHR(
1484 VkInstance instance, const VkDisplaySurfaceCreateInfoKHR *pCreateInfo,
1485 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburncc370d02016-03-08 09:30:30 -07001486 struct loader_instance *inst = loader_get_instance(instance);
Mark Young5467d672016-06-28 10:52:43 -06001487 VkIcdSurface *pIcdSurface = NULL;
Mark Youngf06def92016-11-01 19:20:41 -06001488 VkResult vkRes = VK_SUCCESS;
Jon Ashburncc370d02016-03-08 09:30:30 -07001489
Mark Youngf06def92016-11-01 19:20:41 -06001490 if (!inst->wsi_display_enabled) {
Petros Bantolasf3095862016-04-14 12:50:42 +01001491 loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1492 "VK_KHR_surface extension not enabled. "
1493 "vkCreateDisplayPlaneSurfaceKHR not executed!\n");
Mark Youngf06def92016-11-01 19:20:41 -06001494 vkRes = VK_ERROR_EXTENSION_NOT_PRESENT;
1495 goto out;
Petros Bantolasf3095862016-04-14 12:50:42 +01001496 }
1497
Mark Youngf27962c2016-09-16 10:18:42 -06001498 // The VK_KHR_display path will continue to use the old path (hence the
1499 // false as the last parameter).
1500 pIcdSurface =
1501 AllocateIcdSurfaceStruct(inst, sizeof(pIcdSurface->display_surf.base),
1502 sizeof(pIcdSurface->display_surf), false);
Jon Ashburncc370d02016-03-08 09:30:30 -07001503 if (pIcdSurface == NULL) {
Mark Youngf06def92016-11-01 19:20:41 -06001504 vkRes = VK_ERROR_OUT_OF_HOST_MEMORY;
1505 goto out;
Jon Ashburncc370d02016-03-08 09:30:30 -07001506 }
1507
Mark Young5467d672016-06-28 10:52:43 -06001508 pIcdSurface->display_surf.base.platform = VK_ICD_WSI_PLATFORM_DISPLAY;
1509 pIcdSurface->display_surf.displayMode = pCreateInfo->displayMode;
1510 pIcdSurface->display_surf.planeIndex = pCreateInfo->planeIndex;
1511 pIcdSurface->display_surf.planeStackIndex = pCreateInfo->planeStackIndex;
1512 pIcdSurface->display_surf.transform = pCreateInfo->transform;
1513 pIcdSurface->display_surf.globalAlpha = pCreateInfo->globalAlpha;
1514 pIcdSurface->display_surf.alphaMode = pCreateInfo->alphaMode;
1515 pIcdSurface->display_surf.imageExtent = pCreateInfo->imageExtent;
1516
Mark Youngf06def92016-11-01 19:20:41 -06001517 // Loop through each ICD and determine if they need to create a surface
1518 for (uint32_t i = 0; i < inst->total_icd_count; i++) {
1519 if (inst->icd_libs.list[i].interface_version >=
1520 ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
1521 struct loader_icd *icd = &inst->icds[i];
1522 if (NULL != icd->CreateDisplayPlaneSurfaceKHR) {
1523 vkRes = icd->CreateDisplayPlaneSurfaceKHR(
1524 icd->instance, pCreateInfo, pAllocator,
1525 &pIcdSurface->real_icd_surfaces[i]);
1526 if (VK_SUCCESS != vkRes) {
1527 goto out;
1528 }
1529 }
1530 }
1531 }
1532
Jon Ashburncc370d02016-03-08 09:30:30 -07001533 *pSurface = (VkSurfaceKHR)pIcdSurface;
1534
Mark Youngf06def92016-11-01 19:20:41 -06001535out:
1536
1537 if (VK_SUCCESS != vkRes && NULL != pIcdSurface) {
1538 if (NULL != pIcdSurface->real_icd_surfaces) {
1539 for (uint32_t i = 0; i < inst->total_icd_count; i++) {
1540 struct loader_icd *icd = &inst->icds[i];
1541 if (NULL != (void *)pIcdSurface->real_icd_surfaces[i] &&
1542 NULL != icd->DestroySurfaceKHR) {
1543 icd->DestroySurfaceKHR(icd->instance,
1544 pIcdSurface->real_icd_surfaces[i],
1545 pAllocator);
1546 }
1547 }
1548 loader_instance_heap_free(inst, pIcdSurface->real_icd_surfaces);
1549 }
1550 loader_instance_heap_free(inst, pIcdSurface);
1551 }
1552
1553 return vkRes;
Jon Ashburncc370d02016-03-08 09:30:30 -07001554}
1555
Mark Youngf2eabea2016-07-01 15:18:27 -06001556// This is the trampoline entrypoint
1557// for CreateSharedSwapchainsKHR
1558LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSharedSwapchainsKHR(
1559 VkDevice device, uint32_t swapchainCount,
1560 const VkSwapchainCreateInfoKHR *pCreateInfos,
1561 const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchains) {
Mark Young2a2122f2016-09-08 18:36:32 -06001562 const VkLayerDispatchTable *disp;
1563 disp = loader_get_dispatch(device);
1564 return disp->CreateSharedSwapchainsKHR(device, swapchainCount, pCreateInfos, pAllocator, pSwapchains);
Mark Youngf2eabea2016-07-01 15:18:27 -06001565}
1566
Ian Elliott54cea232015-10-30 15:28:23 -06001567bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance,
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001568 const char *name, void **addr) {
Ian Elliott54cea232015-10-30 15:28:23 -06001569 *addr = NULL;
1570
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001571 // Functions for the VK_KHR_surface extension:
Ian Elliott7c352552015-11-19 13:14:05 -07001572 if (!strcmp("vkDestroySurfaceKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001573 *addr = ptr_instance->wsi_surface_enabled ? (void *)vkDestroySurfaceKHR
1574 : NULL;
Ian Elliott7c352552015-11-19 13:14:05 -07001575 return true;
1576 }
Ian Elliott54cea232015-10-30 15:28:23 -06001577 if (!strcmp("vkGetPhysicalDeviceSurfaceSupportKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001578 *addr = ptr_instance->wsi_surface_enabled
1579 ? (void *)vkGetPhysicalDeviceSurfaceSupportKHR
1580 : NULL;
Ian Elliott54cea232015-10-30 15:28:23 -06001581 return true;
1582 }
Ian Elliottea666b22015-11-19 16:05:09 -07001583 if (!strcmp("vkGetPhysicalDeviceSurfaceCapabilitiesKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001584 *addr = ptr_instance->wsi_surface_enabled
1585 ? (void *)vkGetPhysicalDeviceSurfaceCapabilitiesKHR
1586 : NULL;
Ian Elliottea666b22015-11-19 16:05:09 -07001587 return true;
1588 }
1589 if (!strcmp("vkGetPhysicalDeviceSurfaceFormatsKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001590 *addr = ptr_instance->wsi_surface_enabled
1591 ? (void *)vkGetPhysicalDeviceSurfaceFormatsKHR
1592 : NULL;
Ian Elliottea666b22015-11-19 16:05:09 -07001593 return true;
1594 }
1595 if (!strcmp("vkGetPhysicalDeviceSurfacePresentModesKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001596 *addr = ptr_instance->wsi_surface_enabled
1597 ? (void *)vkGetPhysicalDeviceSurfacePresentModesKHR
1598 : NULL;
Ian Elliottea666b22015-11-19 16:05:09 -07001599 return true;
1600 }
Ian Elliott9b89a472015-11-19 16:39:21 -07001601
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001602 // Functions for the VK_KHR_swapchain extension:
1603
1604 // Note: This is a device extension, and its functions are statically
1605 // exported from the loader. Per Khronos decisions, the loader's GIPA
1606 // function will return the trampoline function for such device-extension
1607 // functions, regardless of whether the extension has been enabled.
Ian Elliott9b89a472015-11-19 16:39:21 -07001608 if (!strcmp("vkCreateSwapchainKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001609 *addr = (void *)vkCreateSwapchainKHR;
Ian Elliott9b89a472015-11-19 16:39:21 -07001610 return true;
1611 }
1612 if (!strcmp("vkDestroySwapchainKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001613 *addr = (void *)vkDestroySwapchainKHR;
Ian Elliott9b89a472015-11-19 16:39:21 -07001614 return true;
1615 }
1616 if (!strcmp("vkGetSwapchainImagesKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001617 *addr = (void *)vkGetSwapchainImagesKHR;
Ian Elliott9b89a472015-11-19 16:39:21 -07001618 return true;
1619 }
1620 if (!strcmp("vkAcquireNextImageKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001621 *addr = (void *)vkAcquireNextImageKHR;
Ian Elliott9b89a472015-11-19 16:39:21 -07001622 return true;
1623 }
1624 if (!strcmp("vkQueuePresentKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001625 *addr = (void *)vkQueuePresentKHR;
Ian Elliott9b89a472015-11-19 16:39:21 -07001626 return true;
1627 }
1628
Ian Elliott7c352552015-11-19 13:14:05 -07001629#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001630
1631 // Functions for the VK_KHR_win32_surface extension:
Ian Elliott7c352552015-11-19 13:14:05 -07001632 if (!strcmp("vkCreateWin32SurfaceKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001633 *addr = ptr_instance->wsi_win32_surface_enabled
1634 ? (void *)vkCreateWin32SurfaceKHR
1635 : NULL;
Ian Elliott7c352552015-11-19 13:14:05 -07001636 return true;
1637 }
Ian Elliotte851dd62015-11-24 15:39:10 -07001638 if (!strcmp("vkGetPhysicalDeviceWin32PresentationSupportKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001639 *addr = ptr_instance->wsi_win32_surface_enabled
1640 ? (void *)vkGetPhysicalDeviceWin32PresentationSupportKHR
1641 : NULL;
Ian Elliotte851dd62015-11-24 15:39:10 -07001642 return true;
1643 }
Ian Elliott7c352552015-11-19 13:14:05 -07001644#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliott7c352552015-11-19 13:14:05 -07001645#ifdef VK_USE_PLATFORM_MIR_KHR
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001646
1647 // Functions for the VK_KHR_mir_surface extension:
Ian Elliott7c352552015-11-19 13:14:05 -07001648 if (!strcmp("vkCreateMirSurfaceKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001649 *addr = ptr_instance->wsi_mir_surface_enabled
1650 ? (void *)vkCreateMirSurfaceKHR
1651 : NULL;
Ian Elliott7c352552015-11-19 13:14:05 -07001652 return true;
1653 }
Ian Elliotte851dd62015-11-24 15:39:10 -07001654 if (!strcmp("vkGetPhysicalDeviceMirPresentationSupportKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001655 *addr = ptr_instance->wsi_mir_surface_enabled
1656 ? (void *)vkGetPhysicalDeviceMirPresentationSupportKHR
1657 : NULL;
Ian Elliotte851dd62015-11-24 15:39:10 -07001658 return true;
Jason Ekstrand3bfebc92016-02-12 17:25:03 -08001659 }
Ian Elliott7c352552015-11-19 13:14:05 -07001660#endif // VK_USE_PLATFORM_MIR_KHR
1661#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001662
1663 // Functions for the VK_KHR_wayland_surface extension:
Jon Ashburnc4e9ae62016-02-26 13:14:27 -07001664 if (!strcmp("vkCreateWaylandSurfaceKHR", name)) {
1665 *addr = ptr_instance->wsi_wayland_surface_enabled
1666 ? (void *)vkCreateWaylandSurfaceKHR
1667 : NULL;
1668 return true;
1669 }
1670 if (!strcmp("vkGetPhysicalDeviceWaylandPresentationSupportKHR", name)) {
1671 *addr = ptr_instance->wsi_wayland_surface_enabled
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001672 ? (void *)vkGetPhysicalDeviceWaylandPresentationSupportKHR
1673 : NULL;
Jon Ashburnc4e9ae62016-02-26 13:14:27 -07001674 return true;
1675 }
Ian Elliott7c352552015-11-19 13:14:05 -07001676#endif // VK_USE_PLATFORM_WAYLAND_KHR
1677#ifdef VK_USE_PLATFORM_XCB_KHR
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001678
1679 // Functions for the VK_KHR_xcb_surface extension:
Jon Ashburnc4e9ae62016-02-26 13:14:27 -07001680 if (!strcmp("vkCreateXcbSurfaceKHR", name)) {
1681 *addr = ptr_instance->wsi_xcb_surface_enabled
1682 ? (void *)vkCreateXcbSurfaceKHR
1683 : NULL;
1684 return true;
1685 }
1686 if (!strcmp("vkGetPhysicalDeviceXcbPresentationSupportKHR", name)) {
1687 *addr = ptr_instance->wsi_xcb_surface_enabled
1688 ? (void *)vkGetPhysicalDeviceXcbPresentationSupportKHR
1689 : NULL;
1690 return true;
1691 }
Ian Elliott7c352552015-11-19 13:14:05 -07001692#endif // VK_USE_PLATFORM_XCB_KHR
1693#ifdef VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001694
1695 // Functions for the VK_KHR_xlib_surface extension:
Jon Ashburnc4e9ae62016-02-26 13:14:27 -07001696 if (!strcmp("vkCreateXlibSurfaceKHR", name)) {
1697 *addr = ptr_instance->wsi_xlib_surface_enabled
1698 ? (void *)vkCreateXlibSurfaceKHR
1699 : NULL;
1700 return true;
1701 }
1702 if (!strcmp("vkGetPhysicalDeviceXlibPresentationSupportKHR", name)) {
1703 *addr = ptr_instance->wsi_xlib_surface_enabled
1704 ? (void *)vkGetPhysicalDeviceXlibPresentationSupportKHR
1705 : NULL;
1706 return true;
1707 }
Ian Elliott7c352552015-11-19 13:14:05 -07001708#endif // VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -07001709#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001710
1711 // Functions for the VK_KHR_android_surface extension:
Jon Ashburnc4e9ae62016-02-26 13:14:27 -07001712 if (!strcmp("vkCreateAndroidSurfaceKHR", name)) {
1713 *addr = ptr_instance->wsi_xlib_surface_enabled
1714 ? (void *)vkCreateAndroidSurfaceKHR
1715 : NULL;
1716 return true;
1717 }
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -07001718#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott7c352552015-11-19 13:14:05 -07001719
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001720 // Functions for VK_KHR_display extension:
Jon Ashburncc370d02016-03-08 09:30:30 -07001721 if (!strcmp("vkGetPhysicalDeviceDisplayPropertiesKHR", name)) {
1722 *addr = ptr_instance->wsi_display_enabled
1723 ? (void *)vkGetPhysicalDeviceDisplayPropertiesKHR
1724 : NULL;
1725 return true;
1726 }
1727 if (!strcmp("vkGetPhysicalDeviceDisplayPlanePropertiesKHR", name)) {
1728 *addr = ptr_instance->wsi_display_enabled
1729 ? (void *)vkGetPhysicalDeviceDisplayPlanePropertiesKHR
1730 : NULL;
1731 return true;
1732 }
1733 if (!strcmp("vkGetDisplayPlaneSupportedDisplaysKHR", name)) {
1734 *addr = ptr_instance->wsi_display_enabled
1735 ? (void *)vkGetDisplayPlaneSupportedDisplaysKHR
1736 : NULL;
1737 return true;
1738 }
1739 if (!strcmp("vkGetDisplayModePropertiesKHR", name)) {
1740 *addr = ptr_instance->wsi_display_enabled
1741 ? (void *)vkGetDisplayModePropertiesKHR
1742 : NULL;
1743 return true;
1744 }
1745 if (!strcmp("vkCreateDisplayModeKHR", name)) {
1746 *addr = ptr_instance->wsi_display_enabled
1747 ? (void *)vkCreateDisplayModeKHR
1748 : NULL;
1749 return true;
1750 }
1751 if (!strcmp("vkGetDisplayPlaneCapabilitiesKHR", name)) {
1752 *addr = ptr_instance->wsi_display_enabled
1753 ? (void *)vkGetDisplayPlaneCapabilitiesKHR
1754 : NULL;
1755 return true;
1756 }
1757 if (!strcmp("vkCreateDisplayPlaneSurfaceKHR", name)) {
1758 *addr = ptr_instance->wsi_display_enabled
1759 ? (void *)vkCreateDisplayPlaneSurfaceKHR
1760 : NULL;
1761 return true;
1762 }
Mark Youngf2eabea2016-07-01 15:18:27 -06001763
1764 // Functions for KHR_display_swapchain extension:
1765 if (!strcmp("vkCreateSharedSwapchainsKHR", name)) {
1766 *addr = (void *)vkCreateSharedSwapchainsKHR;
1767 return true;
1768 }
1769
Jon Ashburnc4e9ae62016-02-26 13:14:27 -07001770 return false;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001771}