diff --git a/.ci/linux/build.sh b/.ci/linux/build.sh index a92cb3fd91..114df7051b 100755 --- a/.ci/linux/build.sh +++ b/.ci/linux/build.sh @@ -3,47 +3,53 @@ # SPDX-FileCopyrightText: 2025 eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later - case "$1" in - amd64|"") - echo "Making amd64-v3 optimized build of Eden" - ARCH="amd64_v3" - ARCH_FLAGS="-march=x86-64-v3" - ;; - steamdeck|zen2) - echo "Making Steam Deck (Zen 2) optimized build of Eden" - ARCH="steamdeck" - ARCH_FLAGS="-march=znver2 -mtune=znver2" - ;; - rog-ally|allyx|zen4) - echo "Making ROG Ally X (Zen 4) optimized build of Eden" - ARCH="rog-ally-x" - ARCH_FLAGS="-march=znver4 -mtune=znver4" - ;; - legacy) - echo "Making amd64 generic build of Eden" - ARCH=amd64 - ARCH_FLAGS="-march=x86-64 -mtune=generic" - ;; - aarch64) - echo "Making armv8-a build of Eden" - ARCH=aarch64 - ARCH_FLAGS="-march=armv8-a -mtune=generic -w" - ;; - armv9) - echo "Making armv9-a build of Eden" - ARCH=armv9 - ARCH_FLAGS="-march=armv9-a -mtune=generic -w" - ;; - native) - echo "Making native build of Eden" - ARCH="$(uname -m)" - ARCH_FLAGS="-march=native -mtune=native" - ;; - *) - echo "Invalid target $1 specified, must be one of native, amd64, steamdeck, zen2, allyx, rog-ally, zen4, legacy, aarch64, armv9" - exit 1 - ;; +amd64 | "") + echo "Making amd64-v3 optimized build of Eden" + ARCH="amd64_v3" + ARCH_FLAGS="-march=x86-64-v3" + export EXTRA_CMAKE_FLAGS=(-DYUZU_BUILD_PRESET=v3) + ;; +steamdeck | zen2) + echo "Making Steam Deck (Zen 2) optimized build of Eden" + ARCH="steamdeck" + ARCH_FLAGS="-march=znver2 -mtune=znver2" + export EXTRA_CMAKE_FLAGS=(-DYUZU_BUILD_PRESET=zen2 -DYUZU_SYSTEM_PROFILE=steamdeck) + ;; +rog-ally | allyx | zen4) + echo "Making ROG Ally X (Zen 4) optimized build of Eden" + ARCH="rog-ally-x" + ARCH_FLAGS="-march=znver4 -mtune=znver4" + export EXTRA_CMAKE_FLAGS=(-DYUZU_BUILD_PRESET=zen2 -DYUZU_SYSTEM_PROFILE=steamdeck) + ;; +legacy) + echo "Making amd64 generic build of Eden" + ARCH=amd64 + ARCH_FLAGS="-march=x86-64 -mtune=generic" + export EXTRA_CMAKE_FLAGS=(-DYUZU_BUILD_PRESET=generic) + ;; +aarch64) + echo "Making armv8-a build of Eden" + ARCH=aarch64 + ARCH_FLAGS="-march=armv8-a -mtune=generic -w" + export EXTRA_CMAKE_FLAGS=(-DYUZU_BUILD_PRESET=generic) + ;; +armv9) + echo "Making armv9-a build of Eden" + ARCH=armv9 + ARCH_FLAGS="-march=armv9-a -mtune=generic -w" + export EXTRA_CMAKE_FLAGS=(-DYUZU_BUILD_PRESET=armv9) + ;; +native) + echo "Making native build of Eden" + ARCH="$(uname -m)" + ARCH_FLAGS="-march=native -mtune=native" + export EXTRA_CMAKE_FLAGS=(-DYUZU_BUILD_PRESET=native) + ;; +*) + echo "Invalid target $1 specified, must be one of native, amd64, steamdeck, zen2, allyx, rog-ally, zen4, legacy, aarch64, armv9" + exit 1 + ;; esac export ARCH_FLAGS="$ARCH_FLAGS -O3" @@ -55,10 +61,10 @@ fi if [ "$1" != "" ]; then shift; fi if [ "$TARGET" = "appimage" ]; then - export EXTRA_CMAKE_FLAGS=(-DCMAKE_INSTALL_PREFIX=/usr -DYUZU_ROOM=ON -DYUZU_ROOM_STANDALONE=OFF -DYUZU_CMD=OFF) + export EXTRA_CMAKE_FLAGS=("${EXTRA_CMAKE_FLAGS[@]}" -DCMAKE_INSTALL_PREFIX=/usr -DYUZU_ROOM=ON -DYUZU_ROOM_STANDALONE=OFF -DYUZU_CMD=OFF) else # For the linux-fresh verification target, verify compilation without PCH as well. - export EXTRA_CMAKE_FLAGS=(-DYUZU_USE_PRECOMPILED_HEADERS=OFF) + export EXTRA_CMAKE_FLAGS=("${EXTRA_CMAKE_FLAGS[@]}" -DYUZU_USE_PRECOMPILED_HEADERS=OFF) fi if [ "$DEVEL" != "true" ]; then @@ -86,7 +92,7 @@ export EXTRA_CMAKE_FLAGS=("${EXTRA_CMAKE_FLAGS[@]}" $@) mkdir -p build && cd build cmake .. -G Ninja \ -DCMAKE_BUILD_TYPE="$BUILD_TYPE" \ - -DENABLE_QT_TRANSLATION=ON \ + -DENABLE_QT_TRANSLATION=ON \ -DUSE_DISCORD_PRESENCE=ON \ -DCMAKE_CXX_FLAGS="$ARCH_FLAGS" \ -DCMAKE_C_FLAGS="$ARCH_FLAGS" \ @@ -99,12 +105,12 @@ cmake .. -G Ninja \ -DYUZU_USE_QT_WEB_ENGINE=$WEBENGINE \ -DYUZU_USE_FASTER_LD=ON \ -DYUZU_ENABLE_LTO=ON \ - "${EXTRA_CMAKE_FLAGS[@]}" + "${EXTRA_CMAKE_FLAGS[@]}" ninja -j${NPROC} if [ -d "bin/Release" ]; then - strip -s bin/Release/* + strip -s bin/Release/* else - strip -s bin/* + strip -s bin/* fi diff --git a/.ci/linux/package.sh b/.ci/linux/package.sh index 41e07ea207..911fea2f7b 100755 --- a/.ci/linux/package.sh +++ b/.ci/linux/package.sh @@ -92,7 +92,6 @@ chmod +x ./sharun-aio xvfb-run -a ./sharun-aio l -p -v -e -s -k \ ../$BUILDDIR/bin/eden* \ $LIBDIR/lib*GL*.so* \ - $LIBDIR/libSDL2*.so* \ $LIBDIR/dri/* \ $LIBDIR/vdpau/* \ $LIBDIR/libvulkan* \ diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 941f94ae26..ac67f73d00 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,9 +2,9 @@ # some stuff needs cleaned up etc name: eden-build -on: - push: - branches: [ "master" ] +#on: +# push: +# branches: [ "master" ] # TODO: combine build.yml into trigger_release.yml jobs: diff --git a/.github/workflows/trigger_release.yml b/.github/workflows/trigger_release.yml index 638ab3424b..645b21e25a 100644 --- a/.github/workflows/trigger_release.yml +++ b/.github/workflows/trigger_release.yml @@ -1,8 +1,8 @@ name: Build Application and Make Release -on: - push: - tags: [ "*" ] +#on: +# push: +# tags: [ "*" ] permissions: contents: write diff --git a/.gitmodules b/.gitmodules index 371b62a605..10f9f7de96 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,15 +16,9 @@ [submodule "opus"] path = externals/opus url = https://github.com/xiph/opus.git -[submodule "SDL"] - path = externals/SDL - url = https://github.com/libsdl-org/SDL.git [submodule "cpp-httplib"] path = externals/cpp-httplib url = https://github.com/yhirose/cpp-httplib.git -[submodule "ffmpeg"] - path = externals/ffmpeg/ffmpeg - url = https://github.com/FFmpeg/FFmpeg.git [submodule "vcpkg"] path = externals/vcpkg url = https://github.com/microsoft/vcpkg.git @@ -49,9 +43,6 @@ [submodule "externals/dynarmic/externals/unordered_dense"] path = externals/dynarmic/externals/unordered_dense url = https://github.com/Lizzie841/unordered_dense.git -[submodule "externals/dynarmic/externals/xbyak"] - path = externals/dynarmic/externals/xbyak - url = https://github.com/Lizzie841/xbyak.git [submodule "externals/dynarmic/externals/zycore-c"] path = externals/dynarmic/externals/zycore-c url = https://github.com/zyantific/zycore-c.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 007debd047..0c2a880ae0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,9 +33,9 @@ endif() option(ENABLE_SDL2 "Enable the SDL2 frontend" ON) CMAKE_DEPENDENT_OPTION(YUZU_USE_BUNDLED_SDL2 "Download bundled SDL2 binaries" ON "ENABLE_SDL2;MSVC" OFF) if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") - CMAKE_DEPENDENT_OPTION(YUZU_USE_EXTERNAL_SDL2 "Compile external SDL2" OFF "ENABLE_SDL2;NOT MSVC" OFF) + CMAKE_DEPENDENT_OPTION(YUZU_USE_EXTERNAL_SDL2 "Compile external SDL2" OFF "ENABLE_SDL2;NOT MSVC" OFF) else() - CMAKE_DEPENDENT_OPTION(YUZU_USE_EXTERNAL_SDL2 "Compile external SDL2" ON "ENABLE_SDL2;NOT MSVC" OFF) + CMAKE_DEPENDENT_OPTION(YUZU_USE_EXTERNAL_SDL2 "Compile external SDL2" ON "ENABLE_SDL2;NOT MSVC" OFF) endif() cmake_dependent_option(ENABLE_LIBUSB "Enable the use of LibUSB" ON "NOT ANDROID" OFF) @@ -332,6 +332,41 @@ if (YUZU_ROOM) add_definitions(-DYUZU_ROOM) endif() +# Build/optimization presets +if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + if (ARCHITECTURE_x86_64) + set(YUZU_BUILD_PRESET "generic" CACHE STRING "Build preset to use. One of: generic, v3, zen2, zen4, native") + if (${YUZU_BUILD_PRESET} STREQUAL "generic") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=x86-64 -mtune=generic") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=x86-64 -mtune=generic") + elseif (${YUZU_BUILD_PRESET} STREQUAL "v3") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=x86-64-v3 -mtune=generic") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=x86-64-v3 -mtune=generic") + elseif (${YUZU_BUILD_PRESET} STREQUAL "zen2") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=znver2 -mtune=znver2") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=znver2 -mtune=znver2") + elseif (${YUZU_BUILD_PRESET} STREQUAL "zen4") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=znver4 -mtune=znver4") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=znver4 -mtune=znver4") + elseif (${YUZU_BUILD_PRESET} STREQUAL "native") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -mtune=native") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mtune=native") + endif() + elseif(ARCHITECTURE_arm64) + set(YUZU_BUILD_PRESET "generic" CACHE STRING "Build preset to use. One of: generic, armv9") + if (${YUZU_BUILD_PRESET} STREQUAL "generic") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv8-a -mtune=generic") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv8-a -mtune=generic") + elseif (${YUZU_BUILD_PRESET} STREQUAL "armv9") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv9-a -mtune=generic") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv9-a -mtune=generic") + endif() + endif() +endif() + +# Other presets, e.g. steamdeck +set(YUZU_SYSTEM_PROFILE "generic" CACHE STRING "CMake and Externals profile to use. One of: generic, steamdeck") + # Configure C++ standard # =========================== @@ -420,6 +455,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR ANDROID) endif() # find SDL2 exports a bunch of variables that are needed, so its easier to do this outside of the YUZU_find_package +# TODO(crueter): combine this all with CPM. if (ENABLE_SDL2) if (YUZU_USE_BUNDLED_SDL2) # Detect toolchain and platform @@ -455,6 +491,8 @@ set(FFmpeg_COMPONENTS avutil swscale) +set(CPM_SOURCE_CACHE ${CMAKE_SOURCE_DIR}/.cache/cpm) + add_subdirectory(externals) if (ENABLE_QT) diff --git a/README.md b/README.md index 724e567516..8e8c769070 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,7 @@
-

