patch sdl3 shaders, got something on screen!

This commit is contained in:
olebeck 2025-06-22 13:27:21 +02:00
parent cb4fcc55ba
commit 3f8b36b323
4 changed files with 84 additions and 16 deletions

View File

@ -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()

View File

@ -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()

View File

@ -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"

View File

@ -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)) {