Skip to content

Commit

Permalink
Support GXM rendering api
Browse files Browse the repository at this point in the history
  • Loading branch information
xfangfang committed Jan 4, 2025
1 parent 0e5afca commit dc09f59
Show file tree
Hide file tree
Showing 10 changed files with 317 additions and 145 deletions.
136 changes: 20 additions & 116 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ jobs:
- name: Upload dist
uses: actions/upload-artifact@v4
with:
name: ${{ needs.version.outputs.DIST_NRO }}${{ matrix.shuffix }}
name: ${{ needs.version.outputs.DIST_NRO }}-${{ matrix.driver }}
path: "cmake-build-switch/wiliwili.nro"

build-ps4:
Expand Down Expand Up @@ -496,143 +496,47 @@ jobs:
needs: [ version ]
name: build-psv
runs-on: ubuntu-latest
container:
image: vitasdk/vitasdk:latest
strategy:
fail-fast: false
matrix:
include:
- { driver: gxm }
- { driver: gles2 }

steps:
- name: Install build requirements
run: |
apk update
apk add cmake ninja meson pkgconf bash git zstd tar
git config --global --add safe.directory $(pwd)
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- uses: actions/cache/restore@v4
id: restore-pvr-cache
with:
path: /vita/dependencies
key: SDL-vita-pvr-3.9

- name: Download PVR_PSP2 (GLES)
if: ${{ !steps.restore-pvr-cache.outputs.cache-hit }}
run: |
pvr_psp2_version=3.9
mkdir -p /vita/dependencies/include
mkdir -p /vita/dependencies/lib
mkdir -p /vita/dependencies/suprx
# Configure PVR_PSP2 headers
wget https://github.com/GrapheneCt/PVR_PSP2/archive/refs/tags/v$pvr_psp2_version.zip -P/tmp
unzip /tmp/v$pvr_psp2_version.zip -d/tmp
cp -r /tmp/PVR_PSP2-$pvr_psp2_version/include/* /vita/dependencies/include
rm /tmp/v$pvr_psp2_version.zip
# include guard of PVR_PSP2's khrplatform.h does not match the usual one
sed -i -e s/__drvkhrplatform_h_/__khrplatform_h_/ /vita/dependencies/include/KHR/khrplatform.h
# Configure PVR_PSP2 stub libraries
wget https://github.com/GrapheneCt/PVR_PSP2/releases/download/v$pvr_psp2_version/vitasdk_stubs.zip -P/tmp
unzip /tmp/vitasdk_stubs.zip -d/tmp/pvr_psp2_stubs
find /tmp/pvr_psp2_stubs -type f -name "*.a" -exec cp {} /vita/dependencies/lib \;
rm /tmp/vitasdk_stubs.zip
rm -rf /tmp/pvr_psp2_stubs
# Configure PVR_PSP2 *.suprx
wget https://github.com/GrapheneCt/PVR_PSP2/releases/download/v$pvr_psp2_version/PSVita_Release.zip -P/tmp
unzip /tmp/PSVita_Release.zip -d/tmp/PSVita_Release
rm /tmp/PSVita_Release/libGLESv1_CM.suprx
rm /tmp/PSVita_Release/libpvr2d.suprx
mv /tmp/PSVita_Release/*.suprx /vita/dependencies/suprx/
rm -rf /tmp/PSVita_Release.zip
rm -rf /tmp/PSVita_Release
- uses: actions/cache/save@v4
if: ${{ !steps.restore-pvr-cache.outputs.cache-hit }}
with:
path: /vita/dependencies
key: SDL-vita-pvr-3.9

- name: Copy PVR_PSP2 (GLES) to vita toolchain dir
- name: Build GLES2
if: ${{ matrix.driver == 'gles2' }}
run: |
cp -rv /vita/dependencies/* ${VITASDK}/arm-vita-eabi
mv /vita/dependencies/suprx/*.suprx scripts/psv/module/
ls -lah ${VITASDK}/arm-vita-eabi
ls -lah scripts/psv/module/
- uses: actions/cache/restore@v4
id: restore-common-deps-cache
with:
path: /vita/common_deps
key: Dep-vita-${{ hashFiles('**/VITABUILD') }}
docker run --rm -v $(pwd):/src/ xfangfang/wiliwili_psv_builder:latest \
"cmake -B build -G Ninja -DPLATFORM_PSV=ON -DUSE_SYSTEM_CURL=ON -DUSE_SYSTEM_SDL2=ON -DCMAKE_BUILD_TYPE=Release && \
cmake --build build"
- name: Install VDPM Dependencies
run: vdpm mbedtls libass harfbuzz fribidi freetype libpng libwebp

