Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 99 additions & 30 deletions .github/workflows/cibuild.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: CI

on: [push, workflow_dispatch]
on:
push:
branches: [master]
tags: ['v*']
pull_request:
workflow_dispatch:

permissions:
contents: read
Expand All @@ -14,6 +19,7 @@ env:
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_COMPILERCHECK: content
CCACHE_MAXSIZE: 2G
SDL_COMMIT: 683181b47cfabd293e3ea409f838915b8297a4fd

jobs:
build:
Expand All @@ -24,45 +30,69 @@ jobs:
with:
submodules: recursive

- uses: nixbuild/nix-quick-install-action@v35
with:
nix_conf: |
keep-env-derivations = true
keep-outputs = true
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential gcc-14 g++-14 cmake ninja-build pkg-config ccache dpkg-dev file \
libvulkan-dev mesa-vulkan-drivers libavcodec-dev libavutil-dev \
spirv-tools spirv-headers libepoxy-dev libegl-dev libopengl-dev \
libasound2-dev libpulse-dev libpipewire-0.3-dev libudev-dev libdbus-1-dev \
libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxfixes-dev \
libxi-dev libxss-dev libxtst-dev libxkbcommon-dev libwayland-dev libdecor-0-dev

- name: Restore Nix store
id: nix-cache
uses: nix-community/cache-nix-action/restore@v7
- name: Restore SDL3
id: sdl-cache
uses: actions/cache/restore@v4
with:
primary-key: nix-ci-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('flake.nix', 'flake.lock') }}
restore-prefixes-first-match: nix-ci-${{ runner.os }}-${{ runner.arch }}-
path: ${{ runner.temp }}/sdl3
key: sdl3-ubuntu-24.04-static-${{ env.SDL_COMMIT }}

- name: Prepare CI shell
run: nix develop .#ci --profile "$RUNNER_TEMP/nix-ci-profile" --command true
- name: Build SDL3
if: steps.sdl-cache.outputs.cache-hit != 'true'
run: |
curl -fL "https://github.com/libsdl-org/SDL/archive/$SDL_COMMIT.tar.gz" | tar -xz -C "$RUNNER_TEMP"
cmake -S "$RUNNER_TEMP/SDL-$SDL_COMMIT" -B "$RUNNER_TEMP/sdl-build" -G Ninja \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$RUNNER_TEMP/sdl3" \
-DSDL_SHARED=OFF -DSDL_STATIC=ON -DSDL_TEST_LIBRARY=OFF -DSDL_TESTS=OFF
cmake --build "$RUNNER_TEMP/sdl-build" --parallel "$(nproc)"
cmake --install "$RUNNER_TEMP/sdl-build"

# Save the toolchain before building, so failures still leave a warm cache.
- name: Save Nix store
if: steps.nix-cache.outputs.hit-primary-key != 'true'
uses: nix-community/cache-nix-action/save@v7
- name: Save SDL3
if: steps.sdl-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
primary-key: ${{ steps.nix-cache.outputs.primary-key }}
gc-max-store-size-linux: 5G
path: ${{ runner.temp }}/sdl3
key: ${{ steps.sdl-cache.outputs.cache-primary-key }}

- name: Restore ccache
id: ccache
uses: actions/cache/restore@v4
with:
path: ${{ env.CCACHE_DIR }}
key: ccache-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('flake.lock') }}-${{ github.run_id }}-${{ github.run_attempt }}
key: ccache-ubuntu-24.04-${{ hashFiles('**/CMakeLists.txt', 'cmake/**', '.github/workflows/cibuild.yml') }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
ccache-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('flake.lock') }}-
ccache-${{ runner.os }}-${{ runner.arch }}-
ccache-ubuntu-24.04-${{ hashFiles('**/CMakeLists.txt', 'cmake/**', '.github/workflows/cibuild.yml') }}-
ccache-ubuntu-24.04-

