From 3cb819ac48cf96a7ffc5156153fa3eb2f266cd38 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sun, 22 Jan 2023 21:02:35 +0100 Subject: [PATCH] vita: fix PVR_PSP2 (GLES) + gl4es4fita (GL) --- CMakeLists.txt | 1 + include/SDL3/SDL_egl.h | 2 ++ src/video/SDL_egl.c | 3 +++ src/video/vita/SDL_vitagl_pvr.c | 40 ++++++++++++++++----------------- src/video/vita/SDL_vitagles.c | 5 +++-- src/video/vita/SDL_vitagles_c.h | 2 +- src/video/vita/SDL_vitavideo.h | 2 +- 7 files changed, 31 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 52fe32684..123520cd9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2460,6 +2460,7 @@ elseif(VITA) list(APPEND SDL_EXTRA_LIBS libgpu_es4_ext_stub_weak libIMGEGL_stub_weak + SceIme_stub ) set(HAVE_VIDEO_VITA_PVR ON) diff --git a/include/SDL3/SDL_egl.h b/include/SDL3/SDL_egl.h index 6f51c0831..077c6e202 100644 --- a/include/SDL3/SDL_egl.h +++ b/include/SDL3/SDL_egl.h @@ -27,6 +27,8 @@ #if !defined(_MSC_VER) && !defined(__ANDROID__) && !defined(SDL_USE_BUILTIN_OPENGL_DEFINITIONS) #if defined(__vita__) || defined(__psp2__) +#include +#include #include #endif diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c index d3b1e4b8c..f00b7db38 100644 --- a/src/video/SDL_egl.c +++ b/src/video/SDL_egl.c @@ -32,6 +32,9 @@ #if SDL_VIDEO_DRIVER_RPI #include #endif +#if SDL_VIDEO_VITA_PVR_OGL +#include +#endif #include "SDL_sysvideo.h" #include "SDL_egl_c.h" diff --git a/src/video/vita/SDL_vitagl_pvr.c b/src/video/vita/SDL_vitagl_pvr.c index b5c60e74e..6a2467752 100644 --- a/src/video/vita/SDL_vitagl_pvr.c +++ b/src/video/vita/SDL_vitagl_pvr.c @@ -34,10 +34,10 @@ #define MAX_PATH 256 // vita limits are somehow wrong /* Defaults */ -int FB_WIDTH = 960; -int FB_HEIGHT = 544; +static int FB_WIDTH = 960; +static int FB_HEIGHT = 544; -void getFBSize(int *width, int *height) +static void getFBSize(int *width, int *height) { *width = FB_WIDTH; *height = FB_HEIGHT; @@ -51,33 +51,33 @@ int VITA_GL_LoadLibrary(_THIS, const char *path) char *default_path = "app0:module"; char target_path[MAX_PATH]; - if (skip_init == NULL) // we don't care about actual value { + if (skip_init == NULL) { // we don't care about actual value if (override != NULL) { default_path = override; } - sceKernelLoadStartModule("vs0:sys/external/libfios2.suprx", 0, NULL, 0, NULL, NULL); - sceKernelLoadStartModule("vs0:sys/external/libc.suprx", 0, NULL, 0, NULL, NULL); + sceKernelLoadStartModule("vs0:sys/external/libfios2.suprx", 0, NULL, 0, NULL, NULL); + sceKernelLoadStartModule("vs0:sys/external/libc.suprx", 0, NULL, 0, NULL, NULL); - SDL_snprintf(target_path, MAX_PATH, "%s/%s", default_path, "libGL.suprx"); - sceKernelLoadStartModule(target_path, 0, NULL, 0, NULL, NULL); + SDL_snprintf(target_path, MAX_PATH, "%s/%s", default_path, "libGL.suprx"); + sceKernelLoadStartModule(target_path, 0, NULL, 0, NULL, NULL); - SDL_snprintf(target_path, MAX_PATH, "%s/%s", default_path, "libgpu_es4_ext.suprx"); - sceKernelLoadStartModule(target_path, 0, NULL, 0, NULL, NULL); + SDL_snprintf(target_path, MAX_PATH, "%s/%s", default_path, "libgpu_es4_ext.suprx"); + sceKernelLoadStartModule(target_path, 0, NULL, 0, NULL, NULL); - SDL_snprintf(target_path, MAX_PATH, "%s/%s", default_path, "libIMGEGL.suprx"); - sceKernelLoadStartModule(target_path, 0, NULL, 0, NULL, NULL); + SDL_snprintf(target_path, MAX_PATH, "%s/%s", default_path, "libIMGEGL.suprx"); + sceKernelLoadStartModule(target_path, 0, NULL, 0, NULL, NULL); - PVRSRVInitializeAppHint(&hint); + PVRSRVInitializeAppHint(&hint); - SDL_snprintf(hint.szGLES1, MAX_PATH, "%s/%s", default_path, "libGLESv1_CM.suprx"); - SDL_snprintf(hint.szGLES2, MAX_PATH, "%s/%s", default_path, "libGLESv2.suprx"); - SDL_snprintf(hint.szWindowSystem, MAX_PATH, "%s/%s", default_path, "libpvrPSP2_WSEGL.suprx"); + SDL_snprintf(hint.szGLES1, MAX_PATH, "%s/%s", default_path, "libGLESv1_CM.suprx"); + SDL_snprintf(hint.szGLES2, MAX_PATH, "%s/%s", default_path, "libGLESv2.suprx"); + SDL_snprintf(hint.szWindowSystem, MAX_PATH, "%s/%s", default_path, "libpvrPSP2_WSEGL.suprx"); - PVRSRVCreateVirtualAppHint(&hint); -} + PVRSRVCreateVirtualAppHint(&hint); + } -return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)0, 0); + return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)0, 0); } SDL_GLContext @@ -115,7 +115,7 @@ VITA_GL_CreateContext(_THIS, SDL_Window *window) return context; } -void * +SDL_FunctionPointer VITA_GL_GetProcAddress(_THIS, const char *proc) { return gl4es_GetProcAddress(proc); diff --git a/src/video/vita/SDL_vitagles.c b/src/video/vita/SDL_vitagles.c index ae0a9892c..f527c4b3b 100644 --- a/src/video/vita/SDL_vitagles.c +++ b/src/video/vita/SDL_vitagles.c @@ -177,9 +177,10 @@ int VITA_GLES_SetSwapInterval(_THIS, int interval) return SDL_SetError("Unable to set the EGL swap interval"); } -int VITA_GLES_GetSwapInterval(_THIS) +int VITA_GLES_GetSwapInterval(_THIS, int *interval) { - return _this->gl_data->swapinterval; + *interval = _this->gl_data->swapinterval; + return 0; } int VITA_GLES_SwapWindow(_THIS, SDL_Window *window) diff --git a/src/video/vita/SDL_vitagles_c.h b/src/video/vita/SDL_vitagles_c.h index 5659a4ef5..bb98699ce 100644 --- a/src/video/vita/SDL_vitagles_c.h +++ b/src/video/vita/SDL_vitagles_c.h @@ -48,6 +48,6 @@ extern SDL_GLContext VITA_GLES_CreateContext(_THIS, SDL_Window *window); extern int VITA_GLES_LoadLibrary(_THIS, const char *path); extern void VITA_GLES_UnloadLibrary(_THIS); extern int VITA_GLES_SetSwapInterval(_THIS, int interval); -extern int VITA_GLES_GetSwapInterval(_THIS); +extern int VITA_GLES_GetSwapInterval(_THIS, int *interval); #endif /* SDL_vitagles_c_h_ */ diff --git a/src/video/vita/SDL_vitavideo.h b/src/video/vita/SDL_vitavideo.h index 68a34577f..497947be0 100644 --- a/src/video/vita/SDL_vitavideo.h +++ b/src/video/vita/SDL_vitavideo.h @@ -97,7 +97,7 @@ void VITA_GLES_UnloadLibrary(_THIS); SDL_GLContext VITA_GLES_CreateContext(_THIS, SDL_Window *window); int VITA_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context); int VITA_GLES_SetSwapInterval(_THIS, int interval); -int VITA_GLES_GetSwapInterval(_THIS); +int VITA_GLES_GetSwapInterval(_THIS, int *interval); int VITA_GLES_SwapWindow(_THIS, SDL_Window *window); void VITA_GLES_DeleteContext(_THIS, SDL_GLContext context); #endif