Skip to content

Commit e8132aa

Browse files
Revert "Remove unused VkIcdSurface struct members"
This reverts commit 55bd9d6. The libMali.so driver still uses the older method of surface creation, so the struct members are still actually 'used'.
1 parent 35a851d commit e8132aa

File tree

2 files changed

+122
-16
lines changed

2 files changed

+122
-16
lines changed

loader/wsi.c

Lines changed: 80 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -551,8 +551,8 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkQueuePresentKHR(VkQueue queue, co
551551
return disp->QueuePresentKHR(queue, pPresentInfo);
552552
}
553553

554-
VkResult allocate_icd_surface_struct(struct loader_instance *instance, const VkAllocationCallbacks *pAllocator,
555-
VkIcdSurface **out_icd_surface) {
554+
VkResult allocate_icd_surface_struct(struct loader_instance *instance, size_t base_size, size_t platform_size,
555+
const VkAllocationCallbacks *pAllocator, VkIcdSurface **out_icd_surface) {
556556
uint32_t next_index = 0;
557557
VkIcdSurface *icd_surface = NULL;
558558
VkResult res = loader_get_next_available_entry(instance, &instance->surfaces_list, &next_index, pAllocator);
@@ -568,6 +568,10 @@ VkResult allocate_icd_surface_struct(struct loader_instance *instance, const VkA
568568
}
569569
// Setup the new sizes and offsets so we can grow the structures in the
570570
// future without having problems
571+
icd_surface->base_size = (uint32_t)base_size;
572+
icd_surface->platform_size = (uint32_t)platform_size;
573+
icd_surface->non_platform_offset = (uint32_t)((uint8_t *)(&icd_surface->base_size) - (uint8_t *)icd_surface);
574+
icd_surface->entire_size = sizeof(VkIcdSurface);
571575
icd_surface->surface_index = next_index;
572576

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

657661
// Next, if so, proceed with the implementation of this function:
658-
result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
662+
result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->win_surf.base), sizeof(icd_surface->win_surf), pAllocator,
663+
&icd_surface);
659664
if (VK_SUCCESS != result) {
660665
goto out;
661666
}
662667

668+
icd_surface->win_surf.base.platform = VK_ICD_WSI_PLATFORM_WIN32;
669+
icd_surface->win_surf.hinstance = pCreateInfo->hinstance;
670+
icd_surface->win_surf.hwnd = pCreateInfo->hwnd;
671+
663672
// Loop through each ICD and determine if they need to create a surface
664673
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
665674
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
@@ -756,11 +765,16 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWaylandSurfaceKHR(VkInstance ins
756765
}
757766

758767
// Next, if so, proceed with the implementation of this function:
759-
result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
768+
result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->wayland_surf.base), sizeof(icd_surface->wayland_surf),
769+
pAllocator, &icd_surface);
760770
if (VK_SUCCESS != result) {
761771
goto out;
762772
}
763773

774+
icd_surface->wayland_surf.base.platform = VK_ICD_WSI_PLATFORM_WAYLAND;
775+
icd_surface->wayland_surf.display = pCreateInfo->display;
776+
icd_surface->wayland_surf.surface = pCreateInfo->surface;
777+
764778
// Loop through each ICD and determine if they need to create a surface
765779
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
766780
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
@@ -861,11 +875,16 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXcbSurfaceKHR(VkInstance instanc
861875
}
862876

863877
// Next, if so, proceed with the implementation of this function:
864-
result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
878+
result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->xcb_surf.base), sizeof(icd_surface->xcb_surf), pAllocator,
879+
&icd_surface);
865880
if (VK_SUCCESS != result) {
866881
goto out;
867882
}
868883

884+
icd_surface->xcb_surf.base.platform = VK_ICD_WSI_PLATFORM_XCB;
885+
icd_surface->xcb_surf.connection = pCreateInfo->connection;
886+
icd_surface->xcb_surf.window = pCreateInfo->window;
887+
869888
// Loop through each ICD and determine if they need to create a surface
870889
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
871890
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
@@ -969,11 +988,16 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXlibSurfaceKHR(VkInstance instan
969988
}
970989

971990
// Next, if so, proceed with the implementation of this function:
972-
result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
991+
result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->xlib_surf.base), sizeof(icd_surface->xlib_surf),
992+
pAllocator, &icd_surface);
973993
if (VK_SUCCESS != result) {
974994
goto out;
975995
}
976996

997+
icd_surface->xlib_surf.base.platform = VK_ICD_WSI_PLATFORM_XLIB;
998+
icd_surface->xlib_surf.dpy = pCreateInfo->dpy;
999+
icd_surface->xlib_surf.window = pCreateInfo->window;
1000+
9771001
// Loop through each ICD and determine if they need to create a surface
9781002
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
9791003
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
@@ -1076,11 +1100,16 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDirectFBSurfaceEXT(VkInstance in
10761100
}
10771101