- name: Build Dependencies
if: ${{ !steps.restore-common-deps-cache.outputs.cache-hit }}
- name: Build GXM
if: ${{ matrix.driver == 'gxm' }}
run: |
mkdir -p /vita/common_deps
apk add patch
adduser --gecos '' --disabled-password builder
echo 'builder ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/builder
chown -R builder:builder $(pwd)/scripts/psv
su - builder -c "cd $(pwd)/scripts/psv/ffmpeg && vita-makepkg"
su - builder -c "cd $(pwd)/scripts/psv/curl && vita-makepkg"
su - builder -c "cd $(pwd)/scripts/psv/sdl2 && vita-makepkg"
vdpm $(pwd)/scripts/psv/ffmpeg/*-arm.tar.xz
vdpm $(pwd)/scripts/psv/sdl2/*-arm.tar.xz
touch /tmp/vdpm_install_ffmpeg
touch /tmp/vdpm_install_sdl2
su - builder -c "cd $(pwd)/scripts/psv/mpv && vita-makepkg"
mv $(pwd)/scripts/psv/curl/*-arm.tar.xz /vita/common_deps/
mv $(pwd)/scripts/psv/sdl2/*-arm.tar.xz /vita/common_deps/
mv $(pwd)/scripts/psv/ffmpeg/*-arm.tar.xz /vita/common_deps/
mv $(pwd)/scripts/psv/mpv/*-arm.tar.xz /vita/common_deps/
ls -lah /vita/common_deps/
- uses: actions/cache/save@v4
if: ${{ !steps.restore-common-deps-cache.outputs.cache-hit }}
with:
path: /vita/common_deps
key: Dep-vita-${{ hashFiles('**/VITABUILD') }}