- name: Configure
id: configure
run: nix develop .#ci --command cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
run: |
version="0.0.0+git.$(git rev-parse --short HEAD)"
if [[ "$GITHUB_REF_TYPE" == tag ]]; then
version="${GITHUB_REF_NAME#v}"
fi
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH="$RUNNER_TEMP/sdl3" -DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_C_COMPILER=gcc-14 -DCMAKE_CXX_COMPILER=g++-14 \
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DDELTA_GPU_D3D12=OFF -DDELTA_PACKAGE_VERSION="$version"
for dependency in SPIRVTOOLS SPIRVHEADERS AVCODEC; do
grep -q "^${dependency}_FOUND:INTERNAL=1$" build/CMakeCache.txt
done

- name: Build
run: nix develop .#ci --command cmake --build build --parallel "$(nproc)"
run: cmake --build build --parallel "$(nproc)" -- -k 0

- name: Save ccache
if: ${{ !cancelled() && steps.configure.outcome == 'success' }}
Expand All @@ -72,12 +102,51 @@ jobs:
key: ${{ steps.ccache.outputs.cache-primary-key }}

- name: Test
run: nix develop .#ci --command ctest --test-dir build --output-on-failure
- name: ccache stats
if: ${{ !cancelled() && steps.configure.outcome == 'success' }}
run: nix develop .#ci --command ccache -s
env:
LIBGL_ALWAYS_SOFTWARE: '1'
EGL_PLATFORM: surfaceless
run: ctest --test-dir build --output-on-failure

- name: Package
run: cpack --config build/CPackConfig.cmake -B dist