10781102
// Next, if so, proceed with the implementation of this function:
1079-
result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
1103+
result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->directfb_surf.base), sizeof(icd_surface->directfb_surf),
1104+
pAllocator, &icd_surface);
10801105
if (VK_SUCCESS != result) {
10811106
goto out;
10821107
}
10831108

1109+
icd_surface->directfb_surf.base.platform = VK_ICD_WSI_PLATFORM_DIRECTFB;
1110+
icd_surface->directfb_surf.dfb = pCreateInfo->dfb;
1111+
icd_surface->directfb_surf.surface = pCreateInfo->surface;
1112+
10841113
// Loop through each ICD and determine if they need to create a surface
10851114
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
10861115
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
@@ -1228,11 +1257,13 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateHeadlessSurfaceEXT(VkInstance in
12281257
}
12291258

12301259
// Next, if so, proceed with the implementation of this function:
1231-
result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
1260+
result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->headless_surf.base), sizeof(icd_surface->headless_surf),
1261+
pAllocator, &icd_surface);
12321262
if (VK_SUCCESS != result) {
12331263
goto out;
12341264
}
12351265

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

13191350
// Next, if so, proceed with the implementation of this function:
1320-
result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
1351+
result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->macos_surf.base), sizeof(icd_surface->macos_surf),
1352+
pAllocator, &icd_surface);
13211353
if (VK_SUCCESS != result) {
13221354
goto out;
13231355
}
13241356

1357+
icd_surface->macos_surf.base.platform = VK_ICD_WSI_PLATFORM_MACOS;
1358+
icd_surface->macos_surf.pView = pCreateInfo->pView;
1359+
13251360
// Loop through each ICD and determine if they need to create a surface
13261361
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
13271362
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
@@ -1431,11 +1466,15 @@ terminator_CreateStreamDescriptorSurfaceGGP(VkInstance instance, const VkStreamD
14311466
}
14321467

14331468
// Next, if so, proceed with the implementation of this function:
1434-
result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
1469+
result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->ggp_surf.base), sizeof(icd_surface->ggp_surf), pAllocator,
1470+
&icd_surface);
14351471
if (VK_SUCCESS != result) {
14361472
goto out;
14371473
}
14381474

1475+
icd_surface->ggp_surf.base.platform = VK_ICD_WSI_PLATFORM_GGP;
1476+
icd_surface->ggp_surf.streamDescriptor = pCreateInfo->streamDescriptor;
1477+
14391478
// Loop through each ICD and determine if they need to create a surface
14401479
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
14411480
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
@@ -1489,11 +1528,15 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateMetalSurfaceEXT(VkInstance insta
14891528
}
14901529

14911530
// Next, if so, proceed with the implementation of this function:
1492-
result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
1531+
result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->metal_surf.base), sizeof(icd_surface->metal_surf),
1532+
pAllocator, &icd_surface);
14931533
if (VK_SUCCESS != result) {
14941534
goto out;
14951535
}
14961536

1537+
icd_surface->metal_surf.base.platform = VK_ICD_WSI_PLATFORM_METAL;
1538+
icd_surface->metal_surf.pLayer = pCreateInfo->pLayer;
1539+
14971540
// Loop through each ICD and determine if they need to create a surface
14981541
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
14991542
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
@@ -1551,11 +1594,16 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateScreenSurfaceQNX(VkInstance inst
15511594
}
15521595

15531596
// Next, if so, proceed with the implementation of this function:
1554-
result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
1597+
result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->screen_surf.base), sizeof(icd_surface->screen_surf),
1598+
pAllocator, &icd_surface);
15551599
if (VK_SUCCESS != result) {
15561600
goto out;
15571601
}
15581602

1603+
icd_surface->screen_surf.base.platform = VK_ICD_WSI_PLATFORM_SCREEN;
1604+
icd_surface->screen_surf.context = pCreateInfo->context;
1605+
icd_surface->screen_surf.window = pCreateInfo->window;
1606+
15591607
// Loop through each ICD and determine if they need to create a surface
15601608
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
15611609
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
@@ -1654,11 +1702,15 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateViSurfaceNN(VkInstance instance,
16541702
}
16551703

16561704
// Next, if so, proceed with the implementation of this function:
1657-
result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
1705+
result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->vi_surf.base), sizeof(icd_surface->vi_surf), pAllocator,
1706+
&icd_surface);
16581707
if (VK_SUCCESS != result) {
16591708
goto out;
16601709
}
16611710

1711+
icd_surface->vi_surf.base.platform = VK_ICD_WSI_PLATFORM_VI;
1712+
icd_surface->vi_surf.window = pCreateInfo->window;
1713+
16621714
// Loop through each ICD and determine if they need to create a surface
16631715
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
16641716
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
@@ -1964,11 +2016,21 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayPlaneSurfaceKHR(VkInstanc
19642016
}
19652017