- name: Install Dependencies
run: vdpm /vita/common_deps/*-arm.tar.xz

- name: Bulid wiliwili
run: |
cmake -S . -B build -G Ninja \
-DPLATFORM_PSV=ON \
-DUSE_SYSTEM_CURL=ON \
-DUSE_SYSTEM_SDL2=ON \
-DMPV_NO_FB=ON \
-DSIMPLE_HIGHLIGHT=ON \
-DCMAKE_BUILD_TYPE=Release \
-DBRLS_UNITY_BUILD=${{ github.event.inputs.disable_unity_build == 'true' && 'OFF' || 'ON' }} \
-DCMAKE_UNITY_BUILD_BATCH_SIZE=16 \
-DCMAKE_CXX_FLAGS="-Wno-error=pedantic -Wno-psabi"
cmake --build build --verbose
mv build/wiliwili.self build/eboot.bin
docker run --rm -v $(pwd):/src/ xfangfang/wiliwili_psv_builder:latest-gxm \
"cmake -B build -G Ninja -DPLATFORM_PSV=ON -DUSE_SYSTEM_CURL=ON -DUSE_GXM=ON -DUSE_VITA_SHARK=ON -DCMAKE_BUILD_TYPE=Release && \
cmake --build build"
- name: Upload vpk
uses: actions/upload-artifact@v4
with:
name: wiliwili-PSVita-${{ needs.version.outputs.VERSION }}
name: wiliwili-PSVita-${{ needs.version.outputs.VERSION }}-${{ matrix.driver }}
path: build/wiliwili.vpk

- name: Upload eboot
uses: actions/upload-artifact@v4
with:
name: psv_dev_eboot.bin
name: psv_dev_eboot_${{ matrix.driver }}.bin
path: build/eboot.bin

- name: Upload elf
uses: actions/upload-artifact@v4
with:
name: psv_dev_elf
name: psv_dev_elf_${{ matrix.driver }}
path: build/wiliwili
26 changes: 13 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -253,25 +253,25 @@ elseif (PLATFORM_IOS)
"wiliwili"
"${APP_VERSION}")
elseif (PLATFORM_PSV)
set(PSV_ASSETS_FILES ${CMAKE_SOURCE_DIR}/scripts/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}/scripts/psv/module/ module)
endif ()
if (USE_VITA_SHARK)
list(APPEND PSV_ASSETS_FILES "${CMAKE_BINARY_DIR}/vendor/SceShaccCg" module)
endif ()
set(VITA_MKSFOEX_FLAGS "${VITA_MKSFOEX_FLAGS} -d ATTRIBUTE2=12") # max heap size mode
# I don't know why, but only manually specifying the link libraries in this order will not cause the program to crash
set(APP_PLATFORM_LIB
stdc++;mpv;
avfilter;swscale;avformat;avcodec;swresample;avutil;
ass;harfbuzz;fribidi;freetype;bz2;png16;
webp;sharpyuv;
m;z;
SceCodecEngine_stub
SceVideodec_stub
SceAudiodec_stub)
vita_create_self(${PROJECT_NAME}.self ${PROJECT_NAME} UNSAFE NOASLR)
vita_create_vpk(${PROJECT_NAME}.vpk ${VITA_TITLEID} ${PROJECT_NAME}.self
VERSION ${VITA_VERSION}
NAME ${PROJECT_NAME}
FILE ${CMAKE_SOURCE_DIR}/resources resources
FILE ${CMAKE_SOURCE_DIR}/scripts/psv/sce_sys sce_sys
FILE ${CMAKE_SOURCE_DIR}/scripts/psv/module/ module
FILE ${PSV_ASSETS_FILES}
)
# TODO: Remove after mpv related code is done
list(APPEND APP_PLATFORM_LINK_OPTION "-Wl,--allow-multiple-definition")
elseif (PLATFORM_PS4)
add_self(${PROJECT_NAME})
add_pkg(${PROJECT_NAME}
Expand Down
16 changes: 12 additions & 4 deletions scripts/psv/ffmpeg/VITABUILD
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
pkgname=ffmpeg
pkgver=7900d3684acc8e5e98fd39cbb12cb7ab73e6d4a5
pkgrel=2
pkgver=3736b0c78da9553b2098dbb0ade0a2e0ddd1753f
pkgrel=3
url="https://ffmpeg.org/"
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/fish47/FFmpeg-vita/archive/${pkgver}.tar.gz")
sha256sums=('SKIP')
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/fish47/FFmpeg-vita/archive/${pkgver}.tar.gz" "optimize.patch")
sha256sums=('SKIP' 'SKIP')
depends=('mbedtls')

prepare() {
cd FFmpeg-vita-$pkgver
patch --strip=1 --input=${srcdir}/optimize.patch
}

build() {
cd FFmpeg-vita-$pkgver
./configure --prefix=$VITASDK/arm-vita-eabi \
--enable-vita \
--target-os=vita \
--enable-cross-compile \
--disable-runtime-cpudetect \
--disable-armv5te \
--cross-prefix=$VITASDK/bin/arm-vita-eabi- \
--extra-cflags=" -Wl,-q -O2 -ftree-vectorize -fomit-frame-pointer -ffast-math -D_BSD_SOURCE" \
--extra-cxxflags=" -Wl,-q -O2 -ftree-vectorize -fomit-frame-pointer -ffast-math -fno-rtti -fno-exceptions -std=gnu++11 -D_BSD_SOURCE" \
--extra-ldflags=" -L$VITASDK/lib " \
--disable-shared \
--enable-static \
--disable-programs \
Expand Down
31 changes: 31 additions & 0 deletions scripts/psv/ffmpeg/optimize.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
diff --git a/libavcodec/vitadec_video.c b/libavcodec/vitadec_video.c
index 8e0b6348c5..6a391be944 100644
--- a/libavcodec/vitadec_video.c
+++ b/libavcodec/vitadec_video.c
@@ -270,7 +270,7 @@ fail:
return false;
}

-static void do_mem_free(VitaDecodeBufferFreeParams *p)
+static void __attribute__((optimize("no-optimize-sibling-calls"))) do_mem_free(VitaDecodeBufferFreeParams *p)
{
sceKernelFreeMemBlock(*p->mb);
}
@@ -285,7 +285,7 @@ static bool do_unmap_open(VitaDecodeBufferAllocParams *p)
return true;
}

-static void do_unmap_close(VitaDecodeBufferFreeParams *p)
+static void __attribute__((optimize("no-optimize-sibling-calls"))) do_unmap_close(VitaDecodeBufferFreeParams *p)
{
sceCodecEngineCloseUnmapMemBlock(*p->mb);
}
@@ -302,7 +302,7 @@ static bool do_vaddr_alloc(VitaDecodeBufferAllocParams *p)
return true;
}

-static void do_vaddr_free(VitaDecodeBufferFreeParams *p)
+static void __attribute__((optimize("no-optimize-sibling-calls"))) do_vaddr_free(VitaDecodeBufferFreeParams *p)
{
SceUID *unmap = p->ref;
SceUIntVAddr *vaddr = p->ptr;
39 changes: 39 additions & 0 deletions scripts/psv/gxm.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM vitasdk/vitasdk:latest

MAINTAINER xfangfang <[email protected]>

RUN apk update && \
apk add cmake ninja meson pkgconf bash git zstd tar patch && \
git config --global --add safe.directory $(pwd)

# Install VDPM Dependencies
ADD . /vdpm
RUN vdpm sdl2 mbedtls libass harfbuzz fribidi freetype libpng libwebp && \
adduser --gecos '' --disabled-password builder && \
echo 'builder ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/builder && \
chown -R builder:builder /vdpm && \
ls -l /vdpm && \
su - builder -c "cd /vdpm/ffmpeg && vita-makepkg" && \
vdpm /vdpm/ffmpeg/*-arm.tar.xz && \
touch /tmp/vdpm_install_ffmpeg && \
su - builder -c "cd /vdpm/mpv_gxm && vita-makepkg" && \
vdpm /vdpm/mpv_gxm/*-arm.tar.xz && \
touch /tmp/vdpm_install_mpv && \
su - builder -c "cd /vdpm/curl && vita-makepkg" && \
vdpm /vdpm/curl/*-arm.tar.xz && \
touch /tmp/vdpm_install_curl && \
rm -rf /vdpm

RUN mkdir /src/ &&\
echo \#\!/bin/bash -i >> /entrypoint.sh &&\
echo >> /entrypoint.sh &&\
echo "set -e" >> /entrypoint.sh &&\
echo "cd /src" >> /entrypoint.sh &&\
echo "echo \"\$@\"" >> /entrypoint.sh &&\
echo "bash -c \"\$@\"" >> /entrypoint.sh &&\
chmod +x /entrypoint.sh

VOLUME /src/
WORKDIR /src/
SHELL ["/bin/bash", "-i", "-c"]
ENTRYPOINT ["/entrypoint.sh"]
36 changes: 36 additions & 0 deletions scripts/psv/mpv_gxm/VITABUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
pkgname=mpv
pkgver=e6f1d2fe199d3442150cef71de2aca3f7a554047
pkgrel=3
url="https://mpv.io/"
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/xfangfang/mpv/archive/${pkgver}.tar.gz")
sha256sums=('SKIP')
depends=('sdl2' 'libass' 'ffmpeg')

prepare() {
cd $pkgname-$pkgver
}

build() {
cd $pkgname-$pkgver
meson setup build --prefix=$prefix --cross-file crossfile.txt \
--default-library static \
-Diconv=disabled \
-Dlua=disabled \
-Djpeg=disabled \
-Dopensles=disabled \
-Dlibavdevice=disabled \
-Dmanpage-build=disabled \
-Dhtml-build=disabled \
-Dsdl2=enabled \
-Dlibmpv=true \
-Dgxm=enabled \
-Dvitashark=enabled \
-Dcplayer=false

meson compile -C build
}

package () {
cd $pkgname-$pkgver
DESTDIR=$pkgdir meson install -C build
}
Loading

0 comments on commit dc09f59

Please sign in to comment.