From 48857d849dd33dcc704998bf62df2700be8b80ff Mon Sep 17 00:00:00 2001 From: scribam Date: Sat, 22 Jul 2023 21:15:41 +0200 Subject: [PATCH] vita: updates and fixes --- CMakeLists.txt | 46 +++++++++++-------- .../imgui/backends/imgui_impl_opengl3.cpp | 2 + core/deps/vixl/code-buffer-vixl.cc | 2 - core/linux-dist/main.cpp | 2 +- core/rend/gles/gles.cpp | 2 + shell/libretro/libretro.cpp | 4 ++ shell/libretro/oslib.cpp | 4 ++ 7 files changed, 39 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dc8a1ee78a..68d639b5e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -137,15 +137,17 @@ if(VITA) set(USE_GLES2 ON) enable_language(ASM) - add_executable(${PROJECT_NAME} core/emulator.cpp) - target_compile_definitions(${PROJECT_NAME} PRIVATE EGL_NO_PLATFORM_SPECIFIC_TYPES) - # target_compile_definitions(${PROJECT_NAME} PRIVATE TARGET_NO_EXCEPTIONS) - target_compile_definitions(${PROJECT_NAME} PRIVATE VITA _GNU_SOURCE) - target_compile_definitions(${PROJECT_NAME} PRIVATE GLES) - - # For proper fseek/ftell definition in external dependency "libchdr", doesn't impact anything else: - target_compile_definitions(${PROJECT_NAME} PRIVATE __PS3__) + if(LIBRETRO) + add_library(${PROJECT_NAME} STATIC core/emulator.cpp) + target_compile_definitions(${PROJECT_NAME} PRIVATE LIBRETRO VITA) + set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "flycast_libretro_vita") + else() + add_executable(${PROJECT_NAME} core/emulator.cpp) + target_compile_definitions(${PROJECT_NAME} PRIVATE EGL_NO_PLATFORM_SPECIFIC_TYPES) + endif() + target_compile_definitions(${PROJECT_NAME} PRIVATE _GNU_SOURCE) + target_compile_definitions(${PROJECT_NAME} PRIVATE GLES) elseif(NINTENDO_SWITCH) set(USE_VULKAN OFF) enable_language(ASM) @@ -638,7 +640,7 @@ target_sources(${PROJECT_NAME} PRIVATE core/deps/chdpsr/cdipsr.h) add_subdirectory(core/deps/nowide EXCLUDE_FROM_ALL) -target_compile_definitions(nowide PRIVATE $<$:_DEFAULT_SOURCE>) +target_compile_definitions(nowide PRIVATE $<$:_DEFAULT_SOURCE> $<$:_GNU_SOURCE>) target_link_libraries(${PROJECT_NAME} PRIVATE nowide::nowide) if(NOT MINIUPNP_FOUND) @@ -659,7 +661,7 @@ if(NOT MINIUPNP_FOUND) endif() endif() -if(NOT LIBZIP_FOUND OR NINTENDO_SWITCH OR VITA) +if(NOT LIBZIP_FOUND OR NINTENDO_SWITCH) option(ENABLE_COMMONCRYPTO "Enable use of CommonCrypto" OFF) option(ENABLE_GNUTLS "Enable use of GnuTLS" OFF) option(ENABLE_MBEDTLS "Enable use of mbed TLS" OFF) @@ -1867,16 +1869,20 @@ if(NINTENDO_SWITCH) endif() if(VITA) - vita_create_self(eboot.bin ${PROJECT_NAME} UNSAFE STRIPPED NOASLR) - vita_create_vpk(${VITA_VPKNAME}.vpk ${VITA_TITLEID} eboot.bin - VERSION ${VITA_VERSION} - NAME ${VITA_APP_NAME} - FILE ${CMAKE_SOURCE_DIR}/shell/vita/icon0.png sce_sys/icon0.png - ${CMAKE_SOURCE_DIR}/shell/vita/startup.png sce_sys/livearea/contents/startup.png - ${CMAKE_SOURCE_DIR}/shell/vita/bg.png sce_sys/livearea/contents/bg.png - ${CMAKE_SOURCE_DIR}/shell/vita/template.xml sce_sys/livearea/contents/template.xml - ${VPK_INCLUDES} - ) + if(LIBRETRO) + # TODO? + else() + vita_create_self(eboot.bin ${PROJECT_NAME} UNSAFE STRIPPED NOASLR) + vita_create_vpk(${VITA_VPKNAME}.vpk ${VITA_TITLEID} eboot.bin + VERSION ${VITA_VERSION} + NAME ${VITA_APP_NAME} + FILE ${CMAKE_SOURCE_DIR}/shell/vita/icon0.png sce_sys/icon0.png + ${CMAKE_SOURCE_DIR}/shell/vita/startup.png sce_sys/livearea/contents/startup.png + ${CMAKE_SOURCE_DIR}/shell/vita/bg.png sce_sys/livearea/contents/bg.png + ${CMAKE_SOURCE_DIR}/shell/vita/template.xml sce_sys/livearea/contents/template.xml + ${VPK_INCLUDES} + ) + endif() endif() if(IOS) diff --git a/core/deps/imgui/backends/imgui_impl_opengl3.cpp b/core/deps/imgui/backends/imgui_impl_opengl3.cpp index c0d2a17069..d2653f76ab 100644 --- a/core/deps/imgui/backends/imgui_impl_opengl3.cpp +++ b/core/deps/imgui/backends/imgui_impl_opengl3.cpp @@ -502,8 +502,10 @@ static bool ImGui_ImplOpenGL3_CreateDeviceObjects() glLinkProgram(g_ShaderHandle); CheckProgram(g_ShaderHandle, "shader program"); +#ifndef __vita__ glDetachShader(g_ShaderHandle, vert_handle); glDetachShader(g_ShaderHandle, frag_handle); +#endif glDeleteShader(vert_handle); glDeleteShader(frag_handle); diff --git a/core/deps/vixl/code-buffer-vixl.cc b/core/deps/vixl/code-buffer-vixl.cc index b22ba3320d..2cfe8b71d3 100644 --- a/core/deps/vixl/code-buffer-vixl.cc +++ b/core/deps/vixl/code-buffer-vixl.cc @@ -25,12 +25,10 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifdef VIXL_CODE_BUFFER_MMAP -#ifndef __vita__ extern "C" { #include } #endif -#endif #include "code-buffer-vixl.h" #include "utils-vixl.h" diff --git a/core/linux-dist/main.cpp b/core/linux-dist/main.cpp index 1940efdb10..8a87e8699a 100644 --- a/core/linux-dist/main.cpp +++ b/core/linux-dist/main.cpp @@ -220,7 +220,7 @@ std::string find_user_data_dir() #endif } -#ifndef __SWITCH__ +#if !defined(__SWITCH__) && !defined(__vita__) static void addDirectoriesFromPath(std::vector& dirs, const std::string& path, const std::string& suffix) { std::string::size_type pos = 0; diff --git a/core/rend/gles/gles.cpp b/core/rend/gles/gles.cpp index adcfc69676..f77577b5db 100644 --- a/core/rend/gles/gles.cpp +++ b/core/rend/gles/gles.cpp @@ -973,8 +973,10 @@ GLuint gl_CompileAndLink(const char *vertexShader, const char *fragmentShader) INFO_LOG(RENDERER, "// FRAGMENT SHADER\n%s\n// END", fragmentShader); die("shader compile fail\n"); } +#ifndef __vita__ glDetachShader(program, vs); glDetachShader(program, ps); +#endif glDeleteShader(vs); glDeleteShader(ps); diff --git a/shell/libretro/libretro.cpp b/shell/libretro/libretro.cpp index cbe6be9d33..2e74ec29c4 100644 --- a/shell/libretro/libretro.cpp +++ b/shell/libretro/libretro.cpp @@ -29,6 +29,10 @@ #include "nswitch.h" #endif +#ifdef __vita__ +#include // for PATH_MAX +#endif + #include #include diff --git a/shell/libretro/oslib.cpp b/shell/libretro/oslib.cpp index 4f7bfa8729..e52158ad20 100644 --- a/shell/libretro/oslib.cpp +++ b/shell/libretro/oslib.cpp @@ -20,6 +20,10 @@ #include "stdclass.h" #include "file/file_path.h" +#ifdef __vita__ +#include // for PATH_MAX +#endif + const char *retro_get_system_directory(); extern char game_dir_no_slash[1024];