diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 917b7c6e..98bba65b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,6 +6,12 @@ on: pull_request: branches: [master] +env: + WOWEE_AMD_FSR2_REPO: https://github.com/GPUOpen-Effects/FidelityFX-FSR2.git + WOWEE_AMD_FSR2_REF: master + WOWEE_FFX_SDK_REPO: https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK.git + WOWEE_FFX_SDK_REF: v1.1.4 + jobs: build: name: Build (${{ matrix.arch }}) @@ -60,7 +66,9 @@ jobs: - name: Fetch AMD FSR2 SDK run: | rm -rf extern/FidelityFX-FSR2 - git clone --depth 1 https://github.com/GPUOpen-Effects/FidelityFX-FSR2.git extern/FidelityFX-FSR2 + git clone --depth 1 --branch "${WOWEE_AMD_FSR2_REF}" "${WOWEE_AMD_FSR2_REPO}" extern/FidelityFX-FSR2 + rm -rf extern/FidelityFX-SDK + git clone --depth 1 --branch "${WOWEE_FFX_SDK_REF}" "${WOWEE_FFX_SDK_REPO}" extern/FidelityFX-SDK - name: Check AMD FSR2 Vulkan permutation headers run: | @@ -74,12 +82,26 @@ jobs: echo "WoWee CMake will bootstrap vendored headers." fi + - name: Check FidelityFX-SDK Vulkan framegen files + run: | + set -euo pipefail + SDK_DIR="$PWD/extern/FidelityFX-SDK/sdk" + test -f "$SDK_DIR/include/FidelityFX/host/ffx_frameinterpolation.h" + test -f "$SDK_DIR/include/FidelityFX/gpu/frameinterpolation/ffx_frameinterpolation_callbacks_glsl.h" + test -f "$SDK_DIR/include/FidelityFX/gpu/opticalflow/ffx_opticalflow_callbacks_glsl.h" + test -f "$SDK_DIR/src/backends/vk/CMakeShadersFrameinterpolation.txt" + test -f "$SDK_DIR/src/backends/vk/CMakeShadersOpticalflow.txt" + echo "FidelityFX-SDK Vulkan framegen files detected." + - name: Configure (AMD ON) run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DWOWEE_ENABLE_AMD_FSR2=ON - name: Assert AMD FSR2 target run: cmake --build build --target wowee_fsr2_amd_vk --parallel $(nproc) + - name: Assert AMD FSR3 framegen probe target + run: cmake --build build --target wowee_fsr3_framegen_amd_vk_probe --parallel $(nproc) + - name: Build run: cmake --build build --parallel $(nproc) @@ -119,7 +141,9 @@ jobs: - name: Fetch AMD FSR2 SDK run: | rm -rf extern/FidelityFX-FSR2 - git clone --depth 1 https://github.com/GPUOpen-Effects/FidelityFX-FSR2.git extern/FidelityFX-FSR2 + git clone --depth 1 --branch "${WOWEE_AMD_FSR2_REF}" "${WOWEE_AMD_FSR2_REPO}" extern/FidelityFX-FSR2 + rm -rf extern/FidelityFX-SDK + git clone --depth 1 --branch "${WOWEE_FFX_SDK_REF}" "${WOWEE_FFX_SDK_REPO}" extern/FidelityFX-SDK - name: Configure run: | @@ -134,6 +158,9 @@ jobs: - name: Assert AMD FSR2 target run: cmake --build build --target wowee_fsr2_amd_vk --parallel $(sysctl -n hw.logicalcpu) + - name: Assert AMD FSR3 framegen probe target + run: cmake --build build --target wowee_fsr3_framegen_amd_vk_probe --parallel $(sysctl -n hw.logicalcpu) + - name: Build run: cmake --build build --parallel $(sysctl -n hw.logicalcpu) @@ -239,7 +266,9 @@ jobs: shell: msys2 {0} run: | rm -rf extern/FidelityFX-FSR2 - git clone --depth 1 https://github.com/GPUOpen-Effects/FidelityFX-FSR2.git extern/FidelityFX-FSR2 + git clone --depth 1 --branch "${WOWEE_AMD_FSR2_REF}" "${WOWEE_AMD_FSR2_REPO}" extern/FidelityFX-FSR2 + rm -rf extern/FidelityFX-SDK + git clone --depth 1 --branch "${WOWEE_FFX_SDK_REF}" "${WOWEE_FFX_SDK_REPO}" extern/FidelityFX-SDK - name: Configure shell: msys2 {0} @@ -249,6 +278,10 @@ jobs: shell: msys2 {0} run: cmake --build build --target wowee_fsr2_amd_vk --parallel $(nproc) + - name: Assert AMD FSR3 framegen probe target + shell: msys2 {0} + run: cmake --build build --target wowee_fsr3_framegen_amd_vk_probe --parallel $(nproc) + - name: Build shell: msys2 {0} run: cmake --build build --parallel $(nproc) @@ -319,7 +352,9 @@ jobs: shell: msys2 {0} run: | rm -rf extern/FidelityFX-FSR2 - git clone --depth 1 https://github.com/GPUOpen-Effects/FidelityFX-FSR2.git extern/FidelityFX-FSR2 + git clone --depth 1 --branch "${WOWEE_AMD_FSR2_REF}" "${WOWEE_AMD_FSR2_REPO}" extern/FidelityFX-FSR2 + rm -rf extern/FidelityFX-SDK + git clone --depth 1 --branch "${WOWEE_FFX_SDK_REF}" "${WOWEE_FFX_SDK_REPO}" extern/FidelityFX-SDK - name: Configure shell: msys2 {0} @@ -329,6 +364,10 @@ jobs: shell: msys2 {0} run: cmake --build build --target wowee_fsr2_amd_vk --parallel $(nproc) + - name: Assert AMD FSR3 framegen probe target + shell: msys2 {0} + run: cmake --build build --target wowee_fsr3_framegen_amd_vk_probe --parallel $(nproc) + - name: Build shell: msys2 {0} run: cmake --build build --parallel $(nproc) diff --git a/CMakeLists.txt b/CMakeLists.txt index d3d5a526..57f33580 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,7 @@ option(BUILD_SHARED_LIBS "Build shared libraries" OFF) option(WOWEE_BUILD_TESTS "Build tests" OFF) option(WOWEE_ENABLE_ASAN "Enable AddressSanitizer (Debug builds)" OFF) option(WOWEE_ENABLE_AMD_FSR2 "Enable AMD FidelityFX FSR2 backend when SDK is present" ON) +option(WOWEE_ENABLE_AMD_FSR3_FRAMEGEN "Enable AMD FidelityFX SDK FSR3 frame generation interface probe when SDK is present" ON) # AMD FidelityFX FSR2 SDK detection (drop-in under extern/FidelityFX-FSR2) set(WOWEE_AMD_FSR2_DIR ${CMAKE_SOURCE_DIR}/extern/FidelityFX-FSR2) @@ -87,6 +88,38 @@ else() endif() endif() +# AMD FidelityFX SDK (FSR3 frame generation interfaces) detection under extern/FidelityFX-SDK +set(WOWEE_AMD_FFX_SDK_DIR ${CMAKE_SOURCE_DIR}/extern/FidelityFX-SDK/sdk) +set(WOWEE_AMD_FFX_SDK_FI_HEADER ${WOWEE_AMD_FFX_SDK_DIR}/include/FidelityFX/host/ffx_frameinterpolation.h) +set(WOWEE_AMD_FFX_SDK_OF_HEADER ${WOWEE_AMD_FFX_SDK_DIR}/include/FidelityFX/host/ffx_opticalflow.h) +set(WOWEE_AMD_FFX_SDK_FSR3_HEADER ${WOWEE_AMD_FFX_SDK_DIR}/include/FidelityFX/host/ffx_fsr3upscaler.h) +set(WOWEE_AMD_FFX_SDK_VK_HEADER ${WOWEE_AMD_FFX_SDK_DIR}/include/FidelityFX/host/backends/vk/ffx_vk.h) + +if(WOWEE_ENABLE_AMD_FSR3_FRAMEGEN + AND EXISTS ${WOWEE_AMD_FFX_SDK_FI_HEADER} + AND EXISTS ${WOWEE_AMD_FFX_SDK_OF_HEADER} + AND EXISTS ${WOWEE_AMD_FFX_SDK_FSR3_HEADER} + AND EXISTS ${WOWEE_AMD_FFX_SDK_VK_HEADER}) + message(STATUS "AMD FidelityFX-SDK framegen headers detected at ${WOWEE_AMD_FFX_SDK_DIR}") + add_compile_definitions(WOWEE_HAS_AMD_FSR3_FRAMEGEN=1) + add_library(wowee_fsr3_framegen_amd_vk_probe STATIC + src/rendering/amd_fsr3_framegen_probe.cpp + ) + set_target_properties(wowee_fsr3_framegen_amd_vk_probe PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON + ) + target_include_directories(wowee_fsr3_framegen_amd_vk_probe PUBLIC + ${WOWEE_AMD_FFX_SDK_DIR}/include + ) + target_link_libraries(wowee_fsr3_framegen_amd_vk_probe PUBLIC Vulkan::Vulkan) +else() + add_compile_definitions(WOWEE_HAS_AMD_FSR3_FRAMEGEN=0) + if(WOWEE_ENABLE_AMD_FSR3_FRAMEGEN) + message(WARNING "AMD FidelityFX-SDK framegen headers not found at ${WOWEE_AMD_FFX_SDK_DIR}; FSR3 framegen interface probe disabled.") + endif() +endif() + # Opcode registry generation/validation find_package(Python3 COMPONENTS Interpreter QUIET) if(Python3_Interpreter_FOUND) @@ -604,6 +637,9 @@ endif() if(TARGET wowee_fsr2_amd_vk) target_link_libraries(wowee PRIVATE wowee_fsr2_amd_vk) endif() +if(TARGET wowee_fsr3_framegen_amd_vk_probe) + target_link_libraries(wowee PRIVATE wowee_fsr3_framegen_amd_vk_probe) +endif() # Link Unicorn if available if(HAVE_UNICORN) diff --git a/README.md b/README.md index 36df3f83..af34f623 100644 --- a/README.md +++ b/README.md @@ -174,12 +174,28 @@ make -j$(nproc) - `extern/FidelityFX-FSR2` - Source URL: - `https://github.com/GPUOpen-Effects/FidelityFX-FSR2.git` +- Ref: + - `master` (depth-1 clone) - The renderer enables the AMD backend only when both are present: - `extern/FidelityFX-FSR2/src/ffx-fsr2-api/ffx_fsr2.h` - `extern/FidelityFX-FSR2/src/ffx-fsr2-api/vk/shaders/ffx_fsr2_accumulate_pass_permutations.h` - If the SDK checkout is missing generated Vulkan permutation headers, CMake auto-bootstraps them from `third_party/fsr2_vk_permutations`. - If SDK files are missing entirely, CMake falls back to the internal non-AMD FSR2 path automatically. +### FidelityFX SDK (Framegen Extern) + +- Build scripts and CI also fetch: + - `extern/FidelityFX-SDK` +- Source URL: + - `https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK.git` +- Ref: + - `v1.1.4` (depth-1 clone) +- This ref includes Vulkan framegen building blocks (`frameinterpolation` + `opticalflow`) and Vulkan shader manifests: + - `sdk/src/backends/vk/CMakeShadersFrameinterpolation.txt` + - `sdk/src/backends/vk/CMakeShadersOpticalflow.txt` +- CMake option: + - `WOWEE_ENABLE_AMD_FSR3_FRAMEGEN=ON` enables a compile-probe target (`wowee_fsr3_framegen_amd_vk_probe`) that validates SDK FI/OF/FSR3/Vulkan interface headers at build time. + ### Current FSR Defaults - Upscaling quality default: `Native (100%)` @@ -249,7 +265,10 @@ make -j$(nproc) - GitHub Actions builds on every push: Linux (x86-64, ARM64), Windows (x86-64, ARM64 via MSYS2), macOS (ARM64) - All build jobs are AMD-FSR2-only (`WOWEE_ENABLE_AMD_FSR2=ON`) and explicitly build `wowee_fsr2_amd_vk` -- Each job clones AMD's FSR2 SDK; if generated Vulkan permutation headers are absent upstream, WoWee bootstraps them from `third_party/fsr2_vk_permutations` +- Each job clones AMD's FSR2 SDK and FidelityFX-SDK (`v1.1.4`) +- Linux CI asserts FidelityFX-SDK Vulkan framegen files are present (FI/OF GLSL callbacks + Vulkan shader manifests) +- All CI platform jobs explicitly build `wowee_fsr3_framegen_amd_vk_probe` +- If FSR2 generated Vulkan permutation headers are absent upstream, WoWee bootstraps them from `third_party/fsr2_vk_permutations` - Container build via `container/build-in-container.sh` (Podman) ## Security diff --git a/build.ps1 b/build.ps1 index 6e965219..35487f76 100644 --- a/build.ps1 +++ b/build.ps1 @@ -30,8 +30,28 @@ function Ensure-Fsr2Sdk { } } +function Ensure-FidelityFxSdk { + $sdkDir = Join-Path $ScriptDir "extern\FidelityFX-SDK" + $sdkHeader = Join-Path $sdkDir "sdk\include\FidelityFX\host\ffx_frameinterpolation.h" + $sdkRef = "v1.1.4" + if (Test-Path $sdkHeader) { return } + + if (-not (Get-Command git -ErrorAction SilentlyContinue)) { + Write-Warning "git not found; cannot auto-fetch AMD FidelityFX SDK." + return + } + + Write-Host "Fetching AMD FidelityFX SDK ($sdkRef) into $sdkDir ..." + New-Item -ItemType Directory -Path (Join-Path $ScriptDir "extern") -Force | Out-Null + & git clone --depth 1 --branch $sdkRef https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK.git $sdkDir + if ($LASTEXITCODE -ne 0) { + Write-Warning "Failed to clone AMD FidelityFX SDK. FSR3 framegen extern will be unavailable." + } +} + Write-Host "Building wowee..." Ensure-Fsr2Sdk +Ensure-FidelityFxSdk # Create build directory if it doesn't exist if (-not (Test-Path "build")) { diff --git a/build.sh b/build.sh index a234bb72..8279cddc 100755 --- a/build.sh +++ b/build.sh @@ -22,8 +22,27 @@ ensure_fsr2_sdk() { } } +ensure_fidelityfx_sdk() { + local sdk_dir="extern/FidelityFX-SDK" + local sdk_header="$sdk_dir/sdk/include/FidelityFX/host/ffx_frameinterpolation.h" + local sdk_ref="v1.1.4" + if [ -f "$sdk_header" ]; then + return + fi + if ! command -v git >/dev/null 2>&1; then + echo "Warning: git not found; cannot auto-fetch AMD FidelityFX SDK." + return + fi + echo "Fetching AMD FidelityFX SDK ($sdk_ref) into $sdk_dir ..." + mkdir -p extern + git clone --depth 1 --branch "$sdk_ref" https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK.git "$sdk_dir" || { + echo "Warning: failed to clone AMD FidelityFX SDK. FSR3 framegen extern will be unavailable." + } +} + echo "Building wowee..." ensure_fsr2_sdk +ensure_fidelityfx_sdk # Create build directory if it doesn't exist mkdir -p build diff --git a/docs/AMD_FSR2_INTEGRATION.md b/docs/AMD_FSR2_INTEGRATION.md index 26358f8e..6608d4a7 100644 --- a/docs/AMD_FSR2_INTEGRATION.md +++ b/docs/AMD_FSR2_INTEGRATION.md @@ -11,6 +11,10 @@ AMD SDK checkout path: `extern/FidelityFX-FSR2` +FidelityFX SDK checkout path (framegen extern): + +`extern/FidelityFX-SDK` (pinned to `v1.1.4` in build scripts and CI) + Detection expects: - `extern/FidelityFX-FSR2/src/ffx-fsr2-api/ffx_fsr2.h` @@ -21,15 +25,20 @@ Detection expects: ## Build Flags - `WOWEE_ENABLE_AMD_FSR2=ON` (default): attempt AMD backend integration. +- `WOWEE_ENABLE_AMD_FSR3_FRAMEGEN=ON` (default): build AMD FSR3 framegen interface probe when FidelityFX-SDK headers are present. - `WOWEE_HAS_AMD_FSR2` compile define: - `1` when AMD SDK prerequisites are present. - `0` when missing, in which case internal fallback remains active. +- `WOWEE_HAS_AMD_FSR3_FRAMEGEN` compile define: + - `1` when FidelityFX-SDK FI/OF/FSR3+VK headers are detected. + - `0` when headers are missing (probe target disabled). ## Current Status - AMD FSR2 Vulkan dispatch path is integrated and used when available. - UI displays active backend in settings (`AMD FidelityFX SDK` or `Internal fallback`). - Runtime settings include persisted FSR2 jitter tuning. +- FidelityFX-SDK `v1.1.4` extern is fetched across platforms and validated in Linux CI for Vulkan framegen source presence. - Startup safety behavior remains enabled: - persisted FSR2 is deferred until `IN_WORLD` - startup falls back unless `WOWEE_ALLOW_STARTUP_FSR2=1` @@ -45,6 +54,16 @@ Detection expects: ## CI Notes - `build-linux-amd-fsr2` clones AMD's repository and configures with `WOWEE_ENABLE_AMD_FSR2=ON`. +- All build jobs clone: + - `GPUOpen-Effects/FidelityFX-FSR2` (`master`) + - `GPUOpen-LibrariesAndSDKs/FidelityFX-SDK` (`v1.1.4`) +- Linux CI additionally checks FidelityFX-SDK Vulkan framegen files: + - `ffx_frameinterpolation_callbacks_glsl.h` + - `ffx_opticalflow_callbacks_glsl.h` + - `CMakeShadersFrameinterpolation.txt` + - `CMakeShadersOpticalflow.txt` +- All CI platform jobs build: + - `wowee_fsr3_framegen_amd_vk_probe` - Some upstream SDK checkouts do not include generated Vulkan permutation headers. - WoWee bootstraps those headers from the vendored snapshot so AMD backend builds remain cross-platform and deterministic. - If SDK headers are missing entirely, WoWee still falls back to the internal backend. diff --git a/include/rendering/renderer.hpp b/include/rendering/renderer.hpp index 91ba6a8d..5256cded 100644 --- a/include/rendering/renderer.hpp +++ b/include/rendering/renderer.hpp @@ -283,6 +283,11 @@ public: #else bool isAmdFsr2SdkAvailable() const { return false; } #endif +#if WOWEE_HAS_AMD_FSR3_FRAMEGEN + bool isAmdFsr3FramegenSdkAvailable() const { return true; } +#else + bool isAmdFsr3FramegenSdkAvailable() const { return false; } +#endif void setWaterRefractionEnabled(bool enabled); bool isWaterRefractionEnabled() const; diff --git a/rebuild.ps1 b/rebuild.ps1 index 9b1efc4e..b0f74f6d 100644 --- a/rebuild.ps1 +++ b/rebuild.ps1 @@ -30,8 +30,28 @@ function Ensure-Fsr2Sdk { } } +function Ensure-FidelityFxSdk { + $sdkDir = Join-Path $ScriptDir "extern\FidelityFX-SDK" + $sdkHeader = Join-Path $sdkDir "sdk\include\FidelityFX\host\ffx_frameinterpolation.h" + $sdkRef = "v1.1.4" + if (Test-Path $sdkHeader) { return } + + if (-not (Get-Command git -ErrorAction SilentlyContinue)) { + Write-Warning "git not found; cannot auto-fetch AMD FidelityFX SDK." + return + } + + Write-Host "Fetching AMD FidelityFX SDK ($sdkRef) into $sdkDir ..." + New-Item -ItemType Directory -Path (Join-Path $ScriptDir "extern") -Force | Out-Null + & git clone --depth 1 --branch $sdkRef https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK.git $sdkDir + if ($LASTEXITCODE -ne 0) { + Write-Warning "Failed to clone AMD FidelityFX SDK. FSR3 framegen extern will be unavailable." + } +} + Write-Host "Clean rebuilding wowee..." Ensure-Fsr2Sdk +Ensure-FidelityFxSdk # Remove build directory completely if (Test-Path "build") { diff --git a/rebuild.sh b/rebuild.sh index 17026d74..000426a8 100755 --- a/rebuild.sh +++ b/rebuild.sh @@ -22,8 +22,27 @@ ensure_fsr2_sdk() { } } +ensure_fidelityfx_sdk() { + local sdk_dir="extern/FidelityFX-SDK" + local sdk_header="$sdk_dir/sdk/include/FidelityFX/host/ffx_frameinterpolation.h" + local sdk_ref="v1.1.4" + if [ -f "$sdk_header" ]; then + return + fi + if ! command -v git >/dev/null 2>&1; then + echo "Warning: git not found; cannot auto-fetch AMD FidelityFX SDK." + return + fi + echo "Fetching AMD FidelityFX SDK ($sdk_ref) into $sdk_dir ..." + mkdir -p extern + git clone --depth 1 --branch "$sdk_ref" https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK.git "$sdk_dir" || { + echo "Warning: failed to clone AMD FidelityFX SDK. FSR3 framegen extern will be unavailable." + } +} + echo "Clean rebuilding wowee..." ensure_fsr2_sdk +ensure_fidelityfx_sdk # Remove build directory completely if [ -d "build" ]; then diff --git a/src/rendering/amd_fsr3_framegen_probe.cpp b/src/rendering/amd_fsr3_framegen_probe.cpp new file mode 100644 index 00000000..7968d1c5 --- /dev/null +++ b/src/rendering/amd_fsr3_framegen_probe.cpp @@ -0,0 +1,31 @@ +#include +#include +#include +#include +#include + +namespace wowee::rendering { + +// Compile-only probe for AMD FSR3 frame generation interfaces. +// This does not dispatch runtime frame generation yet; it ensures the +// expected SDK headers and core types are available for future integration. +bool amdFsr3FramegenCompileProbe() { + FfxFsr3UpscalerContext fsr3Context{}; + FfxFrameInterpolationContext fiContext{}; + FfxOpticalflowContext ofContext{}; + FfxInterface backend{}; + FfxDimensions2D renderSize{}; + + static_assert(FFX_FSR3UPSCALER_VERSION_MAJOR >= 3, "Expected FSR3 upscaler v3+"); + static_assert(FFX_FRAMEINTERPOLATION_VERSION_MAJOR >= 1, "Expected frame interpolation v1+"); + static_assert(FFX_OPTICALFLOW_VERSION_MAJOR >= 1, "Expected optical flow v1+"); + + (void)fsr3Context; + (void)fiContext; + (void)ofContext; + (void)backend; + (void)renderSize; + return true; +} + +} // namespace wowee::rendering