diff --git a/CMakeLists.txt b/CMakeLists.txt index f357fd16..eb131fba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,20 +75,7 @@ if(VITA) include(FetchContent) include(cmake/modules/pvr_psp2.cmake) - - FetchContent_Declare( - SDL3 - GIT_REPOSITORY "https://github.com/libsdl-org/SDL.git" - GIT_TAG "main" - EXCLUDE_FROM_ALL - ) - block() - set(VIDEO_VITA_PVR ON) - get_target_property(PVR_INCLUDES GLESv2 INTERFACE_INCLUDE_DIRECTORIES) - list(APPEND CMAKE_REQUIRED_INCLUDES ${PVR_INCLUDES}) - FetchContent_MakeAvailable(SDL3) - target_include_directories(SDL3-static PRIVATE ${PVR_INCLUDES}) - endblock() + include(cmake/modules/sdl3_pvr_psp2.cmake) fetch_iniparser() diff --git a/cmake/modules/sdl3_pvr_psp2.cmake b/cmake/modules/sdl3_pvr_psp2.cmake new file mode 100644 index 00000000..fc44b69b --- /dev/null +++ b/cmake/modules/sdl3_pvr_psp2.cmake @@ -0,0 +1,33 @@ +cmake_minimum_required(VERSION 3.21) + +include(FetchContent) + +set(SDL3_PATCH_FILE "${CMAKE_CURRENT_LIST_DIR}/sdl3_vita_shaders_fix.patch") + +FetchContent_Declare( + SDL3 + GIT_REPOSITORY "https://github.com/libsdl-org/SDL.git" + GIT_TAG "main" + EXCLUDE_FROM_ALL +) + +FetchContent_GetProperties(SDL3) + +if(NOT SDL3_POPULATED) + FetchContent_Populate(SDL3) + execute_process( + COMMAND git apply --verbose "${SDL3_PATCH_FILE}" + WORKING_DIRECTORY "${sdl3_SOURCE_DIR}" + RESULT_VARIABLE APPLY_RESULT + ) + if(NOT APPLY_RESULT EQUAL 0) + message(FATAL_ERROR "Failed to apply patch to SDL3") + endif() +endif() + +block() + set(VIDEO_VITA_PVR ON) + get_target_property(PVR_INCLUDES GLESv2 INTERFACE_INCLUDE_DIRECTORIES) + list(APPEND CMAKE_REQUIRED_INCLUDES ${PVR_INCLUDES}) + add_subdirectory(${sdl3_SOURCE_DIR} ${sdl3_BINARY_DIR}) +endblock() diff --git a/cmake/modules/sdl3_vita_shaders_fix.patch b/cmake/modules/sdl3_vita_shaders_fix.patch new file mode 100644 index 00000000..05e88ab3 --- /dev/null +++ b/cmake/modules/sdl3_vita_shaders_fix.patch @@ -0,0 +1,46 @@ +--- sdl3-src/src/render/opengles2/SDL_shaders_gles2.c 2025-06-22 13:18:27.905488716 +0200 ++++ "sdl3-src/src/render/opengles2/SDL_shaders_gles2.c" 2025-06-22 13:18:21.377485749 +0200 +@@ -130,9 +130,7 @@ + "void main()\n" + "{\n" + " mediump vec4 color = texture2D(u_texture, v_texCoord);\n" +-" gl_FragColor = color;\n" +-" gl_FragColor.r = color.b;\n" +-" gl_FragColor.b = color.r;\n" ++" gl_FragColor.rgba = color.bgra;\n" + " gl_FragColor *= v_color;\n" + "}\n" + ; +@@ -144,9 +142,7 @@ + "void main()\n" + "{\n" + " mediump vec4 color = texture2D(u_texture, v_texCoord);\n" +-" gl_FragColor = color;\n" +-" gl_FragColor.r = color.b;\n" +-" gl_FragColor.b = color.r;\n" ++" gl_FragColor.rgb = color.bgr;\n" + " gl_FragColor.a = 1.0;\n" + " gl_FragColor *= v_color;\n" + "}\n" +@@ -183,9 +179,7 @@ + "void main()\n" + "{\n" + RGB_PIXELART_GETCOLOR +-" gl_FragColor = color;\n" +-" gl_FragColor.r = color.b;\n" +-" gl_FragColor.b = color.r;\n" ++" gl_FragColor.rgba = color.bgra;\n" + " gl_FragColor *= v_color;\n" + "}\n" + ; +@@ -197,9 +191,7 @@ + "void main()\n" + "{\n" + RGB_PIXELART_GETCOLOR +-" gl_FragColor = color;\n" +-" gl_FragColor.r = color.b;\n" +-" gl_FragColor.b = color.r;\n" ++" gl_FragColor.rgb = color.bgr;\n" + " gl_FragColor.a = 1.0;\n" + " gl_FragColor *= v_color;\n" + "}\n" diff --git a/miniwin/src/ddraw/ddraw.cpp b/miniwin/src/ddraw/ddraw.cpp index 107384aa..d0ba9995 100644 --- a/miniwin/src/ddraw/ddraw.cpp +++ b/miniwin/src/ddraw/ddraw.cpp @@ -296,9 +296,11 @@ HRESULT DirectDrawImpl::SetCooperativeLevel(HWND hWnd, DDSCLFlags dwFlags) return DDERR_INVALIDPARAMS; } - char* sdlRendererName = nullptr; + #ifdef __vita__ - sdlRendererName = "opengles2"; + const char* sdlRendererName = "opengles2"; +#else + const char* sdlRendererName = nullptr; #endif if (!SDL_SetWindowFullscreen(sdlWindow, fullscreen)) {