Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert removing unused surface icd members #1639

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 80 additions & 15 deletions loader/wsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,8 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkQueuePresentKHR(VkQueue queue, co
return disp->QueuePresentKHR(queue, pPresentInfo);
}

VkResult allocate_icd_surface_struct(struct loader_instance *instance, const VkAllocationCallbacks *pAllocator,
VkIcdSurface **out_icd_surface) {
VkResult allocate_icd_surface_struct(struct loader_instance *instance, size_t base_size, size_t platform_size,
const VkAllocationCallbacks *pAllocator, VkIcdSurface **out_icd_surface) {
uint32_t next_index = 0;
VkIcdSurface *icd_surface = NULL;
VkResult res = loader_get_next_available_entry(instance, &instance->surfaces_list, &next_index, pAllocator);
Expand All @@ -568,6 +568,10 @@ VkResult allocate_icd_surface_struct(struct loader_instance *instance, const VkA
}
// Setup the new sizes and offsets so we can grow the structures in the
// future without having problems
icd_surface->base_size = (uint32_t)base_size;
icd_surface->platform_size = (uint32_t)platform_size;
icd_surface->non_platform_offset = (uint32_t)((uint8_t *)(&icd_surface->base_size) - (uint8_t *)icd_surface);
icd_surface->entire_size = sizeof(VkIcdSurface);
icd_surface->surface_index = next_index;

for (struct loader_icd_term *icd_term = instance->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
Expand Down Expand Up @@ -655,11 +659,16 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWin32SurfaceKHR(VkInstance insta
}

// Next, if so, proceed with the implementation of this function:
result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->win_surf.base), sizeof(icd_surface->win_surf), pAllocator,
&icd_surface);
if (VK_SUCCESS != result) {
goto out;
}

icd_surface->win_surf.base.platform = VK_ICD_WSI_PLATFORM_WIN32;
icd_surface->win_surf.hinstance = pCreateInfo->hinstance;
icd_surface->win_surf.hwnd = pCreateInfo->hwnd;

// Loop through each ICD and determine if they need to create a surface
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
Expand Down Expand Up @@ -756,11 +765,16 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWaylandSurfaceKHR(VkInstance ins
}

// Next, if so, proceed with the implementation of this function:
result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->wayland_surf.base), sizeof(icd_surface->wayland_surf),
pAllocator, &icd_surface);
if (VK_SUCCESS != result) {
goto out;
}

icd_surface->wayland_surf.base.platform = VK_ICD_WSI_PLATFORM_WAYLAND;
icd_surface->wayland_surf.display = pCreateInfo->display;
icd_surface->wayland_surf.surface = pCreateInfo->surface;

// Loop through each ICD and determine if they need to create a surface
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
Expand Down Expand Up @@ -861,11 +875,16 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXcbSurfaceKHR(VkInstance instanc
}

// Next, if so, proceed with the implementation of this function:
result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->xcb_surf.base), sizeof(icd_surface->xcb_surf), pAllocator,
&icd_surface);
if (VK_SUCCESS != result) {
goto out;
}

icd_surface->xcb_surf.base.platform = VK_ICD_WSI_PLATFORM_XCB;
icd_surface->xcb_surf.connection = pCreateInfo->connection;
icd_surface->xcb_surf.window = pCreateInfo->window;

// Loop through each ICD and determine if they need to create a surface
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
Expand Down Expand Up @@ -969,11 +988,16 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXlibSurfaceKHR(VkInstance instan
}

// Next, if so, proceed with the implementation of this function:
result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->xlib_surf.base), sizeof(icd_surface->xlib_surf),
pAllocator, &icd_surface);
if (VK_SUCCESS != result) {
goto out;
}

icd_surface->xlib_surf.base.platform = VK_ICD_WSI_PLATFORM_XLIB;
icd_surface->xlib_surf.dpy = pCreateInfo->dpy;
icd_surface->xlib_surf.window = pCreateInfo->window;

// Loop through each ICD and determine if they need to create a surface
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
Expand Down Expand Up @@ -1076,11 +1100,16 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDirectFBSurfaceEXT(VkInstance in
}

// Next, if so, proceed with the implementation of this function:
result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->directfb_surf.base), sizeof(icd_surface->directfb_surf),
pAllocator, &icd_surface);
if (VK_SUCCESS != result) {
goto out;
}

