blob: 123a7f89b505d7f66b8b79cfd328ee9ad494cee9 [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
Ian Elliott954fa342015-10-30 15:28:23 -060024#define _GNU_SOURCE
Ian Elliott2b8965a2016-03-24 13:59:22 -060025#include <stdio.h>
Ian Elliott954fa342015-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 Elliott2c05e222015-11-19 13:14:05 -070031#include <vulkan/vk_icd.h>
Ian Elliott954fa342015-10-30 15:28:23 -060032
Mark Young16573c72016-06-28 10:52:43 -060033// The first ICD/Loader interface that support querying the SurfaceKHR from
34// the ICDs.
35#define ICD_VER_SUPPORTS_ICD_SURFACE_KHR 3
36
Ian Elliott954fa342015-10-30 15:28:23 -060037static const VkExtensionProperties wsi_surface_extension_info = {
Jon Ashburn23d36b12016-02-02 17:47:28 -070038 .extensionName = VK_KHR_SURFACE_EXTENSION_NAME,
39 .specVersion = VK_KHR_SURFACE_SPEC_VERSION,
Ian Elliott954fa342015-10-30 15:28:23 -060040};
41
Ian Elliottc2e9aee2015-11-19 11:58:08 -070042#ifdef VK_USE_PLATFORM_WIN32_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060043static const VkExtensionProperties wsi_win32_surface_extension_info = {
Jon Ashburn23d36b12016-02-02 17:47:28 -070044 .extensionName = VK_KHR_WIN32_SURFACE_EXTENSION_NAME,
45 .specVersion = VK_KHR_WIN32_SURFACE_SPEC_VERSION,
Ian Elliott954fa342015-10-30 15:28:23 -060046};
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -070047#endif // VK_USE_PLATFORM_WIN32_KHR
48
Ian Elliottaf7d6362015-10-30 17:45:05 -060049#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060050static const VkExtensionProperties wsi_mir_surface_extension_info = {
Jon Ashburn23d36b12016-02-02 17:47:28 -070051 .extensionName = VK_KHR_MIR_SURFACE_EXTENSION_NAME,
52 .specVersion = VK_KHR_MIR_SURFACE_SPEC_VERSION,
Ian Elliott954fa342015-10-30 15:28:23 -060053};
Ian Elliottaf7d6362015-10-30 17:45:05 -060054#endif // VK_USE_PLATFORM_MIR_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060055
Ian Elliottaf7d6362015-10-30 17:45:05 -060056#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060057static const VkExtensionProperties wsi_wayland_surface_extension_info = {
Jon Ashburn23d36b12016-02-02 17:47:28 -070058 .extensionName = VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME,
59 .specVersion = VK_KHR_WAYLAND_SURFACE_SPEC_VERSION,
Ian Elliott954fa342015-10-30 15:28:23 -060060};
Ian Elliottaf7d6362015-10-30 17:45:05 -060061#endif // VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060062
Ian Elliottaf7d6362015-10-30 17:45:05 -060063#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060064static const VkExtensionProperties wsi_xcb_surface_extension_info = {
Jon Ashburn23d36b12016-02-02 17:47:28 -070065 .extensionName = VK_KHR_XCB_SURFACE_EXTENSION_NAME,
66 .specVersion = VK_KHR_XCB_SURFACE_SPEC_VERSION,
Ian Elliott954fa342015-10-30 15:28:23 -060067};
Ian Elliottaf7d6362015-10-30 17:45:05 -060068#endif // VK_USE_PLATFORM_XCB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060069
Ian Elliottaf7d6362015-10-30 17:45:05 -060070#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060071static const VkExtensionProperties wsi_xlib_surface_extension_info = {
Jon Ashburn23d36b12016-02-02 17:47:28 -070072 .extensionName = VK_KHR_XLIB_SURFACE_EXTENSION_NAME,
73 .specVersion = VK_KHR_XLIB_SURFACE_SPEC_VERSION,
Ian Elliott954fa342015-10-30 15:28:23 -060074};
Ian Elliottaf7d6362015-10-30 17:45:05 -060075#endif // VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -070076
77#ifdef VK_USE_PLATFORM_ANDROID_KHR
78static const VkExtensionProperties wsi_android_surface_extension_info = {
Jon Ashburn23d36b12016-02-02 17:47:28 -070079 .extensionName = VK_KHR_ANDROID_SURFACE_EXTENSION_NAME,
80 .specVersion = VK_KHR_ANDROID_SURFACE_REVISION,
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -070081};
82#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060083
Jon Ashburn23d36b12016-02-02 17:47:28 -070084void wsi_create_instance(struct loader_instance *ptr_instance,
85 const VkInstanceCreateInfo *pCreateInfo) {
Ian Elliottaf7d6362015-10-30 17:45:05 -060086 ptr_instance->wsi_surface_enabled = false;
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -070087
88#ifdef VK_USE_PLATFORM_WIN32_KHR
Jon Ashburnc7d3e732016-03-08 09:30:30 -070089 ptr_instance->wsi_win32_surface_enabled = false;
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -070090#endif // VK_USE_PLATFORM_WIN32_KHR
91#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060092 ptr_instance->wsi_mir_surface_enabled = false;
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -070093#endif // VK_USE_PLATFORM_MIR_KHR
94#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060095 ptr_instance->wsi_wayland_surface_enabled = false;
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -070096#endif // VK_USE_PLATFORM_WAYLAND_KHR
97#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060098 ptr_instance->wsi_xcb_surface_enabled = false;
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -070099#endif // VK_USE_PLATFORM_XCB_KHR
100#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600101 ptr_instance->wsi_xlib_surface_enabled = false;
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -0700102#endif // VK_USE_PLATFORM_XLIB_KHR
103#ifdef VK_USE_PLATFORM_ANDROID_KHR
104 ptr_instance->wsi_android_surface_enabled = false;
105#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600106
Jon Ashburnc7d3e732016-03-08 09:30:30 -0700107 ptr_instance->wsi_display_enabled = false;
108
Jon Ashburnf19916e2016-01-11 13:12:43 -0700109 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Jon Ashburn23d36b12016-02-02 17:47:28 -0700110 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
111 VK_KHR_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott954fa342015-10-30 15:28:23 -0600112 ptr_instance->wsi_surface_enabled = true;
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700113 continue;
Ian Elliott954fa342015-10-30 15:28:23 -0600114 }
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700115#ifdef VK_USE_PLATFORM_WIN32_KHR
Jon Ashburn23d36b12016-02-02 17:47:28 -0700116 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
117 VK_KHR_WIN32_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliottdb4300a2015-11-23 10:17:23 -0700118 ptr_instance->wsi_win32_surface_enabled = true;
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700119 continue;
Ian Elliott954fa342015-10-30 15:28:23 -0600120 }
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -0700121#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliottaf7d6362015-10-30 17:45:05 -0600122#ifdef VK_USE_PLATFORM_MIR_KHR
Jon Ashburn23d36b12016-02-02 17:47:28 -0700123 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
124 VK_KHR_MIR_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott954fa342015-10-30 15:28:23 -0600125 ptr_instance->wsi_mir_surface_enabled = true;
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700126 continue;
Ian Elliott954fa342015-10-30 15:28:23 -0600127 }
Ian Elliottaf7d6362015-10-30 17:45:05 -0600128#endif // VK_USE_PLATFORM_MIR_KHR
129#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Jon Ashburn23d36b12016-02-02 17:47:28 -0700130 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
131 VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott954fa342015-10-30 15:28:23 -0600132 ptr_instance->wsi_wayland_surface_enabled = true;
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700133 continue;
Ian Elliott954fa342015-10-30 15:28:23 -0600134 }
Ian Elliottaf7d6362015-10-30 17:45:05 -0600135#endif // VK_USE_PLATFORM_WAYLAND_KHR
136#ifdef VK_USE_PLATFORM_XCB_KHR
Jon Ashburn23d36b12016-02-02 17:47:28 -0700137 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
138 VK_KHR_XCB_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott954fa342015-10-30 15:28:23 -0600139 ptr_instance->wsi_xcb_surface_enabled = true;
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700140 continue;
Ian Elliott954fa342015-10-30 15:28:23 -0600141 }
Ian Elliottaf7d6362015-10-30 17:45:05 -0600142#endif // VK_USE_PLATFORM_XCB_KHR
143#ifdef VK_USE_PLATFORM_XLIB_KHR
Jon Ashburn23d36b12016-02-02 17:47:28 -0700144 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
145 VK_KHR_XLIB_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott954fa342015-10-30 15:28:23 -0600146 ptr_instance->wsi_xlib_surface_enabled = true;
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700147 continue;
Ian Elliott954fa342015-10-30 15:28:23 -0600148 }
Ian Elliottaf7d6362015-10-30 17:45:05 -0600149#endif // VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -0700150#ifdef VK_USE_PLATFORM_ANDROID_KHR
Jon Ashburn23d36b12016-02-02 17:47:28 -0700151 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
152 VK_KHR_ANDROID_SURFACE_EXTENSION_NAME) == 0) {
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -0700153 ptr_instance->wsi_android_surface_enabled = true;
154 continue;
155 }
156#endif // VK_USE_PLATFORM_ANDROID_KHR
Jon Ashburnc7d3e732016-03-08 09:30:30 -0700157 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
158 VK_KHR_DISPLAY_EXTENSION_NAME) == 0) {
159 ptr_instance->wsi_display_enabled = true;
160 continue;
161 }
Ian Elliott954fa342015-10-30 15:28:23 -0600162 }
163}
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -0600164
165// Linux WSI surface extensions are not always compiled into the loader. (Assume
166// for Windows the KHR_win32_surface is always compiled into loader). A given
167// Linux build environment might not have the headers required for building one
168// of the four extensions (Xlib, Xcb, Mir, Wayland). Thus, need to check if
169// the built loader actually supports the particular Linux surface extension.
170// If not supported by the built loader it will not be included in the list of
171// enumerated instance extensions. This solves the issue where an ICD or layer
172// advertises support for a given Linux surface extension but the loader was not
173// built to support the extension.
Jon Ashburn6fa520f2016-03-25 12:49:35 -0600174bool wsi_unsupported_instance_extension(const VkExtensionProperties *ext_prop) {
175#ifndef VK_USE_PLATFORM_MIR_KHR
176 if (!strcmp(ext_prop->extensionName, "VK_KHR_mir_surface"))
177 return true;
178#endif // VK_USE_PLATFORM_MIR_KHR
179#ifndef VK_USE_PLATFORM_WAYLAND_KHR
180 if (!strcmp(ext_prop->extensionName, "VK_KHR_wayland_surface"))
181 return true;
182#endif // VK_USE_PLATFORM_WAYLAND_KHR
183#ifndef VK_USE_PLATFORM_XCB_KHR
184 if (!strcmp(ext_prop->extensionName, "VK_KHR_xcb_surface"))
185 return true;
186#endif // VK_USE_PLATFORM_XCB_KHR
187#ifndef VK_USE_PLATFORM_XLIB_KHR
188 if (!strcmp(ext_prop->extensionName, "VK_KHR_xlib_surface"))
189 return true;
190#endif // VK_USE_PLATFORM_XLIB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600191
Jon Ashburn6fa520f2016-03-25 12:49:35 -0600192 return false;
193}
Ian Elliott2c05e222015-11-19 13:14:05 -0700194
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -0600195// Functions for the VK_KHR_surface extension:
196
197// This is the trampoline entrypoint for DestroySurfaceKHR
Jon Ashburn23d36b12016-02-02 17:47:28 -0700198LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
199vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface,
200 const VkAllocationCallbacks *pAllocator) {
Ian Elliottfb42cd72015-11-25 14:43:02 -0700201 const VkLayerInstanceDispatchTable *disp;
202 disp = loader_get_instance_dispatch(instance);
203 disp->DestroySurfaceKHR(instance, surface, pAllocator);
204}
205
Jon Ashburnc7d3e732016-03-08 09:30:30 -0700206// TODO probably need to lock around all the loader_get_instance() calls.
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -0600207
208// This is the instance chain terminator function for DestroySurfaceKHR
Jon Ashburn23d36b12016-02-02 17:47:28 -0700209VKAPI_ATTR void VKAPI_CALL
Jon Ashburn1530c342016-02-26 13:14:27 -0700210terminator_DestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface,
211 const VkAllocationCallbacks *pAllocator) {
Ian Elliottdb4300a2015-11-23 10:17:23 -0700212 struct loader_instance *ptr_instance = loader_get_instance(instance);
213
Mark Young16573c72016-06-28 10:52:43 -0600214// Android doesn't have to worry about multiple ICD scenario, but the rest do.
215#ifndef VK_USE_PLATFORM_ANDROID_KHR
216 VkIcdSurface *icd_surface = (VkIcdSurface *)(surface);
217 if (NULL != icd_surface->real_icd_surfaces) {
218 for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
219 if (ptr_instance->icd_libs.list[i].interface_version >=
220 ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
221 struct loader_icd *icd = &ptr_instance->icds[i];
222 if (NULL != icd->DestroySurfaceKHR &&
223 NULL != (void *)icd_surface->real_icd_surfaces[i]) {
Piers Daniellf9262be2016-09-14 11:24:36 -0600224 icd->DestroySurfaceKHR(icd->instance,
Mark Young16573c72016-06-28 10:52:43 -0600225 icd_surface->real_icd_surfaces[i],
226 pAllocator);
227 icd_surface->real_icd_surfaces[i] = (VkSurfaceKHR)NULL;
228 }
229 } else {
230 // The real_icd_surface for any ICD not supporting the proper
231 // interface version should be NULL. If not, then we have a
232 // problem.
233 assert(NULL == icd_surface->real_icd_surfaces[i]);
234 }
235 }
236 loader_instance_heap_free(ptr_instance, icd_surface->real_icd_surfaces);
237 }
238#endif // !VK_USE_PLATFORM_XLIB_KHR
239
Mark Young0ad83132016-06-30 13:02:42 -0600240 loader_instance_heap_free(ptr_instance, (void *)surface);
Ian Elliott2c05e222015-11-19 13:14:05 -0700241}
242
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -0600243// This is the trampoline entrypoint for GetPhysicalDeviceSurfaceSupportKHR
Jon Ashburn23d36b12016-02-02 17:47:28 -0700244LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
245vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice,
246 uint32_t queueFamilyIndex,
247 VkSurfaceKHR surface,
248 VkBool32 *pSupported) {
Ian Elliott954fa342015-10-30 15:28:23 -0600249 const VkLayerInstanceDispatchTable *disp;
Jon Ashburn014438f2016-03-01 19:51:07 -0700250 VkPhysicalDevice unwrapped_phys_dev =
251 loader_unwrap_physical_device(physicalDevice);
Ian Elliott954fa342015-10-30 15:28:23 -0600252 disp = loader_get_instance_dispatch(physicalDevice);
253 VkResult res = disp->GetPhysicalDeviceSurfaceSupportKHR(
Jon Ashburn014438f2016-03-01 19:51:07 -0700254 unwrapped_phys_dev, queueFamilyIndex, surface, pSupported);
Ian Elliott954fa342015-10-30 15:28:23 -0600255 return res;
256}
257
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -0600258// This is the instance chain terminator function for
259// GetPhysicalDeviceSurfaceSupportKHR
260VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceSupportKHR(
261 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
262 VkSurfaceKHR surface, VkBool32 *pSupported) {
Ian Elliott2b8965a2016-03-24 13:59:22 -0600263 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn23d36b12016-02-02 17:47:28 -0700264 struct loader_physical_device *phys_dev =
265 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -0600266 struct loader_instance *ptr_instance =
267 (struct loader_instance *)phys_dev->this_icd->this_instance;
268 if (!ptr_instance->wsi_surface_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -0600269 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
270 "VK_KHR_VK_KHR_surface extension not enabled. "
271 "vkGetPhysicalDeviceSurfaceSupportKHR not executed!\n");
Ian Elliott2b8965a2016-03-24 13:59:22 -0600272 return VK_SUCCESS;
273 }
274
275 // Next, if so, proceed with the implementation of this function:
Ian Elliott954fa342015-10-30 15:28:23 -0600276 struct loader_icd *icd = phys_dev->this_icd;
277
Jon Ashburn23d36b12016-02-02 17:47:28 -0700278 assert(pSupported &&
279 "GetPhysicalDeviceSurfaceSupportKHR: Error, null pSupported");
Ian Elliott954fa342015-10-30 15:28:23 -0600280 *pSupported = false;
281
Jon Ashburn23d36b12016-02-02 17:47:28 -0700282 assert(icd->GetPhysicalDeviceSurfaceSupportKHR &&
283 "loader: null GetPhysicalDeviceSurfaceSupportKHR ICD pointer");
Ian Elliott954fa342015-10-30 15:28:23 -0600284
Mark Young16573c72016-06-28 10:52:43 -0600285// Android doesn't have to worry about multiple ICD scenario, but the rest do.
286#ifndef VK_USE_PLATFORM_ANDROID_KHR
287 VkIcdSurface *icd_surface = (VkIcdSurface *)(surface);
288 if (NULL != icd_surface->real_icd_surfaces &&
289 NULL != (void *)icd_surface->real_icd_surfaces[phys_dev->icd_index]) {
290 return icd->GetPhysicalDeviceSurfaceSupportKHR(
291 phys_dev->phys_dev, queueFamilyIndex,
292 icd_surface->real_icd_surfaces[phys_dev->icd_index], pSupported);
293 }
294#endif
295
Jon Ashburn23d36b12016-02-02 17:47:28 -0700296 return icd->GetPhysicalDeviceSurfaceSupportKHR(
297 phys_dev->phys_dev, queueFamilyIndex, surface, pSupported);
Ian Elliott954fa342015-10-30 15:28:23 -0600298}
299
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -0600300// This is the trampoline entrypoint for GetPhysicalDeviceSurfaceCapabilitiesKHR
Jon Ashburn23d36b12016-02-02 17:47:28 -0700301LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
302vkGetPhysicalDeviceSurfaceCapabilitiesKHR(
303 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
304 VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) {
Jon Ashburn014438f2016-03-01 19:51:07 -0700305
Ian Elliott486c5502015-11-19 16:05:09 -0700306 const VkLayerInstanceDispatchTable *disp;
Jon Ashburn014438f2016-03-01 19:51:07 -0700307 VkPhysicalDevice unwrapped_phys_dev =
308 loader_unwrap_physical_device(physicalDevice);
Ian Elliott486c5502015-11-19 16:05:09 -0700309 disp = loader_get_instance_dispatch(physicalDevice);
310 VkResult res = disp->GetPhysicalDeviceSurfaceCapabilitiesKHR(
Jon Ashburn014438f2016-03-01 19:51:07 -0700311 unwrapped_phys_dev, surface, pSurfaceCapabilities);
Ian Elliott486c5502015-11-19 16:05:09 -0700312 return res;
313}
314
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -0600315// This is the instance chain terminator function for
316// GetPhysicalDeviceSurfaceCapabilitiesKHR
Jon Ashburn1530c342016-02-26 13:14:27 -0700317VKAPI_ATTR VkResult VKAPI_CALL
318terminator_GetPhysicalDeviceSurfaceCapabilitiesKHR(
Jon Ashburn23d36b12016-02-02 17:47:28 -0700319 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
320 VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) {
Ian Elliott2b8965a2016-03-24 13:59:22 -0600321 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn23d36b12016-02-02 17:47:28 -0700322 struct loader_physical_device *phys_dev =
323 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -0600324 struct loader_instance *ptr_instance =
325 (struct loader_instance *)phys_dev->this_icd->this_instance;
326 if (!ptr_instance->wsi_surface_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -0600327 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
328 "VK_KHR_surface extension not enabled. "
329 "vkGetPhysicalDeviceSurfaceCapabilitiesKHR not executed!\n");
Ian Elliott2b8965a2016-03-24 13:59:22 -0600330 return VK_SUCCESS;
331 }
332
333 // Next, if so, proceed with the implementation of this function:
Ian Elliott486c5502015-11-19 16:05:09 -0700334 struct loader_icd *icd = phys_dev->this_icd;
335
Jon Ashburn23d36b12016-02-02 17:47:28 -0700336 assert(pSurfaceCapabilities && "GetPhysicalDeviceSurfaceCapabilitiesKHR: "
337 "Error, null pSurfaceCapabilities");
Ian Elliott486c5502015-11-19 16:05:09 -0700338
Jon Ashburn23d36b12016-02-02 17:47:28 -0700339 assert(icd->GetPhysicalDeviceSurfaceCapabilitiesKHR &&
340 "loader: null GetPhysicalDeviceSurfaceCapabilitiesKHR ICD pointer");
Ian Elliott486c5502015-11-19 16:05:09 -0700341
Mark Young16573c72016-06-28 10:52:43 -0600342// Android doesn't have to worry about multiple ICD scenario, but the rest do.
343#ifndef VK_USE_PLATFORM_ANDROID_KHR
344 VkIcdSurface *icd_surface = (VkIcdSurface *)(surface);
345 if (NULL != icd_surface->real_icd_surfaces &&
346 NULL != (void *)icd_surface->real_icd_surfaces[phys_dev->icd_index]) {
347 return icd->GetPhysicalDeviceSurfaceCapabilitiesKHR(
348 phys_dev->phys_dev,
349 icd_surface->real_icd_surfaces[phys_dev->icd_index],
350 pSurfaceCapabilities);
351 }
352#endif
353
Jon Ashburn23d36b12016-02-02 17:47:28 -0700354 return icd->GetPhysicalDeviceSurfaceCapabilitiesKHR(
355 phys_dev->phys_dev, surface, pSurfaceCapabilities);
Ian Elliott486c5502015-11-19 16:05:09 -0700356}
357
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -0600358
359// This is the trampoline entrypoint for GetPhysicalDeviceSurfaceFormatsKHR
Jon Ashburn23d36b12016-02-02 17:47:28 -0700360LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
361vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice,
362 VkSurfaceKHR surface,
363 uint32_t *pSurfaceFormatCount,
364 VkSurfaceFormatKHR *pSurfaceFormats) {
Jon Ashburn014438f2016-03-01 19:51:07 -0700365 VkPhysicalDevice unwrapped_phys_dev =
366 loader_unwrap_physical_device(physicalDevice);
Ian Elliott486c5502015-11-19 16:05:09 -0700367 const VkLayerInstanceDispatchTable *disp;
368 disp = loader_get_instance_dispatch(physicalDevice);
369 VkResult res = disp->GetPhysicalDeviceSurfaceFormatsKHR(
Jon Ashburn014438f2016-03-01 19:51:07 -0700370 unwrapped_phys_dev, surface, pSurfaceFormatCount, pSurfaceFormats);
Ian Elliott486c5502015-11-19 16:05:09 -0700371 return res;
372}
373
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -0600374
375// This is the instance chain terminator function for GetPhysicalDeviceSurfaceFormatsKHR
Jon Ashburn1530c342016-02-26 13:14:27 -0700376VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceFormatsKHR(
377 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
378 uint32_t *pSurfaceFormatCount, VkSurfaceFormatKHR *pSurfaceFormats) {
Ian Elliott2b8965a2016-03-24 13:59:22 -0600379 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn23d36b12016-02-02 17:47:28 -0700380 struct loader_physical_device *phys_dev =
381 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -0600382 struct loader_instance *ptr_instance =
383 (struct loader_instance *)phys_dev->this_icd->this_instance;
384 if (!ptr_instance->wsi_surface_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -0600385 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
386 "VK_KHR_surface extension not enabled. "
387 "vkGetPhysicalDeviceSurfaceFormatsKHR not executed!\n");
Ian Elliott2b8965a2016-03-24 13:59:22 -0600388 return VK_SUCCESS;
389 }
390
391 // Next, if so, proceed with the implementation of this function:
Ian Elliott486c5502015-11-19 16:05:09 -0700392 struct loader_icd *icd = phys_dev->this_icd;
393
Jon Ashburn23d36b12016-02-02 17:47:28 -0700394 assert(
395 pSurfaceFormatCount &&
396 "GetPhysicalDeviceSurfaceFormatsKHR: Error, null pSurfaceFormatCount");
Ian Elliott486c5502015-11-19 16:05:09 -0700397
Jon Ashburn23d36b12016-02-02 17:47:28 -0700398 assert(icd->GetPhysicalDeviceSurfaceFormatsKHR &&
399 "loader: null GetPhysicalDeviceSurfaceFormatsKHR ICD pointer");
Ian Elliott486c5502015-11-19 16:05:09 -0700400
Mark Young16573c72016-06-28 10:52:43 -0600401// Android doesn't have to worry about multiple ICD scenario, but the rest do.
402#ifndef VK_USE_PLATFORM_ANDROID_KHR
403 VkIcdSurface *icd_surface = (VkIcdSurface *)(surface);
404 if (NULL != icd_surface->real_icd_surfaces &&
405 NULL != (void *)icd_surface->real_icd_surfaces[phys_dev->icd_index]) {
406 return icd->GetPhysicalDeviceSurfaceFormatsKHR(
407 phys_dev->phys_dev,
408 icd_surface->real_icd_surfaces[phys_dev->icd_index],
409 pSurfaceFormatCount, pSurfaceFormats);
410 }
411#endif
412
Jon Ashburn23d36b12016-02-02 17:47:28 -0700413 return icd->GetPhysicalDeviceSurfaceFormatsKHR(
414 phys_dev->phys_dev, surface, pSurfaceFormatCount, pSurfaceFormats);
Ian Elliott486c5502015-11-19 16:05:09 -0700415}
416
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -0600417// This is the trampoline entrypoint for GetPhysicalDeviceSurfacePresentModesKHR
Jon Ashburn23d36b12016-02-02 17:47:28 -0700418LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
419vkGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,
420 VkSurfaceKHR surface,
421 uint32_t *pPresentModeCount,
422 VkPresentModeKHR *pPresentModes) {
Jon Ashburn014438f2016-03-01 19:51:07 -0700423 VkPhysicalDevice unwrapped_phys_dev =
424 loader_unwrap_physical_device(physicalDevice);
Ian Elliott486c5502015-11-19 16:05:09 -0700425 const VkLayerInstanceDispatchTable *disp;
426 disp = loader_get_instance_dispatch(physicalDevice);
427 VkResult res = disp->GetPhysicalDeviceSurfacePresentModesKHR(
Jon Ashburn014438f2016-03-01 19:51:07 -0700428 unwrapped_phys_dev, surface, pPresentModeCount, pPresentModes);
Ian Elliott486c5502015-11-19 16:05:09 -0700429 return res;
430}
431
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -0600432// This is the instance chain terminator function for
433// GetPhysicalDeviceSurfacePresentModesKHR
Jon Ashburn1530c342016-02-26 13:14:27 -0700434VKAPI_ATTR VkResult VKAPI_CALL
435terminator_GetPhysicalDeviceSurfacePresentModesKHR(
Jon Ashburn23d36b12016-02-02 17:47:28 -0700436 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
437 uint32_t *pPresentModeCount, VkPresentModeKHR *pPresentModes) {
Ian Elliott2b8965a2016-03-24 13:59:22 -0600438 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn23d36b12016-02-02 17:47:28 -0700439 struct loader_physical_device *phys_dev =
440 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -0600441 struct loader_instance *ptr_instance =
442 (struct loader_instance *)phys_dev->this_icd->this_instance;
443 if (!ptr_instance->wsi_surface_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -0600444 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
445 "VK_KHR_surface extension not enabled. "
446 "vkGetPhysicalDeviceSurfacePresentModesKHR not executed!\n");
Ian Elliott2b8965a2016-03-24 13:59:22 -0600447 return VK_SUCCESS;
448 }
449
450 // Next, if so, proceed with the implementation of this function:
Ian Elliott486c5502015-11-19 16:05:09 -0700451 struct loader_icd *icd = phys_dev->this_icd;
452
Jon Ashburn23d36b12016-02-02 17:47:28 -0700453 assert(pPresentModeCount && "GetPhysicalDeviceSurfacePresentModesKHR: "
454 "Error, null pPresentModeCount");
Ian Elliott486c5502015-11-19 16:05:09 -0700455
Jon Ashburn23d36b12016-02-02 17:47:28 -0700456 assert(icd->GetPhysicalDeviceSurfacePresentModesKHR &&
457 "loader: null GetPhysicalDeviceSurfacePresentModesKHR ICD pointer");
Ian Elliott486c5502015-11-19 16:05:09 -0700458
Mark Young16573c72016-06-28 10:52:43 -0600459// Android doesn't have to worry about multiple ICD scenario, but the rest do.
460#ifndef VK_USE_PLATFORM_ANDROID_KHR
461 VkIcdSurface *icd_surface = (VkIcdSurface *)(surface);
462 if (NULL != icd_surface->real_icd_surfaces &&
463 NULL != (void *)icd_surface->real_icd_surfaces[phys_dev->icd_index]) {
464 return icd->GetPhysicalDeviceSurfacePresentModesKHR(
465 phys_dev->phys_dev,
466 icd_surface->real_icd_surfaces[phys_dev->icd_index],
467 pPresentModeCount, pPresentModes);
468 }
469#endif
470
Jon Ashburn23d36b12016-02-02 17:47:28 -0700471 return icd->GetPhysicalDeviceSurfacePresentModesKHR(
472 phys_dev->phys_dev, surface, pPresentModeCount, pPresentModes);
Ian Elliott486c5502015-11-19 16:05:09 -0700473}
474
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -0600475// Functions for the VK_KHR_swapchain extension:
Ian Elliott2c05e222015-11-19 13:14:05 -0700476
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -0600477// This is the trampoline entrypoint for CreateSwapchainKHR
Mark Young0ad83132016-06-30 13:02:42 -0600478LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR(
479 VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
480 const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain) {
Ian Elliott934d0d52015-11-19 16:39:21 -0700481 const VkLayerDispatchTable *disp;
482 disp = loader_get_dispatch(device);
Mark Youngead9b932016-09-08 12:28:38 -0600483 return disp->CreateSwapchainKHR(device, pCreateInfo, pAllocator,
484 pSwapchain);
Ian Elliott934d0d52015-11-19 16:39:21 -0700485}
Ian Elliott2c05e222015-11-19 13:14:05 -0700486
Mark Young16573c72016-06-28 10:52:43 -0600487VKAPI_ATTR VkResult VKAPI_CALL terminator_vkCreateSwapchainKHR(
488 VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
489 const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain) {
490 uint32_t icd_index = 0;
491 struct loader_device *dev;
492 struct loader_icd *icd = loader_get_icd_and_device(device, &dev, &icd_index);
Mark Young16573c72016-06-28 10:52:43 -0600493 if (NULL != icd &&
494 NULL != icd->CreateSwapchainKHR) {
495 // Android doesn't have to worry about multiple ICD scenario, but the rest do.
496#ifndef VK_USE_PLATFORM_ANDROID_KHR
497 VkIcdSurface *icd_surface = (VkIcdSurface *)(pCreateInfo->surface);
498 if (NULL != icd_surface->real_icd_surfaces) {
499 if (NULL != (void *)icd_surface->real_icd_surfaces[icd_index]) {
500 // We found the ICD, and there is an ICD KHR surface
501 // associated with it, so copy the CreateInfo struct
502 // and point it at the ICD's surface.
503 VkSwapchainCreateInfoKHR *pCreateCopy =
504 loader_stack_alloc(sizeof(VkSwapchainCreateInfoKHR));
505 if (NULL == pCreateCopy) {
506 return VK_ERROR_OUT_OF_HOST_MEMORY;
507 }
Piers Daniellf9262be2016-09-14 11:24:36 -0600508 memcpy(pCreateCopy, pCreateInfo, sizeof(VkSwapchainCreateInfoKHR));
Mark Young16573c72016-06-28 10:52:43 -0600509 pCreateCopy->surface =
510 icd_surface->real_icd_surfaces[icd_index];
511 return icd->CreateSwapchainKHR(device, pCreateCopy, pAllocator, pSwapchain);
512 }
513 }
514#endif
515 return icd->CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain);
516 }
517 return VK_SUCCESS;
518}
519
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -0600520// This is the trampoline entrypoint for DestroySwapchainKHR
Jon Ashburn23d36b12016-02-02 17:47:28 -0700521LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
522vkDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain,
523 const VkAllocationCallbacks *pAllocator) {
Ian Elliott934d0d52015-11-19 16:39:21 -0700524 const VkLayerDispatchTable *disp;
525 disp = loader_get_dispatch(device);
526 disp->DestroySwapchainKHR(device, swapchain, pAllocator);
527}
Ian Elliott2c05e222015-11-19 13:14:05 -0700528
Mark Young16573c72016-06-28 10:52:43 -0600529/*
530 * This is the trampoline entrypoint
531 * for GetSwapchainImagesKHR
532 */
533LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR(
534 VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount,
535 VkImage *pSwapchainImages) {
Ian Elliott934d0d52015-11-19 16:39:21 -0700536 const VkLayerDispatchTable *disp;
537 disp = loader_get_dispatch(device);
Mark Youngead9b932016-09-08 12:28:38 -0600538 return disp->GetSwapchainImagesKHR(
Jon Ashburn23d36b12016-02-02 17:47:28 -0700539 device, swapchain, pSwapchainImageCount, pSwapchainImages);
Ian Elliott934d0d52015-11-19 16:39:21 -0700540}
541
Mark Young16573c72016-06-28 10:52:43 -0600542/*
543 * This is the trampoline entrypoint
544 * for AcquireNextImageKHR
545 */
546LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImageKHR(
547 VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
548 VkSemaphore semaphore, VkFence fence, uint32_t *pImageIndex) {
Ian Elliott934d0d52015-11-19 16:39:21 -0700549 const VkLayerDispatchTable *disp;
550 disp = loader_get_dispatch(device);
Mark Youngead9b932016-09-08 12:28:38 -0600551 return disp->AcquireNextImageKHR(device, swapchain, timeout,
552 semaphore, fence, pImageIndex);
Ian Elliott934d0d52015-11-19 16:39:21 -0700553}
554
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -0600555// This is the trampoline entrypoint for QueuePresentKHR
Jon Ashburn23d36b12016-02-02 17:47:28 -0700556LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
557vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) {
Ian Elliott934d0d52015-11-19 16:39:21 -0700558 const VkLayerDispatchTable *disp;
559 disp = loader_get_dispatch(queue);
Mark Youngead9b932016-09-08 12:28:38 -0600560 return disp->QueuePresentKHR(queue, pPresentInfo);
Ian Elliott934d0d52015-11-19 16:39:21 -0700561}
Ian Elliott2c05e222015-11-19 13:14:05 -0700562
Ian Elliott2c05e222015-11-19 13:14:05 -0700563#ifdef VK_USE_PLATFORM_WIN32_KHR
564
Ian Elliott2c05e222015-11-19 13:14:05 -0700565
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -0600566// Functions for the VK_KHR_win32_surface extension:
567
568// This is the trampoline entrypoint for CreateWin32SurfaceKHR
Mark Young0ad83132016-06-30 13:02:42 -0600569LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR(
570 VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
571 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburnf72a04b2015-11-25 17:55:49 -0700572 const VkLayerInstanceDispatchTable *disp;
573 disp = loader_get_instance_dispatch(instance);
574 VkResult res;
575
Jon Ashburn23d36b12016-02-02 17:47:28 -0700576 res = disp->CreateWin32SurfaceKHR(instance, pCreateInfo, pAllocator,
577 pSurface);
Jon Ashburnf72a04b2015-11-25 17:55:49 -0700578 return res;
579}
580
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -0600581// This is the instance chain terminator function for CreateWin32SurfaceKHR
Mark Young0ad83132016-06-30 13:02:42 -0600582VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWin32SurfaceKHR(
583 VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
584 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Mark Young16573c72016-06-28 10:52:43 -0600585 VkResult vkRes = VK_SUCCESS;
Ian Elliott2b8965a2016-03-24 13:59:22 -0600586 // First, check to ensure the appropriate extension was enabled:
Ian Elliottdb4300a2015-11-23 10:17:23 -0700587 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott2b8965a2016-03-24 13:59:22 -0600588 if (!ptr_instance->wsi_win32_surface_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -0600589 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
590 "VK_KHR_win32_surface extension not enabled. "
591 "vkCreateWin32SurfaceKHR not executed!\n");
Mark Young16573c72016-06-28 10:52:43 -0600592 vkRes = VK_ERROR_EXTENSION_NOT_PRESENT;
593 goto out;
Ian Elliott2b8965a2016-03-24 13:59:22 -0600594 }
595
596 // Next, if so, proceed with the implementation of this function:
Mark Young16573c72016-06-28 10:52:43 -0600597 VkIcdSurface *pIcdSurface = loader_instance_heap_alloc(
598 ptr_instance, sizeof(VkIcdSurface), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
Ian Elliott2c05e222015-11-19 13:14:05 -0700599 if (pIcdSurface == NULL) {
Mark Young16573c72016-06-28 10:52:43 -0600600 vkRes = VK_ERROR_OUT_OF_HOST_MEMORY;
601 goto out;
Ian Elliott2c05e222015-11-19 13:14:05 -0700602 }
603
Mark Young16573c72016-06-28 10:52:43 -0600604 pIcdSurface->win_surf.base.platform = VK_ICD_WSI_PLATFORM_WIN32;
605 pIcdSurface->win_surf.hinstance = pCreateInfo->hinstance;
606 pIcdSurface->win_surf.hwnd = pCreateInfo->hwnd;
Ian Elliott2c05e222015-11-19 13:14:05 -0700607
Mark Young16573c72016-06-28 10:52:43 -0600608 // Setup the new sizes and offsets so we can grow the structures in the
609 // future withouth having problems
610 pIcdSurface->base_size = sizeof(pIcdSurface->win_surf.base);
611 pIcdSurface->platform_size = sizeof(pIcdSurface->win_surf);
612 pIcdSurface->non_platform_offset = (uint32_t)(
613 (uint8_t *)(&pIcdSurface->base_size) - (uint8_t *)pIcdSurface);
614 pIcdSurface->entire_size = sizeof(VkIcdSurface);
Ian Elliott2c05e222015-11-19 13:14:05 -0700615
Mark Young16573c72016-06-28 10:52:43 -0600616 pIcdSurface->real_icd_surfaces = loader_instance_heap_alloc(
617 ptr_instance, sizeof(VkSurfaceKHR) * ptr_instance->total_icd_count,
618 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
619 if (pIcdSurface == NULL) {
620 vkRes = VK_ERROR_OUT_OF_HOST_MEMORY;
621 goto out;
622 }
623 memset(pIcdSurface->real_icd_surfaces, 0,
624 sizeof(VkSurfaceKHR) * ptr_instance->total_icd_count);
625
626 // Loop through each ICD and determine if they need to create a surface
627 for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
628 if (ptr_instance->icd_libs.list[i].interface_version >=
629 ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
630 struct loader_icd *icd = &ptr_instance->icds[i];
631 if (NULL != icd->CreateWin32SurfaceKHR) {
632 vkRes = icd->CreateWin32SurfaceKHR(
Piers Daniellf9262be2016-09-14 11:24:36 -0600633 icd->instance, pCreateInfo, pAllocator,
Mark Young16573c72016-06-28 10:52:43 -0600634 &pIcdSurface->real_icd_surfaces[i]);
635 if (VK_SUCCESS != vkRes) {
636 goto out;
637 }
638 }
639 }
640 }
641
642 *pSurface = (VkSurfaceKHR)(pIcdSurface);
643
644out:
645
646 if (VK_SUCCESS != vkRes && NULL != pIcdSurface) {
647 if (NULL != pIcdSurface->real_icd_surfaces) {
648 for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
649 struct loader_icd *icd = &ptr_instance->icds[i];
650 if (NULL != pIcdSurface->real_icd_surfaces[i] &&
651 NULL != icd->DestroySurfaceKHR) {
652 icd->DestroySurfaceKHR(
Piers Daniellf9262be2016-09-14 11:24:36 -0600653 icd->instance, pIcdSurface->real_icd_surfaces[i], pAllocator);
Mark Young16573c72016-06-28 10:52:43 -0600654 }
655 }
656 loader_instance_heap_free(ptr_instance, pIcdSurface->real_icd_surfaces);
657 }
658 loader_instance_heap_free(ptr_instance, pIcdSurface);
659 }
660
661 return vkRes;
Ian Elliott2c05e222015-11-19 13:14:05 -0700662}
Ian Elliott919fa302015-11-24 15:39:10 -0700663
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -0600664// This is the trampoline entrypoint for
665// GetPhysicalDeviceWin32PresentationSupportKHR
Jon Ashburn23d36b12016-02-02 17:47:28 -0700666LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
667vkGetPhysicalDeviceWin32PresentationSupportKHR(VkPhysicalDevice physicalDevice,
668 uint32_t queueFamilyIndex) {
Jon Ashburn014438f2016-03-01 19:51:07 -0700669 VkPhysicalDevice unwrapped_phys_dev =
670 loader_unwrap_physical_device(physicalDevice);
Ian Elliott919fa302015-11-24 15:39:10 -0700671 const VkLayerInstanceDispatchTable *disp;
672 disp = loader_get_instance_dispatch(physicalDevice);
673 VkBool32 res = disp->GetPhysicalDeviceWin32PresentationSupportKHR(
Jon Ashburn014438f2016-03-01 19:51:07 -0700674 unwrapped_phys_dev, queueFamilyIndex);
Ian Elliott919fa302015-11-24 15:39:10 -0700675 return res;
676}
677
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -0600678// This is the instance chain terminator function for
679// GetPhysicalDeviceWin32PresentationSupportKHR
Jon Ashburn23d36b12016-02-02 17:47:28 -0700680VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburn1530c342016-02-26 13:14:27 -0700681terminator_GetPhysicalDeviceWin32PresentationSupportKHR(
Jon Ashburn23d36b12016-02-02 17:47:28 -0700682 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex) {
Ian Elliott2b8965a2016-03-24 13:59:22 -0600683 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn23d36b12016-02-02 17:47:28 -0700684 struct loader_physical_device *phys_dev =
685 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -0600686 struct loader_instance *ptr_instance =
687 (struct loader_instance *)phys_dev->this_icd->this_instance;
688 if (!ptr_instance->wsi_win32_surface_enabled) {
Jon Ashburncc407a22016-04-15 09:25:03 -0600689 loader_log(
690 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
691 "VK_KHR_win32_surface extension not enabled. "
692 "vkGetPhysicalDeviceWin32PresentationSupportKHR not executed!\n");
Ian Elliott2b8965a2016-03-24 13:59:22 -0600693 return VK_SUCCESS;
694 }
695
696 // Next, if so, proceed with the implementation of this function:
Ian Elliott919fa302015-11-24 15:39:10 -0700697 struct loader_icd *icd = phys_dev->this_icd;
698
Jon Ashburn23d36b12016-02-02 17:47:28 -0700699 assert(icd->GetPhysicalDeviceWin32PresentationSupportKHR &&
700 "loader: null GetPhysicalDeviceWin32PresentationSupportKHR ICD "
701 "pointer");
Ian Elliott919fa302015-11-24 15:39:10 -0700702
703 return icd->GetPhysicalDeviceWin32PresentationSupportKHR(phys_dev->phys_dev,
Jon Ashburn23d36b12016-02-02 17:47:28 -0700704 queueFamilyIndex);
Ian Elliott919fa302015-11-24 15:39:10 -0700705}
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -0700706#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliott2c05e222015-11-19 13:14:05 -0700707
708#ifdef VK_USE_PLATFORM_MIR_KHR
709
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -0600710// Functions for the VK_KHR_mir_surface extension:
Ian Elliott2c05e222015-11-19 13:14:05 -0700711
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -0600712// This is the trampoline entrypoint for CreateMirSurfaceKHR
Mark Young0ad83132016-06-30 13:02:42 -0600713LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateMirSurfaceKHR(
714 VkInstance instance, const VkMirSurfaceCreateInfoKHR *pCreateInfo,
715 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburnf72a04b2015-11-25 17:55:49 -0700716 const VkLayerInstanceDispatchTable *disp;
717 disp = loader_get_instance_dispatch(instance);
718 VkResult res;
719
Jon Ashburn23d36b12016-02-02 17:47:28 -0700720 res =
721 disp->CreateMirSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
Jon Ashburnf72a04b2015-11-25 17:55:49 -0700722 return res;
723}
724
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -0600725// This is the instance chain terminator function for CreateMirSurfaceKHR
Mark Young0ad83132016-06-30 13:02:42 -0600726VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateMirSurfaceKHR(
727 VkInstance instance, const VkMirSurfaceCreateInfoKHR *pCreateInfo,
728 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Mark Young16573c72016-06-28 10:52:43 -0600729 VkResult vkRes = VK_SUCCESS;
Ian Elliott2b8965a2016-03-24 13:59:22 -0600730 // First, check to ensure the appropriate extension was enabled:
Ian Elliottdb4300a2015-11-23 10:17:23 -0700731 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott2b8965a2016-03-24 13:59:22 -0600732 if (!ptr_instance->wsi_mir_surface_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -0600733 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
734 "VK_KHR_mir_surface extension not enabled. "
735 "vkCreateMirSurfaceKHR not executed!\n");
Mark Young16573c72016-06-28 10:52:43 -0600736 vkRes = VK_ERROR_EXTENSION_NOT_PRESENT;
737 goto out;
Ian Elliott2b8965a2016-03-24 13:59:22 -0600738 }
739
740 // Next, if so, proceed with the implementation of this function:
Mark Young16573c72016-06-28 10:52:43 -0600741 VkIcdSurface *pIcdSurface = loader_instance_heap_alloc(
742 ptr_instance, sizeof(VkIcdSurface), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
Ian Elliott2c05e222015-11-19 13:14:05 -0700743 if (pIcdSurface == NULL) {
Mark Young16573c72016-06-28 10:52:43 -0600744 vkRes = VK_ERROR_OUT_OF_HOST_MEMORY;
745 goto out;
Ian Elliott2c05e222015-11-19 13:14:05 -0700746 }
747
Mark Young16573c72016-06-28 10:52:43 -0600748 pIcdSurface->mir_surf.base.platform = VK_ICD_WSI_PLATFORM_MIR;
749 pIcdSurface->mir_surf.connection = pCreateInfo->connection;
750 pIcdSurface->mir_surf.mirSurface = pCreateInfo->mirSurface;
751
752 // Setup the new sizes and offsets so we can grow the structures in the
753 // future withouth having problems
754 pIcdSurface->base_size = sizeof(pIcdSurface->mir_surf.base);
755 pIcdSurface->platform_size = sizeof(pIcdSurface->mir_surf);
756 pIcdSurface->non_platform_offset = (uint32_t)(
757 (uint8_t *)(&pIcdSurface->base_size) - (uint8_t *)pIcdSurface);
758 pIcdSurface->entire_size = sizeof(VkIcdSurface);
759
760 pIcdSurface->real_icd_surfaces = loader_instance_heap_alloc(
761 ptr_instance, sizeof(VkSurfaceKHR) * ptr_instance->total_icd_count,
762 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
763 if (pIcdSurface == NULL) {
764 vkRes = VK_ERROR_OUT_OF_HOST_MEMORY;
765 goto out;
766 }
767 memset(pIcdSurface->real_icd_surfaces, 0,
768 sizeof(VkSurfaceKHR) * ptr_instance->total_icd_count);
769
770 // Loop through each ICD and determine if they need to create a surface
771 for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
772 if (ptr_instance->icd_libs.list[i].interface_version >=
773 ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
774 struct loader_icd *icd = &ptr_instance->icds[i];
775 if (NULL != icd->CreateMirSurfaceKHR) {
776 vkRes = icd->CreateMirSurfaceKHR(
Piers Daniellf9262be2016-09-14 11:24:36 -0600777 icd->instance, pCreateInfo, pAllocator,
Mark Young16573c72016-06-28 10:52:43 -0600778 &pIcdSurface->real_icd_surfaces[i]);
779 if (VK_SUCCESS != vkRes) {
780 goto out;
781 }
782 }
783 }
784 }
Ian Elliott2c05e222015-11-19 13:14:05 -0700785
Jon Ashburn23d36b12016-02-02 17:47:28 -0700786 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliott2c05e222015-11-19 13:14:05 -0700787
Mark Young16573c72016-06-28 10:52:43 -0600788out:
789
790 if (VK_SUCCESS != vkRes && NULL != pIcdSurface) {
791 if (NULL != pIcdSurface->real_icd_surfaces) {
792 for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
793 struct loader_icd *icd = &ptr_instance->icds[i];
794 if (NULL != pIcdSurface->real_icd_surfaces[i] &&
795 NULL != icd->DestroySurfaceKHR) {
796 icd->DestroySurfaceKHR(
Piers Daniellf9262be2016-09-14 11:24:36 -0600797 icd->instance, pIcdSurface->real_icd_surfaces[i], pAllocator);
Mark Young16573c72016-06-28 10:52:43 -0600798 }
799 }
800 loader_instance_heap_free(ptr_instance, pIcdSurface->real_icd_surfaces);
801 }
802 loader_instance_heap_free(ptr_instance, pIcdSurface);
803 }
804
805 return vkRes;
Ian Elliott2c05e222015-11-19 13:14:05 -0700806}
Ian Elliott919fa302015-11-24 15:39:10 -0700807
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -0600808// This is the trampoline entrypoint for
809// GetPhysicalDeviceMirPresentationSupportKHR
Jon Ashburn23d36b12016-02-02 17:47:28 -0700810LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
811vkGetPhysicalDeviceMirPresentationSupportKHR(VkPhysicalDevice physicalDevice,
812 uint32_t queueFamilyIndex,
813 MirConnection *connection) {
Jon Ashburn014438f2016-03-01 19:51:07 -0700814 VkPhysicalDevice unwrapped_phys_dev =
815 loader_unwrap_physical_device(physicalDevice);
Ian Elliott919fa302015-11-24 15:39:10 -0700816 const VkLayerInstanceDispatchTable *disp;
817 disp = loader_get_instance_dispatch(physicalDevice);
818 VkBool32 res = disp->GetPhysicalDeviceMirPresentationSupportKHR(
Jon Ashburn014438f2016-03-01 19:51:07 -0700819 unwrapped_phys_dev, queueFamilyIndex, connection);
Ian Elliott919fa302015-11-24 15:39:10 -0700820 return res;
821}
822
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -0600823// This is the instance chain terminator function for
824// GetPhysicalDeviceMirPresentationSupportKHR
Jon Ashburn23d36b12016-02-02 17:47:28 -0700825VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburn1530c342016-02-26 13:14:27 -0700826terminator_GetPhysicalDeviceMirPresentationSupportKHR(
Jon Ashburn23d36b12016-02-02 17:47:28 -0700827 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
828 MirConnection *connection) {
Ian Elliott2b8965a2016-03-24 13:59:22 -0600829 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn23d36b12016-02-02 17:47:28 -0700830 struct loader_physical_device *phys_dev =
831 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -0600832 struct loader_instance *ptr_instance =
833 (struct loader_instance *)phys_dev->this_icd->this_instance;
834 if (!ptr_instance->wsi_mir_surface_enabled) {
Jon Ashburncc407a22016-04-15 09:25:03 -0600835 loader_log(
836 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
837 "VK_KHR_mir_surface extension not enabled. "
838 "vkGetPhysicalDeviceMirPresentationSupportKHR not executed!\n");
Ian Elliott2b8965a2016-03-24 13:59:22 -0600839 return VK_SUCCESS;
840 }
841
842 // Next, if so, proceed with the implementation of this function:
Ian Elliott919fa302015-11-24 15:39:10 -0700843 struct loader_icd *icd = phys_dev->this_icd;
844
Jon Ashburn23d36b12016-02-02 17:47:28 -0700845 assert(
846 icd->GetPhysicalDeviceMirPresentationSupportKHR &&
847 "loader: null GetPhysicalDeviceMirPresentationSupportKHR ICD pointer");
Ian Elliott919fa302015-11-24 15:39:10 -0700848
Jon Ashburn23d36b12016-02-02 17:47:28 -0700849 return icd->GetPhysicalDeviceMirPresentationSupportKHR(
850 phys_dev->phys_dev, queueFamilyIndex, connection);
Ian Elliott919fa302015-11-24 15:39:10 -0700851}
Ian Elliott2c05e222015-11-19 13:14:05 -0700852#endif // VK_USE_PLATFORM_MIR_KHR
853
854#ifdef VK_USE_PLATFORM_WAYLAND_KHR
855
Mark Young16573c72016-06-28 10:52:43 -0600856/*
857 * This is the trampoline entrypoint
858 * for CreateWaylandSurfaceKHR
859 */
860LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateWaylandSurfaceKHR(
861 VkInstance instance, const VkWaylandSurfaceCreateInfoKHR *pCreateInfo,
862 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburnf72a04b2015-11-25 17:55:49 -0700863 const VkLayerInstanceDispatchTable *disp;
864 disp = loader_get_instance_dispatch(instance);
865 VkResult res;
866
Jon Ashburn23d36b12016-02-02 17:47:28 -0700867 res = disp->CreateWaylandSurfaceKHR(instance, pCreateInfo, pAllocator,
868 pSurface);
Jon Ashburnf72a04b2015-11-25 17:55:49 -0700869 return res;
870}
871
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -0600872// This is the instance chain terminator function for CreateWaylandSurfaceKHR
Mark Young0ad83132016-06-30 13:02:42 -0600873VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWaylandSurfaceKHR(
Jon Ashburn1530c342016-02-26 13:14:27 -0700874 VkInstance instance, const VkWaylandSurfaceCreateInfoKHR *pCreateInfo,
875 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Mark Young16573c72016-06-28 10:52:43 -0600876 VkResult vkRes = VK_SUCCESS;
Ian Elliott2b8965a2016-03-24 13:59:22 -0600877 // First, check to ensure the appropriate extension was enabled:
Ian Elliottdb4300a2015-11-23 10:17:23 -0700878 struct loader_instance *ptr_instance = loader_get_instance(instance);
Jon Ashburnd76b51c2016-03-24 17:26:59 -0600879 if (!ptr_instance->wsi_wayland_surface_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -0600880 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
881 "VK_KHR_wayland_surface extension not enabled. "
882 "vkCreateWaylandSurfaceKHR not executed!\n");
Mark Young16573c72016-06-28 10:52:43 -0600883 vkRes = VK_ERROR_EXTENSION_NOT_PRESENT;
884 goto out;
Ian Elliott2b8965a2016-03-24 13:59:22 -0600885 }
886
887 // Next, if so, proceed with the implementation of this function:
Mark Young16573c72016-06-28 10:52:43 -0600888 VkIcdSurface *pIcdSurface = loader_instance_heap_alloc(
889 ptr_instance, sizeof(VkIcdSurface), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
Ian Elliott2c05e222015-11-19 13:14:05 -0700890 if (pIcdSurface == NULL) {
Mark Young16573c72016-06-28 10:52:43 -0600891 vkRes = VK_ERROR_OUT_OF_HOST_MEMORY;
892 goto out;
Ian Elliott2c05e222015-11-19 13:14:05 -0700893 }
894
Mark Young16573c72016-06-28 10:52:43 -0600895 pIcdSurface->wayland_surf.base.platform = VK_ICD_WSI_PLATFORM_WAYLAND;
896 pIcdSurface->wayland_surf.display = pCreateInfo->display;
897 pIcdSurface->wayland_surf.surface = pCreateInfo->surface;
898
899 // Setup the new sizes and offsets so we can grow the structures in the
900 // future withouth having problems
901 pIcdSurface->base_size = sizeof(pIcdSurface->wayland_surf.base);
902 pIcdSurface->platform_size = sizeof(pIcdSurface->wayland_surf);
903 pIcdSurface->non_platform_offset = (uint32_t)(
904 (uint8_t *)(&pIcdSurface->base_size) - (uint8_t *)pIcdSurface);
905 pIcdSurface->entire_size = sizeof(VkIcdSurface);
906
907 pIcdSurface->real_icd_surfaces = loader_instance_heap_alloc(
908 ptr_instance, sizeof(VkSurfaceKHR) * ptr_instance->total_icd_count,
909 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
910 if (pIcdSurface == NULL) {
911 vkRes = VK_ERROR_OUT_OF_HOST_MEMORY;
912 goto out;
913 }
914 memset(pIcdSurface->real_icd_surfaces, 0,
915 sizeof(VkSurfaceKHR) * ptr_instance->total_icd_count);
916
917 // Loop through each ICD and determine if they need to create a surface
918 for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
919 if (ptr_instance->icd_libs.list[i].interface_version >=
920 ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
921 struct loader_icd *icd = &ptr_instance->icds[i];
922 if (NULL != icd->CreateWaylandSurfaceKHR) {
923 vkRes = icd->CreateWaylandSurfaceKHR(
Piers Daniellf9262be2016-09-14 11:24:36 -0600924 icd->instance, pCreateInfo, pAllocator,
Mark Young16573c72016-06-28 10:52:43 -0600925 &pIcdSurface->real_icd_surfaces[i]);
926 if (VK_SUCCESS != vkRes) {
927 goto out;
928 }
929 }
930 }
931 }
Ian Elliott2c05e222015-11-19 13:14:05 -0700932
Jon Ashburn23d36b12016-02-02 17:47:28 -0700933 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliott2c05e222015-11-19 13:14:05 -0700934
Mark Young16573c72016-06-28 10:52:43 -0600935out:
936
937 if (VK_SUCCESS != vkRes && NULL != pIcdSurface) {
938 if (NULL != pIcdSurface->real_icd_surfaces) {
939 for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
940 struct loader_icd *icd = &ptr_instance->icds[i];
941 if (NULL != pIcdSurface->real_icd_surfaces[i] &&
942 NULL != icd->DestroySurfaceKHR) {
943 icd->DestroySurfaceKHR(
Piers Daniellf9262be2016-09-14 11:24:36 -0600944 icd->instance, pIcdSurface->real_icd_surfaces[i], pAllocator);
Mark Young16573c72016-06-28 10:52:43 -0600945 }
946 }
947 loader_instance_heap_free(ptr_instance, pIcdSurface->real_icd_surfaces);
948 }
949 loader_instance_heap_free(ptr_instance, pIcdSurface);
950 }
951
952 return vkRes;
Ian Elliott2c05e222015-11-19 13:14:05 -0700953}
Ian Elliott919fa302015-11-24 15:39:10 -0700954
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -0600955
956// This is the trampoline entrypoint for
957// GetPhysicalDeviceWaylandPresentationSupportKHR
Jon Ashburn23d36b12016-02-02 17:47:28 -0700958LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
959vkGetPhysicalDeviceWaylandPresentationSupportKHR(
960 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
961 struct wl_display *display) {
Jon Ashburn014438f2016-03-01 19:51:07 -0700962 VkPhysicalDevice unwrapped_phys_dev =
963 loader_unwrap_physical_device(physicalDevice);
Ian Elliott919fa302015-11-24 15:39:10 -0700964 const VkLayerInstanceDispatchTable *disp;
965 disp = loader_get_instance_dispatch(physicalDevice);
966 VkBool32 res = disp->GetPhysicalDeviceWaylandPresentationSupportKHR(
Jon Ashburn014438f2016-03-01 19:51:07 -0700967 unwrapped_phys_dev, queueFamilyIndex, display);
Ian Elliott919fa302015-11-24 15:39:10 -0700968 return res;
969}
970
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -0600971// This is the instance chain terminator function for
972// GetPhysicalDeviceWaylandPresentationSupportKHR
Jon Ashburn23d36b12016-02-02 17:47:28 -0700973VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburn1530c342016-02-26 13:14:27 -0700974terminator_GetPhysicalDeviceWaylandPresentationSupportKHR(
Jon Ashburn23d36b12016-02-02 17:47:28 -0700975 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
976 struct wl_display *display) {
Ian Elliott2b8965a2016-03-24 13:59:22 -0600977 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn23d36b12016-02-02 17:47:28 -0700978 struct loader_physical_device *phys_dev =
979 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -0600980 struct loader_instance *ptr_instance =
981 (struct loader_instance *)phys_dev->this_icd->this_instance;
Jon Ashburnd76b51c2016-03-24 17:26:59 -0600982 if (!ptr_instance->wsi_wayland_surface_enabled) {
Jon Ashburncc407a22016-04-15 09:25:03 -0600983 loader_log(
984 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
985 "VK_KHR_wayland_surface extension not enabled. "
986 "vkGetPhysicalDeviceWaylandPresentationSupportKHR not executed!\n");
Ian Elliott2b8965a2016-03-24 13:59:22 -0600987 return VK_SUCCESS;
988 }
989
990 // Next, if so, proceed with the implementation of this function:
Ian Elliott919fa302015-11-24 15:39:10 -0700991 struct loader_icd *icd = phys_dev->this_icd;
992
Jon Ashburn23d36b12016-02-02 17:47:28 -0700993 assert(icd->GetPhysicalDeviceWaylandPresentationSupportKHR &&
994 "loader: null GetPhysicalDeviceWaylandPresentationSupportKHR ICD "
995 "pointer");
Ian Elliott919fa302015-11-24 15:39:10 -0700996
Jon Ashburn23d36b12016-02-02 17:47:28 -0700997 return icd->GetPhysicalDeviceWaylandPresentationSupportKHR(
998 phys_dev->phys_dev, queueFamilyIndex, display);
Ian Elliott919fa302015-11-24 15:39:10 -0700999}
Ian Elliott2c05e222015-11-19 13:14:05 -07001000#endif // VK_USE_PLATFORM_WAYLAND_KHR
1001
1002#ifdef VK_USE_PLATFORM_XCB_KHR
1003
Ian Elliott2c05e222015-11-19 13:14:05 -07001004
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -06001005// Functions for the VK_KHR_xcb_surface extension:
1006
1007// This is the trampoline entrypoint for CreateXcbSurfaceKHR
Mark Young0ad83132016-06-30 13:02:42 -06001008LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXcbSurfaceKHR(
1009 VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo,
1010 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburnf72a04b2015-11-25 17:55:49 -07001011 const VkLayerInstanceDispatchTable *disp;
1012 disp = loader_get_instance_dispatch(instance);
1013 VkResult res;
1014
Jon Ashburn23d36b12016-02-02 17:47:28 -07001015 res =
1016 disp->CreateXcbSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
Jon Ashburnf72a04b2015-11-25 17:55:49 -07001017 return res;
1018}
1019
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -06001020// This is the instance chain terminator function for CreateXcbSurfaceKHR
Mark Young0ad83132016-06-30 13:02:42 -06001021VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXcbSurfaceKHR(
1022 VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo,
1023 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Mark Young16573c72016-06-28 10:52:43 -06001024 VkResult vkRes = VK_SUCCESS;
Ian Elliott2b8965a2016-03-24 13:59:22 -06001025 // First, check to ensure the appropriate extension was enabled:
Ian Elliottdb4300a2015-11-23 10:17:23 -07001026 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott2b8965a2016-03-24 13:59:22 -06001027 if (!ptr_instance->wsi_xcb_surface_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -06001028 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1029 "VK_KHR_xcb_surface extension not enabled. "
1030 "vkCreateXcbSurfaceKHR not executed!\n");
Mark Young16573c72016-06-28 10:52:43 -06001031 vkRes = VK_ERROR_EXTENSION_NOT_PRESENT;
1032 goto out;
Ian Elliott2b8965a2016-03-24 13:59:22 -06001033 }
1034
1035 // Next, if so, proceed with the implementation of this function:
Mark Young16573c72016-06-28 10:52:43 -06001036 VkIcdSurface *pIcdSurface = loader_instance_heap_alloc(
1037 ptr_instance, sizeof(VkIcdSurface), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
Ian Elliott2c05e222015-11-19 13:14:05 -07001038 if (pIcdSurface == NULL) {
Mark Young16573c72016-06-28 10:52:43 -06001039 vkRes = VK_ERROR_OUT_OF_HOST_MEMORY;
1040 goto out;
Ian Elliott2c05e222015-11-19 13:14:05 -07001041 }
1042
Mark Young16573c72016-06-28 10:52:43 -06001043 pIcdSurface->xcb_surf.base.platform = VK_ICD_WSI_PLATFORM_XCB;
1044 pIcdSurface->xcb_surf.connection = pCreateInfo->connection;
1045 pIcdSurface->xcb_surf.window = pCreateInfo->window;
1046
1047 // Setup the new sizes and offsets so we can grow the structures in the
1048 // future withouth having problems
1049 pIcdSurface->base_size = sizeof(pIcdSurface->xcb_surf.base);
1050 pIcdSurface->platform_size = sizeof(pIcdSurface->xcb_surf);
1051 pIcdSurface->non_platform_offset = (uint32_t)(
1052 (uint8_t *)(&pIcdSurface->base_size) - (uint8_t *)pIcdSurface);
1053 pIcdSurface->entire_size = sizeof(VkIcdSurface);
1054
1055 pIcdSurface->real_icd_surfaces = loader_instance_heap_alloc(
1056 ptr_instance, sizeof(VkSurfaceKHR) * ptr_instance->total_icd_count,
1057 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
1058 if (pIcdSurface == NULL) {
1059 vkRes = VK_ERROR_OUT_OF_HOST_MEMORY;
1060 goto out;
1061 }
1062 memset(pIcdSurface->real_icd_surfaces, 0,
1063 sizeof(VkSurfaceKHR) * ptr_instance->total_icd_count);
1064
1065 // Loop through each ICD and determine if they need to create a surface
1066 for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
1067 if (ptr_instance->icd_libs.list[i].interface_version >=
1068 ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
1069 struct loader_icd *icd = &ptr_instance->icds[i];
1070 if (NULL != icd->CreateXcbSurfaceKHR) {
1071 vkRes = icd->CreateXcbSurfaceKHR(
Piers Daniellf9262be2016-09-14 11:24:36 -06001072 icd->instance, pCreateInfo, pAllocator,
Mark Young16573c72016-06-28 10:52:43 -06001073 &pIcdSurface->real_icd_surfaces[i]);
1074 if (VK_SUCCESS != vkRes) {
1075 goto out;
1076 }
1077 }
1078 }
1079 }
Ian Elliott2c05e222015-11-19 13:14:05 -07001080
Jon Ashburn23d36b12016-02-02 17:47:28 -07001081 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliott2c05e222015-11-19 13:14:05 -07001082
Mark Young16573c72016-06-28 10:52:43 -06001083out:
1084
1085 if (VK_SUCCESS != vkRes && NULL != pIcdSurface) {
1086 if (NULL != pIcdSurface->real_icd_surfaces) {
1087 for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
1088 struct loader_icd *icd = &ptr_instance->icds[i];
1089 if (NULL != pIcdSurface->real_icd_surfaces[i] &&
1090 NULL != icd->DestroySurfaceKHR) {
1091 icd->DestroySurfaceKHR(
Piers Daniellf9262be2016-09-14 11:24:36 -06001092 icd->instance, pIcdSurface->real_icd_surfaces[i], pAllocator);
Mark Young16573c72016-06-28 10:52:43 -06001093 }
1094 }
1095 loader_instance_heap_free(ptr_instance, pIcdSurface->real_icd_surfaces);
1096 }
1097 loader_instance_heap_free(ptr_instance, pIcdSurface);
1098 }
1099
1100 return vkRes;
Ian Elliott2c05e222015-11-19 13:14:05 -07001101}
Ian Elliott919fa302015-11-24 15:39:10 -07001102
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -06001103// This is the trampoline entrypoint for
1104// GetPhysicalDeviceXcbPresentationSupportKHR
Jon Ashburn23d36b12016-02-02 17:47:28 -07001105LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
1106vkGetPhysicalDeviceXcbPresentationSupportKHR(VkPhysicalDevice physicalDevice,
1107 uint32_t queueFamilyIndex,
1108 xcb_connection_t *connection,
1109 xcb_visualid_t visual_id) {
Jon Ashburn014438f2016-03-01 19:51:07 -07001110 VkPhysicalDevice unwrapped_phys_dev =
1111 loader_unwrap_physical_device(physicalDevice);
Ian Elliott919fa302015-11-24 15:39:10 -07001112 const VkLayerInstanceDispatchTable *disp;
1113 disp = loader_get_instance_dispatch(physicalDevice);
1114 VkBool32 res = disp->GetPhysicalDeviceXcbPresentationSupportKHR(
Jon Ashburn014438f2016-03-01 19:51:07 -07001115 unwrapped_phys_dev, queueFamilyIndex, connection, visual_id);
Ian Elliott919fa302015-11-24 15:39:10 -07001116 return res;
1117}
1118
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -06001119// This is the instance chain terminator function for
1120// GetPhysicalDeviceXcbPresentationSupportKHR
Jon Ashburn23d36b12016-02-02 17:47:28 -07001121VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburn1530c342016-02-26 13:14:27 -07001122terminator_GetPhysicalDeviceXcbPresentationSupportKHR(
Jon Ashburn23d36b12016-02-02 17:47:28 -07001123 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
1124 xcb_connection_t *connection, xcb_visualid_t visual_id) {
Ian Elliott2b8965a2016-03-24 13:59:22 -06001125 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn23d36b12016-02-02 17:47:28 -07001126 struct loader_physical_device *phys_dev =
1127 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -06001128 struct loader_instance *ptr_instance =
1129 (struct loader_instance *)phys_dev->this_icd->this_instance;
1130 if (!ptr_instance->wsi_xcb_surface_enabled) {
Jon Ashburncc407a22016-04-15 09:25:03 -06001131 loader_log(
1132 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1133 "VK_KHR_xcb_surface extension not enabled. "
1134 "vkGetPhysicalDeviceXcbPresentationSupportKHR not executed!\n");
Ian Elliott2b8965a2016-03-24 13:59:22 -06001135 return VK_SUCCESS;
1136 }
1137
1138 // Next, if so, proceed with the implementation of this function:
Ian Elliott919fa302015-11-24 15:39:10 -07001139 struct loader_icd *icd = phys_dev->this_icd;
1140
Jon Ashburn23d36b12016-02-02 17:47:28 -07001141 assert(
1142 icd->GetPhysicalDeviceXcbPresentationSupportKHR &&
1143 "loader: null GetPhysicalDeviceXcbPresentationSupportKHR ICD pointer");
Ian Elliott919fa302015-11-24 15:39:10 -07001144
Jon Ashburn23d36b12016-02-02 17:47:28 -07001145 return icd->GetPhysicalDeviceXcbPresentationSupportKHR(
1146 phys_dev->phys_dev, queueFamilyIndex, connection, visual_id);
Ian Elliott919fa302015-11-24 15:39:10 -07001147}
Ian Elliott2c05e222015-11-19 13:14:05 -07001148#endif // VK_USE_PLATFORM_XCB_KHR
1149
1150#ifdef VK_USE_PLATFORM_XLIB_KHR
1151
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -06001152// Functions for the VK_KHR_xlib_surface extension:
Ian Elliott2c05e222015-11-19 13:14:05 -07001153
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -06001154// This is the trampoline entrypoint for CreateXlibSurfaceKHR
Mark Young0ad83132016-06-30 13:02:42 -06001155LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR(
1156 VkInstance instance, const VkXlibSurfaceCreateInfoKHR *pCreateInfo,
1157 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburnf72a04b2015-11-25 17:55:49 -07001158 const VkLayerInstanceDispatchTable *disp;
1159 disp = loader_get_instance_dispatch(instance);
1160 VkResult res;
1161
Jon Ashburn23d36b12016-02-02 17:47:28 -07001162 res =
1163 disp->CreateXlibSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
Jon Ashburnf72a04b2015-11-25 17:55:49 -07001164 return res;
1165}
1166
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -06001167// This is the instance chain terminator function for CreateXlibSurfaceKHR
Mark Young0ad83132016-06-30 13:02:42 -06001168VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXlibSurfaceKHR(
1169 VkInstance instance, const VkXlibSurfaceCreateInfoKHR *pCreateInfo,
1170 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Mark Young16573c72016-06-28 10:52:43 -06001171 VkResult vkRes = VK_SUCCESS;
Ian Elliott2b8965a2016-03-24 13:59:22 -06001172 // First, check to ensure the appropriate extension was enabled:
Ian Elliottdb4300a2015-11-23 10:17:23 -07001173 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott2b8965a2016-03-24 13:59:22 -06001174 if (!ptr_instance->wsi_xlib_surface_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -06001175 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1176 "VK_KHR_xlib_surface extension not enabled. "
1177 "vkCreateXlibSurfaceKHR not executed!\n");
Mark Young16573c72016-06-28 10:52:43 -06001178 vkRes = VK_ERROR_EXTENSION_NOT_PRESENT;
1179 goto out;
Ian Elliott2b8965a2016-03-24 13:59:22 -06001180 }
1181
1182 // Next, if so, proceed with the implementation of this function:
Mark Young16573c72016-06-28 10:52:43 -06001183 VkIcdSurface *pIcdSurface = loader_instance_heap_alloc(
1184 ptr_instance, sizeof(VkIcdSurface), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
Ian Elliott2c05e222015-11-19 13:14:05 -07001185 if (pIcdSurface == NULL) {
Mark Young16573c72016-06-28 10:52:43 -06001186 vkRes = VK_ERROR_OUT_OF_HOST_MEMORY;
1187 goto out;
Ian Elliott2c05e222015-11-19 13:14:05 -07001188 }
1189
Mark Young16573c72016-06-28 10:52:43 -06001190 pIcdSurface->xlib_surf.base.platform = VK_ICD_WSI_PLATFORM_XLIB;
1191 pIcdSurface->xlib_surf.dpy = pCreateInfo->dpy;
1192 pIcdSurface->xlib_surf.window = pCreateInfo->window;
1193
1194 // Setup the new sizes and offsets so we can grow the structures in the
1195 // future withouth having problems
1196 pIcdSurface->base_size = sizeof(pIcdSurface->xlib_surf.base);
1197 pIcdSurface->platform_size = sizeof(pIcdSurface->xlib_surf);
1198 pIcdSurface->non_platform_offset = (uint32_t)(
1199 (uint8_t *)(&pIcdSurface->base_size) - (uint8_t *)pIcdSurface);
1200 pIcdSurface->entire_size = sizeof(VkIcdSurface);
1201
1202 pIcdSurface->real_icd_surfaces = loader_instance_heap_alloc(
1203 ptr_instance, sizeof(VkSurfaceKHR) * ptr_instance->total_icd_count,
1204 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
1205 if (pIcdSurface == NULL) {
1206 vkRes = VK_ERROR_OUT_OF_HOST_MEMORY;
1207 goto out;
1208 }
1209 memset(pIcdSurface->real_icd_surfaces, 0,
1210 sizeof(VkSurfaceKHR) * ptr_instance->total_icd_count);
1211
1212 // Loop through each ICD and determine if they need to create a surface
1213 for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
1214 if (ptr_instance->icd_libs.list[i].interface_version >=
1215 ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
1216 struct loader_icd *icd = &ptr_instance->icds[i];
1217 if (NULL != icd->CreateXlibSurfaceKHR) {
1218 vkRes = icd->CreateXlibSurfaceKHR(
Piers Daniellf9262be2016-09-14 11:24:36 -06001219 icd->instance, pCreateInfo, pAllocator,
Mark Young16573c72016-06-28 10:52:43 -06001220 &pIcdSurface->real_icd_surfaces[i]);
1221 if (VK_SUCCESS != vkRes) {
1222 goto out;
1223 }
1224 }
1225 }
1226 }
Ian Elliott2c05e222015-11-19 13:14:05 -07001227
Jon Ashburn23d36b12016-02-02 17:47:28 -07001228 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliott2c05e222015-11-19 13:14:05 -07001229
Mark Young16573c72016-06-28 10:52:43 -06001230out:
1231
1232 if (VK_SUCCESS != vkRes && NULL != pIcdSurface) {
1233 if (NULL != pIcdSurface->real_icd_surfaces) {
1234 for (uint32_t i = 0; i < ptr_instance->total_icd_count; i++) {
1235 struct loader_icd *icd = &ptr_instance->icds[i];
1236 if (NULL != pIcdSurface->real_icd_surfaces[i] &&
1237 NULL != icd->DestroySurfaceKHR) {
1238 icd->DestroySurfaceKHR(
Piers Daniellf9262be2016-09-14 11:24:36 -06001239 icd->instance, pIcdSurface->real_icd_surfaces[i], pAllocator);
Mark Young16573c72016-06-28 10:52:43 -06001240 }
1241 }
1242 loader_instance_heap_free(ptr_instance, pIcdSurface->real_icd_surfaces);
1243 }
1244 loader_instance_heap_free(ptr_instance, pIcdSurface);
1245 }
1246
1247 return vkRes;
Ian Elliott2c05e222015-11-19 13:14:05 -07001248}
Ian Elliott919fa302015-11-24 15:39:10 -07001249
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -06001250// This is the trampoline entrypoint for GetPhysicalDeviceXlibPresentationSupportKHR
Jon Ashburn23d36b12016-02-02 17:47:28 -07001251LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
1252vkGetPhysicalDeviceXlibPresentationSupportKHR(VkPhysicalDevice physicalDevice,
1253 uint32_t queueFamilyIndex,
1254 Display *dpy, VisualID visualID) {
Jon Ashburn014438f2016-03-01 19:51:07 -07001255 VkPhysicalDevice unwrapped_phys_dev =
1256 loader_unwrap_physical_device(physicalDevice);
Ian Elliott919fa302015-11-24 15:39:10 -07001257 const VkLayerInstanceDispatchTable *disp;
1258 disp = loader_get_instance_dispatch(physicalDevice);
1259 VkBool32 res = disp->GetPhysicalDeviceXlibPresentationSupportKHR(
Jon Ashburn014438f2016-03-01 19:51:07 -07001260 unwrapped_phys_dev, queueFamilyIndex, dpy, visualID);
Ian Elliott919fa302015-11-24 15:39:10 -07001261 return res;
1262}
1263
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -06001264// This is the instance chain terminator function for
1265// GetPhysicalDeviceXlibPresentationSupportKHR
Jon Ashburn23d36b12016-02-02 17:47:28 -07001266VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburn1530c342016-02-26 13:14:27 -07001267terminator_GetPhysicalDeviceXlibPresentationSupportKHR(
Jon Ashburn23d36b12016-02-02 17:47:28 -07001268 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, Display *dpy,
1269 VisualID visualID) {
Ian Elliott2b8965a2016-03-24 13:59:22 -06001270 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn23d36b12016-02-02 17:47:28 -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_xlib_surface_enabled) {
Jon Ashburncc407a22016-04-15 09:25:03 -06001276 loader_log(
1277 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1278 "VK_KHR_xlib_surface extension not enabled. "
1279 "vkGetPhysicalDeviceXlibPresentationSupportKHR not executed!\n");
Ian Elliott2b8965a2016-03-24 13:59:22 -06001280 return VK_SUCCESS;
1281 }
1282
1283 // Next, if so, proceed with the implementation of this function:
Ian Elliott919fa302015-11-24 15:39:10 -07001284 struct loader_icd *icd = phys_dev->this_icd;
1285
Jon Ashburn23d36b12016-02-02 17:47:28 -07001286 assert(
1287 icd->GetPhysicalDeviceXlibPresentationSupportKHR &&
1288 "loader: null GetPhysicalDeviceXlibPresentationSupportKHR ICD pointer");
Ian Elliott919fa302015-11-24 15:39:10 -07001289
Jon Ashburn23d36b12016-02-02 17:47:28 -07001290 return icd->GetPhysicalDeviceXlibPresentationSupportKHR(
1291 phys_dev->phys_dev, queueFamilyIndex, dpy, visualID);
Ian Elliott919fa302015-11-24 15:39:10 -07001292}
Ian Elliott2c05e222015-11-19 13:14:05 -07001293#endif // VK_USE_PLATFORM_XLIB_KHR
1294
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -07001295#ifdef VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott2c05e222015-11-19 13:14:05 -07001296
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -07001297
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -06001298// Functions for the VK_KHR_android_surface extension:
1299
1300// This is the trampoline entrypoint for CreateAndroidSurfaceKHR
Mark Young0ad83132016-06-30 13:02:42 -06001301LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateAndroidSurfaceKHR(
1302 VkInstance instance, ANativeWindow *window,
1303 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -07001304 const VkLayerInstanceDispatchTable *disp;
1305 disp = loader_get_instance_dispatch(instance);
1306 VkResult res;
1307
1308 res = disp->CreateAndroidSurfaceKHR(instance, window, pAllocator, pSurface);
1309 return res;
1310}
1311
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -06001312// This is the instance chain terminator function for CreateAndroidSurfaceKHR
Mark Young0ad83132016-06-30 13:02:42 -06001313VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateAndroidSurfaceKHR(
1314 VkInstance instance, Window window, const VkAllocationCallbacks *pAllocator,
1315 VkSurfaceKHR *pSurface) {
Ian Elliott2b8965a2016-03-24 13:59:22 -06001316 // First, check to ensure the appropriate extension was enabled:
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -07001317 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott2b8965a2016-03-24 13:59:22 -06001318 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -06001319 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1320 "VK_KHR_display extension not enabled. "
1321 "vkCreateAndroidSurfaceKHR not executed!\n");
Jeremy Hayes9f1d0b62016-06-14 11:50:02 -06001322 return VK_ERROR_EXTENSION_NOT_PRESENT;
Ian Elliott2b8965a2016-03-24 13:59:22 -06001323 }
1324
1325 // Next, if so, proceed with the implementation of this function:
Mark Young16573c72016-06-28 10:52:43 -06001326 VkIcdSurfaceAndroid *pIcdSurface =
Mark Young0ad83132016-06-30 13:02:42 -06001327 loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceAndroid),
Mark Young16573c72016-06-28 10:52:43 -06001328 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -07001329 if (pIcdSurface == NULL) {
1330 return VK_ERROR_OUT_OF_HOST_MEMORY;
1331 }
1332
1333 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_ANDROID;
1334 pIcdSurface->dpy = dpy;
1335 pIcdSurface->window = window;
1336
Jon Ashburn23d36b12016-02-02 17:47:28 -07001337 *pSurface = (VkSurfaceKHR)pIcdSurface;
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -07001338
1339 return VK_SUCCESS;
1340}
1341
1342#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott2c05e222015-11-19 13:14:05 -07001343
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -06001344
1345// Functions for the VK_KHR_display instance extension:
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001346LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburncc407a22016-04-15 09:25:03 -06001347vkGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice,
1348 uint32_t *pPropertyCount,
1349 VkDisplayPropertiesKHR *pProperties) {
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001350 VkPhysicalDevice unwrapped_phys_dev =
1351 loader_unwrap_physical_device(physicalDevice);
1352 const VkLayerInstanceDispatchTable *disp;
1353 disp = loader_get_instance_dispatch(physicalDevice);
1354 VkResult res = disp->GetPhysicalDeviceDisplayPropertiesKHR(
1355 unwrapped_phys_dev, pPropertyCount, pProperties);
1356 return res;
1357}
1358
Jon Ashburncc407a22016-04-15 09:25:03 -06001359VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceDisplayPropertiesKHR(
1360 VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
1361 VkDisplayPropertiesKHR *pProperties) {
Ian Elliott2b8965a2016-03-24 13:59:22 -06001362 // First, check to ensure the appropriate extension was enabled:
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001363 struct loader_physical_device *phys_dev =
1364 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -06001365 struct loader_instance *ptr_instance =
1366 (struct loader_instance *)phys_dev->this_icd->this_instance;
1367 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -06001368 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1369 "VK_KHR_display extension not enabled. "
1370 "vkGetPhysicalDeviceDisplayPropertiesKHR not executed!\n");
Ian Elliott2b8965a2016-03-24 13:59:22 -06001371 return VK_SUCCESS;
1372 }
1373
1374 // Next, if so, proceed with the implementation of this function:
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001375 struct loader_icd *icd = phys_dev->this_icd;
1376
Jon Ashburncc407a22016-04-15 09:25:03 -06001377 assert(icd->GetPhysicalDeviceDisplayPropertiesKHR &&
1378 "loader: null GetPhysicalDeviceDisplayPropertiesKHR ICD pointer");
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001379
1380 return icd->GetPhysicalDeviceDisplayPropertiesKHR(
1381 phys_dev->phys_dev, pPropertyCount, pProperties);
1382}
1383
1384LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1385vkGetPhysicalDeviceDisplayPlanePropertiesKHR(
Jon Ashburncc407a22016-04-15 09:25:03 -06001386 VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
1387 VkDisplayPlanePropertiesKHR *pProperties) {
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001388 VkPhysicalDevice unwrapped_phys_dev =
1389 loader_unwrap_physical_device(physicalDevice);
1390 const VkLayerInstanceDispatchTable *disp;
1391 disp = loader_get_instance_dispatch(physicalDevice);
1392 VkResult res = disp->GetPhysicalDeviceDisplayPlanePropertiesKHR(
1393 unwrapped_phys_dev, pPropertyCount, pProperties);
1394 return res;
1395}
1396
1397VKAPI_ATTR VkResult VKAPI_CALL
1398terminator_GetPhysicalDeviceDisplayPlanePropertiesKHR(
Jon Ashburncc407a22016-04-15 09:25:03 -06001399 VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
1400 VkDisplayPlanePropertiesKHR *pProperties) {
Ian Elliott2b8965a2016-03-24 13:59:22 -06001401 // First, check to ensure the appropriate extension was enabled:
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001402 struct loader_physical_device *phys_dev =
1403 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -06001404 struct loader_instance *ptr_instance =
1405 (struct loader_instance *)phys_dev->this_icd->this_instance;
1406 if (!ptr_instance->wsi_display_enabled) {
Jon Ashburncc407a22016-04-15 09:25:03 -06001407 loader_log(
1408 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1409 "VK_KHR_display extension not enabled. "
1410 "vkGetPhysicalDeviceDisplayPlanePropertiesKHR not executed!\n");
Ian Elliott2b8965a2016-03-24 13:59:22 -06001411 return VK_SUCCESS;
1412 }
1413
1414 // Next, if so, proceed with the implementation of this function:
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001415 struct loader_icd *icd = phys_dev->this_icd;
1416
1417 assert(
1418 icd->GetPhysicalDeviceDisplayPlanePropertiesKHR &&
1419 "loader: null GetPhysicalDeviceDisplayPlanePropertiesKHR ICD pointer");
1420
1421 return icd->GetPhysicalDeviceDisplayPlanePropertiesKHR(
1422 phys_dev->phys_dev, pPropertyCount, pProperties);
1423}
1424
1425LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburncc407a22016-04-15 09:25:03 -06001426vkGetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice,
1427 uint32_t planeIndex,
1428 uint32_t *pDisplayCount,
1429 VkDisplayKHR *pDisplays) {
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001430 VkPhysicalDevice unwrapped_phys_dev =
1431 loader_unwrap_physical_device(physicalDevice);
1432 const VkLayerInstanceDispatchTable *disp;
1433 disp = loader_get_instance_dispatch(physicalDevice);
1434 VkResult res = disp->GetDisplayPlaneSupportedDisplaysKHR(
1435 unwrapped_phys_dev, planeIndex, pDisplayCount, pDisplays);
1436 return res;
1437}
1438
Mark Young16573c72016-06-28 10:52:43 -06001439VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayPlaneSupportedDisplaysKHR(
1440 VkPhysicalDevice physicalDevice, uint32_t planeIndex,
1441 uint32_t *pDisplayCount, VkDisplayKHR *pDisplays) {
Ian Elliott2b8965a2016-03-24 13:59:22 -06001442 // First, check to ensure the appropriate extension was enabled:
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001443 struct loader_physical_device *phys_dev =
1444 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -06001445 struct loader_instance *ptr_instance =
1446 (struct loader_instance *)phys_dev->this_icd->this_instance;
1447 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -06001448 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1449 "VK_KHR_display extension not enabled. "
1450 "vkGetDisplayPlaneSupportedDisplaysKHR not executed!\n");
Ian Elliott2b8965a2016-03-24 13:59:22 -06001451 return VK_SUCCESS;
1452 }
1453
1454 // Next, if so, proceed with the implementation of this function:
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001455 struct loader_icd *icd = phys_dev->this_icd;
1456
Jon Ashburncc407a22016-04-15 09:25:03 -06001457 assert(icd->GetDisplayPlaneSupportedDisplaysKHR &&
1458 "loader: null GetDisplayPlaneSupportedDisplaysKHR ICD pointer");
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001459
1460 return icd->GetDisplayPlaneSupportedDisplaysKHR(
1461 phys_dev->phys_dev, planeIndex, pDisplayCount, pDisplays);
1462}
1463
Mark Young16573c72016-06-28 10:52:43 -06001464LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayModePropertiesKHR(
1465 VkPhysicalDevice physicalDevice, VkDisplayKHR display,
1466 uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties) {
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001467 VkPhysicalDevice unwrapped_phys_dev =
1468 loader_unwrap_physical_device(physicalDevice);
1469 const VkLayerInstanceDispatchTable *disp;
1470 disp = loader_get_instance_dispatch(physicalDevice);
1471 VkResult res = disp->GetDisplayModePropertiesKHR(
1472 unwrapped_phys_dev, display, pPropertyCount, pProperties);
1473 return res;
1474}
1475
Jon Ashburncc407a22016-04-15 09:25:03 -06001476VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayModePropertiesKHR(
1477 VkPhysicalDevice physicalDevice, VkDisplayKHR display,
1478 uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties) {
Ian Elliott2b8965a2016-03-24 13:59:22 -06001479 // First, check to ensure the appropriate extension was enabled:
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001480 struct loader_physical_device *phys_dev =
1481 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -06001482 struct loader_instance *ptr_instance =
1483 (struct loader_instance *)phys_dev->this_icd->this_instance;
1484 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -06001485 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1486 "VK_KHR_display extension not enabled. "
1487 "vkGetDisplayModePropertiesKHR not executed!\n");
Ian Elliott2b8965a2016-03-24 13:59:22 -06001488 return VK_SUCCESS;
1489 }
1490
1491 // Next, if so, proceed with the implementation of this function:
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001492 struct loader_icd *icd = phys_dev->this_icd;
1493
Jon Ashburncc407a22016-04-15 09:25:03 -06001494 assert(icd->GetDisplayModePropertiesKHR &&
1495 "loader: null GetDisplayModePropertiesKHR ICD pointer");
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001496
Jon Ashburncc407a22016-04-15 09:25:03 -06001497 return icd->GetDisplayModePropertiesKHR(phys_dev->phys_dev, display,
1498 pPropertyCount, pProperties);
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001499}
1500
Mark Young0ad83132016-06-30 13:02:42 -06001501LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayModeKHR(
1502 VkPhysicalDevice physicalDevice, VkDisplayKHR display,
1503 const VkDisplayModeCreateInfoKHR *pCreateInfo,
1504 const VkAllocationCallbacks *pAllocator, VkDisplayModeKHR *pMode) {
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001505 VkPhysicalDevice unwrapped_phys_dev =
1506 loader_unwrap_physical_device(physicalDevice);
1507 const VkLayerInstanceDispatchTable *disp;
1508 disp = loader_get_instance_dispatch(physicalDevice);
Jon Ashburncc407a22016-04-15 09:25:03 -06001509 VkResult res = disp->CreateDisplayModeKHR(unwrapped_phys_dev, display,
1510 pCreateInfo, pAllocator, pMode);
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001511 return res;
1512}
1513
Mark Young0ad83132016-06-30 13:02:42 -06001514VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayModeKHR(
1515 VkPhysicalDevice physicalDevice, VkDisplayKHR display,
1516 const VkDisplayModeCreateInfoKHR *pCreateInfo,
1517 const VkAllocationCallbacks *pAllocator, VkDisplayModeKHR *pMode) {
Ian Elliott2b8965a2016-03-24 13:59:22 -06001518 // First, check to ensure the appropriate extension was enabled:
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001519 struct loader_physical_device *phys_dev =
1520 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -06001521 struct loader_instance *ptr_instance =
1522 (struct loader_instance *)phys_dev->this_icd->this_instance;
1523 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -06001524 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1525 "VK_KHR_display extension not enabled. "
1526 "vkCreateDisplayModeKHR not executed!\n");
Jeremy Hayes9f1d0b62016-06-14 11:50:02 -06001527 return VK_ERROR_EXTENSION_NOT_PRESENT;
Ian Elliott2b8965a2016-03-24 13:59:22 -06001528 }
1529
1530 // Next, if so, proceed with the implementation of this function:
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001531 struct loader_icd *icd = phys_dev->this_icd;
1532
Jon Ashburncc407a22016-04-15 09:25:03 -06001533 assert(icd->CreateDisplayModeKHR &&
1534 "loader: null CreateDisplayModeKHR ICD pointer");
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001535
Jon Ashburncc407a22016-04-15 09:25:03 -06001536 return icd->CreateDisplayModeKHR(phys_dev->phys_dev, display, pCreateInfo,
1537 pAllocator, pMode);
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001538}
1539
Mark Young16573c72016-06-28 10:52:43 -06001540LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayPlaneCapabilitiesKHR(
1541 VkPhysicalDevice physicalDevice, VkDisplayModeKHR mode, uint32_t planeIndex,
1542 VkDisplayPlaneCapabilitiesKHR *pCapabilities) {
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001543 VkPhysicalDevice unwrapped_phys_dev =
1544 loader_unwrap_physical_device(physicalDevice);
1545 const VkLayerInstanceDispatchTable *disp;
1546 disp = loader_get_instance_dispatch(physicalDevice);
1547 VkResult res = disp->GetDisplayPlaneCapabilitiesKHR(
1548 unwrapped_phys_dev, mode, planeIndex, pCapabilities);
1549 return res;
1550}
1551
Jon Ashburncc407a22016-04-15 09:25:03 -06001552VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayPlaneCapabilitiesKHR(
1553 VkPhysicalDevice physicalDevice, VkDisplayModeKHR mode, uint32_t planeIndex,
1554 VkDisplayPlaneCapabilitiesKHR *pCapabilities) {
Ian Elliott2b8965a2016-03-24 13:59:22 -06001555 // First, check to ensure the appropriate extension was enabled:
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001556 struct loader_physical_device *phys_dev =
1557 (struct loader_physical_device *)physicalDevice;
Ian Elliott2b8965a2016-03-24 13:59:22 -06001558 struct loader_instance *ptr_instance =
1559 (struct loader_instance *)phys_dev->this_icd->this_instance;
1560 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott31f72842016-03-24 15:49:02 -06001561 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1562 "VK_KHR_display extension not enabled. "
1563 "vkGetDisplayPlaneCapabilitiesKHR not executed!\n");
Ian Elliott2b8965a2016-03-24 13:59:22 -06001564 return VK_SUCCESS;
1565 }
1566
1567 // Next, if so, proceed with the implementation of this function:
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001568 struct loader_icd *icd = phys_dev->this_icd;
1569
Jon Ashburncc407a22016-04-15 09:25:03 -06001570 assert(icd->GetDisplayPlaneCapabilitiesKHR &&
1571 "loader: null GetDisplayPlaneCapabilitiesKHR ICD pointer");
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001572
Jon Ashburncc407a22016-04-15 09:25:03 -06001573 return icd->GetDisplayPlaneCapabilitiesKHR(phys_dev->phys_dev, mode,
1574 planeIndex, pCapabilities);
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001575}
1576
Mark Young0ad83132016-06-30 13:02:42 -06001577LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayPlaneSurfaceKHR(
1578 VkInstance instance, const VkDisplaySurfaceCreateInfoKHR *pCreateInfo,
1579 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001580 const VkLayerInstanceDispatchTable *disp;
1581 disp = loader_get_instance_dispatch(instance);
1582 VkResult res;
1583
1584 res = disp->CreateDisplayPlaneSurfaceKHR(instance, pCreateInfo, pAllocator,
1585 pSurface);
1586 return res;
1587}
1588
Jon Ashburncc407a22016-04-15 09:25:03 -06001589VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayPlaneSurfaceKHR(
1590 VkInstance instance, const VkDisplaySurfaceCreateInfoKHR *pCreateInfo,
1591 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001592 struct loader_instance *inst = loader_get_instance(instance);
Mark Young16573c72016-06-28 10:52:43 -06001593 VkIcdSurface *pIcdSurface = NULL;
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001594
Petros Bantolas25d27fe2016-04-14 12:50:42 +01001595 if (!inst->wsi_surface_enabled) {
1596 loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1597 "VK_KHR_surface extension not enabled. "
1598 "vkCreateDisplayPlaneSurfaceKHR not executed!\n");
Jeremy Hayes9f1d0b62016-06-14 11:50:02 -06001599 return VK_ERROR_EXTENSION_NOT_PRESENT;
Petros Bantolas25d27fe2016-04-14 12:50:42 +01001600 }
1601
Mark Young16573c72016-06-28 10:52:43 -06001602 pIcdSurface = loader_instance_heap_alloc(inst, sizeof(VkIcdSurface),
1603 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001604 if (pIcdSurface == NULL) {
1605 return VK_ERROR_OUT_OF_HOST_MEMORY;
1606 }
1607
Mark Young16573c72016-06-28 10:52:43 -06001608 pIcdSurface->display_surf.base.platform = VK_ICD_WSI_PLATFORM_DISPLAY;
1609 pIcdSurface->display_surf.displayMode = pCreateInfo->displayMode;
1610 pIcdSurface->display_surf.planeIndex = pCreateInfo->planeIndex;
1611 pIcdSurface->display_surf.planeStackIndex = pCreateInfo->planeStackIndex;
1612 pIcdSurface->display_surf.transform = pCreateInfo->transform;
1613 pIcdSurface->display_surf.globalAlpha = pCreateInfo->globalAlpha;
1614 pIcdSurface->display_surf.alphaMode = pCreateInfo->alphaMode;
1615 pIcdSurface->display_surf.imageExtent = pCreateInfo->imageExtent;
1616
1617 // Setup the new sizes and offsets so we can grow the structures in the
1618 // future withouth having problems
1619 pIcdSurface->real_icd_surfaces = NULL;
1620 pIcdSurface->base_size = sizeof(pIcdSurface->display_surf.base);
1621 pIcdSurface->platform_size = sizeof(pIcdSurface->display_surf);
1622 pIcdSurface->non_platform_offset = (uint32_t)(
1623 (uint8_t *)(&pIcdSurface->base_size) - (uint8_t *)pIcdSurface);
1624 pIcdSurface->entire_size = sizeof(VkIcdSurface);
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001625
1626 *pSurface = (VkSurfaceKHR)pIcdSurface;
1627
1628 return VK_SUCCESS;
1629}
1630
Mark Young1a867442016-07-01 15:18:27 -06001631// This is the trampoline entrypoint
1632// for CreateSharedSwapchainsKHR
1633LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSharedSwapchainsKHR(
1634 VkDevice device, uint32_t swapchainCount,
1635 const VkSwapchainCreateInfoKHR *pCreateInfos,
1636 const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchains) {
Mark Young5210abc2016-09-08 18:36:32 -06001637 const VkLayerDispatchTable *disp;
1638 disp = loader_get_dispatch(device);
1639 return disp->CreateSharedSwapchainsKHR(device, swapchainCount, pCreateInfos, pAllocator, pSwapchains);
Mark Young1a867442016-07-01 15:18:27 -06001640}
1641
Ian Elliott954fa342015-10-30 15:28:23 -06001642bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance,
Jon Ashburn23d36b12016-02-02 17:47:28 -07001643 const char *name, void **addr) {
Ian Elliott954fa342015-10-30 15:28:23 -06001644 *addr = NULL;
1645
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -06001646 // Functions for the VK_KHR_surface extension:
Ian Elliott2c05e222015-11-19 13:14:05 -07001647 if (!strcmp("vkDestroySurfaceKHR", name)) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001648 *addr = ptr_instance->wsi_surface_enabled ? (void *)vkDestroySurfaceKHR
1649 : NULL;
Ian Elliott2c05e222015-11-19 13:14:05 -07001650 return true;
1651 }
Ian Elliott954fa342015-10-30 15:28:23 -06001652 if (!strcmp("vkGetPhysicalDeviceSurfaceSupportKHR", name)) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001653 *addr = ptr_instance->wsi_surface_enabled
1654 ? (void *)vkGetPhysicalDeviceSurfaceSupportKHR
1655 : NULL;
Ian Elliott954fa342015-10-30 15:28:23 -06001656 return true;
1657 }
Ian Elliott486c5502015-11-19 16:05:09 -07001658 if (!strcmp("vkGetPhysicalDeviceSurfaceCapabilitiesKHR", name)) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001659 *addr = ptr_instance->wsi_surface_enabled
1660 ? (void *)vkGetPhysicalDeviceSurfaceCapabilitiesKHR
1661 : NULL;
Ian Elliott486c5502015-11-19 16:05:09 -07001662 return true;
1663 }
1664 if (!strcmp("vkGetPhysicalDeviceSurfaceFormatsKHR", name)) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001665 *addr = ptr_instance->wsi_surface_enabled
1666 ? (void *)vkGetPhysicalDeviceSurfaceFormatsKHR
1667 : NULL;
Ian Elliott486c5502015-11-19 16:05:09 -07001668 return true;
1669 }
1670 if (!strcmp("vkGetPhysicalDeviceSurfacePresentModesKHR", name)) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001671 *addr = ptr_instance->wsi_surface_enabled
1672 ? (void *)vkGetPhysicalDeviceSurfacePresentModesKHR
1673 : NULL;
Ian Elliott486c5502015-11-19 16:05:09 -07001674 return true;
1675 }
Ian Elliott934d0d52015-11-19 16:39:21 -07001676
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -06001677 // Functions for the VK_KHR_swapchain extension:
1678
1679 // Note: This is a device extension, and its functions are statically
1680 // exported from the loader. Per Khronos decisions, the loader's GIPA
1681 // function will return the trampoline function for such device-extension
1682 // functions, regardless of whether the extension has been enabled.
Ian Elliott934d0d52015-11-19 16:39:21 -07001683 if (!strcmp("vkCreateSwapchainKHR", name)) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001684 *addr = (void *)vkCreateSwapchainKHR;
Ian Elliott934d0d52015-11-19 16:39:21 -07001685 return true;
1686 }
1687 if (!strcmp("vkDestroySwapchainKHR", name)) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001688 *addr = (void *)vkDestroySwapchainKHR;
Ian Elliott934d0d52015-11-19 16:39:21 -07001689 return true;
1690 }
1691 if (!strcmp("vkGetSwapchainImagesKHR", name)) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001692 *addr = (void *)vkGetSwapchainImagesKHR;
Ian Elliott934d0d52015-11-19 16:39:21 -07001693 return true;
1694 }
1695 if (!strcmp("vkAcquireNextImageKHR", name)) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001696 *addr = (void *)vkAcquireNextImageKHR;
Ian Elliott934d0d52015-11-19 16:39:21 -07001697 return true;
1698 }
1699 if (!strcmp("vkQueuePresentKHR", name)) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001700 *addr = (void *)vkQueuePresentKHR;
Ian Elliott934d0d52015-11-19 16:39:21 -07001701 return true;
1702 }
1703
Ian Elliott2c05e222015-11-19 13:14:05 -07001704#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -06001705
1706 // Functions for the VK_KHR_win32_surface extension:
Ian Elliott2c05e222015-11-19 13:14:05 -07001707 if (!strcmp("vkCreateWin32SurfaceKHR", name)) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001708 *addr = ptr_instance->wsi_win32_surface_enabled
1709 ? (void *)vkCreateWin32SurfaceKHR
1710 : NULL;
Ian Elliott2c05e222015-11-19 13:14:05 -07001711 return true;
1712 }
Ian Elliott919fa302015-11-24 15:39:10 -07001713 if (!strcmp("vkGetPhysicalDeviceWin32PresentationSupportKHR", name)) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001714 *addr = ptr_instance->wsi_win32_surface_enabled
1715 ? (void *)vkGetPhysicalDeviceWin32PresentationSupportKHR
1716 : NULL;
Ian Elliott919fa302015-11-24 15:39:10 -07001717 return true;
1718 }
Ian Elliott2c05e222015-11-19 13:14:05 -07001719#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliott2c05e222015-11-19 13:14:05 -07001720#ifdef VK_USE_PLATFORM_MIR_KHR
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -06001721
1722 // Functions for the VK_KHR_mir_surface extension:
Ian Elliott2c05e222015-11-19 13:14:05 -07001723 if (!strcmp("vkCreateMirSurfaceKHR", name)) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001724 *addr = ptr_instance->wsi_mir_surface_enabled
1725 ? (void *)vkCreateMirSurfaceKHR
1726 : NULL;
Ian Elliott2c05e222015-11-19 13:14:05 -07001727 return true;
1728 }
Ian Elliott919fa302015-11-24 15:39:10 -07001729 if (!strcmp("vkGetPhysicalDeviceMirPresentationSupportKHR", name)) {
Jon Ashburn23d36b12016-02-02 17:47:28 -07001730 *addr = ptr_instance->wsi_mir_surface_enabled
1731 ? (void *)vkGetPhysicalDeviceMirPresentationSupportKHR
1732 : NULL;
Ian Elliott919fa302015-11-24 15:39:10 -07001733 return true;
Jason Ekstranda5ebe8a2016-02-12 17:25:03 -08001734 }
Ian Elliott2c05e222015-11-19 13:14:05 -07001735#endif // VK_USE_PLATFORM_MIR_KHR
1736#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -06001737
1738 // Functions for the VK_KHR_wayland_surface extension:
Jon Ashburn1530c342016-02-26 13:14:27 -07001739 if (!strcmp("vkCreateWaylandSurfaceKHR", name)) {
1740 *addr = ptr_instance->wsi_wayland_surface_enabled
1741 ? (void *)vkCreateWaylandSurfaceKHR
1742 : NULL;
1743 return true;
1744 }
1745 if (!strcmp("vkGetPhysicalDeviceWaylandPresentationSupportKHR", name)) {
1746 *addr = ptr_instance->wsi_wayland_surface_enabled
Jon Ashburn23d36b12016-02-02 17:47:28 -07001747 ? (void *)vkGetPhysicalDeviceWaylandPresentationSupportKHR
1748 : NULL;
Jon Ashburn1530c342016-02-26 13:14:27 -07001749 return true;
1750 }
Ian Elliott2c05e222015-11-19 13:14:05 -07001751#endif // VK_USE_PLATFORM_WAYLAND_KHR
1752#ifdef VK_USE_PLATFORM_XCB_KHR
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -06001753
1754 // Functions for the VK_KHR_xcb_surface extension:
Jon Ashburn1530c342016-02-26 13:14:27 -07001755 if (!strcmp("vkCreateXcbSurfaceKHR", name)) {
1756 *addr = ptr_instance->wsi_xcb_surface_enabled
1757 ? (void *)vkCreateXcbSurfaceKHR
1758 : NULL;
1759 return true;
1760 }
1761 if (!strcmp("vkGetPhysicalDeviceXcbPresentationSupportKHR", name)) {
1762 *addr = ptr_instance->wsi_xcb_surface_enabled
1763 ? (void *)vkGetPhysicalDeviceXcbPresentationSupportKHR
1764 : NULL;
1765 return true;
1766 }
Ian Elliott2c05e222015-11-19 13:14:05 -07001767#endif // VK_USE_PLATFORM_XCB_KHR
1768#ifdef VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -06001769
1770 // Functions for the VK_KHR_xlib_surface extension:
Jon Ashburn1530c342016-02-26 13:14:27 -07001771 if (!strcmp("vkCreateXlibSurfaceKHR", name)) {
1772 *addr = ptr_instance->wsi_xlib_surface_enabled
1773 ? (void *)vkCreateXlibSurfaceKHR
1774 : NULL;
1775 return true;
1776 }
1777 if (!strcmp("vkGetPhysicalDeviceXlibPresentationSupportKHR", name)) {
1778 *addr = ptr_instance->wsi_xlib_surface_enabled
1779 ? (void *)vkGetPhysicalDeviceXlibPresentationSupportKHR
1780 : NULL;
1781 return true;
1782 }
Ian Elliott2c05e222015-11-19 13:14:05 -07001783#endif // VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -07001784#ifdef VK_USE_PLATFORM_ANDROID_KHR
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -06001785
1786 // Functions for the VK_KHR_android_surface extension:
Jon Ashburn1530c342016-02-26 13:14:27 -07001787 if (!strcmp("vkCreateAndroidSurfaceKHR", name)) {
1788 *addr = ptr_instance->wsi_xlib_surface_enabled
1789 ? (void *)vkCreateAndroidSurfaceKHR
1790 : NULL;
1791 return true;
1792 }
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -07001793#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott2c05e222015-11-19 13:14:05 -07001794
Mark Lobodzinski6e45fe72016-08-31 09:31:29 -06001795 // Functions for VK_KHR_display extension:
Jon Ashburnc7d3e732016-03-08 09:30:30 -07001796 if (!strcmp("vkGetPhysicalDeviceDisplayPropertiesKHR", name)) {
1797 *addr = ptr_instance->wsi_display_enabled
1798 ? (void *)vkGetPhysicalDeviceDisplayPropertiesKHR
1799 : NULL;
1800 return true;
1801 }
1802 if (!strcmp("vkGetPhysicalDeviceDisplayPlanePropertiesKHR", name)) {
1803 *addr = ptr_instance->wsi_display_enabled
1804 ? (void *)vkGetPhysicalDeviceDisplayPlanePropertiesKHR
1805 : NULL;
1806 return true;
1807 }
1808 if (!strcmp("vkGetDisplayPlaneSupportedDisplaysKHR", name)) {
1809 *addr = ptr_instance->wsi_display_enabled
1810 ? (void *)vkGetDisplayPlaneSupportedDisplaysKHR
1811 : NULL;
1812 return true;
1813 }
1814 if (!strcmp("vkGetDisplayModePropertiesKHR", name)) {
1815 *addr = ptr_instance->wsi_display_enabled
1816 ? (void *)vkGetDisplayModePropertiesKHR
1817 : NULL;
1818 return true;
1819 }
1820 if (!strcmp("vkCreateDisplayModeKHR", name)) {
1821 *addr = ptr_instance->wsi_display_enabled
1822 ? (void *)vkCreateDisplayModeKHR
1823 : NULL;
1824 return true;
1825 }
1826 if (!strcmp("vkGetDisplayPlaneCapabilitiesKHR", name)) {
1827 *addr = ptr_instance->wsi_display_enabled
1828 ? (void *)vkGetDisplayPlaneCapabilitiesKHR
1829 : NULL;
1830 return true;
1831 }
1832 if (!strcmp("vkCreateDisplayPlaneSurfaceKHR", name)) {
1833 *addr = ptr_instance->wsi_display_enabled
1834 ? (void *)vkCreateDisplayPlaneSurfaceKHR
1835 : NULL;
1836 return true;
1837 }
Mark Young1a867442016-07-01 15:18:27 -06001838
1839 // Functions for KHR_display_swapchain extension:
1840 if (!strcmp("vkCreateSharedSwapchainsKHR", name)) {
1841 *addr = (void *)vkCreateSharedSwapchainsKHR;
1842 return true;
1843 }
1844
Jon Ashburn1530c342016-02-26 13:14:27 -07001845 return false;
Ian Elliott2b8965a2016-03-24 13:59:22 -06001846}