blob: 9bac94b0b03548d8bac275e9a6e0e619447b3192 [file] [log] [blame]
Ian Elliott954fa342015-10-30 15:28:23 -06001/*
Jon Ashburn23d36b12016-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 Elliott954fa342015-10-30 15:28:23 -06005 *
Jon Ashburn3ebf1252016-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 Elliott954fa342015-10-30 15:28:23 -06009 *
Jon Ashburn3ebf1252016-04-19 11:30:31 -060010 * http://www.apache.org/licenses/LICENSE-2.0
Ian Elliott954fa342015-10-30 15:28:23 -060011 *
Jon Ashburn3ebf1252016-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 Elliott954fa342015-10-30 15:28:23 -060017 *
18 * Author: Ian Elliott <ian@lunarg.com>
Jon Ashburn23d36b12016-02-02 17:47:28 -070019 * Author: Jon Ashburn <jon@lunarg.com>
Ian Elliottc2e9aee2015-11-19 11:58:08 -070020 * Author: Ian Elliott <ianelliott@google.com>
Jon Ashburn23d36b12016-02-02 17:47:28 -070021 * Author: Mark Lobodzinski <mark@lunarg.com>
Ian Elliott954fa342015-10-30 15:28:23 -060022 */
23
24//#define _ISOC11_SOURCE /* for aligned_alloc() */
25#define _GNU_SOURCE
Ian Elliott2b8965a2016-03-24 13:59:22 -060026#include <stdio.h>
Ian Elliott954fa342015-10-30 15:28:23 -060027#include <stdlib.h>
28#include <string.h>
29#include "vk_loader_platform.h"
30#include "loader.h"
31#include "wsi.h"
Ian Elliott2c05e222015-11-19 13:14:05 -070032#include <vulkan/vk_icd.h>
Ian Elliott954fa342015-10-30 15:28:23 -060033
34static const VkExtensionProperties wsi_surface_extension_info = {
Jon Ashburn23d36b12016-02-02 17:47:28 -070035 .extensionName = VK_KHR_SURFACE_EXTENSION_NAME,
36 .specVersion = VK_KHR_SURFACE_SPEC_VERSION,
Ian Elliott954fa342015-10-30 15:28:23 -060037};
38
Ian Elliottc2e9aee2015-11-19 11:58:08 -070039#ifdef VK_USE_PLATFORM_WIN32_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060040static const VkExtensionProperties wsi_win32_surface_extension_info = {
Jon Ashburn23d36b12016-02-02 17:47:28 -070041 .extensionName = VK_KHR_WIN32_SURFACE_EXTENSION_NAME,
42 .specVersion = VK_KHR_WIN32_SURFACE_SPEC_VERSION,
Ian Elliott954fa342015-10-30 15:28:23 -060043};
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -070044#endif // VK_USE_PLATFORM_WIN32_KHR
45
Ian Elliottaf7d6362015-10-30 17:45:05 -060046#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060047static const VkExtensionProperties wsi_mir_surface_extension_info = {
Jon Ashburn23d36b12016-02-02 17:47:28 -070048 .extensionName = VK_KHR_MIR_SURFACE_EXTENSION_NAME,
49 .specVersion = VK_KHR_MIR_SURFACE_SPEC_VERSION,
Ian Elliott954fa342015-10-30 15:28:23 -060050};
Ian Elliottaf7d6362015-10-30 17:45:05 -060051#endif // VK_USE_PLATFORM_MIR_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060052
Ian Elliottaf7d6362015-10-30 17:45:05 -060053#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060054static const VkExtensionProperties wsi_wayland_surface_extension_info = {
Jon Ashburn23d36b12016-02-02 17:47:28 -070055 .extensionName = VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME,
56 .specVersion = VK_KHR_WAYLAND_SURFACE_SPEC_VERSION,
Ian Elliott954fa342015-10-30 15:28:23 -060057};
Ian Elliottaf7d6362015-10-30 17:45:05 -060058#endif // VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060059
Ian Elliottaf7d6362015-10-30 17:45:05 -060060#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060061static const VkExtensionProperties wsi_xcb_surface_extension_info = {
Jon Ashburn23d36b12016-02-02 17:47:28 -070062 .extensionName = VK_KHR_XCB_SURFACE_EXTENSION_NAME,
63 .specVersion = VK_KHR_XCB_SURFACE_SPEC_VERSION,
Ian Elliott954fa342015-10-30 15:28:23 -060064};
Ian Elliottaf7d6362015-10-30 17:45:05 -060065#endif // VK_USE_PLATFORM_XCB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060066
Ian Elliottaf7d6362015-10-30 17:45:05 -060067#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060068static const VkExtensionProperties wsi_xlib_surface_extension_info = {
Jon Ashburn23d36b12016-02-02 17:47:28 -070069 .extensionName = VK_KHR_XLIB_SURFACE_EXTENSION_NAME,
70 .specVersion = VK_KHR_XLIB_SURFACE_SPEC_VERSION,
Ian Elliott954fa342015-10-30 15:28:23 -060071};
Ian Elliottaf7d6362015-10-30 17:45:05 -060072#endif // VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -070073
74#ifdef VK_USE_PLATFORM_ANDROID_KHR
75static const VkExtensionProperties wsi_android_surface_extension_info = {
Jon Ashburn23d36b12016-02-02 17:47:28 -070076 .extensionName = VK_KHR_ANDROID_SURFACE_EXTENSION_NAME,
77 .specVersion = VK_KHR_ANDROID_SURFACE_REVISION,
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -070078};
79#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060080
Jon Ashburn23d36b12016-02-02 17:47:28 -070081void wsi_create_instance(struct loader_instance *ptr_instance,
82 const VkInstanceCreateInfo *pCreateInfo) {
Ian Elliottaf7d6362015-10-30 17:45:05 -060083 ptr_instance->wsi_surface_enabled = false;
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -070084
85#ifdef VK_USE_PLATFORM_WIN32_KHR
Jon Ashburnc7d3e732016-03-08 09:30:30 -070086 ptr_instance->wsi_win32_surface_enabled = false;
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -070087#endif // VK_USE_PLATFORM_WIN32_KHR
88#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060089 ptr_instance->wsi_mir_surface_enabled = false;
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -070090#endif // VK_USE_PLATFORM_MIR_KHR
91#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060092 ptr_instance->wsi_wayland_surface_enabled = false;
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -070093#endif // VK_USE_PLATFORM_WAYLAND_KHR
94#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060095 ptr_instance->wsi_xcb_surface_enabled = false;
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -070096#endif // VK_USE_PLATFORM_XCB_KHR
97#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060098 ptr_instance->wsi_xlib_surface_enabled = false;
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -070099#endif // VK_USE_PLATFORM_XLIB_KHR
100#ifdef VK_USE_PLATFORM_ANDROID_KHR
101 ptr_instance->wsi_android_surface_enabled = false;
102#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600103
Jon Ashburnc7d3e732016-03-08 09:30:30 -0700104 ptr_instance->wsi_display_enabled = false;
105
Jon Ashburnf19916e2016-01-11 13:12:43 -0700106 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Jon Ashburn23d36b12016-02-02 17:47:28 -0700107 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
108 VK_KHR_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott954fa342015-10-30 15:28:23 -0600109 ptr_instance->wsi_surface_enabled = true;
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700110 continue;
Ian Elliott954fa342015-10-30 15:28:23 -0600111 }
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700112#ifdef VK_USE_PLATFORM_WIN32_KHR
Jon Ashburn23d36b12016-02-02 17:47:28 -0700113 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
114 VK_KHR_WIN32_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliottdb4300a2015-11-23 10:17:23 -0700115 ptr_instance->wsi_win32_surface_enabled = true;
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700116 continue;
Ian Elliott954fa342015-10-30 15:28:23 -0600117 }
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -0700118#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliottaf7d6362015-10-30 17:45:05 -0600119#ifdef VK_USE_PLATFORM_MIR_KHR
Jon Ashburn23d36b12016-02-02 17:47:28 -0700120 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
121 VK_KHR_MIR_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott954fa342015-10-30 15:28:23 -0600122 ptr_instance->wsi_mir_surface_enabled = true;
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700123 continue;
Ian Elliott954fa342015-10-30 15:28:23 -0600124 }
Ian Elliottaf7d6362015-10-30 17:45:05 -0600125#endif // VK_USE_PLATFORM_MIR_KHR
126#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Jon Ashburn23d36b12016-02-02 17:47:28 -0700127 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
128 VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott954fa342015-10-30 15:28:23 -0600129 ptr_instance->wsi_wayland_surface_enabled = true;
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700130 continue;
Ian Elliott954fa342015-10-30 15:28:23 -0600131 }
Ian Elliottaf7d6362015-10-30 17:45:05 -0600132#endif // VK_USE_PLATFORM_WAYLAND_KHR
133#ifdef VK_USE_PLATFORM_XCB_KHR
Jon Ashburn23d36b12016-02-02 17:47:28 -0700134 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
135 VK_KHR_XCB_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott954fa342015-10-30 15:28:23 -0600136 ptr_instance->wsi_xcb_surface_enabled = true;
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700137 continue;
Ian Elliott954fa342015-10-30 15:28:23 -0600138 }
Ian Elliottaf7d6362015-10-30 17:45:05 -0600139#endif // VK_USE_PLATFORM_XCB_KHR
140#ifdef VK_USE_PLATFORM_XLIB_KHR
Jon Ashburn23d36b12016-02-02 17:47:28 -0700141 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
142 VK_KHR_XLIB_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott954fa342015-10-30 15:28:23 -0600143 ptr_instance->wsi_xlib_surface_enabled = true;
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700144 continue;
Ian Elliott954fa342015-10-30 15:28:23 -0600145 }
Ian Elliottaf7d6362015-10-30 17:45:05 -0600146#endif // VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -0700147#ifdef VK_USE_PLATFORM_ANDROID_KHR
Jon Ashburn23d36b12016-02-02 17:47:28 -0700148 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
149 VK_KHR_ANDROID_SURFACE_EXTENSION_NAME) == 0) {
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -0700150 ptr_instance->wsi_android_surface_enabled = true;
151 continue;
152 }
153#endif // VK_USE_PLATFORM_ANDROID_KHR
Jon Ashburnc7d3e732016-03-08 09:30:30 -0700154 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
155 VK_KHR_DISPLAY_EXTENSION_NAME) == 0) {
156 ptr_instance->wsi_display_enabled = true;
157 continue;
158 }
Ian Elliott954fa342015-10-30 15:28:23 -0600159 }
160}
Jon Ashburn6fa520f2016-03-25 12:49:35 -0600161/*
162 * Linux WSI surface extensions are not always compiled into the loader. (Assume
163 * for Windows the KHR_win32_surface is always compiled into loader). A given
164 * Linux build environment might not have the headers required for building one
165 * of the four extensions (Xlib, Xcb, Mir, Wayland). Thus, need to check if
166 * the built loader actually supports the particular Linux surface extension.
167 * If not supported by the built loader it will not be included in the list of
168 * enumerated instance extensions. This solves the issue where an ICD or layer
169 * advertises support for a given Linux surface extension but the loader was not
170 * built to support the extension. */
171bool wsi_unsupported_instance_extension(const VkExtensionProperties *ext_prop) {
172#ifndef VK_USE_PLATFORM_MIR_KHR
173 if (!strcmp(ext_prop->extensionName, "VK_KHR_mir_surface"))
174 return true;
175#endif // VK_USE_PLATFORM_MIR_KHR
176#ifndef VK_USE_PLATFORM_WAYLAND_KHR
177 if (!strcmp(ext_prop->extensionName, "VK_KHR_wayland_surface"))
178 return true;
179#endif // VK_USE_PLATFORM_WAYLAND_KHR
180#ifndef VK_USE_PLATFORM_XCB_KHR
181 if (!strcmp(ext_prop->extensionName, "VK_KHR_xcb_surface"))
182 return true;
183#endif // VK_USE_PLATFORM_XCB_KHR
184#ifndef VK_USE_PLATFORM_XLIB_KHR
185 if (!strcmp(ext_prop->extensionName, "VK_KHR_xlib_surface"))
186 return true;
187#endif // VK_USE_PLATFORM_XLIB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600188
Jon Ashburn6fa520f2016-03-25 12:49:35 -0600189 return false;
190}
Ian Elliott954fa342015-10-30 15:28:23 -0600191/*
Ian Elliott2c05e222015-11-19 13:14:05 -0700192 * Functions for the VK_KHR_surface extension:
193 */
194
195/*
196 * This is the trampoline entrypoint
197 * for DestroySurfaceKHR
Ian Elliott2c05e222015-11-19 13:14:05 -0700198 */
Jon Ashburn23d36b12016-02-02 17:47:28 -0700199LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
200vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface,
201 const VkAllocationCallbacks *pAllocator) {
Ian Elliottfb42cd72015-11-25 14:43:02 -0700202 const VkLayerInstanceDispatchTable *disp;
203 disp = loader_get_instance_dispatch(instance);
204 disp->DestroySurfaceKHR(instance, surface, pAllocator);
205}
206
Jon Ashburnc7d3e732016-03-08 09:30:30 -0700207// TODO probably need to lock around all the loader_get_instance() calls.
Ian Elliottfb42cd72015-11-25 14:43:02 -0700208/*
209 * This is the instance chain terminator function
210 * for DestroySurfaceKHR
211 */
Jon Ashburn23d36b12016-02-02 17:47:28 -0700212VKAPI_ATTR void VKAPI_CALL
Jon Ashburn1530c342016-02-26 13:14:27 -0700213terminator_DestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface,
214 const VkAllocationCallbacks *pAllocator) {
Ian Elliottdb4300a2015-11-23 10:17:23 -0700215 struct loader_instance *ptr_instance = loader_get_instance(instance);
216
Mark Young0ad83132016-06-30 13:02:42 -0600217 loader_instance_heap_free(ptr_instance, (void *)surface);
Ian Elliott2c05e222015-11-19 13:14:05 -0700218}
219
220/*
Ian Elliott954fa342015-10-30 15:28:23 -0600221 * This is the trampoline entrypoint
222 * for GetPhysicalDeviceSurfaceSupportKHR
223 */
Jon Ashburn23d36b12016-02-02 17:47:28 -0700224LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
225vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice,
226 uint32_t queueFamilyIndex,
227 VkSurfaceKHR surface,
228 VkBool32 *pSupported) {
Ian Elliott954fa342015-10-30 15:28:23 -0600229 const VkLayerInstanceDispatchTable *disp;
Jon Ashburn014438f2016-03-01 19:51:07 -0700230 VkPhysicalDevice unwrapped_phys_dev =
231 loader_unwrap_physical_device(physicalDevice);
Ian Elliott954fa342015-10-30 15:28:23 -0600232 disp = loader_get_instance_dispatch(physicalDevice);
233 VkResult res = disp->GetPhysicalDeviceSurfaceSupportKHR(
Jon Ashburn014438f2016-03-01 19:51:07 -0700234 unwrapped_phys_dev, queueFamilyIndex, surface, pSupported);
Ian Elliott954fa342015-10-30 15:28:23 -0600235 return res;
236}
237
238/*
239 * This is the instance chain terminator function
240 * for GetPhysicalDeviceSurfaceSupportKHR
241 */
Jon Ashburn23d36b12016-02-02 17:47:28 -0700242VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburn1530c342016-02-26 13:14:27 -0700243terminator_GetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice,
244 uint32_t queueFamilyIndex,
245 VkSurfaceKHR surface,
246 VkBool32 *pSupported) {
Ian Elliott2b8965a2016-03-24 13:59:22 -0600247 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn23d36b12016-02-02 17:47:28 -0700248 struct loader_physical_device *phys_dev =
249 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -0600250 struct loader_instance *ptr_instance =
251 (struct loader_instance *)phys_dev->this_icd->this_instance;
252 if (!ptr_instance->wsi_surface_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -0600253 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
254 "VK_KHR_VK_KHR_surface extension not enabled. "
255 "vkGetPhysicalDeviceSurfaceSupportKHR not executed!\n");
Ian Elliott2b8965a2016-03-24 13:59:22 -0600256 return VK_SUCCESS;
257 }
258
259 // Next, if so, proceed with the implementation of this function:
Ian Elliott954fa342015-10-30 15:28:23 -0600260 struct loader_icd *icd = phys_dev->this_icd;
261
Jon Ashburn23d36b12016-02-02 17:47:28 -0700262 assert(pSupported &&
263 "GetPhysicalDeviceSurfaceSupportKHR: Error, null pSupported");
Ian Elliott954fa342015-10-30 15:28:23 -0600264 *pSupported = false;
265
Jon Ashburn23d36b12016-02-02 17:47:28 -0700266 assert(icd->GetPhysicalDeviceSurfaceSupportKHR &&
267 "loader: null GetPhysicalDeviceSurfaceSupportKHR ICD pointer");
Ian Elliott954fa342015-10-30 15:28:23 -0600268
Jon Ashburn23d36b12016-02-02 17:47:28 -0700269 return icd->GetPhysicalDeviceSurfaceSupportKHR(
270 phys_dev->phys_dev, queueFamilyIndex, surface, pSupported);
Ian Elliott954fa342015-10-30 15:28:23 -0600271}
272
Ian Elliott486c5502015-11-19 16:05:09 -0700273/*
274 * This is the trampoline entrypoint
275 * for GetPhysicalDeviceSurfaceCapabilitiesKHR
276 */
Jon Ashburn23d36b12016-02-02 17:47:28 -0700277LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
278vkGetPhysicalDeviceSurfaceCapabilitiesKHR(
279 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
280 VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) {
Jon Ashburn014438f2016-03-01 19:51:07 -0700281
Ian Elliott486c5502015-11-19 16:05:09 -0700282 const VkLayerInstanceDispatchTable *disp;
Jon Ashburn014438f2016-03-01 19:51:07 -0700283 VkPhysicalDevice unwrapped_phys_dev =
284 loader_unwrap_physical_device(physicalDevice);
Ian Elliott486c5502015-11-19 16:05:09 -0700285 disp = loader_get_instance_dispatch(physicalDevice);
286 VkResult res = disp->GetPhysicalDeviceSurfaceCapabilitiesKHR(
Jon Ashburn014438f2016-03-01 19:51:07 -0700287 unwrapped_phys_dev, surface, pSurfaceCapabilities);
Ian Elliott486c5502015-11-19 16:05:09 -0700288 return res;
289}
290
291/*
292 * This is the instance chain terminator function
293 * for GetPhysicalDeviceSurfaceCapabilitiesKHR
294 */
Jon Ashburn1530c342016-02-26 13:14:27 -0700295VKAPI_ATTR VkResult VKAPI_CALL
296terminator_GetPhysicalDeviceSurfaceCapabilitiesKHR(
Jon Ashburn23d36b12016-02-02 17:47:28 -0700297 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
298 VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) {
Ian Elliott2b8965a2016-03-24 13:59:22 -0600299 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn23d36b12016-02-02 17:47:28 -0700300 struct loader_physical_device *phys_dev =
301 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -0600302 struct loader_instance *ptr_instance =
303 (struct loader_instance *)phys_dev->this_icd->this_instance;
304 if (!ptr_instance->wsi_surface_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -0600305 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
306 "VK_KHR_surface extension not enabled. "
307 "vkGetPhysicalDeviceSurfaceCapabilitiesKHR not executed!\n");
Ian Elliott2b8965a2016-03-24 13:59:22 -0600308 return VK_SUCCESS;
309 }
310
311 // Next, if so, proceed with the implementation of this function:
Ian Elliott486c5502015-11-19 16:05:09 -0700312 struct loader_icd *icd = phys_dev->this_icd;
313
Jon Ashburn23d36b12016-02-02 17:47:28 -0700314 assert(pSurfaceCapabilities && "GetPhysicalDeviceSurfaceCapabilitiesKHR: "
315 "Error, null pSurfaceCapabilities");
Ian Elliott486c5502015-11-19 16:05:09 -0700316
Jon Ashburn23d36b12016-02-02 17:47:28 -0700317 assert(icd->GetPhysicalDeviceSurfaceCapabilitiesKHR &&
318 "loader: null GetPhysicalDeviceSurfaceCapabilitiesKHR ICD pointer");
Ian Elliott486c5502015-11-19 16:05:09 -0700319
Jon Ashburn23d36b12016-02-02 17:47:28 -0700320 return icd->GetPhysicalDeviceSurfaceCapabilitiesKHR(
321 phys_dev->phys_dev, surface, pSurfaceCapabilities);
Ian Elliott486c5502015-11-19 16:05:09 -0700322}
323
324/*
325 * This is the trampoline entrypoint
326 * for GetPhysicalDeviceSurfaceFormatsKHR
327 */
Jon Ashburn23d36b12016-02-02 17:47:28 -0700328LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
329vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice,
330 VkSurfaceKHR surface,
331 uint32_t *pSurfaceFormatCount,
332 VkSurfaceFormatKHR *pSurfaceFormats) {
Jon Ashburn014438f2016-03-01 19:51:07 -0700333 VkPhysicalDevice unwrapped_phys_dev =
334 loader_unwrap_physical_device(physicalDevice);
Ian Elliott486c5502015-11-19 16:05:09 -0700335 const VkLayerInstanceDispatchTable *disp;
336 disp = loader_get_instance_dispatch(physicalDevice);
337 VkResult res = disp->GetPhysicalDeviceSurfaceFormatsKHR(
Jon Ashburn014438f2016-03-01 19:51:07 -0700338 unwrapped_phys_dev, surface, pSurfaceFormatCount, pSurfaceFormats);
Ian Elliott486c5502015-11-19 16:05:09 -0700339 return res;
340}
341
342/*
343 * This is the instance chain terminator function
344 * for GetPhysicalDeviceSurfaceFormatsKHR
345 */
Jon Ashburn1530c342016-02-26 13:14:27 -0700346VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceFormatsKHR(
347 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
348 uint32_t *pSurfaceFormatCount, VkSurfaceFormatKHR *pSurfaceFormats) {
Ian Elliott2b8965a2016-03-24 13:59:22 -0600349 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn23d36b12016-02-02 17:47:28 -0700350 struct loader_physical_device *phys_dev =
351 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -0600352 struct loader_instance *ptr_instance =
353 (struct loader_instance *)phys_dev->this_icd->this_instance;
354 if (!ptr_instance->wsi_surface_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -0600355 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
356 "VK_KHR_surface extension not enabled. "
357 "vkGetPhysicalDeviceSurfaceFormatsKHR not executed!\n");
Ian Elliott2b8965a2016-03-24 13:59:22 -0600358 return VK_SUCCESS;
359 }
360
361 // Next, if so, proceed with the implementation of this function:
Ian Elliott486c5502015-11-19 16:05:09 -0700362 struct loader_icd *icd = phys_dev->this_icd;
363
Jon Ashburn23d36b12016-02-02 17:47:28 -0700364 assert(
365 pSurfaceFormatCount &&
366 "GetPhysicalDeviceSurfaceFormatsKHR: Error, null pSurfaceFormatCount");
Ian Elliott486c5502015-11-19 16:05:09 -0700367
Jon Ashburn23d36b12016-02-02 17:47:28 -0700368 assert(icd->GetPhysicalDeviceSurfaceFormatsKHR &&
369 "loader: null GetPhysicalDeviceSurfaceFormatsKHR ICD pointer");
Ian Elliott486c5502015-11-19 16:05:09 -0700370
Jon Ashburn23d36b12016-02-02 17:47:28 -0700371 return icd->GetPhysicalDeviceSurfaceFormatsKHR(
372 phys_dev->phys_dev, surface, pSurfaceFormatCount, pSurfaceFormats);
Ian Elliott486c5502015-11-19 16:05:09 -0700373}
374
375/*
376 * This is the trampoline entrypoint
377 * for GetPhysicalDeviceSurfacePresentModesKHR
378 */
Jon Ashburn23d36b12016-02-02 17:47:28 -0700379LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
380vkGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,
381 VkSurfaceKHR surface,
382 uint32_t *pPresentModeCount,
383 VkPresentModeKHR *pPresentModes) {
Jon Ashburn014438f2016-03-01 19:51:07 -0700384 VkPhysicalDevice unwrapped_phys_dev =
385 loader_unwrap_physical_device(physicalDevice);
Ian Elliott486c5502015-11-19 16:05:09 -0700386 const VkLayerInstanceDispatchTable *disp;
387 disp = loader_get_instance_dispatch(physicalDevice);
388 VkResult res = disp->GetPhysicalDeviceSurfacePresentModesKHR(
Jon Ashburn014438f2016-03-01 19:51:07 -0700389 unwrapped_phys_dev, surface, pPresentModeCount, pPresentModes);
Ian Elliott486c5502015-11-19 16:05:09 -0700390 return res;
391}
392
393/*
394 * This is the instance chain terminator function
395 * for GetPhysicalDeviceSurfacePresentModesKHR
396 */
Jon Ashburn1530c342016-02-26 13:14:27 -0700397VKAPI_ATTR VkResult VKAPI_CALL
398terminator_GetPhysicalDeviceSurfacePresentModesKHR(
Jon Ashburn23d36b12016-02-02 17:47:28 -0700399 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
400 uint32_t *pPresentModeCount, VkPresentModeKHR *pPresentModes) {
Ian Elliott2b8965a2016-03-24 13:59:22 -0600401 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn23d36b12016-02-02 17:47:28 -0700402 struct loader_physical_device *phys_dev =
403 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -0600404 struct loader_instance *ptr_instance =
405 (struct loader_instance *)phys_dev->this_icd->this_instance;
406 if (!ptr_instance->wsi_surface_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -0600407 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
408 "VK_KHR_surface extension not enabled. "
409 "vkGetPhysicalDeviceSurfacePresentModesKHR not executed!\n");
Ian Elliott2b8965a2016-03-24 13:59:22 -0600410 return VK_SUCCESS;
411 }
412
413 // Next, if so, proceed with the implementation of this function:
Ian Elliott486c5502015-11-19 16:05:09 -0700414 struct loader_icd *icd = phys_dev->this_icd;
415
Jon Ashburn23d36b12016-02-02 17:47:28 -0700416 assert(pPresentModeCount && "GetPhysicalDeviceSurfacePresentModesKHR: "
417 "Error, null pPresentModeCount");
Ian Elliott486c5502015-11-19 16:05:09 -0700418
Jon Ashburn23d36b12016-02-02 17:47:28 -0700419 assert(icd->GetPhysicalDeviceSurfacePresentModesKHR &&
420 "loader: null GetPhysicalDeviceSurfacePresentModesKHR ICD pointer");
Ian Elliott486c5502015-11-19 16:05:09 -0700421
Jon Ashburn23d36b12016-02-02 17:47:28 -0700422 return icd->GetPhysicalDeviceSurfacePresentModesKHR(
423 phys_dev->phys_dev, surface, pPresentModeCount, pPresentModes);
Ian Elliott486c5502015-11-19 16:05:09 -0700424}
425
Ian Elliott2c05e222015-11-19 13:14:05 -0700426/*
427 * Functions for the VK_KHR_swapchain extension:
428 */
429
Ian Elliott934d0d52015-11-19 16:39:21 -0700430/*
431 * This is the trampoline entrypoint
432 * for CreateSwapchainKHR
433 */
Mark Young0ad83132016-06-30 13:02:42 -0600434LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR(
435 VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
436 const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain) {
Ian Elliott934d0d52015-11-19 16:39:21 -0700437 const VkLayerDispatchTable *disp;
438 disp = loader_get_dispatch(device);
Jon Ashburn23d36b12016-02-02 17:47:28 -0700439 VkResult res =
440 disp->CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain);
Ian Elliott934d0d52015-11-19 16:39:21 -0700441 return res;
442}
Ian Elliott2c05e222015-11-19 13:14:05 -0700443
Ian Elliott934d0d52015-11-19 16:39:21 -0700444/*
445 * This is the trampoline entrypoint
446 * for DestroySwapchainKHR
447 */
Jon Ashburn23d36b12016-02-02 17:47:28 -0700448LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
449vkDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain,
450 const VkAllocationCallbacks *pAllocator) {
Ian Elliott934d0d52015-11-19 16:39:21 -0700451 const VkLayerDispatchTable *disp;
452 disp = loader_get_dispatch(device);
453 disp->DestroySwapchainKHR(device, swapchain, pAllocator);
454}
Ian Elliott2c05e222015-11-19 13:14:05 -0700455
Ian Elliott934d0d52015-11-19 16:39:21 -0700456/*
457 * This is the trampoline entrypoint
458 * for GetSwapchainImagesKHR
459 */
Jon Ashburn23d36b12016-02-02 17:47:28 -0700460LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
461vkGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain,
462 uint32_t *pSwapchainImageCount,
463 VkImage *pSwapchainImages) {
Ian Elliott934d0d52015-11-19 16:39:21 -0700464 const VkLayerDispatchTable *disp;
465 disp = loader_get_dispatch(device);
466 VkResult res = disp->GetSwapchainImagesKHR(
Jon Ashburn23d36b12016-02-02 17:47:28 -0700467 device, swapchain, pSwapchainImageCount, pSwapchainImages);
Ian Elliott934d0d52015-11-19 16:39:21 -0700468 return res;
469}
470
471/*
472 * This is the trampoline entrypoint
473 * for AcquireNextImageKHR
474 */
Jon Ashburn23d36b12016-02-02 17:47:28 -0700475LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
476vkAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain,
477 uint64_t timeout, VkSemaphore semaphore, VkFence fence,
478 uint32_t *pImageIndex) {
Ian Elliott934d0d52015-11-19 16:39:21 -0700479 const VkLayerDispatchTable *disp;
480 disp = loader_get_dispatch(device);
Jon Ashburn23d36b12016-02-02 17:47:28 -0700481 VkResult res = disp->AcquireNextImageKHR(device, swapchain, timeout,
482 semaphore, fence, pImageIndex);
Ian Elliott934d0d52015-11-19 16:39:21 -0700483 return res;
484}
485
486/*
487 * This is the trampoline entrypoint
488 * for QueuePresentKHR
489 */
Jon Ashburn23d36b12016-02-02 17:47:28 -0700490LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
491vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) {
Ian Elliott934d0d52015-11-19 16:39:21 -0700492 const VkLayerDispatchTable *disp;
493 disp = loader_get_dispatch(queue);
494 VkResult res = disp->QueuePresentKHR(queue, pPresentInfo);
495 return res;
496}
Ian Elliott2c05e222015-11-19 13:14:05 -0700497
Ian Elliott2c05e222015-11-19 13:14:05 -0700498#ifdef VK_USE_PLATFORM_WIN32_KHR
499
500/*
501 * Functions for the VK_KHR_win32_surface extension:
502 */
503
504/*
505 * This is the trampoline entrypoint
506 * for CreateWin32SurfaceKHR
507 */
Mark Young0ad83132016-06-30 13:02:42 -0600508LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR(
509 VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
510 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburnf72a04b2015-11-25 17:55:49 -0700511 const VkLayerInstanceDispatchTable *disp;
512 disp = loader_get_instance_dispatch(instance);
513 VkResult res;
514
Jon Ashburn23d36b12016-02-02 17:47:28 -0700515 res = disp->CreateWin32SurfaceKHR(instance, pCreateInfo, pAllocator,
516 pSurface);
Jon Ashburnf72a04b2015-11-25 17:55:49 -0700517 return res;
518}
519
520/*
521 * This is the instance chain terminator function
522 * for CreateWin32SurfaceKHR
523 */
Mark Young0ad83132016-06-30 13:02:42 -0600524VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWin32SurfaceKHR(
525 VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
526 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Ian Elliott2b8965a2016-03-24 13:59:22 -0600527 // First, check to ensure the appropriate extension was enabled:
Ian Elliottdb4300a2015-11-23 10:17:23 -0700528 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott2b8965a2016-03-24 13:59:22 -0600529 if (!ptr_instance->wsi_win32_surface_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -0600530 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
531 "VK_KHR_win32_surface extension not enabled. "
532 "vkCreateWin32SurfaceKHR not executed!\n");
Jeremy Hayes9f1d0b62016-06-14 11:50:02 -0600533 return VK_ERROR_EXTENSION_NOT_PRESENT;
Ian Elliott2b8965a2016-03-24 13:59:22 -0600534 }
535
536 // Next, if so, proceed with the implementation of this function:
Ian Elliott2c05e222015-11-19 13:14:05 -0700537 VkIcdSurfaceWin32 *pIcdSurface = NULL;
538
Mark Young0ad83132016-06-30 13:02:42 -0600539 pIcdSurface =
540 loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceWin32),
541 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott2c05e222015-11-19 13:14:05 -0700542 if (pIcdSurface == NULL) {
543 return VK_ERROR_OUT_OF_HOST_MEMORY;
544 }
545
546 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_WIN32;
Ian Elliott6e7e6002015-12-10 17:28:50 -0700547 pIcdSurface->hinstance = pCreateInfo->hinstance;
548 pIcdSurface->hwnd = pCreateInfo->hwnd;
Ian Elliott2c05e222015-11-19 13:14:05 -0700549
Jon Ashburn23d36b12016-02-02 17:47:28 -0700550 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliott2c05e222015-11-19 13:14:05 -0700551
552 return VK_SUCCESS;
553}
Ian Elliott919fa302015-11-24 15:39:10 -0700554
555/*
556 * This is the trampoline entrypoint
557 * for GetPhysicalDeviceWin32PresentationSupportKHR
558 */
Jon Ashburn23d36b12016-02-02 17:47:28 -0700559LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
560vkGetPhysicalDeviceWin32PresentationSupportKHR(VkPhysicalDevice physicalDevice,
561 uint32_t queueFamilyIndex) {
Jon Ashburn014438f2016-03-01 19:51:07 -0700562 VkPhysicalDevice unwrapped_phys_dev =
563 loader_unwrap_physical_device(physicalDevice);
Ian Elliott919fa302015-11-24 15:39:10 -0700564 const VkLayerInstanceDispatchTable *disp;
565 disp = loader_get_instance_dispatch(physicalDevice);
566 VkBool32 res = disp->GetPhysicalDeviceWin32PresentationSupportKHR(
Jon Ashburn014438f2016-03-01 19:51:07 -0700567 unwrapped_phys_dev, queueFamilyIndex);
Ian Elliott919fa302015-11-24 15:39:10 -0700568 return res;
569}
570
Ian Elliott919fa302015-11-24 15:39:10 -0700571/*
572 * This is the instance chain terminator function
573 * for GetPhysicalDeviceWin32PresentationSupportKHR
574 */
Jon Ashburn23d36b12016-02-02 17:47:28 -0700575VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburn1530c342016-02-26 13:14:27 -0700576terminator_GetPhysicalDeviceWin32PresentationSupportKHR(
Jon Ashburn23d36b12016-02-02 17:47:28 -0700577 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex) {
Ian Elliott2b8965a2016-03-24 13:59:22 -0600578 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn23d36b12016-02-02 17:47:28 -0700579 struct loader_physical_device *phys_dev =
580 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -0600581 struct loader_instance *ptr_instance =
582 (struct loader_instance *)phys_dev->this_icd->this_instance;
583 if (!ptr_instance->wsi_win32_surface_enabled) {
Jon Ashburncc407a22016-04-15 09:25:03 -0600584 loader_log(
585 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
586 "VK_KHR_win32_surface extension not enabled. "
587 "vkGetPhysicalDeviceWin32PresentationSupportKHR not executed!\n");
Ian Elliott2b8965a2016-03-24 13:59:22 -0600588 return VK_SUCCESS;
589 }
590
591 // Next, if so, proceed with the implementation of this function:
Ian Elliott919fa302015-11-24 15:39:10 -0700592 struct loader_icd *icd = phys_dev->this_icd;
593
Jon Ashburn23d36b12016-02-02 17:47:28 -0700594 assert(icd->GetPhysicalDeviceWin32PresentationSupportKHR &&
595 "loader: null GetPhysicalDeviceWin32PresentationSupportKHR ICD "
596 "pointer");
Ian Elliott919fa302015-11-24 15:39:10 -0700597
598 return icd->GetPhysicalDeviceWin32PresentationSupportKHR(phys_dev->phys_dev,
Jon Ashburn23d36b12016-02-02 17:47:28 -0700599 queueFamilyIndex);
Ian Elliott919fa302015-11-24 15:39:10 -0700600}
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -0700601#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliott2c05e222015-11-19 13:14:05 -0700602
603#ifdef VK_USE_PLATFORM_MIR_KHR
604
605/*
606 * Functions for the VK_KHR_mir_surface extension:
607 */
608
609/*
610 * This is the trampoline entrypoint
611 * for CreateMirSurfaceKHR
612 */
Mark Young0ad83132016-06-30 13:02:42 -0600613LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateMirSurfaceKHR(
614 VkInstance instance, const VkMirSurfaceCreateInfoKHR *pCreateInfo,
615 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburnf72a04b2015-11-25 17:55:49 -0700616 const VkLayerInstanceDispatchTable *disp;
617 disp = loader_get_instance_dispatch(instance);
618 VkResult res;
619
Jon Ashburn23d36b12016-02-02 17:47:28 -0700620 res =
621 disp->CreateMirSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
Jon Ashburnf72a04b2015-11-25 17:55:49 -0700622 return res;
623}
624
625/*
626 * This is the instance chain terminator function
627 * for CreateMirSurfaceKHR
628 */
Mark Young0ad83132016-06-30 13:02:42 -0600629VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateMirSurfaceKHR(
630 VkInstance instance, const VkMirSurfaceCreateInfoKHR *pCreateInfo,
631 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Ian Elliott2b8965a2016-03-24 13:59:22 -0600632 // First, check to ensure the appropriate extension was enabled:
Ian Elliottdb4300a2015-11-23 10:17:23 -0700633 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott2b8965a2016-03-24 13:59:22 -0600634 if (!ptr_instance->wsi_mir_surface_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -0600635 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
636 "VK_KHR_mir_surface extension not enabled. "
637 "vkCreateMirSurfaceKHR not executed!\n");
Jeremy Hayes9f1d0b62016-06-14 11:50:02 -0600638 return VK_ERROR_EXTENSION_NOT_PRESENT;
Ian Elliott2b8965a2016-03-24 13:59:22 -0600639 }
640
641 // Next, if so, proceed with the implementation of this function:
Ian Elliott2c05e222015-11-19 13:14:05 -0700642 VkIcdSurfaceMir *pIcdSurface = NULL;
643
Mark Young0ad83132016-06-30 13:02:42 -0600644 pIcdSurface =
645 loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceMir),
646 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott2c05e222015-11-19 13:14:05 -0700647 if (pIcdSurface == NULL) {
648 return VK_ERROR_OUT_OF_HOST_MEMORY;
649 }
650
651 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_MIR;
Ian Elliott6e7e6002015-12-10 17:28:50 -0700652 pIcdSurface->connection = pCreateInfo->connection;
653 pIcdSurface->mirSurface = pCreateInfo->mirSurface;
Ian Elliott2c05e222015-11-19 13:14:05 -0700654
Jon Ashburn23d36b12016-02-02 17:47:28 -0700655 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliott2c05e222015-11-19 13:14:05 -0700656
657 return VK_SUCCESS;
658}
Ian Elliott919fa302015-11-24 15:39:10 -0700659
660/*
661 * This is the trampoline entrypoint
662 * for GetPhysicalDeviceMirPresentationSupportKHR
663 */
Jon Ashburn23d36b12016-02-02 17:47:28 -0700664LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
665vkGetPhysicalDeviceMirPresentationSupportKHR(VkPhysicalDevice physicalDevice,
666 uint32_t queueFamilyIndex,
667 MirConnection *connection) {
Jon Ashburn014438f2016-03-01 19:51:07 -0700668 VkPhysicalDevice unwrapped_phys_dev =
669 loader_unwrap_physical_device(physicalDevice);
Ian Elliott919fa302015-11-24 15:39:10 -0700670 const VkLayerInstanceDispatchTable *disp;
671 disp = loader_get_instance_dispatch(physicalDevice);
672 VkBool32 res = disp->GetPhysicalDeviceMirPresentationSupportKHR(
Jon Ashburn014438f2016-03-01 19:51:07 -0700673 unwrapped_phys_dev, queueFamilyIndex, connection);
Ian Elliott919fa302015-11-24 15:39:10 -0700674 return res;
675}
676
Ian Elliott919fa302015-11-24 15:39:10 -0700677/*
678 * This is the instance chain terminator function
679 * for GetPhysicalDeviceMirPresentationSupportKHR
680 */
Jon Ashburn23d36b12016-02-02 17:47:28 -0700681VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburn1530c342016-02-26 13:14:27 -0700682terminator_GetPhysicalDeviceMirPresentationSupportKHR(
Jon Ashburn23d36b12016-02-02 17:47:28 -0700683 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
684 MirConnection *connection) {
Ian Elliott2b8965a2016-03-24 13:59:22 -0600685 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn23d36b12016-02-02 17:47:28 -0700686 struct loader_physical_device *phys_dev =
687 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -0600688 struct loader_instance *ptr_instance =
689 (struct loader_instance *)phys_dev->this_icd->this_instance;
690 if (!ptr_instance->wsi_mir_surface_enabled) {
Jon Ashburncc407a22016-04-15 09:25:03 -0600691 loader_log(
692 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
693 "VK_KHR_mir_surface extension not enabled. "
694 "vkGetPhysicalDeviceMirPresentationSupportKHR not executed!\n");
Ian Elliott2b8965a2016-03-24 13:59:22 -0600695 return VK_SUCCESS;
696 }
697
698 // Next, if so, proceed with the implementation of this function:
Ian Elliott919fa302015-11-24 15:39:10 -0700699 struct loader_icd *icd = phys_dev->this_icd;
700
Jon Ashburn23d36b12016-02-02 17:47:28 -0700701 assert(
702 icd->GetPhysicalDeviceMirPresentationSupportKHR &&
703 "loader: null GetPhysicalDeviceMirPresentationSupportKHR ICD pointer");
Ian Elliott919fa302015-11-24 15:39:10 -0700704
Jon Ashburn23d36b12016-02-02 17:47:28 -0700705 return icd->GetPhysicalDeviceMirPresentationSupportKHR(
706 phys_dev->phys_dev, queueFamilyIndex, connection);
Ian Elliott919fa302015-11-24 15:39:10 -0700707}
Ian Elliott2c05e222015-11-19 13:14:05 -0700708#endif // VK_USE_PLATFORM_MIR_KHR
709
710#ifdef VK_USE_PLATFORM_WAYLAND_KHR
711
712/*
713 * Functions for the VK_KHR_wayland_surface extension:
714 */
715
716/*
717 * This is the trampoline entrypoint
718 * for CreateWaylandSurfaceKHR
719 */
Jon Ashburn23d36b12016-02-02 17:47:28 -0700720LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
721vkCreateWaylandSurfaceKHR(VkInstance instance,
Jason Ekstranda5ebe8a2016-02-12 17:25:03 -0800722 const VkWaylandSurfaceCreateInfoKHR *pCreateInfo,
Jon Ashburn23d36b12016-02-02 17:47:28 -0700723 const VkAllocationCallbacks *pAllocator,
724 VkSurfaceKHR *pSurface) {
Jon Ashburnf72a04b2015-11-25 17:55:49 -0700725 const VkLayerInstanceDispatchTable *disp;
726 disp = loader_get_instance_dispatch(instance);
727 VkResult res;
728
Jon Ashburn23d36b12016-02-02 17:47:28 -0700729 res = disp->CreateWaylandSurfaceKHR(instance, pCreateInfo, pAllocator,
730 pSurface);
Jon Ashburnf72a04b2015-11-25 17:55:49 -0700731 return res;
732}
733
734/*
735 * This is the instance chain terminator function
Mun, Gwan-gyeong0a88f4c2016-02-22 09:33:58 +0900736 * for CreateWaylandSurfaceKHR
Jon Ashburnf72a04b2015-11-25 17:55:49 -0700737 */
Mark Young0ad83132016-06-30 13:02:42 -0600738VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWaylandSurfaceKHR(
Jon Ashburn1530c342016-02-26 13:14:27 -0700739 VkInstance instance, const VkWaylandSurfaceCreateInfoKHR *pCreateInfo,
740 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Ian Elliott2b8965a2016-03-24 13:59:22 -0600741 // First, check to ensure the appropriate extension was enabled:
Ian Elliottdb4300a2015-11-23 10:17:23 -0700742 struct loader_instance *ptr_instance = loader_get_instance(instance);
Jon Ashburnd76b51c2016-03-24 17:26:59 -0600743 if (!ptr_instance->wsi_wayland_surface_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -0600744 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
745 "VK_KHR_wayland_surface extension not enabled. "
746 "vkCreateWaylandSurfaceKHR not executed!\n");
Jeremy Hayes9f1d0b62016-06-14 11:50:02 -0600747 return VK_ERROR_EXTENSION_NOT_PRESENT;
Ian Elliott2b8965a2016-03-24 13:59:22 -0600748 }
749
750 // Next, if so, proceed with the implementation of this function:
Ian Elliott2c05e222015-11-19 13:14:05 -0700751 VkIcdSurfaceWayland *pIcdSurface = NULL;
752
Mark Young0ad83132016-06-30 13:02:42 -0600753 pIcdSurface =
754 loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceWayland),
755 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott2c05e222015-11-19 13:14:05 -0700756 if (pIcdSurface == NULL) {
757 return VK_ERROR_OUT_OF_HOST_MEMORY;
758 }
759
760 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_WAYLAND;
Ian Elliott6e7e6002015-12-10 17:28:50 -0700761 pIcdSurface->display = pCreateInfo->display;
762 pIcdSurface->surface = pCreateInfo->surface;
Ian Elliott2c05e222015-11-19 13:14:05 -0700763
Jon Ashburn23d36b12016-02-02 17:47:28 -0700764 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliott2c05e222015-11-19 13:14:05 -0700765
766 return VK_SUCCESS;
767}
Ian Elliott919fa302015-11-24 15:39:10 -0700768
769/*
770 * This is the trampoline entrypoint
771 * for GetPhysicalDeviceWaylandPresentationSupportKHR
772 */
Jon Ashburn23d36b12016-02-02 17:47:28 -0700773LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
774vkGetPhysicalDeviceWaylandPresentationSupportKHR(
775 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
776 struct wl_display *display) {
Jon Ashburn014438f2016-03-01 19:51:07 -0700777 VkPhysicalDevice unwrapped_phys_dev =
778 loader_unwrap_physical_device(physicalDevice);
Ian Elliott919fa302015-11-24 15:39:10 -0700779 const VkLayerInstanceDispatchTable *disp;
780 disp = loader_get_instance_dispatch(physicalDevice);
781 VkBool32 res = disp->GetPhysicalDeviceWaylandPresentationSupportKHR(
Jon Ashburn014438f2016-03-01 19:51:07 -0700782 unwrapped_phys_dev, queueFamilyIndex, display);
Ian Elliott919fa302015-11-24 15:39:10 -0700783 return res;
784}
785
Ian Elliott919fa302015-11-24 15:39:10 -0700786/*
787 * This is the instance chain terminator function
788 * for GetPhysicalDeviceWaylandPresentationSupportKHR
789 */
Jon Ashburn23d36b12016-02-02 17:47:28 -0700790VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburn1530c342016-02-26 13:14:27 -0700791terminator_GetPhysicalDeviceWaylandPresentationSupportKHR(
Jon Ashburn23d36b12016-02-02 17:47:28 -0700792 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
793 struct wl_display *display) {
Ian Elliott2b8965a2016-03-24 13:59:22 -0600794 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn23d36b12016-02-02 17:47:28 -0700795 struct loader_physical_device *phys_dev =
796 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -0600797 struct loader_instance *ptr_instance =
798 (struct loader_instance *)phys_dev->this_icd->this_instance;
Jon Ashburnd76b51c2016-03-24 17:26:59 -0600799 if (!ptr_instance->wsi_wayland_surface_enabled) {
Jon Ashburncc407a22016-04-15 09:25:03 -0600800 loader_log(
801 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
802 "VK_KHR_wayland_surface extension not enabled. "
803 "vkGetPhysicalDeviceWaylandPresentationSupportKHR not executed!\n");
Ian Elliott2b8965a2016-03-24 13:59:22 -0600804 return VK_SUCCESS;
805 }
806
807 // Next, if so, proceed with the implementation of this function:
Ian Elliott919fa302015-11-24 15:39:10 -0700808 struct loader_icd *icd = phys_dev->this_icd;
809
Jon Ashburn23d36b12016-02-02 17:47:28 -0700810 assert(icd->GetPhysicalDeviceWaylandPresentationSupportKHR &&
811 "loader: null GetPhysicalDeviceWaylandPresentationSupportKHR ICD "
812 "pointer");
Ian Elliott919fa302015-11-24 15:39:10 -0700813
Jon Ashburn23d36b12016-02-02 17:47:28 -0700814 return icd->GetPhysicalDeviceWaylandPresentationSupportKHR(
815 phys_dev->phys_dev, queueFamilyIndex, display);
Ian Elliott919fa302015-11-24 15:39:10 -0700816}
Ian Elliott2c05e222015-11-19 13:14:05 -0700817#endif // VK_USE_PLATFORM_WAYLAND_KHR
818
819#ifdef VK_USE_PLATFORM_XCB_KHR
820
821/*
822 * Functions for the VK_KHR_xcb_surface extension:
823 */
824
825/*
826 * This is the trampoline entrypoint
827 * for CreateXcbSurfaceKHR
828 */
Mark Young0ad83132016-06-30 13:02:42 -0600829LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXcbSurfaceKHR(
830 VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo,
831 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburnf72a04b2015-11-25 17:55:49 -0700832 const VkLayerInstanceDispatchTable *disp;
833 disp = loader_get_instance_dispatch(instance);
834 VkResult res;
835
Jon Ashburn23d36b12016-02-02 17:47:28 -0700836 res =
837 disp->CreateXcbSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
Jon Ashburnf72a04b2015-11-25 17:55:49 -0700838 return res;
839}
840
841/*
842 * This is the instance chain terminator function
843 * for CreateXcbSurfaceKHR
844 */
Mark Young0ad83132016-06-30 13:02:42 -0600845VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXcbSurfaceKHR(
846 VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo,
847 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Ian Elliott2b8965a2016-03-24 13:59:22 -0600848 // First, check to ensure the appropriate extension was enabled:
Ian Elliottdb4300a2015-11-23 10:17:23 -0700849 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott2b8965a2016-03-24 13:59:22 -0600850 if (!ptr_instance->wsi_xcb_surface_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -0600851 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
852 "VK_KHR_xcb_surface extension not enabled. "
853 "vkCreateXcbSurfaceKHR not executed!\n");
Jeremy Hayes9f1d0b62016-06-14 11:50:02 -0600854 return VK_ERROR_EXTENSION_NOT_PRESENT;
Ian Elliott2b8965a2016-03-24 13:59:22 -0600855 }
856
857 // Next, if so, proceed with the implementation of this function:
Ian Elliott2c05e222015-11-19 13:14:05 -0700858 VkIcdSurfaceXcb *pIcdSurface = NULL;
859
Mark Young0ad83132016-06-30 13:02:42 -0600860 pIcdSurface =
861 loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceXcb),
862 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott2c05e222015-11-19 13:14:05 -0700863 if (pIcdSurface == NULL) {
864 return VK_ERROR_OUT_OF_HOST_MEMORY;
865 }
866
867 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_XCB;
Ian Elliott6e7e6002015-12-10 17:28:50 -0700868 pIcdSurface->connection = pCreateInfo->connection;
869 pIcdSurface->window = pCreateInfo->window;
Ian Elliott2c05e222015-11-19 13:14:05 -0700870
Jon Ashburn23d36b12016-02-02 17:47:28 -0700871 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliott2c05e222015-11-19 13:14:05 -0700872
873 return VK_SUCCESS;
874}
Ian Elliott919fa302015-11-24 15:39:10 -0700875
876/*
877 * This is the trampoline entrypoint
878 * for GetPhysicalDeviceXcbPresentationSupportKHR
879 */
Jon Ashburn23d36b12016-02-02 17:47:28 -0700880LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
881vkGetPhysicalDeviceXcbPresentationSupportKHR(VkPhysicalDevice physicalDevice,
882 uint32_t queueFamilyIndex,
883 xcb_connection_t *connection,
884 xcb_visualid_t visual_id) {
Jon Ashburn014438f2016-03-01 19:51:07 -0700885 VkPhysicalDevice unwrapped_phys_dev =
886 loader_unwrap_physical_device(physicalDevice);
Ian Elliott919fa302015-11-24 15:39:10 -0700887 const VkLayerInstanceDispatchTable *disp;
888 disp = loader_get_instance_dispatch(physicalDevice);
889 VkBool32 res = disp->GetPhysicalDeviceXcbPresentationSupportKHR(
Jon Ashburn014438f2016-03-01 19:51:07 -0700890 unwrapped_phys_dev, queueFamilyIndex, connection, visual_id);
Ian Elliott919fa302015-11-24 15:39:10 -0700891 return res;
892}
893
Ian Elliott919fa302015-11-24 15:39:10 -0700894/*
895 * This is the instance chain terminator function
896 * for GetPhysicalDeviceXcbPresentationSupportKHR
897 */
Jon Ashburn23d36b12016-02-02 17:47:28 -0700898VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburn1530c342016-02-26 13:14:27 -0700899terminator_GetPhysicalDeviceXcbPresentationSupportKHR(
Jon Ashburn23d36b12016-02-02 17:47:28 -0700900 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
901 xcb_connection_t *connection, xcb_visualid_t visual_id) {
Ian Elliott2b8965a2016-03-24 13:59:22 -0600902 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn23d36b12016-02-02 17:47:28 -0700903 struct loader_physical_device *phys_dev =
904 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -0600905 struct loader_instance *ptr_instance =
906 (struct loader_instance *)phys_dev->this_icd->this_instance;
907 if (!ptr_instance->wsi_xcb_surface_enabled) {
Jon Ashburncc407a22016-04-15 09:25:03 -0600908 loader_log(
909 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
910 "VK_KHR_xcb_surface extension not enabled. "
911 "vkGetPhysicalDeviceXcbPresentationSupportKHR not executed!\n");
Ian Elliott2b8965a2016-03-24 13:59:22 -0600912 return VK_SUCCESS;
913 }
914
915 // Next, if so, proceed with the implementation of this function:
Ian Elliott919fa302015-11-24 15:39:10 -0700916 struct loader_icd *icd = phys_dev->this_icd;
917
Jon Ashburn23d36b12016-02-02 17:47:28 -0700918 assert(
919 icd->GetPhysicalDeviceXcbPresentationSupportKHR &&
920 "loader: null GetPhysicalDeviceXcbPresentationSupportKHR ICD pointer");
Ian Elliott919fa302015-11-24 15:39:10 -0700921
Jon Ashburn23d36b12016-02-02 17:47:28 -0700922 return icd->GetPhysicalDeviceXcbPresentationSupportKHR(
923 phys_dev->phys_dev, queueFamilyIndex, connection, visual_id);
Ian Elliott919fa302015-11-24 15:39:10 -0700924}
Ian Elliott2c05e222015-11-19 13:14:05 -0700925#endif // VK_USE_PLATFORM_XCB_KHR
926
927#ifdef VK_USE_PLATFORM_XLIB_KHR
928
929/*
930 * Functions for the VK_KHR_xlib_surface extension:
931 */
932
933/*
934 * This is the trampoline entrypoint
935 * for CreateXlibSurfaceKHR
936 */
Mark Young0ad83132016-06-30 13:02:42 -0600937LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR(
938 VkInstance instance, const VkXlibSurfaceCreateInfoKHR *pCreateInfo,
939 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburnf72a04b2015-11-25 17:55:49 -0700940 const VkLayerInstanceDispatchTable *disp;
941 disp = loader_get_instance_dispatch(instance);
942 VkResult res;
943
Jon Ashburn23d36b12016-02-02 17:47:28 -0700944 res =
945 disp->CreateXlibSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
Jon Ashburnf72a04b2015-11-25 17:55:49 -0700946 return res;
947}
948
949/*
950 * This is the instance chain terminator function
951 * for CreateXlibSurfaceKHR
952 */
Mark Young0ad83132016-06-30 13:02:42 -0600953VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXlibSurfaceKHR(
954 VkInstance instance, const VkXlibSurfaceCreateInfoKHR *pCreateInfo,
955 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Ian Elliott2b8965a2016-03-24 13:59:22 -0600956 // First, check to ensure the appropriate extension was enabled:
Ian Elliottdb4300a2015-11-23 10:17:23 -0700957 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott2b8965a2016-03-24 13:59:22 -0600958 if (!ptr_instance->wsi_xlib_surface_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -0600959 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
960 "VK_KHR_xlib_surface extension not enabled. "
961 "vkCreateXlibSurfaceKHR not executed!\n");
Jeremy Hayes9f1d0b62016-06-14 11:50:02 -0600962 return VK_ERROR_EXTENSION_NOT_PRESENT;
Ian Elliott2b8965a2016-03-24 13:59:22 -0600963 }
964
965 // Next, if so, proceed with the implementation of this function:
Ian Elliott2c05e222015-11-19 13:14:05 -0700966 VkIcdSurfaceXlib *pIcdSurface = NULL;
967
Mark Young0ad83132016-06-30 13:02:42 -0600968 pIcdSurface =
969 loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceXlib),
970 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott2c05e222015-11-19 13:14:05 -0700971 if (pIcdSurface == NULL) {
972 return VK_ERROR_OUT_OF_HOST_MEMORY;
973 }
974
975 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_XLIB;
Ian Elliott6e7e6002015-12-10 17:28:50 -0700976 pIcdSurface->dpy = pCreateInfo->dpy;
977 pIcdSurface->window = pCreateInfo->window;
Ian Elliott2c05e222015-11-19 13:14:05 -0700978
Jon Ashburn23d36b12016-02-02 17:47:28 -0700979 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliott2c05e222015-11-19 13:14:05 -0700980
981 return VK_SUCCESS;
982}
Ian Elliott919fa302015-11-24 15:39:10 -0700983
984/*
985 * This is the trampoline entrypoint
986 * for GetPhysicalDeviceXlibPresentationSupportKHR
987 */
Jon Ashburn23d36b12016-02-02 17:47:28 -0700988LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
989vkGetPhysicalDeviceXlibPresentationSupportKHR(VkPhysicalDevice physicalDevice,
990 uint32_t queueFamilyIndex,
991 Display *dpy, VisualID visualID) {
Jon Ashburn014438f2016-03-01 19:51:07 -0700992 VkPhysicalDevice unwrapped_phys_dev =
993 loader_unwrap_physical_device(physicalDevice);
Ian Elliott919fa302015-11-24 15:39:10 -0700994 const VkLayerInstanceDispatchTable *disp;
995 disp = loader_get_instance_dispatch(physicalDevice);
996 VkBool32 res = disp->GetPhysicalDeviceXlibPresentationSupportKHR(
Jon Ashburn014438f2016-03-01 19:51:07 -0700997 unwrapped_phys_dev, queueFamilyIndex, dpy, visualID);
Ian Elliott919fa302015-11-24 15:39:10 -0700998 return res;
999}
1000
Ian Elliott919fa302015-11-24 15:39:10 -07001001/*
1002 * This is the instance chain terminator function
1003 * for GetPhysicalDeviceXlibPresentationSupportKHR
1004 */
Jon Ashburn23d36b12016-02-02 17:47:28 -07001005VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburn1530c342016-02-26 13:14:27 -07001006terminator_GetPhysicalDeviceXlibPresentationSupportKHR(
Jon Ashburn23d36b12016-02-02 17:47:28 -07001007 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, Display *dpy,
1008 VisualID visualID) {
Ian Elliott2b8965a2016-03-24 13:59:22 -06001009 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn23d36b12016-02-02 17:47:28 -07001010 struct loader_physical_device *phys_dev =
1011 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -06001012 struct loader_instance *ptr_instance =
1013 (struct loader_instance *)phys_dev->this_icd->this_instance;
1014 if (!ptr_instance->wsi_xlib_surface_enabled) {
Jon Ashburncc407a22016-04-15 09:25:03 -06001015 loader_log(
1016 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1017 "VK_KHR_xlib_surface extension not enabled. "
1018 "vkGetPhysicalDeviceXlibPresentationSupportKHR not executed!\n");
Ian Elliott2b8965a2016-03-24 13:59:22 -06001019 return VK_SUCCESS;
1020 }
1021
1022 // Next, if so, proceed with the implementation of this function:
Ian Elliott919fa302015-11-24 15:39:10 -07001023 struct loader_icd *icd = phys_dev->this_icd;
1024
Jon Ashburn23d36b12016-02-02 17:47:28 -07001025 assert(
1026 icd->GetPhysicalDeviceXlibPresentationSupportKHR &&
1027 "loader: null GetPhysicalDeviceXlibPresentationSupportKHR ICD pointer");
Ian Elliott919fa302015-11-24 15:39:10 -07001028
Jon Ashburn23d36b12016-02-02 17:47:28 -07001029 return icd->GetPhysicalDeviceXlibPresentationSupportKHR(
1030 phys_dev->phys_dev, queueFamilyIndex, dpy, visualID);
Ian Elliott919fa302015-11-24 15:39:10 -07001031}
Ian Elliott2c05e222015-11-19 13:14:05 -07001032#endif // VK_USE_PLATFORM_XLIB_KHR
1033
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -07001034#ifdef VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott2c05e222015-11-19 13:14:05 -07001035
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -07001036/*
1037 * Functions for the VK_KHR_android_surface extension:
1038 */
1039
1040/*
1041 * This is the trampoline entrypoint
1042 * for CreateAndroidSurfaceKHR
1043 */
Mark Young0ad83132016-06-30 13:02:42 -06001044LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateAndroidSurfaceKHR(
1045 VkInstance instance, ANativeWindow *window,
1046 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -07001047 const VkLayerInstanceDispatchTable *disp;
1048 disp = loader_get_instance_dispatch(instance);
1049 VkResult res;
1050
1051 res = disp->CreateAndroidSurfaceKHR(instance, window, pAllocator, pSurface);
1052 return res;
1053}
1054
1055/*
1056 * This is the instance chain terminator function
1057 * for CreateAndroidSurfaceKHR
1058 */
Mark Young0ad83132016-06-30 13:02:42 -06001059VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateAndroidSurfaceKHR(
1060 VkInstance instance, Window window, const VkAllocationCallbacks *pAllocator,
1061 VkSurfaceKHR *pSurface) {
Ian Elliott2b8965a2016-03-24 13:59:22 -06001062 // First, check to ensure the appropriate extension was enabled:
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -07001063 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott2b8965a2016-03-24 13:59:22 -06001064 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -06001065 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1066 "VK_KHR_display extension not enabled. "
1067 "vkCreateAndroidSurfaceKHR not executed!\n");
Jeremy Hayes9f1d0b62016-06-14 11:50:02 -06001068 return VK_ERROR_EXTENSION_NOT_PRESENT;
Ian Elliott2b8965a2016-03-24 13:59:22 -06001069 }
1070
1071 // Next, if so, proceed with the implementation of this function:
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -07001072 VkIcdSurfaceAndroid *pIcdSurface = NULL;
1073
Mark Young0ad83132016-06-30 13:02:42 -06001074 pIcdSurface =
1075 loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceAndroid),
1076 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -07001077 if (pIcdSurface == NULL) {
1078 return VK_ERROR_OUT_OF_HOST_MEMORY;
1079 }
1080
1081 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_ANDROID;
1082 pIcdSurface->dpy = dpy;
1083 pIcdSurface->window = window;
1084
Jon Ashburn23d36b12016-02-02 17:47:28 -07001085 *pSurface = (VkSurfaceKHR)pIcdSurface;
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -07001086
1087 return VK_SUCCESS;
1088}
1089
1090#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott2c05e222015-11-19 13:14:05 -07001091
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001092/*
1093 * Functions for the VK_KHR_display instance extension:
1094 */
1095LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburncc407a22016-04-15 09:25:03 -06001096vkGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice,
1097 uint32_t *pPropertyCount,
1098 VkDisplayPropertiesKHR *pProperties) {
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001099 VkPhysicalDevice unwrapped_phys_dev =
1100 loader_unwrap_physical_device(physicalDevice);
1101 const VkLayerInstanceDispatchTable *disp;
1102 disp = loader_get_instance_dispatch(physicalDevice);
1103 VkResult res = disp->GetPhysicalDeviceDisplayPropertiesKHR(
1104 unwrapped_phys_dev, pPropertyCount, pProperties);
1105 return res;
1106}
1107
Jon Ashburncc407a22016-04-15 09:25:03 -06001108VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceDisplayPropertiesKHR(
1109 VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
1110 VkDisplayPropertiesKHR *pProperties) {
Ian Elliott2b8965a2016-03-24 13:59:22 -06001111 // First, check to ensure the appropriate extension was enabled:
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001112 struct loader_physical_device *phys_dev =
1113 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -06001114 struct loader_instance *ptr_instance =
1115 (struct loader_instance *)phys_dev->this_icd->this_instance;
1116 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -06001117 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1118 "VK_KHR_display extension not enabled. "
1119 "vkGetPhysicalDeviceDisplayPropertiesKHR not executed!\n");
Ian Elliott2b8965a2016-03-24 13:59:22 -06001120 return VK_SUCCESS;
1121 }
1122
1123 // Next, if so, proceed with the implementation of this function:
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001124 struct loader_icd *icd = phys_dev->this_icd;
1125
Jon Ashburncc407a22016-04-15 09:25:03 -06001126 assert(icd->GetPhysicalDeviceDisplayPropertiesKHR &&
1127 "loader: null GetPhysicalDeviceDisplayPropertiesKHR ICD pointer");
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001128
1129 return icd->GetPhysicalDeviceDisplayPropertiesKHR(
1130 phys_dev->phys_dev, pPropertyCount, pProperties);
1131}
1132
1133LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1134vkGetPhysicalDeviceDisplayPlanePropertiesKHR(
Jon Ashburncc407a22016-04-15 09:25:03 -06001135 VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
1136 VkDisplayPlanePropertiesKHR *pProperties) {
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001137 VkPhysicalDevice unwrapped_phys_dev =
1138 loader_unwrap_physical_device(physicalDevice);
1139 const VkLayerInstanceDispatchTable *disp;
1140 disp = loader_get_instance_dispatch(physicalDevice);
1141 VkResult res = disp->GetPhysicalDeviceDisplayPlanePropertiesKHR(
1142 unwrapped_phys_dev, pPropertyCount, pProperties);
1143 return res;
1144}
1145
1146VKAPI_ATTR VkResult VKAPI_CALL
1147terminator_GetPhysicalDeviceDisplayPlanePropertiesKHR(
Jon Ashburncc407a22016-04-15 09:25:03 -06001148 VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
1149 VkDisplayPlanePropertiesKHR *pProperties) {
Ian Elliott2b8965a2016-03-24 13:59:22 -06001150 // First, check to ensure the appropriate extension was enabled:
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001151 struct loader_physical_device *phys_dev =
1152 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -06001153 struct loader_instance *ptr_instance =
1154 (struct loader_instance *)phys_dev->this_icd->this_instance;
1155 if (!ptr_instance->wsi_display_enabled) {
Jon Ashburncc407a22016-04-15 09:25:03 -06001156 loader_log(
1157 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1158 "VK_KHR_display extension not enabled. "
1159 "vkGetPhysicalDeviceDisplayPlanePropertiesKHR not executed!\n");
Ian Elliott2b8965a2016-03-24 13:59:22 -06001160 return VK_SUCCESS;
1161 }
1162
1163 // Next, if so, proceed with the implementation of this function:
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001164 struct loader_icd *icd = phys_dev->this_icd;
1165
1166 assert(
1167 icd->GetPhysicalDeviceDisplayPlanePropertiesKHR &&
1168 "loader: null GetPhysicalDeviceDisplayPlanePropertiesKHR ICD pointer");
1169
1170 return icd->GetPhysicalDeviceDisplayPlanePropertiesKHR(
1171 phys_dev->phys_dev, pPropertyCount, pProperties);
1172}
1173
1174LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburncc407a22016-04-15 09:25:03 -06001175vkGetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice,
1176 uint32_t planeIndex,
1177 uint32_t *pDisplayCount,
1178 VkDisplayKHR *pDisplays) {
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001179 VkPhysicalDevice unwrapped_phys_dev =
1180 loader_unwrap_physical_device(physicalDevice);
1181 const VkLayerInstanceDispatchTable *disp;
1182 disp = loader_get_instance_dispatch(physicalDevice);
1183 VkResult res = disp->GetDisplayPlaneSupportedDisplaysKHR(
1184 unwrapped_phys_dev, planeIndex, pDisplayCount, pDisplays);
1185 return res;
1186}
1187
1188VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburncc407a22016-04-15 09:25:03 -06001189terminator_GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice,
1190 uint32_t planeIndex,
1191 uint32_t *pDisplayCount,
1192 VkDisplayKHR *pDisplays) {
Ian Elliott2b8965a2016-03-24 13:59:22 -06001193 // First, check to ensure the appropriate extension was enabled:
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001194 struct loader_physical_device *phys_dev =
1195 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -06001196 struct loader_instance *ptr_instance =
1197 (struct loader_instance *)phys_dev->this_icd->this_instance;
1198 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -06001199 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1200 "VK_KHR_display extension not enabled. "
1201 "vkGetDisplayPlaneSupportedDisplaysKHR not executed!\n");
Ian Elliott2b8965a2016-03-24 13:59:22 -06001202 return VK_SUCCESS;
1203 }
1204
1205 // Next, if so, proceed with the implementation of this function:
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001206 struct loader_icd *icd = phys_dev->this_icd;
1207
Jon Ashburncc407a22016-04-15 09:25:03 -06001208 assert(icd->GetDisplayPlaneSupportedDisplaysKHR &&
1209 "loader: null GetDisplayPlaneSupportedDisplaysKHR ICD pointer");
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001210
1211 return icd->GetDisplayPlaneSupportedDisplaysKHR(
1212 phys_dev->phys_dev, planeIndex, pDisplayCount, pDisplays);
1213}
1214
1215LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburncc407a22016-04-15 09:25:03 -06001216vkGetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice,
1217 VkDisplayKHR display, uint32_t *pPropertyCount,
1218 VkDisplayModePropertiesKHR *pProperties) {
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001219 VkPhysicalDevice unwrapped_phys_dev =
1220 loader_unwrap_physical_device(physicalDevice);
1221 const VkLayerInstanceDispatchTable *disp;
1222 disp = loader_get_instance_dispatch(physicalDevice);
1223 VkResult res = disp->GetDisplayModePropertiesKHR(
1224 unwrapped_phys_dev, display, pPropertyCount, pProperties);
1225 return res;
1226}
1227
Jon Ashburncc407a22016-04-15 09:25:03 -06001228VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayModePropertiesKHR(
1229 VkPhysicalDevice physicalDevice, VkDisplayKHR display,
1230 uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties) {
Ian Elliott2b8965a2016-03-24 13:59:22 -06001231 // First, check to ensure the appropriate extension was enabled:
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001232 struct loader_physical_device *phys_dev =
1233 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -06001234 struct loader_instance *ptr_instance =
1235 (struct loader_instance *)phys_dev->this_icd->this_instance;
1236 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -06001237 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1238 "VK_KHR_display extension not enabled. "
1239 "vkGetDisplayModePropertiesKHR not executed!\n");
Ian Elliott2b8965a2016-03-24 13:59:22 -06001240 return VK_SUCCESS;
1241 }
1242
1243 // Next, if so, proceed with the implementation of this function:
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001244 struct loader_icd *icd = phys_dev->this_icd;
1245
Jon Ashburncc407a22016-04-15 09:25:03 -06001246 assert(icd->GetDisplayModePropertiesKHR &&
1247 "loader: null GetDisplayModePropertiesKHR ICD pointer");
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001248
Jon Ashburncc407a22016-04-15 09:25:03 -06001249 return icd->GetDisplayModePropertiesKHR(phys_dev->phys_dev, display,
1250 pPropertyCount, pProperties);
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001251}
1252
Mark Young0ad83132016-06-30 13:02:42 -06001253LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayModeKHR(
1254 VkPhysicalDevice physicalDevice, VkDisplayKHR display,
1255 const VkDisplayModeCreateInfoKHR *pCreateInfo,
1256 const VkAllocationCallbacks *pAllocator, VkDisplayModeKHR *pMode) {
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001257 VkPhysicalDevice unwrapped_phys_dev =
1258 loader_unwrap_physical_device(physicalDevice);
1259 const VkLayerInstanceDispatchTable *disp;
1260 disp = loader_get_instance_dispatch(physicalDevice);
Jon Ashburncc407a22016-04-15 09:25:03 -06001261 VkResult res = disp->CreateDisplayModeKHR(unwrapped_phys_dev, display,
1262 pCreateInfo, pAllocator, pMode);
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001263 return res;
1264}
1265
Mark Young0ad83132016-06-30 13:02:42 -06001266VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayModeKHR(
1267 VkPhysicalDevice physicalDevice, VkDisplayKHR display,
1268 const VkDisplayModeCreateInfoKHR *pCreateInfo,
1269 const VkAllocationCallbacks *pAllocator, VkDisplayModeKHR *pMode) {
Ian Elliott2b8965a2016-03-24 13:59:22 -06001270 // First, check to ensure the appropriate extension was enabled:
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001271 struct loader_physical_device *phys_dev =
1272 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -06001273 struct loader_instance *ptr_instance =
1274 (struct loader_instance *)phys_dev->this_icd->this_instance;
1275 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -06001276 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1277 "VK_KHR_display extension not enabled. "
1278 "vkCreateDisplayModeKHR not executed!\n");
Jeremy Hayes9f1d0b62016-06-14 11:50:02 -06001279 return VK_ERROR_EXTENSION_NOT_PRESENT;
Ian Elliott2b8965a2016-03-24 13:59:22 -06001280 }
1281
1282 // Next, if so, proceed with the implementation of this function:
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001283 struct loader_icd *icd = phys_dev->this_icd;
1284
Jon Ashburncc407a22016-04-15 09:25:03 -06001285 assert(icd->CreateDisplayModeKHR &&
1286 "loader: null CreateDisplayModeKHR ICD pointer");
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001287
Jon Ashburncc407a22016-04-15 09:25:03 -06001288 return icd->CreateDisplayModeKHR(phys_dev->phys_dev, display, pCreateInfo,
1289 pAllocator, pMode);
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001290}
1291
1292LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburncc407a22016-04-15 09:25:03 -06001293vkGetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physicalDevice,
1294 VkDisplayModeKHR mode, uint32_t planeIndex,
1295 VkDisplayPlaneCapabilitiesKHR *pCapabilities) {
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001296 VkPhysicalDevice unwrapped_phys_dev =
1297 loader_unwrap_physical_device(physicalDevice);
1298 const VkLayerInstanceDispatchTable *disp;
1299 disp = loader_get_instance_dispatch(physicalDevice);
1300 VkResult res = disp->GetDisplayPlaneCapabilitiesKHR(
1301 unwrapped_phys_dev, mode, planeIndex, pCapabilities);
1302 return res;
1303}
1304
Jon Ashburncc407a22016-04-15 09:25:03 -06001305VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayPlaneCapabilitiesKHR(
1306 VkPhysicalDevice physicalDevice, VkDisplayModeKHR mode, uint32_t planeIndex,
1307 VkDisplayPlaneCapabilitiesKHR *pCapabilities) {
Ian Elliott2b8965a2016-03-24 13:59:22 -06001308 // First, check to ensure the appropriate extension was enabled:
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001309 struct loader_physical_device *phys_dev =
1310 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -06001311 struct loader_instance *ptr_instance =
1312 (struct loader_instance *)phys_dev->this_icd->this_instance;
1313 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -06001314 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1315 "VK_KHR_display extension not enabled. "
1316 "vkGetDisplayPlaneCapabilitiesKHR not executed!\n");
Ian Elliott2b8965a2016-03-24 13:59:22 -06001317 return VK_SUCCESS;
1318 }
1319
1320 // Next, if so, proceed with the implementation of this function:
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001321 struct loader_icd *icd = phys_dev->this_icd;
1322
Jon Ashburncc407a22016-04-15 09:25:03 -06001323 assert(icd->GetDisplayPlaneCapabilitiesKHR &&
1324 "loader: null GetDisplayPlaneCapabilitiesKHR ICD pointer");
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001325
Jon Ashburncc407a22016-04-15 09:25:03 -06001326 return icd->GetDisplayPlaneCapabilitiesKHR(phys_dev->phys_dev, mode,
1327 planeIndex, pCapabilities);
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001328}
1329
Mark Young0ad83132016-06-30 13:02:42 -06001330LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayPlaneSurfaceKHR(
1331 VkInstance instance, const VkDisplaySurfaceCreateInfoKHR *pCreateInfo,
1332 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001333 const VkLayerInstanceDispatchTable *disp;
1334 disp = loader_get_instance_dispatch(instance);
1335 VkResult res;
1336
1337 res = disp->CreateDisplayPlaneSurfaceKHR(instance, pCreateInfo, pAllocator,
1338 pSurface);
1339 return res;
1340}
1341
Jon Ashburncc407a22016-04-15 09:25:03 -06001342VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayPlaneSurfaceKHR(
1343 VkInstance instance, const VkDisplaySurfaceCreateInfoKHR *pCreateInfo,
1344 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001345 struct loader_instance *inst = loader_get_instance(instance);
1346 VkIcdSurfaceDisplay *pIcdSurface = NULL;
1347
Petros Bantolas25d27fe2016-04-14 12:50:42 +01001348 if (!inst->wsi_surface_enabled) {
1349 loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1350 "VK_KHR_surface extension not enabled. "
1351 "vkCreateDisplayPlaneSurfaceKHR not executed!\n");
Jeremy Hayes9f1d0b62016-06-14 11:50:02 -06001352 return VK_ERROR_EXTENSION_NOT_PRESENT;
Petros Bantolas25d27fe2016-04-14 12:50:42 +01001353 }
1354
Mark Young0ad83132016-06-30 13:02:42 -06001355 pIcdSurface = loader_instance_heap_alloc(
1356 inst, sizeof(VkIcdSurfaceDisplay), VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001357 if (pIcdSurface == NULL) {
1358 return VK_ERROR_OUT_OF_HOST_MEMORY;
1359 }
1360
1361 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_DISPLAY;
1362 pIcdSurface->displayMode = pCreateInfo->displayMode;
1363 pIcdSurface->planeIndex = pCreateInfo->planeIndex;
1364 pIcdSurface->planeStackIndex = pCreateInfo->planeStackIndex;
1365 pIcdSurface->transform = pCreateInfo->transform;
1366 pIcdSurface->globalAlpha = pCreateInfo->globalAlpha;
1367 pIcdSurface->alphaMode = pCreateInfo->alphaMode;
1368 pIcdSurface->imageExtent = pCreateInfo->imageExtent;
1369
1370 *pSurface = (VkSurfaceKHR)pIcdSurface;
1371
1372 return VK_SUCCESS;
1373}
1374
Ian Elliott954fa342015-10-30 15:28:23 -06001375bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance,
Jon Ashburn23d36b12016-02-02 17:47:28 -07001376 const char *name, void **addr) {
Ian Elliott954fa342015-10-30 15:28:23 -06001377 *addr = NULL;
1378
Ian Elliott934d0d52015-11-19 16:39:21 -07001379 /*
1380 * Functions for the VK_KHR_surface extension:
1381 */
Ian Elliott2c05e222015-11-19 13:14:05 -07001382 if (!strcmp("vkDestroySurfaceKHR", name)) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001383 *addr = ptr_instance->wsi_surface_enabled ? (void *)vkDestroySurfaceKHR
1384 : NULL;
Ian Elliott2c05e222015-11-19 13:14:05 -07001385 return true;
1386 }
Ian Elliott954fa342015-10-30 15:28:23 -06001387 if (!strcmp("vkGetPhysicalDeviceSurfaceSupportKHR", name)) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001388 *addr = ptr_instance->wsi_surface_enabled
1389 ? (void *)vkGetPhysicalDeviceSurfaceSupportKHR
1390 : NULL;
Ian Elliott954fa342015-10-30 15:28:23 -06001391 return true;
1392 }
Ian Elliott486c5502015-11-19 16:05:09 -07001393 if (!strcmp("vkGetPhysicalDeviceSurfaceCapabilitiesKHR", name)) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001394 *addr = ptr_instance->wsi_surface_enabled
1395 ? (void *)vkGetPhysicalDeviceSurfaceCapabilitiesKHR
1396 : NULL;
Ian Elliott486c5502015-11-19 16:05:09 -07001397 return true;
1398 }
1399 if (!strcmp("vkGetPhysicalDeviceSurfaceFormatsKHR", name)) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001400 *addr = ptr_instance->wsi_surface_enabled
1401 ? (void *)vkGetPhysicalDeviceSurfaceFormatsKHR
1402 : NULL;
Ian Elliott486c5502015-11-19 16:05:09 -07001403 return true;
1404 }
1405 if (!strcmp("vkGetPhysicalDeviceSurfacePresentModesKHR", name)) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001406 *addr = ptr_instance->wsi_surface_enabled
1407 ? (void *)vkGetPhysicalDeviceSurfacePresentModesKHR
1408 : NULL;
Ian Elliott486c5502015-11-19 16:05:09 -07001409 return true;
1410 }
Ian Elliott934d0d52015-11-19 16:39:21 -07001411
1412 /*
1413 * Functions for the VK_KHR_swapchain extension:
1414 *
1415 * Note: This is a device extension, and its functions are statically
1416 * exported from the loader. Per Khronos decisions, the the loader's GIPA
1417 * function will return the trampoline function for such device-extension
1418 * functions, regardless of whether the extension has been enabled.
1419 */
1420 if (!strcmp("vkCreateSwapchainKHR", name)) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001421 *addr = (void *)vkCreateSwapchainKHR;
Ian Elliott934d0d52015-11-19 16:39:21 -07001422 return true;
1423 }
1424 if (!strcmp("vkDestroySwapchainKHR", name)) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001425 *addr = (void *)vkDestroySwapchainKHR;
Ian Elliott934d0d52015-11-19 16:39:21 -07001426 return true;
1427 }
1428 if (!strcmp("vkGetSwapchainImagesKHR", name)) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001429 *addr = (void *)vkGetSwapchainImagesKHR;
Ian Elliott934d0d52015-11-19 16:39:21 -07001430 return true;
1431 }
1432 if (!strcmp("vkAcquireNextImageKHR", name)) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001433 *addr = (void *)vkAcquireNextImageKHR;
Ian Elliott934d0d52015-11-19 16:39:21 -07001434 return true;
1435 }
1436 if (!strcmp("vkQueuePresentKHR", name)) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001437 *addr = (void *)vkQueuePresentKHR;
Ian Elliott934d0d52015-11-19 16:39:21 -07001438 return true;
1439 }
1440
Ian Elliott2c05e222015-11-19 13:14:05 -07001441#ifdef VK_USE_PLATFORM_WIN32_KHR
Ian Elliott934d0d52015-11-19 16:39:21 -07001442 /*
1443 * Functions for the VK_KHR_win32_surface extension:
1444 */
Ian Elliott2c05e222015-11-19 13:14:05 -07001445 if (!strcmp("vkCreateWin32SurfaceKHR", name)) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001446 *addr = ptr_instance->wsi_win32_surface_enabled
1447 ? (void *)vkCreateWin32SurfaceKHR
1448 : NULL;
Ian Elliott2c05e222015-11-19 13:14:05 -07001449 return true;
1450 }
Ian Elliott919fa302015-11-24 15:39:10 -07001451 if (!strcmp("vkGetPhysicalDeviceWin32PresentationSupportKHR", name)) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001452 *addr = ptr_instance->wsi_win32_surface_enabled
1453 ? (void *)vkGetPhysicalDeviceWin32PresentationSupportKHR
1454 : NULL;
Ian Elliott919fa302015-11-24 15:39:10 -07001455 return true;
1456 }
Ian Elliott2c05e222015-11-19 13:14:05 -07001457#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliott2c05e222015-11-19 13:14:05 -07001458#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott934d0d52015-11-19 16:39:21 -07001459 /*
1460 * Functions for the VK_KHR_mir_surface extension:
1461 */
Ian Elliott2c05e222015-11-19 13:14:05 -07001462 if (!strcmp("vkCreateMirSurfaceKHR", name)) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001463 *addr = ptr_instance->wsi_mir_surface_enabled
1464 ? (void *)vkCreateMirSurfaceKHR
1465 : NULL;
Ian Elliott2c05e222015-11-19 13:14:05 -07001466 return true;
1467 }
Ian Elliott919fa302015-11-24 15:39:10 -07001468 if (!strcmp("vkGetPhysicalDeviceMirPresentationSupportKHR", name)) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001469 *addr = ptr_instance->wsi_mir_surface_enabled
1470 ? (void *)vkGetPhysicalDeviceMirPresentationSupportKHR
1471 : NULL;
Ian Elliott919fa302015-11-24 15:39:10 -07001472 return true;
Jason Ekstranda5ebe8a2016-02-12 17:25:03 -08001473 }
Ian Elliott2c05e222015-11-19 13:14:05 -07001474#endif // VK_USE_PLATFORM_MIR_KHR
1475#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Jon Ashburn1530c342016-02-26 13:14:27 -07001476 /*
1477 * Functions for the VK_KHR_wayland_surface extension:
1478 */
1479 if (!strcmp("vkCreateWaylandSurfaceKHR", name)) {
1480 *addr = ptr_instance->wsi_wayland_surface_enabled
1481 ? (void *)vkCreateWaylandSurfaceKHR
1482 : NULL;
1483 return true;
1484 }
1485 if (!strcmp("vkGetPhysicalDeviceWaylandPresentationSupportKHR", name)) {
1486 *addr = ptr_instance->wsi_wayland_surface_enabled
Jon Ashburn23d36b12016-02-02 17:47:28 -07001487 ? (void *)vkGetPhysicalDeviceWaylandPresentationSupportKHR
1488 : NULL;
Jon Ashburn1530c342016-02-26 13:14:27 -07001489 return true;
1490 }
Ian Elliott2c05e222015-11-19 13:14:05 -07001491#endif // VK_USE_PLATFORM_WAYLAND_KHR
1492#ifdef VK_USE_PLATFORM_XCB_KHR
Jon Ashburn1530c342016-02-26 13:14:27 -07001493 /*
1494 * Functions for the VK_KHR_xcb_surface extension:
1495 */
1496 if (!strcmp("vkCreateXcbSurfaceKHR", name)) {
1497 *addr = ptr_instance->wsi_xcb_surface_enabled
1498 ? (void *)vkCreateXcbSurfaceKHR
1499 : NULL;
1500 return true;
1501 }
1502 if (!strcmp("vkGetPhysicalDeviceXcbPresentationSupportKHR", name)) {
1503 *addr = ptr_instance->wsi_xcb_surface_enabled
1504 ? (void *)vkGetPhysicalDeviceXcbPresentationSupportKHR
1505 : NULL;
1506 return true;
1507 }
Ian Elliott2c05e222015-11-19 13:14:05 -07001508#endif // VK_USE_PLATFORM_XCB_KHR
1509#ifdef VK_USE_PLATFORM_XLIB_KHR
Jon Ashburn1530c342016-02-26 13:14:27 -07001510 /*
1511 * Functions for the VK_KHR_xlib_surface extension:
1512 */
1513 if (!strcmp("vkCreateXlibSurfaceKHR", name)) {
1514 *addr = ptr_instance->wsi_xlib_surface_enabled
1515 ? (void *)vkCreateXlibSurfaceKHR
1516 : NULL;
1517 return true;
1518 }
1519 if (!strcmp("vkGetPhysicalDeviceXlibPresentationSupportKHR", name)) {
1520 *addr = ptr_instance->wsi_xlib_surface_enabled
1521 ? (void *)vkGetPhysicalDeviceXlibPresentationSupportKHR
1522 : NULL;
1523 return true;
1524 }
Ian Elliott2c05e222015-11-19 13:14:05 -07001525#endif // VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -07001526#ifdef VK_USE_PLATFORM_ANDROID_KHR
Jon Ashburn1530c342016-02-26 13:14:27 -07001527 /*
1528 * Functions for the VK_KHR_android_surface extension:
1529 */
1530 if (!strcmp("vkCreateAndroidSurfaceKHR", name)) {
1531 *addr = ptr_instance->wsi_xlib_surface_enabled
1532 ? (void *)vkCreateAndroidSurfaceKHR
1533 : NULL;
1534 return true;
1535 }
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -07001536#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott2c05e222015-11-19 13:14:05 -07001537
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001538 /*
1539 * Functions for VK_KHR_display extension:
1540 */
1541 if (!strcmp("vkGetPhysicalDeviceDisplayPropertiesKHR", name)) {
1542 *addr = ptr_instance->wsi_display_enabled
1543 ? (void *)vkGetPhysicalDeviceDisplayPropertiesKHR
1544 : NULL;
1545 return true;
1546 }
1547 if (!strcmp("vkGetPhysicalDeviceDisplayPlanePropertiesKHR", name)) {
1548 *addr = ptr_instance->wsi_display_enabled
1549 ? (void *)vkGetPhysicalDeviceDisplayPlanePropertiesKHR
1550 : NULL;
1551 return true;
1552 }
1553 if (!strcmp("vkGetDisplayPlaneSupportedDisplaysKHR", name)) {
1554 *addr = ptr_instance->wsi_display_enabled
1555 ? (void *)vkGetDisplayPlaneSupportedDisplaysKHR
1556 : NULL;
1557 return true;
1558 }
1559 if (!strcmp("vkGetDisplayModePropertiesKHR", name)) {
1560 *addr = ptr_instance->wsi_display_enabled
1561 ? (void *)vkGetDisplayModePropertiesKHR
1562 : NULL;
1563 return true;
1564 }
1565 if (!strcmp("vkCreateDisplayModeKHR", name)) {
1566 *addr = ptr_instance->wsi_display_enabled
1567 ? (void *)vkCreateDisplayModeKHR
1568 : NULL;
1569 return true;
1570 }
1571 if (!strcmp("vkGetDisplayPlaneCapabilitiesKHR", name)) {
1572 *addr = ptr_instance->wsi_display_enabled
1573 ? (void *)vkGetDisplayPlaneCapabilitiesKHR
1574 : NULL;
1575 return true;
1576 }
1577 if (!strcmp("vkCreateDisplayPlaneSurfaceKHR", name)) {
1578 *addr = ptr_instance->wsi_display_enabled
1579 ? (void *)vkCreateDisplayPlaneSurfaceKHR
1580 : NULL;
1581 return true;
1582 }
Jon Ashburn1530c342016-02-26 13:14:27 -07001583 return false;
Ian Elliott2b8965a2016-03-24 13:59:22 -06001584}