Skip to content

Commit 0db7f6a

Browse files
committed
vim4: Fix vulkan crash
Vulkan loader versions since 1.3.296 has introduced a change that is crashing libMali. Revert the change introduced in vulkan loader The issue is tracked here KhronosGroup/Vulkan-Loader#1637
1 parent c77d2f1 commit 0db7f6a

File tree

1 file changed

+306
-0
lines changed

1 file changed

+306
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,306 @@
1+
--- a/loader/wsi.c
2+
+++ b/loader/wsi.c
3+
@@ -549,8 +549,8 @@
4+
return disp->QueuePresentKHR(queue, pPresentInfo);
5+
}
6+
7+
-VkResult allocate_icd_surface_struct(struct loader_instance *instance, const VkAllocationCallbacks *pAllocator,
8+
- VkIcdSurface **out_icd_surface) {
9+
+VkResult allocate_icd_surface_struct(struct loader_instance *instance, size_t base_size, size_t platform_size,
10+
+ const VkAllocationCallbacks *pAllocator, VkIcdSurface **out_icd_surface) {
11+
uint32_t next_index = 0;
12+
VkIcdSurface *icd_surface = NULL;
13+
VkResult res = loader_get_next_available_entry(instance, &instance->surfaces_list, &next_index, pAllocator);
14+
@@ -566,6 +566,10 @@
15+
}
16+
// Setup the new sizes and offsets so we can grow the structures in the
17+
// future without having problems
18+
+ icd_surface->base_size = (uint32_t)base_size;
19+
+ icd_surface->platform_size = (uint32_t)platform_size;
20+
+ icd_surface->non_platform_offset = (uint32_t)((uint8_t *)(&icd_surface->base_size) - (uint8_t *)icd_surface);
21+
+ icd_surface->entire_size = sizeof(VkIcdSurface);
22+
icd_surface->surface_index = next_index;
23+
24+
for (struct loader_icd_term *icd_term = instance->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
25+
@@ -653,11 +657,16 @@
26+
}
27+
28+
// Next, if so, proceed with the implementation of this function:
29+
- result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
30+
+ result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->win_surf.base), sizeof(icd_surface->win_surf), pAllocator,
31+
+ &icd_surface);
32+
if (VK_SUCCESS != result) {
33+
goto out;
34+
}
35+
36+
+ icd_surface->win_surf.base.platform = VK_ICD_WSI_PLATFORM_WIN32;
37+
+ icd_surface->win_surf.hinstance = pCreateInfo->hinstance;
38+
+ icd_surface->win_surf.hwnd = pCreateInfo->hwnd;
39+
+
40+
// Loop through each ICD and determine if they need to create a surface
41+
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
42+
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
43+
@@ -754,11 +763,16 @@
44+
}
45+
46+
// Next, if so, proceed with the implementation of this function:
47+
- result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
48+
+ result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->wayland_surf.base), sizeof(icd_surface->wayland_surf),
49+
+ pAllocator, &icd_surface);
50+
if (VK_SUCCESS != result) {
51+
goto out;
52+
}
53+
54+
+ icd_surface->wayland_surf.base.platform = VK_ICD_WSI_PLATFORM_WAYLAND;
55+
+ icd_surface->wayland_surf.display = pCreateInfo->display;
56+
+ icd_surface->wayland_surf.surface = pCreateInfo->surface;
57+
+
58+
// Loop through each ICD and determine if they need to create a surface
59+
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
60+
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
61+
@@ -859,11 +873,16 @@
62+
}
63+
64+
// Next, if so, proceed with the implementation of this function:
65+
- result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
66+
+ result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->xcb_surf.base), sizeof(icd_surface->xcb_surf), pAllocator,
67+
+ &icd_surface);
68+
if (VK_SUCCESS != result) {
69+
goto out;
70+
}
71+
72+
+ icd_surface->xcb_surf.base.platform = VK_ICD_WSI_PLATFORM_XCB;
73+
+ icd_surface->xcb_surf.connection = pCreateInfo->connection;
74+
+ icd_surface->xcb_surf.window = pCreateInfo->window;
75+
+
76+
// Loop through each ICD and determine if they need to create a surface
77+
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
78+
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
79+
@@ -967,11 +986,16 @@
80+
}
81+
82+
// Next, if so, proceed with the implementation of this function:
83+
- result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
84+
+ result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->xlib_surf.base), sizeof(icd_surface->xlib_surf),
85+
+ pAllocator, &icd_surface);
86+
if (VK_SUCCESS != result) {
87+
goto out;
88+
}
89+
90+
+ icd_surface->xlib_surf.base.platform = VK_ICD_WSI_PLATFORM_XLIB;
91+
+ icd_surface->xlib_surf.dpy = pCreateInfo->dpy;
92+
+ icd_surface->xlib_surf.window = pCreateInfo->window;
93+
+
94+
// Loop through each ICD and determine if they need to create a surface
95+
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
96+
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
97+
@@ -1074,11 +1098,16 @@
98+
}
99+
100+
// Next, if so, proceed with the implementation of this function:
101+
- result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
102+
+ result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->directfb_surf.base), sizeof(icd_surface->directfb_surf),
103+
+ pAllocator, &icd_surface);
104+
if (VK_SUCCESS != result) {
105+
goto out;
106+
}
107+
108+
+ icd_surface->directfb_surf.base.platform = VK_ICD_WSI_PLATFORM_DIRECTFB;
109+
+ icd_surface->directfb_surf.dfb = pCreateInfo->dfb;
110+
+ icd_surface->directfb_surf.surface = pCreateInfo->surface;
111+
+
112+
// Loop through each ICD and determine if they need to create a surface
113+
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
114+
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
115+
@@ -1226,11 +1255,13 @@
116+
}
117+
118+
// Next, if so, proceed with the implementation of this function:
119+
- result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
120+
+ result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->headless_surf.base), sizeof(icd_surface->headless_surf),
121+
+ pAllocator, &icd_surface);
122+
if (VK_SUCCESS != result) {
123+
goto out;
124+
}
125+
126+
+ icd_surface->headless_surf.base.platform = VK_ICD_WSI_PLATFORM_HEADLESS;
127+
// Loop through each ICD and determine if they need to create a surface
128+
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
129+
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
130+
@@ -1315,11 +1346,15 @@
131+
}
132+
133+
// Next, if so, proceed with the implementation of this function:
134+
- result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
135+
+ result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->macos_surf.base), sizeof(icd_surface->macos_surf),
136+
+ pAllocator, &icd_surface);
137+
if (VK_SUCCESS != result) {
138+
goto out;
139+
}
140+
141+
+ icd_surface->macos_surf.base.platform = VK_ICD_WSI_PLATFORM_MACOS;
142+
+ icd_surface->macos_surf.pView = pCreateInfo->pView;
143+
+
144+
// Loop through each ICD and determine if they need to create a surface
145+
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
146+
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
147+
@@ -1429,11 +1464,15 @@
148+
}
149+
150+
// Next, if so, proceed with the implementation of this function:
151+
- result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
152+
+ result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->ggp_surf.base), sizeof(icd_surface->ggp_surf), pAllocator,
153+
+ &icd_surface);
154+
if (VK_SUCCESS != result) {
155+
goto out;
156+
}
157+
158+
+ icd_surface->ggp_surf.base.platform = VK_ICD_WSI_PLATFORM_GGP;
159+
+ icd_surface->ggp_surf.streamDescriptor = pCreateInfo->streamDescriptor;
160+
+
161+
// Loop through each ICD and determine if they need to create a surface
162+
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
163+
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
164+
@@ -1487,11 +1526,15 @@
165+
}
166+
167+
// Next, if so, proceed with the implementation of this function:
168+
- result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
169+
+ result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->metal_surf.base), sizeof(icd_surface->metal_surf),
170+
+ pAllocator, &icd_surface);
171+
if (VK_SUCCESS != result) {
172+
goto out;
173+
}
174+
175+
+ icd_surface->metal_surf.base.platform = VK_ICD_WSI_PLATFORM_METAL;
176+
+ icd_surface->metal_surf.pLayer = pCreateInfo->pLayer;
177+
+
178+
// Loop through each ICD and determine if they need to create a surface
179+
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
180+
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
181+
@@ -1549,11 +1592,16 @@
182+
}
183+
184+
// Next, if so, proceed with the implementation of this function:
185+
- result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
186+
+ result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->screen_surf.base), sizeof(icd_surface->screen_surf),
187+
+ pAllocator, &icd_surface);
188+
if (VK_SUCCESS != result) {
189+
goto out;
190+
}
191+
192+
+ icd_surface->screen_surf.base.platform = VK_ICD_WSI_PLATFORM_SCREEN;
193+
+ icd_surface->screen_surf.context = pCreateInfo->context;
194+
+ icd_surface->screen_surf.window = pCreateInfo->window;
195+
+
196+
// Loop through each ICD and determine if they need to create a surface
197+
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
198+
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
199+
@@ -1652,11 +1700,15 @@
200+
}
201+
202+
// Next, if so, proceed with the implementation of this function:
203+
- result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
204+
+ result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->vi_surf.base), sizeof(icd_surface->vi_surf), pAllocator,
205+
+ &icd_surface);
206+
if (VK_SUCCESS != result) {
207+
goto out;
208+
}
209+
210+
+ icd_surface->vi_surf.base.platform = VK_ICD_WSI_PLATFORM_VI;
211+
+ icd_surface->vi_surf.window = pCreateInfo->window;
212+
+
213+
// Loop through each ICD and determine if they need to create a surface
214+
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
215+
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
216+
@@ -1962,11 +2014,21 @@
217+
}
218+
219+
// Next, if so, proceed with the implementation of this function:
220+
- result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
221+
+ result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->display_surf.base), sizeof(icd_surface->display_surf),
222+
+ pAllocator, &icd_surface);
223+
if (VK_SUCCESS != result) {
224+
goto out;
225+
}
226+
227+
+ icd_surface->display_surf.base.platform = VK_ICD_WSI_PLATFORM_DISPLAY;
228+
+ icd_surface->display_surf.displayMode = pCreateInfo->displayMode;
229+
+ icd_surface->display_surf.planeIndex = pCreateInfo->planeIndex;
230+
+ icd_surface->display_surf.planeStackIndex = pCreateInfo->planeStackIndex;
231+
+ icd_surface->display_surf.transform = pCreateInfo->transform;
232+
+ icd_surface->display_surf.globalAlpha = pCreateInfo->globalAlpha;
233+
+ icd_surface->display_surf.alphaMode = pCreateInfo->alphaMode;
234+
+ icd_surface->display_surf.imageExtent = pCreateInfo->imageExtent;
235+
+
236+
// Loop through each ICD and determine if they need to create a surface
237+
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
238+
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
239+
@@ -2398,11 +2460,14 @@
240+
}
241+
242+
// Next, if so, proceed with the implementation of this function:
243+
- result = allocate_icd_surface_struct(loader_inst, pAllocator, &icd_surface);
244+
+ result = allocate_icd_surface_struct(loader_inst, sizeof(icd_surface->imagepipe_surf.base), sizeof(icd_surface->imagepipe_surf),
245+
+ pAllocator, &icd_surface);
246+
if (VK_SUCCESS != result) {
247+
goto out;
248+
}
249+
250+
+ icd_surface->imagepipe_surf.base.platform = VK_ICD_WSI_PLATFORM_FUCHSIA;
251+
+
252+
// Loop through each ICD and determine if they need to create a surface
253+
for (struct loader_icd_term *icd_term = loader_inst->icd_terms; icd_term != NULL; icd_term = icd_term->next) {
254+
if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) {
255+
--- a/loader/wsi.h
256+
+++ b/loader/wsi.h
257+
@@ -25,7 +25,48 @@
258+
#include "loader_common.h"
259+
260+
typedef struct {
261+
- uint32_t surface_index; // This surface's index into each drivers list of created surfaces
262+
+ union {
263+
+#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
264+
+ VkIcdSurfaceWayland wayland_surf;
265+
+#endif // VK_USE_PLATFORM_WAYLAND_KHR
266+
+#if defined(VK_USE_PLATFORM_WIN32_KHR)
267+
+ VkIcdSurfaceWin32 win_surf;
268+
+#endif // VK_USE_PLATFORM_WIN32_KHR
269+
+#if defined(VK_USE_PLATFORM_XCB_KHR)
270+
+ VkIcdSurfaceXcb xcb_surf;
271+
+#endif // VK_USE_PLATFORM_XCB_KHR
272+
+#if defined(VK_USE_PLATFORM_XLIB_KHR)
273+
+ VkIcdSurfaceXlib xlib_surf;
274+
+#endif // VK_USE_PLATFORM_XLIB_KHR
275+
+#if defined(VK_USE_PLATFORM_DIRECTFB_EXT)
276+
+ VkIcdSurfaceDirectFB directfb_surf;
277+
+#endif // VK_USE_PLATFORM_DIRECTFB_EXT
278+
+#if defined(VK_USE_PLATFORM_MACOS_MVK)
279+
+ VkIcdSurfaceMacOS macos_surf;
280+
+#endif // VK_USE_PLATFORM_MACOS_MVK
281+
+#if defined(VK_USE_PLATFORM_GGP)
282+
+ VkIcdSurfaceGgp ggp_surf;
283+
+#endif // VK_USE_PLATFORM_GGP
284+
+#if defined(VK_USE_PLATFORM_FUCHSIA)
285+
+ VkIcdSurfaceImagePipe imagepipe_surf;
286+
+#endif // VK_USE_PLATFORM_FUCHSIA
287+
+#if defined(VK_USE_PLATFORM_METAL_EXT)
288+
+ VkIcdSurfaceMetal metal_surf;
289+
+#endif // VK_USE_PLATFORM_METAL_EXT
290+
+#if defined(VK_USE_PLATFORM_SCREEN_QNX)
291+
+ VkIcdSurfaceScreen screen_surf;
292+
+#endif // VK_USE_PLATFORM_SCREEN_QNX
293+
+#if defined(VK_USE_PLATFORM_VI_NN)
294+
+ VkIcdSurfaceVi vi_surf;
295+
+#endif // VK_USE_PLATFORM_VI_NN
296+
+ VkIcdSurfaceDisplay display_surf;
297+
+ VkIcdSurfaceHeadless headless_surf;
298+
+ };
299+
+ uint32_t base_size; // Size of VkIcdSurfaceBase
300+
+ uint32_t platform_size; // Size of corresponding VkIcdSurfaceXXX
301+
+ uint32_t non_platform_offset; // Start offset to base_size
302+
+ uint32_t entire_size; // Size of entire VkIcdSurface
303+
+ uint32_t surface_index; // This surface's index into each drivers list of created surfaces
304+
} VkIcdSurface;
305+
306+
bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, const char *name, void **addr);

0 commit comments

Comments
 (0)