mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-19 05:41:17 +00:00
remove some unneeded changes
This commit is contained in:
parent
a6b90abcca
commit
2aeeff7d07
18
.github/workflows/ci.yml
vendored
18
.github/workflows/ci.yml
vendored
@ -41,6 +41,7 @@ jobs:
|
|||||||
- { name: 'msys2 mingw64', os: 'windows-latest', dx5: false, config: true, build-type: 'Debug', mingw: true, werror: true, clang-tidy: true, msystem: 'mingw64', msys-env: 'mingw-w64-x86_64', shell: 'msys2 {0}' }
|
- { name: 'msys2 mingw64', os: 'windows-latest', dx5: false, config: true, build-type: 'Debug', mingw: true, werror: true, clang-tidy: true, msystem: 'mingw64', msys-env: 'mingw-w64-x86_64', shell: 'msys2 {0}' }
|
||||||
- { name: 'macOS', os: 'macos-latest', dx5: false, config: true, build-type: 'Debug', brew: true, werror: true, clang-tidy: false }
|
- { name: 'macOS', os: 'macos-latest', dx5: false, config: true, build-type: 'Debug', brew: true, werror: true, clang-tidy: false }
|
||||||
- { name: 'Emscripten', os: 'ubuntu-latest', dx5: false, config: false, build-type: 'Debug', emsdk: true, werror: true, clang-tidy: false, cmake-wrapper: 'emcmake' }
|
- { name: 'Emscripten', os: 'ubuntu-latest', dx5: false, config: false, build-type: 'Debug', emsdk: true, werror: true, clang-tidy: false, cmake-wrapper: 'emcmake' }
|
||||||
|
- { name: 'Vita', os: 'ubuntu-latest', dx5: false, config: false, build-type: 'Debug', vita: true, werror: true, clang-tidy: false }
|
||||||
steps:
|
steps:
|
||||||
- name: Setup vcvars
|
- name: Setup vcvars
|
||||||
if: ${{ !!matrix.msvc }}
|
if: ${{ !!matrix.msvc }}
|
||||||
@ -83,12 +84,27 @@ jobs:
|
|||||||
- name: Setup ninja
|
- name: Setup ninja
|
||||||
if: ${{ matrix.msvc }}
|
if: ${{ matrix.msvc }}
|
||||||
uses: ashutoshvarma/setup-ninja@master
|
uses: ashutoshvarma/setup-ninja@master
|
||||||
|
|
||||||
|
- name: Setup vitasdk
|
||||||
|
if: ${{ matrix.vita }}
|
||||||
|
run: |
|
||||||
|
git clone https://github.com/vitasdk/vdpm
|
||||||
|
cd vdpm
|
||||||
|
./bootstrap-vitasdk.sh
|
||||||
|
./install-all.sh
|
||||||
|
echo "VITASDK=/usr/local/vitasdk" >> $GITHUB_ENV
|
||||||
|
echo "PATH=$VITASDK/bin:$PATH" >> $GITHUB_ENV
|
||||||
|
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Configure (CMake)
|
- name: Configure (CMake)
|
||||||
run: |
|
run: |
|
||||||
${{ matrix.cmake-wrapper || '' }} cmake -S . -B build -GNinja \
|
if [ "${{ matrix.vita }}" = "true" ]; then
|
||||||
|
echo "PRESET=--preset vita-debug" >> $GITHUB_ENV
|
||||||
|
else
|
||||||
|
echo "PRESET=" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
${{ matrix.cmake-wrapper || '' }} cmake $PRESET -S . -B build -GNinja \
|
||||||
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \
|
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \
|
||||||
-DISLE_USE_DX5=${{ !!matrix.dx5 }} \
|
-DISLE_USE_DX5=${{ !!matrix.dx5 }} \
|
||||||
-DISLE_BUILD_CONFIG=${{ matrix.config }} \
|
-DISLE_BUILD_CONFIG=${{ matrix.config }} \
|
||||||
|
|||||||
6
3rdparty/CMakeLists.txt
vendored
6
3rdparty/CMakeLists.txt
vendored
@ -68,13 +68,7 @@ add_library(imgui STATIC
|
|||||||
${imgui_SOURCE_DIR}/backends/imgui_impl_sdl3.cpp
|
${imgui_SOURCE_DIR}/backends/imgui_impl_sdl3.cpp
|
||||||
${imgui_SOURCE_DIR}/backends/imgui_impl_sdlrenderer3.cpp
|
${imgui_SOURCE_DIR}/backends/imgui_impl_sdlrenderer3.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(imgui PUBLIC ${imgui_SOURCE_DIR})
|
target_include_directories(imgui PUBLIC ${imgui_SOURCE_DIR})
|
||||||
target_link_libraries(imgui PUBLIC SDL3::Headers)
|
target_link_libraries(imgui PUBLIC SDL3::Headers)
|
||||||
target_link_libraries(imgui PRIVATE SDL3::SDL3)
|
target_link_libraries(imgui PRIVATE SDL3::SDL3)
|
||||||
set_property(TARGET imgui PROPERTY CXX_CLANG_TIDY "")
|
set_property(TARGET imgui PROPERTY CXX_CLANG_TIDY "")
|
||||||
if(VITA)
|
|
||||||
target_compile_definitions(imgui PRIVATE
|
|
||||||
IMGUI_DISABLE_DEFAULT_SHELL_FUNCTIONS
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|||||||
@ -48,8 +48,6 @@ if(VITA)
|
|||||||
set(BUILD_SHARED_LIBS OFF)
|
set(BUILD_SHARED_LIBS OFF)
|
||||||
set(ISLE_DEBUG OFF)
|
set(ISLE_DEBUG OFF)
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE OFF)
|
set(CMAKE_POSITION_INDEPENDENT_CODE OFF)
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/modules")
|
|
||||||
#set(VITA_USE_OPENGLES2 ON)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
message(STATUS "Isle app: ${ISLE_BUILD_APP}")
|
message(STATUS "Isle app: ${ISLE_BUILD_APP}")
|
||||||
@ -65,37 +63,20 @@ if (DOWNLOAD_DEPENDENCIES)
|
|||||||
# FetchContent downloads and configures dependencies
|
# FetchContent downloads and configures dependencies
|
||||||
message(STATUS "Fetching SDL3 and iniparser. This might take a while...")
|
message(STATUS "Fetching SDL3 and iniparser. This might take a while...")
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
|
|
||||||
if(VITA)
|
|
||||||
#set(SDL_PATCH "${CMAKE_CURRENT_LIST_DIR}/cmake/modules/sdl3_vita_shaders_fix.patch")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(VITA_USE_OPENGLES2)
|
|
||||||
include(cmake/modules/pvr_psp2.cmake)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
SDL3
|
SDL3
|
||||||
GIT_REPOSITORY "https://github.com/libsdl-org/SDL.git"
|
GIT_REPOSITORY "https://github.com/libsdl-org/SDL.git"
|
||||||
GIT_TAG "main"
|
GIT_TAG "main"
|
||||||
UPDATE_DISCONNECTED TRUE
|
UPDATE_DISCONNECTED TRUE
|
||||||
EXCLUDE_FROM_ALL
|
EXCLUDE_FROM_ALL
|
||||||
PATCH_COMMAND ${SDL_PATCH}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
block()
|
block()
|
||||||
if(VITA_USE_OPENGLES2)
|
if(VITA)
|
||||||
set(VIDEO_VITA_PVR ON)
|
|
||||||
get_target_property(PVR_INCLUDES GLESv2 INTERFACE_INCLUDE_DIRECTORIES)
|
|
||||||
list(APPEND CMAKE_REQUIRED_INCLUDES ${PVR_INCLUDES})
|
|
||||||
else()
|
|
||||||
set(SDL_RENDER OFF)
|
set(SDL_RENDER OFF)
|
||||||
|
set(SDL_GPU OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
FetchContent_MakeAvailable(SDL3)
|
FetchContent_MakeAvailable(SDL3)
|
||||||
if(VITA_USE_OPENGLES2)
|
|
||||||
target_include_directories(SDL3-static PRIVATE ${PVR_INCLUDES})
|
|
||||||
endif()
|
|
||||||
endblock()
|
endblock()
|
||||||
|
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
@ -532,12 +513,6 @@ if (ISLE_BUILD_APP)
|
|||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_link_libraries(isle PRIVATE winmm)
|
target_link_libraries(isle PRIVATE winmm)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(VITA AND VITA_USE_OPENGLES2)
|
|
||||||
target_link_libraries(isle PRIVATE GLESv2)
|
|
||||||
target_compile_definitions(isle PRIVATE USE_OPENGLES2)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Link LEGO1
|
# Link LEGO1
|
||||||
target_link_libraries(isle PRIVATE lego1)
|
target_link_libraries(isle PRIVATE lego1)
|
||||||
if(ISLE_DEBUG)
|
if(ISLE_DEBUG)
|
||||||
@ -686,16 +661,23 @@ if(EMSCRIPTEN)
|
|||||||
DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
if(VITA)
|
||||||
|
install(FILES "$<TARGET_FILE_DIR:isle>/isle.vpk" "$<TARGET_FILE_DIR:isle>/isle.self"
|
||||||
|
DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(CPACK_PACKAGE_DIRECTORY "dist")
|
set(CPACK_PACKAGE_DIRECTORY "dist")
|
||||||
set(CPACK_PACKAGE_FILE_NAME "isle-${PROJECT_VERSION}-${ISLE_PACKAGE_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
|
set(CPACK_PACKAGE_FILE_NAME "isle-${PROJECT_VERSION}-${ISLE_PACKAGE_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
|
||||||
|
if(MSVC)
|
||||||
|
set(CPACK_GENERATOR ZIP)
|
||||||
|
else()
|
||||||
|
set(CPACK_GENERATOR TGZ)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(VITA)
|
if(VITA)
|
||||||
include("${VITASDK}/share/vita.cmake" REQUIRED)
|
include("${VITASDK}/share/vita.cmake" REQUIRED)
|
||||||
|
|
||||||
if(VITA_USE_OPENGLES2)
|
|
||||||
target_link_libraries(lego1 PRIVATE GLESv2)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(ISLE_PACKAGE_NAME "vita-isle")
|
set(ISLE_PACKAGE_NAME "vita-isle")
|
||||||
set(VITA_APP_NAME "Lego Island")
|
set(VITA_APP_NAME "Lego Island")
|
||||||
set(VITA_TITLEID "LEGO00001")
|
set(VITA_TITLEID "LEGO00001")
|
||||||
@ -717,10 +699,8 @@ if(VITA)
|
|||||||
NAME ${VITA_APP_NAME}
|
NAME ${VITA_APP_NAME}
|
||||||
${VPK_FILE_ARGS}
|
${VPK_FILE_ARGS}
|
||||||
)
|
)
|
||||||
endif()
|
set(CPACK_PACKAGE_FILE_NAME "isle-${PROJECT_VERSION}-vita")
|
||||||
if(MSVC)
|
|
||||||
set(CPACK_GENERATOR ZIP)
|
set(CPACK_GENERATOR ZIP)
|
||||||
else()
|
|
||||||
set(CPACK_GENERATOR TGZ)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(CPack)
|
include(CPack)
|
||||||
|
|||||||
@ -50,39 +50,6 @@
|
|||||||
#include "emscripten/messagebox.h"
|
#include "emscripten/messagebox.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __vita__
|
|
||||||
#define USE_GXM
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__vita__) && defined(USE_OPENGLES2)
|
|
||||||
extern "C"{
|
|
||||||
#include <gpu_es4/psp2_pvr_hint.h>
|
|
||||||
}
|
|
||||||
#include <psp2/kernel/modulemgr.h>
|
|
||||||
|
|
||||||
#define DO_HARDWARE_TRANSFERS 1
|
|
||||||
|
|
||||||
#define NEWLIB_HEAP_SIZE 157286400
|
|
||||||
#define LIBC_HEAP_SIZE 41943040
|
|
||||||
#define GPU_MEM_SIZE 16777216
|
|
||||||
|
|
||||||
|
|
||||||
#if (NEWLIB_HEAP_SIZE + LIBC_HEAP_SIZE) > 382730240
|
|
||||||
#error Memory usage, exceeds maximum memory for userland applications.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (GPU_MEM_SIZE) > 134217728
|
|
||||||
#error GPU Memory exceeds maximum memblck size
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern SDL_Window* DDWindow;
|
|
||||||
|
|
||||||
int _newlib_heap_size_user = NEWLIB_HEAP_SIZE;
|
|
||||||
unsigned int sceLibcHeapSize = LIBC_HEAP_SIZE;
|
|
||||||
unsigned int sceLibcHeapExtendedAlloc = 1;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DECOMP_SIZE_ASSERT(IsleApp, 0x8c)
|
DECOMP_SIZE_ASSERT(IsleApp, 0x8c)
|
||||||
|
|
||||||
// GLOBAL: ISLE 0x410030
|
// GLOBAL: ISLE 0x410030
|
||||||
@ -294,30 +261,7 @@ SDL_AppResult SDL_AppInit(void** appstate, int argc, char** argv)
|
|||||||
SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "0");
|
SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "0");
|
||||||
SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");
|
SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");
|
||||||
|
|
||||||
#if defined(__vita__) && defined(USE_OPENGLES2)
|
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK)) {
|
||||||
SDL_SetHint("VITA_PVR_SKIP_INIT", "enable");
|
|
||||||
PVRSRV_PSP2_APPHINT hint;
|
|
||||||
|
|
||||||
sceKernelLoadStartModule("vs0:sys/external/libfios2.suprx", 0, NULL, 0, NULL, NULL);
|
|
||||||
sceKernelLoadStartModule("vs0:sys/external/libc.suprx", 0, NULL, 0, NULL, NULL);
|
|
||||||
sceKernelLoadStartModule("app0:/module/libgpu_es4_ext.suprx", 0, NULL, 0, NULL, NULL);
|
|
||||||
sceKernelLoadStartModule("app0:/module/libIMGEGL.suprx", 0, NULL, 0, NULL, NULL);
|
|
||||||
PVRSRVInitializeAppHint(&hint);
|
|
||||||
|
|
||||||
#if DO_HARDWARE_TRANSFERS == 0
|
|
||||||
hint.bDisableHWTextureUpload = 1;
|
|
||||||
hint.bDisableHWTQBufferBlit = 1;
|
|
||||||
hint.bDisableHWTQMipGen = 1;
|
|
||||||
hint.bDisableHWTQNormalBlit = 1;
|
|
||||||
hint.bDisableHWTQTextureUpload = 1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define GPU_MEM_SIZE 16777216
|
|
||||||
hint.ui32DriverMemorySize = GPU_MEM_SIZE;
|
|
||||||
PVRSRVCreateVirtualAppHint(&hint);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD)) {
|
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
SDL_snprintf(
|
SDL_snprintf(
|
||||||
buffer,
|
buffer,
|
||||||
@ -713,7 +657,7 @@ MxResult IsleApp::SetupWindow()
|
|||||||
SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER, g_targetHeight);
|
SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER, g_targetHeight);
|
||||||
SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_FULLSCREEN_BOOLEAN, m_fullScreen);
|
SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_FULLSCREEN_BOOLEAN, m_fullScreen);
|
||||||
SDL_SetStringProperty(props, SDL_PROP_WINDOW_CREATE_TITLE_STRING, WINDOW_TITLE);
|
SDL_SetStringProperty(props, SDL_PROP_WINDOW_CREATE_TITLE_STRING, WINDOW_TITLE);
|
||||||
#if defined(MINIWIN) && !defined(USE_GXM)
|
#if defined(MINIWIN) && !defined(__vita__)
|
||||||
SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_OPENGL_BOOLEAN, true);
|
SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_OPENGL_BOOLEAN, true);
|
||||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||||
#endif
|
#endif
|
||||||
@ -726,14 +670,9 @@ MxResult IsleApp::SetupWindow()
|
|||||||
(HWND) SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL);
|
(HWND) SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__vita__) && defined(USE_OPENGLES2)
|
|
||||||
DDWindow = window;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SDL_DestroyProperties(props);
|
SDL_DestroyProperties(props);
|
||||||
|
|
||||||
if (!m_windowHandle) {
|
if (!m_windowHandle) {
|
||||||
SDL_Log("failed to create window: %s", SDL_GetError());
|
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,56 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.21)
|
|
||||||
|
|
||||||
include(FetchContent)
|
|
||||||
|
|
||||||
# headers
|
|
||||||
FetchContent_Declare(
|
|
||||||
PVR_PSP2
|
|
||||||
URL https://github.com/GrapheneCt/PVR_PSP2/archive/refs/tags/v3.9.tar.gz
|
|
||||||
SOURCE_SUBDIR .
|
|
||||||
DOWNLOAD_EXTRACT_TIMESTAMP FALSE
|
|
||||||
)
|
|
||||||
FetchContent_MakeAvailable(PVR_PSP2)
|
|
||||||
set(PVR_PSP2_SOURCE_DIR ${pvr_psp2_SOURCE_DIR})
|
|
||||||
set(PVR_PSP2_BINARY_DIR ${pvr_psp2_BINARY_DIR})
|
|
||||||
|
|
||||||
# stubs
|
|
||||||
file(DOWNLOAD
|
|
||||||
https://github.com/GrapheneCt/PVR_PSP2/releases/download/v3.9/vitasdk_stubs.zip
|
|
||||||
${PVR_PSP2_BINARY_DIR}/vitasdk_stubs.zip
|
|
||||||
EXPECTED_HASH SHA256=7ee2498b58cb97871fcb0e3e134ce1045acf2c22ce4873b1844a391b5da4fe47
|
|
||||||
)
|
|
||||||
|
|
||||||
# suprxs
|
|
||||||
file(DOWNLOAD
|
|
||||||
https://github.com/GrapheneCt/PVR_PSP2/releases/download/v3.9/PSVita_Release.zip
|
|
||||||
${PVR_PSP2_BINARY_DIR}/PSVita_Release.zip
|
|
||||||
EXPECTED_HASH SHA256=ed69be89f21c4894e8009a8c3567c89b1778c8db0beb3c2f4ea134adab4c494f
|
|
||||||
)
|
|
||||||
|
|
||||||
# extract
|
|
||||||
file(MAKE_DIRECTORY ${PVR_PSP2_BINARY_DIR}/extracted)
|
|
||||||
|
|
||||||
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf ${PVR_PSP2_BINARY_DIR}/vitasdk_stubs.zip
|
|
||||||
WORKING_DIRECTORY ${PVR_PSP2_BINARY_DIR}/extracted)
|
|
||||||
|
|
||||||
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf ${PVR_PSP2_BINARY_DIR}/PSVita_Release.zip
|
|
||||||
WORKING_DIRECTORY ${PVR_PSP2_BINARY_DIR}/extracted)
|
|
||||||
|
|
||||||
# create library
|
|
||||||
add_library(GLESv2 INTERFACE)
|
|
||||||
target_include_directories(GLESv2 INTERFACE
|
|
||||||
${PVR_PSP2_SOURCE_DIR}/include
|
|
||||||
)
|
|
||||||
target_link_directories(GLESv2 INTERFACE
|
|
||||||
${PVR_PSP2_BINARY_DIR}/extracted/libGLESv2_stub_vitasdk.a/
|
|
||||||
${PVR_PSP2_BINARY_DIR}/extracted/libgpu_es4_ext_stub_vitasdk.a/
|
|
||||||
${PVR_PSP2_BINARY_DIR}/extracted/libIMGEGL_stub_vitasdk.a/
|
|
||||||
)
|
|
||||||
target_link_libraries(GLESv2 INTERFACE
|
|
||||||
libGLESv2_stub_weak
|
|
||||||
libgpu_es4_ext_stub_weak
|
|
||||||
libIMGEGL_stub_weak
|
|
||||||
)
|
|
||||||
set_target_properties(GLESv2 PROPERTIES
|
|
||||||
MODULES "${PVR_PSP2_BINARY_DIR}/extracted/libGLESv2.suprx;${PVR_PSP2_BINARY_DIR}/extracted/libIMGEGL.suprx;${PVR_PSP2_BINARY_DIR}/extracted/libgpu_es4_ext.suprx;${PVR_PSP2_BINARY_DIR}/extracted/libpvrPSP2_WSEGL.suprx"
|
|
||||||
)
|
|
||||||
@ -1,22 +0,0 @@
|
|||||||
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
|
|
||||||
UPDATE_DISCONNECTED TRUE
|
|
||||||
PATCH_COMMAND git apply "${SDL3_PATCH_FILE}"
|
|
||||||
)
|
|
||||||
|
|
||||||
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()
|
|
||||||
@ -1,46 +0,0 @@
|
|||||||
--- 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"
|
|
||||||
@ -31,29 +31,30 @@ target_compile_definitions(miniwin PRIVATE
|
|||||||
$<$<CONFIG:Debug>:DEBUG>
|
$<$<CONFIG:Debug>:DEBUG>
|
||||||
)
|
)
|
||||||
|
|
||||||
find_package(OpenGL)
|
list(APPEND GRAPHICS_BACKENDS USE_SOFTWARE_RENDER)
|
||||||
find_package(GLEW)
|
list(APPEND GRAPHICS_BACKENDS USE_SDL_GPU)
|
||||||
if(OpenGL_FOUND AND GLEW_FOUND)
|
|
||||||
message(STATUS "Found OpenGL and GLEW: enabling OpenGL 1.x renderer")
|
if(NOT VITA)
|
||||||
target_sources(miniwin PRIVATE src/d3drm/backends/opengl1/renderer.cpp)
|
find_package(OpenGL)
|
||||||
target_compile_definitions(miniwin PRIVATE USE_OPENGL1)
|
find_package(GLEW)
|
||||||
target_link_libraries(miniwin PRIVATE OpenGL::GL GLEW::GLEW)
|
if(OpenGL_FOUND AND GLEW_FOUND)
|
||||||
else()
|
message(STATUS "Found OpenGL and GLEW: enabling OpenGL 1.x renderer")
|
||||||
message(STATUS "🧩 OpenGL 1.x support not enabled — needs OpenGL and GLEW")
|
target_sources(miniwin PRIVATE src/d3drm/backends/opengl1/renderer.cpp)
|
||||||
endif()
|
list(APPEND GRAPHICS_BACKENDS USE_OPENGL1)
|
||||||
|
target_link_libraries(miniwin PRIVATE OpenGL::GL GLEW::GLEW)
|
||||||
|
else()
|
||||||
|
message(STATUS "🧩 OpenGL 1.x support not enabled — needs OpenGL and GLEW")
|
||||||
|
endif()
|
||||||
|
|
||||||
if(TARGET GLESv2)
|
|
||||||
set(OPENGL_ES2_LIBRARY GLESv2)
|
|
||||||
else()
|
|
||||||
find_library(OPENGL_ES2_LIBRARY NAMES GLESv2)
|
find_library(OPENGL_ES2_LIBRARY NAMES GLESv2)
|
||||||
endif()
|
if(OPENGL_ES2_LIBRARY)
|
||||||
if(OPENGL_ES2_LIBRARY)
|
message(STATUS "Found OpenGL: enabling OpenGL ES 2.x renderer")
|
||||||
message(STATUS "Found OpenGL: enabling OpenGL ES 2.x renderer")
|
target_sources(miniwin PRIVATE src/d3drm/backends/opengles2/renderer.cpp)
|
||||||
target_sources(miniwin PRIVATE src/d3drm/backends/opengles2/renderer.cpp)
|
list(APPEND GRAPHICS_BACKENDS USE_OPENGLES2)
|
||||||
target_compile_definitions(miniwin PRIVATE USE_OPENGLES2)
|
target_link_libraries(miniwin PRIVATE ${OPENGL_ES2_LIBRARY})
|
||||||
target_link_libraries(miniwin PRIVATE ${OPENGL_ES2_LIBRARY})
|
else()
|
||||||
else()
|
message(STATUS "🧩 OpenGL ES 2.x support not enabled")
|
||||||
message(STATUS "🧩 OpenGL ES 2.x support not enabled")
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(VITA)
|
if(VITA)
|
||||||
@ -65,9 +66,11 @@ if(VITA)
|
|||||||
SceGxm_stub
|
SceGxm_stub
|
||||||
SceRazorCapture_stub
|
SceRazorCapture_stub
|
||||||
)
|
)
|
||||||
|
list(APPEND GRAPHICS_BACKENDS USE_GXM)
|
||||||
|
list(REMOVE_ITEM GRAPHICS_BACKENDS USE_SOFTWARE_RENDER USE_SDL_GPU)
|
||||||
# for shaders incbin
|
# for shaders incbin
|
||||||
target_include_directories(miniwin PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/d3drm/backends/gxm)
|
target_include_directories(miniwin PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/d3drm/backends/gxm)
|
||||||
target_link_directories(miniwin PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/d3drm/backends/gxm)
|
#target_link_directories(miniwin PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/d3drm/backends/gxm)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
@ -89,6 +92,9 @@ target_link_libraries(miniwin PUBLIC miniwin-headers)
|
|||||||
|
|
||||||
target_link_libraries(miniwin PRIVATE SDL3::SDL3)
|
target_link_libraries(miniwin PRIVATE SDL3::SDL3)
|
||||||
|
|
||||||
|
target_compile_definitions(miniwin PRIVATE ${GRAPHICS_BACKENDS})
|
||||||
|
|
||||||
|
|
||||||
# Shader stuff
|
# Shader stuff
|
||||||
|
|
||||||
set(shader_src_dir "${CMAKE_CURRENT_SOURCE_DIR}/src/d3drm/backends/sdl3gpu/shaders/src")
|
set(shader_src_dir "${CMAKE_CURRENT_SOURCE_DIR}/src/d3drm/backends/sdl3gpu/shaders/src")
|
||||||
|
|||||||
@ -19,8 +19,12 @@
|
|||||||
#ifdef __vita__
|
#ifdef __vita__
|
||||||
#include "d3drmrenderer_gxm.h"
|
#include "d3drmrenderer_gxm.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef USE_SDL_GPU
|
||||||
#include "d3drmrenderer_sdl3gpu.h"
|
#include "d3drmrenderer_sdl3gpu.h"
|
||||||
|
#endif
|
||||||
|
#ifdef USE_SOFTWARE_RENDER
|
||||||
#include "d3drmrenderer_software.h"
|
#include "d3drmrenderer_software.h"
|
||||||
|
#endif
|
||||||
#include "d3drmtexture_impl.h"
|
#include "d3drmtexture_impl.h"
|
||||||
#include "d3drmviewport_impl.h"
|
#include "d3drmviewport_impl.h"
|
||||||
#include "ddraw_impl.h"
|
#include "ddraw_impl.h"
|
||||||
@ -148,14 +152,16 @@ HRESULT Direct3DRMImpl::CreateDeviceFromSurface(
|
|||||||
|
|
||||||
|
|
||||||
if(false) {}
|
if(false) {}
|
||||||
#ifndef __vita__
|
#ifdef USE_SDL_GPU
|
||||||
else if (SDL_memcmp(&guid, &SDL3_GPU_GUID, sizeof(GUID)) == 0) {
|
else if (SDL_memcmp(&guid, &SDL3_GPU_GUID, sizeof(GUID)) == 0) {
|
||||||
DDRenderer = Direct3DRMSDL3GPURenderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
DDRenderer = Direct3DRMSDL3GPURenderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef USE_SOFTWARE_RENDER
|
||||||
else if (SDL_memcmp(&guid, &SOFTWARE_GUID, sizeof(GUID)) == 0) {
|
else if (SDL_memcmp(&guid, &SOFTWARE_GUID, sizeof(GUID)) == 0) {
|
||||||
DDRenderer = new Direct3DRMSoftwareRenderer(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
DDRenderer = new Direct3DRMSoftwareRenderer(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#ifdef USE_OPENGLES2
|
#ifdef USE_OPENGLES2
|
||||||
else if (SDL_memcmp(&guid, &OpenGLES2_GUID, sizeof(GUID)) == 0) {
|
else if (SDL_memcmp(&guid, &OpenGLES2_GUID, sizeof(GUID)) == 0) {
|
||||||
DDRenderer = OpenGLES2Renderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
DDRenderer = OpenGLES2Renderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||||
|
|||||||
@ -10,8 +10,12 @@
|
|||||||
#ifdef __vita__
|
#ifdef __vita__
|
||||||
#include "d3drmrenderer_gxm.h"
|
#include "d3drmrenderer_gxm.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef USE_SDL_GPU
|
||||||
#include "d3drmrenderer_sdl3gpu.h"
|
#include "d3drmrenderer_sdl3gpu.h"
|
||||||
|
#endif
|
||||||
|
#ifdef USE_SOFTWARE_RENDER
|
||||||
#include "d3drmrenderer_software.h"
|
#include "d3drmrenderer_software.h"
|
||||||
|
#endif
|
||||||
#include "ddpalette_impl.h"
|
#include "ddpalette_impl.h"
|
||||||
#include "ddraw_impl.h"
|
#include "ddraw_impl.h"
|
||||||
#include "ddsurface_impl.h"
|
#include "ddsurface_impl.h"
|
||||||
@ -224,7 +228,7 @@ void EnumDevice(LPD3DENUMDEVICESCALLBACK cb, void* ctx, Direct3DRMRenderer* devi
|
|||||||
|
|
||||||
HRESULT DirectDrawImpl::EnumDevices(LPD3DENUMDEVICESCALLBACK cb, void* ctx)
|
HRESULT DirectDrawImpl::EnumDevices(LPD3DENUMDEVICESCALLBACK cb, void* ctx)
|
||||||
{
|
{
|
||||||
#ifndef __vita__
|
#ifdef USE_SDL_GPU
|
||||||
Direct3DRMSDL3GPU_EnumDevice(cb, ctx);
|
Direct3DRMSDL3GPU_EnumDevice(cb, ctx);
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_OPENGLES2
|
#ifdef USE_OPENGLES2
|
||||||
@ -239,8 +243,9 @@ HRESULT DirectDrawImpl::EnumDevices(LPD3DENUMDEVICESCALLBACK cb, void* ctx)
|
|||||||
#ifdef __vita__
|
#ifdef __vita__
|
||||||
GXMRenderer_EnumDevice(cb, ctx);
|
GXMRenderer_EnumDevice(cb, ctx);
|
||||||
#endif
|
#endif
|
||||||
//Direct3DRMSoftware_EnumDevice(cb, ctx);
|
#ifdef USE_SOFTWARE_RENDER
|
||||||
|
Direct3DRMSoftware_EnumDevice(cb, ctx);
|
||||||
|
#endif
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,12 +314,6 @@ HRESULT DirectDrawImpl::SetCooperativeLevel(HWND hWnd, DDSCLFlags dwFlags)
|
|||||||
return DDERR_INVALIDPARAMS;
|
return DDERR_INVALIDPARAMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__vita__) && defined(USE_OPENGLES2)
|
|
||||||
const char* sdlRendererName = "opengles2";
|
|
||||||
#else
|
|
||||||
const char* sdlRendererName = nullptr;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!SDL_SetWindowFullscreen(sdlWindow, fullscreen)) {
|
if (!SDL_SetWindowFullscreen(sdlWindow, fullscreen)) {
|
||||||
#ifndef __EMSCRIPTEN__
|
#ifndef __EMSCRIPTEN__
|
||||||
return DDERR_GENERIC;
|
return DDERR_GENERIC;
|
||||||
@ -344,7 +343,7 @@ HRESULT DirectDrawImpl::CreateDevice(
|
|||||||
pBackBuffer->GetSurfaceDesc(&DDSDesc);
|
pBackBuffer->GetSurfaceDesc(&DDSDesc);
|
||||||
|
|
||||||
if(false) {}
|
if(false) {}
|
||||||
#ifndef __vita__
|
#ifdef USE_SDL_GPU
|
||||||
else if (SDL_memcmp(&guid, &SDL3_GPU_GUID, sizeof(GUID)) == 0) {
|
else if (SDL_memcmp(&guid, &SDL3_GPU_GUID, sizeof(GUID)) == 0) {
|
||||||
DDRenderer = Direct3DRMSDL3GPURenderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
DDRenderer = Direct3DRMSDL3GPURenderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||||
}
|
}
|
||||||
@ -369,9 +368,11 @@ HRESULT DirectDrawImpl::CreateDevice(
|
|||||||
DDRenderer = GXMRenderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
DDRenderer = GXMRenderer::Create(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef USE_SOFTWARE_RENDER
|
||||||
else if (SDL_memcmp(&guid, &SOFTWARE_GUID, sizeof(GUID)) == 0) {
|
else if (SDL_memcmp(&guid, &SOFTWARE_GUID, sizeof(GUID)) == 0) {
|
||||||
DDRenderer = new Direct3DRMSoftwareRenderer(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
DDRenderer = new Direct3DRMSoftwareRenderer(DDSDesc.dwWidth, DDSDesc.dwHeight);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
else {
|
else {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Device GUID not recognized");
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Device GUID not recognized");
|
||||||
return E_NOINTERFACE;
|
return E_NOINTERFACE;
|
||||||
|
|||||||
@ -37,8 +37,6 @@ HRESULT FrameBufferImpl::AddAttachedSurface(LPDIRECTDRAWSURFACE lpDDSAttachedSur
|
|||||||
return DDERR_GENERIC;
|
return DDERR_GENERIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
HRESULT FrameBufferImpl::Blt(
|
HRESULT FrameBufferImpl::Blt(
|
||||||
LPRECT lpDestRect,
|
LPRECT lpDestRect,
|
||||||
LPDIRECTDRAWSURFACE lpDDSrcSurface,
|
LPDIRECTDRAWSURFACE lpDDSrcSurface,
|
||||||
|
|||||||
@ -1,466 +0,0 @@
|
|||||||
#include "ddpalette_impl.h"
|
|
||||||
#include "ddraw_impl.h"
|
|
||||||
#include "dummysurface_impl.h"
|
|
||||||
#include "framebuffer_impl.h"
|
|
||||||
#include "miniwin.h"
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include "../d3drm/backends/gxm/memory.h"
|
|
||||||
#include "../d3drm/backends/gxm/utils.h"
|
|
||||||
|
|
||||||
FrameBufferImpl::FrameBufferImpl(LPDDSURFACEDESC lpDDSurfaceDesc)
|
|
||||||
{
|
|
||||||
this->width = 960;
|
|
||||||
this->height = 544;
|
|
||||||
|
|
||||||
if(!get_gxm_context(&this->context, &this->shaderPatcher, &this->cdramPool)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// render target
|
|
||||||
SceGxmRenderTargetParams renderTargetParams;
|
|
||||||
memset(&renderTargetParams, 0, sizeof(SceGxmRenderTargetParams));
|
|
||||||
renderTargetParams.flags = 0;
|
|
||||||
renderTargetParams.width = this->width;
|
|
||||||
renderTargetParams.height = this->height;
|
|
||||||
renderTargetParams.scenesPerFrame = 1;
|
|
||||||
renderTargetParams.multisampleMode = 0;
|
|
||||||
renderTargetParams.multisampleLocations = 0;
|
|
||||||
renderTargetParams.driverMemBlock = -1; // Invalid UID
|
|
||||||
|
|
||||||
if(SCE_ERR(sceGxmCreateRenderTarget, &renderTargetParams, &this->renderTarget)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i = 0; i < VITA_GXM_DISPLAY_BUFFER_COUNT; i++) {
|
|
||||||
this->displayBuffers[i].data = vita_mem_alloc(
|
|
||||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW,
|
|
||||||
4 * this->width * this->height,
|
|
||||||
SCE_GXM_COLOR_SURFACE_ALIGNMENT,
|
|
||||||
SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE,
|
|
||||||
&this->displayBuffers[i].uid, "display", nullptr);
|
|
||||||
|
|
||||||
if(SCE_ERR(sceGxmColorSurfaceInit,
|
|
||||||
&this->displayBuffers[i].surface,
|
|
||||||
SCE_GXM_COLOR_FORMAT_A8B8G8R8,
|
|
||||||
SCE_GXM_COLOR_SURFACE_LINEAR,
|
|
||||||
SCE_GXM_COLOR_SURFACE_SCALE_NONE,
|
|
||||||
SCE_GXM_OUTPUT_REGISTER_SIZE_32BIT,
|
|
||||||
width, height, width,
|
|
||||||
this->displayBuffers[i].data
|
|
||||||
)) {
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
if(SCE_ERR(sceGxmSyncObjectCreate, &this->displayBuffers[i].sync)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(SCE_ERR(sceGxmShaderPatcherRegisterProgram, this->shaderPatcher, blitVertexProgramGxp, &this->blitVertexProgramId)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(SCE_ERR(sceGxmShaderPatcherRegisterProgram, this->shaderPatcher, blitColorFragmentProgramGxp, &this->blitColorFragmentProgramId)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(SCE_ERR(sceGxmShaderPatcherRegisterProgram, this->shaderPatcher, blitTexFragmentProgramGxp, &this->blitTexFragmentProgramId)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
GET_SHADER_PARAM(positionAttribute, blitVertexProgramGxp, "aPosition",);
|
|
||||||
GET_SHADER_PARAM(texCoordAttribute, blitVertexProgramGxp, "aTexCoord",);
|
|
||||||
|
|
||||||
SceGxmVertexAttribute vertexAttributes[1];
|
|
||||||
SceGxmVertexStream vertexStreams[1];
|
|
||||||
vertexAttributes[0].streamIndex = 0;
|
|
||||||
vertexAttributes[0].offset = 0;
|
|
||||||
vertexAttributes[0].format = SCE_GXM_ATTRIBUTE_FORMAT_F32;
|
|
||||||
vertexAttributes[0].componentCount = 2;
|
|
||||||
vertexAttributes[0].regIndex = sceGxmProgramParameterGetResourceIndex(positionAttribute);
|
|
||||||
vertexAttributes[1].streamIndex = 0;
|
|
||||||
vertexAttributes[1].offset = 8;
|
|
||||||
vertexAttributes[1].format = SCE_GXM_ATTRIBUTE_FORMAT_F32;
|
|
||||||
vertexAttributes[1].componentCount = 2;
|
|
||||||
vertexAttributes[1].regIndex = sceGxmProgramParameterGetResourceIndex(texCoordAttribute);
|
|
||||||
vertexStreams[0].stride = sizeof(float)*4;
|
|
||||||
vertexStreams[0].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT;
|
|
||||||
|
|
||||||
if(SCE_ERR(sceGxmShaderPatcherCreateVertexProgram,
|
|
||||||
this->shaderPatcher,
|
|
||||||
this->blitVertexProgramId,
|
|
||||||
vertexAttributes, 2,
|
|
||||||
vertexStreams, 1,
|
|
||||||
&this->blitVertexProgram
|
|
||||||
)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(SCE_ERR(sceGxmShaderPatcherCreateFragmentProgram,
|
|
||||||
this->shaderPatcher,
|
|
||||||
this->blitColorFragmentProgramId,
|
|
||||||
SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4,
|
|
||||||
SCE_GXM_MULTISAMPLE_NONE,
|
|
||||||
NULL,
|
|
||||||
blitVertexProgramGxp,
|
|
||||||
&this->blitColorFragmentProgram
|
|
||||||
)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(SCE_ERR(sceGxmShaderPatcherCreateFragmentProgram,
|
|
||||||
this->shaderPatcher,
|
|
||||||
this->blitTexFragmentProgramId,
|
|
||||||
SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4,
|
|
||||||
SCE_GXM_MULTISAMPLE_NONE,
|
|
||||||
NULL,
|
|
||||||
blitVertexProgramGxp,
|
|
||||||
&this->blitTexFragmentProgram
|
|
||||||
)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this->uScreenMatrix = sceGxmProgramFindParameterByName(blitVertexProgramGxp, "uScreenMatrix"); // matrix4
|
|
||||||
|
|
||||||
this->uColor = sceGxmProgramFindParameterByName(blitColorFragmentProgramGxp, "uColor"); // vec4
|
|
||||||
this->uTexMatrix = sceGxmProgramFindParameterByName(blitTexFragmentProgramGxp, "uTexMatrix"); // matrix4
|
|
||||||
|
|
||||||
const size_t quadMeshVerticiesSize = 4 * sizeof(float)*4;
|
|
||||||
const size_t quadMeshIndiciesSize = 4 * sizeof(uint16_t);
|
|
||||||
this->quadMeshBuffer = sceClibMspaceMalloc(this->cdramPool, quadMeshVerticiesSize + quadMeshIndiciesSize);
|
|
||||||
this->quadVerticies = (float*)this->quadMeshBuffer;
|
|
||||||
this->quadIndicies = (uint16_t*)((uint8_t*)(this->quadMeshBuffer)+quadMeshVerticiesSize);
|
|
||||||
|
|
||||||
float quadVerts[] = {
|
|
||||||
// x, y, u, v
|
|
||||||
-1.0f, -1.0f, 0.0f, 1.0f, // Bottom-left
|
|
||||||
-1.0f, 1.0f, 0.0f, 0.0f, // Top-left
|
|
||||||
1.0f, -1.0f, 1.0f, 1.0f, // Bottom-right
|
|
||||||
1.0f, 1.0f, 1.0f, 0.0f // Top-right
|
|
||||||
};
|
|
||||||
memcpy(this->quadVerticies, quadVerts, quadMeshVerticiesSize);
|
|
||||||
this->quadIndicies[0] = 0;
|
|
||||||
this->quadIndicies[1] = 1;
|
|
||||||
this->quadIndicies[2] = 2;
|
|
||||||
this->quadIndicies[3] = 3;
|
|
||||||
|
|
||||||
this->backBufferIndex = 0;
|
|
||||||
this->frontBufferIndex = 1;
|
|
||||||
|
|
||||||
DDBackBuffer = SDL_CreateSurfaceFrom(this->width, this->height, SDL_PIXELFORMAT_RGBA8888, nullptr, 0);
|
|
||||||
if (!DDBackBuffer) {
|
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to create surface: %s", SDL_GetError());
|
|
||||||
}
|
|
||||||
|
|
||||||
DDBackBuffer->pitch = this->width*4;
|
|
||||||
DDBackBuffer->pixels = this->backBuffer()->data;
|
|
||||||
}
|
|
||||||
|
|
||||||
FrameBufferImpl::~FrameBufferImpl()
|
|
||||||
{
|
|
||||||
if (m_palette) {
|
|
||||||
m_palette->Release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// IUnknown interface
|
|
||||||
HRESULT FrameBufferImpl::QueryInterface(const GUID& riid, void** ppvObject)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
return E_NOINTERFACE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// IDirectDrawSurface interface
|
|
||||||
HRESULT FrameBufferImpl::AddAttachedSurface(LPDIRECTDRAWSURFACE lpDDSAttachedSurface)
|
|
||||||
{
|
|
||||||
if (dynamic_cast<DummySurfaceImpl*>(lpDDSAttachedSurface)) {
|
|
||||||
return DD_OK;
|
|
||||||
}
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
return DDERR_GENERIC;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
void calculateTexMatrix(SDL_Rect srcRect, int textureWidth, int textureHeight, float matrix[4][4]) {
|
|
||||||
float scaleX = srcRect.w / (float)textureWidth;
|
|
||||||
float scaleY = srcRect.h / (float)textureHeight;
|
|
||||||
float offsetX = srcRect.x / (float)textureWidth;
|
|
||||||
float offsetY = srcRect.y / (float)textureHeight;
|
|
||||||
memset(matrix, 0, sizeof(float) * 16);
|
|
||||||
matrix[0][0] = scaleX;
|
|
||||||
matrix[1][1] = scaleY;
|
|
||||||
matrix[2][2] = 1.0f;
|
|
||||||
matrix[3][3] = 1.0f;
|
|
||||||
matrix[0][3] = offsetX;
|
|
||||||
matrix[1][3] = offsetY;
|
|
||||||
}
|
|
||||||
|
|
||||||
void calculateScreenMatrix(SDL_Rect dstRect, int screenWidth, int screenHeight, float matrix[4][4]) {
|
|
||||||
float scaleX = (2.0f * dstRect.w) / screenWidth;
|
|
||||||
float scaleY = (2.0f * dstRect.h) / screenHeight;
|
|
||||||
float offsetX = (2.0f * dstRect.x) / screenWidth - 1.0f + scaleX * 0.5f;
|
|
||||||
float offsetY = 1.0f - (2.0f * dstRect.y) / screenHeight - scaleY * 0.5f;
|
|
||||||
memset(matrix, 0, sizeof(float) * 16);
|
|
||||||
matrix[0][0] = scaleX;
|
|
||||||
matrix[1][1] = scaleY;
|
|
||||||
matrix[2][2] = 1.0f;
|
|
||||||
matrix[3][3] = 1.0f;
|
|
||||||
matrix[0][3] = offsetX;
|
|
||||||
matrix[1][3] = offsetY;
|
|
||||||
}
|
|
||||||
HRESULT FrameBufferImpl::Blt(
|
|
||||||
LPRECT lpDestRect,
|
|
||||||
LPDIRECTDRAWSURFACE lpDDSrcSurface,
|
|
||||||
LPRECT lpSrcRect,
|
|
||||||
DDBltFlags dwFlags,
|
|
||||||
LPDDBLTFX lpDDBltFx
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (dynamic_cast<FrameBufferImpl*>(lpDDSrcSurface) == this) {
|
|
||||||
return Flip(nullptr, DDFLIP_WAIT);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!sceneStarted) {
|
|
||||||
SCE_ERR(sceGxmBeginScene,
|
|
||||||
this->context,
|
|
||||||
0,
|
|
||||||
this->renderTarget,
|
|
||||||
nullptr,
|
|
||||||
nullptr,
|
|
||||||
nullptr,
|
|
||||||
&this->backBuffer()->surface,
|
|
||||||
nullptr
|
|
||||||
);
|
|
||||||
|
|
||||||
sceGxmSetFrontStencilFunc(
|
|
||||||
this->context,
|
|
||||||
SCE_GXM_STENCIL_FUNC_NEVER,
|
|
||||||
SCE_GXM_STENCIL_OP_KEEP,
|
|
||||||
SCE_GXM_STENCIL_OP_KEEP,
|
|
||||||
SCE_GXM_STENCIL_OP_KEEP,
|
|
||||||
0xFF,
|
|
||||||
0xFF
|
|
||||||
);
|
|
||||||
sceGxmSetFrontDepthFunc(this->context, SCE_GXM_DEPTH_FUNC_ALWAYS);
|
|
||||||
|
|
||||||
sceneStarted = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool colorFill = ((dwFlags & DDBLT_COLORFILL) == DDBLT_COLORFILL);
|
|
||||||
sceGxmSetVertexProgram(this->context, this->blitVertexProgram);
|
|
||||||
SCE_ERR(sceGxmSetVertexStream, this->context, 0, this->quadVerticies);
|
|
||||||
|
|
||||||
if(colorFill) {
|
|
||||||
sceGxmSetFragmentProgram(this->context, this->blitColorFragmentProgram);
|
|
||||||
} else {
|
|
||||||
sceGxmSetFragmentProgram(this->context, this->blitTexFragmentProgram);
|
|
||||||
}
|
|
||||||
|
|
||||||
void* vertUniforms;
|
|
||||||
void* fragUniforms;
|
|
||||||
SCE_ERR(sceGxmReserveVertexDefaultUniformBuffer, this->context, &vertUniforms);
|
|
||||||
SCE_ERR(sceGxmReserveFragmentDefaultUniformBuffer, this->context, &fragUniforms);
|
|
||||||
|
|
||||||
if(colorFill) {
|
|
||||||
SDL_Rect rect = {0, 0, this->width, this->height};
|
|
||||||
|
|
||||||
DirectDrawPaletteImpl* ddPal = static_cast<DirectDrawPaletteImpl*>(m_palette);
|
|
||||||
SDL_Palette* sdlPalette = ddPal ? ddPal->m_palette : nullptr;
|
|
||||||
uint8_t r,g,b,a;
|
|
||||||
SDL_GetRGBA(lpDDBltFx->dwFillColor, SDL_GetPixelFormatDetails(SDL_PIXELFORMAT_ABGR8888), sdlPalette, &r, &g, &b, &a);
|
|
||||||
|
|
||||||
float screenMatrix[4][4];
|
|
||||||
calculateScreenMatrix(rect, this->width, this->height, screenMatrix);
|
|
||||||
SET_UNIFORM(vertUniforms, this->uScreenMatrix, screenMatrix);
|
|
||||||
|
|
||||||
float color[4] = {
|
|
||||||
(float)r / 255.0f,
|
|
||||||
(float)g / 255.0f,
|
|
||||||
(float)b / 255.0f,
|
|
||||||
(float)a / 255.0f
|
|
||||||
};
|
|
||||||
SET_UNIFORM(fragUniforms, this->uColor, color);
|
|
||||||
} else {
|
|
||||||
auto other = static_cast<DirectDrawSurfaceImpl*>(lpDDSrcSurface);
|
|
||||||
if (!other) {
|
|
||||||
return DDERR_GENERIC;
|
|
||||||
}
|
|
||||||
SDL_Surface* blitSource = other->m_surface;
|
|
||||||
|
|
||||||
SDL_Rect srcRect = lpSrcRect ? ConvertRect(lpSrcRect) : SDL_Rect{0, 0, other->m_surface->w, other->m_surface->h};
|
|
||||||
SDL_Rect dstRect = lpDestRect ? ConvertRect(lpDestRect) : SDL_Rect{0, 0, this->width, this->height};
|
|
||||||
|
|
||||||
float screenMatrix[4][4];
|
|
||||||
calculateScreenMatrix(dstRect, this->width, this->height, screenMatrix);
|
|
||||||
SET_UNIFORM(vertUniforms, this->uScreenMatrix, screenMatrix);
|
|
||||||
|
|
||||||
float texMatrix[4][4];
|
|
||||||
calculateTexMatrix(srcRect, blitSource->w, blitSource->h, texMatrix);
|
|
||||||
SET_UNIFORM(vertUniforms, this->uTexMatrix, texMatrix);
|
|
||||||
|
|
||||||
SceGxmTextureFormat texFormat = SCE_GXM_TEXTURE_FORMAT_A8B8G8R8;
|
|
||||||
SceGxmTexture gxmTexture;
|
|
||||||
SCE_ERR(sceGxmTextureInitLinear, &gxmTexture, blitSource->pixels, texFormat, blitSource->w, blitSource->h, 0);
|
|
||||||
sceGxmTextureSetStride(&gxmTexture, blitSource->pitch);
|
|
||||||
SCE_ERR(sceGxmTextureSetMinFilter, &gxmTexture, SCE_GXM_TEXTURE_FILTER_POINT);
|
|
||||||
SCE_ERR(sceGxmTextureSetMagFilter, &gxmTexture, SCE_GXM_TEXTURE_FILTER_POINT);
|
|
||||||
SCE_ERR(sceGxmSetFragmentTexture, this->context, 0, &gxmTexture);
|
|
||||||
}
|
|
||||||
|
|
||||||
SCE_ERR(sceGxmDraw,
|
|
||||||
this->context,
|
|
||||||
SCE_GXM_PRIMITIVE_TRIANGLE_STRIP,
|
|
||||||
SCE_GXM_INDEX_FORMAT_U16,
|
|
||||||
this->quadIndicies,
|
|
||||||
4
|
|
||||||
);
|
|
||||||
return DD_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT FrameBufferImpl::BltFast(
|
|
||||||
DWORD dwX,
|
|
||||||
DWORD dwY,
|
|
||||||
LPDIRECTDRAWSURFACE lpDDSrcSurface,
|
|
||||||
LPRECT lpSrcRect,
|
|
||||||
DDBltFastFlags dwTrans
|
|
||||||
)
|
|
||||||
{
|
|
||||||
RECT destRect = {
|
|
||||||
(int) dwX,
|
|
||||||
(int) dwY,
|
|
||||||
(int) (lpSrcRect->right - lpSrcRect->left + dwX),
|
|
||||||
(int) (lpSrcRect->bottom - lpSrcRect->top + dwY)
|
|
||||||
};
|
|
||||||
return Blt(&destRect, lpDDSrcSurface, lpSrcRect, DDBLT_NONE, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT FrameBufferImpl::Flip(LPDIRECTDRAWSURFACE lpDDSurfaceTargetOverride, DDFlipFlags dwFlags)
|
|
||||||
{
|
|
||||||
if(this->sceneStarted) {
|
|
||||||
sceGxmEndScene(this->context, nullptr, nullptr);
|
|
||||||
this->sceneStarted = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
sceGxmPadHeartbeat(
|
|
||||||
&this->displayBuffers[this->backBufferIndex].surface,
|
|
||||||
this->displayBuffers[this->backBufferIndex].sync
|
|
||||||
);
|
|
||||||
|
|
||||||
VITA_GXM_DisplayData displayData;
|
|
||||||
displayData.address = this->displayBuffers[this->backBufferIndex].data;
|
|
||||||
|
|
||||||
sceGxmDisplayQueueAddEntry(
|
|
||||||
this->displayBuffers[this->frontBufferIndex].sync,
|
|
||||||
this->displayBuffers[this->backBufferIndex].sync,
|
|
||||||
&displayData
|
|
||||||
);
|
|
||||||
|
|
||||||
this->frontBufferIndex = this->backBufferIndex;
|
|
||||||
this->backBufferIndex = (this->backBufferIndex + 1) % VITA_GXM_DISPLAY_BUFFER_COUNT;
|
|
||||||
|
|
||||||
DDBackBuffer->pixels = this->backBuffer()->data;
|
|
||||||
return DD_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT FrameBufferImpl::GetAttachedSurface(LPDDSCAPS lpDDSCaps, LPDIRECTDRAWSURFACE* lplpDDAttachedSurface)
|
|
||||||
{
|
|
||||||
if ((lpDDSCaps->dwCaps & DDSCAPS_BACKBUFFER) != DDSCAPS_BACKBUFFER) {
|
|
||||||
return DDERR_INVALIDPARAMS;
|
|
||||||
}
|
|
||||||
*lplpDDAttachedSurface = static_cast<IDirectDrawSurface*>(this);
|
|
||||||
return DD_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT FrameBufferImpl::GetDC(HDC* lphDC)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
return DD_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT FrameBufferImpl::GetPalette(LPDIRECTDRAWPALETTE* lplpDDPalette)
|
|
||||||
{
|
|
||||||
if (!m_palette) {
|
|
||||||
return DDERR_GENERIC;
|
|
||||||
}
|
|
||||||
m_palette->AddRef();
|
|
||||||
*lplpDDPalette = m_palette;
|
|
||||||
return DD_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT FrameBufferImpl::GetPixelFormat(LPDDPIXELFORMAT lpDDPixelFormat)
|
|
||||||
{
|
|
||||||
memset(lpDDPixelFormat, 0, sizeof(*lpDDPixelFormat));
|
|
||||||
lpDDPixelFormat->dwFlags = DDPF_RGB;
|
|
||||||
lpDDPixelFormat->dwFlags |= DDPF_PALETTEINDEXED8;
|
|
||||||
lpDDPixelFormat->dwRGBBitCount = 8;
|
|
||||||
lpDDPixelFormat->dwRBitMask = 0xff;
|
|
||||||
lpDDPixelFormat->dwGBitMask = 0xff;
|
|
||||||
lpDDPixelFormat->dwBBitMask = 0xff;
|
|
||||||
lpDDPixelFormat->dwRGBAlphaBitMask = 0xff;
|
|
||||||
return DD_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT FrameBufferImpl::GetSurfaceDesc(LPDDSURFACEDESC lpDDSurfaceDesc)
|
|
||||||
{
|
|
||||||
lpDDSurfaceDesc->dwFlags = DDSD_PIXELFORMAT;
|
|
||||||
GetPixelFormat(&lpDDSurfaceDesc->ddpfPixelFormat);
|
|
||||||
lpDDSurfaceDesc->dwFlags |= DDSD_WIDTH | DDSD_HEIGHT;
|
|
||||||
lpDDSurfaceDesc->dwWidth = this->width;
|
|
||||||
lpDDSurfaceDesc->dwHeight = this->height;
|
|
||||||
return DD_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT FrameBufferImpl::IsLost()
|
|
||||||
{
|
|
||||||
return DD_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT FrameBufferImpl::Lock(LPRECT lpDestRect, DDSURFACEDESC* lpDDSurfaceDesc, DDLockFlags dwFlags, HANDLE hEvent)
|
|
||||||
{
|
|
||||||
GetSurfaceDesc(lpDDSurfaceDesc);
|
|
||||||
lpDDSurfaceDesc->lpSurface = this->backBuffer()->data;
|
|
||||||
lpDDSurfaceDesc->lPitch = this->width*4;
|
|
||||||
|
|
||||||
return DD_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT FrameBufferImpl::ReleaseDC(HDC hDC)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
return DD_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT FrameBufferImpl::Restore()
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
return DD_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT FrameBufferImpl::SetClipper(LPDIRECTDRAWCLIPPER lpDDClipper)
|
|
||||||
{
|
|
||||||
return DD_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT FrameBufferImpl::SetColorKey(DDColorKeyFlags dwFlags, LPDDCOLORKEY lpDDColorKey)
|
|
||||||
{
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
|
||||||
return DD_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT FrameBufferImpl::SetPalette(LPDIRECTDRAWPALETTE lpDDPalette)
|
|
||||||
{
|
|
||||||
if (m_palette) {
|
|
||||||
m_palette->Release();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_palette = lpDDPalette;
|
|
||||||
//SDL_SetSurfacePalette(DDBackBuffer, ((DirectDrawPaletteImpl*) m_palette)->m_palette);
|
|
||||||
m_palette->AddRef();
|
|
||||||
return DD_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT FrameBufferImpl::Unlock(LPVOID lpSurfaceData)
|
|
||||||
{
|
|
||||||
return DD_OK;
|
|
||||||
}
|
|
||||||
@ -1,92 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <SDL3/SDL.h>
|
|
||||||
#include <ddsurface_impl.h>
|
|
||||||
#include <miniwin/ddraw.h>
|
|
||||||
|
|
||||||
#include <SDL3/SDL_gxm.h>
|
|
||||||
#include <psp2/gxm.h>
|
|
||||||
#define VITA_GXM_DISPLAY_BUFFER_COUNT 2
|
|
||||||
|
|
||||||
typedef struct GXMDisplayBuffer {
|
|
||||||
SceUID uid;
|
|
||||||
SceGxmSyncObject* sync;
|
|
||||||
void* data;
|
|
||||||
SceGxmColorSurface surface;
|
|
||||||
} GXMDisplayBuffer;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
void *address;
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
} GXMDisplayData;
|
|
||||||
|
|
||||||
struct FrameBufferImpl : public IDirectDrawSurface3 {
|
|
||||||
FrameBufferImpl(LPDDSURFACEDESC lpDDSurfaceDesc);
|
|
||||||
~FrameBufferImpl() override;
|
|
||||||
|
|
||||||
// IUnknown interface
|
|
||||||
HRESULT QueryInterface(const GUID& riid, void** ppvObject) override;
|
|
||||||
// IDirectDrawSurface interface
|
|
||||||
HRESULT AddAttachedSurface(IDirectDrawSurface* lpDDSAttachedSurface) override;
|
|
||||||
HRESULT Blt(
|
|
||||||
LPRECT lpDestRect,
|
|
||||||
IDirectDrawSurface* lpDDSrcSurface,
|
|
||||||
LPRECT lpSrcRect,
|
|
||||||
DDBltFlags dwFlags,
|
|
||||||
LPDDBLTFX lpDDBltFx
|
|
||||||
) override;
|
|
||||||
HRESULT BltFast(DWORD dwX, DWORD dwY, IDirectDrawSurface* lpDDSrcSurface, LPRECT lpSrcRect, DDBltFastFlags dwTrans)
|
|
||||||
override;
|
|
||||||
HRESULT Flip(IDirectDrawSurface* lpDDSurfaceTargetOverride, DDFlipFlags dwFlags) override;
|
|
||||||
HRESULT GetAttachedSurface(LPDDSCAPS lpDDSCaps, IDirectDrawSurface** lplpDDAttachedSurface) override;
|
|
||||||
HRESULT GetDC(HDC* lphDC) override;
|
|
||||||
HRESULT GetPalette(LPDIRECTDRAWPALETTE* lplpDDPalette) override;
|
|
||||||
HRESULT GetPixelFormat(LPDDPIXELFORMAT lpDDPixelFormat) override;
|
|
||||||
HRESULT GetSurfaceDesc(DDSURFACEDESC* lpDDSurfaceDesc) override;
|
|
||||||
HRESULT IsLost() override;
|
|
||||||
HRESULT Lock(LPRECT lpDestRect, DDSURFACEDESC* lpDDSurfaceDesc, DDLockFlags dwFlags, HANDLE hEvent) override;
|
|
||||||
HRESULT ReleaseDC(HDC hDC) override;
|
|
||||||
HRESULT Restore() override;
|
|
||||||
HRESULT SetClipper(IDirectDrawClipper* lpDDClipper) override;
|
|
||||||
HRESULT SetColorKey(DDColorKeyFlags dwFlags, LPDDCOLORKEY lpDDColorKey) override;
|
|
||||||
HRESULT SetPalette(LPDIRECTDRAWPALETTE lpDDPalette) override;
|
|
||||||
HRESULT Unlock(LPVOID lpSurfaceData) override;
|
|
||||||
|
|
||||||
// added
|
|
||||||
inline GXMDisplayBuffer* backBuffer() {
|
|
||||||
return &displayBuffers[backBufferIndex];
|
|
||||||
}
|
|
||||||
inline SceGxmRenderTarget* GetRenderTarget() {
|
|
||||||
return this->renderTarget;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
SceGxmContext* context;
|
|
||||||
SceGxmShaderPatcher* shaderPatcher;
|
|
||||||
SceGxmRenderTarget* renderTarget;
|
|
||||||
SceClibMspace cdramPool;
|
|
||||||
|
|
||||||
SceGxmShaderPatcherId blitVertexProgramId;
|
|
||||||
SceGxmVertexProgram* blitVertexProgram;
|
|
||||||
SceGxmShaderPatcherId blitColorFragmentProgramId;
|
|
||||||
SceGxmFragmentProgram* blitColorFragmentProgram;
|
|
||||||
SceGxmShaderPatcherId blitTexFragmentProgramId;
|
|
||||||
SceGxmFragmentProgram* blitTexFragmentProgram;
|
|
||||||
|
|
||||||
const SceGxmProgramParameter* uScreenMatrix;
|
|
||||||
const SceGxmProgramParameter* uColor;
|
|
||||||
const SceGxmProgramParameter* uTexMatrix;
|
|
||||||
|
|
||||||
void* quadMeshBuffer;
|
|
||||||
float* quadVerticies;
|
|
||||||
uint16_t* quadIndicies;
|
|
||||||
|
|
||||||
GXMDisplayBuffer displayBuffers[VITA_GXM_DISPLAY_BUFFER_COUNT];
|
|
||||||
int backBufferIndex = 0;
|
|
||||||
int frontBufferIndex = 1;
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
bool sceneStarted;
|
|
||||||
IDirectDrawPalette* m_palette = nullptr;
|
|
||||||
};
|
|
||||||
413
sdl3.patch
413
sdl3.patch
@ -1,413 +0,0 @@
|
|||||||
diff --git a/include/SDL3/SDL_gxm.h b/include/SDL3/SDL_gxm.h
|
|
||||||
new file mode 100644
|
|
||||||
index 000000000..1a80e2664
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/include/SDL3/SDL_gxm.h
|
|
||||||
@@ -0,0 +1,33 @@
|
|
||||||
+#ifndef SDL_gxm_h_
|
|
||||||
+#define SDL_gxm_h_
|
|
||||||
+
|
|
||||||
+#include <SDL3/SDL_stdinc.h>
|
|
||||||
+#include <SDL3/SDL_error.h>
|
|
||||||
+
|
|
||||||
+#include <psp2/gxm.h>
|
|
||||||
+#include <psp2/kernel/clib.h>
|
|
||||||
+
|
|
||||||
+#include <SDL3/SDL_begin_code.h>
|
|
||||||
+/* Set up for C function definitions, even when using C++ */
|
|
||||||
+#ifdef __cplusplus
|
|
||||||
+extern "C" {
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
+typedef struct {
|
|
||||||
+ void *address;
|
|
||||||
+ Uint8 wait_vblank;
|
|
||||||
+} VITA_GXM_DisplayData;
|
|
||||||
+
|
|
||||||
+extern SceClibMspace SDL_gxm_get_cdramPool();
|
|
||||||
+
|
|
||||||
+extern int SDL_gxm_init();
|
|
||||||
+extern bool SDL_gxm_is_init();
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+/* Ends C function definitions when using C++ */
|
|
||||||
+#ifdef __cplusplus
|
|
||||||
+}
|
|
||||||
+#endif
|
|
||||||
+#include <SDL3/SDL_close_code.h>
|
|
||||||
+
|
|
||||||
+#endif
|
|
||||||
\ No newline at end of file
|
|
||||||
diff --git a/src/SDL_error.c b/src/SDL_error.c
|
|
||||||
index 3f4273b4f..e41b8d81b 100644
|
|
||||||
--- a/src/SDL_error.c
|
|
||||||
+++ b/src/SDL_error.c
|
|
||||||
@@ -66,7 +66,7 @@ bool SDL_SetErrorV(SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap)
|
|
||||||
// Enable this if you want to see all errors printed as they occur.
|
|
||||||
// Note that there are many recoverable errors that may happen internally and
|
|
||||||
// can be safely ignored if the public API doesn't return an error code.
|
|
||||||
-#if 0
|
|
||||||
+#if 1
|
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "%s", error->str);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
|
|
||||||
index 0a088a8b4..cace29340 100644
|
|
||||||
--- a/src/render/SDL_render.c
|
|
||||||
+++ b/src/render/SDL_render.c
|
|
||||||
@@ -2871,7 +2871,7 @@ static void SDL_RenderLogicalPresentation(SDL_Renderer *renderer)
|
|
||||||
|
|
||||||
// now set everything back.
|
|
||||||
view->logical_presentation_mode = mode;
|
|
||||||
- SDL_SetRenderViewport(renderer, &orig_viewport);
|
|
||||||
+ //SDL_SetRenderViewport(renderer, &orig_viewport);
|
|
||||||
if (clipping_enabled) {
|
|
||||||
SDL_SetRenderClipRect(renderer, &orig_cliprect);
|
|
||||||
}
|
|
||||||
@@ -3040,7 +3040,7 @@ bool SDL_SetRenderViewport(SDL_Renderer *renderer, const SDL_Rect *rect)
|
|
||||||
SDL_RenderViewState *view = renderer->view;
|
|
||||||
if (rect) {
|
|
||||||
if ((rect->w < 0) || (rect->h < 0)) {
|
|
||||||
- return SDL_SetError("rect has a negative size");
|
|
||||||
+ return SDL_SetError("rect has a negative size %d %d", rect->w, rect->h);
|
|
||||||
}
|
|
||||||
SDL_copyp(&view->viewport, rect);
|
|
||||||
} else {
|
|
||||||
diff --git a/src/render/opengles2/SDL_shaders_gles2.c b/src/render/opengles2/SDL_shaders_gles2.c
|
|
||||||
index 3bff21178..0b6dace68 100644
|
|
||||||
--- a/src/render/opengles2/SDL_shaders_gles2.c
|
|
||||||
+++ b/src/render/opengles2/SDL_shaders_gles2.c
|
|
||||||
@@ -130,9 +130,7 @@ static const char GLES2_Fragment_TextureARGB[] =
|
|
||||||
"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 @@ static const char GLES2_Fragment_TextureRGB[] =
|
|
||||||
"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 @@ static const char GLES2_Fragment_TextureARGB_PixelArt[] =
|
|
||||||
"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 @@ static const char GLES2_Fragment_TextureRGB_PixelArt[] =
|
|
||||||
"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/src/render/vitagxm/SDL_render_vita_gxm.c b/src/render/vitagxm/SDL_render_vita_gxm.c
|
|
||||||
index 039155b73..dc1640634 100644
|
|
||||||
--- a/src/render/vitagxm/SDL_render_vita_gxm.c
|
|
||||||
+++ b/src/render/vitagxm/SDL_render_vita_gxm.c
|
|
||||||
@@ -1197,6 +1197,11 @@ static bool VITA_GXM_RenderPresent(SDL_Renderer *renderer)
|
|
||||||
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->internal;
|
|
||||||
SceCommonDialogUpdateParam updateParam;
|
|
||||||
|
|
||||||
+ uint32_t* pixels = data->displayBufferData[data->backBufferIndex];
|
|
||||||
+ for(int i = 0; i < 10*960; i++) {
|
|
||||||
+ pixels[i] = 0xffffffff;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
data->displayData.address = data->displayBufferData[data->backBufferIndex];
|
|
||||||
|
|
||||||
SDL_memset(&updateParam, 0, sizeof(updateParam));
|
|
||||||
diff --git a/src/render/vitagxm/SDL_render_vita_gxm_memory.c b/src/render/vitagxm/SDL_render_vita_gxm_memory.c
|
|
||||||
index e37a345c3..1a3904433 100644
|
|
||||||
--- a/src/render/vitagxm/SDL_render_vita_gxm_memory.c
|
|
||||||
+++ b/src/render/vitagxm/SDL_render_vita_gxm_memory.c
|
|
||||||
@@ -25,6 +25,9 @@
|
|
||||||
|
|
||||||
#include "SDL_render_vita_gxm_memory.h"
|
|
||||||
|
|
||||||
+static SceUID cdramPoolUID = -1;
|
|
||||||
+static SceClibMspace cdramPool = NULL;
|
|
||||||
+
|
|
||||||
void *vita_mem_alloc(unsigned int type, unsigned int size, unsigned int alignment, unsigned int attribs, SceUID *uid)
|
|
||||||
{
|
|
||||||
void *mem;
|
|
||||||
@@ -64,61 +67,70 @@ void vita_mem_free(SceUID uid)
|
|
||||||
sceKernelFreeMemBlock(uid);
|
|
||||||
}
|
|
||||||
|
|
||||||
-void *vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int size)
|
|
||||||
-{
|
|
||||||
- void *mem;
|
|
||||||
+static bool cdramPool_init() {
|
|
||||||
+ if(cdramPool) {
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+ int poolsize;
|
|
||||||
+ int ret;
|
|
||||||
+ void* mem;
|
|
||||||
+ SceKernelFreeMemorySizeInfo info;
|
|
||||||
+ info.size = sizeof(SceKernelFreeMemorySizeInfo);
|
|
||||||
+ sceKernelGetFreeMemorySize(&info);
|
|
||||||
+
|
|
||||||
+ poolsize = ALIGN(info.size_cdram, 256 * 1024);
|
|
||||||
+ if (poolsize > info.size_cdram) {
|
|
||||||
+ poolsize = ALIGN(info.size_cdram - 256 * 1024, 256 * 1024);
|
|
||||||
+ }
|
|
||||||
+ poolsize -= 16 * 1024 * 1024;
|
|
||||||
+ cdramPoolUID = sceKernelAllocMemBlock("gpu_cdram_pool", SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW, poolsize, NULL);
|
|
||||||
+ if (cdramPool < 0) {
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
|
|
||||||
- if (!data->texturePool) {
|
|
||||||
- int poolsize;
|
|
||||||
- int ret;
|
|
||||||
- SceKernelFreeMemorySizeInfo info;
|
|
||||||
- info.size = sizeof(SceKernelFreeMemorySizeInfo);
|
|
||||||
- sceKernelGetFreeMemorySize(&info);
|
|
||||||
+ ret = sceKernelGetMemBlockBase(cdramPoolUID, &mem);
|
|
||||||
+ if (ret < 0) {
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+ cdramPool = sceClibMspaceCreate(mem, poolsize);
|
|
||||||
|
|
||||||
- poolsize = ALIGN(info.size_cdram, 256 * 1024);
|
|
||||||
- if (poolsize > info.size_cdram) {
|
|
||||||
- poolsize = ALIGN(info.size_cdram - 256 * 1024, 256 * 1024);
|
|
||||||
- }
|
|
||||||
- data->texturePoolUID = sceKernelAllocMemBlock("gpu_texture_pool", SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW, poolsize, NULL);
|
|
||||||
- if (data->texturePoolUID < 0) {
|
|
||||||
- return NULL;
|
|
||||||
- }
|
|
||||||
+ if (!cdramPool) {
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+ ret = sceGxmMapMemory(mem, poolsize, SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE);
|
|
||||||
+ if (ret < 0) {
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+ return true;
|
|
||||||
+}
|
|
||||||
|
|
||||||
- ret = sceKernelGetMemBlockBase(data->texturePoolUID, &mem);
|
|
||||||
- if (ret < 0) {
|
|
||||||
- return NULL;
|
|
||||||
- }
|
|
||||||
- data->texturePool = sceClibMspaceCreate(mem, poolsize);
|
|
||||||
+SceClibMspace SDL_gxm_get_cdramPool() {
|
|
||||||
+ cdramPool_init();
|
|
||||||
+ return cdramPool;
|
|
||||||
+}
|
|
||||||
|
|
||||||
- if (!data->texturePool) {
|
|
||||||
- return NULL;
|
|
||||||
- }
|
|
||||||
- ret = sceGxmMapMemory(mem, poolsize, SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE);
|
|
||||||
- if (ret < 0) {
|
|
||||||
- return NULL;
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- return sceClibMspaceMemalign(data->texturePool, SCE_GXM_TEXTURE_ALIGNMENT, size);
|
|
||||||
+void *vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int alignment, unsigned int size)
|
|
||||||
+{
|
|
||||||
+ cdramPool_init();
|
|
||||||
+ return sceClibMspaceMemalign(cdramPool, alignment, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void vita_gpu_mem_free(VITA_GXM_RenderData *data, void *ptr)
|
|
||||||
{
|
|
||||||
- if (data->texturePool) {
|
|
||||||
- sceClibMspaceFree(data->texturePool, ptr);
|
|
||||||
- }
|
|
||||||
+ sceClibMspaceFree(cdramPool, ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void vita_gpu_mem_destroy(VITA_GXM_RenderData *data)
|
|
||||||
{
|
|
||||||
void *mem = NULL;
|
|
||||||
- if (data->texturePool) {
|
|
||||||
- sceClibMspaceDestroy(data->texturePool);
|
|
||||||
- data->texturePool = NULL;
|
|
||||||
- if (sceKernelGetMemBlockBase(data->texturePoolUID, &mem) < 0) {
|
|
||||||
+ if (cdramPool) {
|
|
||||||
+ sceClibMspaceDestroy(cdramPool);
|
|
||||||
+ cdramPool = NULL;
|
|
||||||
+ if (sceKernelGetMemBlockBase(cdramPoolUID, &mem) < 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sceGxmUnmapMemory(mem);
|
|
||||||
- sceKernelFreeMemBlock(data->texturePoolUID);
|
|
||||||
+ sceKernelFreeMemBlock(cdramPoolUID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/src/render/vitagxm/SDL_render_vita_gxm_memory.h b/src/render/vitagxm/SDL_render_vita_gxm_memory.h
|
|
||||||
index cc548b3ba..18d011c8b 100644
|
|
||||||
--- a/src/render/vitagxm/SDL_render_vita_gxm_memory.h
|
|
||||||
+++ b/src/render/vitagxm/SDL_render_vita_gxm_memory.h
|
|
||||||
@@ -31,7 +31,7 @@
|
|
||||||
|
|
||||||
void *vita_mem_alloc(unsigned int type, unsigned int size, unsigned int alignment, unsigned int attribs, SceUID *uid);
|
|
||||||
void vita_mem_free(SceUID uid);
|
|
||||||
-void *vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int size);
|
|
||||||
+void *vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int alignment, unsigned int size);
|
|
||||||
void vita_gpu_mem_free(VITA_GXM_RenderData *data, void *ptr);
|
|
||||||
void vita_gpu_mem_destroy(VITA_GXM_RenderData *data);
|
|
||||||
void *vita_mem_vertex_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_offset);
|
|
||||||
diff --git a/src/render/vitagxm/SDL_render_vita_gxm_tools.c b/src/render/vitagxm/SDL_render_vita_gxm_tools.c
|
|
||||||
index 48af7b8f6..b12a5bfd9 100644
|
|
||||||
--- a/src/render/vitagxm/SDL_render_vita_gxm_tools.c
|
|
||||||
+++ b/src/render/vitagxm/SDL_render_vita_gxm_tools.c
|
|
||||||
@@ -291,6 +291,38 @@ void unset_clip_rectangle(VITA_GXM_RenderData *data)
|
|
||||||
0xFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
+static bool gxm_initialized = false;
|
|
||||||
+
|
|
||||||
+bool SDL_gxm_is_init() {
|
|
||||||
+ return gxm_initialized;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+__weak_symbol void load_razor() {}
|
|
||||||
+
|
|
||||||
+int SDL_gxm_init() {
|
|
||||||
+ if(gxm_initialized) {
|
|
||||||
+ return 0;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ load_razor();
|
|
||||||
+
|
|
||||||
+ SceGxmInitializeParams initializeParams;
|
|
||||||
+ SDL_memset(&initializeParams, 0, sizeof(SceGxmInitializeParams));
|
|
||||||
+ initializeParams.flags = 0;
|
|
||||||
+ initializeParams.displayQueueMaxPendingCount = VITA_GXM_PENDING_SWAPS;
|
|
||||||
+ initializeParams.displayQueueCallback = display_callback;
|
|
||||||
+ initializeParams.displayQueueCallbackDataSize = sizeof(VITA_GXM_DisplayData);
|
|
||||||
+ initializeParams.parameterBufferSize = SCE_GXM_DEFAULT_PARAMETER_BUFFER_SIZE;
|
|
||||||
+
|
|
||||||
+ int err = sceGxmInitialize(&initializeParams);
|
|
||||||
+ if (err != 0) {
|
|
||||||
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "gxm init failed: %d", err);
|
|
||||||
+ return err;
|
|
||||||
+ }
|
|
||||||
+ gxm_initialized = true;
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
int gxm_init(SDL_Renderer *renderer)
|
|
||||||
{
|
|
||||||
unsigned int i, x, y;
|
|
||||||
@@ -376,18 +408,8 @@ int gxm_init(SDL_Renderer *renderer)
|
|
||||||
|
|
||||||
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->internal;
|
|
||||||
|
|
||||||
- SceGxmInitializeParams initializeParams;
|
|
||||||
- SDL_memset(&initializeParams, 0, sizeof(SceGxmInitializeParams));
|
|
||||||
- initializeParams.flags = 0;
|
|
||||||
- initializeParams.displayQueueMaxPendingCount = VITA_GXM_PENDING_SWAPS;
|
|
||||||
- initializeParams.displayQueueCallback = display_callback;
|
|
||||||
- initializeParams.displayQueueCallbackDataSize = sizeof(VITA_GXM_DisplayData);
|
|
||||||
- initializeParams.parameterBufferSize = SCE_GXM_DEFAULT_PARAMETER_BUFFER_SIZE;
|
|
||||||
-
|
|
||||||
- err = sceGxmInitialize(&initializeParams);
|
|
||||||
-
|
|
||||||
- if (err != 0) {
|
|
||||||
- SDL_LogError(SDL_LOG_CATEGORY_RENDER, "gxm init failed: %d", err);
|
|
||||||
+ err = SDL_gxm_init();
|
|
||||||
+ if(err != 0) {
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -464,6 +486,10 @@ int gxm_init(SDL_Renderer *renderer)
|
|
||||||
SCE_GXM_COLOR_SURFACE_ALIGNMENT,
|
|
||||||
SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE,
|
|
||||||
&data->displayBufferUid[i]);
|
|
||||||
+ if(!data->displayBufferData[i]) {
|
|
||||||
+ SDL_Log("failed to allocate display buffer");
|
|
||||||
+ return -1;
|
|
||||||
+ }
|
|
||||||
|
|
||||||
// SDL_memset the buffer to black
|
|
||||||
for (y = 0; y < VITA_GXM_SCREEN_HEIGHT; y++) {
|
|
||||||
@@ -535,7 +561,6 @@ int gxm_init(SDL_Renderer *renderer)
|
|
||||||
SCE_GXM_STENCIL_OP_KEEP,
|
|
||||||
0xFF,
|
|
||||||
0xFF);
|
|
||||||
-
|
|
||||||
// allocate memory for buffers and USSE code
|
|
||||||
patcherBuffer = vita_mem_alloc(
|
|
||||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE,
|
|
||||||
@@ -1012,6 +1037,7 @@ gxm_texture *create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsig
|
|
||||||
// Allocate a GPU buffer for the texture
|
|
||||||
texture_data = vita_gpu_mem_alloc(
|
|
||||||
data,
|
|
||||||
+ SCE_GXM_TEXTURE_ALIGNMENT,
|
|
||||||
tex_size);
|
|
||||||
|
|
||||||
// Try SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE in case we're out of VRAM
|
|
||||||
diff --git a/src/render/vitagxm/SDL_render_vita_gxm_types.h b/src/render/vitagxm/SDL_render_vita_gxm_types.h
|
|
||||||
index 6fc2c9e81..06ccecc91 100644
|
|
||||||
--- a/src/render/vitagxm/SDL_render_vita_gxm_types.h
|
|
||||||
+++ b/src/render/vitagxm/SDL_render_vita_gxm_types.h
|
|
||||||
@@ -25,6 +25,7 @@
|
|
||||||
#include "SDL_internal.h"
|
|
||||||
|
|
||||||
#include "../SDL_sysrender.h"
|
|
||||||
+#include <SDL3/SDL_gxm.h>
|
|
||||||
|
|
||||||
#include <psp2/kernel/processmgr.h>
|
|
||||||
#include <psp2/appmgr.h>
|
|
||||||
@@ -47,12 +48,6 @@
|
|
||||||
#define VITA_GXM_PENDING_SWAPS 2
|
|
||||||
#define VITA_GXM_POOL_SIZE 2 * 1024 * 1024
|
|
||||||
|
|
||||||
-typedef struct
|
|
||||||
-{
|
|
||||||
- void *address;
|
|
||||||
- Uint8 wait_vblank;
|
|
||||||
-} VITA_GXM_DisplayData;
|
|
||||||
-
|
|
||||||
typedef struct clear_vertex
|
|
||||||
{
|
|
||||||
float x;
|
|
||||||
@@ -193,8 +188,6 @@ typedef struct
|
|
||||||
blend_fragment_programs blendFragmentPrograms;
|
|
||||||
|
|
||||||
gxm_drawstate_cache drawstate;
|
|
||||||
- SceClibMspace texturePool;
|
|
||||||
- SceUID texturePoolUID;
|
|
||||||
} VITA_GXM_RenderData;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c
|
|
||||||
index f40a92d85..b46b94730 100644
|
|
||||||
--- a/src/video/SDL_surface.c
|
|
||||||
+++ b/src/video/SDL_surface.c
|
|
||||||
@@ -271,6 +271,7 @@ SDL_Surface *SDL_CreateSurfaceFrom(int width, int height, SDL_PixelFormat format
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pitch < 0 || (size_t)pitch < minimalPitch) {
|
|
||||||
+ SDL_Log("pitch=%d minimalPitch=%d", pitch, minimalPitch);
|
|
||||||
SDL_InvalidParamError("pitch");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user