icd_surface->directfb_surf.base.platform = VK_ICD_WSI_PLATFORM_DIRECTFB;
icd_surface->directfb_surf.dfb = pCreateInfo->dfb;
icd_surface->directfb_surf.surface = pCreateInfo->surface;

// Loop through each ICD and determine if they need to create a surface
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
Expand Down Expand Up @@ -1228,11 +1257,13 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateHeadlessSurfaceEXT(VkInstance in
}

// Next, if so, proceed with the implementation of this function:
result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->headless_surf.base), sizeof(icd_surface->headless_surf),
pAllocator, &icd_surface);
if (VK_SUCCESS != result) {
goto out;
}

icd_surface->headless_surf.base.platform = VK_ICD_WSI_PLATFORM_HEADLESS;
// Loop through each ICD and determine if they need to create a surface
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
Expand Down Expand Up @@ -1317,11 +1348,15 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateMacOSSurfaceMVK(VkInstance insta
}

// Next, if so, proceed with the implementation of this function:
result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->macos_surf.base), sizeof(icd_surface->macos_surf),
pAllocator, &icd_surface);
if (VK_SUCCESS != result) {
goto out;
}

icd_surface->macos_surf.base.platform = VK_ICD_WSI_PLATFORM_MACOS;
icd_surface->macos_surf.pView = pCreateInfo->pView;

// Loop through each ICD and determine if they need to create a surface
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
Expand Down Expand Up @@ -1431,11 +1466,15 @@ terminator_CreateStreamDescriptorSurfaceGGP(VkInstance instance, const VkStreamD
}

// Next, if so, proceed with the implementation of this function:
result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->ggp_surf.base), sizeof(icd_surface->ggp_surf), pAllocator,
&icd_surface);
if (VK_SUCCESS != result) {
goto out;
}

icd_surface->ggp_surf.base.platform = VK_ICD_WSI_PLATFORM_GGP;
icd_surface->ggp_surf.streamDescriptor = pCreateInfo->streamDescriptor;

// Loop through each ICD and determine if they need to create a surface
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
Expand Down Expand Up @@ -1489,11 +1528,15 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateMetalSurfaceEXT(VkInstance insta
}

// Next, if so, proceed with the implementation of this function:
result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->metal_surf.base), sizeof(icd_surface->metal_surf),
pAllocator, &icd_surface);
if (VK_SUCCESS != result) {
goto out;
}

icd_surface->metal_surf.base.platform = VK_ICD_WSI_PLATFORM_METAL;
icd_surface->metal_surf.pLayer = pCreateInfo->pLayer;

// Loop through each ICD and determine if they need to create a surface
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
Expand Down Expand Up @@ -1551,11 +1594,16 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateScreenSurfaceQNX(VkInstance inst
}

// Next, if so, proceed with the implementation of this function:
result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->screen_surf.base), sizeof(icd_surface->screen_surf),
pAllocator, &icd_surface);
if (VK_SUCCESS != result) {
goto out;
}

icd_surface->screen_surf.base.platform = VK_ICD_WSI_PLATFORM_SCREEN;
icd_surface->screen_surf.context = pCreateInfo->context;
icd_surface->screen_surf.window = pCreateInfo->window;

// Loop through each ICD and determine if they need to create a surface
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
Expand Down Expand Up @@ -1654,11 +1702,15 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateViSurfaceNN(VkInstance instance,
}

// Next, if so, proceed with the implementation of this function:
result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->vi_surf.base), sizeof(icd_surface->vi_surf), pAllocator,
&icd_surface);
if (VK_SUCCESS != result) {
goto out;
}

icd_surface->vi_surf.base.platform = VK_ICD_WSI_PLATFORM_VI;
icd_surface->vi_surf.window = pCreateInfo->window;

// Loop through each ICD and determine if they need to create a surface
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
Expand Down Expand Up @@ -1964,11 +2016,21 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayPlaneSurfaceKHR(VkInstanc
}

// Next, if so, proceed with the implementation of this function:
result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->display_surf.base), sizeof(icd_surface->display_surf),
pAllocator, &icd_surface);
if (VK_SUCCESS != result) {
goto out;
}

