Skip to content

Commit

Permalink
Revert "Remove unused VkIcdSurface struct members"
Browse files Browse the repository at this point in the history
This reverts commit 55bd9d6.
The libMali.so driver still uses the older method of surface creation,
so the struct members are still actually 'used'.
  • Loading branch information
charles-lunarg committed Jan 17, 2025
1 parent 35a851d commit 214bdd4
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 16 deletions.
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
43 changes: 42 additions & 1 deletion loader/wsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,48 @@
#include "loader_common.h"

typedef struct {
uint32_t surface_index; // This surface's index into each drivers list of created surfaces
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

0 comments on commit 214bdd4

Please sign in to comment.