Skip to content

Commit

Permalink
PSV: Support gxm graphics api
Browse files Browse the repository at this point in the history
  • Loading branch information
xfangfang committed Nov 14, 2024
1 parent 46ae986 commit 14ed2f9
Show file tree
Hide file tree
Showing 20 changed files with 3,624 additions and 73 deletions.
21 changes: 19 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,37 @@ jobs:

psv:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- { driver: gxm }
- { driver: gles2 }
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Build

- name: Build GLES2
if: ${{ matrix.driver == 'gles2' }}
run: |
docker run --rm -v $(pwd):/src/ xfangfang/vitasdk_sdl2_gles2:latest \
"cmake -B build -G Ninja -DPLATFORM_PSV=ON -DUSE_SYSTEM_SDL2=ON -DCMAKE_BUILD_TYPE=Release && \
cmake --build build"
- name: Build GXM
if: ${{ matrix.driver == 'gxm' }}
run: |
echo "cd /src" > build_gxm.sh
echo "cmake -B build -DPLATFORM_PSV=ON -DCMAKE_BUILD_TYPE=Release -DUSE_GXM=ON" >> build_gxm.sh
echo "cmake --build build -- -j$(nproc)" >> build_gxm.sh
docker run --rm -v $(pwd):/src/ vitasdk/vitasdk:latest sh -C /src/build_gxm.sh
- name: Upload dist
uses: actions/upload-artifact@v4
with:
name: borealis-psv
name: borealis-psv-${{ matrix.driver }}
path: build/*.vpk

switch:
Expand Down
27 changes: 13 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,21 @@ if (PLATFORM_DESKTOP)
elseif (PLATFORM_PSV)
set(VITA_MKSFOEX_FLAGS "${VITA_MKSFOEX_FLAGS} -d ATTRIBUTE2=12") # max heap size mode
vita_create_self(${PROJECT_NAME}.self ${PROJECT_NAME} UNSAFE)
if (USE_LIBROMFS)
vita_create_vpk(${PROJECT_NAME}.vpk ${PSN_TITLE_ID} ${PROJECT_NAME}.self
VERSION ${PSN_VERSION}
NAME ${PROJECT_NAME}
FILE ${CMAKE_SOURCE_DIR}/psv/sce_sys sce_sys
FILE ${CMAKE_SOURCE_DIR}/psv/module/ module
)
else()
vita_create_vpk(${PROJECT_NAME}.vpk ${PSN_TITLE_ID} ${PROJECT_NAME}.self
set(PSV_ASSETS_FILES ${CMAKE_SOURCE_DIR}/psv/sce_sys sce_sys)
if (NOT USE_LIBROMFS)
list(APPEND PSV_ASSETS_FILES ${CMAKE_SOURCE_DIR}/resources resources)
endif ()
if (NOT USE_GXM)
list(APPEND PSV_ASSETS_FILES ${CMAKE_SOURCE_DIR}/psv/module/ module)
endif ()
if (USE_VITA_SHARK)
list(APPEND PSV_ASSETS_FILES "${CMAKE_BINARY_DIR}/vendor/SceShaccCg" module)
endif ()
vita_create_vpk(${PROJECT_NAME}.vpk ${PSN_TITLE_ID} ${PROJECT_NAME}.self
VERSION ${PSN_VERSION}
NAME ${PROJECT_NAME}
FILE ${CMAKE_SOURCE_DIR}/resources resources
FILE ${CMAKE_SOURCE_DIR}/psv/sce_sys sce_sys
FILE ${CMAKE_SOURCE_DIR}/psv/module/ module
)
endif()
FILE ${PSV_ASSETS_FILES}
)
elseif (PLATFORM_PS4)
# There is no `add_self` and `add_pkg` functions without pacbrew toolchain.
# We can install the OpenOrbits SDK so that the IDE can provide some basic code prompts,
Expand Down
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ Check the [daily builds](https://github.com/xfangfang/borealis/actions) for what
To build for Switch, a standard development environment must first be set up. In order to do so, [refer to the Getting Started guide](https://devkitpro.org/wiki/Getting_Started).

```bash
# 1. OpenGL
cmake -B build_switch -DPLATFORM_SWITCH=ON
make -C build_switch borealis_demo.nro -j$(nproc)

# 2. deko3d
cmake -B build_switch -DPLATFORM_SWITCH=ON -DUSE_DEKO3D=ON
make -C build_switch borealis_demo.nro -j$(nproc)
```

## Building the demo for PC
Expand Down Expand Up @@ -70,16 +75,26 @@ xmake b -y demo
## Building the demo for PSV

- install [VITASDK](https://github.com/vitasdk/vdpm)
- install [PVR_PSP2](https://github.com/GrapheneCt/PVR_PSP2) headers and libs. refer to: [SDL/vita.yaml](https://github.com/libsdl-org/SDL/blob/5733f42c7c2cbfbbd03282919534ed30c3b07da6/.github/workflows/vita.yaml#L28-L44)
- put `*.suprx` files ([PVR_PSP2](https://github.com/GrapheneCt/PVR_PSP2)) to `psv/module`
- (GLES2.0 Only) install [PVR_PSP2](https://github.com/GrapheneCt/PVR_PSP2) headers and libs. refer to: [SDL/vita.yaml](https://github.com/libsdl-org/SDL/blob/5733f42c7c2cbfbbd03282919534ed30c3b07da6/.github/workflows/vita.yaml#L28-L44)
- (GLES2.0 Only) put `*.suprx` files ([PVR_PSP2](https://github.com/GrapheneCt/PVR_PSP2)) to `psv/module`
- Unlock unsafe mode in `System Settings/HENkaku`

> We only need: `libGLESv2.suprx` `libgpu_es4_ext.suprx` `libIMGEGL.suprx` `libpvrPSP2_WSEGL.suprx`
> Overclock ES4(GPU) to 166MHz or higher for a smoother experience.
> (GLES2.0 Only) We only need: `libGLESv2.suprx` `libgpu_es4_ext.suprx` `libIMGEGL.suprx` `libpvrPSP2_WSEGL.suprx`
> (GLES2.0 Only) Overclock ES4(GPU) to 166MHz or higher for a smoother experience.
```bash
# 1. OpenGL ES 2.0
cmake -B build_psv -DPLATFORM_PSV=ON
make -C build_psv borealis_demo.vpk -j$(nproc)

# 2. OpenGL ES 2.0; Using Docker image
docker run --rm -v $(pwd):/src/ xfangfang/vitasdk_sdl2_gles2:latest \
"cmake -B build -G Ninja -DPLATFORM_PSV=ON -DUSE_SYSTEM_SDL2=ON -DCMAKE_BUILD_TYPE=Release && \
cmake --build build"

# 3. GXM
cmake -B build_psv -DPLATFORM_PSV=ON -DUSE_GXM=ON
make -C build_psv borealis_demo.vpk -j$(nproc)
```

#### My daily development experience on PSV
Expand Down
72 changes: 54 additions & 18 deletions library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,27 +116,58 @@ if (PLATFORM_DESKTOP)
list(APPEND BOREALIS_SOURCE ${BOREALIS_PATH}/lib/platforms/desktop)
set(BRLS_PLATFORM_RESOURCES_PATH "\"${BRLS_RESOURCES_DIR}/resources/\"")
elseif (PLATFORM_PSV)
if (USE_SYSTEM_SDL2)
find_package(SDL2 REQUIRED)
else ()
set(BUILD_SHARED_LIBS OFF)
set(VIDEO_VITA_PVR ON CACHE BOOL "")
add_subdirectory(${BOREALIS_PATH}/lib/extern/SDL EXCLUDE_FROM_ALL)
endif ()
list(APPEND BOREALIS_SOURCE
${BOREALIS_PATH}/lib/platforms/psv
${BOREALIS_PATH}/lib/platforms/sdl
${BOREALIS_PATH}/lib/platforms/desktop)
list(APPEND BOREALIS_SOURCE ${BOREALIS_PATH}/lib/platforms/desktop)
list(APPEND BRLS_PLATFORM_LIBS
SDL2::SDL2-static
libgpu_es4_ext_stub_weak
libIMGEGL_stub_weak
libGLESv2_stub_weak
SceGxm_stub
SceDisplay_stub
SceCtrl_stub
SceCommonDialog_stub
SceTouch_stub
SceAppUtil_stub
SceCtrl_stub
SceIme_stub
ScePower_stub
SceAVConfig_stub
SceRegistryMgr_stub
-Wl,--whole-archive -lpthread -Wl,--no-whole-archive
)
list(APPEND BRLS_PLATFORM_OPTION -D__SDL2__ -D__PSV__ -DUSE_GLES2)
-Wl,--whole-archive -lpthread -Wl,--no-whole-archive)
if (BOREALIS_USE_GXM)
if (USE_VITA_SHARK)
include(FetchContent)
FetchContent_Populate(
libshacccg
URL "https://codeload.github.com/AnimMouse/SceShaccCg/zip/refs/heads/main"
SOURCE_DIR "${CMAKE_BINARY_DIR}/vendor/SceShaccCg"
SUBBUILD_DIR "${CMAKE_BINARY_DIR}/CMakeFiles/SceShaccCg"
BINARY_DIR "${CMAKE_BINARY_DIR}/CMakeFiles/SceShaccCg"
)
list(APPEND BRLS_PLATFORM_LIBS
vitashark
SceShaccCgExt
taihen_stub
SceShaccCg_stub
)
endif ()
file(GLOB_RECURSE PSV_PLATFORM_SRC "${BOREALIS_PATH}/lib/platforms/psv/*.cpp")
list(APPEND BOREALIS_SRC ${PSV_PLATFORM_SRC})
else()
if (USE_SYSTEM_SDL2)
find_package(SDL2 REQUIRED)
else ()
set(BUILD_SHARED_LIBS OFF)
set(VIDEO_VITA_PVR ${BOREALIS_USE_GXM} CACHE BOOL "")
add_subdirectory(${BOREALIS_PATH}/lib/extern/SDL EXCLUDE_FROM_ALL)
endif ()
list(APPEND BRLS_PLATFORM_LIBS
SDL2::SDL2-static
libgpu_es4_ext_stub_weak
libIMGEGL_stub_weak
libGLESv2_stub_weak)
# Using SDL implementation instead
file(GLOB_RECURSE SDL_PLATFORM_SRC "${BOREALIS_PATH}/lib/platforms/sdl/*.cpp")
list(APPEND BOREALIS_SRC ${SDL_PLATFORM_SRC})
list(APPEND BOREALIS_SRC ${BOREALIS_PATH}/lib/platforms/psv/psv_platform.cpp)
endif ()
list(APPEND BRLS_PLATFORM_OPTION -D__PSV__ -DSTBI_NEON)
set(BRLS_PLATFORM_RESOURCES_PATH "\"app0:resources/\"")
set_target_properties(yogacore PROPERTIES POSITION_INDEPENDENT_CODE OFF)
elseif(PLATFORM_PS4)
Expand Down Expand Up @@ -255,6 +286,11 @@ elseif (BOREALIS_USE_D3D11)
set(BOREALIS_DRIVER BOREALIS_USE_D3D11)
elseif (BOREALIS_USE_DEKO3D)
set(BOREALIS_DRIVER BOREALIS_USE_DEKO3D)
elseif (BOREALIS_USE_GXM)
set(BOREALIS_DRIVER BOREALIS_USE_GXM)
if (USE_VITA_SHARK)
list(APPEND BRLS_PLATFORM_OPTION -DUSE_VITA_SHARK)
endif ()
endif ()
list(APPEND BRLS_PLATFORM_OPTION -D${BOREALIS_DRIVER})
message(STATUS "borealis driver ${BOREALIS_DRIVER}")
Expand Down
4 changes: 4 additions & 0 deletions library/cmake/commonOption.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ cmake_dependent_option(INSTALL "Install to system." OFF "UNIX;NOT APPLE" OFF)
# PS4 Only
cmake_dependent_option(LIBJBC "Root access enabled" OFF "PLATFORM_PS4" OFF)

# PSVita Only
cmake_dependent_option(USE_GXM "Using gxm instead of OpenGL." OFF "PLATFORM_PSV" OFF)
cmake_dependent_option(USE_VITA_SHARK "Using runtime shader compiler." OFF "USE_GXM" OFF)

# iOS Only (If empty then not sign)
set(IOS_CODE_SIGN_IDENTITY "" CACHE STRING "The code sign identity to use when building the IPA.")
set(IOS_GUI_IDENTIFIER "" CACHE STRING "Package name.")
Expand Down
20 changes: 17 additions & 3 deletions library/cmake/toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ if (PLATFORM_DESKTOP)
message(STATUS "building for Desktop")
set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -g2 -ggdb -Wall")
set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
if (NOT USE_GLFW AND NOT SDL2)
set(USE_GLFW ON)
endif ()
elseif (PLATFORM_IOS OR PLATFORM_TVOS)
if(PLATFORM_IOS)
message(STATUS "building for iOS")
Expand Down Expand Up @@ -48,9 +51,12 @@ elseif(PLATFORM_ANDROID)
check_libromfs_generator()
elseif(PLATFORM_PSV)
message(STATUS "building for PSVita")
set(USE_SDL2 ON)
set(USE_SDL2 OFF)
set(USE_GLFW OFF)
set(USE_GLES2 ON)
if (NOT USE_GXM)
set(USE_GLES2 ON)
set(USE_SDL2 ON)
endif ()
if (NOT DEFINED ENV{VITASDK})
message(FATAL_ERROR "Please define VITASDK to point to your SDK path!")
endif ()
Expand Down Expand Up @@ -81,6 +87,9 @@ elseif (PLATFORM_SWITCH)
set(CMAKE_C_FLAGS "-I${DEVKITPRO}/libnx/include -I${DEVKITPRO}/portlibs/switch/include")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")
include(${DEVKITPRO}/cmake/Switch.cmake REQUIRED)
if (NOT USE_GLFW AND NOT SDL2)
set(USE_GLFW ON)
endif ()
else()
message(FATAL_ERROR "Please set build target. Example: -DPLATFORM_DESKTOP=ON or -DPLATFORM_SWITCH=ON")
endif ()
Expand All @@ -92,6 +101,9 @@ if (USE_DEKO3D)
elseif (USE_D3D11)
message(STATUS "USE_D3D11")
set(BOREALIS_USE_D3D11 ON)
elseif (USE_GXM)
message(STATUS "USE_GXM")
set(BOREALIS_USE_GXM ON)
elseif (USE_METAL)
message(STATUS "USE_METAL")
set(BOREALIS_USE_METAL ON)
Expand All @@ -114,11 +126,13 @@ if (USE_SDL2)
set(USE_SDL2 ON)
set(USE_GLFW OFF)
add_definitions(-D__SDL2__)
else ()
elseif (USE_GLFW)
message(STATUS "GLFW")
set(USE_SDL2 OFF)
set(USE_GLFW ON)
add_definitions(-D__GLFW__)
else ()
message(STATUS "SDL2 AND GLFW is both disabled, make sure this is what you want")
endif ()

if (SIMPLE_HIGHLIGHT)
Expand Down
1 change: 0 additions & 1 deletion library/include/borealis/core/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ class Application
inline static bool muteSounds = false;

inline static std::string commonFooter;
inline static NVGcolor backgroundColor{};

inline static bool globalQuitEnabled = false;
inline static ActionIdentifier gloablQuitIdentifier = ACTION_NONE;
Expand Down
Loading

0 comments on commit 14ed2f9

Please sign in to comment.