icd_surface->display_surf.base.platform = VK_ICD_WSI_PLATFORM_DISPLAY;
icd_surface->display_surf.displayMode = pCreateInfo->displayMode;
icd_surface->display_surf.planeIndex = pCreateInfo->planeIndex;
icd_surface->display_surf.planeStackIndex = pCreateInfo->planeStackIndex;
icd_surface->display_surf.transform = pCreateInfo->transform;
icd_surface->display_surf.globalAlpha = pCreateInfo->globalAlpha;
icd_surface->display_surf.alphaMode = pCreateInfo->alphaMode;
icd_surface->display_surf.imageExtent = pCreateInfo->imageExtent;

// Loop through each ICD and determine if they need to create a surface
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
Expand Down Expand Up @@ -2400,11 +2462,14 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateImagePipeSurfaceFUCHSIA(VkInstan
}

// Next, if so, proceed with the implementation of this function:
result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->imagepipe_surf.base), sizeof(icd_surface->imagepipe_surf),
pAllocator, &icd_surface);
if (VK_SUCCESS != result) {
goto out;
}

icd_surface->imagepipe_surf.base.platform = VK_ICD_WSI_PLATFORM_FUCHSIA;

// Loop through each ICD and determine if they need to create a surface
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
Expand Down
47 changes: 46 additions & 1 deletion loader/wsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,52 @@
#include "loader_common.h"

typedef struct {
uint32_t surface_index; // This surface's index into each drivers list of created surfaces
// This union holds the data that drivers which use ICD interface version 2 and before expect. This is so they can dereference
// VkSurfaceKHR to get this struct and access the creation parameters used in subsequent API calls, such as get surface formats
// & get surface present modes.
// Thus, these members need to stay here in order to preserve ABI compatibility.
union {
#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
VkIcdSurfaceWayland wayland_surf;
#endif // VK_USE_PLATFORM_WAYLAND_KHR
#if defined(VK_USE_PLATFORM_WIN32_KHR)
VkIcdSurfaceWin32 win_surf;
#endif // VK_USE_PLATFORM_WIN32_KHR
#if defined(VK_USE_PLATFORM_XCB_KHR)
VkIcdSurfaceXcb xcb_surf;
#endif // VK_USE_PLATFORM_XCB_KHR
#if defined(VK_USE_PLATFORM_XLIB_KHR)
VkIcdSurfaceXlib xlib_surf;
#endif // VK_USE_PLATFORM_XLIB_KHR
#if defined(VK_USE_PLATFORM_DIRECTFB_EXT)
VkIcdSurfaceDirectFB directfb_surf;
#endif // VK_USE_PLATFORM_DIRECTFB_EXT
#if defined(VK_USE_PLATFORM_MACOS_MVK)
VkIcdSurfaceMacOS macos_surf;
#endif // VK_USE_PLATFORM_MACOS_MVK
#if defined(VK_USE_PLATFORM_GGP)
VkIcdSurfaceGgp ggp_surf;
#endif // VK_USE_PLATFORM_GGP
#if defined(VK_USE_PLATFORM_FUCHSIA)
VkIcdSurfaceImagePipe imagepipe_surf;
#endif // VK_USE_PLATFORM_FUCHSIA
#if defined(VK_USE_PLATFORM_METAL_EXT)
VkIcdSurfaceMetal metal_surf;
#endif // VK_USE_PLATFORM_METAL_EXT
#if defined(VK_USE_PLATFORM_SCREEN_QNX)
VkIcdSurfaceScreen screen_surf;
#endif // VK_USE_PLATFORM_SCREEN_QNX
#if defined(VK_USE_PLATFORM_VI_NN)
VkIcdSurfaceVi vi_surf;
#endif // VK_USE_PLATFORM_VI_NN
VkIcdSurfaceDisplay display_surf;
VkIcdSurfaceHeadless headless_surf;
};
uint32_t base_size; // Size of VkIcdSurfaceBase
uint32_t platform_size; // Size of corresponding VkIcdSurfaceXXX
uint32_t non_platform_offset; // Start offset to base_size
uint32_t entire_size; // Size of entire VkIcdSurface
uint32_t surface_index; // This surface's index into each drivers list of created surfaces
} VkIcdSurface;

bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, const char *name, void **addr);
Expand Down
Loading