blob: a74cdb4b709e25916250153355f48c4253134080 [file] [log] [blame]
Ian Elliott54cea232015-10-30 15:28:23 -06001/*
Jon Ashburn1c75aec2016-02-02 17:47:28 -07002 * Copyright (c) 2015-2016 The Khronos Group Inc.
3 * Copyright (c) 2015-2016 Valve Corporation
4 * Copyright (c) 2015-2016 LunarG, Inc.
Ian Elliott54cea232015-10-30 15:28:23 -06005 *
Jon Ashburn4f80d672016-04-19 11:30:31 -06006 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
Ian Elliott54cea232015-10-30 15:28:23 -06009 *
Jon Ashburn4f80d672016-04-19 11:30:31 -060010 * http://www.apache.org/licenses/LICENSE-2.0
Ian Elliott54cea232015-10-30 15:28:23 -060011 *
Jon Ashburn4f80d672016-04-19 11:30:31 -060012 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
Ian Elliott54cea232015-10-30 15:28:23 -060017 *
18 * Author: Ian Elliott <ian@lunarg.com>
Jon Ashburn1c75aec2016-02-02 17:47:28 -070019 * Author: Jon Ashburn <jon@lunarg.com>
Ian Elliottb1849742015-11-19 11:58:08 -070020 * Author: Ian Elliott <ianelliott@google.com>
Jon Ashburn1c75aec2016-02-02 17:47:28 -070021 * Author: Mark Lobodzinski <mark@lunarg.com>
Ian Elliott54cea232015-10-30 15:28:23 -060022 */
23
Ian Elliott54cea232015-10-30 15:28:23 -060024#define _GNU_SOURCE
Ian Elliott0d4ffa32016-03-24 13:59:22 -060025#include <stdio.h>
Ian Elliott54cea232015-10-30 15:28:23 -060026#include <stdlib.h>
27#include <string.h>
28#include "vk_loader_platform.h"
29#include "loader.h"
30#include "wsi.h"
Ian Elliott7c352552015-11-19 13:14:05 -070031#include <vulkan/vk_icd.h>
Ian Elliott54cea232015-10-30 15:28:23 -060032
33static const VkExtensionProperties wsi_surface_extension_info = {
Jon Ashburn1c75aec2016-02-02 17:47:28 -070034 .extensionName = VK_KHR_SURFACE_EXTENSION_NAME,
35 .specVersion = VK_KHR_SURFACE_SPEC_VERSION,
Ian Elliott54cea232015-10-30 15:28:23 -060036};
37
Ian Elliottb1849742015-11-19 11:58:08 -070038#ifdef VK_USE_PLATFORM_WIN32_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060039static const VkExtensionProperties wsi_win32_surface_extension_info = {
Jon Ashburn1c75aec2016-02-02 17:47:28 -070040 .extensionName = VK_KHR_WIN32_SURFACE_EXTENSION_NAME,
41 .specVersion = VK_KHR_WIN32_SURFACE_SPEC_VERSION,
Ian Elliott54cea232015-10-30 15:28:23 -060042};
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -070043#endif // VK_USE_PLATFORM_WIN32_KHR
44
Ian Elliott5fb891a2015-10-30 17:45:05 -060045#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060046static const VkExtensionProperties wsi_mir_surface_extension_info = {
Jon Ashburn1c75aec2016-02-02 17:47:28 -070047 .extensionName = VK_KHR_MIR_SURFACE_EXTENSION_NAME,
48 .specVersion = VK_KHR_MIR_SURFACE_SPEC_VERSION,
Ian Elliott54cea232015-10-30 15:28:23 -060049};
Ian Elliott5fb891a2015-10-30 17:45:05 -060050#endif // VK_USE_PLATFORM_MIR_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060051
Ian Elliott5fb891a2015-10-30 17:45:05 -060052#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060053static const VkExtensionProperties wsi_wayland_surface_extension_info = {
Jon Ashburn1c75aec2016-02-02 17:47:28 -070054 .extensionName = VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME,
55 .specVersion = VK_KHR_WAYLAND_SURFACE_SPEC_VERSION,
Ian Elliott54cea232015-10-30 15:28:23 -060056};
Ian Elliott5fb891a2015-10-30 17:45:05 -060057#endif // VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060058
Ian Elliott5fb891a2015-10-30 17:45:05 -060059#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060060static const VkExtensionProperties wsi_xcb_surface_extension_info = {
Jon Ashburn1c75aec2016-02-02 17:47:28 -070061 .extensionName = VK_KHR_XCB_SURFACE_EXTENSION_NAME,
62 .specVersion = VK_KHR_XCB_SURFACE_SPEC_VERSION,
Ian Elliott54cea232015-10-30 15:28:23 -060063};
Ian Elliott5fb891a2015-10-30 17:45:05 -060064#endif // VK_USE_PLATFORM_XCB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060065
Ian Elliott5fb891a2015-10-30 17:45:05 -060066#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060067static const VkExtensionProperties wsi_xlib_surface_extension_info = {
Jon Ashburn1c75aec2016-02-02 17:47:28 -070068 .extensionName = VK_KHR_XLIB_SURFACE_EXTENSION_NAME,
69 .specVersion = VK_KHR_XLIB_SURFACE_SPEC_VERSION,
Ian Elliott54cea232015-10-30 15:28:23 -060070};
Ian Elliott5fb891a2015-10-30 17:45:05 -060071#endif // VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -070072
73#ifdef VK_USE_PLATFORM_ANDROID_KHR
74static const VkExtensionProperties wsi_android_surface_extension_info = {
Jon Ashburn1c75aec2016-02-02 17:47:28 -070075 .extensionName = VK_KHR_ANDROID_SURFACE_EXTENSION_NAME,
76 .specVersion = VK_KHR_ANDROID_SURFACE_REVISION,
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -070077};
78#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060079
Jon Ashburn1c75aec2016-02-02 17:47:28 -070080void wsi_create_instance(struct loader_instance *ptr_instance,
81 const VkInstanceCreateInfo *pCreateInfo) {
Ian Elliott5fb891a2015-10-30 17:45:05 -060082 ptr_instance->wsi_surface_enabled = false;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -070083
84#ifdef VK_USE_PLATFORM_WIN32_KHR
Jon Ashburncc370d02016-03-08 09:30:30 -070085 ptr_instance->wsi_win32_surface_enabled = false;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -070086#endif // VK_USE_PLATFORM_WIN32_KHR
87#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060088 ptr_instance->wsi_mir_surface_enabled = false;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -070089#endif // VK_USE_PLATFORM_MIR_KHR
90#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060091 ptr_instance->wsi_wayland_surface_enabled = false;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -070092#endif // VK_USE_PLATFORM_WAYLAND_KHR
93#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060094 ptr_instance->wsi_xcb_surface_enabled = false;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -070095#endif // VK_USE_PLATFORM_XCB_KHR
96#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060097 ptr_instance->wsi_xlib_surface_enabled = false;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -070098#endif // VK_USE_PLATFORM_XLIB_KHR
99#ifdef VK_USE_PLATFORM_ANDROID_KHR
100 ptr_instance->wsi_android_surface_enabled = false;
101#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600102
Jon Ashburncc370d02016-03-08 09:30:30 -0700103 ptr_instance->wsi_display_enabled = false;
104
Jon Ashburna0673ab2016-01-11 13:12:43 -0700105 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700106 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
107 VK_KHR_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott54cea232015-10-30 15:28:23 -0600108 ptr_instance->wsi_surface_enabled = true;
Ian Elliottb1849742015-11-19 11:58:08 -0700109 continue;
Ian Elliott54cea232015-10-30 15:28:23 -0600110 }
Ian Elliottb1849742015-11-19 11:58:08 -0700111#ifdef VK_USE_PLATFORM_WIN32_KHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700112 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
113 VK_KHR_WIN32_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott1693f592015-11-23 10:17:23 -0700114 ptr_instance->wsi_win32_surface_enabled = true;
Ian Elliottb1849742015-11-19 11:58:08 -0700115 continue;
Ian Elliott54cea232015-10-30 15:28:23 -0600116 }
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700117#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliott5fb891a2015-10-30 17:45:05 -0600118#ifdef VK_USE_PLATFORM_MIR_KHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700119 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
120 VK_KHR_MIR_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott54cea232015-10-30 15:28:23 -0600121 ptr_instance->wsi_mir_surface_enabled = true;
Ian Elliottb1849742015-11-19 11:58:08 -0700122 continue;
Ian Elliott54cea232015-10-30 15:28:23 -0600123 }
Ian Elliott5fb891a2015-10-30 17:45:05 -0600124#endif // VK_USE_PLATFORM_MIR_KHR
125#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700126 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
127 VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott54cea232015-10-30 15:28:23 -0600128 ptr_instance->wsi_wayland_surface_enabled = true;
Ian Elliottb1849742015-11-19 11:58:08 -0700129 continue;
Ian Elliott54cea232015-10-30 15:28:23 -0600130 }
Ian Elliott5fb891a2015-10-30 17:45:05 -0600131#endif // VK_USE_PLATFORM_WAYLAND_KHR
132#ifdef VK_USE_PLATFORM_XCB_KHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700133 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
134 VK_KHR_XCB_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott54cea232015-10-30 15:28:23 -0600135 ptr_instance->wsi_xcb_surface_enabled = true;
Ian Elliottb1849742015-11-19 11:58:08 -0700136 continue;
Ian Elliott54cea232015-10-30 15:28:23 -0600137 }
Ian Elliott5fb891a2015-10-30 17:45:05 -0600138#endif // VK_USE_PLATFORM_XCB_KHR
139#ifdef VK_USE_PLATFORM_XLIB_KHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700140 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
141 VK_KHR_XLIB_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott54cea232015-10-30 15:28:23 -0600142 ptr_instance->wsi_xlib_surface_enabled = true;
Ian Elliottb1849742015-11-19 11:58:08 -0700143 continue;
Ian Elliott54cea232015-10-30 15:28:23 -0600144 }
Ian Elliott5fb891a2015-10-30 17:45:05 -0600145#endif // VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700146#ifdef VK_USE_PLATFORM_ANDROID_KHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700147 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
148 VK_KHR_ANDROID_SURFACE_EXTENSION_NAME) == 0) {
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700149 ptr_instance->wsi_android_surface_enabled = true;
150 continue;
151 }
152#endif // VK_USE_PLATFORM_ANDROID_KHR
Jon Ashburncc370d02016-03-08 09:30:30 -0700153 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
154 VK_KHR_DISPLAY_EXTENSION_NAME) == 0) {
155 ptr_instance->wsi_display_enabled = true;
156 continue;
157 }
Ian Elliott54cea232015-10-30 15:28:23 -0600158 }
159}
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600160
161// Linux WSI surface extensions are not always compiled into the loader. (Assume
162// for Windows the KHR_win32_surface is always compiled into loader). A given
163// Linux build environment might not have the headers required for building one
164// of the four extensions (Xlib, Xcb, Mir, Wayland). Thus, need to check if
165// the built loader actually supports the particular Linux surface extension.
166// If not supported by the built loader it will not be included in the list of
167// enumerated instance extensions. This solves the issue where an ICD or layer
168// advertises support for a given Linux surface extension but the loader was not
169// built to support the extension.
Jon Ashburnae8f1e82016-03-25 12:49:35 -0600170bool wsi_unsupported_instance_extension(const VkExtensionProperties *ext_prop) {
171#ifndef VK_USE_PLATFORM_MIR_KHR
172 if (!strcmp(ext_prop->extensionName, "VK_KHR_mir_surface"))
173 return true;
174#endif // VK_USE_PLATFORM_MIR_KHR
175#ifndef VK_USE_PLATFORM_WAYLAND_KHR
176 if (!strcmp(ext_prop->extensionName, "VK_KHR_wayland_surface"))
177 return true;
178#endif // VK_USE_PLATFORM_WAYLAND_KHR
179#ifndef VK_USE_PLATFORM_XCB_KHR
180 if (!strcmp(ext_prop->extensionName, "VK_KHR_xcb_surface"))
181 return true;
182#endif // VK_USE_PLATFORM_XCB_KHR
183#ifndef VK_USE_PLATFORM_XLIB_KHR
184 if (!strcmp(ext_prop->extensionName, "VK_KHR_xlib_surface"))
185 return true;
186#endif // VK_USE_PLATFORM_XLIB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600187
Jon Ashburnae8f1e82016-03-25 12:49:35 -0600188 return false;
189}
Ian Elliott7c352552015-11-19 13:14:05 -0700190
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600191// Functions for the VK_KHR_surface extension:
192
193// This is the trampoline entrypoint for DestroySurfaceKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700194LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
195vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface,
196 const VkAllocationCallbacks *pAllocator) {
Ian Elliottabf50662015-11-25 14:43:02 -0700197 const VkLayerInstanceDispatchTable *disp;
198 disp = loader_get_instance_dispatch(instance);
199 disp->DestroySurfaceKHR(instance, surface, pAllocator);
200}
201
Jon Ashburncc370d02016-03-08 09:30:30 -0700202// TODO probably need to lock around all the loader_get_instance() calls.
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600203
204// This is the instance chain terminator function for DestroySurfaceKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700205VKAPI_ATTR void VKAPI_CALL
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700206terminator_DestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface,
207 const VkAllocationCallbacks *pAllocator) {
Ian Elliott1693f592015-11-23 10:17:23 -0700208 struct loader_instance *ptr_instance = loader_get_instance(instance);
209
Mark Young74dd5d12016-06-30 13:02:42 -0600210 loader_instance_heap_free(ptr_instance, (void *)surface);
Ian Elliott7c352552015-11-19 13:14:05 -0700211}
212
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600213// This is the trampoline entrypoint for GetPhysicalDeviceSurfaceSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700214LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
215vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice,
216 uint32_t queueFamilyIndex,
217 VkSurfaceKHR surface,
218 VkBool32 *pSupported) {
Ian Elliott54cea232015-10-30 15:28:23 -0600219 const VkLayerInstanceDispatchTable *disp;
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700220 VkPhysicalDevice unwrapped_phys_dev =
221 loader_unwrap_physical_device(physicalDevice);
Ian Elliott54cea232015-10-30 15:28:23 -0600222 disp = loader_get_instance_dispatch(physicalDevice);
223 VkResult res = disp->GetPhysicalDeviceSurfaceSupportKHR(
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700224 unwrapped_phys_dev, queueFamilyIndex, surface, pSupported);
Ian Elliott54cea232015-10-30 15:28:23 -0600225 return res;
226}
227
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600228// This is the instance chain terminator function for
229// GetPhysicalDeviceSurfaceSupportKHR
230VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceSupportKHR(
231 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
232 VkSurfaceKHR surface, VkBool32 *pSupported) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600233 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700234 struct loader_physical_device *phys_dev =
235 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600236 struct loader_instance *ptr_instance =
237 (struct loader_instance *)phys_dev->this_icd->this_instance;
238 if (!ptr_instance->wsi_surface_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -0600239 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
240 "VK_KHR_VK_KHR_surface extension not enabled. "
241 "vkGetPhysicalDeviceSurfaceSupportKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600242 return VK_SUCCESS;
243 }
244
245 // Next, if so, proceed with the implementation of this function:
Ian Elliott54cea232015-10-30 15:28:23 -0600246 struct loader_icd *icd = phys_dev->this_icd;
247
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700248 assert(pSupported &&
249 "GetPhysicalDeviceSurfaceSupportKHR: Error, null pSupported");
Ian Elliott54cea232015-10-30 15:28:23 -0600250 *pSupported = false;
251
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700252 assert(icd->GetPhysicalDeviceSurfaceSupportKHR &&
253 "loader: null GetPhysicalDeviceSurfaceSupportKHR ICD pointer");
Ian Elliott54cea232015-10-30 15:28:23 -0600254
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700255 return icd->GetPhysicalDeviceSurfaceSupportKHR(
256 phys_dev->phys_dev, queueFamilyIndex, surface, pSupported);
Ian Elliott54cea232015-10-30 15:28:23 -0600257}
258
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600259// This is the trampoline entrypoint for GetPhysicalDeviceSurfaceCapabilitiesKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700260LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
261vkGetPhysicalDeviceSurfaceCapabilitiesKHR(
262 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
263 VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) {
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700264
Ian Elliottea666b22015-11-19 16:05:09 -0700265 const VkLayerInstanceDispatchTable *disp;
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700266 VkPhysicalDevice unwrapped_phys_dev =
267 loader_unwrap_physical_device(physicalDevice);
Ian Elliottea666b22015-11-19 16:05:09 -0700268 disp = loader_get_instance_dispatch(physicalDevice);
269 VkResult res = disp->GetPhysicalDeviceSurfaceCapabilitiesKHR(
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700270 unwrapped_phys_dev, surface, pSurfaceCapabilities);
Ian Elliottea666b22015-11-19 16:05:09 -0700271 return res;
272}
273
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600274// This is the instance chain terminator function for
275// GetPhysicalDeviceSurfaceCapabilitiesKHR
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700276VKAPI_ATTR VkResult VKAPI_CALL
277terminator_GetPhysicalDeviceSurfaceCapabilitiesKHR(
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700278 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
279 VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600280 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700281 struct loader_physical_device *phys_dev =
282 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600283 struct loader_instance *ptr_instance =
284 (struct loader_instance *)phys_dev->this_icd->this_instance;
285 if (!ptr_instance->wsi_surface_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -0600286 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
287 "VK_KHR_surface extension not enabled. "
288 "vkGetPhysicalDeviceSurfaceCapabilitiesKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600289 return VK_SUCCESS;
290 }
291
292 // Next, if so, proceed with the implementation of this function:
Ian Elliottea666b22015-11-19 16:05:09 -0700293 struct loader_icd *icd = phys_dev->this_icd;
294
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700295 assert(pSurfaceCapabilities && "GetPhysicalDeviceSurfaceCapabilitiesKHR: "
296 "Error, null pSurfaceCapabilities");
Ian Elliottea666b22015-11-19 16:05:09 -0700297
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700298 assert(icd->GetPhysicalDeviceSurfaceCapabilitiesKHR &&
299 "loader: null GetPhysicalDeviceSurfaceCapabilitiesKHR ICD pointer");
Ian Elliottea666b22015-11-19 16:05:09 -0700300
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
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700348 return icd->GetPhysicalDeviceSurfaceFormatsKHR(
349 phys_dev->phys_dev, surface, pSurfaceFormatCount, pSurfaceFormats);
Ian Elliottea666b22015-11-19 16:05:09 -0700350}
351
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600352// This is the trampoline entrypoint for GetPhysicalDeviceSurfacePresentModesKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700353LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
354vkGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,
355 VkSurfaceKHR surface,
356 uint32_t *pPresentModeCount,
357 VkPresentModeKHR *pPresentModes) {
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700358 VkPhysicalDevice unwrapped_phys_dev =
359 loader_unwrap_physical_device(physicalDevice);
Ian Elliottea666b22015-11-19 16:05:09 -0700360 const VkLayerInstanceDispatchTable *disp;
361 disp = loader_get_instance_dispatch(physicalDevice);
362 VkResult res = disp->GetPhysicalDeviceSurfacePresentModesKHR(
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700363 unwrapped_phys_dev, surface, pPresentModeCount, pPresentModes);
Ian Elliottea666b22015-11-19 16:05:09 -0700364 return res;
365}
366
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600367// This is the instance chain terminator function for
368// GetPhysicalDeviceSurfacePresentModesKHR
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700369VKAPI_ATTR VkResult VKAPI_CALL
370terminator_GetPhysicalDeviceSurfacePresentModesKHR(
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700371 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
372 uint32_t *pPresentModeCount, VkPresentModeKHR *pPresentModes) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600373 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700374 struct loader_physical_device *phys_dev =
375 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600376 struct loader_instance *ptr_instance =
377 (struct loader_instance *)phys_dev->this_icd->this_instance;
378 if (!ptr_instance->wsi_surface_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -0600379 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
380 "VK_KHR_surface extension not enabled. "
381 "vkGetPhysicalDeviceSurfacePresentModesKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600382 return VK_SUCCESS;
383 }
384
385 // Next, if so, proceed with the implementation of this function:
Ian Elliottea666b22015-11-19 16:05:09 -0700386 struct loader_icd *icd = phys_dev->this_icd;
387
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700388 assert(pPresentModeCount && "GetPhysicalDeviceSurfacePresentModesKHR: "
389 "Error, null pPresentModeCount");
Ian Elliottea666b22015-11-19 16:05:09 -0700390
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700391 assert(icd->GetPhysicalDeviceSurfacePresentModesKHR &&
392 "loader: null GetPhysicalDeviceSurfacePresentModesKHR ICD pointer");
Ian Elliottea666b22015-11-19 16:05:09 -0700393
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700394 return icd->GetPhysicalDeviceSurfacePresentModesKHR(
395 phys_dev->phys_dev, surface, pPresentModeCount, pPresentModes);
Ian Elliottea666b22015-11-19 16:05:09 -0700396}
397
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600398// Functions for the VK_KHR_swapchain extension:
Ian Elliott7c352552015-11-19 13:14:05 -0700399
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600400// This is the trampoline entrypoint for CreateSwapchainKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600401LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR(
402 VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
403 const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain) {
Ian Elliott9b89a472015-11-19 16:39:21 -0700404 const VkLayerDispatchTable *disp;
405 disp = loader_get_dispatch(device);
Mark Young76b3fe02016-09-08 12:28:38 -0600406 return disp->CreateSwapchainKHR(device, pCreateInfo, pAllocator,
407 pSwapchain);
Ian Elliott9b89a472015-11-19 16:39:21 -0700408}
Ian Elliott7c352552015-11-19 13:14:05 -0700409
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600410// This is the trampoline entrypoint for DestroySwapchainKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700411LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
412vkDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain,
413 const VkAllocationCallbacks *pAllocator) {
Ian Elliott9b89a472015-11-19 16:39:21 -0700414 const VkLayerDispatchTable *disp;
415 disp = loader_get_dispatch(device);
416 disp->DestroySwapchainKHR(device, swapchain, pAllocator);
417}
Ian Elliott7c352552015-11-19 13:14:05 -0700418
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600419// This is the trampoline entrypoint for GetSwapchainImagesKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700420LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
421vkGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain,
422 uint32_t *pSwapchainImageCount,
423 VkImage *pSwapchainImages) {
Ian Elliott9b89a472015-11-19 16:39:21 -0700424 const VkLayerDispatchTable *disp;
425 disp = loader_get_dispatch(device);
Mark Young76b3fe02016-09-08 12:28:38 -0600426 return disp->GetSwapchainImagesKHR(
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700427 device, swapchain, pSwapchainImageCount, pSwapchainImages);
Ian Elliott9b89a472015-11-19 16:39:21 -0700428}
429
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600430// This is the trampoline entrypoint for AcquireNextImageKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700431LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
432vkAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain,
433 uint64_t timeout, VkSemaphore semaphore, VkFence fence,
434 uint32_t *pImageIndex) {
Ian Elliott9b89a472015-11-19 16:39:21 -0700435 const VkLayerDispatchTable *disp;
436 disp = loader_get_dispatch(device);
Mark Young76b3fe02016-09-08 12:28:38 -0600437 return disp->AcquireNextImageKHR(device, swapchain, timeout,
438 semaphore, fence, pImageIndex);
Ian Elliott9b89a472015-11-19 16:39:21 -0700439}
440
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600441// This is the trampoline entrypoint for QueuePresentKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700442LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
443vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) {
Ian Elliott9b89a472015-11-19 16:39:21 -0700444 const VkLayerDispatchTable *disp;
445 disp = loader_get_dispatch(queue);
Mark Young76b3fe02016-09-08 12:28:38 -0600446 return disp->QueuePresentKHR(queue, pPresentInfo);
Ian Elliott9b89a472015-11-19 16:39:21 -0700447}
Ian Elliott7c352552015-11-19 13:14:05 -0700448
Ian Elliott7c352552015-11-19 13:14:05 -0700449#ifdef VK_USE_PLATFORM_WIN32_KHR
450
Ian Elliott7c352552015-11-19 13:14:05 -0700451
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600452// Functions for the VK_KHR_win32_surface extension:
453
454// This is the trampoline entrypoint for CreateWin32SurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600455LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR(
456 VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
457 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburn16edfa62015-11-25 17:55:49 -0700458 const VkLayerInstanceDispatchTable *disp;
459 disp = loader_get_instance_dispatch(instance);
460 VkResult res;
461
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700462 res = disp->CreateWin32SurfaceKHR(instance, pCreateInfo, pAllocator,
463 pSurface);
Jon Ashburn16edfa62015-11-25 17:55:49 -0700464 return res;
465}
466
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600467// This is the instance chain terminator function for CreateWin32SurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600468VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWin32SurfaceKHR(
469 VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
470 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600471 // First, check to ensure the appropriate extension was enabled:
Ian Elliott1693f592015-11-23 10:17:23 -0700472 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600473 if (!ptr_instance->wsi_win32_surface_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -0600474 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
475 "VK_KHR_win32_surface extension not enabled. "
476 "vkCreateWin32SurfaceKHR not executed!\n");
Jeremy Hayes0231e1c2016-06-14 11:50:02 -0600477 return VK_ERROR_EXTENSION_NOT_PRESENT;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600478 }
479
480 // Next, if so, proceed with the implementation of this function:
Ian Elliott7c352552015-11-19 13:14:05 -0700481 VkIcdSurfaceWin32 *pIcdSurface = NULL;
482
Mark Young74dd5d12016-06-30 13:02:42 -0600483 pIcdSurface =
484 loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceWin32),
485 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott7c352552015-11-19 13:14:05 -0700486 if (pIcdSurface == NULL) {
487 return VK_ERROR_OUT_OF_HOST_MEMORY;
488 }
489
490 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_WIN32;
Ian Elliott07eb3282015-12-10 17:28:50 -0700491 pIcdSurface->hinstance = pCreateInfo->hinstance;
492 pIcdSurface->hwnd = pCreateInfo->hwnd;
Ian Elliott7c352552015-11-19 13:14:05 -0700493
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700494 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliott7c352552015-11-19 13:14:05 -0700495
496 return VK_SUCCESS;
497}
Ian Elliotte851dd62015-11-24 15:39:10 -0700498
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600499// This is the trampoline entrypoint for
500// GetPhysicalDeviceWin32PresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700501LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
502vkGetPhysicalDeviceWin32PresentationSupportKHR(VkPhysicalDevice physicalDevice,
503 uint32_t queueFamilyIndex) {
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700504 VkPhysicalDevice unwrapped_phys_dev =
505 loader_unwrap_physical_device(physicalDevice);
Ian Elliotte851dd62015-11-24 15:39:10 -0700506 const VkLayerInstanceDispatchTable *disp;
507 disp = loader_get_instance_dispatch(physicalDevice);
508 VkBool32 res = disp->GetPhysicalDeviceWin32PresentationSupportKHR(
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700509 unwrapped_phys_dev, queueFamilyIndex);
Ian Elliotte851dd62015-11-24 15:39:10 -0700510 return res;
511}
512
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600513// This is the instance chain terminator function for
514// GetPhysicalDeviceWin32PresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700515VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700516terminator_GetPhysicalDeviceWin32PresentationSupportKHR(
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700517 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600518 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700519 struct loader_physical_device *phys_dev =
520 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600521 struct loader_instance *ptr_instance =
522 (struct loader_instance *)phys_dev->this_icd->this_instance;
523 if (!ptr_instance->wsi_win32_surface_enabled) {
Jon Ashburnc466da52016-04-15 09:25:03 -0600524 loader_log(
525 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
526 "VK_KHR_win32_surface extension not enabled. "
527 "vkGetPhysicalDeviceWin32PresentationSupportKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600528 return VK_SUCCESS;
529 }
530
531 // Next, if so, proceed with the implementation of this function:
Ian Elliotte851dd62015-11-24 15:39:10 -0700532 struct loader_icd *icd = phys_dev->this_icd;
533
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700534 assert(icd->GetPhysicalDeviceWin32PresentationSupportKHR &&
535 "loader: null GetPhysicalDeviceWin32PresentationSupportKHR ICD "
536 "pointer");
Ian Elliotte851dd62015-11-24 15:39:10 -0700537
538 return icd->GetPhysicalDeviceWin32PresentationSupportKHR(phys_dev->phys_dev,
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700539 queueFamilyIndex);
Ian Elliotte851dd62015-11-24 15:39:10 -0700540}
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700541#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliott7c352552015-11-19 13:14:05 -0700542
543#ifdef VK_USE_PLATFORM_MIR_KHR
544
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600545// Functions for the VK_KHR_mir_surface extension:
Ian Elliott7c352552015-11-19 13:14:05 -0700546
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600547// This is the trampoline entrypoint for CreateMirSurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600548LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateMirSurfaceKHR(
549 VkInstance instance, const VkMirSurfaceCreateInfoKHR *pCreateInfo,
550 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburn16edfa62015-11-25 17:55:49 -0700551 const VkLayerInstanceDispatchTable *disp;
552 disp = loader_get_instance_dispatch(instance);
553 VkResult res;
554
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700555 res =
556 disp->CreateMirSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
Jon Ashburn16edfa62015-11-25 17:55:49 -0700557 return res;
558}
559
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600560// This is the instance chain terminator function for CreateMirSurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600561VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateMirSurfaceKHR(
562 VkInstance instance, const VkMirSurfaceCreateInfoKHR *pCreateInfo,
563 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600564 // First, check to ensure the appropriate extension was enabled:
Ian Elliott1693f592015-11-23 10:17:23 -0700565 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600566 if (!ptr_instance->wsi_mir_surface_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -0600567 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
568 "VK_KHR_mir_surface extension not enabled. "
569 "vkCreateMirSurfaceKHR not executed!\n");
Jeremy Hayes0231e1c2016-06-14 11:50:02 -0600570 return VK_ERROR_EXTENSION_NOT_PRESENT;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600571 }
572
573 // Next, if so, proceed with the implementation of this function:
Ian Elliott7c352552015-11-19 13:14:05 -0700574 VkIcdSurfaceMir *pIcdSurface = NULL;
575
Mark Young74dd5d12016-06-30 13:02:42 -0600576 pIcdSurface =
577 loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceMir),
578 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott7c352552015-11-19 13:14:05 -0700579 if (pIcdSurface == NULL) {
580 return VK_ERROR_OUT_OF_HOST_MEMORY;
581 }
582
583 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_MIR;
Ian Elliott07eb3282015-12-10 17:28:50 -0700584 pIcdSurface->connection = pCreateInfo->connection;
585 pIcdSurface->mirSurface = pCreateInfo->mirSurface;
Ian Elliott7c352552015-11-19 13:14:05 -0700586
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700587 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliott7c352552015-11-19 13:14:05 -0700588
589 return VK_SUCCESS;
590}
Ian Elliotte851dd62015-11-24 15:39:10 -0700591
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600592// This is the trampoline entrypoint for
593// GetPhysicalDeviceMirPresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700594LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
595vkGetPhysicalDeviceMirPresentationSupportKHR(VkPhysicalDevice physicalDevice,
596 uint32_t queueFamilyIndex,
597 MirConnection *connection) {
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700598 VkPhysicalDevice unwrapped_phys_dev =
599 loader_unwrap_physical_device(physicalDevice);
Ian Elliotte851dd62015-11-24 15:39:10 -0700600 const VkLayerInstanceDispatchTable *disp;
601 disp = loader_get_instance_dispatch(physicalDevice);
602 VkBool32 res = disp->GetPhysicalDeviceMirPresentationSupportKHR(
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700603 unwrapped_phys_dev, queueFamilyIndex, connection);
Ian Elliotte851dd62015-11-24 15:39:10 -0700604 return res;
605}
606
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600607// This is the instance chain terminator function for
608// GetPhysicalDeviceMirPresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700609VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700610terminator_GetPhysicalDeviceMirPresentationSupportKHR(
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700611 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
612 MirConnection *connection) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600613 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700614 struct loader_physical_device *phys_dev =
615 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600616 struct loader_instance *ptr_instance =
617 (struct loader_instance *)phys_dev->this_icd->this_instance;
618 if (!ptr_instance->wsi_mir_surface_enabled) {
Jon Ashburnc466da52016-04-15 09:25:03 -0600619 loader_log(
620 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
621 "VK_KHR_mir_surface extension not enabled. "
622 "vkGetPhysicalDeviceMirPresentationSupportKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600623 return VK_SUCCESS;
624 }
625
626 // Next, if so, proceed with the implementation of this function:
Ian Elliotte851dd62015-11-24 15:39:10 -0700627 struct loader_icd *icd = phys_dev->this_icd;
628
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700629 assert(
630 icd->GetPhysicalDeviceMirPresentationSupportKHR &&
631 "loader: null GetPhysicalDeviceMirPresentationSupportKHR ICD pointer");
Ian Elliotte851dd62015-11-24 15:39:10 -0700632
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700633 return icd->GetPhysicalDeviceMirPresentationSupportKHR(
634 phys_dev->phys_dev, queueFamilyIndex, connection);
Ian Elliotte851dd62015-11-24 15:39:10 -0700635}
Ian Elliott7c352552015-11-19 13:14:05 -0700636#endif // VK_USE_PLATFORM_MIR_KHR
637
638#ifdef VK_USE_PLATFORM_WAYLAND_KHR
639
Ian Elliott7c352552015-11-19 13:14:05 -0700640
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600641// Functions for the VK_KHR_wayland_surface extension:
642
643// This is the trampoline entrypoint for CreateWaylandSurfaceKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700644LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
645vkCreateWaylandSurfaceKHR(VkInstance instance,
Jason Ekstrand3bfebc92016-02-12 17:25:03 -0800646 const VkWaylandSurfaceCreateInfoKHR *pCreateInfo,
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700647 const VkAllocationCallbacks *pAllocator,
648 VkSurfaceKHR *pSurface) {
Jon Ashburn16edfa62015-11-25 17:55:49 -0700649 const VkLayerInstanceDispatchTable *disp;
650 disp = loader_get_instance_dispatch(instance);
651 VkResult res;
652
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700653 res = disp->CreateWaylandSurfaceKHR(instance, pCreateInfo, pAllocator,
654 pSurface);
Jon Ashburn16edfa62015-11-25 17:55:49 -0700655 return res;
656}
657
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600658// This is the instance chain terminator function for CreateWaylandSurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600659VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWaylandSurfaceKHR(
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700660 VkInstance instance, const VkWaylandSurfaceCreateInfoKHR *pCreateInfo,
661 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600662 // First, check to ensure the appropriate extension was enabled:
Ian Elliott1693f592015-11-23 10:17:23 -0700663 struct loader_instance *ptr_instance = loader_get_instance(instance);
Jon Ashburn436d6a32016-03-24 17:26:59 -0600664 if (!ptr_instance->wsi_wayland_surface_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -0600665 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
666 "VK_KHR_wayland_surface extension not enabled. "
667 "vkCreateWaylandSurfaceKHR not executed!\n");
Jeremy Hayes0231e1c2016-06-14 11:50:02 -0600668 return VK_ERROR_EXTENSION_NOT_PRESENT;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600669 }
670
671 // Next, if so, proceed with the implementation of this function:
Ian Elliott7c352552015-11-19 13:14:05 -0700672 VkIcdSurfaceWayland *pIcdSurface = NULL;
673
Mark Young74dd5d12016-06-30 13:02:42 -0600674 pIcdSurface =
675 loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceWayland),
676 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott7c352552015-11-19 13:14:05 -0700677 if (pIcdSurface == NULL) {
678 return VK_ERROR_OUT_OF_HOST_MEMORY;
679 }
680
681 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_WAYLAND;
Ian Elliott07eb3282015-12-10 17:28:50 -0700682 pIcdSurface->display = pCreateInfo->display;
683 pIcdSurface->surface = pCreateInfo->surface;
Ian Elliott7c352552015-11-19 13:14:05 -0700684
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700685 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliott7c352552015-11-19 13:14:05 -0700686
687 return VK_SUCCESS;
688}
Ian Elliotte851dd62015-11-24 15:39:10 -0700689
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600690
691// This is the trampoline entrypoint for
692// GetPhysicalDeviceWaylandPresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700693LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
694vkGetPhysicalDeviceWaylandPresentationSupportKHR(
695 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
696 struct wl_display *display) {
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700697 VkPhysicalDevice unwrapped_phys_dev =
698 loader_unwrap_physical_device(physicalDevice);
Ian Elliotte851dd62015-11-24 15:39:10 -0700699 const VkLayerInstanceDispatchTable *disp;
700 disp = loader_get_instance_dispatch(physicalDevice);
701 VkBool32 res = disp->GetPhysicalDeviceWaylandPresentationSupportKHR(
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700702 unwrapped_phys_dev, queueFamilyIndex, display);
Ian Elliotte851dd62015-11-24 15:39:10 -0700703 return res;
704}
705
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600706// This is the instance chain terminator function for
707// GetPhysicalDeviceWaylandPresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700708VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700709terminator_GetPhysicalDeviceWaylandPresentationSupportKHR(
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700710 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
711 struct wl_display *display) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600712 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700713 struct loader_physical_device *phys_dev =
714 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600715 struct loader_instance *ptr_instance =
716 (struct loader_instance *)phys_dev->this_icd->this_instance;
Jon Ashburn436d6a32016-03-24 17:26:59 -0600717 if (!ptr_instance->wsi_wayland_surface_enabled) {
Jon Ashburnc466da52016-04-15 09:25:03 -0600718 loader_log(
719 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
720 "VK_KHR_wayland_surface extension not enabled. "
721 "vkGetPhysicalDeviceWaylandPresentationSupportKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600722 return VK_SUCCESS;
723 }
724
725 // Next, if so, proceed with the implementation of this function:
Ian Elliotte851dd62015-11-24 15:39:10 -0700726 struct loader_icd *icd = phys_dev->this_icd;
727
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700728 assert(icd->GetPhysicalDeviceWaylandPresentationSupportKHR &&
729 "loader: null GetPhysicalDeviceWaylandPresentationSupportKHR ICD "
730 "pointer");
Ian Elliotte851dd62015-11-24 15:39:10 -0700731
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700732 return icd->GetPhysicalDeviceWaylandPresentationSupportKHR(
733 phys_dev->phys_dev, queueFamilyIndex, display);
Ian Elliotte851dd62015-11-24 15:39:10 -0700734}
Ian Elliott7c352552015-11-19 13:14:05 -0700735#endif // VK_USE_PLATFORM_WAYLAND_KHR
736
737#ifdef VK_USE_PLATFORM_XCB_KHR
738
Ian Elliott7c352552015-11-19 13:14:05 -0700739
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600740// Functions for the VK_KHR_xcb_surface extension:
741
742// This is the trampoline entrypoint for CreateXcbSurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600743LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXcbSurfaceKHR(
744 VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo,
745 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburn16edfa62015-11-25 17:55:49 -0700746 const VkLayerInstanceDispatchTable *disp;
747 disp = loader_get_instance_dispatch(instance);
748 VkResult res;
749
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700750 res =
751 disp->CreateXcbSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
Jon Ashburn16edfa62015-11-25 17:55:49 -0700752 return res;
753}
754
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600755// This is the instance chain terminator function for CreateXcbSurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600756VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXcbSurfaceKHR(
757 VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo,
758 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600759 // First, check to ensure the appropriate extension was enabled:
Ian Elliott1693f592015-11-23 10:17:23 -0700760 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600761 if (!ptr_instance->wsi_xcb_surface_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -0600762 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
763 "VK_KHR_xcb_surface extension not enabled. "
764 "vkCreateXcbSurfaceKHR not executed!\n");
Jeremy Hayes0231e1c2016-06-14 11:50:02 -0600765 return VK_ERROR_EXTENSION_NOT_PRESENT;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600766 }
767
768 // Next, if so, proceed with the implementation of this function:
Ian Elliott7c352552015-11-19 13:14:05 -0700769 VkIcdSurfaceXcb *pIcdSurface = NULL;
770
Mark Young74dd5d12016-06-30 13:02:42 -0600771 pIcdSurface =
772 loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceXcb),
773 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott7c352552015-11-19 13:14:05 -0700774 if (pIcdSurface == NULL) {
775 return VK_ERROR_OUT_OF_HOST_MEMORY;
776 }
777
778 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_XCB;
Ian Elliott07eb3282015-12-10 17:28:50 -0700779 pIcdSurface->connection = pCreateInfo->connection;
780 pIcdSurface->window = pCreateInfo->window;
Ian Elliott7c352552015-11-19 13:14:05 -0700781
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700782 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliott7c352552015-11-19 13:14:05 -0700783
784 return VK_SUCCESS;
785}
Ian Elliotte851dd62015-11-24 15:39:10 -0700786
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600787// This is the trampoline entrypoint for
788// GetPhysicalDeviceXcbPresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700789LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
790vkGetPhysicalDeviceXcbPresentationSupportKHR(VkPhysicalDevice physicalDevice,
791 uint32_t queueFamilyIndex,
792 xcb_connection_t *connection,
793 xcb_visualid_t visual_id) {
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700794 VkPhysicalDevice unwrapped_phys_dev =
795 loader_unwrap_physical_device(physicalDevice);
Ian Elliotte851dd62015-11-24 15:39:10 -0700796 const VkLayerInstanceDispatchTable *disp;
797 disp = loader_get_instance_dispatch(physicalDevice);
798 VkBool32 res = disp->GetPhysicalDeviceXcbPresentationSupportKHR(
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700799 unwrapped_phys_dev, queueFamilyIndex, connection, visual_id);
Ian Elliotte851dd62015-11-24 15:39:10 -0700800 return res;
801}
802
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600803// This is the instance chain terminator function for
804// GetPhysicalDeviceXcbPresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700805VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700806terminator_GetPhysicalDeviceXcbPresentationSupportKHR(
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700807 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
808 xcb_connection_t *connection, xcb_visualid_t visual_id) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600809 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700810 struct loader_physical_device *phys_dev =
811 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600812 struct loader_instance *ptr_instance =
813 (struct loader_instance *)phys_dev->this_icd->this_instance;
814 if (!ptr_instance->wsi_xcb_surface_enabled) {
Jon Ashburnc466da52016-04-15 09:25:03 -0600815 loader_log(
816 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
817 "VK_KHR_xcb_surface extension not enabled. "
818 "vkGetPhysicalDeviceXcbPresentationSupportKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600819 return VK_SUCCESS;
820 }
821
822 // Next, if so, proceed with the implementation of this function:
Ian Elliotte851dd62015-11-24 15:39:10 -0700823 struct loader_icd *icd = phys_dev->this_icd;
824
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700825 assert(
826 icd->GetPhysicalDeviceXcbPresentationSupportKHR &&
827 "loader: null GetPhysicalDeviceXcbPresentationSupportKHR ICD pointer");
Ian Elliotte851dd62015-11-24 15:39:10 -0700828
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700829 return icd->GetPhysicalDeviceXcbPresentationSupportKHR(
830 phys_dev->phys_dev, queueFamilyIndex, connection, visual_id);
Ian Elliotte851dd62015-11-24 15:39:10 -0700831}
Ian Elliott7c352552015-11-19 13:14:05 -0700832#endif // VK_USE_PLATFORM_XCB_KHR
833
834#ifdef VK_USE_PLATFORM_XLIB_KHR
835
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600836// Functions for the VK_KHR_xlib_surface extension:
Ian Elliott7c352552015-11-19 13:14:05 -0700837
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600838// This is the trampoline entrypoint for CreateXlibSurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600839LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR(
840 VkInstance instance, const VkXlibSurfaceCreateInfoKHR *pCreateInfo,
841 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburn16edfa62015-11-25 17:55:49 -0700842 const VkLayerInstanceDispatchTable *disp;
843 disp = loader_get_instance_dispatch(instance);
844 VkResult res;
845
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700846 res =
847 disp->CreateXlibSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
Jon Ashburn16edfa62015-11-25 17:55:49 -0700848 return res;
849}
850
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600851// This is the instance chain terminator function for CreateXlibSurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600852VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXlibSurfaceKHR(
853 VkInstance instance, const VkXlibSurfaceCreateInfoKHR *pCreateInfo,
854 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600855 // First, check to ensure the appropriate extension was enabled:
Ian Elliott1693f592015-11-23 10:17:23 -0700856 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600857 if (!ptr_instance->wsi_xlib_surface_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -0600858 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
859 "VK_KHR_xlib_surface extension not enabled. "
860 "vkCreateXlibSurfaceKHR not executed!\n");
Jeremy Hayes0231e1c2016-06-14 11:50:02 -0600861 return VK_ERROR_EXTENSION_NOT_PRESENT;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600862 }
863
864 // Next, if so, proceed with the implementation of this function:
Ian Elliott7c352552015-11-19 13:14:05 -0700865 VkIcdSurfaceXlib *pIcdSurface = NULL;
866
Mark Young74dd5d12016-06-30 13:02:42 -0600867 pIcdSurface =
868 loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceXlib),
869 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott7c352552015-11-19 13:14:05 -0700870 if (pIcdSurface == NULL) {
871 return VK_ERROR_OUT_OF_HOST_MEMORY;
872 }
873
874 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_XLIB;
Ian Elliott07eb3282015-12-10 17:28:50 -0700875 pIcdSurface->dpy = pCreateInfo->dpy;
876 pIcdSurface->window = pCreateInfo->window;
Ian Elliott7c352552015-11-19 13:14:05 -0700877
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700878 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliott7c352552015-11-19 13:14:05 -0700879
880 return VK_SUCCESS;
881}
Ian Elliotte851dd62015-11-24 15:39:10 -0700882
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600883// This is the trampoline entrypoint for GetPhysicalDeviceXlibPresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700884LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
885vkGetPhysicalDeviceXlibPresentationSupportKHR(VkPhysicalDevice physicalDevice,
886 uint32_t queueFamilyIndex,
887 Display *dpy, VisualID visualID) {
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->GetPhysicalDeviceXlibPresentationSupportKHR(
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700893 unwrapped_phys_dev, queueFamilyIndex, dpy, visualID);
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// GetPhysicalDeviceXlibPresentationSupportKHR
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700899VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700900terminator_GetPhysicalDeviceXlibPresentationSupportKHR(
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700901 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, Display *dpy,
902 VisualID visualID) {
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;
908 if (!ptr_instance->wsi_xlib_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_xlib_surface extension not enabled. "
912 "vkGetPhysicalDeviceXlibPresentationSupportKHR 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(
920 icd->GetPhysicalDeviceXlibPresentationSupportKHR &&
921 "loader: null GetPhysicalDeviceXlibPresentationSupportKHR ICD pointer");
Ian Elliotte851dd62015-11-24 15:39:10 -0700922
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700923 return icd->GetPhysicalDeviceXlibPresentationSupportKHR(
924 phys_dev->phys_dev, queueFamilyIndex, dpy, visualID);
Ian Elliotte851dd62015-11-24 15:39:10 -0700925}
Ian Elliott7c352552015-11-19 13:14:05 -0700926#endif // VK_USE_PLATFORM_XLIB_KHR
927
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700928#ifdef VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott7c352552015-11-19 13:14:05 -0700929
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700930
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600931// Functions for the VK_KHR_android_surface extension:
932
933// This is the trampoline entrypoint for CreateAndroidSurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600934LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateAndroidSurfaceKHR(
935 VkInstance instance, ANativeWindow *window,
936 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700937 const VkLayerInstanceDispatchTable *disp;
938 disp = loader_get_instance_dispatch(instance);
939 VkResult res;
940
941 res = disp->CreateAndroidSurfaceKHR(instance, window, pAllocator, pSurface);
942 return res;
943}
944
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600945// This is the instance chain terminator function for CreateAndroidSurfaceKHR
Mark Young74dd5d12016-06-30 13:02:42 -0600946VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateAndroidSurfaceKHR(
947 VkInstance instance, Window window, const VkAllocationCallbacks *pAllocator,
948 VkSurfaceKHR *pSurface) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600949 // First, check to ensure the appropriate extension was enabled:
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700950 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600951 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -0600952 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
953 "VK_KHR_display extension not enabled. "
954 "vkCreateAndroidSurfaceKHR not executed!\n");
Jeremy Hayes0231e1c2016-06-14 11:50:02 -0600955 return VK_ERROR_EXTENSION_NOT_PRESENT;
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600956 }
957
958 // Next, if so, proceed with the implementation of this function:
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700959 VkIcdSurfaceAndroid *pIcdSurface = NULL;
960
Mark Young74dd5d12016-06-30 13:02:42 -0600961 pIcdSurface =
962 loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceAndroid),
963 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700964 if (pIcdSurface == NULL) {
965 return VK_ERROR_OUT_OF_HOST_MEMORY;
966 }
967
968 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_ANDROID;
969 pIcdSurface->dpy = dpy;
970 pIcdSurface->window = window;
971
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700972 *pSurface = (VkSurfaceKHR)pIcdSurface;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700973
974 return VK_SUCCESS;
975}
976
977#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott7c352552015-11-19 13:14:05 -0700978
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600979
980// Functions for the VK_KHR_display instance extension:
Jon Ashburncc370d02016-03-08 09:30:30 -0700981LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburnc466da52016-04-15 09:25:03 -0600982vkGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice,
983 uint32_t *pPropertyCount,
984 VkDisplayPropertiesKHR *pProperties) {
Jon Ashburncc370d02016-03-08 09:30:30 -0700985 VkPhysicalDevice unwrapped_phys_dev =
986 loader_unwrap_physical_device(physicalDevice);
987 const VkLayerInstanceDispatchTable *disp;
988 disp = loader_get_instance_dispatch(physicalDevice);
989 VkResult res = disp->GetPhysicalDeviceDisplayPropertiesKHR(
990 unwrapped_phys_dev, pPropertyCount, pProperties);
991 return res;
992}
993
Jon Ashburnc466da52016-04-15 09:25:03 -0600994VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceDisplayPropertiesKHR(
995 VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
996 VkDisplayPropertiesKHR *pProperties) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -0600997 // First, check to ensure the appropriate extension was enabled:
Jon Ashburncc370d02016-03-08 09:30:30 -0700998 struct loader_physical_device *phys_dev =
999 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001000 struct loader_instance *ptr_instance =
1001 (struct loader_instance *)phys_dev->this_icd->this_instance;
1002 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -06001003 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1004 "VK_KHR_display extension not enabled. "
1005 "vkGetPhysicalDeviceDisplayPropertiesKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001006 return VK_SUCCESS;
1007 }
1008
1009 // Next, if so, proceed with the implementation of this function:
Jon Ashburncc370d02016-03-08 09:30:30 -07001010 struct loader_icd *icd = phys_dev->this_icd;
1011
Jon Ashburnc466da52016-04-15 09:25:03 -06001012 assert(icd->GetPhysicalDeviceDisplayPropertiesKHR &&
1013 "loader: null GetPhysicalDeviceDisplayPropertiesKHR ICD pointer");
Jon Ashburncc370d02016-03-08 09:30:30 -07001014
1015 return icd->GetPhysicalDeviceDisplayPropertiesKHR(
1016 phys_dev->phys_dev, pPropertyCount, pProperties);
1017}
1018
1019LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1020vkGetPhysicalDeviceDisplayPlanePropertiesKHR(
Jon Ashburnc466da52016-04-15 09:25:03 -06001021 VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
1022 VkDisplayPlanePropertiesKHR *pProperties) {
Jon Ashburncc370d02016-03-08 09:30:30 -07001023 VkPhysicalDevice unwrapped_phys_dev =
1024 loader_unwrap_physical_device(physicalDevice);
1025 const VkLayerInstanceDispatchTable *disp;
1026 disp = loader_get_instance_dispatch(physicalDevice);
1027 VkResult res = disp->GetPhysicalDeviceDisplayPlanePropertiesKHR(
1028 unwrapped_phys_dev, pPropertyCount, pProperties);
1029 return res;
1030}
1031
1032VKAPI_ATTR VkResult VKAPI_CALL
1033terminator_GetPhysicalDeviceDisplayPlanePropertiesKHR(
Jon Ashburnc466da52016-04-15 09:25:03 -06001034 VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
1035 VkDisplayPlanePropertiesKHR *pProperties) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001036 // First, check to ensure the appropriate extension was enabled:
Jon Ashburncc370d02016-03-08 09:30:30 -07001037 struct loader_physical_device *phys_dev =
1038 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001039 struct loader_instance *ptr_instance =
1040 (struct loader_instance *)phys_dev->this_icd->this_instance;
1041 if (!ptr_instance->wsi_display_enabled) {
Jon Ashburnc466da52016-04-15 09:25:03 -06001042 loader_log(
1043 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1044 "VK_KHR_display extension not enabled. "
1045 "vkGetPhysicalDeviceDisplayPlanePropertiesKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001046 return VK_SUCCESS;
1047 }
1048
1049 // Next, if so, proceed with the implementation of this function:
Jon Ashburncc370d02016-03-08 09:30:30 -07001050 struct loader_icd *icd = phys_dev->this_icd;
1051
1052 assert(
1053 icd->GetPhysicalDeviceDisplayPlanePropertiesKHR &&
1054 "loader: null GetPhysicalDeviceDisplayPlanePropertiesKHR ICD pointer");
1055
1056 return icd->GetPhysicalDeviceDisplayPlanePropertiesKHR(
1057 phys_dev->phys_dev, pPropertyCount, pProperties);
1058}
1059
1060LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburnc466da52016-04-15 09:25:03 -06001061vkGetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice,
1062 uint32_t planeIndex,
1063 uint32_t *pDisplayCount,
1064 VkDisplayKHR *pDisplays) {
Jon Ashburncc370d02016-03-08 09:30:30 -07001065 VkPhysicalDevice unwrapped_phys_dev =
1066 loader_unwrap_physical_device(physicalDevice);
1067 const VkLayerInstanceDispatchTable *disp;
1068 disp = loader_get_instance_dispatch(physicalDevice);
1069 VkResult res = disp->GetDisplayPlaneSupportedDisplaysKHR(
1070 unwrapped_phys_dev, planeIndex, pDisplayCount, pDisplays);
1071 return res;
1072}
1073
1074VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburnc466da52016-04-15 09:25:03 -06001075terminator_GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice,
1076 uint32_t planeIndex,
1077 uint32_t *pDisplayCount,
1078 VkDisplayKHR *pDisplays) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001079 // First, check to ensure the appropriate extension was enabled:
Jon Ashburncc370d02016-03-08 09:30:30 -07001080 struct loader_physical_device *phys_dev =
1081 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001082 struct loader_instance *ptr_instance =
1083 (struct loader_instance *)phys_dev->this_icd->this_instance;
1084 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -06001085 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1086 "VK_KHR_display extension not enabled. "
1087 "vkGetDisplayPlaneSupportedDisplaysKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001088 return VK_SUCCESS;
1089 }
1090
1091 // Next, if so, proceed with the implementation of this function:
Jon Ashburncc370d02016-03-08 09:30:30 -07001092 struct loader_icd *icd = phys_dev->this_icd;
1093
Jon Ashburnc466da52016-04-15 09:25:03 -06001094 assert(icd->GetDisplayPlaneSupportedDisplaysKHR &&
1095 "loader: null GetDisplayPlaneSupportedDisplaysKHR ICD pointer");
Jon Ashburncc370d02016-03-08 09:30:30 -07001096
1097 return icd->GetDisplayPlaneSupportedDisplaysKHR(
1098 phys_dev->phys_dev, planeIndex, pDisplayCount, pDisplays);
1099}
1100
1101LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburnc466da52016-04-15 09:25:03 -06001102vkGetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice,
1103 VkDisplayKHR display, uint32_t *pPropertyCount,
1104 VkDisplayModePropertiesKHR *pProperties) {
Jon Ashburncc370d02016-03-08 09:30:30 -07001105 VkPhysicalDevice unwrapped_phys_dev =
1106 loader_unwrap_physical_device(physicalDevice);
1107 const VkLayerInstanceDispatchTable *disp;
1108 disp = loader_get_instance_dispatch(physicalDevice);
1109 VkResult res = disp->GetDisplayModePropertiesKHR(
1110 unwrapped_phys_dev, display, pPropertyCount, pProperties);
1111 return res;
1112}
1113
Jon Ashburnc466da52016-04-15 09:25:03 -06001114VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayModePropertiesKHR(
1115 VkPhysicalDevice physicalDevice, VkDisplayKHR display,
1116 uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001117 // First, check to ensure the appropriate extension was enabled:
Jon Ashburncc370d02016-03-08 09:30:30 -07001118 struct loader_physical_device *phys_dev =
1119 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001120 struct loader_instance *ptr_instance =
1121 (struct loader_instance *)phys_dev->this_icd->this_instance;
1122 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -06001123 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1124 "VK_KHR_display extension not enabled. "
1125 "vkGetDisplayModePropertiesKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001126 return VK_SUCCESS;
1127 }
1128
1129 // Next, if so, proceed with the implementation of this function:
Jon Ashburncc370d02016-03-08 09:30:30 -07001130 struct loader_icd *icd = phys_dev->this_icd;
1131
Jon Ashburnc466da52016-04-15 09:25:03 -06001132 assert(icd->GetDisplayModePropertiesKHR &&
1133 "loader: null GetDisplayModePropertiesKHR ICD pointer");
Jon Ashburncc370d02016-03-08 09:30:30 -07001134
Jon Ashburnc466da52016-04-15 09:25:03 -06001135 return icd->GetDisplayModePropertiesKHR(phys_dev->phys_dev, display,
1136 pPropertyCount, pProperties);
Jon Ashburncc370d02016-03-08 09:30:30 -07001137}
1138
Mark Young74dd5d12016-06-30 13:02:42 -06001139LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayModeKHR(
1140 VkPhysicalDevice physicalDevice, VkDisplayKHR display,
1141 const VkDisplayModeCreateInfoKHR *pCreateInfo,
1142 const VkAllocationCallbacks *pAllocator, VkDisplayModeKHR *pMode) {
Jon Ashburncc370d02016-03-08 09:30:30 -07001143 VkPhysicalDevice unwrapped_phys_dev =
1144 loader_unwrap_physical_device(physicalDevice);
1145 const VkLayerInstanceDispatchTable *disp;
1146 disp = loader_get_instance_dispatch(physicalDevice);
Jon Ashburnc466da52016-04-15 09:25:03 -06001147 VkResult res = disp->CreateDisplayModeKHR(unwrapped_phys_dev, display,
1148 pCreateInfo, pAllocator, pMode);
Jon Ashburncc370d02016-03-08 09:30:30 -07001149 return res;
1150}
1151
Mark Young74dd5d12016-06-30 13:02:42 -06001152VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayModeKHR(
1153 VkPhysicalDevice physicalDevice, VkDisplayKHR display,
1154 const VkDisplayModeCreateInfoKHR *pCreateInfo,
1155 const VkAllocationCallbacks *pAllocator, VkDisplayModeKHR *pMode) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001156 // First, check to ensure the appropriate extension was enabled:
Jon Ashburncc370d02016-03-08 09:30:30 -07001157 struct loader_physical_device *phys_dev =
1158 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001159 struct loader_instance *ptr_instance =
1160 (struct loader_instance *)phys_dev->this_icd->this_instance;
1161 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -06001162 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1163 "VK_KHR_display extension not enabled. "
1164 "vkCreateDisplayModeKHR not executed!\n");
Jeremy Hayes0231e1c2016-06-14 11:50:02 -06001165 return VK_ERROR_EXTENSION_NOT_PRESENT;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001166 }
1167
1168 // Next, if so, proceed with the implementation of this function:
Jon Ashburncc370d02016-03-08 09:30:30 -07001169 struct loader_icd *icd = phys_dev->this_icd;
1170
Jon Ashburnc466da52016-04-15 09:25:03 -06001171 assert(icd->CreateDisplayModeKHR &&
1172 "loader: null CreateDisplayModeKHR ICD pointer");
Jon Ashburncc370d02016-03-08 09:30:30 -07001173
Jon Ashburnc466da52016-04-15 09:25:03 -06001174 return icd->CreateDisplayModeKHR(phys_dev->phys_dev, display, pCreateInfo,
1175 pAllocator, pMode);
Jon Ashburncc370d02016-03-08 09:30:30 -07001176}
1177
1178LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburnc466da52016-04-15 09:25:03 -06001179vkGetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physicalDevice,
1180 VkDisplayModeKHR mode, uint32_t planeIndex,
1181 VkDisplayPlaneCapabilitiesKHR *pCapabilities) {
Jon Ashburncc370d02016-03-08 09:30:30 -07001182 VkPhysicalDevice unwrapped_phys_dev =
1183 loader_unwrap_physical_device(physicalDevice);
1184 const VkLayerInstanceDispatchTable *disp;
1185 disp = loader_get_instance_dispatch(physicalDevice);
1186 VkResult res = disp->GetDisplayPlaneCapabilitiesKHR(
1187 unwrapped_phys_dev, mode, planeIndex, pCapabilities);
1188 return res;
1189}
1190
Jon Ashburnc466da52016-04-15 09:25:03 -06001191VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayPlaneCapabilitiesKHR(
1192 VkPhysicalDevice physicalDevice, VkDisplayModeKHR mode, uint32_t planeIndex,
1193 VkDisplayPlaneCapabilitiesKHR *pCapabilities) {
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001194 // First, check to ensure the appropriate extension was enabled:
Jon Ashburncc370d02016-03-08 09:30:30 -07001195 struct loader_physical_device *phys_dev =
1196 (struct loader_physical_device *)physicalDevice;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001197 struct loader_instance *ptr_instance =
1198 (struct loader_instance *)phys_dev->this_icd->this_instance;
1199 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott469ea4a2016-03-24 15:49:02 -06001200 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1201 "VK_KHR_display extension not enabled. "
1202 "vkGetDisplayPlaneCapabilitiesKHR not executed!\n");
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001203 return VK_SUCCESS;
1204 }
1205
1206 // Next, if so, proceed with the implementation of this function:
Jon Ashburncc370d02016-03-08 09:30:30 -07001207 struct loader_icd *icd = phys_dev->this_icd;
1208
Jon Ashburnc466da52016-04-15 09:25:03 -06001209 assert(icd->GetDisplayPlaneCapabilitiesKHR &&
1210 "loader: null GetDisplayPlaneCapabilitiesKHR ICD pointer");
Jon Ashburncc370d02016-03-08 09:30:30 -07001211
Jon Ashburnc466da52016-04-15 09:25:03 -06001212 return icd->GetDisplayPlaneCapabilitiesKHR(phys_dev->phys_dev, mode,
1213 planeIndex, pCapabilities);
Jon Ashburncc370d02016-03-08 09:30:30 -07001214}
1215
Mark Young74dd5d12016-06-30 13:02:42 -06001216LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayPlaneSurfaceKHR(
1217 VkInstance instance, const VkDisplaySurfaceCreateInfoKHR *pCreateInfo,
1218 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburncc370d02016-03-08 09:30:30 -07001219 const VkLayerInstanceDispatchTable *disp;
1220 disp = loader_get_instance_dispatch(instance);
1221 VkResult res;
1222
1223 res = disp->CreateDisplayPlaneSurfaceKHR(instance, pCreateInfo, pAllocator,
1224 pSurface);
1225 return res;
1226}
1227
Jon Ashburnc466da52016-04-15 09:25:03 -06001228VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayPlaneSurfaceKHR(
1229 VkInstance instance, const VkDisplaySurfaceCreateInfoKHR *pCreateInfo,
1230 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburncc370d02016-03-08 09:30:30 -07001231 struct loader_instance *inst = loader_get_instance(instance);
1232 VkIcdSurfaceDisplay *pIcdSurface = NULL;
1233
Petros Bantolasf3095862016-04-14 12:50:42 +01001234 if (!inst->wsi_surface_enabled) {
1235 loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1236 "VK_KHR_surface extension not enabled. "
1237 "vkCreateDisplayPlaneSurfaceKHR not executed!\n");
Jeremy Hayes0231e1c2016-06-14 11:50:02 -06001238 return VK_ERROR_EXTENSION_NOT_PRESENT;
Petros Bantolasf3095862016-04-14 12:50:42 +01001239 }
1240
Mark Young74dd5d12016-06-30 13:02:42 -06001241 pIcdSurface = loader_instance_heap_alloc(
1242 inst, sizeof(VkIcdSurfaceDisplay), VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Jon Ashburncc370d02016-03-08 09:30:30 -07001243 if (pIcdSurface == NULL) {
1244 return VK_ERROR_OUT_OF_HOST_MEMORY;
1245 }
1246
1247 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_DISPLAY;
1248 pIcdSurface->displayMode = pCreateInfo->displayMode;
1249 pIcdSurface->planeIndex = pCreateInfo->planeIndex;
1250 pIcdSurface->planeStackIndex = pCreateInfo->planeStackIndex;
1251 pIcdSurface->transform = pCreateInfo->transform;
1252 pIcdSurface->globalAlpha = pCreateInfo->globalAlpha;
1253 pIcdSurface->alphaMode = pCreateInfo->alphaMode;
1254 pIcdSurface->imageExtent = pCreateInfo->imageExtent;
1255
1256 *pSurface = (VkSurfaceKHR)pIcdSurface;
1257
1258 return VK_SUCCESS;
1259}
1260
Mark Youngf2eabea2016-07-01 15:18:27 -06001261// This is the trampoline entrypoint
1262// for CreateSharedSwapchainsKHR
1263LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSharedSwapchainsKHR(
1264 VkDevice device, uint32_t swapchainCount,
1265 const VkSwapchainCreateInfoKHR *pCreateInfos,
1266 const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchains) {
Mark Young2a2122f2016-09-08 18:36:32 -06001267 const VkLayerDispatchTable *disp;
1268 disp = loader_get_dispatch(device);
1269 return disp->CreateSharedSwapchainsKHR(device, swapchainCount, pCreateInfos, pAllocator, pSwapchains);
Mark Youngf2eabea2016-07-01 15:18:27 -06001270}
1271
Ian Elliott54cea232015-10-30 15:28:23 -06001272bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance,
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001273 const char *name, void **addr) {
Ian Elliott54cea232015-10-30 15:28:23 -06001274 *addr = NULL;
1275
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001276 // Functions for the VK_KHR_surface extension:
Ian Elliott7c352552015-11-19 13:14:05 -07001277 if (!strcmp("vkDestroySurfaceKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001278 *addr = ptr_instance->wsi_surface_enabled ? (void *)vkDestroySurfaceKHR
1279 : NULL;
Ian Elliott7c352552015-11-19 13:14:05 -07001280 return true;
1281 }
Ian Elliott54cea232015-10-30 15:28:23 -06001282 if (!strcmp("vkGetPhysicalDeviceSurfaceSupportKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001283 *addr = ptr_instance->wsi_surface_enabled
1284 ? (void *)vkGetPhysicalDeviceSurfaceSupportKHR
1285 : NULL;
Ian Elliott54cea232015-10-30 15:28:23 -06001286 return true;
1287 }
Ian Elliottea666b22015-11-19 16:05:09 -07001288 if (!strcmp("vkGetPhysicalDeviceSurfaceCapabilitiesKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001289 *addr = ptr_instance->wsi_surface_enabled
1290 ? (void *)vkGetPhysicalDeviceSurfaceCapabilitiesKHR
1291 : NULL;
Ian Elliottea666b22015-11-19 16:05:09 -07001292 return true;
1293 }
1294 if (!strcmp("vkGetPhysicalDeviceSurfaceFormatsKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001295 *addr = ptr_instance->wsi_surface_enabled
1296 ? (void *)vkGetPhysicalDeviceSurfaceFormatsKHR
1297 : NULL;
Ian Elliottea666b22015-11-19 16:05:09 -07001298 return true;
1299 }
1300 if (!strcmp("vkGetPhysicalDeviceSurfacePresentModesKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001301 *addr = ptr_instance->wsi_surface_enabled
1302 ? (void *)vkGetPhysicalDeviceSurfacePresentModesKHR
1303 : NULL;
Ian Elliottea666b22015-11-19 16:05:09 -07001304 return true;
1305 }
Ian Elliott9b89a472015-11-19 16:39:21 -07001306
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001307 // Functions for the VK_KHR_swapchain extension:
1308
1309 // Note: This is a device extension, and its functions are statically
1310 // exported from the loader. Per Khronos decisions, the loader's GIPA
1311 // function will return the trampoline function for such device-extension
1312 // functions, regardless of whether the extension has been enabled.
Ian Elliott9b89a472015-11-19 16:39:21 -07001313 if (!strcmp("vkCreateSwapchainKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001314 *addr = (void *)vkCreateSwapchainKHR;
Ian Elliott9b89a472015-11-19 16:39:21 -07001315 return true;
1316 }
1317 if (!strcmp("vkDestroySwapchainKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001318 *addr = (void *)vkDestroySwapchainKHR;
Ian Elliott9b89a472015-11-19 16:39:21 -07001319 return true;
1320 }
1321 if (!strcmp("vkGetSwapchainImagesKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001322 *addr = (void *)vkGetSwapchainImagesKHR;
Ian Elliott9b89a472015-11-19 16:39:21 -07001323 return true;
1324 }
1325 if (!strcmp("vkAcquireNextImageKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001326 *addr = (void *)vkAcquireNextImageKHR;
Ian Elliott9b89a472015-11-19 16:39:21 -07001327 return true;
1328 }
1329 if (!strcmp("vkQueuePresentKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001330 *addr = (void *)vkQueuePresentKHR;
Ian Elliott9b89a472015-11-19 16:39:21 -07001331 return true;
1332 }
1333
Ian Elliott7c352552015-11-19 13:14:05 -07001334#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001335
1336 // Functions for the VK_KHR_win32_surface extension:
Ian Elliott7c352552015-11-19 13:14:05 -07001337 if (!strcmp("vkCreateWin32SurfaceKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001338 *addr = ptr_instance->wsi_win32_surface_enabled
1339 ? (void *)vkCreateWin32SurfaceKHR
1340 : NULL;
Ian Elliott7c352552015-11-19 13:14:05 -07001341 return true;
1342 }
Ian Elliotte851dd62015-11-24 15:39:10 -07001343 if (!strcmp("vkGetPhysicalDeviceWin32PresentationSupportKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001344 *addr = ptr_instance->wsi_win32_surface_enabled
1345 ? (void *)vkGetPhysicalDeviceWin32PresentationSupportKHR
1346 : NULL;
Ian Elliotte851dd62015-11-24 15:39:10 -07001347 return true;
1348 }
Ian Elliott7c352552015-11-19 13:14:05 -07001349#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliott7c352552015-11-19 13:14:05 -07001350#ifdef VK_USE_PLATFORM_MIR_KHR
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001351
1352 // Functions for the VK_KHR_mir_surface extension:
Ian Elliott7c352552015-11-19 13:14:05 -07001353 if (!strcmp("vkCreateMirSurfaceKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001354 *addr = ptr_instance->wsi_mir_surface_enabled
1355 ? (void *)vkCreateMirSurfaceKHR
1356 : NULL;
Ian Elliott7c352552015-11-19 13:14:05 -07001357 return true;
1358 }
Ian Elliotte851dd62015-11-24 15:39:10 -07001359 if (!strcmp("vkGetPhysicalDeviceMirPresentationSupportKHR", name)) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001360 *addr = ptr_instance->wsi_mir_surface_enabled
1361 ? (void *)vkGetPhysicalDeviceMirPresentationSupportKHR
1362 : NULL;
Ian Elliotte851dd62015-11-24 15:39:10 -07001363 return true;
Jason Ekstrand3bfebc92016-02-12 17:25:03 -08001364 }
Ian Elliott7c352552015-11-19 13:14:05 -07001365#endif // VK_USE_PLATFORM_MIR_KHR
1366#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001367
1368 // Functions for the VK_KHR_wayland_surface extension:
Jon Ashburnc4e9ae62016-02-26 13:14:27 -07001369 if (!strcmp("vkCreateWaylandSurfaceKHR", name)) {
1370 *addr = ptr_instance->wsi_wayland_surface_enabled
1371 ? (void *)vkCreateWaylandSurfaceKHR
1372 : NULL;
1373 return true;
1374 }
1375 if (!strcmp("vkGetPhysicalDeviceWaylandPresentationSupportKHR", name)) {
1376 *addr = ptr_instance->wsi_wayland_surface_enabled
Jon Ashburn1c75aec2016-02-02 17:47:28 -07001377 ? (void *)vkGetPhysicalDeviceWaylandPresentationSupportKHR
1378 : NULL;
Jon Ashburnc4e9ae62016-02-26 13:14:27 -07001379 return true;
1380 }
Ian Elliott7c352552015-11-19 13:14:05 -07001381#endif // VK_USE_PLATFORM_WAYLAND_KHR
1382#ifdef VK_USE_PLATFORM_XCB_KHR
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001383
1384 // Functions for the VK_KHR_xcb_surface extension:
Jon Ashburnc4e9ae62016-02-26 13:14:27 -07001385 if (!strcmp("vkCreateXcbSurfaceKHR", name)) {
1386 *addr = ptr_instance->wsi_xcb_surface_enabled
1387 ? (void *)vkCreateXcbSurfaceKHR
1388 : NULL;
1389 return true;
1390 }
1391 if (!strcmp("vkGetPhysicalDeviceXcbPresentationSupportKHR", name)) {
1392 *addr = ptr_instance->wsi_xcb_surface_enabled
1393 ? (void *)vkGetPhysicalDeviceXcbPresentationSupportKHR
1394 : NULL;
1395 return true;
1396 }
Ian Elliott7c352552015-11-19 13:14:05 -07001397#endif // VK_USE_PLATFORM_XCB_KHR
1398#ifdef VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001399
1400 // Functions for the VK_KHR_xlib_surface extension:
Jon Ashburnc4e9ae62016-02-26 13:14:27 -07001401 if (!strcmp("vkCreateXlibSurfaceKHR", name)) {
1402 *addr = ptr_instance->wsi_xlib_surface_enabled
1403 ? (void *)vkCreateXlibSurfaceKHR
1404 : NULL;
1405 return true;
1406 }
1407 if (!strcmp("vkGetPhysicalDeviceXlibPresentationSupportKHR", name)) {
1408 *addr = ptr_instance->wsi_xlib_surface_enabled
1409 ? (void *)vkGetPhysicalDeviceXlibPresentationSupportKHR
1410 : NULL;
1411 return true;
1412 }
Ian Elliott7c352552015-11-19 13:14:05 -07001413#endif // VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -07001414#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001415
1416 // Functions for the VK_KHR_android_surface extension:
Jon Ashburnc4e9ae62016-02-26 13:14:27 -07001417 if (!strcmp("vkCreateAndroidSurfaceKHR", name)) {
1418 *addr = ptr_instance->wsi_xlib_surface_enabled
1419 ? (void *)vkCreateAndroidSurfaceKHR
1420 : NULL;
1421 return true;
1422 }
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -07001423#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott7c352552015-11-19 13:14:05 -07001424
Mark Lobodzinskib16da052016-08-31 09:31:29 -06001425 // Functions for VK_KHR_display extension:
Jon Ashburncc370d02016-03-08 09:30:30 -07001426 if (!strcmp("vkGetPhysicalDeviceDisplayPropertiesKHR", name)) {
1427 *addr = ptr_instance->wsi_display_enabled
1428 ? (void *)vkGetPhysicalDeviceDisplayPropertiesKHR
1429 : NULL;
1430 return true;
1431 }
1432 if (!strcmp("vkGetPhysicalDeviceDisplayPlanePropertiesKHR", name)) {
1433 *addr = ptr_instance->wsi_display_enabled
1434 ? (void *)vkGetPhysicalDeviceDisplayPlanePropertiesKHR
1435 : NULL;
1436 return true;
1437 }
1438 if (!strcmp("vkGetDisplayPlaneSupportedDisplaysKHR", name)) {
1439 *addr = ptr_instance->wsi_display_enabled
1440 ? (void *)vkGetDisplayPlaneSupportedDisplaysKHR
1441 : NULL;
1442 return true;
1443 }
1444 if (!strcmp("vkGetDisplayModePropertiesKHR", name)) {
1445 *addr = ptr_instance->wsi_display_enabled
1446 ? (void *)vkGetDisplayModePropertiesKHR
1447 : NULL;
1448 return true;
1449 }
1450 if (!strcmp("vkCreateDisplayModeKHR", name)) {
1451 *addr = ptr_instance->wsi_display_enabled
1452 ? (void *)vkCreateDisplayModeKHR
1453 : NULL;
1454 return true;
1455 }
1456 if (!strcmp("vkGetDisplayPlaneCapabilitiesKHR", name)) {
1457 *addr = ptr_instance->wsi_display_enabled
1458 ? (void *)vkGetDisplayPlaneCapabilitiesKHR
1459 : NULL;
1460 return true;
1461 }
1462 if (!strcmp("vkCreateDisplayPlaneSurfaceKHR", name)) {
1463 *addr = ptr_instance->wsi_display_enabled
1464 ? (void *)vkCreateDisplayPlaneSurfaceKHR
1465 : NULL;
1466 return true;
1467 }
Mark Youngf2eabea2016-07-01 15:18:27 -06001468
1469 // Functions for KHR_display_swapchain extension:
1470 if (!strcmp("vkCreateSharedSwapchainsKHR", name)) {
1471 *addr = (void *)vkCreateSharedSwapchainsKHR;
1472 return true;
1473 }
1474
Jon Ashburnc4e9ae62016-02-26 13:14:27 -07001475 return false;
Ian Elliott0d4ffa32016-03-24 13:59:22 -06001476}