- uses: actions/upload-artifact@v4
with:
name: ps4delta
path: build/delta/main/ps4delta
name: prosperity-ubuntu-24.04-amd64
path: dist/*.deb
if-no-files-found: error

install:
needs: build
runs-on: ubuntu-24.04
container: ubuntu:24.04
steps:
- uses: actions/download-artifact@v4
with:
name: prosperity-ubuntu-24.04-amd64
path: dist
- name: Install and smoke test
run: |
apt-get update
apt-get install -y ./dist/*.deb
ps4delta --version
ps4delta --help
test -f /usr/bin/game_profiles/README.md
test -f /usr/share/applications/ps4delta.desktop
! ldd /usr/bin/ps4delta | grep -E 'not found|/nix/store'

release:
if: startsWith(github.ref, 'refs/tags/v')
needs: install
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
name: prosperity-ubuntu-24.04-amd64
path: dist
- name: Publish release
env:
GH_TOKEN: ${{ github.token }}
run: gh release create "$GITHUB_REF_NAME" dist/*.deb --repo "$GITHUB_REPOSITORY" --verify-tag --generate-notes
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,7 @@ if(NOT ANDROID)
add_subdirectory(tools/archive_extract)
add_subdirectory(tools/window_test)
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
include(PackageLinux)
endif()
23 changes: 23 additions & 0 deletions cmake/PackageLinux.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
set(DELTA_PACKAGE_VERSION "0.0.0" CACHE STRING "Linux package version")

set(CPACK_GENERATOR DEB)
set(CPACK_PACKAGE_NAME prosperity)
set(CPACK_PACKAGE_VERSION "${DELTA_PACKAGE_VERSION}")
set(CPACK_PACKAGE_CONTACT "Vincent Hengel <prelink835@gmail.com>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Prosperity PS4 and PS5 emulator")
set(CPACK_PACKAGING_INSTALL_PREFIX /usr)
set(CPACK_STRIP_FILES ON)
set(CPACK_COMPONENTS_ALL Runtime)
set(CPACK_DEB_COMPONENT_INSTALL ON)
set(CPACK_DEBIAN_RUNTIME_PACKAGE_NAME prosperity)
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
set(CPACK_DEBIAN_PACKAGE_SECTION games)
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/Force67/prosperity")
# SDL and epoxy load these libraries at runtime, outside shlibdeps.
set(CPACK_DEBIAN_PACKAGE_DEPENDS
"libegl1, libopengl0, libasound2t64, libpulse0, libudev1, libdbus-1-3, libx11-6, libxext6, libxrandr2, libxcursor1, libxfixes3, libxi6, libxss1, libxtst6, libxkbcommon0, libwayland-client0, libwayland-cursor0, libwayland-egl1, libdecor-0-0")

install(FILES "${CMAKE_SOURCE_DIR}/LICENSE"
DESTINATION share/doc/prosperity COMPONENT Runtime)
include(CPack)
1 change: 1 addition & 0 deletions delta/gpu/gcn/gcn_tiling_shader.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "gpu/gcn/gcn_translate.h"

#ifdef DELTA_HAVE_SPIRV_BACKEND
#include <cstdint>
#include <spirv/unified1/GLSL.std.450.h>
#include "base/containers/vector.h"
#include "base/logging.h"
Expand Down
1 change: 1 addition & 0 deletions delta/gpu/gcn/spirv/translate_mem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#ifdef DELTA_HAVE_SPIRV_BACKEND

#include <cstdint>
#include <initializer_list>
#include "base/arch.h"

Expand Down
1 change: 1 addition & 0 deletions delta/gpu/ps5/rdna/rdna_compute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ RecompileCompute(const u32*,
} // namespace gpu::rdna
#else

#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
Expand Down
1 change: 1 addition & 0 deletions delta/gpu/ps5/rdna/rdna_resource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "gpu/gcn/gcn_detile.h"
#include "gpu/guest_memory.h"

#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
Expand Down
16 changes: 9 additions & 7 deletions delta/gpu/tests/gcn_spirv_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ bool HasBuiltin(const base::Vector<u32>& spirv, u32 builtin) {

bool Recompile(base::Vector<u32> code) {
code.push_back(kEndPgm);
// The recompiler scans 4096 dwords for shader metadata.
code.resize(4096);
const u32 user_data[16] = {};
return gpu::gcn::Recompile(code.data(), nullptr, user_data, user_data).ok;
}
Expand Down Expand Up @@ -110,10 +112,10 @@ TEST(RdnaScalarReplay, CompareWritesOnlyItsSelectedMaskRegister) {

TEST(RdnaSpirv, NoColorExportDoesNotSynthesizeWhiteOutput) {
const u32 user_data[32] = {};
const u32 vs[64] = {kEndPgm};
const u32 no_export[64] = {kEndPgm};
const u32 null_export[64] = {0xf8000890, 0, kEndPgm};
const u32 color_export[64] = {0x7e0002f2, 0xf800080f, 0,
const u32 vs[4096] = {kEndPgm};
const u32 no_export[4096] = {kEndPgm};
const u32 null_export[4096] = {0xf8000890, 0, kEndPgm};
const u32 color_export[4096] = {0x7e0002f2, 0xf800080f, 0,
kEndPgm}; // v0=1; exp mrt0 v0,v0,v0,v0
for (const u32* ps : {no_export, null_export, color_export}) {
gpu::rdna::NextProgramGeneration();
Expand All @@ -124,7 +126,7 @@ TEST(RdnaSpirv, NoColorExportDoesNotSynthesizeWhiteOutput) {
}

TEST(RdnaSpirv, ReloadedDescriptorUsesItsOwnGraphicsBuffer) {
const u32 vs[64] = {
const u32 vs[4096] = {
0xf4080404, 0xfa000000, // s_load_dwordx4 s[16:19], s[8:9], 0
0xe0300000, 0x80040000, // v0 = buffer A[0]
0xe0300004, 0x80040100, // v1 = buffer A[1], same descriptor
Expand Down Expand Up @@ -405,8 +407,8 @@ TEST(GcnSpirv, PlansScalarLoadedCbufferDescriptor) {

TEST(GcnSpirv, SeedsPixelPositionFromFragCoord) {
const IsaScope base(gpu::gcn::IsaMode::kBase);
const u32 vs[] = {kEndPgm};
const u32 ps[] = {
const u32 vs[4096] = {kEndPgm};
const u32 ps[4096] = {
0x7e080f02, // v_cvt_u32_f32 v4, v2
0x7e0a0f03, // v_cvt_u32_f32 v5, v3
0xf800000f, 0x07060504, // exp mrt0 v4, v5, v6, v7
Expand Down
Loading
Loading