Eden is a open-source Nintendo Switch emulator, forked from the Yuzu emulator — started by former Citron developer Camille LaVey and the Eden team. -
+

Eden is an open-source Nintendo Switch emulator, forked from the Yuzu emulator — started by former Citron developer Camille LaVey and the Eden team. It is written in C++ with portability in mind, and we actively maintain builds for Windows, Linux and Android.

@@ -76,7 +75,7 @@ Any donations received will go towards things such as: * Additional hardware (e.g. GPUs as needed to improve rendering support, other peripherals to add support for, etc.) * CI Infrastructure -If you would prefer to support us in a different way, please join our [Discord](https://discord.gg/edenemu), once public, and talk to Camille or any of our other developers. +If you would prefer to support us in a different way, please join our [Discord](https://discord.gg/edenemu) and talk to Camille or any of our other developers. ## License diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index e5b35954f7..cd7b80a33c 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -83,7 +83,23 @@ if (YUZU_USE_EXTERNAL_SDL2) set(SDL_FILE ON) endif() - add_subdirectory(SDL) + include(CPM) + set(CPM_USE_LOCAL_PACKAGES OFF) + + if ("${YUZU_SYSTEM_PROFILE}" STREQUAL "steamdeck") + set(SDL_HASH cc016b0046) + set(SDL_PIPEWIRE OFF) # build errors out with this on + set(SDL_SHA512SUM 34d5ef58da6a4f9efa6689c82f67badcbd741f5a4f562a9c2c30828fa839830fb07681c5dc6a7851520e261c8405a416ac0a2c2513b51984fb3b4fa4dcb3e20b) + else() + set(SDL_HASH 2e4c12cd2c) + set(SDL_SHA512SUM d95af47f469a312876f8ab361074a1e7b8083db19935a102d9c6e5887ace6008e64475a8c54b00164b40cad86492bb1b2366084efdd0b2555e5fea6d9c5da80e) + endif() + + CPMAddPackage( + NAME SDL2 + URL "https://github.com/libsdl-org/SDL/archive/${SDL_HASH}.zip" + URL_HASH SHA512=${SDL_SHA512SUM} + ) endif() # ENet diff --git a/externals/SDL b/externals/SDL deleted file mode 160000 index 2e4c12cd2c..0000000000 --- a/externals/SDL +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2e4c12cd2cb2c5d0b60ef2196b400339591e733c diff --git a/externals/Vulkan-Headers b/externals/Vulkan-Headers index 16cedde356..89268a6d17 160000 --- a/externals/Vulkan-Headers +++ b/externals/Vulkan-Headers @@ -1 +1 @@ -Subproject commit 16cedde3564629c43808401ad1eb3ca6ef24709a +Subproject commit 89268a6d17fc87003b209a1422c17ab288be99a0 diff --git a/externals/Vulkan-Utility-Libraries b/externals/Vulkan-Utility-Libraries index f216bb107b..df2e358152 160000 --- a/externals/Vulkan-Utility-Libraries +++ b/externals/Vulkan-Utility-Libraries @@ -1 +1 @@ -Subproject commit f216bb107bfc6d99a9605572963613e828b10880 +Subproject commit df2e3581520f36776cd42b9fec3ec4a51ab878ef diff --git a/externals/VulkanMemoryAllocator b/externals/VulkanMemoryAllocator index 6ec8481c8a..1076b348ab 160000 --- a/externals/VulkanMemoryAllocator +++ b/externals/VulkanMemoryAllocator @@ -1 +1 @@ -Subproject commit 6ec8481c8a13db586d7b3ba58f4eb9bbf017edf0 +Subproject commit 1076b348abd17859a116f4b111c43d58a588a086 diff --git a/externals/cubeb b/externals/cubeb index 832fcf38e6..fa02160712 160000 --- a/externals/cubeb +++ b/externals/cubeb @@ -1 +1 @@ -Subproject commit 832fcf38e600bf80b4b728a3e0227403088d992c +Subproject commit fa021607121360af7c171d881dc5bc8af7bb56eb diff --git a/externals/dynarmic/externals/CMakeLists.txt b/externals/dynarmic/externals/CMakeLists.txt index f96497db7a..67fb0f4190 100644 --- a/externals/dynarmic/externals/CMakeLists.txt +++ b/externals/dynarmic/externals/CMakeLists.txt @@ -64,12 +64,13 @@ if (NOT TARGET ankerl::unordered_dense) endif() # xbyak +# uncomment if in an independent repo. -if (NOT TARGET xbyak::xbyak) - if ("x86_64" IN_LIST ARCHITECTURE) - add_subdirectory(xbyak) - endif() -endif() +# if (NOT TARGET xbyak::xbyak) +# if ("x86_64" IN_LIST ARCHITECTURE) +# add_subdirectory(xbyak) +# endif() +# endif() # zydis diff --git a/externals/dynarmic/externals/xbyak b/externals/dynarmic/externals/xbyak deleted file mode 160000 index 12557954c6..0000000000 --- a/externals/dynarmic/externals/xbyak +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 12557954c68a780563f9ab9fc24a3a156c96cba1 diff --git a/externals/ffmpeg/CMakeLists.txt b/externals/ffmpeg/CMakeLists.txt index 9eb71418a0..3222efba70 100644 --- a/externals/ffmpeg/CMakeLists.txt +++ b/externals/ffmpeg/CMakeLists.txt @@ -19,8 +19,17 @@ if (NOT WIN32 AND NOT ANDROID) message(FATAL_ERROR "Required program `autoconf` not found.") endif() - set(FFmpeg_PREFIX ${PROJECT_SOURCE_DIR}/externals/ffmpeg/ffmpeg) - set(FFmpeg_BUILD_DIR ${PROJECT_BINARY_DIR}/externals/ffmpeg-build) + include(CPM) + set(CPM_USE_LOCAL_PACKAGES OFF) + + CPMAddPackage( + NAME ffmpeg + URL "https://github.com/ffmpeg/ffmpeg/archive/9c1294eadd.zip" + URL_HASH SHA512=2076e4cb843787c44718c70c4452517273dbc963ef98442f343762ade6c7b9f78555ae9b50a7c628844a15d8cb5e866c04e2f1acfb77093cea4fbc9edf3ad21a + ) + + set(FFmpeg_PREFIX ${ffmpeg_SOURCE_DIR}) + set(FFmpeg_BUILD_DIR ${ffmpeg_BINARY_DIR}) set(FFmpeg_MAKEFILE ${FFmpeg_BUILD_DIR}/Makefile) make_directory(${FFmpeg_BUILD_DIR}) diff --git a/externals/ffmpeg/ffmpeg b/externals/ffmpeg/ffmpeg deleted file mode 160000 index 9c1294eadd..0000000000 --- a/externals/ffmpeg/ffmpeg +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 9c1294eaddb88cb0e044c675ccae059a85fc9c6c diff --git a/externals/libusb/libusb b/externals/libusb/libusb index c060e9ce30..3dbfa16f0c 160000 --- a/externals/libusb/libusb +++ b/externals/libusb/libusb @@ -1 +1 @@ -Subproject commit c060e9ce30ac2e3ffb49d94209c4dae77b6642f7 +Subproject commit 3dbfa16f0cd9e8ed4fec916c6c00f41c738cb8f4 diff --git a/externals/opus b/externals/opus index df02d25f0c..5ded705cf4 160000 --- a/externals/opus +++ b/externals/opus @@ -1 +1 @@ -Subproject commit df02d25f0c6334a60f8c01c5ecf63081845d6c9d +Subproject commit 5ded705cf4ffa13702c78eebecea0fdb2f4ef0de diff --git a/externals/renderdoc/renderdoc_app.h b/externals/renderdoc/renderdoc_app.h index f4eb12526e..3fdc233165 100644 --- a/externals/renderdoc/renderdoc_app.h +++ b/externals/renderdoc/renderdoc_app.h @@ -7,7 +7,7 @@ /****************************************************************************** * The MIT License (MIT) * - * Copyright (c) 2019-2023 Baldur Karlsson + * Copyright (c) 2019-2025 Baldur Karlsson * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -41,8 +41,12 @@ #if defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) #define RENDERDOC_CC __cdecl -#else +#elif defined(__linux__) || defined(__FreeBSD__) || defined(__sun__) #define RENDERDOC_CC +#elif defined(__APPLE__) +#define RENDERDOC_CC +#else +#error "Unknown platform" #endif #ifdef __cplusplus @@ -357,14 +361,14 @@ typedef enum RENDERDOC_OverlayBits eRENDERDOC_Overlay_FrameNumber | eRENDERDOC_Overlay_CaptureList), // Enable all bits - eRENDERDOC_Overlay_All = ~0U, + eRENDERDOC_Overlay_All = 0x7ffffff, // Disable all bits eRENDERDOC_Overlay_None = 0, } RENDERDOC_OverlayBits; // returns the overlay bits that have been set -typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetOverlayBits)(); +typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetOverlayBits)(void); // sets the overlay bits with an and & or mask typedef void(RENDERDOC_CC *pRENDERDOC_MaskOverlayBits)(uint32_t And, uint32_t Or); @@ -375,7 +379,7 @@ typedef void(RENDERDOC_CC *pRENDERDOC_MaskOverlayBits)(uint32_t And, uint32_t Or // injected hooks and shut down. Behaviour is undefined if this is called // after any API functions have been called, and there is still no guarantee of // success. -typedef void(RENDERDOC_CC *pRENDERDOC_RemoveHooks)(); +typedef void(RENDERDOC_CC *pRENDERDOC_RemoveHooks)(void); // DEPRECATED: compatibility for code compiled against pre-1.4.1 headers. typedef pRENDERDOC_RemoveHooks pRENDERDOC_Shutdown; @@ -385,7 +389,7 @@ typedef pRENDERDOC_RemoveHooks pRENDERDOC_Shutdown; // If you use your own crash handler and don't want RenderDoc's handler to // intercede, you can call this function to unload it and any unhandled // exceptions will pass to the next handler. -typedef void(RENDERDOC_CC *pRENDERDOC_UnloadCrashHandler)(); +typedef void(RENDERDOC_CC *pRENDERDOC_UnloadCrashHandler)(void); // Sets the capture file path template // @@ -407,14 +411,14 @@ typedef void(RENDERDOC_CC *pRENDERDOC_UnloadCrashHandler)(); typedef void(RENDERDOC_CC *pRENDERDOC_SetCaptureFilePathTemplate)(const char *pathtemplate); // returns the current capture path template, see SetCaptureFileTemplate above, as a UTF-8 string -typedef const char *(RENDERDOC_CC *pRENDERDOC_GetCaptureFilePathTemplate)(); +typedef const char *(RENDERDOC_CC *pRENDERDOC_GetCaptureFilePathTemplate)(void); // DEPRECATED: compatibility for code compiled against pre-1.1.2 headers. typedef pRENDERDOC_SetCaptureFilePathTemplate pRENDERDOC_SetLogFilePathTemplate; typedef pRENDERDOC_GetCaptureFilePathTemplate pRENDERDOC_GetLogFilePathTemplate; // returns the number of captures that have been made -typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetNumCaptures)(); +typedef uint32_t(RENDERDOC_CC *pRENDERDOC_GetNumCaptures)(void); // This function returns the details of a capture, by index. New captures are added // to the end of the list. @@ -445,7 +449,7 @@ typedef void(RENDERDOC_CC *pRENDERDOC_SetCaptureFileComments)(const char *filePa const char *comments); // returns 1 if the RenderDoc UI is connected to this application, 0 otherwise -typedef uint32_t(RENDERDOC_CC *pRENDERDOC_IsTargetControlConnected)(); +typedef uint32_t(RENDERDOC_CC *pRENDERDOC_IsTargetControlConnected)(void); // DEPRECATED: compatibility for code compiled against pre-1.1.1 headers. // This was renamed to IsTargetControlConnected in API 1.1.1, the old typedef is kept here for @@ -477,7 +481,7 @@ typedef void(RENDERDOC_CC *pRENDERDOC_GetAPIVersion)(int *major, int *minor, int // This will return 1 if the request was successfully passed on, though it's not guaranteed that // the UI will be on top in all cases depending on OS rules. It will return 0 if there is no current // target control connection to make such a request, or if there was another error -typedef uint32_t(RENDERDOC_CC *pRENDERDOC_ShowReplayUI)(); +typedef uint32_t(RENDERDOC_CC *pRENDERDOC_ShowReplayUI)(void); ////////////////////////////////////////////////////////////////////////// // Capturing functions @@ -508,7 +512,7 @@ typedef void(RENDERDOC_CC *pRENDERDOC_SetActiveWindow)(RENDERDOC_DevicePointer d RENDERDOC_WindowHandle wndHandle); // capture the next frame on whichever window and API is currently considered active -typedef void(RENDERDOC_CC *pRENDERDOC_TriggerCapture)(); +typedef void(RENDERDOC_CC *pRENDERDOC_TriggerCapture)(void); // capture the next N frames on whichever window and API is currently considered active typedef void(RENDERDOC_CC *pRENDERDOC_TriggerMultiFrameCapture)(uint32_t numFrames); @@ -537,7 +541,7 @@ typedef void(RENDERDOC_CC *pRENDERDOC_StartFrameCapture)(RENDERDOC_DevicePointer // Returns whether or not a frame capture is currently ongoing anywhere. // // This will return 1 if a capture is ongoing, and 0 if there is no capture running -typedef uint32_t(RENDERDOC_CC *pRENDERDOC_IsFrameCapturing)(); +typedef uint32_t(RENDERDOC_CC *pRENDERDOC_IsFrameCapturing)(void); // Ends capturing immediately. // diff --git a/externals/xbyak b/externals/xbyak index 12557954c6..4e44f4614d 160000 --- a/externals/xbyak +++ b/externals/xbyak @@ -1 +1 @@ -Subproject commit 12557954c68a780563f9ab9fc24a3a156c96cba1 +Subproject commit 4e44f4614ddbf038f2a6296f5b906d5c72691e0f diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index c78487e327..324deaa255 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml @@ -89,7 +89,7 @@ Enhanced Frame Pacing Ensures smooth and consistent frame delivery by synchronizing the timing between frames, reducing stuttering and uneven animation. Ideal for games that experience frame timing instability or micro-stutters during gameplay. Release fences early - Some games may require this to get past 0FPS errors, such as DKCR:HD, Subnautica, and Ori 2. + Some games may require this to get past 0FPS errors, such as DKCR:HD, Subnautica, and Ori 2. Other games, notably Unreal Engine games, may work improperly or not boot with this enabled. CPU and Memory Synchronize Core Speed diff --git a/src/audio_core/sink/cubeb_sink.cpp b/src/audio_core/sink/cubeb_sink.cpp index 7f4b1c365a..a33162b806 100644 --- a/src/audio_core/sink/cubeb_sink.cpp +++ b/src/audio_core/sink/cubeb_sink.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -334,6 +337,48 @@ std::vector ListCubebSinkDevices(bool capture) { return device_list; } +/* REVERSION TO 3833 - function GetCubebLatency REINTRODUCED FROM 3833 - DIABLO 3 FIX */ +u32 GetCubebLatency() { + cubeb* ctx; + +#ifdef _WIN32 + auto com_init_result = CoInitializeEx(nullptr, COINIT_MULTITHREADED); +#endif + + // Init cubeb + if (cubeb_init(&ctx, "yuzu Latency Getter", nullptr) != CUBEB_OK) { + LOG_CRITICAL(Audio_Sink, "cubeb_init failed"); + // Return a large latency so we choose SDL instead. + return 10000u; + } + +#ifdef _WIN32 + if (SUCCEEDED(com_init_result)) { + CoUninitialize(); + } +#endif + + // Get min latency + cubeb_stream_params params{}; + params.rate = TargetSampleRate; + params.channels = 2; + params.format = CUBEB_SAMPLE_S16LE; + params.prefs = CUBEB_STREAM_PREF_NONE; + params.layout = CUBEB_LAYOUT_STEREO; + + u32 latency{0}; + const auto latency_error = cubeb_get_min_latency(ctx, ¶ms, &latency); + if (latency_error != CUBEB_OK) { + LOG_CRITICAL(Audio_Sink, "Error getting minimum latency, error: {}", latency_error); + latency = TargetSampleCount * 2; + } + latency = std::max(latency, TargetSampleCount * 2); + cubeb_destroy(ctx); + return latency; +} + +// REVERTED back to 3833 - Below namespace section and function IsCubebSuitable() removed, reverting to GetCubebLatency() above. - DIABLO 3 FIX +/* namespace { static long TmpDataCallback(cubeb_stream*, void*, const void*, void*, long) { return TargetSampleCount; @@ -400,5 +445,6 @@ bool IsCubebSuitable() { return true; #endif } +*/ } // namespace AudioCore::Sink diff --git a/src/audio_core/sink/cubeb_sink.h b/src/audio_core/sink/cubeb_sink.h index f49a6fdaa7..6dc7d3d296 100644 --- a/src/audio_core/sink/cubeb_sink.h +++ b/src/audio_core/sink/cubeb_sink.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -96,12 +99,20 @@ private: */ std::vector ListCubebSinkDevices(bool capture); +// REVERSION - function GetCubebLatency() reintroduced from EA-3833 - DIABLO 3 FIX +/** + * Get the reported latency for this sink. + * + * @return Minimum latency for this sink. + */ +u32 GetCubebLatency(); + /** * Check if this backend is suitable for use. * Checks if enabled, its latency, whether it opens successfully, etc. * * @return True is this backend is suitable, false otherwise. */ -bool IsCubebSuitable(); +// bool IsCubebSuitable(); // REVERTED BACK TO GetCubebLatency() FROM 3833 } // namespace AudioCore::Sink diff --git a/src/audio_core/sink/sdl2_sink.cpp b/src/audio_core/sink/sdl2_sink.cpp index ffdd77042e..25ed58620e 100644 --- a/src/audio_core/sink/sdl2_sink.cpp +++ b/src/audio_core/sink/sdl2_sink.cpp @@ -234,6 +234,13 @@ std::vector ListSDLSinkDevices(bool capture) { return device_list; } +/* REVERSION to 3833 - function GetSDLLatency() REINTRODUCED FROM 3833 - DIABLO 3 FIX */ +u32 GetSDLLatency() { + return TargetSampleCount * 2; +} + +// REVERTED back to 3833 - Below function IsSDLSuitable() removed, reverting to GetSDLLatency() above. - DIABLO 3 FIX +/* bool IsSDLSuitable() { #if !defined(HAVE_SDL2) return false; @@ -271,5 +278,6 @@ bool IsSDLSuitable() { return true; #endif } +*/ } // namespace AudioCore::Sink diff --git a/src/audio_core/sink/sdl2_sink.h b/src/audio_core/sink/sdl2_sink.h index 9211d2e978..19ea32595f 100644 --- a/src/audio_core/sink/sdl2_sink.h +++ b/src/audio_core/sink/sdl2_sink.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -87,12 +90,20 @@ private: */ std::vector ListSDLSinkDevices(bool capture); +// REVERSION - function GetSDLLatency() reintroduced from EA-3833 - DIABLO 3 FIX /** + * Get the reported latency for this sink. + * + * @return Minimum latency for this sink. + */ +u32 GetSDLLatency(); + +/** REVERTED back to 3833 - Below function IsSDLSuitable() removed, reverting to GetSDLLatency() above. - DIABLO 3 FIX * Check if this backend is suitable for use. * Checks if enabled, its latency, whether it opens successfully, etc. * * @return True is this backend is suitable, false otherwise. */ -bool IsSDLSuitable(); +//bool IsSDLSuitable(); // REVERTED for GetSDLLatency() from EA-3833 } // namespace AudioCore::Sink diff --git a/src/audio_core/sink/sink_details.cpp b/src/audio_core/sink/sink_details.cpp index 449af659d0..70bf75018b 100644 --- a/src/audio_core/sink/sink_details.cpp +++ b/src/audio_core/sink/sink_details.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -25,7 +28,8 @@ namespace { struct SinkDetails { using FactoryFn = std::unique_ptr (*)(std::string_view); using ListDevicesFn = std::vector (*)(bool); - using SuitableFn = bool (*)(); + using LatencyFn = u32 (*)(); // REINTRODUCED FROM 3833 - DIABLO 3 FIX + // using SuitableFn = bool (*)(); // REVERTED FOR ABOVE - DIABLO 3 FIX /// Name for this sink. Settings::AudioEngine id; @@ -33,10 +37,18 @@ struct SinkDetails { FactoryFn factory; /// A method to call to list available devices. ListDevicesFn list_devices; + /// Method to get the latency of this backend - REINTRODUCED FROM 3833 - DIABLO 3 FIX + LatencyFn latency; /// Check whether this backend is suitable to be used. - SuitableFn is_suitable; + /// SuitableFn is_suitable; // REVERTED FOR LatencyFn latency ABOVE - DIABLO 3 FIX }; +// NOTE TO PROBABLY FIX LATER FOR ANDROID - the return value "0u" for the first HAVE_OBOE +// section below was just copied from the null section so there's a somewhat valid value +// being returned, since the previous "true" value probably isn't compatible with the +// previous EA-3833 code. (HAVE_OBOE was introduced in a later release.) Eventually need +// to change "0u" for something else directly from the oboe_sink.cpp functions. + // sink_details is ordered in terms of desirability, with the best choice at the top. constexpr SinkDetails sink_details[] = { #ifdef HAVE_OBOE @@ -46,7 +58,7 @@ constexpr SinkDetails sink_details[] = { return std::make_unique(); }, [](bool capture) { return std::vector{"Default"}; }, - []() { return true; }, + []() { return 0u; }, }, #endif #ifdef HAVE_CUBEB @@ -56,7 +68,7 @@ constexpr SinkDetails sink_details[] = { return std::make_unique(device_id); }, &ListCubebSinkDevices, - &IsCubebSuitable, + &GetCubebLatency, }, #endif #ifdef HAVE_SDL2 @@ -66,7 +78,7 @@ constexpr SinkDetails sink_details[] = { return std::make_unique(device_id); }, &ListSDLSinkDevices, - &IsSDLSuitable, + &GetSDLLatency, }, #endif SinkDetails{ @@ -75,7 +87,7 @@ constexpr SinkDetails sink_details[] = { return std::make_unique(device_id); }, [](bool capture) { return std::vector{"null"}; }, - []() { return true; }, + []() { return 0u; }, }, }; @@ -88,6 +100,8 @@ const SinkDetails& GetOutputSinkDetails(Settings::AudioEngine sink_id) { auto iter = find_backend(sink_id); if (sink_id == Settings::AudioEngine::Auto) { + // REVERTED TO 3833 BELOW - DIABLO 3 FIX + /* // Auto-select a backend. Use the sink details ordering, preferring cubeb first, checking // that the backend is available and suitable to use. for (auto& details : sink_details) { @@ -96,14 +110,29 @@ const SinkDetails& GetOutputSinkDetails(Settings::AudioEngine sink_id) { break; } } + */ // END REVERTED CODE - DIABLO 3 FIX + + // BEGIN REINTRODUCED FROM 3833 - REPLACED CODE BLOCK ABOVE - DIABLO 3 FIX + // Auto-select a backend. Prefer CubeB, but it may report a large minimum latency which + // causes audio issues, in that case go with SDL. +#if defined(HAVE_CUBEB) && defined(HAVE_SDL2) + iter = find_backend(Settings::AudioEngine::Cubeb); + if (iter->latency() > TargetSampleCount * 3) { + iter = find_backend(Settings::AudioEngine::Sdl2); + } +#else + iter = std::begin(sink_details); +#endif + // END REINTRODUCED SECTION FROM 3833 - DIABLO 3 FIX LOG_INFO(Service_Audio, "Auto-selecting the {} backend", Settings::CanonicalizeEnum(iter->id)); + /* BEGIN REMOVED - REVERTING BACK TO 3833, this didn't exist at all. - DIABLO 3 FIX } else { if (iter != std::end(sink_details) && !iter->is_suitable()) { LOG_ERROR(Service_Audio, "Selected backend {} is not suitable, falling back to null", Settings::CanonicalizeEnum(iter->id)); iter = find_backend(Settings::AudioEngine::Null); - } + } */ // END REMOVED REVERT - DIABLO 3 FIX } if (iter == std::end(sink_details)) { diff --git a/src/common/settings.h b/src/common/settings.h index e3c2bd57cc..702926d82a 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -705,7 +705,7 @@ struct Values { // Miscellaneous Setting log_filter{linkage, "*:Info", "log_filter", Category::Miscellaneous}; - Setting log_flush_lines{linkage, false, "flush_lines", Category::Miscellaneous}; + Setting log_flush_lines{linkage, true, "flush_lines", Category::Miscellaneous, Specialization::Default, true, true}; Setting censor_username{linkage, true, "censor_username", Category::Miscellaneous}; Setting use_dev_keys{linkage, false, "use_dev_keys", Category::Miscellaneous}; Setting first_launch{linkage, true, "first_launch", Category::Miscellaneous}; diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp index c4ea15c1dd..ed07e80ce2 100644 --- a/src/core/core_timing.cpp +++ b/src/core/core_timing.cpp @@ -174,15 +174,21 @@ void CoreTiming::UnscheduleEvent(const std::shared_ptr& event_type, } } +static u64 GetNextTickCount(u64 next_ticks) { + if (Settings::values.use_custom_cpu_ticks.GetValue()) { + return Settings::values.cpu_ticks.GetValue(); + } + return next_ticks; +} + void CoreTiming::AddTicks(u64 ticks_to_add) { - cpu_ticks = Settings::values.use_custom_cpu_ticks.GetValue() - ? Settings::values.cpu_ticks.GetValue() - : cpu_ticks + ticks_to_add; - downcount -= static_cast(cpu_ticks); + const u64 ticks = GetNextTickCount(ticks_to_add); + cpu_ticks += ticks; + downcount -= static_cast(ticks); } void CoreTiming::Idle() { - cpu_ticks += 1000U; + AddTicks(1000U); } void CoreTiming::ResetTicks() { diff --git a/src/core/hle/service/am/applet.h b/src/core/hle/service/am/applet.h index 571904fab4..835cfe6ec8 100644 --- a/src/core/hle/service/am/applet.h +++ b/src/core/hle/service/am/applet.h @@ -92,6 +92,7 @@ struct Applet { // Channels std::deque> user_channel_launch_parameter{}; std::deque> preselected_user_launch_parameter{}; + std::deque> friend_invitation_storage_channel{}; // Caller applet std::weak_ptr caller_applet{}; diff --git a/src/core/hle/service/am/service/application_functions.cpp b/src/core/hle/service/am/service/application_functions.cpp index 3bab5ac5f1..560244c714 100644 --- a/src/core/hle/service/am/service/application_functions.cpp +++ b/src/core/hle/service/am/service/application_functions.cpp @@ -456,8 +456,21 @@ Result IApplicationFunctions::GetFriendInvitationStorageChannelEvent( Result IApplicationFunctions::TryPopFromFriendInvitationStorageChannel( Out> out_storage) { - LOG_INFO(Service_AM, "(STUBBED) called"); - R_THROW(AM::ResultNoDataInChannel); + LOG_DEBUG(Service_AM, "called"); + + std::scoped_lock lk{m_applet->lock}; + + auto& channel = m_applet->friend_invitation_storage_channel; + + if (channel.empty()) { + return AM::ResultNoDataInChannel; + } + + auto data = channel.back(); + channel.pop_back(); + + *out_storage = std::make_shared(system, std::move(data)); + R_SUCCEED(); } Result IApplicationFunctions::GetNotificationStorageChannelEvent( diff --git a/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp b/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp index 4317aee1c4..1bb88a45fa 100644 --- a/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp +++ b/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp @@ -728,22 +728,26 @@ Status BufferQueueProducer::Connect(const std::shared_ptr& li return status; } +// https://android.googlesource.com/platform/frameworks/native/%2B/master/libs/gui/BufferQueueProducer.cpp#1457 Status BufferQueueProducer::Disconnect(NativeWindowApi api) { - LOG_DEBUG(Service_Nvnflinger, "api = {}", api); + LOG_DEBUG(Service_Nvnflinger, "disconnect api = {}", api); - Status status = Status::NoError; std::shared_ptr listener; + Status status = Status::NoError; { std::scoped_lock lock{core->mutex}; - core->WaitWhileAllocatingLocked(); if (core->is_abandoned) { - // Disconnecting after the surface has been abandoned is a no-op. return Status::NoError; } + if (core->connected_api == NativeWindowApi::NoConnectedApi) { + LOG_DEBUG(Service_Nvnflinger, "disconnect: not connected (req = {})", api); + return Status::NoInit; + } + switch (api) { case NativeWindowApi::Egl: case NativeWindowApi::Cpu: @@ -758,20 +762,20 @@ Status BufferQueueProducer::Disconnect(NativeWindowApi api) { buffer_wait_event->Signal(); listener = core->consumer_listener; } else { - LOG_ERROR(Service_Nvnflinger, "still connected to another api (cur = {} req = {})", + LOG_ERROR(Service_Nvnflinger, + "disconnect: still connected to another api (cur = {} req = {})", core->connected_api, api); status = Status::BadValue; } break; default: - LOG_ERROR(Service_Nvnflinger, "unknown api = {}", api); + LOG_ERROR(Service_Nvnflinger, "disconnect: unknown api = {}", api); status = Status::BadValue; break; } } - // Call back without lock held - if (listener != nullptr) { + if (listener) { listener->OnBuffersReleased(); } diff --git a/src/core/hle/service/nvnflinger/hos_binder_driver.cpp b/src/core/hle/service/nvnflinger/hos_binder_driver.cpp index 8629a2e89b..d30aa3717d 100644 --- a/src/core/hle/service/nvnflinger/hos_binder_driver.cpp +++ b/src/core/hle/service/nvnflinger/hos_binder_driver.cpp @@ -40,17 +40,22 @@ Result IHOSBinderDriver::TransactParcel(s32 binder_id, u32 transaction_id, } Result IHOSBinderDriver::AdjustRefcount(s32 binder_id, s32 addval, s32 type) { - LOG_WARNING(Service_VI, "(STUBBED) called id={}, addval={}, type={}", binder_id, addval, type); + LOG_DEBUG(Service_VI, "called id={}, addval={}, type={}", binder_id, addval, type); + R_UNLESS(type == 0 || type == 1, ResultUnknown); + m_server->AdjustRefcount(binder_id, addval, type == 1); R_SUCCEED(); } Result IHOSBinderDriver::GetNativeHandle(s32 binder_id, u32 type_id, OutCopyHandle out_handle) { - LOG_WARNING(Service_VI, "(STUBBED) called id={}, type_id={}", binder_id, type_id); + LOG_DEBUG(Service_VI, "called id={}, type_id={}", binder_id, type_id); const auto binder = m_server->TryGetBinder(binder_id); R_UNLESS(binder != nullptr, ResultUnknown); + auto native_handle = binder->GetNativeHandle(type_id); + R_UNLESS(native_handle != nullptr, ResultUnknown); + *out_handle = binder->GetNativeHandle(type_id); R_SUCCEED(); diff --git a/src/core/hle/service/nvnflinger/hos_binder_driver_server.cpp b/src/core/hle/service/nvnflinger/hos_binder_driver_server.cpp index 29addda44d..b85f1a4fa4 100644 --- a/src/core/hle/service/nvnflinger/hos_binder_driver_server.cpp +++ b/src/core/hle/service/nvnflinger/hos_binder_driver_server.cpp @@ -17,6 +17,7 @@ s32 HosBinderDriverServer::RegisterBinder(std::shared_ptr&& bi last_id++; binders[last_id] = std::move(binder); + refcounts[last_id] = {}; // strong = 1, weak = 0 return last_id; } @@ -25,6 +26,29 @@ void HosBinderDriverServer::UnregisterBinder(s32 binder_id) { std::scoped_lock lk{lock}; binders.erase(binder_id); + refcounts.erase(binder_id); +} + +void HosBinderDriverServer::AdjustRefcount(s32 binder_id, s32 delta, bool is_weak) { + std::scoped_lock lk{lock}; + + auto search_rc = refcounts.find(binder_id); + if (search_rc == refcounts.end()) { + LOG_WARNING(Service_VI, "AdjustRefcount called for unknown binder id {}", binder_id); + return; + } + + auto& rc = search_rc->second; + s32& counter = is_weak ? rc.weak : rc.strong; + counter += delta; + + if (counter < 0) + counter = 0; + + if (rc.strong == 0 && rc.weak == 0) { + binders.erase(binder_id); + refcounts.erase(search_rc); + } } std::shared_ptr HosBinderDriverServer::TryGetBinder(s32 id) const { diff --git a/src/core/hle/service/nvnflinger/hos_binder_driver_server.h b/src/core/hle/service/nvnflinger/hos_binder_driver_server.h index d72b50833d..f4b4060115 100644 --- a/src/core/hle/service/nvnflinger/hos_binder_driver_server.h +++ b/src/core/hle/service/nvnflinger/hos_binder_driver_server.h @@ -26,10 +26,18 @@ public: std::shared_ptr TryGetBinder(s32 id) const; + void AdjustRefcount(s32 binder_id, s32 delta, bool is_weak); + private: - std::unordered_map> binders; + struct RefCounts { + s32 strong{1}; + s32 weak{0}; + }; + mutable std::mutex lock; - s32 last_id{}; + s32 last_id = 0; + std::unordered_map> binders; + std::unordered_map refcounts; }; } // namespace Service::Nvnflinger diff --git a/src/core/hle/service/ssl/ssl.cpp b/src/core/hle/service/ssl/ssl.cpp index 67e37e0823..2d10bd04d2 100644 --- a/src/core/hle/service/ssl/ssl.cpp +++ b/src/core/hle/service/ssl/ssl.cpp @@ -41,6 +41,8 @@ enum class IoMode : u32 { enum class OptionType : u32 { DoNotCloseSocket = 0, GetServerCertChain = 1, + SkipDefaultVerify = 2, + EnableAlpn = 3, }; // This is nn::ssl::sf::SslVersion @@ -93,11 +95,11 @@ public: {20, nullptr, "SetRenegotiationMode"}, {21, nullptr, "GetRenegotiationMode"}, {22, &ISslConnection::SetOption, "SetOption"}, - {23, nullptr, "GetOption"}, + {23, &ISslConnection::GetOption, "GetOption"}, {24, nullptr, "GetVerifyCertErrors"}, {25, nullptr, "GetCipherInfo"}, - {26, nullptr, "SetNextAlpnProto"}, - {27, nullptr, "GetNextAlpnProto"}, + {26, &ISslConnection::SetNextAlpnProto, "SetNextAlpnProto"}, + {27, &ISslConnection::GetNextAlpnProto, "GetNextAlpnProto"}, {28, nullptr, "SetDtlsSocketDescriptor"}, {29, nullptr, "GetDtlsHandshakeTimeout"}, {30, nullptr, "SetPrivateOption"}, @@ -140,7 +142,10 @@ private: std::optional fd_to_close; bool do_not_close_socket = false; bool get_server_cert_chain = false; + bool skip_default_verify = false; + bool enable_alpn = false; std::shared_ptr socket; + std::vector next_alpn_proto; bool did_handshake = false; Result SetSocketDescriptorImpl(s32* out_fd, s32 fd) { @@ -381,6 +386,12 @@ private: case OptionType::GetServerCertChain: get_server_cert_chain = static_cast(parameters.value); break; + case OptionType::SkipDefaultVerify: + skip_default_verify = static_cast(parameters.value); + break; + case OptionType::EnableAlpn: + enable_alpn = static_cast(parameters.value); + break; default: LOG_WARNING(Service_SSL, "Unknown option={}, value={}", parameters.option, parameters.value); @@ -389,6 +400,63 @@ private: IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } + + void GetOption(HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + const auto option = rp.PopRaw(); + + u8 value = 0; + + switch (option) { + case OptionType::DoNotCloseSocket: + value = static_cast(do_not_close_socket); + break; + case OptionType::GetServerCertChain: + value = static_cast(get_server_cert_chain); + break; + case OptionType::SkipDefaultVerify: + value = static_cast(skip_default_verify); + break; + case OptionType::EnableAlpn: + value = static_cast(enable_alpn); + break; + default: + LOG_WARNING(Service_SSL, "Unknown option={}", option); + value = 0; + break; + } + + LOG_DEBUG(Service_SSL, "GetOption called, option={}, ret value={}", option, value); + + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(ResultSuccess); + rb.Push(value); + } + + void SetNextAlpnProto(HLERequestContext& ctx) { + const auto data = ctx.ReadBuffer(0); + next_alpn_proto.assign(data.begin(), data.end()); + + LOG_DEBUG(Service_SSL, "SetNextAlpnProto called, size={}", next_alpn_proto.size()); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); + } + + void GetNextAlpnProto(HLERequestContext& ctx) { + const size_t writable = ctx.GetWriteBufferSize(); + const size_t to_write = std::min(next_alpn_proto.size(), writable); + + if (to_write != 0) { + ctx.WriteBuffer(std::span(next_alpn_proto.data(), to_write)); + } + + LOG_DEBUG(Service_SSL, "GetNextAlpnProto called, size={}", to_write); + + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(ResultSuccess); + rb.Push(static_cast(to_write)); + } }; class ISslContext final : public ServiceFramework { @@ -398,7 +466,7 @@ public: shared_data{std::make_shared()} { static const FunctionInfo functions[] = { {0, &ISslContext::SetOption, "SetOption"}, - {1, nullptr, "GetOption"}, + {1, &ISslContext::GetOption, "GetOption"}, {2, &ISslContext::CreateConnection, "CreateConnection"}, {3, &ISslContext::GetConnectionCount, "GetConnectionCount"}, {4, &ISslContext::ImportServerPki, "ImportServerPki"}, @@ -434,6 +502,17 @@ private: IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); + + } + + void GetOption(HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + const auto parameters = rp.PopRaw(); + + LOG_WARNING(Service_SSL, "(STUBBED) called. option={}", parameters); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); } void CreateConnection(HLERequestContext& ctx) { diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index a6e87a3583..66db162c5d 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h @@ -467,6 +467,10 @@ void BufferCache

::BindComputeStorageBuffer(size_t ssbo_index, u32 cbuf_index, channel_state->written_compute_storage_buffers |= (is_written ? 1U : 0U) << ssbo_index; const auto& launch_desc = kepler_compute->launch_description; + if (((launch_desc.const_buffer_enable_mask >> cbuf_index) & 1) == 0) { + LOG_WARNING(HW_GPU, "Skipped binding SSBO: cbuf index {} is not enabled", cbuf_index); + return; + } ASSERT(((launch_desc.const_buffer_enable_mask >> cbuf_index) & 1) != 0); const auto& cbufs = launch_desc.const_buffer_config; @@ -1701,6 +1705,11 @@ template Binding BufferCache

::StorageBufferBinding(GPUVAddr ssbo_addr, u32 cbuf_index, bool is_written) const { const GPUVAddr gpu_addr = gpu_memory->Read(ssbo_addr); + + if (gpu_addr == 0) { + return NULL_BINDING; + } + const auto size = [&]() { const bool is_nvn_cbuf = cbuf_index == 0; // The NVN driver buffer (index 0) is known to pack the SSBO address followed by its size. @@ -1723,7 +1732,7 @@ Binding BufferCache

::StorageBufferBinding(GPUVAddr ssbo_addr, u32 cbuf_index, const std::optional aligned_device_addr = gpu_memory->GpuToCpuAddress(aligned_gpu_addr); if (!aligned_device_addr || size == 0) { - LOG_WARNING(HW_GPU, "Failed to find storage buffer for cbuf index {}", cbuf_index); + LOG_DEBUG(HW_GPU, "Failed to find storage buffer for cbuf index {}", cbuf_index); return NULL_BINDING; } const std::optional device_addr = gpu_memory->GpuToCpuAddress(gpu_addr); diff --git a/src/video_core/query_cache/query_cache.h b/src/video_core/query_cache/query_cache.h index 08b7790555..6e084cc079 100644 --- a/src/video_core/query_cache/query_cache.h +++ b/src/video_core/query_cache/query_cache.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later @@ -115,8 +118,8 @@ struct QueryCacheBase::QueryCacheBaseImpl { QueryCacheBaseImpl(QueryCacheBase* owner_, VideoCore::RasterizerInterface& rasterizer_, Tegra::MaxwellDeviceMemoryManager& device_memory_, RuntimeType& runtime_, Tegra::GPU& gpu_) - : owner{owner_}, rasterizer{rasterizer_}, - device_memory{device_memory_}, runtime{runtime_}, gpu{gpu_} { + : owner{owner_}, rasterizer{rasterizer_}, device_memory{device_memory_}, runtime{runtime_}, + gpu{gpu_} { streamer_mask = 0; for (size_t i = 0; i < static_cast(QueryType::MaxQueryTypes); i++) { streamers[i] = runtime.GetStreamerInterface(static_cast(i)); @@ -267,7 +270,11 @@ void QueryCacheBase::CounterReport(GPUVAddr addr, QueryType counter_type return; } if (False(query_base->flags & QueryFlagBits::IsFinalValueSynced)) [[unlikely]] { - ASSERT(false); + LOG_ERROR(HW_GPU, + "Query report value not synchronized. Consider increasing GPU accuracy."); + if (!is_synced) [[likely]] { + impl->pending_unregister.push_back(query_location); + } return; } query_base->value += streamer->GetAmendValue(); @@ -370,8 +377,6 @@ void QueryCacheBase::NotifySegment(bool resume) { if (resume) { impl->runtime.ResumeHostConditionalRendering(); } else { - CounterClose(VideoCommon::QueryType::ZPassPixelCount64); - CounterClose(VideoCommon::QueryType::StreamingByteCount); impl->runtime.PauseHostConditionalRendering(); } } diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index 0d07e89b6b..ddd29e7acf 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp @@ -324,9 +324,8 @@ bool GraphicsPipeline::ConfigureImpl(bool is_indexed) { size_t ssbo_index{}; for (const auto& desc : info.storage_buffers_descriptors) { ASSERT(desc.count == 1); - if (!buffer_cache.BindGraphicsStorageBuffer(stage, ssbo_index, desc.cbuf_index, - desc.cbuf_offset, desc.is_written)) - return false; + buffer_cache.BindGraphicsStorageBuffer(stage, ssbo_index, desc.cbuf_index, + desc.cbuf_offset, desc.is_written); ++ssbo_index; } } diff --git a/src/video_core/renderer_vulkan/vk_query_cache.cpp b/src/video_core/renderer_vulkan/vk_query_cache.cpp index 44c06eddf3..1f71bc68c6 100644 --- a/src/video_core/renderer_vulkan/vk_query_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_query_cache.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later @@ -1161,10 +1164,9 @@ struct QueryCacheRuntimeImpl { StagingBufferPool& staging_pool_, ComputePassDescriptorQueue& compute_pass_descriptor_queue, DescriptorPool& descriptor_pool) - : rasterizer{rasterizer_}, device_memory{device_memory_}, - buffer_cache{buffer_cache_}, device{device_}, - memory_allocator{memory_allocator_}, scheduler{scheduler_}, staging_pool{staging_pool_}, - guest_streamer(0, runtime), + : rasterizer{rasterizer_}, device_memory{device_memory_}, buffer_cache{buffer_cache_}, + device{device_}, memory_allocator{memory_allocator_}, scheduler{scheduler_}, + staging_pool{staging_pool_}, guest_streamer(0, runtime), sample_streamer(static_cast(QueryType::ZPassPixelCount64), runtime, rasterizer, device, scheduler, memory_allocator, compute_pass_descriptor_queue, descriptor_pool), @@ -1300,9 +1302,11 @@ void QueryCacheRuntime::HostConditionalRenderingCompareValueImpl(VideoCommon::Lo if (impl->hcr_is_set) { if (impl->hcr_setup.buffer == impl->hcr_buffer && impl->hcr_setup.offset == impl->hcr_offset) { - ResumeHostConditionalRendering(); return; } + } + bool was_running = impl->is_hcr_running; + if (was_running) { PauseHostConditionalRendering(); } impl->hcr_setup.buffer = impl->hcr_buffer; @@ -1310,7 +1314,9 @@ void QueryCacheRuntime::HostConditionalRenderingCompareValueImpl(VideoCommon::Lo impl->hcr_setup.flags = is_equal ? VK_CONDITIONAL_RENDERING_INVERTED_BIT_EXT : 0; impl->hcr_is_set = true; impl->is_hcr_running = false; - ResumeHostConditionalRendering(); + if (was_running) { + ResumeHostConditionalRendering(); + } } void QueryCacheRuntime::HostConditionalRenderingCompareBCImpl(DAddr address, bool is_equal) { @@ -1325,7 +1331,8 @@ void QueryCacheRuntime::HostConditionalRenderingCompareBCImpl(DAddr address, boo to_resolve = buffer->Handle(); to_resolve_offset = static_cast(offset); } - if (impl->is_hcr_running) { + bool was_running = impl->is_hcr_running; + if (was_running) { PauseHostConditionalRendering(); } impl->conditional_resolve_pass->Resolve(*impl->hcr_resolve_buffer, to_resolve, @@ -1335,7 +1342,9 @@ void QueryCacheRuntime::HostConditionalRenderingCompareBCImpl(DAddr address, boo impl->hcr_setup.flags = is_equal ? 0 : VK_CONDITIONAL_RENDERING_INVERTED_BIT_EXT; impl->hcr_is_set = true; impl->is_hcr_running = false; - ResumeHostConditionalRendering(); + if (was_running) { + ResumeHostConditionalRendering(); + } } bool QueryCacheRuntime::HostConditionalRenderingCompareValue(VideoCommon::LookupData object_1, diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 33b90a1ec9..c803b50e24 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -217,8 +217,6 @@ void RasterizerVulkan::PrepareDraw(bool is_indexed, Func&& draw_func) { FlushWork(); gpu_memory->FlushCaching(); - query_cache.NotifySegment(true); - GraphicsPipeline* const pipeline{pipeline_cache.CurrentGraphicsPipeline()}; if (!pipeline) { return; @@ -232,9 +230,13 @@ void RasterizerVulkan::PrepareDraw(bool is_indexed, Func&& draw_func) { UpdateDynamicStates(); HandleTransformFeedback(); + query_cache.NotifySegment(true); query_cache.CounterEnable(VideoCommon::QueryType::ZPassPixelCount64, maxwell3d->regs.zpass_pixel_count_enable); + draw_func(); + + query_cache.CounterEnable(VideoCommon::QueryType::StreamingByteCount, false); } void RasterizerVulkan::Draw(bool is_indexed, u32 instance_count) { @@ -311,8 +313,6 @@ void RasterizerVulkan::DrawTexture() { }; FlushWork(); - query_cache.NotifySegment(true); - std::scoped_lock l{texture_cache.mutex}; texture_cache.SynchronizeGraphicsDescriptors(); texture_cache.UpdateRenderTargets(false); @@ -359,10 +359,6 @@ void RasterizerVulkan::Clear(u32 layer_count) { FlushWork(); gpu_memory->FlushCaching(); - query_cache.NotifySegment(true); - query_cache.CounterEnable(VideoCommon::QueryType::ZPassPixelCount64, - maxwell3d->regs.zpass_pixel_count_enable); - auto& regs = maxwell3d->regs; const bool use_color = regs.clear_surface.R || regs.clear_surface.G || regs.clear_surface.B || regs.clear_surface.A; @@ -378,6 +374,10 @@ void RasterizerVulkan::Clear(u32 layer_count) { const VkExtent2D render_area = framebuffer->RenderArea(); scheduler.RequestRenderpass(framebuffer); + query_cache.NotifySegment(true); + query_cache.CounterEnable(VideoCommon::QueryType::ZPassPixelCount64, + maxwell3d->regs.zpass_pixel_count_enable); + u32 up_scale = 1; u32 down_shift = 0; if (texture_cache.IsRescaling()) { @@ -518,6 +518,14 @@ void RasterizerVulkan::DispatchCompute() { } const std::array dim{qmd.grid_dim_x, qmd.grid_dim_y, qmd.grid_dim_z}; scheduler.RequestOutsideRenderPassOperationContext(); + static constexpr VkMemoryBarrier READ_BARRIER{ + .sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER, + .pNext = nullptr, + .srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT, + .dstAccessMask = VK_ACCESS_MEMORY_READ_BIT, + }; + scheduler.Record([](vk::CommandBuffer cmdbuf) { cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, + 0, READ_BARRIER); }); scheduler.Record([dim](vk::CommandBuffer cmdbuf) { cmdbuf.Dispatch(dim[0], dim[1], dim[2]); }); } @@ -824,6 +832,7 @@ std::optional RasterizerVulkan::AccelerateDisplay( if (!image_view) { return {}; } + query_cache.NotifySegment(false); const auto& resolution = Settings::values.resolution_info; @@ -935,22 +944,20 @@ void RasterizerVulkan::UpdateDynamicStates() { UpdateDepthBounds(regs); UpdateStencilFaces(regs); UpdateLineWidth(regs); - // TODO: updating line stipple causes the cmdbuf to die - // UpdateLineStipple(regs); const u8 dynamic_state = Settings::values.dyna_state.GetValue(); auto features = DynamicFeatures{ - .has_extended_dynamic_state = device.IsExtExtendedDynamicStateSupported() - && dynamic_state > 0, - .has_extended_dynamic_state_2 = device.IsExtExtendedDynamicState2Supported() - && dynamic_state > 1, - .has_extended_dynamic_state_2_extra = device.IsExtExtendedDynamicState2ExtrasSupported() - && dynamic_state > 1, - .has_extended_dynamic_state_3_blend = device.IsExtExtendedDynamicState3BlendingSupported() - && dynamic_state > 2, - .has_extended_dynamic_state_3_enables = device.IsExtExtendedDynamicState3EnablesSupported() - && dynamic_state > 2, + .has_extended_dynamic_state = + device.IsExtExtendedDynamicStateSupported() && dynamic_state > 0, + .has_extended_dynamic_state_2 = + device.IsExtExtendedDynamicState2Supported() && dynamic_state > 1, + .has_extended_dynamic_state_2_extra = + device.IsExtExtendedDynamicState2ExtrasSupported() && dynamic_state > 1, + .has_extended_dynamic_state_3_blend = + device.IsExtExtendedDynamicState3BlendingSupported() && dynamic_state > 2, + .has_extended_dynamic_state_3_enables = + device.IsExtExtendedDynamicState3EnablesSupported() && dynamic_state > 2, .has_dynamic_vertex_input = device.IsExtVertexInputDynamicStateSupported(), }; @@ -975,16 +982,12 @@ void RasterizerVulkan::UpdateDynamicStates() { if (features.has_extended_dynamic_state_3_enables) { using namespace Tegra::Engines; - if (device.GetDriverID() == VkDriverIdKHR::VK_DRIVER_ID_AMD_OPEN_SOURCE - || device.GetDriverID() == VkDriverIdKHR::VK_DRIVER_ID_AMD_PROPRIETARY) { - struct In - { + if (device.GetDriverID() == VkDriverIdKHR::VK_DRIVER_ID_AMD_OPEN_SOURCE || + device.GetDriverID() == VkDriverIdKHR::VK_DRIVER_ID_AMD_PROPRIETARY) { + struct In { const Maxwell3D::Regs::VertexAttribute::Type d; - In(Maxwell3D::Regs::VertexAttribute::Type n) - : d(n) - {} - bool operator()(Maxwell3D::Regs::VertexAttribute n) const - { + In(Maxwell3D::Regs::VertexAttribute::Type n) : d(n) {} + bool operator()(Maxwell3D::Regs::VertexAttribute n) const { return n.type == d; } }; @@ -1135,36 +1138,36 @@ void RasterizerVulkan::UpdateDepthBias(Tegra::Engines::Maxwell3D::Regs& regs) { if (is_d24 && !device.SupportsD24DepthBuffer()) { static constexpr const size_t length = sizeof(NEEDS_D24) / sizeof(NEEDS_D24[0]); - static constexpr const u64 *start = NEEDS_D24; - static constexpr const u64 *end = NEEDS_D24 + length; + static constexpr const u64* start = NEEDS_D24; + static constexpr const u64* end = NEEDS_D24 + length; - const u64 *it = std::find(start, end, program_id); + const u64* it = std::find(start, end, program_id); if (it != end) { // the base formulas can be obtained from here: // https://docs.microsoft.com/en-us/windows/win32/direct3d11/d3d10-graphics-programming-guide-output-merger-stage-depth-bias - const double rescale_factor = static_cast(1ULL << (32 - 24)) - / (static_cast(0x1.ep+127)); + const double rescale_factor = + static_cast(1ULL << (32 - 24)) / (static_cast(0x1.ep+127)); units = static_cast(static_cast(units) * rescale_factor); } } - scheduler.Record( - [constant = units, clamp = regs.depth_bias_clamp, factor = regs.slope_scale_depth_bias, this]( - vk::CommandBuffer cmdbuf) { - if (device.IsExtDepthBiasControlSupported()) { - static VkDepthBiasRepresentationInfoEXT bias_info{ - .sType = VK_STRUCTURE_TYPE_DEPTH_BIAS_REPRESENTATION_INFO_EXT, - .pNext = nullptr, - .depthBiasRepresentation = VK_DEPTH_BIAS_REPRESENTATION_LEAST_REPRESENTABLE_VALUE_FORCE_UNORM_EXT, - .depthBiasExact = VK_FALSE, - }; + scheduler.Record([constant = units, clamp = regs.depth_bias_clamp, + factor = regs.slope_scale_depth_bias, this](vk::CommandBuffer cmdbuf) { + if (device.IsExtDepthBiasControlSupported()) { + static VkDepthBiasRepresentationInfoEXT bias_info{ + .sType = VK_STRUCTURE_TYPE_DEPTH_BIAS_REPRESENTATION_INFO_EXT, + .pNext = nullptr, + .depthBiasRepresentation = + VK_DEPTH_BIAS_REPRESENTATION_LEAST_REPRESENTABLE_VALUE_FORCE_UNORM_EXT, + .depthBiasExact = VK_FALSE, + }; - cmdbuf.SetDepthBias(constant, clamp, factor, &bias_info); - } else { - cmdbuf.SetDepthBias(constant, clamp, factor); - } - }); + cmdbuf.SetDepthBias(constant, clamp, factor, &bias_info); + } else { + cmdbuf.SetDepthBias(constant, clamp, factor); + } + }); } void RasterizerVulkan::UpdateBlendConstants(Tegra::Engines::Maxwell3D::Regs& regs) { @@ -1346,8 +1349,7 @@ void RasterizerVulkan::UpdateRasterizerDiscardEnable(Tegra::Engines::Maxwell3D:: }); } -void RasterizerVulkan::UpdateConservativeRasterizationMode(Tegra::Engines::Maxwell3D::Regs& regs) -{ +void RasterizerVulkan::UpdateConservativeRasterizationMode(Tegra::Engines::Maxwell3D::Regs& regs) { if (!state_tracker.TouchConservativeRasterizationMode()) { return; } @@ -1359,8 +1361,7 @@ void RasterizerVulkan::UpdateConservativeRasterizationMode(Tegra::Engines::Maxwe }); } -void RasterizerVulkan::UpdateLineStippleEnable(Tegra::Engines::Maxwell3D::Regs& regs) -{ +void RasterizerVulkan::UpdateLineStippleEnable(Tegra::Engines::Maxwell3D::Regs& regs) { if (!state_tracker.TouchLineStippleEnable()) { return; } @@ -1370,19 +1371,7 @@ void RasterizerVulkan::UpdateLineStippleEnable(Tegra::Engines::Maxwell3D::Regs& }); } -void RasterizerVulkan::UpdateLineStipple(Tegra::Engines::Maxwell3D::Regs& regs) -{ - if (!state_tracker.TouchLineStipple()) { - return; - } - - scheduler.Record([params = regs.line_stipple_params](vk::CommandBuffer cmdbuf) { - cmdbuf.SetLineStippleEXT(params.factor, static_cast(params.pattern)); - }); -} - -void RasterizerVulkan::UpdateLineRasterizationMode(Tegra::Engines::Maxwell3D::Regs& regs) -{ +void RasterizerVulkan::UpdateLineRasterizationMode(Tegra::Engines::Maxwell3D::Regs& regs) { // if (!state_tracker.TouchLi()) { // return; // } diff --git a/src/video_core/renderer_vulkan/vk_scheduler.cpp b/src/video_core/renderer_vulkan/vk_scheduler.cpp index 146923db4d..7c556588b6 100644 --- a/src/video_core/renderer_vulkan/vk_scheduler.cpp +++ b/src/video_core/renderer_vulkan/vk_scheduler.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -257,16 +260,6 @@ u64 Scheduler::SubmitExecution(VkSemaphore signal_semaphore, VkSemaphore wait_se void Scheduler::AllocateNewContext() { // Enable counters once again. These are disabled when a command buffer is finished. - if (query_cache) { -#if ANDROID - if (Settings::IsGPULevelHigh()) { - // This is problematic on Android, disable on GPU Normal. - query_cache->NotifySegment(true); - } -#else - query_cache->NotifySegment(true); -#endif - } } void Scheduler::InvalidateState() { @@ -276,15 +269,7 @@ void Scheduler::InvalidateState() { } void Scheduler::EndPendingOperations() { -#if ANDROID - if (Settings::IsGPULevelHigh()) { - // This is problematic on Android, disable on GPU Normal. - // query_cache->DisableStreams(); - } -#else - // query_cache->DisableStreams(); -#endif - query_cache->NotifySegment(false); + query_cache->CounterReset(VideoCommon::QueryType::ZPassPixelCount64); EndRenderPass(); } @@ -292,6 +277,10 @@ void Scheduler::EndRenderPass() { if (!state.renderpass) { return; } + + query_cache->CounterEnable(VideoCommon::QueryType::ZPassPixelCount64, false); + query_cache->NotifySegment(false); + Record([num_images = num_renderpass_images, images = renderpass_images, ranges = renderpass_image_ranges](vk::CommandBuffer cmdbuf) { std::array barriers; diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index 022a9ae572..9259639107 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later @@ -38,6 +41,7 @@ using VideoCommon::ImageInfo; using VideoCommon::ImageType; using VideoCommon::SubresourceRange; using VideoCore::Surface::BytesPerBlock; +using VideoCore::Surface::HasAlpha; using VideoCore::Surface::IsPixelFormatASTC; using VideoCore::Surface::IsPixelFormatInteger; using VideoCore::Surface::SurfaceType; @@ -1323,6 +1327,7 @@ void TextureCacheRuntime::ConvertImage(Framebuffer* dst, ImageView& dst_view, Im case PixelFormat::D32_FLOAT_S8_UINT: case PixelFormat::Invalid: default: + LOG_ERROR(Render_Vulkan, "Unimplemented texture conversion from {} to {} format type", src_view.format, dst_view.format); break; } } @@ -1364,6 +1369,16 @@ bool TextureCacheRuntime::IsFormatScalable(PixelFormat format) { void TextureCacheRuntime::CopyImage(Image& dst, Image& src, std::span copies) { + // As per the size-compatible formats section of vulkan, copy manually via ReinterpretImage + // these images that aren't size-compatible + if (BytesPerBlock(src.info.format) != BytesPerBlock(dst.info.format)) { + auto oneCopy = VideoCommon::ImageCopy{ + .src_offset = VideoCommon::Offset3D(0, 0, 0), + .dst_offset = VideoCommon::Offset3D(0, 0, 0), + .extent = dst.info.size + }; + return ReinterpretImage(dst, src, std::span{&oneCopy, 1}); + } boost::container::small_vector vk_copies(copies.size()); const VkImageAspectFlags aspect_mask = dst.AspectMask(); ASSERT(aspect_mask == src.AspectMask()); diff --git a/src/video_core/surface.cpp b/src/video_core/surface.cpp index 9055b1b929..1998849e84 100644 --- a/src/video_core/surface.cpp +++ b/src/video_core/surface.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: 2014 Citra Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -237,6 +240,44 @@ SurfaceType GetFormatType(PixelFormat pixel_format) { return SurfaceType::Invalid; } +bool HasAlpha(PixelFormat pixel_format) { + switch (pixel_format) { + case PixelFormat::A8B8G8R8_UNORM: + case PixelFormat::A8B8G8R8_SNORM: + case PixelFormat::A8B8G8R8_SINT: + case PixelFormat::A8B8G8R8_UINT: + case PixelFormat::A1R5G5B5_UNORM: + case PixelFormat::A2B10G10R10_UNORM: + case PixelFormat::A2B10G10R10_UINT: + case PixelFormat::A2R10G10B10_UNORM: + case PixelFormat::A1B5G5R5_UNORM: + case PixelFormat::A5B5G5R1_UNORM: + case PixelFormat::R16G16B16A16_FLOAT: + case PixelFormat::R16G16B16A16_UNORM: + case PixelFormat::R16G16B16A16_SNORM: + case PixelFormat::R16G16B16A16_SINT: + case PixelFormat::R16G16B16A16_UINT: + case PixelFormat::R32G32B32A32_UINT: + case PixelFormat::BC1_RGBA_UNORM: + case PixelFormat::B8G8R8A8_UNORM: + case PixelFormat::R32G32B32A32_FLOAT: + case PixelFormat::R32G32B32A32_SINT: + case PixelFormat::A8B8G8R8_SRGB: + case PixelFormat::B8G8R8A8_SRGB: + case PixelFormat::BC1_RGBA_SRGB: + case PixelFormat::A4B4G4R4_UNORM: + case PixelFormat::BC2_SRGB: + case PixelFormat::BC2_UNORM: + case PixelFormat::BC3_SRGB: + case PixelFormat::BC3_UNORM: + case PixelFormat::BC7_SRGB: + case PixelFormat::BC7_UNORM: + return true; + default: + return false; + } +} + bool IsPixelFormatASTC(PixelFormat format) { switch (format) { case PixelFormat::ASTC_2D_4X4_UNORM: diff --git a/src/video_core/surface.h b/src/video_core/surface.h index ec9cd2fbf0..4ccb24f27d 100644 --- a/src/video_core/surface.h +++ b/src/video_core/surface.h @@ -503,6 +503,8 @@ PixelFormat PixelFormatFromGPUPixelFormat(Service::android::PixelFormat format); SurfaceType GetFormatType(PixelFormat pixel_format); +bool HasAlpha(PixelFormat pixel_format); + bool IsPixelFormatASTC(PixelFormat format); bool IsPixelFormatBCn(PixelFormat format); diff --git a/src/video_core/vulkan_common/vulkan_wrapper.cpp b/src/video_core/vulkan_common/vulkan_wrapper.cpp index 40136c3fbf..5d80531b47 100644 --- a/src/video_core/vulkan_common/vulkan_wrapper.cpp +++ b/src/video_core/vulkan_common/vulkan_wrapper.cpp @@ -11,8 +11,8 @@ #include #include "common/common_types.h" -#include "common/settings.h" #include "common/logging/log.h" +#include "common/settings.h" #include "video_core/vulkan_common/vk_enum_string_helper.h" #include "video_core/vulkan_common/vma.h" #include "video_core/vulkan_common/vulkan_wrapper.h" @@ -440,14 +440,15 @@ Instance Instance::Create(u32 version, Span layers, Span