summaryrefslogtreecommitdiff
path: root/contrib/SDL-3.2.8/src/video/vivante
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/SDL-3.2.8/src/video/vivante')
-rw-r--r--contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteopengles.c41
-rw-r--r--contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteopengles.h46
-rw-r--r--contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteplatform.c49
-rw-r--r--contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteplatform.h45
-rw-r--r--contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevideo.c363
-rw-r--r--contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevideo.h86
-rw-r--r--contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevulkan.c154
-rw-r--r--contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevulkan.h51
8 files changed, 835 insertions, 0 deletions
diff --git a/contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteopengles.c b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteopengles.c
new file mode 100644
index 0000000..577711f
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteopengles.c
@@ -0,0 +1,41 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21#include "SDL_internal.h"
22
23#if defined(SDL_VIDEO_DRIVER_VIVANTE) && defined(SDL_VIDEO_OPENGL_EGL)
24
25#include "SDL_vivanteopengles.h"
26#include "SDL_vivantevideo.h"
27
28// EGL implementation of SDL OpenGL support
29
30bool VIVANTE_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path)
31{
32 SDL_DisplayData *displaydata = SDL_GetDisplayDriverData(SDL_GetPrimaryDisplay());
33
34 return SDL_EGL_LoadLibrary(_this, path, displaydata->native_display, 0);
35}
36
37SDL_EGL_CreateContext_impl(VIVANTE)
38SDL_EGL_SwapWindow_impl(VIVANTE)
39SDL_EGL_MakeCurrent_impl(VIVANTE)
40
41#endif // SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL
diff --git a/contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteopengles.h b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteopengles.h
new file mode 100644
index 0000000..47cdc16
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteopengles.h
@@ -0,0 +1,46 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21#include "SDL_internal.h"
22
23#ifndef SDL_vivanteopengles_h_
24#define SDL_vivanteopengles_h_
25
26#if defined(SDL_VIDEO_DRIVER_VIVANTE) && defined(SDL_VIDEO_OPENGL_EGL)
27
28#include "../SDL_sysvideo.h"
29#include "../SDL_egl_c.h"
30
31// OpenGLES functions
32#define VIVANTE_GLES_GetAttribute SDL_EGL_GetAttribute
33#define VIVANTE_GLES_GetProcAddress SDL_EGL_GetProcAddressInternal
34#define VIVANTE_GLES_UnloadLibrary SDL_EGL_UnloadLibrary
35#define VIVANTE_GLES_SetSwapInterval SDL_EGL_SetSwapInterval
36#define VIVANTE_GLES_GetSwapInterval SDL_EGL_GetSwapInterval
37#define VIVANTE_GLES_DestroyContext SDL_EGL_DestroyContext
38
39extern bool VIVANTE_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path);
40extern SDL_GLContext VIVANTE_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window);
41extern bool VIVANTE_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window);
42extern bool VIVANTE_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context);
43
44#endif // SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL
45
46#endif // SDL_vivanteopengles_h_
diff --git a/contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteplatform.c b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteplatform.c
new file mode 100644
index 0000000..5d1e6d9
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteplatform.c
@@ -0,0 +1,49 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21#include "SDL_internal.h"
22
23#ifdef SDL_VIDEO_DRIVER_VIVANTE
24
25#include "SDL_vivanteplatform.h"
26
27#ifdef VIVANTE_PLATFORM_GENERIC
28
29bool VIVANTE_SetupPlatform(SDL_VideoDevice *_this)
30{
31 return true;
32}
33
34char *VIVANTE_GetDisplayName(SDL_VideoDevice *_this)
35{
36 return NULL;
37}
38
39void VIVANTE_UpdateDisplayScale(SDL_VideoDevice *_this)
40{
41}
42
43void VIVANTE_CleanupPlatform(SDL_VideoDevice *_this)
44{
45}
46
47#endif // VIVANTE_PLATFORM_GENERIC
48
49#endif // SDL_VIDEO_DRIVER_VIVANTE
diff --git a/contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteplatform.h b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteplatform.h
new file mode 100644
index 0000000..87babc0
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteplatform.h
@@ -0,0 +1,45 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21#include "SDL_internal.h"
22
23#ifndef SDL_vivanteplatform_h_
24#define SDL_vivanteplatform_h_
25
26#ifdef SDL_VIDEO_DRIVER_VIVANTE
27
28#include "SDL_vivantevideo.h"
29
30#ifdef CAVIUM
31#define VIVANTE_PLATFORM_CAVIUM
32#elif defined(MARVELL)
33#define VIVANTE_PLATFORM_MARVELL
34#else
35#define VIVANTE_PLATFORM_GENERIC
36#endif
37
38extern bool VIVANTE_SetupPlatform(SDL_VideoDevice *_this);
39extern char *VIVANTE_GetDisplayName(SDL_VideoDevice *_this);
40extern void VIVANTE_UpdateDisplayScale(SDL_VideoDevice *_this);
41extern void VIVANTE_CleanupPlatform(SDL_VideoDevice *_this);
42
43#endif // SDL_VIDEO_DRIVER_VIVANTE
44
45#endif // SDL_vivanteplatform_h_
diff --git a/contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevideo.c b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevideo.c
new file mode 100644
index 0000000..245c496
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevideo.c
@@ -0,0 +1,363 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21#include "SDL_internal.h"
22
23#ifdef SDL_VIDEO_DRIVER_VIVANTE
24
25// SDL internals
26#include "../SDL_sysvideo.h"
27#include "../../events/SDL_events_c.h"
28
29#ifdef SDL_INPUT_LINUXEV
30#include "../../core/linux/SDL_evdev.h"
31#endif
32
33#include "SDL_vivantevideo.h"
34#include "SDL_vivanteplatform.h"
35#include "SDL_vivanteopengles.h"
36#include "SDL_vivantevulkan.h"
37
38static void VIVANTE_Destroy(SDL_VideoDevice *device)
39{
40 SDL_free(device->internal);
41 SDL_free(device);
42}
43
44static SDL_VideoDevice *VIVANTE_Create(void)
45{
46 SDL_VideoDevice *device;
47 SDL_VideoData *data;
48
49 // Initialize SDL_VideoDevice structure
50 device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice));
51 if (!device) {
52 return NULL;
53 }
54
55 // Initialize internal data
56 data = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData));
57 if (!data) {
58 SDL_free(device);
59 return NULL;
60 }
61
62 device->internal = data;
63
64 // Setup amount of available displays
65 device->num_displays = 0;
66
67 // Set device free function
68 device->free = VIVANTE_Destroy;
69
70 // Setup all functions which we can handle
71 device->VideoInit = VIVANTE_VideoInit;
72 device->VideoQuit = VIVANTE_VideoQuit;
73 device->CreateSDLWindow = VIVANTE_CreateWindow;
74 device->SetWindowTitle = VIVANTE_SetWindowTitle;
75 device->SetWindowPosition = VIVANTE_SetWindowPosition;
76 device->SetWindowSize = VIVANTE_SetWindowSize;
77 device->ShowWindow = VIVANTE_ShowWindow;
78 device->HideWindow = VIVANTE_HideWindow;
79 device->DestroyWindow = VIVANTE_DestroyWindow;
80
81#ifdef SDL_VIDEO_OPENGL_EGL
82 device->GL_LoadLibrary = VIVANTE_GLES_LoadLibrary;
83 device->GL_GetProcAddress = VIVANTE_GLES_GetProcAddress;
84 device->GL_UnloadLibrary = VIVANTE_GLES_UnloadLibrary;
85 device->GL_CreateContext = VIVANTE_GLES_CreateContext;
86 device->GL_MakeCurrent = VIVANTE_GLES_MakeCurrent;
87 device->GL_SetSwapInterval = VIVANTE_GLES_SetSwapInterval;
88 device->GL_GetSwapInterval = VIVANTE_GLES_GetSwapInterval;
89 device->GL_SwapWindow = VIVANTE_GLES_SwapWindow;
90 device->GL_DestroyContext = VIVANTE_GLES_DestroyContext;
91#endif
92
93#ifdef SDL_VIDEO_VULKAN
94 device->Vulkan_LoadLibrary = VIVANTE_Vulkan_LoadLibrary;
95 device->Vulkan_UnloadLibrary = VIVANTE_Vulkan_UnloadLibrary;
96 device->Vulkan_GetInstanceExtensions = VIVANTE_Vulkan_GetInstanceExtensions;
97 device->Vulkan_CreateSurface = VIVANTE_Vulkan_CreateSurface;
98 device->Vulkan_DestroySurface = VIVANTE_Vulkan_DestroySurface;
99#endif
100
101 device->PumpEvents = VIVANTE_PumpEvents;
102
103 return device;
104}
105
106VideoBootStrap VIVANTE_bootstrap = {
107 "vivante",
108 "Vivante EGL Video Driver",
109 VIVANTE_Create,
110 NULL, // no ShowMessageBox implementation
111 false
112};
113
114/*****************************************************************************/
115// SDL Video and Display initialization/handling functions
116/*****************************************************************************/
117
118static bool VIVANTE_AddVideoDisplays(SDL_VideoDevice *_this)
119{
120 SDL_VideoData *videodata = _this->internal;
121 SDL_VideoDisplay display;
122 SDL_DisplayMode mode;
123 SDL_DisplayData *data;
124 int pitch = 0, bpp = 0;
125 unsigned long pixels = 0;
126
127 data = (SDL_DisplayData *)SDL_calloc(1, sizeof(SDL_DisplayData));
128 if (!data) {
129 return false;
130 }
131
132 SDL_zero(mode);
133#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK
134 data->native_display = vdkGetDisplay(videodata->vdk_private);
135
136 vdkGetDisplayInfo(data->native_display, &mode.w, &mode.h, &pixels, &pitch,
137 &bpp);
138#else
139 data->native_display = videodata->fbGetDisplayByIndex(0);
140
141 videodata->fbGetDisplayInfo(data->native_display, &mode.w, &mode.h,
142 &pixels, &pitch, &bpp);
143#endif // SDL_VIDEO_DRIVER_VIVANTE_VDK
144
145 switch (bpp) {
146 default: // Is another format used?
147 case 32:
148 mode.format = SDL_PIXELFORMAT_ARGB8888;
149 break;
150 case 16:
151 mode.format = SDL_PIXELFORMAT_RGB565;
152 break;
153 }
154 // FIXME: How do we query refresh rate?
155 mode.refresh_rate = 60.0f;
156
157 SDL_zero(display);
158 display.name = VIVANTE_GetDisplayName(_this);
159 display.desktop_mode = mode;
160 display.internal = data;
161 if (SDL_AddVideoDisplay(&display, false) == 0) {
162 return false;
163 }
164 return true;
165}
166
167bool VIVANTE_VideoInit(SDL_VideoDevice *_this)
168{
169 SDL_VideoData *videodata = _this->internal;
170
171#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK
172 videodata->vdk_private = vdkInitialize();
173 if (!videodata->vdk_private) {
174 return SDL_SetError("vdkInitialize() failed");
175 }
176#else
177 videodata->egl_handle = SDL_LoadObject("libEGL.so.1");
178 if (!videodata->egl_handle) {
179 videodata->egl_handle = SDL_LoadObject("libEGL.so");
180 if (!videodata->egl_handle) {
181 return false;
182 }
183 }
184#define LOAD_FUNC(TYPE, NAME) \
185 videodata->NAME = (TYPE)SDL_LoadFunction(videodata->egl_handle, #NAME); \
186 if (!videodata->NAME) \
187 return false;
188
189 LOAD_FUNC(EGLNativeDisplayType (EGLAPIENTRY *)(void *), fbGetDisplay);
190 LOAD_FUNC(EGLNativeDisplayType (EGLAPIENTRY *)(int), fbGetDisplayByIndex);
191 LOAD_FUNC(void (EGLAPIENTRY *)(EGLNativeDisplayType, int *, int *), fbGetDisplayGeometry);
192 LOAD_FUNC(void (EGLAPIENTRY *)(EGLNativeDisplayType, int *, int *, unsigned long *, int *, int *), fbGetDisplayInfo);
193 LOAD_FUNC(void (EGLAPIENTRY *)(EGLNativeDisplayType), fbDestroyDisplay);
194 LOAD_FUNC(EGLNativeWindowType (EGLAPIENTRY *)(EGLNativeDisplayType, int, int, int, int), fbCreateWindow);
195 LOAD_FUNC(void (EGLAPIENTRY *)(EGLNativeWindowType, int *, int *, int *, int *), fbGetWindowGeometry);
196 LOAD_FUNC(void (EGLAPIENTRY *)(EGLNativeWindowType, int *, int *, int *, int *, int *, unsigned int *), fbGetWindowInfo);
197 LOAD_FUNC(void (EGLAPIENTRY *)(EGLNativeWindowType), fbDestroyWindow);
198#endif
199
200 if (!VIVANTE_SetupPlatform(_this)) {
201 return false;
202 }
203
204 if (!VIVANTE_AddVideoDisplays(_this)) {
205 return false;
206 }
207
208 VIVANTE_UpdateDisplayScale(_this);
209
210#ifdef SDL_INPUT_LINUXEV
211 if (!SDL_EVDEV_Init()) {
212 return false;
213 }
214#endif
215
216 return true;
217}
218
219void VIVANTE_VideoQuit(SDL_VideoDevice *_this)
220{
221 SDL_VideoData *videodata = _this->internal;
222
223#ifdef SDL_INPUT_LINUXEV
224 SDL_EVDEV_Quit();
225#endif
226
227 VIVANTE_CleanupPlatform(_this);
228
229#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK
230 if (videodata->vdk_private) {
231 vdkExit(videodata->vdk_private);
232 videodata->vdk_private = NULL;
233 }
234#else
235 if (videodata->egl_handle) {
236 SDL_UnloadObject(videodata->egl_handle);
237 videodata->egl_handle = NULL;
238 }
239#endif
240}
241
242bool VIVANTE_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props)
243{
244 SDL_VideoData *videodata = _this->internal;
245 SDL_DisplayData *displaydata;
246 SDL_WindowData *data;
247
248 displaydata = SDL_GetDisplayDriverData(SDL_GetPrimaryDisplay());
249
250 // Allocate window internal data
251 data = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData));
252 if (!data) {
253 return false;
254 }
255
256 // Setup driver data for this window
257 window->internal = data;
258
259 SDL_PropertiesID props = SDL_GetWindowProperties(window);
260 SDL_SetPointerProperty(props, SDL_PROP_WINDOW_VIVANTE_DISPLAY_POINTER, displaydata->native_display);
261
262#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK
263 data->native_window = vdkCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h);
264#else
265 data->native_window = videodata->fbCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h);
266#endif
267 if (!data->native_window) {
268 return SDL_SetError("VIVANTE: Can't create native window");
269 }
270 SDL_SetPointerProperty(props, SDL_PROP_WINDOW_VIVANTE_WINDOW_POINTER, data->native_window);
271
272#ifdef SDL_VIDEO_OPENGL_EGL
273 if (window->flags & SDL_WINDOW_OPENGL) {
274 data->egl_surface = SDL_EGL_CreateSurface(_this, window, data->native_window);
275 if (data->egl_surface == EGL_NO_SURFACE) {
276 return SDL_SetError("VIVANTE: Can't create EGL surface");
277 }
278 } else {
279 data->egl_surface = EGL_NO_SURFACE;
280 }
281 SDL_SetPointerProperty(props, SDL_PROP_WINDOW_VIVANTE_SURFACE_POINTER, data->egl_surface);
282#endif
283
284 // Window has been successfully created
285 return true;
286}
287
288void VIVANTE_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window)
289{
290 SDL_VideoData *videodata = _this->internal;
291 SDL_WindowData *data;
292
293 data = window->internal;
294 if (data) {
295#ifdef SDL_VIDEO_OPENGL_EGL
296 if (data->egl_surface != EGL_NO_SURFACE) {
297 SDL_EGL_DestroySurface(_this, data->egl_surface);
298 }
299#endif
300
301 if (data->native_window) {
302#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK
303 vdkDestroyWindow(data->native_window);
304#else
305 videodata->fbDestroyWindow(data->native_window);
306#endif
307 }
308
309 SDL_free(data);
310 }
311 window->internal = NULL;
312}
313
314void VIVANTE_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window)
315{
316#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK
317 SDL_WindowData *data = window->internal;
318 vdkSetWindowTitle(data->native_window, window->title);
319#endif
320}
321
322bool VIVANTE_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window)
323{
324 // FIXME
325 return SDL_Unsupported();
326}
327
328void VIVANTE_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window)
329{
330 // FIXME
331}
332
333void VIVANTE_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window)
334{
335#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK
336 SDL_WindowData *data = window->internal;
337 vdkShowWindow(data->native_window);
338#endif
339 SDL_SetMouseFocus(window);
340 SDL_SetKeyboardFocus(window);
341}
342
343void VIVANTE_HideWindow(SDL_VideoDevice *_this, SDL_Window *window)
344{
345#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK
346 SDL_WindowData *data = window->internal;
347 vdkHideWindow(data->native_window);
348#endif
349 SDL_SetMouseFocus(NULL);
350 SDL_SetKeyboardFocus(NULL);
351}
352
353/*****************************************************************************/
354// SDL event functions
355/*****************************************************************************/
356void VIVANTE_PumpEvents(SDL_VideoDevice *_this)
357{
358#ifdef SDL_INPUT_LINUXEV
359 SDL_EVDEV_Poll();
360#endif
361}
362
363#endif // SDL_VIDEO_DRIVER_VIVANTE
diff --git a/contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevideo.h b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevideo.h
new file mode 100644
index 0000000..44399d9
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevideo.h
@@ -0,0 +1,86 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21#include "SDL_internal.h"
22
23#ifndef SDL_vivantevideo_h_
24#define SDL_vivantevideo_h_
25
26#include "../SDL_sysvideo.h"
27
28// Set up definitions for Vivante EGL
29#include <SDL3/SDL_egl.h>
30
31#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK
32#include <gc_vdk.h>
33#else
34#include <EGL/egl.h>
35#endif
36
37struct SDL_VideoData
38{
39#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK
40 vdkPrivate vdk_private;
41#else
42 SDL_SharedObject *egl_handle; // EGL shared library handle
43 EGLNativeDisplayType(EGLAPIENTRY *fbGetDisplay)(void *context);
44 EGLNativeDisplayType(EGLAPIENTRY *fbGetDisplayByIndex)(int DisplayIndex);
45 void(EGLAPIENTRY *fbGetDisplayGeometry)(EGLNativeDisplayType Display, int *Width, int *Height);
46 void(EGLAPIENTRY *fbGetDisplayInfo)(EGLNativeDisplayType Display, int *Width, int *Height, unsigned long *Physical, int *Stride, int *bits_per_pixel);
47 void(EGLAPIENTRY *fbDestroyDisplay)(EGLNativeDisplayType Display);
48 EGLNativeWindowType(EGLAPIENTRY *fbCreateWindow)(EGLNativeDisplayType Display, int X, int Y, int Width, int Height);
49 void(EGLAPIENTRY *fbGetWindowGeometry)(EGLNativeWindowType Window, int *X, int *Y, int *Width, int *Height);
50 void(EGLAPIENTRY *fbGetWindowInfo)(EGLNativeWindowType Window, int *X, int *Y, int *Width, int *Height, int *bits_per_pixel, unsigned int *Offset);
51 void(EGLAPIENTRY *fbDestroyWindow)(EGLNativeWindowType Window);
52#endif
53};
54
55struct SDL_DisplayData
56{
57 EGLNativeDisplayType native_display;
58};
59
60struct SDL_WindowData
61{
62 EGLNativeWindowType native_window;
63 EGLSurface egl_surface;
64};
65
66/****************************************************************************/
67// SDL_VideoDevice functions declaration
68/****************************************************************************/
69
70// Display and window functions
71bool VIVANTE_VideoInit(SDL_VideoDevice *_this);
72void VIVANTE_VideoQuit(SDL_VideoDevice *_this);
73bool VIVANTE_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display);
74bool VIVANTE_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode);
75bool VIVANTE_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props);
76void VIVANTE_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window);
77bool VIVANTE_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window);
78void VIVANTE_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window);
79void VIVANTE_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window);
80void VIVANTE_HideWindow(SDL_VideoDevice *_this, SDL_Window *window);
81void VIVANTE_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window);
82
83// Event functions
84void VIVANTE_PumpEvents(SDL_VideoDevice *_this);
85
86#endif // SDL_vivantevideo_h_
diff --git a/contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevulkan.c b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevulkan.c
new file mode 100644
index 0000000..a021a99
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevulkan.c
@@ -0,0 +1,154 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21#include "SDL_internal.h"
22
23/*
24 * @author Wladimir J. van der Laan. Based on Jacob Lifshay's
25 * SDL_x11vulkan.c, Mark Callow's SDL_androidvulkan.c, and
26 * the FSL demo framework.
27 */
28
29#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_VIVANTE)
30
31#include "../SDL_vulkan_internal.h"
32
33#include "SDL_vivantevideo.h"
34
35#include "SDL_vivantevulkan.h"
36
37bool VIVANTE_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path)
38{
39 VkExtensionProperties *extensions = NULL;
40 Uint32 i, extensionCount = 0;
41 bool hasSurfaceExtension = false;
42 bool hasDisplayExtension = false;
43 PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL;
44 if (_this->vulkan_config.loader_handle) {
45 return SDL_SetError("Vulkan already loaded");
46 }
47
48 // Load the Vulkan loader library
49 if (!path) {
50 path = SDL_GetHint(SDL_HINT_VULKAN_LIBRARY);
51 }
52 if (!path) {
53 // If no path set, try Vivante fb vulkan driver explicitly
54 path = "libvulkan-fb.so";
55 _this->vulkan_config.loader_handle = SDL_LoadObject(path);
56 if (!_this->vulkan_config.loader_handle) {
57 // If that couldn't be loaded, fall back to default name
58 path = "libvulkan.so";
59 _this->vulkan_config.loader_handle = SDL_LoadObject(path);
60 }
61 } else {
62 _this->vulkan_config.loader_handle = SDL_LoadObject(path);
63 }
64 if (!_this->vulkan_config.loader_handle) {
65 return false;
66 }
67 SDL_strlcpy(_this->vulkan_config.loader_path, path,
68 SDL_arraysize(_this->vulkan_config.loader_path));
69 SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vivante: Loaded vulkan driver %s", path);
70 vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_LoadFunction(
71 _this->vulkan_config.loader_handle, "vkGetInstanceProcAddr");
72 if (!vkGetInstanceProcAddr) {
73 goto fail;
74 }
75 _this->vulkan_config.vkGetInstanceProcAddr = (void *)vkGetInstanceProcAddr;
76 _this->vulkan_config.vkEnumerateInstanceExtensionProperties =
77 (void *)((PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr)(
78 VK_NULL_HANDLE, "vkEnumerateInstanceExtensionProperties");
79 if (!_this->vulkan_config.vkEnumerateInstanceExtensionProperties) {
80 goto fail;
81 }
82 extensions = SDL_Vulkan_CreateInstanceExtensionsList(
83 (PFN_vkEnumerateInstanceExtensionProperties)
84 _this->vulkan_config.vkEnumerateInstanceExtensionProperties,
85 &extensionCount);
86 if (!extensions) {
87 goto fail;
88 }
89 for (i = 0; i < extensionCount; i++) {
90 if (SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) {
91 hasSurfaceExtension = true;
92 } else if (SDL_strcmp(VK_KHR_DISPLAY_EXTENSION_NAME, extensions[i].extensionName) == 0) {
93 hasDisplayExtension = true;
94 }
95 }
96 SDL_free(extensions);
97 if (!hasSurfaceExtension) {
98 SDL_SetError("Installed Vulkan doesn't implement the " VK_KHR_SURFACE_EXTENSION_NAME " extension");
99 goto fail;
100 } else if (!hasDisplayExtension) {
101 SDL_SetError("Installed Vulkan doesn't implement the " VK_KHR_DISPLAY_EXTENSION_NAME "extension");
102 goto fail;
103 }
104 return true;
105
106fail:
107 SDL_UnloadObject(_this->vulkan_config.loader_handle);
108 _this->vulkan_config.loader_handle = NULL;
109 return false;
110}
111
112void VIVANTE_Vulkan_UnloadLibrary(SDL_VideoDevice *_this)
113{
114 if (_this->vulkan_config.loader_handle) {
115 SDL_UnloadObject(_this->vulkan_config.loader_handle);
116 _this->vulkan_config.loader_handle = NULL;
117 }
118}
119
120char const* const* VIVANTE_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this,
121 Uint32 *count)
122{
123 static const char *const extensionsForVivante[] = {
124 VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_DISPLAY_EXTENSION_NAME
125 };
126 if (count) {
127 *count = SDL_arraysize(extensionsForVivante);
128 }
129 return extensionsForVivante;
130}
131
132bool VIVANTE_Vulkan_CreateSurface(SDL_VideoDevice *_this,
133 SDL_Window *window,
134 VkInstance instance,
135 const struct VkAllocationCallbacks *allocator,
136 VkSurfaceKHR *surface)
137{
138 if (!_this->vulkan_config.loader_handle) {
139 return SDL_SetError("Vulkan is not loaded");
140 }
141 return SDL_Vulkan_Display_CreateSurface(_this->vulkan_config.vkGetInstanceProcAddr, instance, allocator, surface);
142}
143
144void VIVANTE_Vulkan_DestroySurface(SDL_VideoDevice *_this,
145 VkInstance instance,
146 VkSurfaceKHR surface,
147 const struct VkAllocationCallbacks *allocator)
148{
149 if (_this->vulkan_config.loader_handle) {
150 SDL_Vulkan_DestroySurface_Internal(_this->vulkan_config.vkGetInstanceProcAddr, instance, surface, allocator);
151 }
152}
153
154#endif
diff --git a/contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevulkan.h b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevulkan.h
new file mode 100644
index 0000000..49f14d3
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevulkan.h
@@ -0,0 +1,51 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21#include "SDL_internal.h"
22
23/*
24 * @author Wladimir J. van der Laan. Based on Jacob Lifshay's
25 * SDL_x11vulkan.h and Mark Callow's SDL_vivantevulkan.h
26 */
27
28#ifndef SDL_vivantevulkan_h_
29#define SDL_vivantevulkan_h_
30
31#include "../SDL_vulkan_internal.h"
32#include "../SDL_sysvideo.h"
33
34#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_VIVANTE)
35
36extern bool VIVANTE_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path);
37extern void VIVANTE_Vulkan_UnloadLibrary(SDL_VideoDevice *_this);
38extern char const* const* VIVANTE_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, Uint32 *count);
39extern bool VIVANTE_Vulkan_CreateSurface(SDL_VideoDevice *_this,
40 SDL_Window *window,
41 VkInstance instance,
42 const struct VkAllocationCallbacks *allocator,
43 VkSurfaceKHR *surface);
44extern void VIVANTE_Vulkan_DestroySurface(SDL_VideoDevice *_this,
45 VkInstance instance,
46 VkSurfaceKHR surface,
47 const struct VkAllocationCallbacks *allocator);
48
49#endif
50
51#endif // SDL_vivantevulkan_h_