19662018
// Next, if so, proceed with the implementation of this function:
1967-
result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
2019+
result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->display_surf.base), sizeof(icd_surface->display_surf),
2020+
pAllocator, &icd_surface);
19682021
if (VK_SUCCESS != result) {
19692022
goto out;
19702023
}
19712024

2025+
icd_surface->display_surf.base.platform = VK_ICD_WSI_PLATFORM_DISPLAY;
2026+
icd_surface->display_surf.displayMode = pCreateInfo->displayMode;
2027+
icd_surface->display_surf.planeIndex = pCreateInfo->planeIndex;
2028+
icd_surface->display_surf.planeStackIndex = pCreateInfo->planeStackIndex;
2029+
icd_surface->display_surf.transform = pCreateInfo->transform;
2030+
icd_surface->display_surf.globalAlpha = pCreateInfo->globalAlpha;
2031+
icd_surface->display_surf.alphaMode = pCreateInfo->alphaMode;
2032+
icd_surface->display_surf.imageExtent = pCreateInfo->imageExtent;
2033+
19722034
// Loop through each ICD and determine if they need to create a surface
19732035
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
19742036
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
@@ -2400,11 +2462,14 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateImagePipeSurfaceFUCHSIA(VkInstan
24002462
}
24012463

24022464
// Next, if so, proceed with the implementation of this function:
2403-
result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
2465+
result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->imagepipe_surf.base), sizeof(icd_surface->imagepipe_surf),
2466+
pAllocator, &icd_surface);
24042467
if (VK_SUCCESS != result) {
24052468
goto out;
24062469
}
24072470

2471+
icd_surface->imagepipe_surf.base.platform = VK_ICD_WSI_PLATFORM_FUCHSIA;
2472+
24082473
// Loop through each ICD and determine if they need to create a surface
24092474
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
24102475
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {

loader/wsi.h

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,48 @@
2525
#include "loader_common.h"
2626

2727
typedef struct {
28-
uint32_t surface_index; // This surface's index into each drivers list of created surfaces
28+
union {
29+
#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
30+
VkIcdSurfaceWayland wayland_surf;
31+
#endif // VK_USE_PLATFORM_WAYLAND_KHR
32+
#if defined(VK_USE_PLATFORM_WIN32_KHR)
33+
VkIcdSurfaceWin32 win_surf;
34+
#endif // VK_USE_PLATFORM_WIN32_KHR
35+
#if defined(VK_USE_PLATFORM_XCB_KHR)
36+
VkIcdSurfaceXcb xcb_surf;
37+
#endif // VK_USE_PLATFORM_XCB_KHR
38+
#if defined(VK_USE_PLATFORM_XLIB_KHR)
39+
VkIcdSurfaceXlib xlib_surf;
40+
#endif // VK_USE_PLATFORM_XLIB_KHR
41+
#if defined(VK_USE_PLATFORM_DIRECTFB_EXT)
42+
VkIcdSurfaceDirectFB directfb_surf;
43+
#endif // VK_USE_PLATFORM_DIRECTFB_EXT
44+
#if defined(VK_USE_PLATFORM_MACOS_MVK)
45+
VkIcdSurfaceMacOS macos_surf;
46+
#endif // VK_USE_PLATFORM_MACOS_MVK
47+
#if defined(VK_USE_PLATFORM_GGP)
48+
VkIcdSurfaceGgp ggp_surf;
49+
#endif // VK_USE_PLATFORM_GGP
50+
#if defined(VK_USE_PLATFORM_FUCHSIA)
51+
VkIcdSurfaceImagePipe imagepipe_surf;
52+
#endif // VK_USE_PLATFORM_FUCHSIA
53+
#if defined(VK_USE_PLATFORM_METAL_EXT)
54+
VkIcdSurfaceMetal metal_surf;
55+
#endif // VK_USE_PLATFORM_METAL_EXT
56+
#if defined(VK_USE_PLATFORM_SCREEN_QNX)
57+
VkIcdSurfaceScreen screen_surf;
58+
#endif // VK_USE_PLATFORM_SCREEN_QNX
59+
#if defined(VK_USE_PLATFORM_VI_NN)
60+
VkIcdSurfaceVi vi_surf;
61+
#endif // VK_USE_PLATFORM_VI_NN
62+
VkIcdSurfaceDisplay display_surf;
63+
VkIcdSurfaceHeadless headless_surf;
64+
};
65+
uint32_t base_size; // Size of VkIcdSurfaceBase
66+
uint32_t platform_size; // Size of corresponding VkIcdSurfaceXXX
67+
uint32_t non_platform_offset; // Start offset to base_size
68+
uint32_t entire_size; // Size of entire VkIcdSurface
69+
uint32_t surface_index; // This surface's index into each drivers list of created surfaces
2970
} VkIcdSurface;
3071

3172
bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, const char *name, void **addr);

0 commit comments

Comments
 (0)