diff --git a/.github/ISSUE_TEMPLATE/app-bug-report.yaml b/.github/ISSUE_TEMPLATE/app-bug-report.yaml index cd540e06e..8959221a0 100644 --- a/.github/ISSUE_TEMPLATE/app-bug-report.yaml +++ b/.github/ISSUE_TEMPLATE/app-bug-report.yaml @@ -53,3 +53,24 @@ body: placeholder: "Example: Windows 11, Arch Linux, MacOS 15" validations: required: true + - type: input + id: cpu + attributes: + label: CPU + placeholder: "Example: Intel Core i7-8700" + validations: + required: true + - type: input + id: gpu + attributes: + label: GPU + placeholder: "Example: nVidia GTX 1650" + validations: + required: true + - type: input + id: ram + attributes: + label: Amount of RAM in GB + placeholder: "Example: 16 GB" + validations: + required: true diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 86ca81c38..ceb915f6a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,7 +30,7 @@ jobs: - name: Install run: | wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-19 main' + sudo add-apt-repository 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble-19 main' sudo apt update sudo apt install clang-format-19 - name: Build @@ -205,12 +205,12 @@ jobs: run: | mkdir upload mv ${{github.workspace}}/build/shadps4 upload - cp ${{github.workspace}}/build/externals/MoltenVK/libMoltenVK.dylib upload - tar cf shadps4-macos-sdl.tar.gz -C upload . + mv ${{github.workspace}}/build/MoltenVK_icd.json upload + mv ${{github.workspace}}/build/libMoltenVK.dylib upload - uses: actions/upload-artifact@v4 with: name: shadps4-macos-sdl-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }} - path: shadps4-macos-sdl.tar.gz + path: upload/ macos-qt: runs-on: macos-15 @@ -281,8 +281,13 @@ jobs: with: submodules: recursive + - name: Add LLVM repository + run: | + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + sudo add-apt-repository 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble-19 main' + - name: Install dependencies - run: sudo apt-get update && sudo apt install -y libx11-dev libxext-dev libwayland-dev libdecor-0-dev libxkbcommon-dev libglfw3-dev libgles2-mesa-dev libfuse2 clang build-essential libasound2-dev libpulse-dev libopenal-dev libudev-dev + run: sudo apt-get update && sudo apt install -y libx11-dev libxext-dev libwayland-dev libdecor-0-dev libxkbcommon-dev libglfw3-dev libgles2-mesa-dev libfuse2 clang-19 mold build-essential libasound2-dev libpulse-dev libopenal-dev libudev-dev - name: Cache CMake Configuration uses: actions/cache@v4 @@ -304,7 +309,7 @@ jobs: key: ${{ env.cache-name }}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }} - name: Configure CMake - run: cmake --fresh -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE=ON -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + run: cmake --fresh -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE=ON -DCMAKE_C_COMPILER=clang-19 -DCMAKE_CXX_COMPILER=clang++-19 -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=mold" -DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=mold" -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - name: Build run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel $(nproc) @@ -337,8 +342,13 @@ jobs: with: submodules: recursive + - name: Add LLVM repository + run: | + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + sudo add-apt-repository 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble-19 main' + - name: Install dependencies - run: sudo apt-get update && sudo apt install -y libx11-dev libxext-dev libwayland-dev libdecor-0-dev libxkbcommon-dev libglfw3-dev libgles2-mesa-dev libfuse2 clang build-essential qt6-base-dev qt6-tools-dev qt6-multimedia-dev libasound2-dev libpulse-dev libopenal-dev libudev-dev + run: sudo apt-get update && sudo apt install -y libx11-dev libxext-dev libwayland-dev libdecor-0-dev libxkbcommon-dev libglfw3-dev libgles2-mesa-dev libfuse2 clang-19 mold build-essential qt6-base-dev qt6-tools-dev qt6-multimedia-dev libasound2-dev libpulse-dev libopenal-dev libudev-dev - name: Cache CMake Configuration uses: actions/cache@v4 @@ -360,7 +370,7 @@ jobs: key: ${{ env.cache-name }}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }} - name: Configure CMake - run: cmake --fresh -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE=ON -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DENABLE_QT_GUI=ON -DENABLE_UPDATER=ON -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + run: cmake --fresh -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE=ON -DCMAKE_C_COMPILER=clang-19 -DCMAKE_CXX_COMPILER=clang++-19 -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=mold" -DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=mold" -DENABLE_QT_GUI=ON -DENABLE_UPDATER=ON -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - name: Build run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel $(nproc) @@ -385,7 +395,7 @@ jobs: submodules: recursive - name: Install dependencies - run: sudo apt-get update && sudo apt install -y libx11-dev libxext-dev libwayland-dev libdecor-0-dev libxkbcommon-dev libglfw3-dev libgles2-mesa-dev libfuse2 gcc-14 build-essential libasound2-dev libpulse-dev libopenal-dev libudev-dev + run: sudo apt-get update && sudo apt install -y libx11-dev libxext-dev libwayland-dev libdecor-0-dev libxkbcommon-dev libglfw3-dev libgles2-mesa-dev libfuse2 gcc-14 mold build-essential libasound2-dev libpulse-dev libopenal-dev libudev-dev - name: Cache CMake Configuration uses: actions/cache@v4 @@ -407,7 +417,7 @@ jobs: key: ${{ env.cache-name }}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }} - name: Configure CMake - run: cmake --fresh -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE=ON -DCMAKE_C_COMPILER=gcc-14 -DCMAKE_CXX_COMPILER=g++-14 -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + run: cmake --fresh -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE=ON -DCMAKE_C_COMPILER=gcc-14 -DCMAKE_CXX_COMPILER=g++-14 -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=mold" -DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=mold" -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - name: Build run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel $(nproc) @@ -421,7 +431,7 @@ jobs: submodules: recursive - name: Install dependencies - run: sudo apt-get update && sudo apt install -y libx11-dev libxext-dev libwayland-dev libdecor-0-dev libxkbcommon-dev libglfw3-dev libgles2-mesa-dev libfuse2 gcc-14 build-essential qt6-base-dev qt6-tools-dev qt6-multimedia-dev libasound2-dev libpulse-dev libopenal-dev libudev-dev + run: sudo apt-get update && sudo apt install -y libx11-dev libxext-dev libwayland-dev libdecor-0-dev libxkbcommon-dev libglfw3-dev libgles2-mesa-dev libfuse2 gcc-14 mold build-essential qt6-base-dev qt6-tools-dev qt6-multimedia-dev libasound2-dev libpulse-dev libopenal-dev libudev-dev - name: Cache CMake Configuration uses: actions/cache@v4 @@ -443,7 +453,7 @@ jobs: key: ${{ env.cache-name }}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }} - name: Configure CMake - run: cmake --fresh -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE=ON -DCMAKE_C_COMPILER=gcc-14 -DCMAKE_CXX_COMPILER=g++-14 -DENABLE_QT_GUI=ON -DENABLE_UPDATER=ON -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + run: cmake --fresh -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE=ON -DCMAKE_C_COMPILER=gcc-14 -DCMAKE_CXX_COMPILER=g++-14 -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=mold" -DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=mold" -DENABLE_QT_GUI=ON -DENABLE_UPDATER=ON -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - name: Build run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel $(nproc) diff --git a/.gitmodules b/.gitmodules index 3d0d21c5b..065a4570f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,15 +1,3 @@ -[submodule "externals/cryptopp-cmake"] - path = externals/cryptopp-cmake - url = https://github.com/shadps4-emu/ext-cryptopp-cmake.git - shallow = true -[submodule "externals/cryptopp"] - path = externals/cryptopp - url = https://github.com/shadps4-emu/ext-cryptopp.git - shallow = true -[submodule "externals/cryptoppwin"] - path = externals/cryptoppwin - url = https://github.com/shadps4-emu/ext-cryptoppwin.git - shallow = true [submodule "externals/zlib-ng"] path = externals/zlib-ng url = https://github.com/shadps4-emu/ext-zlib-ng.git @@ -119,3 +107,6 @@ path = externals/MoltenVK/cereal url = https://github.com/USCiLab/cereal shallow = true +[submodule "externals/libusb"] + path = externals/libusb + url = https://github.com/libusb/libusb-cmake.git diff --git a/CMakeLists.txt b/CMakeLists.txt index b05a175bb..e36c1f280 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED True) if(APPLE) list(APPEND ADDITIONAL_LANGUAGES OBJC) - set(CMAKE_OSX_DEPLOYMENT_TARGET 14) + # Starting with 15.4, Rosetta 2 has support for all the necessary instruction sets. + set(CMAKE_OSX_DEPLOYMENT_TARGET 15.4 CACHE STRING "") endif() if (NOT CMAKE_BUILD_TYPE) @@ -37,8 +38,10 @@ option(ENABLE_UPDATER "Enables the options to updater" ON) # First, determine whether to use CMAKE_OSX_ARCHITECTURES or CMAKE_SYSTEM_PROCESSOR. if (APPLE AND CMAKE_OSX_ARCHITECTURES) set(BASE_ARCHITECTURE "${CMAKE_OSX_ARCHITECTURES}") -else() +elseif (CMAKE_SYSTEM_PROCESSOR) set(BASE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}") +else() + set(BASE_ARCHITECTURE "${CMAKE_HOST_SYSTEM_PROCESSOR}") endif() # Next, match common architecture strings down to a known common value. @@ -50,7 +53,13 @@ else() message(FATAL_ERROR "Unsupported CPU architecture: ${BASE_ARCHITECTURE}") endif() -if (APPLE AND ARCHITECTURE STREQUAL "x86_64" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") +if (ARCHITECTURE STREQUAL "x86_64") + # Target the same CPU architecture as the PS4, to maintain the same level of compatibility. + # Exclude SSE4a as it is only available on AMD CPUs. + add_compile_options(-march=btver2 -mtune=generic -mno-sse4a) +endif() + +if (APPLE AND ARCHITECTURE STREQUAL "x86_64" AND CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "arm64") # Exclude ARM homebrew path to avoid conflicts when cross compiling. list(APPEND CMAKE_IGNORE_PREFIX_PATH "/opt/homebrew") @@ -96,38 +105,81 @@ if (CLANG_FORMAT) unset(CCOMMENT) endif() -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") - # generate git revision information -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modules/") -include(GetGitRevisionDescription) +include("${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modules/GetGitRevisionDescription.cmake") get_git_head_revision(GIT_REF_SPEC GIT_REV) git_describe(GIT_DESC --always --long --dirty) git_branch_name(GIT_BRANCH) string(TIMESTAMP BUILD_DATE "%Y-%m-%d %H:%M:%S") +message("start git things") + # Try to get the upstream remote and branch +message("check for remote and branch") execute_process( COMMAND git rev-parse --abbrev-ref --symbolic-full-name @{u} OUTPUT_VARIABLE GIT_REMOTE_NAME - RESULT_VARIABLE GIT_BRANCH_RESULT + RESULT_VARIABLE GIT_REMOTE_RESULT ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE ) # If there's no upstream set or the command failed, check remote.pushDefault -if (GIT_BRANCH_RESULT OR GIT_REMOTE_NAME STREQUAL "") +if (GIT_REMOTE_RESULT OR GIT_REMOTE_NAME STREQUAL "") + message("check default push") execute_process( COMMAND git config --get remote.pushDefault OUTPUT_VARIABLE GIT_REMOTE_NAME - RESULT_VARIABLE GIT_PUSH_DEFAULT_RESULT + RESULT_VARIABLE GIT_REMOTE_RESULT ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE ) - - # If remote.pushDefault is not set or fails, default to origin - if (GIT_PUSH_DEFAULT_RESULT OR GIT_REMOTE_NAME STREQUAL "") - set(GIT_REMOTE_NAME "origin") +endif() + +# If running in GitHub Actions and the above fails +if (GIT_REMOTE_RESULT OR GIT_REMOTE_NAME STREQUAL "") + message("check github") + set(GIT_REMOTE_NAME "origin") + + # Retrieve environment variables + if (DEFINED ENV{GITHUB_HEAD_REF} AND NOT "$ENV{GITHUB_HEAD_REF}" STREQUAL "") + message("github head ref: $ENV{GITHUB_HEAD_REF}") + set(GITHUB_HEAD_REF "$ENV{GITHUB_HEAD_REF}") + else() + set(GITHUB_HEAD_REF "") + endif() + + if (DEFINED ENV{GITHUB_REF} AND NOT "$ENV{GITHUB_REF}" STREQUAL "") + message("github ref: $ENV{GITHUB_REF}") + string(REGEX REPLACE "^refs/[^/]*/" "" GITHUB_BRANCH "$ENV{GITHUB_REF}") + string(REGEX MATCH "refs/pull/([0-9]+)/merge" MATCHED_REF "$ENV{GITHUB_REF}") + if (MATCHED_REF) + set(PR_NUMBER "${CMAKE_MATCH_1}") + set(GITHUB_BRANCH "") + message("PR number: ${PR_NUMBER}") + else() + set(PR_NUMBER "") + endif() + else() + set(GITHUB_BRANCH "") + set(PR_NUMBER "") + endif() + + if (NOT "${PR_NUMBER}" STREQUAL "" AND NOT "${GITHUB_HEAD_REF}" STREQUAL "") + set(GIT_BRANCH "pr-${PR_NUMBER}-${GITHUB_HEAD_REF}") + elseif (NOT "${PR_NUMBER}" STREQUAL "" AND NOT "${GITHUB_BRANCH}" STREQUAL "") + set(GIT_BRANCH "pr-${PR_NUMBER}-${GITHUB_BRANCH}") + elseif (NOT "${PR_NUMBER}" STREQUAL "") + set(GIT_BRANCH "pr-${PR_NUMBER}") + elseif ("${PR_NUMBER}" STREQUAL "" AND NOT "${GITHUB_HEAD_REF}" STREQUAL "") + set(GIT_BRANCH "${GITHUB_HEAD_REF}") + elseif ("${PR_NUMBER}" STREQUAL "" AND NOT "${GITHUB_BRANCH}" STREQUAL "") + set(GIT_BRANCH "${GITHUB_BRANCH}") + elseif ("${PR_NUMBER}" STREQUAL "" AND NOT "${GITHUB_REF}" STREQUAL "") + set(GIT_BRANCH "${GITHUB_REF}") + else() + message("couldn't find branch") + set(GIT_BRANCH "detached-head") endif() else() # Extract remote name if the output contains a remote/branch format @@ -141,14 +193,27 @@ else() endif() # Get remote link +message("getting remote link") execute_process( COMMAND git config --get remote.${GIT_REMOTE_NAME}.url OUTPUT_VARIABLE GIT_REMOTE_URL OUTPUT_STRIP_TRAILING_WHITESPACE ) +# Set Version +set(EMULATOR_VERSION_MAJOR "0") +set(EMULATOR_VERSION_MINOR "8") +set(EMULATOR_VERSION_PATCH "1") + +set_source_files_properties(src/shadps4.rc PROPERTIES COMPILE_DEFINITIONS "EMULATOR_VERSION_MAJOR=${EMULATOR_VERSION_MAJOR};EMULATOR_VERSION_MINOR=${EMULATOR_VERSION_MINOR};EMULATOR_VERSION_PATCH=${EMULATOR_VERSION_PATCH}") + +set(APP_VERSION "${EMULATOR_VERSION_MAJOR}.${EMULATOR_VERSION_MINOR}.${EMULATOR_VERSION_PATCH} WIP") +set(APP_IS_RELEASE false) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/common/scm_rev.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/src/common/scm_rev.cpp" @ONLY) +message("end git things, remote: ${GIT_REMOTE_NAME}, branch: ${GIT_BRANCH}") + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") find_package(Boost 1.84.0 CONFIG) find_package(FFmpeg 5.1.2 MODULE) find_package(fmt 10.2.0 CONFIG) @@ -161,21 +226,18 @@ find_package(SDL3 3.1.2 CONFIG) find_package(stb MODULE) find_package(toml11 4.2.0 CONFIG) find_package(tsl-robin-map 1.3.0 CONFIG) -find_package(VulkanHeaders 1.4.305 CONFIG) +find_package(VulkanHeaders 1.4.309 CONFIG) find_package(VulkanMemoryAllocator 3.1.0 CONFIG) find_package(xbyak 7.07 CONFIG) find_package(xxHash 0.8.2 MODULE) find_package(ZLIB 1.3 MODULE) find_package(Zydis 5.0.0 CONFIG) find_package(pugixml 1.14 CONFIG) - -if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR NOT MSVC) - find_package(cryptopp 8.9.0 MODULE) -endif() - +find_package(libusb 1.0.27 MODULE) if (APPLE) find_package(date 3.0.1 CONFIG) endif() +list(POP_BACK CMAKE_MODULE_PATH) # Note: Windows always has these functions through winpthreads include(CheckSymbolExists) @@ -278,6 +340,8 @@ set(KERNEL_LIB src/core/libraries/kernel/sync/mutex.cpp src/core/libraries/kernel/threads/thread_state.h src/core/libraries/kernel/process.cpp src/core/libraries/kernel/process.h + src/core/libraries/kernel/debug.cpp + src/core/libraries/kernel/debug.h src/core/libraries/kernel/equeue.cpp src/core/libraries/kernel/equeue.h src/core/libraries/kernel/file_system.cpp @@ -298,6 +362,7 @@ set(KERNEL_LIB src/core/libraries/kernel/sync/mutex.cpp set(NETWORK_LIBS src/core/libraries/network/http.cpp src/core/libraries/network/http.h + src/core/libraries/network/http_error.h src/core/libraries/network/http2.cpp src/core/libraries/network/http2.h src/core/libraries/network/net.cpp @@ -370,12 +435,28 @@ set(SYSTEM_LIBS src/core/libraries/system/commondialog.cpp src/core/libraries/ngs2/ngs2_error.h src/core/libraries/ngs2/ngs2_impl.cpp src/core/libraries/ngs2/ngs2_impl.h + src/core/libraries/ngs2/ngs2_custom.cpp + src/core/libraries/ngs2/ngs2_custom.h + src/core/libraries/ngs2/ngs2_reverb.cpp + src/core/libraries/ngs2/ngs2_reverb.h + src/core/libraries/ngs2/ngs2_geom.cpp + src/core/libraries/ngs2/ngs2_geom.h + src/core/libraries/ngs2/ngs2_pan.cpp + src/core/libraries/ngs2/ngs2_pan.h + src/core/libraries/ngs2/ngs2_report.cpp + src/core/libraries/ngs2/ngs2_report.h + src/core/libraries/ngs2/ngs2_eq.cpp + src/core/libraries/ngs2/ngs2_eq.h + src/core/libraries/ngs2/ngs2_mastering.cpp + src/core/libraries/ngs2/ngs2_mastering.h + src/core/libraries/ngs2/ngs2_sampler.cpp + src/core/libraries/ngs2/ngs2_sampler.h + src/core/libraries/ngs2/ngs2_submixer.cpp + src/core/libraries/ngs2/ngs2_submixer.h src/core/libraries/ajm/ajm_error.h src/core/libraries/audio3d/audio3d.cpp src/core/libraries/audio3d/audio3d.h src/core/libraries/audio3d/audio3d_error.h - src/core/libraries/audio3d/audio3d_impl.cpp - src/core/libraries/audio3d/audio3d_impl.h src/core/libraries/game_live_streaming/gamelivestreaming.cpp src/core/libraries/game_live_streaming/gamelivestreaming.h src/core/libraries/remote_play/remoteplay.cpp @@ -489,6 +570,8 @@ set(NP_LIBS src/core/libraries/np_common/np_common.cpp src/core/libraries/np_web_api/np_web_api.h src/core/libraries/np_party/np_party.cpp src/core/libraries/np_party/np_party.h + src/core/libraries/np_auth/np_auth.cpp + src/core/libraries/np_auth/np_auth.h ) set(ZLIB_LIB src/core/libraries/zlib/zlib.cpp @@ -504,6 +587,8 @@ set(MISC_LIBS src/core/libraries/screenshot/screenshot.cpp src/core/libraries/screenshot/screenshot.h src/core/libraries/move/move.cpp src/core/libraries/move/move.h + src/core/libraries/ulobjmgr/ulobjmgr.cpp + src/core/libraries/ulobjmgr/ulobjmgr.h ) set(DEV_TOOLS src/core/devtools/layer.cpp @@ -543,6 +628,7 @@ set(COMMON src/common/logging/backend.cpp src/common/logging/text_formatter.cpp src/common/logging/text_formatter.h src/common/logging/types.h + src/common/aes.h src/common/alignment.h src/common/arch.h src/common/assert.cpp @@ -574,6 +660,7 @@ set(COMMON src/common/logging/backend.cpp src/common/polyfill_thread.h src/common/rdtsc.cpp src/common/rdtsc.h + src/common/sha1.h src/common/signal_context.h src/common/signal_context.cpp src/common/singleton.h @@ -583,6 +670,7 @@ set(COMMON src/common/logging/backend.cpp src/common/spin_lock.h src/common/stb.cpp src/common/stb.h + src/common/string_literal.h src/common/string_util.cpp src/common/string_util.h src/common/thread.cpp @@ -591,7 +679,6 @@ set(COMMON src/common/logging/backend.cpp src/common/uint128.h src/common/unique_function.h src/common/va_ctx.h - src/common/version.h src/common/ntapi.h src/common/ntapi.cpp src/common/number_utils.h @@ -612,9 +699,6 @@ set(CORE src/core/aerolib/stubs.cpp src/core/aerolib/aerolib.h src/core/address_space.cpp src/core/address_space.h - src/core/crypto/crypto.cpp - src/core/crypto/crypto.h - src/core/crypto/keys.h src/core/devices/base_device.cpp src/core/devices/base_device.h src/core/devices/ioccom.h @@ -632,22 +716,14 @@ set(CORE src/core/aerolib/stubs.cpp src/core/devices/srandom_device.cpp src/core/devices/srandom_device.h src/core/file_format/pfs.h - src/core/file_format/pkg.cpp - src/core/file_format/pkg.h - src/core/file_format/pkg_type.cpp - src/core/file_format/pkg_type.h src/core/file_format/psf.cpp src/core/file_format/psf.h src/core/file_format/playgo_chunk.cpp src/core/file_format/playgo_chunk.h src/core/file_format/trp.cpp src/core/file_format/trp.h - src/core/file_format/splash.h - src/core/file_format/splash.cpp src/core/file_sys/fs.cpp src/core/file_sys/fs.h - src/core/loader.cpp - src/core/loader.h src/core/loader/dwarf.cpp src/core/loader/dwarf.h src/core/loader/elf.cpp @@ -764,6 +840,8 @@ set(SHADER_RECOMPILER src/shader_recompiler/exception.h src/shader_recompiler/ir/passes/identity_removal_pass.cpp src/shader_recompiler/ir/passes/ir_passes.h src/shader_recompiler/ir/passes/lower_buffer_format_to_raw.cpp + src/shader_recompiler/ir/passes/lower_fp64_to_fp32.cpp + src/shader_recompiler/ir/passes/readlane_elimination_pass.cpp src/shader_recompiler/ir/passes/resource_tracking_pass.cpp src/shader_recompiler/ir/passes/ring_access_elimination.cpp src/shader_recompiler/ir/passes/shader_info_collection_pass.cpp @@ -844,6 +922,10 @@ set(VIDEO_CORE src/video_core/amdgpu/liverpool.cpp src/video_core/renderer_vulkan/vk_shader_util.h src/video_core/renderer_vulkan/vk_swapchain.cpp src/video_core/renderer_vulkan/vk_swapchain.h + src/video_core/renderer_vulkan/host_passes/fsr_pass.cpp + src/video_core/renderer_vulkan/host_passes/fsr_pass.h + src/video_core/renderer_vulkan/host_passes/pp_pass.cpp + src/video_core/renderer_vulkan/host_passes/pp_pass.h src/video_core/texture_cache/image.cpp src/video_core/texture_cache/image.h src/video_core/texture_cache/image_info.cpp @@ -916,6 +998,9 @@ set(QT_GUI src/qt_gui/about_dialog.cpp src/qt_gui/control_settings.cpp src/qt_gui/control_settings.h src/qt_gui/control_settings.ui + src/qt_gui/kbm_gui.cpp + src/qt_gui/kbm_gui.h + src/qt_gui/kbm_gui.ui src/qt_gui/main_window_ui.h src/qt_gui/main_window.cpp src/qt_gui/main_window.h @@ -929,10 +1014,6 @@ set(QT_GUI src/qt_gui/about_dialog.cpp src/qt_gui/game_grid_frame.h src/qt_gui/game_install_dialog.cpp src/qt_gui/game_install_dialog.h - src/qt_gui/install_dir_select.cpp - src/qt_gui/install_dir_select.h - src/qt_gui/pkg_viewer.cpp - src/qt_gui/pkg_viewer.h src/qt_gui/trophy_viewer.cpp src/qt_gui/trophy_viewer.h src/qt_gui/elf_viewer.cpp @@ -988,7 +1069,7 @@ endif() create_target_directory_groups(shadps4) target_link_libraries(shadps4 PRIVATE magic_enum::magic_enum fmt::fmt toml11::toml11 tsl::robin_map xbyak::xbyak Tracy::TracyClient RenderDoc::API FFmpeg::ffmpeg Dear_ImGui gcn half::half ZLIB::ZLIB PNG::PNG) -target_link_libraries(shadps4 PRIVATE Boost::headers GPUOpen::VulkanMemoryAllocator LibAtrac9 sirit Vulkan::Headers xxHash::xxhash Zydis::Zydis glslang::glslang SDL3::SDL3 pugixml::pugixml stb::headers) +target_link_libraries(shadps4 PRIVATE Boost::headers GPUOpen::VulkanMemoryAllocator LibAtrac9 sirit Vulkan::Headers xxHash::xxhash Zydis::Zydis glslang::glslang SDL3::SDL3 pugixml::pugixml stb::headers libusb::usb) target_compile_definitions(shadps4 PRIVATE IMGUI_USER_CONFIG="imgui/imgui_config.h") target_compile_definitions(Dear_ImGui PRIVATE IMGUI_USER_CONFIG="${PROJECT_SOURCE_DIR}/src/imgui/imgui_config.h") @@ -1003,46 +1084,49 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND ENABLE_USERFAULTFD) endif() if (APPLE) - if (ENABLE_QT_GUI) - # Include MoltenVK in the app bundle, along with an ICD file so it can be found by the system Vulkan loader if used for loading layers. - set(MVK_ICD ${CMAKE_CURRENT_SOURCE_DIR}/externals/MoltenVK/MoltenVK_icd.json) - target_sources(shadps4 PRIVATE ${MVK_ICD}) - set_source_files_properties(${MVK_ICD} PROPERTIES MACOSX_PACKAGE_LOCATION Resources/vulkan/icd.d) + # Include MoltenVK, along with an ICD file so it can be found by the system Vulkan loader if used for loading layers. + if (ENABLE_QT_GUI) + set(MVK_BUNDLE_PATH "Resources/vulkan/icd.d") + set_property(TARGET shadps4 APPEND PROPERTY BUILD_RPATH "@executable_path/../${MVK_BUNDLE_PATH}") + set(MVK_DST ${CMAKE_CURRENT_BINARY_DIR}/shadps4.app/Contents/${MVK_BUNDLE_PATH}) + else() + set_property(TARGET shadps4 APPEND PROPERTY BUILD_RPATH "@executable_path") + set(MVK_DST ${CMAKE_CURRENT_BINARY_DIR}) + endif() - set(MVK_DYLIB_SRC ${CMAKE_CURRENT_BINARY_DIR}/externals/MoltenVK/libMoltenVK.dylib) - set(MVK_DYLIB_DST ${CMAKE_CURRENT_BINARY_DIR}/shadps4.app/Contents/Frameworks/libMoltenVK.dylib) - add_custom_command( - OUTPUT ${MVK_DYLIB_DST} - DEPENDS ${MVK_DYLIB_SRC} - COMMAND cmake -E copy ${MVK_DYLIB_SRC} ${MVK_DYLIB_DST}) - add_custom_target(CopyMoltenVK DEPENDS ${MVK_DYLIB_DST}) - add_dependencies(CopyMoltenVK MoltenVK) - add_dependencies(shadps4 CopyMoltenVK) - set_property(TARGET shadps4 APPEND PROPERTY BUILD_RPATH "@executable_path/../Frameworks") - else() - # For non-bundled SDL build, just do a normal library link. - target_link_libraries(shadps4 PRIVATE MoltenVK) - endif() + set(MVK_DYLIB_SRC ${CMAKE_CURRENT_BINARY_DIR}/externals/MoltenVK/libMoltenVK.dylib) + set(MVK_DYLIB_DST ${MVK_DST}/libMoltenVK.dylib) + set(MVK_ICD_SRC ${CMAKE_CURRENT_SOURCE_DIR}/externals/MoltenVK/MoltenVK/MoltenVK/icd/MoltenVK_icd.json) + set(MVK_ICD_DST ${MVK_DST}/MoltenVK_icd.json) - if (ARCHITECTURE STREQUAL "x86_64") - # Reserve system-managed memory space. - target_link_options(shadps4 PRIVATE -Wl,-no_pie,-no_fixup_chains,-no_huge,-pagezero_size,0x4000,-segaddr,TCB_SPACE,0x4000,-segaddr,SYSTEM_MANAGED,0x400000,-segaddr,SYSTEM_RESERVED,0x7FFFFC000,-image_base,0x20000000000) - endif() + add_custom_command( + OUTPUT ${MVK_DST} + COMMAND ${CMAKE_COMMAND} -E make_directory ${MVK_DST}) + add_custom_command( + OUTPUT ${MVK_ICD_DST} + DEPENDS ${MVK_ICD_SRC} ${MVK_DST} + COMMAND ${CMAKE_COMMAND} -E copy ${MVK_ICD_SRC} ${MVK_ICD_DST}) + add_custom_command( + OUTPUT ${MVK_DYLIB_DST} + DEPENDS ${MVK_DYLIB_SRC} ${MVK_DST} + COMMAND ${CMAKE_COMMAND} -E copy ${MVK_DYLIB_SRC} ${MVK_DYLIB_DST}) + add_custom_target(CopyMoltenVK DEPENDS ${MVK_ICD_DST} ${MVK_DYLIB_DST}) + add_dependencies(CopyMoltenVK MoltenVK) + add_dependencies(shadps4 CopyMoltenVK) - # Replacement for std::chrono::time_zone - target_link_libraries(shadps4 PRIVATE date::date-tz) + if (ARCHITECTURE STREQUAL "x86_64") + # Reserve system-managed memory space. + target_link_options(shadps4 PRIVATE -Wl,-no_pie,-no_fixup_chains,-no_huge,-pagezero_size,0x4000,-segaddr,TCB_SPACE,0x4000,-segaddr,SYSTEM_MANAGED,0x400000,-segaddr,SYSTEM_RESERVED,0x7FFFFC000,-image_base,0x20000000000) + endif() + + # Replacement for std::chrono::time_zone + target_link_libraries(shadps4 PRIVATE date::date-tz) endif() if (NOT ENABLE_QT_GUI) target_link_libraries(shadps4 PRIVATE SDL3::SDL3) endif() -if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND MSVC) - target_link_libraries(shadps4 PRIVATE cryptoppwin) -else() - target_link_libraries(shadps4 PRIVATE cryptopp::cryptopp) -endif() - if (ENABLE_QT_GUI) target_link_libraries(shadps4 PRIVATE Qt6::Widgets Qt6::Concurrent Qt6::Network Qt6::Multimedia) add_definitions(-DENABLE_QT_GUI) @@ -1105,7 +1189,7 @@ target_include_directories(shadps4 PRIVATE ${HOST_SHADERS_INCLUDE}) # embed resources -include(CMakeRC) +include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/CMakeRC.cmake") cmrc_add_resource_library(embedded-resources ALIAS res::embedded NAMESPACE res @@ -1113,7 +1197,6 @@ cmrc_add_resource_library(embedded-resources src/images/gold.png src/images/platinum.png src/images/silver.png) - target_link_libraries(shadps4 PRIVATE res::embedded) # ImGui resources @@ -1127,8 +1210,8 @@ if (ENABLE_QT_GUI) MACOSX_BUNDLE ON MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/dist/MacOSBundleInfo.plist.in" MACOSX_BUNDLE_ICON_FILE "shadPS4.icns" - MACOSX_BUNDLE_SHORT_VERSION_STRING "0.4.1" - ) + MACOSX_BUNDLE_SHORT_VERSION_STRING "${APP_VERSION}" + ) set_source_files_properties(src/images/shadPS4.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources) diff --git a/README.md b/README.md index 9259ab875..985bba586 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ SPDX-License-Identifier: GPL-2.0-or-later

- + @@ -71,7 +71,7 @@ Check the build instructions for [**Linux**](https://github.com/shadps4-emu/shad Check the build instructions for [**macOS**](https://github.com/shadps4-emu/shadPS4/blob/main/documents/building-macos.md). > [!IMPORTANT] -> macOS users need at least macOS 15 on Apple Silicon-based Mac devices and at least macOS 14 on Intel-based Mac devices. +> macOS users need at least macOS 15.4 to run shadPS4. Due to GPU issues there are currently heavy bugs on Intel Macs. # Debugging and reporting issues @@ -122,19 +122,37 @@ R3 | M | Keyboard and mouse inputs can be customized in the settings menu by clicking the Controller button, and further details and help on controls are also found there. Custom bindings are saved per-game. Inputs support up to three keys per binding, mouse buttons, mouse movement mapped to joystick input, and more. +# Firmware files + +shadPS4 can load some PlayStation 4 firmware files, these must be dumped from your legally owned PlayStation 4 console.\ +The following firmware modules are supported and must be placed in shadPS4's `user/sys_modules` folder. + +
+ +| Modules | Modules | Modules | Modules | +|-------------------------|-------------------------|-------------------------|-------------------------| +| libSceCesCs.sprx | libSceFont.sprx | libSceFontFt.sprx | libSceFreeTypeOt.sprx | +| libSceJson.sprx | libSceJson2.sprx | libSceLibcInternal.sprx | libSceNgs2.sprx | +| libSceRtc.sprx | libSceUlt.sprx | | | + +
+ +> [!Caution] +> The above modules are required to run the games properly and must be extracted from your PlayStation 4.\ +> **We do not provide any information or support on how to do this**. + + + # Main team - [**georgemoralis**](https://github.com/georgemoralis) -- [**raphaelthegreat**](https://github.com/raphaelthegreat) - [**psucien**](https://github.com/psucien) -- [**skmp**](https://github.com/skmp) -- [**wheremyfoodat**](https://github.com/wheremyfoodat) -- [**raziel1000**](https://github.com/raziel1000) - [**viniciuslrangel**](https://github.com/viniciuslrangel) - [**roamic**](https://github.com/vladmikhalin) -- [**poly**](https://github.com/polybiusproxy) - [**squidbus**](https://github.com/squidbus) - [**frodo**](https://github.com/baggins183) +- [**Stephen Miller**](https://github.com/StevenMiller123) +- [**kalaposfos13**](https://github.com/kalaposfos13) Logo is done by [**Xphalnos**](https://github.com/Xphalnos) @@ -145,11 +163,11 @@ Open a PR and we'll check it :) # Translations -If you want to translate shadPS4 to your language we use [**crowdin**](https://crowdin.com/project/shadps4-emulator). +If you want to translate shadPS4 to your language we use [**Crowdin**](https://crowdin.com/project/shadps4-emulator). # Contributors
- + diff --git a/REUSE.toml b/REUSE.toml index d8f31c2f2..662987611 100644 --- a/REUSE.toml +++ b/REUSE.toml @@ -30,6 +30,7 @@ path = [ "src/images/dump_icon.png", "src/images/exit_icon.png", "src/images/file_icon.png", + "src/images/trophy_icon.png", "src/images/flag_china.png", "src/images/flag_eu.png", "src/images/flag_jp.png", @@ -41,23 +42,33 @@ path = [ "src/images/grid_icon.png", "src/images/keyboard_icon.png", "src/images/iconsize_icon.png", + "src/images/KBM.png", "src/images/ko-fi.png", "src/images/list_icon.png", "src/images/list_mode_icon.png", "src/images/pause_icon.png", "src/images/play_icon.png", "src/images/ps4_controller.png", - "src/images/refresh_icon.png", + "src/images/restart_game_icon.png", + "src/images/refreshlist_icon.png", "src/images/settings_icon.png", + "src/images/fullscreen_icon.png", "src/images/stop_icon.png", "src/images/utils_icon.png", "src/images/shadPS4.icns", "src/images/shadps4.ico", + "src/images/shadps4.png", "src/images/net.shadps4.shadPS4.svg", "src/images/themes_icon.png", "src/images/update_icon.png", "src/images/youtube.png", "src/images/website.png", + "src/images/discord.svg", + "src/images/github.svg", + "src/images/ko-fi.svg", + "src/images/shadps4.svg", + "src/images/website.svg", + "src/images/youtube.svg", "src/shadps4.qrc", "src/shadps4.rc", "src/qt_gui/translations/update_translation.sh", @@ -110,4 +121,9 @@ SPDX-License-Identifier = "CC0-1.0" [[annotations]] path = "cmake/CMakeRC.cmake" SPDX-FileCopyrightText = "Copyright (c) 2017 vector-of-bool " -SPDX-License-Identifier = "MIT" \ No newline at end of file +SPDX-License-Identifier = "MIT" + +[[annotations]] +path = "src/video_core/host_shaders/fsr/*" +SPDX-FileCopyrightText = "Copyright (c) 2021 Advanced Micro Devices, Inc. All rights reserved." +SPDX-License-Identifier = "MIT" diff --git a/cmake/Findcryptopp.cmake b/cmake/Findcryptopp.cmake deleted file mode 100644 index d57c0bc54..000000000 --- a/cmake/Findcryptopp.cmake +++ /dev/null @@ -1,15 +0,0 @@ -# SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project -# SPDX-License-Identifier: GPL-2.0-or-later - -find_package(PkgConfig QUIET) -pkg_search_module(CRYPTOPP QUIET IMPORTED_TARGET libcryptopp) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(cryptopp - REQUIRED_VARS CRYPTOPP_LINK_LIBRARIES - VERSION_VAR CRYPTOPP_VERSION -) - -if (cryptopp_FOUND AND NOT TARGET cryptopp::cryptopp) - add_library(cryptopp::cryptopp ALIAS PkgConfig::CRYPTOPP) -endif() diff --git a/cmake/Findlibusb.cmake b/cmake/Findlibusb.cmake new file mode 100644 index 000000000..c8b35e979 --- /dev/null +++ b/cmake/Findlibusb.cmake @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project +# SPDX-License-Identifier: GPL-2.0-or-later + +find_package(PkgConfig QUIET) +pkg_search_module(LIBUSB QUIET IMPORTED_TARGET libusb-1.0) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(libusb + REQUIRED_VARS LIBUSB_LINK_LIBRARIES + VERSION_VAR LIBUSB_VERSION +) + +if (libusb_FOUND AND NOT TARGET libusb::usb) + add_library(libusb::usb ALIAS PkgConfig::LIBUSB) +endif() diff --git a/dist/net.shadps4.shadPS4.metainfo.xml b/dist/net.shadps4.shadPS4.metainfo.xml index c8c9d5c23..9f7b4f9c5 100644 --- a/dist/net.shadps4.shadPS4.metainfo.xml +++ b/dist/net.shadps4.shadPS4.metainfo.xml @@ -37,6 +37,12 @@ Game + + https://github.com/shadps4-emu/shadPS4/releases/tag/v.0.8.0 + + + https://github.com/shadps4-emu/shadPS4/releases/tag/v.0.7.0 + https://github.com/shadps4-emu/shadPS4/releases/tag/v.0.6.0 diff --git a/documents/Quickstart/2.png b/documents/Quickstart/2.png deleted file mode 100644 index 7e5bdfb15..000000000 Binary files a/documents/Quickstart/2.png and /dev/null differ diff --git a/documents/Quickstart/Quickstart.md b/documents/Quickstart/Quickstart.md index 2f2751887..62df95e71 100644 --- a/documents/Quickstart/Quickstart.md +++ b/documents/Quickstart/Quickstart.md @@ -13,7 +13,6 @@ SPDX-License-Identifier: GPL-2.0-or-later - [**RAM**](#ram) - [**OS**](#os) - [**Have the latest WIP version**](#how-to-run-the-latest-work-in-progress-builds-of-shadps4) -- [**Install PKG files (Games and Updates)**](#install-pkg-files) - [**Configure the emulator**](#configure-the-emulator) ## Minimum PC requirements @@ -25,13 +24,13 @@ SPDX-License-Identifier: GPL-2.0-or-later - A CPU supporting the following instruction sets: MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, F16C, CLMUL, AES, BMI1, MOVBE, XSAVE, ABM - **Intel**: Haswell generation or newer - **AMD**: Jaguar generation or newer - - **Apple**: Rosetta 2 on macOS 15 or newer + - **Apple**: Rosetta 2 on macOS 15.4 or newer ### GPU - A graphics card with at least 1GB of VRAM -- Keep your graphics drivers up to date -- Vulkan 1.3 support (required) +- Up-to-date graphics drivers +- Vulkan 1.3 with the `VK_KHR_swapchain` and `VK_KHR_push_descriptor` extensions ### RAM @@ -48,13 +47,7 @@ SPDX-License-Identifier: GPL-2.0-or-later 2. Once downloaded, extract to its own folder, and run shadPS4's executable from the extracted folder. -3. Upon first launch, shadPS4 will prompt you to select a folder to store your installed games in. Select "Browse" and then select a folder that shadPS4 can use to install your PKG files to. - -## Install PKG files - -To install PKG files (game and updates), you will need the Qt application (with UI). You will have to go to "File" then to "Install Packages (PKG)", a window will open then you will have to select the files. You can install multiple PKG files at once. Once finished, the game should appear in the application. - - +3. Upon first launch, shadPS4 will prompt you to select a folder to store your installed games in. Select "Browse" and then select a folder that contains your dumped games. ## Configure the emulator diff --git a/documents/building-linux.md b/documents/building-linux.md index 18ddab0c6..cdc8ba12f 100644 --- a/documents/building-linux.md +++ b/documents/building-linux.md @@ -108,7 +108,7 @@ Now run the emulator. If Qt was enabled at configure time: ./build/shadps4 ``` -Otherwise, specify the path to your PKG's boot file: +Otherwise, specify the path to your game's boot file: ```bash ./build/shadps4 /"PATH"/"TO"/"GAME"/"FOLDER"/eboot.bin diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index bb434677d..b92e13795 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -26,24 +26,7 @@ if (NOT TARGET fmt::fmt) add_subdirectory(fmt) endif() -if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND MSVC) - # If it is clang and MSVC we will add a static lib - # CryptoPP - add_subdirectory(cryptoppwin) - target_include_directories(cryptoppwin INTERFACE cryptoppwin/include) -else() - # CryptoPP - if (NOT TARGET cryptopp::cryptopp) - set(CRYPTOPP_INSTALL OFF) - set(CRYPTOPP_BUILD_TESTING OFF) - set(CRYPTOPP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/cryptopp) - add_subdirectory(cryptopp-cmake) - file(COPY cryptopp DESTINATION cryptopp FILES_MATCHING PATTERN "*.h") - # remove externals/cryptopp from include directories because it contains a conflicting zlib.h file - set_target_properties(cryptopp PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/cryptopp") - endif() -endif() - +# FFmpeg if (NOT TARGET FFmpeg::ffmpeg) add_subdirectory(ffmpeg-core) add_library(FFmpeg::ffmpeg ALIAS ffmpeg) @@ -218,6 +201,12 @@ if (NOT TARGET pugixml::pugixml) add_subdirectory(pugixml) endif() +# libusb +if (NOT TARGET libusb::usb) + add_subdirectory(libusb) + add_library(libusb::usb ALIAS usb-1.0) +endif() + # Discord RPC if (ENABLE_DISCORD_RPC) add_subdirectory(discord-rpc) diff --git a/externals/MoltenVK/MoltenVK b/externals/MoltenVK/MoltenVK index 2048427e5..87a8e8b13 160000 --- a/externals/MoltenVK/MoltenVK +++ b/externals/MoltenVK/MoltenVK @@ -1 +1 @@ -Subproject commit 2048427e50f9eb20f2b8f98d316ecaee398c9b91 +Subproject commit 87a8e8b13d4ad8835367fea1ebad1896d0460946 diff --git a/externals/MoltenVK/MoltenVK_icd.json b/externals/MoltenVK/MoltenVK_icd.json deleted file mode 100644 index 2c3319263..000000000 --- a/externals/MoltenVK/MoltenVK_icd.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "file_format_version": "1.0.0", - "ICD": { - "library_path": "../../../Frameworks/libMoltenVK.dylib", - "api_version": "1.2.0", - "is_portability_driver": true - } -} diff --git a/externals/MoltenVK/SPIRV-Cross b/externals/MoltenVK/SPIRV-Cross index 2c32b6bf8..791877574 160000 --- a/externals/MoltenVK/SPIRV-Cross +++ b/externals/MoltenVK/SPIRV-Cross @@ -1 +1 @@ -Subproject commit 2c32b6bf86f3c4a5539aa1f0bacbd59fe61759cf +Subproject commit 7918775748c5e2f5c40d9918ce68825035b5a1e1 diff --git a/externals/MoltenVK/cereal b/externals/MoltenVK/cereal index d1fcec807..a56bad8bb 160000 --- a/externals/MoltenVK/cereal +++ b/externals/MoltenVK/cereal @@ -1 +1 @@ -Subproject commit d1fcec807b372f04e4c1041b3058e11c12853e6e +Subproject commit a56bad8bbb770ee266e930c95d37fff2a5be7fea diff --git a/externals/cryptopp b/externals/cryptopp deleted file mode 160000 index 60f81a77e..000000000 --- a/externals/cryptopp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 60f81a77e0c9a0e7ffc1ca1bc438ddfa2e43b78e diff --git a/externals/cryptopp-cmake b/externals/cryptopp-cmake deleted file mode 160000 index 2c384c282..000000000 --- a/externals/cryptopp-cmake +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2c384c28265a93358a2455e610e76393358794df diff --git a/externals/cryptoppwin b/externals/cryptoppwin deleted file mode 160000 index bc3441dd2..000000000 --- a/externals/cryptoppwin +++ /dev/null @@ -1 +0,0 @@ -Subproject commit bc3441dd2d6a9728e747dc0180bc8b9065a2923c diff --git a/externals/date b/externals/date index 28b7b2325..a45ea7c17 160000 --- a/externals/date +++ b/externals/date @@ -1 +1 @@ -Subproject commit 28b7b232521ace2c8ef3f2ad4126daec3569c14f +Subproject commit a45ea7c17b4a7f320e199b71436074bd624c9e15 diff --git a/externals/dear_imgui b/externals/dear_imgui index 636cd4a7d..f4d935909 160000 --- a/externals/dear_imgui +++ b/externals/dear_imgui @@ -1 +1 @@ -Subproject commit 636cd4a7d623a2bc9bf59bb3acbb4ca075befba3 +Subproject commit f4d9359095eff3eb03f685921edc1cf0e37b1687 diff --git a/externals/discord-rpc b/externals/discord-rpc index 51b09d426..19f66e6dc 160000 --- a/externals/discord-rpc +++ b/externals/discord-rpc @@ -1 +1 @@ -Subproject commit 51b09d426a4a1bcfa6ee6d4894e57d669f4a2e65 +Subproject commit 19f66e6dcabb2268965f453db9e5774ede43238f diff --git a/externals/ffmpeg-core b/externals/ffmpeg-core index 27de97c82..b0de1dcca 160000 --- a/externals/ffmpeg-core +++ b/externals/ffmpeg-core @@ -1 +1 @@ -Subproject commit 27de97c826b6b40c255891c37ac046a25836a575 +Subproject commit b0de1dcca26c0ebfb8011b8e59dd17fc399db0ff diff --git a/externals/fmt b/externals/fmt index 8ee89546f..64db979e3 160000 --- a/externals/fmt +++ b/externals/fmt @@ -1 +1 @@ -Subproject commit 8ee89546ffcf046309d1f0d38c0393f02fde56c8 +Subproject commit 64db979e38ec644b1798e41610b28c8d2c8a2739 diff --git a/externals/glslang b/externals/glslang index a0995c49e..ba1640446 160000 --- a/externals/glslang +++ b/externals/glslang @@ -1 +1 @@ -Subproject commit a0995c49ebcaca2c6d3b03efbabf74f3843decdb +Subproject commit ba1640446f3826a518721d1f083f3a8cca1120c3 diff --git a/externals/libusb b/externals/libusb new file mode 160000 index 000000000..a63a7e43e --- /dev/null +++ b/externals/libusb @@ -0,0 +1 @@ +Subproject commit a63a7e43e0950a595cf4b98a0eaf4051749ace5f diff --git a/externals/magic_enum b/externals/magic_enum index 1a1824df7..a413fcc9c 160000 --- a/externals/magic_enum +++ b/externals/magic_enum @@ -1 +1 @@ -Subproject commit 1a1824df7ac798177a521eed952720681b0bf482 +Subproject commit a413fcc9c46a020a746907136a384c227f3cd095 diff --git a/externals/pugixml b/externals/pugixml index 4bc14418d..caade5a28 160000 --- a/externals/pugixml +++ b/externals/pugixml @@ -1 +1 @@ -Subproject commit 4bc14418d12d289dd9978fdce9490a45deeb653e +Subproject commit caade5a28aad86b92a4b5337a9dc70c4ba73c5eb diff --git a/externals/robin-map b/externals/robin-map index fe845fd78..4ec1bf19c 160000 --- a/externals/robin-map +++ b/externals/robin-map @@ -1 +1 @@ -Subproject commit fe845fd7852ef541c5479ae23b3d36b57f8608ee +Subproject commit 4ec1bf19c6a96125ea22062f38c2cf5b958e448e diff --git a/externals/sdl3 b/externals/sdl3 index a336b62d8..4093e4a19 160000 --- a/externals/sdl3 +++ b/externals/sdl3 @@ -1 +1 @@ -Subproject commit a336b62d8b0b97b09214e053203e442e2b6e2be5 +Subproject commit 4093e4a193971ef1d4928158e0a1832be42e4599 diff --git a/externals/sirit b/externals/sirit index 8b9b12c20..427a42c9e 160000 --- a/externals/sirit +++ b/externals/sirit @@ -1 +1 @@ -Subproject commit 8b9b12c2089505ac8b10fa56bf56b3ed49d9d7b0 +Subproject commit 427a42c9ed99b38204d9107bc3dc14e92458acf1 diff --git a/externals/toml11 b/externals/toml11 index 7f6c574ff..a01fe3b4c 160000 --- a/externals/toml11 +++ b/externals/toml11 @@ -1 +1 @@ -Subproject commit 7f6c574ff5aa1053534e7e19c0a4f22bf4c6aaca +Subproject commit a01fe3b4c14c6d7b99ee3f07c9e80058c6403097 diff --git a/externals/vma b/externals/vma index 5a53a1989..f378e7b3f 160000 --- a/externals/vma +++ b/externals/vma @@ -1 +1 @@ -Subproject commit 5a53a198945ba8260fbc58fadb788745ce6aa263 +Subproject commit f378e7b3f18f6e2b06b957f6ba7b1c7207d2a536 diff --git a/externals/vulkan-headers b/externals/vulkan-headers index a03d2f6d5..5ceb9ed48 160000 --- a/externals/vulkan-headers +++ b/externals/vulkan-headers @@ -1 +1 @@ -Subproject commit a03d2f6d5753b365d704d58161825890baad0755 +Subproject commit 5ceb9ed481e58e705d0d9b5326537daedd06b97d diff --git a/externals/winpthreads b/externals/winpthreads index f00c973a6..f35b0948d 160000 --- a/externals/winpthreads +++ b/externals/winpthreads @@ -1 +1 @@ -Subproject commit f00c973a6ab2a23573708568b8ef4acc20a9d36b +Subproject commit f35b0948d36a736e6a2d052ae295a3ffde09703f diff --git a/externals/xbyak b/externals/xbyak index 4e44f4614..44a72f369 160000 --- a/externals/xbyak +++ b/externals/xbyak @@ -1 +1 @@ -Subproject commit 4e44f4614ddbf038f2a6296f5b906d5c72691e0f +Subproject commit 44a72f369268f7d552650891b296693e91db86bb diff --git a/externals/xxhash b/externals/xxhash index 2bf8313b9..953a09abc 160000 --- a/externals/xxhash +++ b/externals/xxhash @@ -1 +1 @@ -Subproject commit 2bf8313b934633b2a5b7e8fd239645b85e10c852 +Subproject commit 953a09abc39096da9e216b6eb0002c681cdc1199 diff --git a/externals/zlib-ng b/externals/zlib-ng index d54e3769b..fd0d263ce 160000 --- a/externals/zlib-ng +++ b/externals/zlib-ng @@ -1 +1 @@ -Subproject commit d54e3769be0c522015b784eca2af258b1c026107 +Subproject commit fd0d263cedab1a136f40d65199987e3eaeecfcbd diff --git a/externals/zydis b/externals/zydis index bffbb610c..120e0e705 160000 --- a/externals/zydis +++ b/externals/zydis @@ -1 +1 @@ -Subproject commit bffbb610cfea643b98e87658b9058382f7522807 +Subproject commit 120e0e705f8e3b507dc49377ac2879979f0d545c diff --git a/src/common/aes.h b/src/common/aes.h new file mode 100644 index 000000000..5ca0096bd --- /dev/null +++ b/src/common/aes.h @@ -0,0 +1,1195 @@ +// SPDX-FileCopyrightText: 2015 kkAyataka +// SPDX-License-Identifier: BSL-1.0 + +#pragma once + +#include +#include +#include +#include +#include +#include + +/** AES cipher APIs */ +namespace aes { +namespace detail { + +const int kWordSize = 4; +typedef unsigned int Word; + +const int kBlockSize = 4; +/** @private */ +struct State { + Word w[4]; + Word& operator[](const int index) { + return w[index]; + } + const Word& operator[](const int index) const { + return w[index]; + } +}; + +const int kStateSize = 16; // Word * BlockSize +typedef State RoundKey; +typedef std::vector RoundKeys; + +inline void add_round_key(const RoundKey& key, State& state) { + for (int i = 0; i < kBlockSize; ++i) { + state[i] ^= key[i]; + } +} + +const unsigned char kSbox[] = { + 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, + 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, + 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, + 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, + 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, + 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, + 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, + 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, + 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, + 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, + 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, + 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, + 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, + 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, + 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, + 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16}; + +const unsigned char kInvSbox[] = { + 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, + 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, + 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, + 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25, + 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, + 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, + 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, + 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, + 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, + 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e, + 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, + 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, + 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, + 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, + 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, + 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d}; + +inline Word sub_word(const Word w) { + return kSbox[(w >> 0) & 0xFF] << 0 | kSbox[(w >> 8) & 0xFF] << 8 | + kSbox[(w >> 16) & 0xFF] << 16 | kSbox[(w >> 24) & 0xFF] << 24; +} + +inline Word inv_sub_word(const Word w) { + return kInvSbox[(w >> 0) & 0xFF] << 0 | kInvSbox[(w >> 8) & 0xFF] << 8 | + kInvSbox[(w >> 16) & 0xFF] << 16 | kInvSbox[(w >> 24) & 0xFF] << 24; +} + +inline void sub_bytes(State& state) { + for (int i = 0; i < kBlockSize; ++i) { + state[i] = sub_word(state[i]); + } +} + +inline void inv_sub_bytes(State& state) { + for (int i = 0; i < kBlockSize; ++i) { + state[i] = inv_sub_word(state[i]); + } +} + +inline void shift_rows(State& state) { + const State ori = {state[0], state[1], state[2], state[3]}; + for (int r = 1; r < kWordSize; ++r) { + const Word m2 = 0xFF << (r * 8); + const Word m1 = ~m2; + for (int c = 0; c < kBlockSize; ++c) { + state[c] = (state[c] & m1) | (ori[(c + r) % kBlockSize] & m2); + } + } +} + +inline void inv_shift_rows(State& state) { + const State ori = {state[0], state[1], state[2], state[3]}; + for (int r = 1; r < kWordSize; ++r) { + const Word m2 = 0xFF << (r * 8); + const Word m1 = ~m2; + for (int c = 0; c < kBlockSize; ++c) { + state[c] = (state[c] & m1) | (ori[(c + kBlockSize - r) % kWordSize] & m2); + } + } +} + +inline unsigned char mul2(const unsigned char b) { + unsigned char m2 = b << 1; + if (b & 0x80) { + m2 ^= 0x011B; + } + + return m2; +} + +inline unsigned char mul(const unsigned char b, const unsigned char m) { + unsigned char v = 0; + unsigned char t = b; + for (int i = 0; i < 8; ++i) { // 8-bits + if ((m >> i) & 0x01) { + v ^= t; + } + + t = mul2(t); + } + + return v; +} + +inline void mix_columns(State& state) { + for (int i = 0; i < kBlockSize; ++i) { + const unsigned char v0_1 = (state[i] >> 0) & 0xFF; + const unsigned char v1_1 = (state[i] >> 8) & 0xFF; + const unsigned char v2_1 = (state[i] >> 16) & 0xFF; + const unsigned char v3_1 = (state[i] >> 24) & 0xFF; + + const unsigned char v0_2 = mul2(v0_1); + const unsigned char v1_2 = mul2(v1_1); + const unsigned char v2_2 = mul2(v2_1); + const unsigned char v3_2 = mul2(v3_1); + + const unsigned char v0_3 = v0_2 ^ v0_1; + const unsigned char v1_3 = v1_2 ^ v1_1; + const unsigned char v2_3 = v2_2 ^ v2_1; + const unsigned char v3_3 = v3_2 ^ v3_1; + + state[i] = (v0_2 ^ v1_3 ^ v2_1 ^ v3_1) << 0 | (v0_1 ^ v1_2 ^ v2_3 ^ v3_1) << 8 | + (v0_1 ^ v1_1 ^ v2_2 ^ v3_3) << 16 | (v0_3 ^ v1_1 ^ v2_1 ^ v3_2) << 24; + } +} + +inline void inv_mix_columns(State& state) { + for (int i = 0; i < kBlockSize; ++i) { + const unsigned char v0 = (state[i] >> 0) & 0xFF; + const unsigned char v1 = (state[i] >> 8) & 0xFF; + const unsigned char v2 = (state[i] >> 16) & 0xFF; + const unsigned char v3 = (state[i] >> 24) & 0xFF; + + state[i] = (mul(v0, 0x0E) ^ mul(v1, 0x0B) ^ mul(v2, 0x0D) ^ mul(v3, 0x09)) << 0 | + (mul(v0, 0x09) ^ mul(v1, 0x0E) ^ mul(v2, 0x0B) ^ mul(v3, 0x0D)) << 8 | + (mul(v0, 0x0D) ^ mul(v1, 0x09) ^ mul(v2, 0x0E) ^ mul(v3, 0x0B)) << 16 | + (mul(v0, 0x0B) ^ mul(v1, 0x0D) ^ mul(v2, 0x09) ^ mul(v3, 0x0E)) << 24; + } +} + +inline Word rot_word(const Word v) { + return ((v >> 8) & 0x00FFFFFF) | ((v & 0xFF) << 24); +} + +/** + * @private + * @throws std::invalid_argument + */ +inline unsigned int get_round_count(const int key_size) { + switch (key_size) { + case 16: + return 10; + case 24: + return 12; + case 32: + return 14; + default: + throw std::invalid_argument("Invalid key size"); + } +} + +/** + * @private + * @throws std::invalid_argument + */ +inline RoundKeys expand_key(const unsigned char* key, const int key_size) { + if (key_size != 16 && key_size != 24 && key_size != 32) { + throw std::invalid_argument("Invalid key size"); + } + + const Word rcon[] = {0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36}; + + const int nb = kBlockSize; + const int nk = key_size / nb; + const int nr = get_round_count(key_size); + + std::vector w(nb * (nr + 1)); + for (int i = 0; i < nk; ++i) { + memcpy(&w[i], key + (i * kWordSize), kWordSize); + } + + for (int i = nk; i < nb * (nr + 1); ++i) { + Word t = w[i - 1]; + if (i % nk == 0) { + t = sub_word(rot_word(t)) ^ rcon[i / nk]; + } else if (nk > 6 && i % nk == 4) { + t = sub_word(t); + } + + w[i] = t ^ w[i - nk]; + } + + RoundKeys keys(nr + 1); + memcpy(&keys[0], &w[0], w.size() * kWordSize); + + return keys; +} + +inline void copy_bytes_to_state(const unsigned char data[16], State& state) { + memcpy(&state[0], data + 0, kWordSize); + memcpy(&state[1], data + 4, kWordSize); + memcpy(&state[2], data + 8, kWordSize); + memcpy(&state[3], data + 12, kWordSize); +} + +inline void copy_state_to_bytes(const State& state, unsigned char buf[16]) { + memcpy(buf + 0, &state[0], kWordSize); + memcpy(buf + 4, &state[1], kWordSize); + memcpy(buf + 8, &state[2], kWordSize); + memcpy(buf + 12, &state[3], kWordSize); +} + +inline void xor_data(unsigned char data[kStateSize], const unsigned char v[kStateSize]) { + for (int i = 0; i < kStateSize; ++i) { + data[i] ^= v[i]; + } +} + +/** increment counter (128-bit int) by 1 */ +inline void incr_counter(unsigned char counter[kStateSize]) { + unsigned n = kStateSize, c = 1; + do { + --n; + c += counter[n]; + counter[n] = c; + c >>= 8; + } while (n); +} + +inline void encrypt_state(const RoundKeys& rkeys, const unsigned char data[16], + unsigned char encrypted[16]) { + State s; + copy_bytes_to_state(data, s); + + add_round_key(rkeys[0], s); + + for (unsigned int i = 1; i < rkeys.size() - 1; ++i) { + sub_bytes(s); + shift_rows(s); + mix_columns(s); + add_round_key(rkeys[i], s); + } + + sub_bytes(s); + shift_rows(s); + add_round_key(rkeys.back(), s); + + copy_state_to_bytes(s, encrypted); +} + +inline void decrypt_state(const RoundKeys& rkeys, const unsigned char data[16], + unsigned char decrypted[16]) { + State s; + copy_bytes_to_state(data, s); + + add_round_key(rkeys.back(), s); + inv_shift_rows(s); + inv_sub_bytes(s); + + for (std::size_t i = rkeys.size() - 2; i > 0; --i) { + add_round_key(rkeys[i], s); + inv_mix_columns(s); + inv_shift_rows(s); + inv_sub_bytes(s); + } + + add_round_key(rkeys[0], s); + + copy_state_to_bytes(s, decrypted); +} + +template +std::vector key_from_string(const char (*key_str)[KeyLen]) { + std::vector key(KeyLen - 1); + memcpy(&key[0], *key_str, KeyLen - 1); + return key; +} + +inline bool is_valid_key_size(const std::size_t key_size) { + if (key_size != 16 && key_size != 24 && key_size != 32) { + return false; + } else { + return true; + } +} + +namespace gcm { + +const int kBlockBitSize = 128; +const int kBlockByteSize = kBlockBitSize / 8; + +/** + * @private + * GCM operation unit as bit. + * This library handles 128 bit little endian bit array. + * e.g. 0^127 || 1 == "000...0001" (bit string) == 1 + */ +typedef std::bitset bitset128; + +/** + * @private + * GCM operation unit. + * Little endian byte array + * + * If bitset128 is 1: 0^127 || 1 == "000...0001" (bit string) == 1 + * byte array is 0x00, 0x00, 0x00 ... 0x01 (low -> high). + * Byte array is NOT 0x01, 0x00 ... 0x00. + * + * This library handles GCM bit string in two ways. + * One is an array of bitset, which is a little endian 128-bit array's array. + * + * <- first byte + * bitset128 || bitset128 || bitset128... + * + * The other one is a byte array. + * <- first byte + * byte || byte || byte... + */ +class Block { +public: + Block() { + init_v(0, 0); + } + + Block(const unsigned char* bytes, const unsigned long bytes_size) { + init_v(bytes, bytes_size); + } + + Block(const std::vector& bytes) { + init_v(&bytes[0], bytes.size()); + } + + Block(const std::bitset<128>& bits); // implementation below + + inline unsigned char* data() { + return v_; + } + + inline const unsigned char* data() const { + return v_; + } + + inline std::bitset<128> to_bits() const { + std::bitset<128> bits; + for (int i = 0; i < 16; ++i) { + bits <<= 8; + bits |= v_[i]; + } + + return bits; + } + + inline Block operator^(const Block& b) const { + Block r; + for (int i = 0; i < 16; ++i) { + r.data()[i] = data()[i] ^ b.data()[i]; + } + return r; + } + +private: + unsigned char v_[16]; + + inline void init_v(const unsigned char* bytes, const std::size_t bytes_size) { + memset(v_, 0, sizeof(v_)); + + const std::size_t cs = (std::min)(bytes_size, static_cast(16)); + for (std::size_t i = 0; i < cs; ++i) { + v_[i] = bytes[i]; + } + } +}; + +// Workaround for clang optimization in 32-bit build via Visual Studio producing incorrect results +// (https://github.com/kkAyataka/plusaes/issues/43) +#if defined(__clang__) && defined(_WIN32) && !defined(_WIN64) +#pragma optimize("", off) +#endif +inline Block::Block(const std::bitset<128>& bits) { + init_v(0, 0); + const std::bitset<128> mask(0xFF); // 1 byte mask + for (std::size_t i = 0; i < 16; ++i) { + v_[15 - i] = static_cast(((bits >> (i * 8)) & mask).to_ulong()); + } +} +#if defined(__clang__) && defined(_WIN32) && !defined(_WIN64) +#pragma optimize("", on) +#endif + +template +unsigned long ceil(const T v) { + return static_cast(std::ceil(v) + 0.5); +} + +template +std::bitset operator||(const std::bitset& v1, const std::bitset& v2) { + std::bitset ret(v1.to_string() + v2.to_string()); + return ret; +} + +template +std::bitset lsb(const std::bitset& X) { + std::bitset r; + for (std::size_t i = 0; i < S; ++i) { + r[i] = X[i]; + } + return r; +} + +template +std::bitset msb(const std::bitset& X) { + std::bitset r; + for (std::size_t i = 0; i < S; ++i) { + r[S - 1 - i] = X[X.size() - 1 - i]; + } + return r; +} + +template +std::bitset inc32(const std::bitset X) { + const std::size_t S = 32; + + const auto a = msb(X); + const std::bitset b( + (lsb(X).to_ulong() + 1)); // % (2^32); + // lsb<32> is low 32-bit value + // Spec.'s "mod 2^S" is not necessary when S is 32 (inc32). + // ...and 2^32 is over 32-bit integer. + + return a || b; +} + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wself-assign" +#endif // __clang__ + +/** Algorithm 1 @private */ +inline Block mul_blocks(const Block X, const Block Y) { + const bitset128 R = (std::bitset<8>("11100001") || std::bitset<120>()); + + bitset128 X_bits = X.to_bits(); + bitset128 Z; + bitset128 V = Y.to_bits(); + for (int i = 127; i >= 0; --i) { + // Z + if (X_bits[i] == false) { + Z = Z; + } else { + Z = Z ^ V; + } + + // V + if (V[0] == false) { + V = V >> 1; + } else { + V = (V >> 1) ^ R; + } + } + + return Z; +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif // __clang__ + +/** Algorithm 2 @private */ +inline Block ghash(const Block& H, const std::vector& X) { + const std::size_t m = X.size() / kBlockByteSize; + Block Ym; + for (std::size_t i = 0; i < m; ++i) { + const Block Xi(&X[i * kBlockByteSize], kBlockByteSize); + Ym = mul_blocks((Ym ^ Xi), H); + } + + return Ym; +} + +template +std::bitset make_bitset(const unsigned char* bytes, const std::size_t bytes_size) { + std::bitset bits; + for (auto i = 0u; i < bytes_size; ++i) { + bits <<= 8; + bits |= bytes[i]; + } + return bits; +} + +/** Algorithm 3 @private */ +inline std::vector gctr(const detail::RoundKeys& rkeys, const Block& ICB, + const unsigned char* X, const std::size_t X_size) { + if (!X || X_size == 0) { + return std::vector(); + } else { + const unsigned long n = ceil(X_size * 8.0 / kBlockBitSize); + std::vector Y(X_size); + + Block CB; + for (std::size_t i = 0; i < n; ++i) { + // CB + if (i == 0) { // first + CB = ICB; + } else { + CB = inc32(CB.to_bits()); + } + + // CIPH + Block eCB; + encrypt_state(rkeys, CB.data(), eCB.data()); + + // Y + int op_size = 0; + if (i < n - 1) { + op_size = kBlockByteSize; + } else { // last + op_size = (X_size % kBlockByteSize) ? (X_size % kBlockByteSize) : kBlockByteSize; + } + const Block Yi = Block(X + i * kBlockBitSize / 8, op_size) ^ eCB; + memcpy(&Y[i * kBlockByteSize], Yi.data(), op_size); + } + + return Y; + } +} + +inline void push_back(std::vector& bytes, const unsigned char* data, + const std::size_t data_size) { + bytes.insert(bytes.end(), data, data + data_size); +} + +inline void push_back(std::vector& bytes, const std::bitset<64>& bits) { + const std::bitset<64> mask(0xFF); // 1 byte mask + for (std::size_t i = 0; i < 8; ++i) { + bytes.push_back(static_cast(((bits >> ((7 - i) * 8)) & mask).to_ulong())); + } +} + +inline void push_back_zero_bits(std::vector& bytes, + const std::size_t zero_bits_size) { + const std::vector zero_bytes(zero_bits_size / 8); + bytes.insert(bytes.end(), zero_bytes.begin(), zero_bytes.end()); +} + +inline Block calc_H(const RoundKeys& rkeys) { + std::vector H_raw(gcm::kBlockByteSize); + encrypt_state(rkeys, &H_raw[0], &H_raw[0]); + return gcm::Block(H_raw); +} + +inline Block calc_J0(const Block& H, const unsigned char* iv, const std::size_t iv_size) { + if (iv_size == 12) { + const std::bitset<96> iv_bits = gcm::make_bitset<96>(iv, iv_size); + return iv_bits || std::bitset<31>() || std::bitset<1>(1); + } else { + const auto len_iv = iv_size * 8; + const auto s = 128 * gcm::ceil(len_iv / 128.0) - len_iv; + std::vector ghash_in; + gcm::push_back(ghash_in, iv, iv_size); + gcm::push_back_zero_bits(ghash_in, s + 64); + gcm::push_back(ghash_in, std::bitset<64>(len_iv)); + + return gcm::ghash(H, ghash_in); + } +} + +inline void calc_gcm_tag(const unsigned char* data, const std::size_t data_size, + const unsigned char* aadata, const std::size_t aadata_size, + const unsigned char* key, const std::size_t key_size, + const unsigned char* iv, const std::size_t iv_size, unsigned char* tag, + const std::size_t tag_size) { + const detail::RoundKeys rkeys = detail::expand_key(key, static_cast(key_size)); + const gcm::Block H = gcm::calc_H(rkeys); + const gcm::Block J0 = gcm::calc_J0(H, iv, iv_size); + + const auto lenC = data_size * 8; + const auto lenA = aadata_size * 8; + const std::size_t u = 128 * gcm::ceil(lenC / 128.0) - lenC; + const std::size_t v = 128 * gcm::ceil(lenA / 128.0) - lenA; + + std::vector ghash_in; + ghash_in.reserve((aadata_size + v / 8) + (data_size + u / 8) + 8 + 8); + gcm::push_back(ghash_in, aadata, aadata_size); + gcm::push_back_zero_bits(ghash_in, v); + gcm::push_back(ghash_in, data, data_size); + gcm::push_back_zero_bits(ghash_in, u); + gcm::push_back(ghash_in, std::bitset<64>(lenA)); + gcm::push_back(ghash_in, std::bitset<64>(lenC)); + const gcm::Block S = gcm::ghash(H, ghash_in); + const std::vector T = gcm::gctr(rkeys, J0, S.data(), gcm::kBlockByteSize); + + // return + memcpy(tag, &T[0], (std::min)(tag_size, static_cast(16))); +} + +/** Algorithm 4 and 5 @private */ +inline void crypt_gcm(const unsigned char* data, const std::size_t data_size, + const unsigned char* key, const std::size_t key_size, const unsigned char* iv, + const std::size_t iv_size, unsigned char* crypted) { + const detail::RoundKeys rkeys = detail::expand_key(key, static_cast(key_size)); + const gcm::Block H = gcm::calc_H(rkeys); + const gcm::Block J0 = gcm::calc_J0(H, iv, iv_size); + + const std::vector C = + gcm::gctr(rkeys, gcm::inc32(J0.to_bits()), data, data_size); + + if (crypted) { + memcpy(crypted, &C[0], data_size); + } +} + +} // namespace gcm + +} // namespace detail + +/** @defgroup Base Base + * Base definitions and convenient functions + * @{ */ + +/** Create 128-bit key from string. */ +inline std::vector key_from_string(const char (*key_str)[17]) { + return detail::key_from_string<17>(key_str); +} + +/** Create 192-bit key from string. */ +inline std::vector key_from_string(const char (*key_str)[25]) { + return detail::key_from_string<25>(key_str); +} + +/** Create 256-bit key from string. */ +inline std::vector key_from_string(const char (*key_str)[33]) { + return detail::key_from_string<33>(key_str); +} + +/** Calculates encrypted data size when padding is enabled. */ +inline unsigned long get_padded_encrypted_size(const unsigned long data_size) { + return data_size + detail::kStateSize - (data_size % detail::kStateSize); +} + +/** Error code */ +typedef enum { + kErrorOk = 0, + kErrorInvalidDataSize = 1, + kErrorInvalidKeySize, + kErrorInvalidBufferSize, + kErrorInvalidKey, + kErrorDeprecated, // kErrorInvalidNonceSize + kErrorInvalidIvSize, + kErrorInvalidTagSize, + kErrorInvalidTag +} Error; + +/** @} */ + +namespace detail { + +inline Error check_encrypt_cond(const unsigned long data_size, const unsigned long key_size, + const unsigned long encrypted_size, const bool pads) { + // check data size + if (!pads && (data_size % kStateSize != 0)) { + return kErrorInvalidDataSize; + } + + // check key size + if (!detail::is_valid_key_size(key_size)) { + return kErrorInvalidKeySize; + } + + // check encrypted buffer size + if (pads) { + const unsigned long required_size = get_padded_encrypted_size(data_size); + if (encrypted_size < required_size) { + return kErrorInvalidBufferSize; + } + } else { + if (encrypted_size < data_size) { + return kErrorInvalidBufferSize; + } + } + return kErrorOk; +} + +inline Error check_decrypt_cond(const unsigned long data_size, const unsigned long key_size, + const unsigned long decrypted_size, + const unsigned long* padded_size) { + // check data size + if (data_size % 16 != 0) { + return kErrorInvalidDataSize; + } + + // check key size + if (!detail::is_valid_key_size(key_size)) { + return kErrorInvalidKeySize; + } + + // check decrypted buffer size + if (!padded_size) { + if (decrypted_size < data_size) { + return kErrorInvalidBufferSize; + } + } else { + if (decrypted_size < (data_size - kStateSize)) { + return kErrorInvalidBufferSize; + } + } + + return kErrorOk; +} + +inline bool check_padding(const unsigned long padding, const unsigned char data[kStateSize]) { + if (padding > kStateSize) { + return false; + } + + for (unsigned long i = 0; i < padding; ++i) { + if (data[kStateSize - 1 - i] != padding) { + return false; + } + } + + return true; +} + +inline Error check_gcm_cond(const std::size_t key_size, const std::size_t iv_size, + const std::size_t tag_size) { + // check key size + if (!detail::is_valid_key_size(key_size)) { + return kErrorInvalidKeySize; + } + + if (iv_size < 1) { + return kErrorInvalidIvSize; + } + + // check tag size + if ((tag_size < 12 || 16 < tag_size) && (tag_size != 8) && (tag_size != 4)) { + return kErrorInvalidTagSize; + } + + return kErrorOk; +} + +} // namespace detail + +/** @defgroup ECB ECB + * ECB mode functions + * @{ */ + +/** + * Encrypts data with ECB mode. + * @param [in] data Data. + * @param [in] data_size Data size. + * If the pads is false, data size must be multiple of 16. + * @param [in] key key bytes. The key length must be 16 (128-bit), 24 (192-bit) or 32 (256-bit). + * @param [in] key_size key size. + * @param [out] encrypted Encrypted data buffer. + * @param [in] encrypted_size Encrypted data buffer size. + * @param [in] pads If this value is true, encrypted data is padded by PKCS. + * Encrypted data size must be multiple of 16. + * If the pads is true, encrypted data is padded with PKCS. + * So the data is multiple of 16, encrypted data size needs additonal 16 bytes. + * @since 1.0.0 + */ +inline Error encrypt_ecb(const unsigned char* data, const unsigned long data_size, + const unsigned char* key, const unsigned long key_size, + unsigned char* encrypted, const unsigned long encrypted_size, + const bool pads) { + const Error e = detail::check_encrypt_cond(data_size, key_size, encrypted_size, pads); + if (e != kErrorOk) { + return e; + } + + const detail::RoundKeys rkeys = detail::expand_key(key, static_cast(key_size)); + + const unsigned long bc = data_size / detail::kStateSize; + for (unsigned long i = 0; i < bc; ++i) { + detail::encrypt_state(rkeys, data + (i * detail::kStateSize), + encrypted + (i * detail::kStateSize)); + } + + if (pads) { + const int rem = data_size % detail::kStateSize; + const char pad_v = detail::kStateSize - rem; + + std::vector ib(detail::kStateSize, pad_v), ob(detail::kStateSize); + memcpy(&ib[0], data + data_size - rem, rem); + + detail::encrypt_state(rkeys, &ib[0], &ob[0]); + memcpy(encrypted + (data_size - rem), &ob[0], detail::kStateSize); + } + + return kErrorOk; +} + +/** + * Decrypts data with ECB mode. + * @param [in] data Data bytes. + * @param [in] data_size Data size. + * @param [in] key Key bytes. + * @param [in] key_size Key size. + * @param [out] decrypted Decrypted data buffer. + * @param [in] decrypted_size Decrypted data buffer size. + * @param [out] padded_size If this value is NULL, this function does not remove padding. + * If this value is not NULL, this function removes padding by PKCS + * and returns padded size using padded_size. + * @since 1.0.0 + */ +inline Error decrypt_ecb(const unsigned char* data, const unsigned long data_size, + const unsigned char* key, const unsigned long key_size, + unsigned char* decrypted, const unsigned long decrypted_size, + unsigned long* padded_size) { + const Error e = detail::check_decrypt_cond(data_size, key_size, decrypted_size, padded_size); + if (e != kErrorOk) { + return e; + } + + const detail::RoundKeys rkeys = detail::expand_key(key, static_cast(key_size)); + + const unsigned long bc = data_size / detail::kStateSize - 1; + for (unsigned long i = 0; i < bc; ++i) { + detail::decrypt_state(rkeys, data + (i * detail::kStateSize), + decrypted + (i * detail::kStateSize)); + } + + unsigned char last[detail::kStateSize] = {}; + detail::decrypt_state(rkeys, data + (bc * detail::kStateSize), last); + + if (padded_size) { + *padded_size = last[detail::kStateSize - 1]; + const unsigned long cs = detail::kStateSize - *padded_size; + + if (!detail::check_padding(*padded_size, last)) { + return kErrorInvalidKey; + } else if (decrypted_size >= (bc * detail::kStateSize) + cs) { + memcpy(decrypted + (bc * detail::kStateSize), last, cs); + } else { + return kErrorInvalidBufferSize; + } + } else { + memcpy(decrypted + (bc * detail::kStateSize), last, sizeof(last)); + } + + return kErrorOk; +} + +/** @} */ + +/** @defgroup CBC CBC + * CBC mode functions + * @{ */ + +/** + * Encrypt data with CBC mode. + * @param [in] data Data. + * @param [in] data_size Data size. + * If the pads is false, data size must be multiple of 16. + * @param [in] key key bytes. The key length must be 16 (128-bit), 24 (192-bit) or 32 (256-bit). + * @param [in] key_size key size. + * @param [in] iv Initialize vector. + * @param [out] encrypted Encrypted data buffer. + * @param [in] encrypted_size Encrypted data buffer size. + * @param [in] pads If this value is true, encrypted data is padded by PKCS. + * Encrypted data size must be multiple of 16. + * If the pads is true, encrypted data is padded with PKCS. + * So the data is multiple of 16, encrypted data size needs additonal 16 bytes. + * @since 1.0.0 + */ +inline Error encrypt_cbc(const unsigned char* data, const unsigned long data_size, + const unsigned char* key, const unsigned long key_size, + const unsigned char iv[16], unsigned char* encrypted, + const unsigned long encrypted_size, const bool pads) { + const Error e = detail::check_encrypt_cond(data_size, key_size, encrypted_size, pads); + if (e != kErrorOk) { + return e; + } + + const detail::RoundKeys rkeys = detail::expand_key(key, static_cast(key_size)); + + unsigned char s[detail::kStateSize] = {}; // encrypting data + + // calculate padding value + const bool ge16 = (data_size >= detail::kStateSize); + const int rem = data_size % detail::kStateSize; + const unsigned char pad_v = detail::kStateSize - rem; + + // encrypt 1st state + if (ge16) { + memcpy(s, data, detail::kStateSize); + } else { + memset(s, pad_v, detail::kStateSize); + memcpy(s, data, data_size); + } + if (iv) { + detail::xor_data(s, iv); + } + detail::encrypt_state(rkeys, s, encrypted); + + // encrypt mid + const unsigned long bc = data_size / detail::kStateSize; + for (unsigned long i = 1; i < bc; ++i) { + const long offset = i * detail::kStateSize; + memcpy(s, data + offset, detail::kStateSize); + detail::xor_data(s, encrypted + offset - detail::kStateSize); + + detail::encrypt_state(rkeys, s, encrypted + offset); + } + + // enctypt last + if (pads && ge16) { + std::vector ib(detail::kStateSize, pad_v), ob(detail::kStateSize); + memcpy(&ib[0], data + data_size - rem, rem); + + detail::xor_data(&ib[0], encrypted + (bc - 1) * detail::kStateSize); + + detail::encrypt_state(rkeys, &ib[0], &ob[0]); + memcpy(encrypted + (data_size - rem), &ob[0], detail::kStateSize); + } + + return kErrorOk; +} + +/** + * Decrypt data with CBC mode. + * @param [in] data Data bytes. + * @param [in] data_size Data size. + * @param [in] key Key bytes. + * @param [in] key_size Key size. + * @param [in] iv Initialize vector. + * @param [out] decrypted Decrypted data buffer. + * @param [in] decrypted_size Decrypted data buffer size. + * @param [out] padded_size If this value is NULL, this function does not remove padding. + * If this value is not NULL, this function removes padding by PKCS + * and returns padded size using padded_size. + * @since 1.0.0 + */ +inline Error decrypt_cbc(const unsigned char* data, const unsigned long data_size, + const unsigned char* key, const unsigned long key_size, + const unsigned char iv[16], unsigned char* decrypted, + const unsigned long decrypted_size, unsigned long* padded_size) { + const Error e = detail::check_decrypt_cond(data_size, key_size, decrypted_size, padded_size); + if (e != kErrorOk) { + return e; + } + + const detail::RoundKeys rkeys = detail::expand_key(key, static_cast(key_size)); + + // decrypt 1st state + detail::decrypt_state(rkeys, data, decrypted); + if (iv) { + detail::xor_data(decrypted, iv); + } + + // decrypt mid + const unsigned long bc = data_size / detail::kStateSize - 1; + for (unsigned long i = 1; i < bc; ++i) { + const long offset = i * detail::kStateSize; + detail::decrypt_state(rkeys, data + offset, decrypted + offset); + detail::xor_data(decrypted + offset, data + offset - detail::kStateSize); + } + + // decrypt last + unsigned char last[detail::kStateSize] = {}; + if (data_size > detail::kStateSize) { + detail::decrypt_state(rkeys, data + (bc * detail::kStateSize), last); + detail::xor_data(last, data + (bc * detail::kStateSize - detail::kStateSize)); + } else { + memcpy(last, decrypted, data_size); + memset(decrypted, 0, decrypted_size); + } + + if (padded_size) { + *padded_size = last[detail::kStateSize - 1]; + const unsigned long cs = detail::kStateSize - *padded_size; + + if (!detail::check_padding(*padded_size, last)) { + return kErrorInvalidKey; + } else if (decrypted_size >= (bc * detail::kStateSize) + cs) { + memcpy(decrypted + (bc * detail::kStateSize), last, cs); + } else { + return kErrorInvalidBufferSize; + } + } else { + memcpy(decrypted + (bc * detail::kStateSize), last, sizeof(last)); + } + + return kErrorOk; +} + +/** @} */ + +/** @defgroup GCM GCM + * GCM mode functions + * @{ */ + +/** + * Encrypts data with GCM mode and gets an authentication tag. + * + * You can specify iv size and tag size. + * But usually you should use the other overloaded function whose iv and tag size is fixed. + * + * @returns kErrorOk + * @returns kErrorInvalidKeySize + * @returns kErrorInvalidIvSize + * @returns kErrorInvalidTagSize + */ +inline Error encrypt_gcm(unsigned char* data, const std::size_t data_size, + const unsigned char* aadata, const std::size_t aadata_size, + const unsigned char* key, const std::size_t key_size, + const unsigned char* iv, const std::size_t iv_size, unsigned char* tag, + const std::size_t tag_size) { + const Error err = detail::check_gcm_cond(key_size, iv_size, tag_size); + if (err != kErrorOk) { + return err; + } + + detail::gcm::crypt_gcm(data, data_size, key, key_size, iv, iv_size, data); + detail::gcm::calc_gcm_tag(data, data_size, aadata, aadata_size, key, key_size, iv, iv_size, tag, + tag_size); + + return kErrorOk; +} + +/** + * Encrypts data with GCM mode and gets an authentication tag. + * + * @param [in,out] data Input data and output buffer. + * This buffer is replaced with encrypted data. + * @param [in] data_size data size + * @param [in] aadata Additional Authenticated data + * @param [in] aadata_size aadata size + * @param [in] key Cipher key + * @param [in] key_size Cipher key size. This value must be 16 (128-bit), 24 (192-bit), or 32 + * (256-bit). + * @param [in] iv Initialization vector + * @param [out] tag Calculated authentication tag data + * + * @returns kErrorOk + * @returns kErrorInvalidKeySize + */ +inline Error encrypt_gcm(unsigned char* data, const std::size_t data_size, + const unsigned char* aadata, const std::size_t aadata_size, + const unsigned char* key, const std::size_t key_size, + const unsigned char (*iv)[12], unsigned char (*tag)[16]) { + return encrypt_gcm(data, data_size, aadata, aadata_size, key, key_size, *iv, 12, *tag, 16); +} + +/** + * Decrypts data with GCM mode and checks an authentication tag. + * + * You can specify iv size and tag size. + * But usually you should use the other overloaded function whose iv and tag size is fixed. + * + * @returns kErrorOk + * @returns kErrorInvalidKeySize + * @returns kErrorInvalidIvSize + * @returns kErrorInvalidTagSize + * @returns kErrorInvalidTag + */ +inline Error decrypt_gcm(unsigned char* data, const std::size_t data_size, + const unsigned char* aadata, const std::size_t aadata_size, + const unsigned char* key, const std::size_t key_size, + const unsigned char* iv, const std::size_t iv_size, + const unsigned char* tag, const std::size_t tag_size) { + const Error err = detail::check_gcm_cond(key_size, iv_size, tag_size); + if (err != kErrorOk) { + return err; + } + + unsigned char* C = data; + const auto C_size = data_size; + unsigned char tagd[16] = {}; + detail::gcm::calc_gcm_tag(C, C_size, aadata, aadata_size, key, key_size, iv, iv_size, tagd, 16); + + if (memcmp(tag, tagd, tag_size) != 0) { + return kErrorInvalidTag; + } else { + detail::gcm::crypt_gcm(C, C_size, key, key_size, iv, iv_size, C); + + return kErrorOk; + } +} + +/** + * Decrypts data with GCM mode and checks an authentication tag. + * + * @param [in,out] data Input data and output buffer. + * This buffer is replaced with decrypted data. + * @param [in] data_size data size + * @param [in] aadata Additional Authenticated data + * @param [in] aadata_size aadata size + * @param [in] key Cipher key + * @param [in] key_size Cipher key size. This value must be 16 (128-bit), 24 (192-bit), or 32 + * (256-bit). + * @param [in] iv Initialization vector + * @param [in] tag Authentication tag data + * + * @returns kErrorOk + * @returns kErrorInvalidKeySize + * @returns kErrorInvalidTag + */ +inline Error decrypt_gcm(unsigned char* data, const std::size_t data_size, + const unsigned char* aadata, const std::size_t aadata_size, + const unsigned char* key, const std::size_t key_size, + const unsigned char (*iv)[12], const unsigned char (*tag)[16]) { + return decrypt_gcm(data, data_size, aadata, aadata_size, key, key_size, *iv, 12, *tag, 16); +} + +/** @} */ + +/** @defgroup CTR CTR + * CTR mode function + * @{ */ + +/** + * Encrypts or decrypt data in-place with CTR mode. + * + * @param [in,out] data Input data and output buffer. + * This buffer is replaced with encrypted / decrypted data. + * @param [in] data_size Data size. + * @param [in] key Cipher key + * @param [in] key_size Cipher key size. This value must be 16 (128-bit), 24 (192-bit), or 32 + * (256-bit). + * @param [in] nonce Nonce of the counter initialization. + * + * @returns kErrorOk + * @returns kErrorInvalidKeySize + * @since 1.0.0 + */ +inline Error crypt_ctr(unsigned char* data, const std::size_t data_size, const unsigned char* key, + const std::size_t key_size, const unsigned char (*nonce)[16]) { + if (!detail::is_valid_key_size(key_size)) + return kErrorInvalidKeySize; + const detail::RoundKeys rkeys = detail::expand_key(key, static_cast(key_size)); + + unsigned long pos = 0; + unsigned long blkpos = detail::kStateSize; + unsigned char blk[detail::kStateSize] = {}; + unsigned char counter[detail::kStateSize] = {}; + memcpy(counter, nonce, 16); + + while (pos < data_size) { + if (blkpos == detail::kStateSize) { + detail::encrypt_state(rkeys, counter, blk); + detail::incr_counter(counter); + blkpos = 0; + } + data[pos++] ^= blk[blkpos++]; + } + + return kErrorOk; +} + +/** @} */ + +} // namespace aes diff --git a/src/common/config.cpp b/src/common/config.cpp index 36566a14c..111c0cfa9 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -7,10 +7,10 @@ #include // for wstring support #include +#include "common/config.h" +#include "common/logging/formatter.h" #include "common/path_util.h" -#include "config.h" -#include "logging/formatter.h" -#include "version.h" +#include "common/scm_rev.h" namespace toml { template @@ -32,6 +32,7 @@ std::filesystem::path find_fs_path_or(const basic_value& v, const K& ky, namespace Config { static bool isNeo = false; +static bool isDevKit = false; static bool playBGM = false; static bool isTrophyPopupDisabled = false; static int BGMvolume = 50; @@ -40,7 +41,7 @@ static u32 screenWidth = 1280; static u32 screenHeight = 720; static s32 gpuId = -1; // Vulkan physical device index. Set to negative for auto select static std::string logFilter; -static std::string logType = "async"; +static std::string logType = "sync"; static std::string userName = "shadPS4"; static std::string updateChannel; static std::string chooseHomeTab; @@ -53,7 +54,7 @@ static bool isShaderDebug = false; static bool isShowSplash = false; static bool isAutoUpdate = false; static bool isAlwaysShowChangelog = false; -static bool isLeftSideTrophy = false; +static std::string isSideTrophy = "right"; static bool isNullGpu = false; static bool shouldCopyGPUBuffers = false; static bool shouldDumpShaders = false; @@ -74,14 +75,14 @@ static double trophyNotificationDuration = 6.0; static bool useUnifiedInputConfig = true; static bool overrideControllerColor = false; static int controllerCustomColorRGB[3] = {0, 0, 255}; -static bool separateupdatefolder = false; static bool compatibilityData = false; static bool checkCompatibilityOnStartup = false; static std::string trophyKey; // Gui static bool load_game_size = true; -std::vector settings_install_dirs = {}; +static std::vector settings_install_dirs = {}; +std::vector install_dirs_enabled = {}; std::filesystem::path settings_addon_install_dir = {}; std::filesystem::path save_data_path = {}; u32 main_window_geometry_x = 400; @@ -96,7 +97,6 @@ u32 m_slider_pos_grid = 0; u32 m_table_mode = 0; u32 m_window_size_W = 1280; u32 m_window_size_H = 720; -std::vector m_pkg_viewer; std::vector m_elf_viewer; std::vector m_recent_files; std::string emulator_language = "en_US"; @@ -105,6 +105,7 @@ static bool showBackgroundImage = true; static bool isFullscreen = false; static std::string fullscreenMode = "Windowed"; static bool isHDRAllowed = false; +static bool showLabelsUnderIcons = true; // Language u32 m_language = 1; // english @@ -166,10 +167,22 @@ bool isNeoModeConsole() { return isNeo; } +bool isDevKitConsole() { + return isDevKit; +} + bool getIsFullscreen() { return isFullscreen; } +bool getShowLabelsUnderIcons() { + return showLabelsUnderIcons; +} + +bool setShowLabelsUnderIcons() { + return false; +} + std::string getFullscreenMode() { return fullscreenMode; } @@ -270,8 +283,8 @@ bool alwaysShowChangelog() { return isAlwaysShowChangelog; } -bool leftSideTrophy() { - return isLeftSideTrophy; +std::string sideTrophy() { + return isSideTrophy; } bool nullGpu() { @@ -338,10 +351,6 @@ void setVkGuestMarkersEnabled(bool enable) { vkGuestMarkers = enable; } -bool getSeparateUpdateEnabled() { - return separateupdatefolder; -} - bool getCompatibilityEnabled() { return compatibilityData; } @@ -381,8 +390,9 @@ void setAutoUpdate(bool enable) { void setAlwaysShowChangelog(bool enable) { isAlwaysShowChangelog = enable; } -void setLeftSideTrophy(bool enable) { - isLeftSideTrophy = enable; + +void setSideTrophy(std::string side) { + isSideTrophy = side; } void setNullGpu(bool enable) { @@ -420,6 +430,9 @@ void setVblankDiv(u32 value) { void setIsFullscreen(bool enable) { isFullscreen = enable; } +static void setShowLabelsUnderIcons(bool enable) { + showLabelsUnderIcons = enable; +} void setFullscreenMode(std::string mode) { fullscreenMode = mode; @@ -499,10 +512,6 @@ void setIsMotionControlsEnabled(bool use) { isMotionControlsEnabled = use; } -void setSeparateUpdateEnabled(bool use) { - separateupdatefolder = use; -} - void setCompatibilityEnabled(bool use) { compatibilityData = use; } @@ -518,22 +527,34 @@ void setMainWindowGeometry(u32 x, u32 y, u32 w, u32 h) { main_window_geometry_h = h; } -bool addGameInstallDir(const std::filesystem::path& dir) { - if (std::find(settings_install_dirs.begin(), settings_install_dirs.end(), dir) == - settings_install_dirs.end()) { - settings_install_dirs.push_back(dir); - return true; +bool addGameInstallDir(const std::filesystem::path& dir, bool enabled) { + for (const auto& install_dir : settings_install_dirs) { + if (install_dir.path == dir) { + return false; + } } - return false; + settings_install_dirs.push_back({dir, enabled}); + return true; } void removeGameInstallDir(const std::filesystem::path& dir) { - auto iterator = std::find(settings_install_dirs.begin(), settings_install_dirs.end(), dir); + auto iterator = + std::find_if(settings_install_dirs.begin(), settings_install_dirs.end(), + [&dir](const GameInstallDir& install_dir) { return install_dir.path == dir; }); if (iterator != settings_install_dirs.end()) { settings_install_dirs.erase(iterator); } } +void setGameInstallDirEnabled(const std::filesystem::path& dir, bool enabled) { + auto iterator = + std::find_if(settings_install_dirs.begin(), settings_install_dirs.end(), + [&dir](const GameInstallDir& install_dir) { return install_dir.path == dir; }); + if (iterator != settings_install_dirs.end()) { + iterator->enabled = enabled; + } +} + void setAddonInstallDir(const std::filesystem::path& dir) { settings_addon_install_dir = dir; } @@ -570,11 +591,6 @@ void setMainWindowHeight(u32 height) { m_window_size_H = height; } -void setPkgViewer(const std::vector& pkgList) { - m_pkg_viewer.resize(pkgList.size()); - m_pkg_viewer = pkgList; -} - void setElfViewer(const std::vector& elfList) { m_elf_viewer.resize(elfList.size()); m_elf_viewer = elfList; @@ -589,8 +605,15 @@ void setEmulatorLanguage(std::string language) { emulator_language = language; } -void setGameInstallDirs(const std::vector& settings_install_dirs_config) { - settings_install_dirs = settings_install_dirs_config; +void setGameInstallDirs(const std::vector& dirs_config) { + settings_install_dirs.clear(); + for (const auto& dir : dirs_config) { + settings_install_dirs.push_back({dir, true}); + } +} + +void setAllGameInstallDirs(const std::vector& dirs_config) { + settings_install_dirs = dirs_config; } void setSaveDataPath(const std::filesystem::path& path) { @@ -613,8 +636,22 @@ u32 getMainWindowGeometryH() { return main_window_geometry_h; } -const std::vector& getGameInstallDirs() { - return settings_install_dirs; +const std::vector getGameInstallDirs() { + std::vector enabled_dirs; + for (const auto& dir : settings_install_dirs) { + if (dir.enabled) { + enabled_dirs.push_back(dir.path); + } + } + return enabled_dirs; +} + +const std::vector getGameInstallDirsEnabled() { + std::vector enabled_dirs; + for (const auto& dir : settings_install_dirs) { + enabled_dirs.push_back(dir.enabled); + } + return enabled_dirs; } std::filesystem::path getAddonInstallDir() { @@ -657,10 +694,6 @@ u32 getMainWindowHeight() { return m_window_size_H; } -std::vector getPkgViewer() { - return m_pkg_viewer; -} - std::vector getElfViewer() { return m_elf_viewer; } @@ -720,6 +753,7 @@ void load(const std::filesystem::path& path) { const toml::value& general = data.at("General"); isNeo = toml::find_or(general, "isPS4Pro", false); + isDevKit = toml::find_or(general, "isDevKit", false); playBGM = toml::find_or(general, "playBGM", false); isTrophyPopupDisabled = toml::find_or(general, "isTrophyPopupDisabled", false); trophyNotificationDuration = @@ -729,7 +763,7 @@ void load(const std::filesystem::path& path) { logFilter = toml::find_or(general, "logFilter", ""); logType = toml::find_or(general, "logType", "sync"); userName = toml::find_or(general, "userName", "shadPS4"); - if (Common::isRelease) { + if (Common::g_is_release) { updateChannel = toml::find_or(general, "updateChannel", "Release"); } else { updateChannel = toml::find_or(general, "updateChannel", "Nightly"); @@ -737,8 +771,7 @@ void load(const std::filesystem::path& path) { isShowSplash = toml::find_or(general, "showSplash", true); isAutoUpdate = toml::find_or(general, "autoUpdate", false); isAlwaysShowChangelog = toml::find_or(general, "alwaysShowChangelog", false); - isLeftSideTrophy = toml::find_or(general, "leftSideTrophy", false); - separateupdatefolder = toml::find_or(general, "separateUpdateEnabled", false); + isSideTrophy = toml::find_or(general, "sideTrophy", "right"); compatibilityData = toml::find_or(general, "compatibilityEnabled", false); checkCompatibilityOnStartup = toml::find_or(general, "checkCompatibilityOnStartup", false); @@ -807,9 +840,23 @@ void load(const std::filesystem::path& path) { m_window_size_H = toml::find_or(gui, "mw_height", 0); const auto install_dir_array = - toml::find_or>(gui, "installDirs", {}); - for (const auto& dir : install_dir_array) { - addGameInstallDir(std::filesystem::path{dir}); + toml::find_or>(gui, "installDirs", {}); + + try { + install_dirs_enabled = toml::find>(gui, "installDirsEnabled"); + } catch (...) { + // If it does not exist, assume that all are enabled. + install_dirs_enabled.resize(install_dir_array.size(), true); + } + + if (install_dirs_enabled.size() < install_dir_array.size()) { + install_dirs_enabled.resize(install_dir_array.size(), true); + } + + settings_install_dirs.clear(); + for (size_t i = 0; i < install_dir_array.size(); i++) { + settings_install_dirs.push_back( + {std::filesystem::path{install_dir_array[i]}, install_dirs_enabled[i]}); } save_data_path = toml::find_fs_path_or(gui, "saveDataPath", {}); @@ -819,7 +866,6 @@ void load(const std::filesystem::path& path) { main_window_geometry_y = toml::find_or(gui, "geometry_y", 0); main_window_geometry_w = toml::find_or(gui, "geometry_w", 0); main_window_geometry_h = toml::find_or(gui, "geometry_h", 0); - m_pkg_viewer = toml::find_or>(gui, "pkgDirs", {}); m_elf_viewer = toml::find_or>(gui, "elfDirs", {}); m_recent_files = toml::find_or>(gui, "recentFiles", {}); m_table_mode = toml::find_or(gui, "gameTableMode", 0); @@ -852,6 +898,37 @@ void load(const std::filesystem::path& path) { } } +void sortTomlSections(toml::ordered_value& data) { + toml::ordered_value ordered_data; + std::vector section_order = {"General", "Input", "GPU", "Vulkan", + "Debug", "Keys", "GUI", "Settings"}; + + for (const auto& section : section_order) { + if (data.contains(section)) { + std::vector keys; + for (const auto& item : data.at(section).as_table()) { + keys.push_back(item.first); + } + + std::sort(keys.begin(), keys.end(), [](const std::string& a, const std::string& b) { + return std::lexicographical_compare( + a.begin(), a.end(), b.begin(), b.end(), [](char a_char, char b_char) { + return std::tolower(a_char) < std::tolower(b_char); + }); + }); + + toml::ordered_value ordered_section; + for (const auto& key : keys) { + ordered_section[key] = data.at(section).at(key); + } + + ordered_data[section] = ordered_section; + } + } + + data = ordered_data; +} + void save(const std::filesystem::path& path) { toml::ordered_value data; @@ -875,6 +952,7 @@ void save(const std::filesystem::path& path) { } data["General"]["isPS4Pro"] = isNeo; + data["General"]["isDevKit"] = isDevKit; data["General"]["isTrophyPopupDisabled"] = isTrophyPopupDisabled; data["General"]["trophyNotificationDuration"] = trophyNotificationDuration; data["General"]["playBGM"] = playBGM; @@ -888,8 +966,7 @@ void save(const std::filesystem::path& path) { data["General"]["showSplash"] = isShowSplash; data["General"]["autoUpdate"] = isAutoUpdate; data["General"]["alwaysShowChangelog"] = isAlwaysShowChangelog; - data["General"]["leftSideTrophy"] = isLeftSideTrophy; - data["General"]["separateUpdateEnabled"] = separateupdatefolder; + data["General"]["sideTrophy"] = isSideTrophy; data["General"]["compatibilityEnabled"] = compatibilityData; data["General"]["checkCompatibilityOnStartup"] = checkCompatibilityOnStartup; data["Input"]["cursorState"] = cursorState; @@ -921,14 +998,37 @@ void save(const std::filesystem::path& path) { data["Debug"]["CollectShader"] = isShaderDebug; data["Debug"]["isSeparateLogFilesEnabled"] = isSeparateLogFilesEnabled; data["Debug"]["FPSColor"] = isFpsColor; - data["Keys"]["TrophyKey"] = trophyKey; std::vector install_dirs; - for (const auto& dirString : settings_install_dirs) { - install_dirs.emplace_back(std::string{fmt::UTF(dirString.u8string()).data}); + std::vector install_dirs_enabled; + + // temporary structure for ordering + struct DirEntry { + std::string path_str; + bool enabled; + }; + + std::vector sorted_dirs; + for (const auto& dirInfo : settings_install_dirs) { + sorted_dirs.push_back( + {std::string{fmt::UTF(dirInfo.path.u8string()).data}, dirInfo.enabled}); } + + // Sort directories alphabetically + std::sort(sorted_dirs.begin(), sorted_dirs.end(), [](const DirEntry& a, const DirEntry& b) { + return std::lexicographical_compare( + a.path_str.begin(), a.path_str.end(), b.path_str.begin(), b.path_str.end(), + [](char a_char, char b_char) { return std::tolower(a_char) < std::tolower(b_char); }); + }); + + for (const auto& entry : sorted_dirs) { + install_dirs.push_back(entry.path_str); + install_dirs_enabled.push_back(entry.enabled); + } + data["GUI"]["installDirs"] = install_dirs; + data["GUI"]["installDirsEnabled"] = install_dirs_enabled; data["GUI"]["saveDataPath"] = std::string{fmt::UTF(save_data_path.u8string()).data}; data["GUI"]["loadGameSizeEnabled"] = load_game_size; @@ -939,9 +1039,13 @@ void save(const std::filesystem::path& path) { data["GUI"]["showBackgroundImage"] = showBackgroundImage; data["Settings"]["consoleLanguage"] = m_language; + // Sorting of TOML sections + sortTomlSections(data); + std::ofstream file(path, std::ios::binary); file << data; file.close(); + saveMainWindow(path); } @@ -979,10 +1083,12 @@ void saveMainWindow(const std::filesystem::path& path) { data["GUI"]["geometry_y"] = main_window_geometry_y; data["GUI"]["geometry_w"] = main_window_geometry_w; data["GUI"]["geometry_h"] = main_window_geometry_h; - data["GUI"]["pkgDirs"] = m_pkg_viewer; data["GUI"]["elfDirs"] = m_elf_viewer; data["GUI"]["recentFiles"] = m_recent_files; + // Sorting of TOML sections + sortTomlSections(data); + std::ofstream file(path, std::ios::binary); file << data; file.close(); @@ -991,6 +1097,7 @@ void saveMainWindow(const std::filesystem::path& path) { void setDefaultValues() { isHDRAllowed = false; isNeo = false; + isDevKit = false; isFullscreen = false; isTrophyPopupDisabled = false; playBGM = false; @@ -999,9 +1106,9 @@ void setDefaultValues() { screenWidth = 1280; screenHeight = 720; logFilter = ""; - logType = "async"; + logType = "sync"; userName = "shadPS4"; - if (Common::isRelease) { + if (Common::g_is_release) { updateChannel = "Release"; } else { updateChannel = "Nightly"; @@ -1018,7 +1125,7 @@ void setDefaultValues() { isShowSplash = false; isAutoUpdate = false; isAlwaysShowChangelog = false; - isLeftSideTrophy = false; + isSideTrophy = "right"; isNullGpu = false; shouldDumpShaders = false; vblankDivider = 1; @@ -1032,7 +1139,6 @@ void setDefaultValues() { emulator_language = "en_US"; m_language = 1; gpuId = -1; - separateupdatefolder = false; compatibilityData = false; checkCompatibilityOnStartup = false; backgroundImageOpacity = 50; diff --git a/src/common/config.h b/src/common/config.h index 988734b93..aba23621c 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -9,6 +9,11 @@ namespace Config { +struct GameInstallDir { + std::filesystem::path path; + bool enabled; +}; + enum HideCursorState : s16 { Never, Idle, Always }; void load(const std::filesystem::path& path); @@ -21,13 +26,15 @@ bool GetLoadGameSizeEnabled(); std::filesystem::path GetSaveDataPath(); void setLoadGameSizeEnabled(bool enable); bool getIsFullscreen(); +bool getShowLabelsUnderIcons(); +bool setShowLabelsUnderIcons(); std::string getFullscreenMode(); bool isNeoModeConsole(); +bool isDevKitConsole(); bool getPlayBGM(); int getBGMvolume(); bool getisTrophyPopupDisabled(); bool getEnableDiscordRPC(); -bool getSeparateUpdateEnabled(); bool getCompatibilityEnabled(); bool getCheckCompatibilityOnStartup(); int getBackgroundImageOpacity(); @@ -63,7 +70,7 @@ bool collectShadersForDebug(); bool showSplash(); bool autoUpdate(); bool alwaysShowChangelog(); -bool leftSideTrophy(); +std::string sideTrophy(); bool nullGpu(); bool copyGPUCmdBuffers(); bool dumpShaders(); @@ -77,7 +84,7 @@ void setCollectShaderForDebug(bool enable); void setShowSplash(bool enable); void setAutoUpdate(bool enable); void setAlwaysShowChangelog(bool enable); -void setLeftSideTrophy(bool enable); +void setSideTrophy(std::string side); void setNullGpu(bool enable); void setAllowHDR(bool enable); void setCopyGPUCmdBuffers(bool enable); @@ -97,8 +104,8 @@ void setNeoMode(bool enable); void setUserName(const std::string& type); void setUpdateChannel(const std::string& type); void setChooseHomeTab(const std::string& type); -void setSeparateUpdateEnabled(bool use); -void setGameInstallDirs(const std::vector& settings_install_dirs_config); +void setGameInstallDirs(const std::vector& dirs_config); +void setAllGameInstallDirs(const std::vector& dirs_config); void setSaveDataPath(const std::filesystem::path& path); void setCompatibilityEnabled(bool use); void setCheckCompatibilityOnStartup(bool use); @@ -133,8 +140,9 @@ void setVkGuestMarkersEnabled(bool enable); // Gui void setMainWindowGeometry(u32 x, u32 y, u32 w, u32 h); -bool addGameInstallDir(const std::filesystem::path& dir); +bool addGameInstallDir(const std::filesystem::path& dir, bool enabled = true); void removeGameInstallDir(const std::filesystem::path& dir); +void setGameInstallDirEnabled(const std::filesystem::path& dir, bool enabled); void setAddonInstallDir(const std::filesystem::path& dir); void setMainWindowTheme(u32 theme); void setIconSize(u32 size); @@ -144,7 +152,6 @@ void setSliderPositionGrid(u32 pos); void setTableMode(u32 mode); void setMainWindowWidth(u32 width); void setMainWindowHeight(u32 height); -void setPkgViewer(const std::vector& pkgList); void setElfViewer(const std::vector& elfList); void setRecentFiles(const std::vector& recentFiles); void setEmulatorLanguage(std::string language); @@ -153,7 +160,8 @@ u32 getMainWindowGeometryX(); u32 getMainWindowGeometryY(); u32 getMainWindowGeometryW(); u32 getMainWindowGeometryH(); -const std::vector& getGameInstallDirs(); +const std::vector getGameInstallDirs(); +const std::vector getGameInstallDirsEnabled(); std::filesystem::path getAddonInstallDir(); u32 getMainWindowTheme(); u32 getIconSize(); @@ -163,7 +171,6 @@ u32 getSliderPositionGrid(); u32 getTableMode(); u32 getMainWindowWidth(); u32 getMainWindowHeight(); -std::vector getPkgViewer(); std::vector getElfViewer(); std::vector getRecentFiles(); std::string getEmulatorLanguage(); diff --git a/src/common/elf_info.h b/src/common/elf_info.h index d885709cd..062cee012 100644 --- a/src/common/elf_info.h +++ b/src/common/elf_info.h @@ -3,6 +3,7 @@ #pragma once +#include #include #include @@ -69,6 +70,8 @@ class ElfInfo { u32 raw_firmware_ver = 0; PSFAttributes psf_attributes{}; + std::filesystem::path splash_path{}; + public: static constexpr u32 FW_15 = 0x1500000; static constexpr u32 FW_16 = 0x1600000; @@ -116,6 +119,10 @@ public: ASSERT(initialized); return psf_attributes; } + + [[nodiscard]] const std::filesystem::path& GetSplashPath() const { + return splash_path; + } }; } // namespace Common diff --git a/src/common/io_file.cpp b/src/common/io_file.cpp index 067010a26..3efadc6ea 100644 --- a/src/common/io_file.cpp +++ b/src/common/io_file.cpp @@ -125,12 +125,15 @@ namespace { [[nodiscard]] constexpr int ToSeekOrigin(SeekOrigin origin) { switch (origin) { case SeekOrigin::SetOrigin: - default: return SEEK_SET; case SeekOrigin::CurrentPosition: return SEEK_CUR; case SeekOrigin::End: return SEEK_END; + default: + LOG_ERROR(Common_Filesystem, "Unsupported origin {}, defaulting to SEEK_SET", + static_cast(origin)); + return SEEK_SET; } } @@ -377,20 +380,6 @@ bool IOFile::Seek(s64 offset, SeekOrigin origin) const { return false; } - if (False(file_access_mode & (FileAccessMode::Write | FileAccessMode::Append))) { - u64 size = GetSize(); - if (origin == SeekOrigin::CurrentPosition && Tell() + offset > size) { - LOG_ERROR(Common_Filesystem, "Seeking past the end of the file"); - return false; - } else if (origin == SeekOrigin::SetOrigin && (u64)offset > size) { - LOG_ERROR(Common_Filesystem, "Seeking past the end of the file"); - return false; - } else if (origin == SeekOrigin::End && offset > 0) { - LOG_ERROR(Common_Filesystem, "Seeking past the end of the file"); - return false; - } - } - errno = 0; const auto seek_result = fseeko(file, offset, ToSeekOrigin(origin)) == 0; diff --git a/src/common/io_file.h b/src/common/io_file.h index 45787a092..fb20a2bc5 100644 --- a/src/common/io_file.h +++ b/src/common/io_file.h @@ -61,6 +61,8 @@ enum class SeekOrigin : u32 { SetOrigin, // Seeks from the start of the file. CurrentPosition, // Seeks from the current file pointer position. End, // Seeks from the end of the file. + SeekHole, // Seeks from the start of the next hole in the file. + SeekData, // Seeks from the start of the next non-hole region in the file. }; class IOFile final { diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp index bed7802ed..867d62916 100644 --- a/src/common/logging/filter.cpp +++ b/src/common/logging/filter.cpp @@ -101,6 +101,7 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) { SUB(Lib, Ssl2) \ SUB(Lib, SysModule) \ SUB(Lib, Move) \ + SUB(Lib, NpAuth) \ SUB(Lib, NpCommon) \ SUB(Lib, NpManager) \ SUB(Lib, NpScore) \ diff --git a/src/common/logging/types.h b/src/common/logging/types.h index c07efbc0d..e5714a81a 100644 --- a/src/common/logging/types.h +++ b/src/common/logging/types.h @@ -69,6 +69,7 @@ enum class Class : u8 { Lib_Http2, ///< The LibSceHttp2 implementation. Lib_SysModule, ///< The LibSceSysModule implementation Lib_NpCommon, ///< The LibSceNpCommon implementation + Lib_NpAuth, ///< The LibSceNpAuth implementation Lib_NpManager, ///< The LibSceNpManager implementation Lib_NpScore, ///< The LibSceNpScore implementation Lib_NpTrophy, ///< The LibSceNpTrophy implementation diff --git a/src/common/memory_patcher.cpp b/src/common/memory_patcher.cpp index 2a8b26acb..bb2d23c45 100644 --- a/src/common/memory_patcher.cpp +++ b/src/common/memory_patcher.cpp @@ -169,7 +169,8 @@ void OnGameLoaded() { if (type == "mask_jump32") patchMask = MemoryPatcher::PatchMask::Mask_Jump32; - if (type == "mask" || type == "mask_jump32" && !maskOffsetStr.empty()) { + if ((type == "mask" || type == "mask_jump32") && + !maskOffsetStr.empty()) { maskOffsetValue = std::stoi(maskOffsetStr, 0, 10); } diff --git a/src/common/path_util.cpp b/src/common/path_util.cpp index d48e8c3fe..1a6ff9ec8 100644 --- a/src/common/path_util.cpp +++ b/src/common/path_util.cpp @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include #include #include "common/logging/log.h" #include "common/path_util.h" @@ -16,6 +17,8 @@ #ifdef _WIN32 // This is the maximum number of UTF-16 code units permissible in Windows file paths #define MAX_PATH 260 +#include +#include #else // This is the maximum number of UTF-8 code units permissible in all other OSes' file paths #define MAX_PATH 1024 @@ -57,7 +60,7 @@ static CFURLRef UntranslocateBundlePath(const CFURLRef bundle_path) { return nullptr; } -static std::filesystem::path GetBundleParentDirectory() { +static std::optional GetBundleParentDirectory() { if (CFBundleRef bundle_ref = CFBundleGetMainBundle()) { if (CFURLRef bundle_url_ref = CFBundleCopyBundleURL(bundle_ref)) { SCOPE_EXIT { @@ -80,14 +83,16 @@ static std::filesystem::path GetBundleParentDirectory() { } } } - return std::filesystem::current_path(); + return std::nullopt; } #endif static auto UserPaths = [] { -#ifdef __APPLE__ +#if defined(__APPLE__) && defined(ENABLE_QT_GUI) // Set the current path to the directory containing the app bundle. - std::filesystem::current_path(GetBundleParentDirectory()); + if (const auto bundle_dir = GetBundleParentDirectory()) { + std::filesystem::current_path(*bundle_dir); + } #endif // Try the portable user directory first. @@ -105,6 +110,10 @@ static auto UserPaths = [] { } else { user_dir = std::filesystem::path(getenv("HOME")) / ".local" / "share" / "shadPS4"; } +#elif _WIN32 + TCHAR appdata[MAX_PATH] = {0}; + SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, appdata); + user_dir = std::filesystem::path(appdata) / "shadPS4"; #endif } @@ -130,6 +139,21 @@ static auto UserPaths = [] { create_path(PathType::MetaDataDir, user_dir / METADATA_DIR); create_path(PathType::CustomTrophy, user_dir / CUSTOM_TROPHY); + std::ofstream notice_file(user_dir / CUSTOM_TROPHY / "Notice.txt"); + if (notice_file.is_open()) { + notice_file + << "++++++++++++++++++++++++++++++++\n+ Custom Trophy Images / Sound " + "+\n++++++++++++++++++++++++++++++++\n\nYou can add custom images to the " + "trophies.\n*We recommend a square resolution image, for example 200x200, 500x500, " + "the same size as the height and width.\nIn this folder ('user\\custom_trophy'), " + "add the files with the following " + "names:\n\nbronze.png\nsilver.png\ngold.png\nplatinum.png\n\nYou can add a custom " + "sound for trophy notifications.\n*By default, no audio is played unless it is in " + "this folder and you are using the QT version.\nIn this folder " + "('user\\custom_trophy'), add the files with the following names:\n\ntrophy.mp3"; + notice_file.close(); + } + return paths; }(); @@ -223,4 +247,4 @@ std::filesystem::path PathFromQString(const QString& path) { } #endif -} // namespace Common::FS \ No newline at end of file +} // namespace Common::FS diff --git a/src/common/scm_rev.cpp.in b/src/common/scm_rev.cpp.in index 2de04e0be..71c4c2d0a 100644 --- a/src/common/scm_rev.cpp.in +++ b/src/common/scm_rev.cpp.in @@ -3,21 +3,17 @@ #include "common/scm_rev.h" -#define GIT_REV "@GIT_REV@" -#define GIT_BRANCH "@GIT_BRANCH@" -#define GIT_DESC "@GIT_DESC@" -#define GIT_REMOTE_NAME "@GIT_REMOTE_NAME@" -#define GIT_REMOTE_URL "@GIT_REMOTE_URL@" -#define BUILD_DATE "@BUILD_DATE@" - namespace Common { -const char g_scm_rev[] = GIT_REV; -const char g_scm_branch[] = GIT_BRANCH; -const char g_scm_desc[] = GIT_DESC; -const char g_scm_remote_name[] = GIT_REMOTE_NAME; -const char g_scm_remote_url[] = GIT_REMOTE_URL; -const char g_scm_date[] = BUILD_DATE; +constexpr char g_version[] = "@APP_VERSION@"; +constexpr bool g_is_release = @APP_IS_RELEASE@; + +constexpr char g_scm_rev[] = "@GIT_REV@"; +constexpr char g_scm_branch[] = "@GIT_BRANCH@"; +constexpr char g_scm_desc[] = "@GIT_DESC@"; +constexpr char g_scm_remote_name[] = "@GIT_REMOTE_NAME@"; +constexpr char g_scm_remote_url[] = "@GIT_REMOTE_URL@"; +constexpr char g_scm_date[] = "@BUILD_DATE@"; } // namespace diff --git a/src/common/scm_rev.h b/src/common/scm_rev.h index f38efff42..36b844e94 100644 --- a/src/common/scm_rev.h +++ b/src/common/scm_rev.h @@ -5,6 +5,9 @@ namespace Common { +extern const char g_version[]; +extern const bool g_is_release; + extern const char g_scm_rev[]; extern const char g_scm_branch[]; extern const char g_scm_desc[]; diff --git a/src/common/sha1.h b/src/common/sha1.h new file mode 100644 index 000000000..fad849dcc --- /dev/null +++ b/src/common/sha1.h @@ -0,0 +1,180 @@ +// SPDX-FileCopyrightText: 2012 SAURAV MOHAPATRA +// SPDX-License-Identifier: MIT + +#pragma once + +#include +#include +#include + +namespace sha1 { +class SHA1 { +public: + typedef uint32_t digest32_t[5]; + typedef uint8_t digest8_t[20]; + inline static uint32_t LeftRotate(uint32_t value, size_t count) { + return (value << count) ^ (value >> (32 - count)); + } + SHA1() { + reset(); + } + virtual ~SHA1() {} + SHA1(const SHA1& s) { + *this = s; + } + const SHA1& operator=(const SHA1& s) { + memcpy(m_digest, s.m_digest, 5 * sizeof(uint32_t)); + memcpy(m_block, s.m_block, 64); + m_blockByteIndex = s.m_blockByteIndex; + m_byteCount = s.m_byteCount; + return *this; + } + SHA1& reset() { + m_digest[0] = 0x67452301; + m_digest[1] = 0xEFCDAB89; + m_digest[2] = 0x98BADCFE; + m_digest[3] = 0x10325476; + m_digest[4] = 0xC3D2E1F0; + m_blockByteIndex = 0; + m_byteCount = 0; + return *this; + } + SHA1& processByte(uint8_t octet) { + this->m_block[this->m_blockByteIndex++] = octet; + ++this->m_byteCount; + if (m_blockByteIndex == 64) { + this->m_blockByteIndex = 0; + processBlock(); + } + return *this; + } + SHA1& processBlock(const void* const start, const void* const end) { + const uint8_t* begin = static_cast(start); + const uint8_t* finish = static_cast(end); + while (begin != finish) { + processByte(*begin); + begin++; + } + return *this; + } + SHA1& processBytes(const void* const data, size_t len) { + const uint8_t* block = static_cast(data); + processBlock(block, block + len); + return *this; + } + const uint32_t* getDigest(digest32_t digest) { + size_t bitCount = this->m_byteCount * 8; + processByte(0x80); + if (this->m_blockByteIndex > 56) { + while (m_blockByteIndex != 0) { + processByte(0); + } + while (m_blockByteIndex < 56) { + processByte(0); + } + } else { + while (m_blockByteIndex < 56) { + processByte(0); + } + } + processByte(0); + processByte(0); + processByte(0); + processByte(0); + processByte(static_cast((bitCount >> 24) & 0xFF)); + processByte(static_cast((bitCount >> 16) & 0xFF)); + processByte(static_cast((bitCount >> 8) & 0xFF)); + processByte(static_cast((bitCount) & 0xFF)); + + memcpy(digest, m_digest, 5 * sizeof(uint32_t)); + return digest; + } + const uint8_t* getDigestBytes(digest8_t digest) { + digest32_t d32; + getDigest(d32); + size_t di = 0; + digest[di++] = ((d32[0] >> 24) & 0xFF); + digest[di++] = ((d32[0] >> 16) & 0xFF); + digest[di++] = ((d32[0] >> 8) & 0xFF); + digest[di++] = ((d32[0]) & 0xFF); + + digest[di++] = ((d32[1] >> 24) & 0xFF); + digest[di++] = ((d32[1] >> 16) & 0xFF); + digest[di++] = ((d32[1] >> 8) & 0xFF); + digest[di++] = ((d32[1]) & 0xFF); + + digest[di++] = ((d32[2] >> 24) & 0xFF); + digest[di++] = ((d32[2] >> 16) & 0xFF); + digest[di++] = ((d32[2] >> 8) & 0xFF); + digest[di++] = ((d32[2]) & 0xFF); + + digest[di++] = ((d32[3] >> 24) & 0xFF); + digest[di++] = ((d32[3] >> 16) & 0xFF); + digest[di++] = ((d32[3] >> 8) & 0xFF); + digest[di++] = ((d32[3]) & 0xFF); + + digest[di++] = ((d32[4] >> 24) & 0xFF); + digest[di++] = ((d32[4] >> 16) & 0xFF); + digest[di++] = ((d32[4] >> 8) & 0xFF); + digest[di++] = ((d32[4]) & 0xFF); + return digest; + } + +protected: + void processBlock() { + uint32_t w[80]; + for (size_t i = 0; i < 16; i++) { + w[i] = (m_block[i * 4 + 0] << 24); + w[i] |= (m_block[i * 4 + 1] << 16); + w[i] |= (m_block[i * 4 + 2] << 8); + w[i] |= (m_block[i * 4 + 3]); + } + for (size_t i = 16; i < 80; i++) { + w[i] = LeftRotate((w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16]), 1); + } + + uint32_t a = m_digest[0]; + uint32_t b = m_digest[1]; + uint32_t c = m_digest[2]; + uint32_t d = m_digest[3]; + uint32_t e = m_digest[4]; + + for (std::size_t i = 0; i < 80; ++i) { + uint32_t f = 0; + uint32_t k = 0; + + if (i < 20) { + f = (b & c) | (~b & d); + k = 0x5A827999; + } else if (i < 40) { + f = b ^ c ^ d; + k = 0x6ED9EBA1; + } else if (i < 60) { + f = (b & c) | (b & d) | (c & d); + k = 0x8F1BBCDC; + } else { + f = b ^ c ^ d; + k = 0xCA62C1D6; + } + uint32_t temp = LeftRotate(a, 5) + f + e + k + w[i]; + e = d; + d = c; + c = LeftRotate(b, 30); + b = a; + a = temp; + } + + m_digest[0] += a; + m_digest[1] += b; + m_digest[2] += c; + m_digest[3] += d; + m_digest[4] += e; + } + +private: + digest32_t m_digest; + uint8_t m_block[64]; + size_t m_blockByteIndex; + size_t m_byteCount; +}; +} // namespace sha1 diff --git a/src/common/string_literal.h b/src/common/string_literal.h new file mode 100644 index 000000000..9f64f62bd --- /dev/null +++ b/src/common/string_literal.h @@ -0,0 +1,15 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +template +struct StringLiteral { + static constexpr size_t len = N; + + constexpr StringLiteral(const C (&str)[N]) { + std::copy_n(str, N, value); + } + + C value[N]{}; +}; diff --git a/src/common/version.h b/src/common/version.h deleted file mode 100644 index e7f6cc817..000000000 --- a/src/common/version.h +++ /dev/null @@ -1,14 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include -#include - -namespace Common { - -constexpr char VERSION[] = "0.6.1 WIP"; -constexpr bool isRelease = false; - -} // namespace Common diff --git a/src/core/cpu_patches.cpp b/src/core/cpu_patches.cpp index 21acf1a7b..c8106b270 100644 --- a/src/core/cpu_patches.cpp +++ b/src/core/cpu_patches.cpp @@ -22,10 +22,6 @@ #include #else #include -#ifdef __APPLE__ -#include -#include -#endif #endif using namespace Xbyak::util; @@ -81,490 +77,6 @@ static Xbyak::Address ZydisToXbyakMemoryOperand(const ZydisDecodedOperand& opera return ptr[expression]; } -static u64 ZydisToXbyakImmediateOperand(const ZydisDecodedOperand& operand) { - ASSERT_MSG(operand.type == ZYDIS_OPERAND_TYPE_IMMEDIATE, - "Expected immediate operand, got type: {}", static_cast(operand.type)); - return operand.imm.value.u; -} - -static std::unique_ptr ZydisToXbyakOperand(const ZydisDecodedOperand& operand) { - switch (operand.type) { - case ZYDIS_OPERAND_TYPE_REGISTER: { - return std::make_unique(ZydisToXbyakRegisterOperand(operand)); - } - case ZYDIS_OPERAND_TYPE_MEMORY: { - return std::make_unique(ZydisToXbyakMemoryOperand(operand)); - } - default: - UNREACHABLE_MSG("Unsupported operand type: {}", static_cast(operand.type)); - } -} - -static bool OperandUsesRegister(const Xbyak::Operand* operand, int index) { - if (operand->isREG()) { - return operand->getIdx() == index; - } - if (operand->isMEM()) { - const Xbyak::RegExp& reg_exp = operand->getAddress().getRegExp(); - return reg_exp.getBase().getIdx() == index || reg_exp.getIndex().getIdx() == index; - } - UNREACHABLE_MSG("Unsupported operand kind: {}", static_cast(operand->getKind())); -} - -static bool IsRegisterAllocated( - const std::initializer_list& allocated_registers, const int index) { - return std::ranges::find_if(allocated_registers.begin(), allocated_registers.end(), - [index](const Xbyak::Operand* operand) { - return OperandUsesRegister(operand, index); - }) != allocated_registers.end(); -} - -static Xbyak::Reg AllocateScratchRegister( - const std::initializer_list allocated_registers, const u32 bits) { - for (int index = Xbyak::Operand::R8; index <= Xbyak::Operand::R15; index++) { - if (!IsRegisterAllocated(allocated_registers, index)) { - return Xbyak::Reg32e(index, static_cast(bits)); - } - } - UNREACHABLE_MSG("Out of scratch registers!"); -} - -#ifdef __APPLE__ - -static pthread_key_t stack_pointer_slot; -static pthread_key_t patch_stack_slot; -static std::once_flag patch_context_slots_init_flag; -static constexpr u32 patch_stack_size = 0x1000; - -static_assert(sizeof(void*) == sizeof(u64), - "Cannot fit a register inside a thread local storage slot."); - -static void FreePatchStack(void* patch_stack) { - // Subtract back to the bottom of the stack for free. - std::free(static_cast(patch_stack) - patch_stack_size); -} - -static void InitializePatchContextSlots() { - ASSERT_MSG(pthread_key_create(&stack_pointer_slot, nullptr) == 0, - "Unable to allocate thread-local register for stack pointer."); - ASSERT_MSG(pthread_key_create(&patch_stack_slot, FreePatchStack) == 0, - "Unable to allocate thread-local register for patch stack."); -} - -void InitializeThreadPatchStack() { - std::call_once(patch_context_slots_init_flag, InitializePatchContextSlots); - - pthread_setspecific(patch_stack_slot, - static_cast(std::malloc(patch_stack_size)) + patch_stack_size); -} - -/// Saves the stack pointer to thread local storage and loads the patch stack. -static void SaveStack(Xbyak::CodeGenerator& c) { - std::call_once(patch_context_slots_init_flag, InitializePatchContextSlots); - - // Save original stack pointer and load patch stack. - c.putSeg(gs); - c.mov(qword[reinterpret_cast(stack_pointer_slot * sizeof(void*))], rsp); - c.putSeg(gs); - c.mov(rsp, qword[reinterpret_cast(patch_stack_slot * sizeof(void*))]); -} - -/// Restores the stack pointer from thread local storage. -static void RestoreStack(Xbyak::CodeGenerator& c) { - std::call_once(patch_context_slots_init_flag, InitializePatchContextSlots); - - // Save patch stack pointer and load original stack. - c.putSeg(gs); - c.mov(qword[reinterpret_cast(patch_stack_slot * sizeof(void*))], rsp); - c.putSeg(gs); - c.mov(rsp, qword[reinterpret_cast(stack_pointer_slot * sizeof(void*))]); -} - -#else - -// These utilities are not implemented as we can't save anything to thread local storage without -// temporary registers. -void InitializeThreadPatchStack() { - // No-op -} - -/// Saves the stack pointer to thread local storage and loads the patch stack. -static void SaveStack(Xbyak::CodeGenerator& c) { - UNIMPLEMENTED(); -} - -/// Restores the stack pointer from thread local storage. -static void RestoreStack(Xbyak::CodeGenerator& c) { - UNIMPLEMENTED(); -} - -#endif - -/// Switches to the patch stack, saves registers, and restores the original stack. -static void SaveRegisters(Xbyak::CodeGenerator& c, const std::initializer_list regs) { - SaveStack(c); - for (const auto& reg : regs) { - c.push(reg.cvt64()); - } - RestoreStack(c); -} - -/// Switches to the patch stack, restores registers, and restores the original stack. -static void RestoreRegisters(Xbyak::CodeGenerator& c, - const std::initializer_list regs) { - SaveStack(c); - for (const auto& reg : regs) { - c.pop(reg.cvt64()); - } - RestoreStack(c); -} - -/// Switches to the patch stack and stores all registers. -static void SaveContext(Xbyak::CodeGenerator& c, bool save_flags = false) { - SaveStack(c); - for (int reg = Xbyak::Operand::RAX; reg <= Xbyak::Operand::R15; reg++) { - c.push(Xbyak::Reg64(reg)); - } - c.lea(rsp, ptr[rsp - 32 * 16]); - for (int reg = 0; reg <= 15; reg++) { - c.vmovdqu(ptr[rsp + 32 * reg], Xbyak::Ymm(reg)); - } - if (save_flags) { - c.pushfq(); - } -} - -/// Restores all registers and restores the original stack. -/// If the destination is a register, it is not restored to preserve the output. -static void RestoreContext(Xbyak::CodeGenerator& c, const Xbyak::Operand& dst, - bool restore_flags = false) { - if (restore_flags) { - c.popfq(); - } - for (int reg = 15; reg >= 0; reg--) { - if ((!dst.isXMM() && !dst.isYMM()) || dst.getIdx() != reg) { - c.vmovdqu(Xbyak::Ymm(reg), ptr[rsp + 32 * reg]); - } - } - c.lea(rsp, ptr[rsp + 32 * 16]); - for (int reg = Xbyak::Operand::R15; reg >= Xbyak::Operand::RAX; reg--) { - if (!dst.isREG() || dst.getIdx() != reg) { - c.pop(Xbyak::Reg64(reg)); - } else { - c.lea(rsp, ptr[rsp + 8]); - } - } - RestoreStack(c); -} - -#ifdef __APPLE__ - -static void GenerateANDN(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) { - const auto dst = ZydisToXbyakRegisterOperand(operands[0]); - const auto src1 = ZydisToXbyakRegisterOperand(operands[1]); - const auto src2 = ZydisToXbyakOperand(operands[2]); - - // Check if src2 is a memory operand or a register different to dst. - // In those cases, we don't need to use a temporary register and are free to modify dst. - // In cases where dst and src2 are the same register, a temporary needs to be used to avoid - // modifying src2. - bool src2_uses_dst = false; - if (src2->isMEM()) { - const auto base = src2->getAddress().getRegExp().getBase().getIdx(); - const auto index = src2->getAddress().getRegExp().getIndex().getIdx(); - src2_uses_dst = base == dst.getIdx() || index == dst.getIdx(); - } else { - ASSERT(src2->isREG()); - src2_uses_dst = src2->getReg() == dst; - } - - if (!src2_uses_dst) { - if (dst != src1) - c.mov(dst, src1); - c.not_(dst); - c.and_(dst, *src2); - } else { - const auto scratch = AllocateScratchRegister({&dst, &src1, src2.get()}, dst.getBit()); - - SaveRegisters(c, {scratch}); - - c.mov(scratch, src1); - c.not_(scratch); - c.and_(scratch, *src2); - c.mov(dst, scratch); - - RestoreRegisters(c, {scratch}); - } -} - -static void GenerateBEXTR(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) { - const auto dst = ZydisToXbyakRegisterOperand(operands[0]); - const auto src = ZydisToXbyakOperand(operands[1]); - const auto start_len = ZydisToXbyakRegisterOperand(operands[2]); - - const Xbyak::Reg32e shift(Xbyak::Operand::RCX, static_cast(start_len.getBit())); - const auto scratch1 = - AllocateScratchRegister({&dst, src.get(), &start_len, &shift}, dst.getBit()); - const auto scratch2 = - AllocateScratchRegister({&dst, src.get(), &start_len, &shift, &scratch1}, dst.getBit()); - - if (dst.getIdx() == shift.getIdx()) { - SaveRegisters(c, {scratch1, scratch2}); - } else { - SaveRegisters(c, {scratch1, scratch2, shift}); - } - - c.mov(scratch1, *src); - if (shift.getIdx() != start_len.getIdx()) { - c.mov(shift, start_len); - } - - c.shr(scratch1, shift.cvt8()); - c.shr(shift, 8); - c.mov(scratch2, 1); - c.shl(scratch2, shift.cvt8()); - c.dec(scratch2); - - c.mov(dst, scratch1); - c.and_(dst, scratch2); - - if (dst.getIdx() == shift.getIdx()) { - RestoreRegisters(c, {scratch2, scratch1}); - } else { - RestoreRegisters(c, {shift, scratch2, scratch1}); - } -} - -static void GenerateBLSI(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) { - const auto dst = ZydisToXbyakRegisterOperand(operands[0]); - const auto src = ZydisToXbyakOperand(operands[1]); - - const auto scratch = AllocateScratchRegister({&dst, src.get()}, dst.getBit()); - - SaveRegisters(c, {scratch}); - - // BLSI sets CF to zero if source is zero, otherwise it sets CF to one. - Xbyak::Label clear_carry, end; - - c.mov(scratch, *src); - c.neg(scratch); // NEG, like BLSI, clears CF if the source is zero and sets it otherwise - c.jnc(clear_carry); - - c.and_(scratch, *src); - c.stc(); // setting/clearing carry needs to happen after the AND because that clears CF - c.jmp(end); - - c.L(clear_carry); - c.and_(scratch, *src); - // We don't need to clear carry here since AND does that for us - - c.L(end); - c.mov(dst, scratch); - - RestoreRegisters(c, {scratch}); -} - -static void GenerateBLSMSK(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) { - const auto dst = ZydisToXbyakRegisterOperand(operands[0]); - const auto src = ZydisToXbyakOperand(operands[1]); - - const auto scratch = AllocateScratchRegister({&dst, src.get()}, dst.getBit()); - - SaveRegisters(c, {scratch}); - - Xbyak::Label clear_carry, end; - - // BLSMSK sets CF to zero if source is NOT zero, otherwise it sets CF to one. - c.mov(scratch, *src); - c.test(scratch, scratch); - c.jnz(clear_carry); - - c.dec(scratch); - c.xor_(scratch, *src); - c.stc(); - c.jmp(end); - - c.L(clear_carry); - c.dec(scratch); - c.xor_(scratch, *src); - // We don't need to clear carry here since XOR does that for us - - c.L(end); - c.mov(dst, scratch); - - RestoreRegisters(c, {scratch}); -} - -static void GenerateBLSR(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) { - const auto dst = ZydisToXbyakRegisterOperand(operands[0]); - const auto src = ZydisToXbyakOperand(operands[1]); - - const auto scratch = AllocateScratchRegister({&dst, src.get()}, dst.getBit()); - - SaveRegisters(c, {scratch}); - - Xbyak::Label clear_carry, end; - - // BLSR sets CF to zero if source is NOT zero, otherwise it sets CF to one. - c.mov(scratch, *src); - c.test(scratch, scratch); - c.jnz(clear_carry); - - c.dec(scratch); - c.and_(scratch, *src); - c.stc(); - c.jmp(end); - - c.L(clear_carry); - c.dec(scratch); - c.and_(scratch, *src); - // We don't need to clear carry here since AND does that for us - - c.L(end); - c.mov(dst, scratch); - - RestoreRegisters(c, {scratch}); -} - -static __attribute__((sysv_abi)) void PerformVCVTPH2PS(float* out, const half_float::half* in, - const u32 count) { - for (u32 i = 0; i < count; i++) { - out[i] = half_float::half_cast(in[i]); - } -} - -static void GenerateVCVTPH2PS(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) { - const auto dst = ZydisToXbyakRegisterOperand(operands[0]); - const auto src = ZydisToXbyakOperand(operands[1]); - - const auto float_count = dst.getBit() / 32; - const auto byte_count = float_count * 4; - - SaveContext(c, true); - - // Allocate stack space for outputs and load into first parameter. - c.sub(rsp, byte_count); - c.mov(rdi, rsp); - - if (src->isXMM()) { - // Allocate stack space for inputs and load into second parameter. - c.sub(rsp, byte_count); - c.mov(rsi, rsp); - - // Move input to the allocated space. - c.movdqu(ptr[rsp], *reinterpret_cast(src.get())); - } else { - c.lea(rsi, src->getAddress()); - } - - // Load float count into third parameter. - c.mov(rdx, float_count); - - c.mov(rax, reinterpret_cast(PerformVCVTPH2PS)); - c.call(rax); - - if (src->isXMM()) { - // Clean up after inputs space. - c.add(rsp, byte_count); - } - - // Load outputs into destination register and clean up space. - if (dst.isYMM()) { - c.vmovdqu(*reinterpret_cast(&dst), ptr[rsp]); - } else { - c.movdqu(*reinterpret_cast(&dst), ptr[rsp]); - } - c.add(rsp, byte_count); - - RestoreContext(c, dst, true); -} - -using SingleToHalfFloatConverter = half_float::half (*)(float); -static const SingleToHalfFloatConverter SingleToHalfFloatConverters[4] = { - half_float::half_cast, - half_float::half_cast, - half_float::half_cast, - half_float::half_cast, -}; - -static __attribute__((sysv_abi)) void PerformVCVTPS2PH(half_float::half* out, const float* in, - const u32 count, const u8 rounding_mode) { - const auto conversion_func = SingleToHalfFloatConverters[rounding_mode]; - - for (u32 i = 0; i < count; i++) { - out[i] = conversion_func(in[i]); - } -} - -static void GenerateVCVTPS2PH(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) { - const auto dst = ZydisToXbyakOperand(operands[0]); - const auto src = ZydisToXbyakRegisterOperand(operands[1]); - const auto ctrl = ZydisToXbyakImmediateOperand(operands[2]); - - const auto float_count = src.getBit() / 32; - const auto byte_count = float_count * 4; - - SaveContext(c, true); - - if (dst->isXMM()) { - // Allocate stack space for outputs and load into first parameter. - c.sub(rsp, byte_count); - c.mov(rdi, rsp); - } else { - c.lea(rdi, dst->getAddress()); - } - - // Allocate stack space for inputs and load into second parameter. - c.sub(rsp, byte_count); - c.mov(rsi, rsp); - - // Move input to the allocated space. - if (src.isYMM()) { - c.vmovdqu(ptr[rsp], *reinterpret_cast(&src)); - } else { - c.movdqu(ptr[rsp], *reinterpret_cast(&src)); - } - - // Load float count into third parameter. - c.mov(rdx, float_count); - - // Load rounding mode into fourth parameter. - if (ctrl & 4) { - // Load from MXCSR.RC. - c.stmxcsr(ptr[rsp - 4]); - c.mov(rcx, ptr[rsp - 4]); - c.shr(rcx, 13); - c.and_(rcx, 3); - } else { - c.mov(rcx, ctrl & 3); - } - - c.mov(rax, reinterpret_cast(PerformVCVTPS2PH)); - c.call(rax); - - // Clean up after inputs space. - c.add(rsp, byte_count); - - if (dst->isXMM()) { - // Load outputs into destination register and clean up space. - c.movdqu(*reinterpret_cast(dst.get()), ptr[rsp]); - c.add(rsp, byte_count); - } - - RestoreContext(c, *dst, true); -} - -static bool FilterRosetta2Only(const ZydisDecodedOperand*) { - int ret = 0; - size_t size = sizeof(ret); - if (sysctlbyname("sysctl.proc_translated", &ret, &size, nullptr, 0) != 0) { - return false; - } - return ret; -} - -#else // __APPLE__ - static bool FilterTcbAccess(const ZydisDecodedOperand* operands) { const auto& dst_op = operands[0]; const auto& src_op = operands[1]; @@ -609,8 +121,6 @@ static void GenerateTcbAccess(const ZydisDecodedOperand* operands, Xbyak::CodeGe #endif } -#endif // __APPLE__ - static bool FilterNoSSE4a(const ZydisDecodedOperand*) { Cpu cpu; return !cpu.has(Cpu::tSSE4a); @@ -887,28 +397,16 @@ struct PatchInfo { }; static const std::unordered_map Patches = { + // SSE4a + {ZYDIS_MNEMONIC_EXTRQ, {FilterNoSSE4a, GenerateEXTRQ, true}}, + {ZYDIS_MNEMONIC_INSERTQ, {FilterNoSSE4a, GenerateINSERTQ, true}}, + #if defined(_WIN32) // Windows needs a trampoline. {ZYDIS_MNEMONIC_MOV, {FilterTcbAccess, GenerateTcbAccess, true}}, #elif !defined(__APPLE__) {ZYDIS_MNEMONIC_MOV, {FilterTcbAccess, GenerateTcbAccess, false}}, #endif - - {ZYDIS_MNEMONIC_EXTRQ, {FilterNoSSE4a, GenerateEXTRQ, true}}, - {ZYDIS_MNEMONIC_INSERTQ, {FilterNoSSE4a, GenerateINSERTQ, true}}, - -#ifdef __APPLE__ - // Patches for instruction sets not supported by Rosetta 2. - // BMI1 - {ZYDIS_MNEMONIC_ANDN, {FilterRosetta2Only, GenerateANDN, true}}, - {ZYDIS_MNEMONIC_BEXTR, {FilterRosetta2Only, GenerateBEXTR, true}}, - {ZYDIS_MNEMONIC_BLSI, {FilterRosetta2Only, GenerateBLSI, true}}, - {ZYDIS_MNEMONIC_BLSMSK, {FilterRosetta2Only, GenerateBLSMSK, true}}, - {ZYDIS_MNEMONIC_BLSR, {FilterRosetta2Only, GenerateBLSR, true}}, - // F16C - {ZYDIS_MNEMONIC_VCVTPH2PS, {FilterRosetta2Only, GenerateVCVTPH2PS, true}}, - {ZYDIS_MNEMONIC_VCVTPS2PH, {FilterRosetta2Only, GenerateVCVTPS2PH, true}}, -#endif }; static std::once_flag init_flag; @@ -1225,18 +723,7 @@ void RegisterPatchModule(void* module_ptr, u64 module_size, void* trampoline_are } void PrePatchInstructions(u64 segment_addr, u64 segment_size) { -#if defined(__APPLE__) - // HACK: For some reason patching in the signal handler at the start of a page does not work - // under Rosetta 2. Patch any instructions at the start of a page ahead of time. - if (!Patches.empty()) { - auto* code_page = reinterpret_cast(Common::AlignUp(segment_addr, 0x1000)); - const auto* end_page = code_page + Common::AlignUp(segment_size, 0x1000); - while (code_page < end_page) { - TryPatchJit(code_page); - code_page += 0x1000; - } - } -#elif !defined(_WIN32) +#if !defined(_WIN32) && !defined(__APPLE__) // Linux and others have an FS segment pointing to valid memory, so continue to do full // ahead-of-time patching for now until a better solution is worked out. if (!Patches.empty()) { diff --git a/src/core/cpu_patches.h b/src/core/cpu_patches.h index 1ccac073a..7a0546046 100644 --- a/src/core/cpu_patches.h +++ b/src/core/cpu_patches.h @@ -7,12 +7,6 @@ namespace Core { -/// Initializes a stack for the current thread for use by patch implementations. -void InitializeThreadPatchStack(); - -/// Cleans up the patch stack for the current thread. -void CleanupThreadPatchStack(); - /// Registers a module for patching, providing an area to generate trampoline code. void RegisterPatchModule(void* module_ptr, u64 module_size, void* trampoline_area_ptr, u64 trampoline_area_size); diff --git a/src/core/crypto/crypto.cpp b/src/core/crypto/crypto.cpp deleted file mode 100644 index 4020edfd8..000000000 --- a/src/core/crypto/crypto.cpp +++ /dev/null @@ -1,215 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include - -#include "crypto.h" - -CryptoPP::RSA::PrivateKey Crypto::key_pkg_derived_key3_keyset_init() { - CryptoPP::InvertibleRSAFunction params; - params.SetPrime1(CryptoPP::Integer(PkgDerivedKey3Keyset::Prime1, 0x80)); - params.SetPrime2(CryptoPP::Integer(PkgDerivedKey3Keyset::Prime2, 0x80)); - - params.SetPublicExponent(CryptoPP::Integer(PkgDerivedKey3Keyset::PublicExponent, 4)); - params.SetPrivateExponent(CryptoPP::Integer(PkgDerivedKey3Keyset::PrivateExponent, 0x100)); - - params.SetModPrime1PrivateExponent(CryptoPP::Integer(PkgDerivedKey3Keyset::Exponent1, 0x80)); - params.SetModPrime2PrivateExponent(CryptoPP::Integer(PkgDerivedKey3Keyset::Exponent2, 0x80)); - - params.SetModulus(CryptoPP::Integer(PkgDerivedKey3Keyset::Modulus, 0x100)); - params.SetMultiplicativeInverseOfPrime2ModPrime1( - CryptoPP::Integer(PkgDerivedKey3Keyset::Coefficient, 0x80)); - - CryptoPP::RSA::PrivateKey privateKey(params); - - return privateKey; -} - -CryptoPP::RSA::PrivateKey Crypto::FakeKeyset_keyset_init() { - CryptoPP::InvertibleRSAFunction params; - params.SetPrime1(CryptoPP::Integer(FakeKeyset::Prime1, 0x80)); - params.SetPrime2(CryptoPP::Integer(FakeKeyset::Prime2, 0x80)); - - params.SetPublicExponent(CryptoPP::Integer(FakeKeyset::PublicExponent, 4)); - params.SetPrivateExponent(CryptoPP::Integer(FakeKeyset::PrivateExponent, 0x100)); - - params.SetModPrime1PrivateExponent(CryptoPP::Integer(FakeKeyset::Exponent1, 0x80)); - params.SetModPrime2PrivateExponent(CryptoPP::Integer(FakeKeyset::Exponent2, 0x80)); - - params.SetModulus(CryptoPP::Integer(FakeKeyset::Modulus, 0x100)); - params.SetMultiplicativeInverseOfPrime2ModPrime1( - CryptoPP::Integer(FakeKeyset::Coefficient, 0x80)); - - CryptoPP::RSA::PrivateKey privateKey(params); - - return privateKey; -} - -CryptoPP::RSA::PrivateKey Crypto::DebugRifKeyset_init() { - CryptoPP::InvertibleRSAFunction params; - params.SetPrime1(CryptoPP::Integer(DebugRifKeyset::Prime1, sizeof(DebugRifKeyset::Prime1))); - params.SetPrime2(CryptoPP::Integer(DebugRifKeyset::Prime2, sizeof(DebugRifKeyset::Prime2))); - - params.SetPublicExponent( - CryptoPP::Integer(DebugRifKeyset::PublicExponent, sizeof(DebugRifKeyset::PublicExponent))); - params.SetPrivateExponent(CryptoPP::Integer(DebugRifKeyset::PrivateExponent, - sizeof(DebugRifKeyset::PrivateExponent))); - - params.SetModPrime1PrivateExponent( - CryptoPP::Integer(DebugRifKeyset::Exponent1, sizeof(DebugRifKeyset::Exponent1))); - params.SetModPrime2PrivateExponent( - CryptoPP::Integer(DebugRifKeyset::Exponent2, sizeof(DebugRifKeyset::Exponent2))); - - params.SetModulus(CryptoPP::Integer(DebugRifKeyset::Modulus, sizeof(DebugRifKeyset::Modulus))); - params.SetMultiplicativeInverseOfPrime2ModPrime1( - CryptoPP::Integer(DebugRifKeyset::Coefficient, sizeof(DebugRifKeyset::Coefficient))); - - CryptoPP::RSA::PrivateKey privateKey(params); - - return privateKey; -} - -void Crypto::RSA2048Decrypt(std::span dec_key, - std::span ciphertext, - bool is_dk3) { // RSAES_PKCS1v15_ - // Create an RSA decryptor - CryptoPP::RSA::PrivateKey privateKey; - if (is_dk3) { - privateKey = key_pkg_derived_key3_keyset_init(); - } else { - privateKey = FakeKeyset_keyset_init(); - } - - CryptoPP::RSAES_PKCS1v15_Decryptor rsaDecryptor(privateKey); - - // Allocate memory for the decrypted data - std::array decrypted; - - // Perform the decryption - CryptoPP::AutoSeededRandomPool rng; - CryptoPP::DecodingResult result = - rsaDecryptor.Decrypt(rng, ciphertext.data(), decrypted.size(), decrypted.data()); - std::copy(decrypted.begin(), decrypted.begin() + dec_key.size(), dec_key.begin()); -} - -void Crypto::ivKeyHASH256(std::span cipher_input, - std::span ivkey_result) { - CryptoPP::SHA256 sha256; - std::array hashResult; - auto array_sink = new CryptoPP::ArraySink(hashResult.data(), CryptoPP::SHA256::DIGESTSIZE); - auto filter = new CryptoPP::HashFilter(sha256, array_sink); - CryptoPP::ArraySource r(cipher_input.data(), cipher_input.size(), true, filter); - std::copy(hashResult.begin(), hashResult.begin() + ivkey_result.size(), ivkey_result.begin()); -} - -void Crypto::aesCbcCfb128Decrypt(std::span ivkey, - std::span ciphertext, - std::span decrypted) { - std::array key; - std::array iv; - - std::copy(ivkey.begin() + 16, ivkey.begin() + 16 + key.size(), key.begin()); - std::copy(ivkey.begin(), ivkey.begin() + iv.size(), iv.begin()); - - CryptoPP::AES::Decryption aesDecryption(key.data(), CryptoPP::AES::DEFAULT_KEYLENGTH); - CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption(aesDecryption, iv.data()); - - for (size_t i = 0; i < decrypted.size(); i += CryptoPP::AES::BLOCKSIZE) { - cbcDecryption.ProcessData(decrypted.data() + i, ciphertext.data() + i, - CryptoPP::AES::BLOCKSIZE); - } -} - -void Crypto::aesCbcCfb128DecryptEntry(std::span ivkey, - std::span ciphertext, - std::span decrypted) { - std::array key; - std::array iv; - - std::copy(ivkey.begin() + 16, ivkey.begin() + 16 + key.size(), key.begin()); - std::copy(ivkey.begin(), ivkey.begin() + iv.size(), iv.begin()); - - CryptoPP::AES::Decryption aesDecryption(key.data(), CryptoPP::AES::DEFAULT_KEYLENGTH); - CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption(aesDecryption, iv.data()); - - for (size_t i = 0; i < decrypted.size(); i += CryptoPP::AES::BLOCKSIZE) { - cbcDecryption.ProcessData(decrypted.data() + i, ciphertext.data() + i, - CryptoPP::AES::BLOCKSIZE); - } -} - -void Crypto::decryptEFSM(std::span trophyKey, - std::span NPcommID, - std::span efsmIv, std::span ciphertext, - std::span decrypted) { - - // step 1: Encrypt NPcommID - CryptoPP::CBC_Mode::Encryption encrypt; - - std::vector trophyIv(16, 0); - std::vector trpKey(16); - - encrypt.SetKeyWithIV(trophyKey.data(), trophyKey.size(), trophyIv.data()); - encrypt.ProcessData(trpKey.data(), NPcommID.data(), 16); - - // step 2: decrypt efsm. - CryptoPP::CBC_Mode::Decryption decrypt; - decrypt.SetKeyWithIV(trpKey.data(), trpKey.size(), efsmIv.data()); - - for (size_t i = 0; i < decrypted.size(); i += CryptoPP::AES::BLOCKSIZE) { - decrypt.ProcessData(decrypted.data() + i, ciphertext.data() + i, CryptoPP::AES::BLOCKSIZE); - } -} - -void Crypto::PfsGenCryptoKey(std::span ekpfs, - std::span seed, - std::span dataKey, - std::span tweakKey) { - CryptoPP::HMAC hmac(ekpfs.data(), ekpfs.size()); - - CryptoPP::SecByteBlock d(20); // Use Crypto++ SecByteBlock for better memory management - - // Copy the bytes of 'index' to the 'd' array - uint32_t index = 1; - std::memcpy(d, &index, sizeof(uint32_t)); - - // Copy the bytes of 'seed' to the 'd' array starting from index 4 - std::memcpy(d + sizeof(uint32_t), seed.data(), seed.size()); - - // Allocate memory for 'u64' using new - std::vector data_tweak_key(hmac.DigestSize()); - - // Calculate the HMAC - hmac.CalculateDigest(data_tweak_key.data(), d, d.size()); - std::copy(data_tweak_key.begin(), data_tweak_key.begin() + dataKey.size(), tweakKey.begin()); - std::copy(data_tweak_key.begin() + tweakKey.size(), - data_tweak_key.begin() + tweakKey.size() + dataKey.size(), dataKey.begin()); -} - -void Crypto::decryptPFS(std::span dataKey, - std::span tweakKey, std::span src_image, - std::span dst_image, u64 sector) { - // Start at 0x10000 to keep the header when decrypting the whole pfs_image. - for (int i = 0; i < src_image.size(); i += 0x1000) { - const u64 current_sector = sector + (i / 0x1000); - CryptoPP::ECB_Mode::Encryption encrypt(tweakKey.data(), tweakKey.size()); - CryptoPP::ECB_Mode::Decryption decrypt(dataKey.data(), dataKey.size()); - - std::array tweak{}; - std::array encryptedTweak; - std::array xorBuffer; - std::memcpy(tweak.data(), ¤t_sector, sizeof(u64)); - - // Encrypt the tweak for each sector. - encrypt.ProcessData(encryptedTweak.data(), tweak.data(), 16); - - for (int plaintextOffset = 0; plaintextOffset < 0x1000; plaintextOffset += 16) { - xtsXorBlock(xorBuffer.data(), src_image.data() + i + plaintextOffset, - encryptedTweak.data()); // x, c, t - decrypt.ProcessData(xorBuffer.data(), xorBuffer.data(), 16); // x, x - xtsXorBlock(dst_image.data() + i + plaintextOffset, xorBuffer.data(), - encryptedTweak.data()); //(p) c, x , t - xtsMult(encryptedTweak); - } - } -} diff --git a/src/core/crypto/crypto.h b/src/core/crypto/crypto.h deleted file mode 100644 index b5d8104b5..000000000 --- a/src/core/crypto/crypto.h +++ /dev/null @@ -1,63 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "common/types.h" -#include "keys.h" - -class Crypto { -public: - CryptoPP::RSA::PrivateKey key_pkg_derived_key3_keyset_init(); - CryptoPP::RSA::PrivateKey FakeKeyset_keyset_init(); - CryptoPP::RSA::PrivateKey DebugRifKeyset_init(); - - void RSA2048Decrypt(std::span dk3, - std::span ciphertext, - bool is_dk3); // RSAES_PKCS1v15_ - void ivKeyHASH256(std::span cipher_input, - std::span ivkey_result); - void aesCbcCfb128Decrypt(std::span ivkey, - std::span ciphertext, - std::span decrypted); - void aesCbcCfb128DecryptEntry(std::span ivkey, - std::span ciphertext, - std::span decrypted); - void decryptEFSM(std::span trophyKey, - std::span NPcommID, std::span efsmIv, - std::span ciphertext, std::span decrypted); - void PfsGenCryptoKey(std::span ekpfs, - std::span seed, - std::span dataKey, - std::span tweakKey); - void decryptPFS(std::span dataKey, - std::span tweakKey, std::span src_image, - std::span dst_image, u64 sector); - - void xtsXorBlock(CryptoPP::byte* x, const CryptoPP::byte* a, const CryptoPP::byte* b) { - for (int i = 0; i < 16; i++) { - x[i] = a[i] ^ b[i]; - } - } - - void xtsMult(std::span encryptedTweak) { - int feedback = 0; - for (int k = 0; k < encryptedTweak.size(); k++) { - const auto tmp = (encryptedTweak[k] >> 7) & 1; - encryptedTweak[k] = ((encryptedTweak[k] << 1) + feedback) & 0xFF; - feedback = tmp; - } - if (feedback != 0) { - encryptedTweak[0] ^= 0x87; - } - } -}; diff --git a/src/core/crypto/keys.h b/src/core/crypto/keys.h deleted file mode 100644 index 441082481..000000000 --- a/src/core/crypto/keys.h +++ /dev/null @@ -1,305 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once -#include - -class FakeKeyset { -public: - // Constructor - static constexpr CryptoPP::byte Exponent1[] = { - 0x6D, 0x48, 0xE0, 0x54, 0x40, 0x25, 0xC8, 0x41, 0x29, 0x52, 0x42, 0x27, 0xEB, 0xD2, 0xC7, - 0xAB, 0x6B, 0x9C, 0x27, 0x0A, 0xB4, 0x1F, 0x94, 0x4E, 0xFA, 0x42, 0x1D, 0xB7, 0xBC, 0xB9, - 0xAE, 0xBC, 0x04, 0x6F, 0x75, 0x8F, 0x10, 0x5F, 0x89, 0xAC, 0xAB, 0x9C, 0xD2, 0xFA, 0xE6, - 0xA4, 0x13, 0x83, 0x68, 0xD4, 0x56, 0x38, 0xFE, 0xE5, 0x2B, 0x78, 0x44, 0x9C, 0x34, 0xE6, - 0x5A, 0xA0, 0xBE, 0x05, 0x70, 0xAD, 0x15, 0xC3, 0x2D, 0x31, 0xAC, 0x97, 0x5D, 0x88, 0xFC, - 0xC1, 0x62, 0x3D, 0xE2, 0xED, 0x11, 0xDB, 0xB6, 0x9E, 0xFC, 0x5A, 0x5A, 0x03, 0xF6, 0xCF, - 0x08, 0xD4, 0x5D, 0x90, 0xC9, 0x2A, 0xB9, 0x9B, 0xCF, 0xC8, 0x1A, 0x65, 0xF3, 0x5B, 0xE8, - 0x7F, 0xCF, 0xA5, 0xA6, 0x4C, 0x5C, 0x2A, 0x12, 0x0F, 0x92, 0xA5, 0xE3, 0xF0, 0x17, 0x1E, - 0x9A, 0x97, 0x45, 0x86, 0xFD, 0xDB, 0x54, 0x25}; - // exponent2 = d mod (q - 1) - static constexpr CryptoPP::byte Exponent2[] = { - 0x2A, 0x51, 0xCE, 0x02, 0x44, 0x28, 0x50, 0xE8, 0x30, 0x20, 0x7C, 0x9C, 0x55, 0xBF, 0x60, - 0x39, 0xBC, 0xD1, 0xF0, 0xE7, 0x68, 0xF8, 0x08, 0x5B, 0x61, 0x1F, 0xA7, 0xBF, 0xD0, 0xE8, - 0x8B, 0xB5, 0xB1, 0xD5, 0xD9, 0x16, 0xAC, 0x75, 0x0C, 0x6D, 0xF2, 0xE0, 0xB5, 0x97, 0x75, - 0xD2, 0x68, 0x16, 0x1F, 0x00, 0x7D, 0x8B, 0x17, 0xE8, 0x78, 0x48, 0x41, 0x71, 0x2B, 0x18, - 0x96, 0x80, 0x11, 0xDB, 0x68, 0x39, 0x9C, 0xD6, 0xE0, 0x72, 0x42, 0x86, 0xF0, 0x1B, 0x16, - 0x0D, 0x3E, 0x12, 0x94, 0x3D, 0x25, 0xA8, 0xA9, 0x30, 0x9E, 0x54, 0x5A, 0xD6, 0x36, 0x6C, - 0xD6, 0x8C, 0x20, 0x62, 0x8F, 0xA1, 0x6B, 0x1F, 0x7C, 0x6D, 0xB2, 0xB1, 0xC1, 0x2E, 0xAD, - 0x36, 0x02, 0x9C, 0x3A, 0xCA, 0x2F, 0x09, 0xD2, 0x45, 0x9E, 0xEB, 0xF2, 0xBC, 0x6C, 0xAA, - 0x3B, 0x3E, 0x90, 0xBC, 0x38, 0x67, 0x35, 0x4D}; - // e - static constexpr CryptoPP::byte PublicExponent[] = {0, 1, 0, 1}; - // (InverseQ)(q) = 1 mod p - static constexpr CryptoPP::byte Coefficient[] = { - 0x0B, 0x67, 0x1C, 0x0D, 0x6C, 0x57, 0xD3, 0xE7, 0x05, 0x65, 0x94, 0x31, 0x56, 0x55, 0xFD, - 0x28, 0x08, 0xFA, 0x05, 0x8A, 0xCC, 0x55, 0x39, 0x61, 0x97, 0x63, 0xA0, 0x16, 0x27, 0x3D, - 0xED, 0xC1, 0x16, 0x40, 0x2A, 0x12, 0xEA, 0x6F, 0xD9, 0xD8, 0x58, 0x56, 0xA8, 0x56, 0x8B, - 0x0D, 0x38, 0x5E, 0x1E, 0x80, 0x3B, 0x5F, 0x40, 0x80, 0x6F, 0x62, 0x4F, 0x28, 0xA2, 0x69, - 0xF3, 0xD3, 0xF7, 0xFD, 0xB2, 0xC3, 0x52, 0x43, 0x20, 0x92, 0x9D, 0x97, 0x8D, 0xA0, 0x15, - 0x07, 0x15, 0x6E, 0xA4, 0x0D, 0x56, 0xD3, 0x37, 0x1A, 0xC4, 0x9E, 0xDF, 0x02, 0x49, 0xB8, - 0x0A, 0x84, 0x62, 0xF5, 0xFA, 0xB9, 0x3F, 0xA4, 0x09, 0x76, 0xCC, 0xAA, 0xB9, 0x9B, 0xA6, - 0x4F, 0xC1, 0x6A, 0x64, 0xCE, 0xD8, 0x77, 0xAB, 0x4B, 0xF9, 0xA0, 0xAE, 0xDA, 0xF1, 0x67, - 0x87, 0x7C, 0x98, 0x5C, 0x7E, 0xB8, 0x73, 0xF5}; - // n = p * q - static constexpr CryptoPP::byte Modulus[] = { - 0xC6, 0xCF, 0x71, 0xE7, 0xE5, 0x9A, 0xF0, 0xD1, 0x2A, 0x2C, 0x45, 0x8B, 0xF9, 0x2A, 0x0E, - 0xC1, 0x43, 0x05, 0x8B, 0xC3, 0x71, 0x17, 0x80, 0x1D, 0xCD, 0x49, 0x7D, 0xDE, 0x35, 0x9D, - 0x25, 0x9B, 0xA0, 0xD7, 0xA0, 0xF2, 0x7D, 0x6C, 0x08, 0x7E, 0xAA, 0x55, 0x02, 0x68, 0x2B, - 0x23, 0xC6, 0x44, 0xB8, 0x44, 0x18, 0xEB, 0x56, 0xCF, 0x16, 0xA2, 0x48, 0x03, 0xC9, 0xE7, - 0x4F, 0x87, 0xEB, 0x3D, 0x30, 0xC3, 0x15, 0x88, 0xBF, 0x20, 0xE7, 0x9D, 0xFF, 0x77, 0x0C, - 0xDE, 0x1D, 0x24, 0x1E, 0x63, 0xA9, 0x4F, 0x8A, 0xBF, 0x5B, 0xBE, 0x60, 0x19, 0x68, 0x33, - 0x3B, 0xFC, 0xED, 0x9F, 0x47, 0x4E, 0x5F, 0xF8, 0xEA, 0xCB, 0x3D, 0x00, 0xBD, 0x67, 0x01, - 0xF9, 0x2C, 0x6D, 0xC6, 0xAC, 0x13, 0x64, 0xE7, 0x67, 0x14, 0xF3, 0xDC, 0x52, 0x69, 0x6A, - 0xB9, 0x83, 0x2C, 0x42, 0x30, 0x13, 0x1B, 0xB2, 0xD8, 0xA5, 0x02, 0x0D, 0x79, 0xED, 0x96, - 0xB1, 0x0D, 0xF8, 0xCC, 0x0C, 0xDF, 0x81, 0x95, 0x4F, 0x03, 0x58, 0x09, 0x57, 0x0E, 0x80, - 0x69, 0x2E, 0xFE, 0xFF, 0x52, 0x77, 0xEA, 0x75, 0x28, 0xA8, 0xFB, 0xC9, 0xBE, 0xBF, 0x9F, - 0xBB, 0xB7, 0x79, 0x8E, 0x18, 0x05, 0xE1, 0x80, 0xBD, 0x50, 0x34, 0x94, 0x81, 0xD3, 0x53, - 0xC2, 0x69, 0xA2, 0xD2, 0x4C, 0xCF, 0x6C, 0xF4, 0x57, 0x2C, 0x10, 0x4A, 0x3F, 0xFB, 0x22, - 0xFD, 0x8B, 0x97, 0xE2, 0xC9, 0x5B, 0xA6, 0x2B, 0xCD, 0xD6, 0x1B, 0x6B, 0xDB, 0x68, 0x7F, - 0x4B, 0xC2, 0xA0, 0x50, 0x34, 0xC0, 0x05, 0xE5, 0x8D, 0xEF, 0x24, 0x67, 0xFF, 0x93, 0x40, - 0xCF, 0x2D, 0x62, 0xA2, 0xA0, 0x50, 0xB1, 0xF1, 0x3A, 0xA8, 0x3D, 0xFD, 0x80, 0xD1, 0xF9, - 0xB8, 0x05, 0x22, 0xAF, 0xC8, 0x35, 0x45, 0x90, 0x58, 0x8E, 0xE3, 0x3A, 0x7C, 0xBD, 0x3E, - 0x27}; - // p - static constexpr CryptoPP::byte Prime1[] = { - 0xFE, 0xF6, 0xBF, 0x1D, 0x69, 0xAB, 0x16, 0x25, 0x08, 0x47, 0x55, 0x6B, 0x86, 0xE4, 0x35, - 0x88, 0x72, 0x2A, 0xB1, 0x3D, 0xF8, 0xB6, 0x44, 0xCA, 0xB3, 0xAB, 0x19, 0xD1, 0x04, 0x24, - 0x28, 0x0A, 0x74, 0x55, 0xB8, 0x15, 0x45, 0x09, 0xCC, 0x13, 0x1C, 0xF2, 0xBA, 0x37, 0xA9, - 0x03, 0x90, 0x8F, 0x02, 0x10, 0xFF, 0x25, 0x79, 0x86, 0xCC, 0x18, 0x50, 0x9A, 0x10, 0x5F, - 0x5B, 0x4C, 0x1C, 0x4E, 0xB0, 0xA7, 0xE3, 0x59, 0xB1, 0x2D, 0xA0, 0xC6, 0xB0, 0x20, 0x2C, - 0x21, 0x33, 0x12, 0xB3, 0xAF, 0x72, 0x34, 0x83, 0xCD, 0x52, 0x2F, 0xAF, 0x0F, 0x20, 0x5A, - 0x1B, 0xC0, 0xE2, 0xA3, 0x76, 0x34, 0x0F, 0xD7, 0xFC, 0xC1, 0x41, 0xC9, 0xF9, 0x79, 0x40, - 0x17, 0x42, 0x21, 0x3E, 0x9D, 0xFD, 0xC7, 0xC1, 0x50, 0xDE, 0x44, 0x5A, 0xC9, 0x31, 0x89, - 0x6A, 0x78, 0x05, 0xBE, 0x65, 0xB4, 0xE8, 0x2D}; - // q - static constexpr CryptoPP::byte Prime2[] = { - 0xC7, 0x9E, 0x47, 0x58, 0x00, 0x7D, 0x62, 0x82, 0xB0, 0xD2, 0x22, 0x81, 0xD4, 0xA8, 0x97, - 0x1B, 0x79, 0x0C, 0x3A, 0xB0, 0xD7, 0xC9, 0x30, 0xE3, 0xC3, 0x53, 0x8E, 0x57, 0xEF, 0xF0, - 0x9B, 0x9F, 0xB3, 0x90, 0x52, 0xC6, 0x94, 0x22, 0x36, 0xAA, 0xE6, 0x4A, 0x5F, 0x72, 0x1D, - 0x70, 0xE8, 0x76, 0x58, 0xC8, 0xB2, 0x91, 0xCE, 0x9C, 0xC3, 0xE9, 0x09, 0x7F, 0x2E, 0x47, - 0x97, 0xCC, 0x90, 0x39, 0x15, 0x35, 0x31, 0xDE, 0x1F, 0x0C, 0x8C, 0x0D, 0xC1, 0xC2, 0x92, - 0xBE, 0x97, 0xBF, 0x2F, 0x91, 0xA1, 0x8C, 0x7D, 0x50, 0xA8, 0x21, 0x2F, 0xD7, 0xA2, 0x9A, - 0x7E, 0xB5, 0xA7, 0x2A, 0x90, 0x02, 0xD9, 0xF3, 0x3D, 0xD1, 0xEB, 0xB8, 0xE0, 0x5A, 0x79, - 0x9E, 0x7D, 0x8D, 0xCA, 0x18, 0x6D, 0xBD, 0x9E, 0xA1, 0x80, 0x28, 0x6B, 0x2A, 0xFE, 0x51, - 0x24, 0x9B, 0x6F, 0x4D, 0x84, 0x77, 0x80, 0x23}; - static constexpr CryptoPP::byte PrivateExponent[] = { - 0x7F, 0x76, 0xCD, 0x0E, 0xE2, 0xD4, 0xDE, 0x05, 0x1C, 0xC6, 0xD9, 0xA8, 0x0E, 0x8D, 0xFA, - 0x7B, 0xCA, 0x1E, 0xAA, 0x27, 0x1A, 0x40, 0xF8, 0xF1, 0x22, 0x87, 0x35, 0xDD, 0xDB, 0xFD, - 0xEE, 0xF8, 0xC2, 0xBC, 0xBD, 0x01, 0xFB, 0x8B, 0xE2, 0x3E, 0x63, 0xB2, 0xB1, 0x22, 0x5C, - 0x56, 0x49, 0x6E, 0x11, 0xBE, 0x07, 0x44, 0x0B, 0x9A, 0x26, 0x66, 0xD1, 0x49, 0x2C, 0x8F, - 0xD3, 0x1B, 0xCF, 0xA4, 0xA1, 0xB8, 0xD1, 0xFB, 0xA4, 0x9E, 0xD2, 0x21, 0x28, 0x83, 0x09, - 0x8A, 0xF6, 0xA0, 0x0B, 0xA3, 0xD6, 0x0F, 0x9B, 0x63, 0x68, 0xCC, 0xBC, 0x0C, 0x4E, 0x14, - 0x5B, 0x27, 0xA4, 0xA9, 0xF4, 0x2B, 0xB9, 0xB8, 0x7B, 0xC0, 0xE6, 0x51, 0xAD, 0x1D, 0x77, - 0xD4, 0x6B, 0xB9, 0xCE, 0x20, 0xD1, 0x26, 0x66, 0x7E, 0x5E, 0x9E, 0xA2, 0xE9, 0x6B, 0x90, - 0xF3, 0x73, 0xB8, 0x52, 0x8F, 0x44, 0x11, 0x03, 0x0C, 0x13, 0x97, 0x39, 0x3D, 0x13, 0x22, - 0x58, 0xD5, 0x43, 0x82, 0x49, 0xDA, 0x6E, 0x7C, 0xA1, 0xC5, 0x8C, 0xA5, 0xB0, 0x09, 0xE0, - 0xCE, 0x3D, 0xDF, 0xF4, 0x9D, 0x3C, 0x97, 0x15, 0xE2, 0x6A, 0xC7, 0x2B, 0x3C, 0x50, 0x93, - 0x23, 0xDB, 0xBA, 0x4A, 0x22, 0x66, 0x44, 0xAC, 0x78, 0xBB, 0x0E, 0x1A, 0x27, 0x43, 0xB5, - 0x71, 0x67, 0xAF, 0xF4, 0xAB, 0x48, 0x46, 0x93, 0x73, 0xD0, 0x42, 0xAB, 0x93, 0x63, 0xE5, - 0x6C, 0x9A, 0xDE, 0x50, 0x24, 0xC0, 0x23, 0x7D, 0x99, 0x79, 0x3F, 0x22, 0x07, 0xE0, 0xC1, - 0x48, 0x56, 0x1B, 0xDF, 0x83, 0x09, 0x12, 0xB4, 0x2D, 0x45, 0x6B, 0xC9, 0xC0, 0x68, 0x85, - 0x99, 0x90, 0x79, 0x96, 0x1A, 0xD7, 0xF5, 0x4D, 0x1F, 0x37, 0x83, 0x40, 0x4A, 0xEC, 0x39, - 0x37, 0xA6, 0x80, 0x92, 0x7D, 0xC5, 0x80, 0xC7, 0xD6, 0x6F, 0xFE, 0x8A, 0x79, 0x89, 0xC6, - 0xB1}; -}; - -class DebugRifKeyset { -public: - // std::uint8_t* PrivateExponent; - static constexpr CryptoPP::byte Exponent1[] = { - 0xCD, 0x9A, 0x61, 0xB0, 0xB8, 0xD5, 0xB4, 0xE4, 0xE4, 0xF6, 0xAB, 0xF7, 0x27, 0xB7, 0x56, - 0x59, 0x6B, 0xB9, 0x11, 0xE7, 0xF4, 0x83, 0xAF, 0xB9, 0x73, 0x99, 0x7F, 0x49, 0xA2, 0x9C, - 0xF0, 0xB5, 0x6D, 0x37, 0x82, 0x14, 0x15, 0xF1, 0x04, 0x8A, 0xD4, 0x8E, 0xEB, 0x2E, 0x1F, - 0xE2, 0x81, 0xA9, 0x62, 0x6E, 0xB1, 0x68, 0x75, 0x62, 0xF3, 0x0F, 0xFE, 0xD4, 0x91, 0x87, - 0x98, 0x78, 0xBF, 0x26, 0xB5, 0x07, 0x58, 0xD0, 0xEE, 0x3F, 0x21, 0xE8, 0xC8, 0x0F, 0x5F, - 0xFA, 0x1C, 0x64, 0x74, 0x49, 0x52, 0xEB, 0xE7, 0xEE, 0xDE, 0xBA, 0x23, 0x26, 0x4A, 0xF6, - 0x9C, 0x1A, 0x09, 0x3F, 0xB9, 0x0B, 0x36, 0x26, 0x1A, 0xBE, 0xA9, 0x76, 0xE6, 0xF2, 0x69, - 0xDE, 0xFF, 0xAF, 0xCC, 0x0C, 0x9A, 0x66, 0x03, 0x86, 0x0A, 0x1F, 0x49, 0xA4, 0x10, 0xB6, - 0xBC, 0xC3, 0x7C, 0x88, 0xE8, 0xCE, 0x4B, 0xD9}; - // exponent2 = d mod (q - 1) - static constexpr CryptoPP::byte Exponent2[] = { - 0xB3, 0x73, 0xA3, 0x59, 0xE6, 0x97, 0xC0, 0xAB, 0x3B, 0x68, 0xFC, 0x39, 0xAC, 0xDB, 0x44, - 0xB1, 0xB4, 0x9E, 0x35, 0x4D, 0xBE, 0xC5, 0x36, 0x69, 0x6C, 0x3D, 0xC5, 0xFC, 0xFE, 0x4B, - 0x2F, 0xDC, 0x86, 0x80, 0x46, 0x96, 0x40, 0x1A, 0x0D, 0x6E, 0xFA, 0x8C, 0xE0, 0x47, 0x91, - 0xAC, 0xAD, 0x95, 0x2B, 0x8E, 0x1F, 0xF2, 0x0A, 0x45, 0xF8, 0x29, 0x95, 0x70, 0xC6, 0x88, - 0x5F, 0x71, 0x03, 0x99, 0x79, 0xBC, 0x84, 0x71, 0xBD, 0xE8, 0x84, 0x8C, 0x0E, 0xD4, 0x7B, - 0x30, 0x74, 0x57, 0x1A, 0x95, 0xE7, 0x90, 0x19, 0x8D, 0xAD, 0x8B, 0x4C, 0x4E, 0xC3, 0xE7, - 0x6B, 0x23, 0x86, 0x01, 0xEE, 0x9B, 0xE0, 0x2F, 0x15, 0xA2, 0x2C, 0x4C, 0x39, 0xD3, 0xDF, - 0x9C, 0x39, 0x01, 0xF1, 0x8C, 0x44, 0x4A, 0x15, 0x44, 0xDC, 0x51, 0xF7, 0x22, 0xD7, 0x7F, - 0x41, 0x7F, 0x68, 0xFA, 0xEE, 0x56, 0xE8, 0x05}; - // e - static constexpr CryptoPP::byte PublicExponent[] = {0x00, 0x01, 0x00, 0x01}; - // (InverseQ)(q) = 1 mod p - static constexpr CryptoPP::byte Coefficient[] = { - 0xC0, 0x32, 0x43, 0xD3, 0x8C, 0x3D, 0xB4, 0xD2, 0x48, 0x8C, 0x42, 0x41, 0x24, 0x94, 0x6C, - 0x80, 0xC9, 0xC1, 0x79, 0x36, 0x7F, 0xAC, 0xC3, 0xFF, 0x6A, 0x25, 0xEB, 0x2C, 0xFB, 0xD4, - 0x2B, 0xA0, 0xEB, 0xFE, 0x25, 0xE9, 0xC6, 0x77, 0xCE, 0xFE, 0x2D, 0x23, 0xFE, 0xD0, 0xF4, - 0x0F, 0xD9, 0x7E, 0xD5, 0xA5, 0x7D, 0x1F, 0xC0, 0xE8, 0xE8, 0xEC, 0x80, 0x5B, 0xC7, 0xFD, - 0xE2, 0xBD, 0x94, 0xA6, 0x2B, 0xDD, 0x6A, 0x60, 0x45, 0x54, 0xAB, 0xCA, 0x42, 0x9C, 0x6A, - 0x6C, 0xBF, 0x3C, 0x84, 0xF9, 0xA5, 0x0E, 0x63, 0x0C, 0x51, 0x58, 0x62, 0x6D, 0x5A, 0xB7, - 0x3C, 0x3F, 0x49, 0x1A, 0xD0, 0x93, 0xB8, 0x4F, 0x1A, 0x6C, 0x5F, 0xC5, 0xE5, 0xA9, 0x75, - 0xD4, 0x86, 0x9E, 0xDF, 0x87, 0x0F, 0x27, 0xB0, 0x26, 0x78, 0x4E, 0xFB, 0xC1, 0x8A, 0x4A, - 0x24, 0x3F, 0x7F, 0x8F, 0x9A, 0x12, 0x51, 0xCB}; - // n = p * q - static constexpr CryptoPP::byte Modulus[] = { - 0xC2, 0xD2, 0x44, 0xBC, 0xDD, 0x84, 0x3F, 0xD9, 0xC5, 0x22, 0xAF, 0xF7, 0xFC, 0x88, 0x8A, - 0x33, 0x80, 0xED, 0x8E, 0xE2, 0xCC, 0x81, 0xF7, 0xEC, 0xF8, 0x1C, 0x79, 0xBF, 0x02, 0xBB, - 0x12, 0x8E, 0x61, 0x68, 0x29, 0x1B, 0x15, 0xB6, 0x5E, 0xC6, 0xF8, 0xBF, 0x5A, 0xE0, 0x3B, - 0x6A, 0x6C, 0xD9, 0xD6, 0xF5, 0x75, 0xAB, 0xA0, 0x6F, 0x34, 0x81, 0x34, 0x9A, 0x5B, 0xAD, - 0xED, 0x31, 0xE3, 0xC6, 0xEA, 0x1A, 0xD1, 0x13, 0x22, 0xBB, 0xB3, 0xDA, 0xB3, 0xB2, 0x53, - 0xBD, 0x45, 0x79, 0x87, 0xAD, 0x0A, 0x01, 0x72, 0x18, 0x10, 0x29, 0x49, 0xF4, 0x41, 0x7F, - 0xD6, 0x47, 0x0C, 0x72, 0x92, 0x9E, 0xE9, 0xBB, 0x95, 0xA9, 0x5D, 0x79, 0xEB, 0xE4, 0x30, - 0x76, 0x90, 0x45, 0x4B, 0x9D, 0x9C, 0xCF, 0x92, 0x03, 0x60, 0x8C, 0x4B, 0x6C, 0xB3, 0x7A, - 0x3A, 0x05, 0x39, 0xA0, 0x66, 0xA9, 0x35, 0xCF, 0xB9, 0xFA, 0xAD, 0x9C, 0xAB, 0xEB, 0xE4, - 0x6A, 0x8C, 0xE9, 0x3B, 0xCC, 0x72, 0x12, 0x62, 0x63, 0xBD, 0x80, 0xC4, 0xEE, 0x37, 0x2B, - 0x32, 0x03, 0xA3, 0x09, 0xF7, 0xA0, 0x61, 0x57, 0xAD, 0x0D, 0xCF, 0x15, 0x98, 0x9E, 0x4E, - 0x49, 0xF8, 0xB5, 0xA3, 0x5C, 0x27, 0xEE, 0x45, 0x04, 0xEA, 0xE4, 0x4B, 0xBC, 0x8F, 0x87, - 0xED, 0x19, 0x1E, 0x46, 0x75, 0x63, 0xC4, 0x5B, 0xD5, 0xBC, 0x09, 0x2F, 0x02, 0x73, 0x19, - 0x3C, 0x58, 0x55, 0x49, 0x66, 0x4C, 0x11, 0xEC, 0x0F, 0x09, 0xFA, 0xA5, 0x56, 0x0A, 0x5A, - 0x63, 0x56, 0xAD, 0xA0, 0x0D, 0x86, 0x08, 0xC1, 0xE6, 0xB6, 0x13, 0x22, 0x49, 0x2F, 0x7C, - 0xDB, 0x4C, 0x56, 0x97, 0x0E, 0xC2, 0xD9, 0x2E, 0x87, 0xBC, 0x0E, 0x67, 0xC0, 0x1B, 0x58, - 0xBC, 0x64, 0x2B, 0xC2, 0x6E, 0xE2, 0x93, 0x2E, 0xB5, 0x6B, 0x70, 0xA4, 0x42, 0x9F, 0x64, - 0xC1}; - // p - static constexpr CryptoPP::byte Prime1[] = { - 0xE5, 0x62, 0xE1, 0x7F, 0x9F, 0x86, 0x08, 0xE2, 0x61, 0xD3, 0xD0, 0x42, 0xE2, 0xC4, 0xB6, - 0xA8, 0x51, 0x09, 0x19, 0x14, 0xA4, 0x3A, 0x11, 0x4C, 0x33, 0xA5, 0x9C, 0x01, 0x5E, 0x34, - 0xB6, 0x3F, 0x02, 0x1A, 0xCA, 0x47, 0xF1, 0x4F, 0x3B, 0x35, 0x2A, 0x07, 0x20, 0xEC, 0xD8, - 0xC1, 0x15, 0xD9, 0xCA, 0x03, 0x4F, 0xB8, 0xE8, 0x09, 0x73, 0x3F, 0x85, 0xB7, 0x41, 0xD5, - 0x51, 0x3E, 0x7B, 0xE3, 0x53, 0x2B, 0x48, 0x8B, 0x8E, 0xCB, 0xBA, 0xF7, 0xE0, 0x60, 0xF5, - 0x35, 0x0E, 0x6F, 0xB0, 0xD9, 0x2A, 0x99, 0xD0, 0xFF, 0x60, 0x14, 0xED, 0x40, 0xEA, 0xF8, - 0xD7, 0x0B, 0xC3, 0x8D, 0x8C, 0xE8, 0x81, 0xB3, 0x75, 0x93, 0x15, 0xB3, 0x7D, 0xF6, 0x39, - 0x60, 0x1A, 0x00, 0xE7, 0xC3, 0x27, 0xAD, 0xA4, 0x33, 0xD5, 0x3E, 0xA4, 0x35, 0x48, 0x6F, - 0x22, 0xEF, 0x5D, 0xDD, 0x7D, 0x7B, 0x61, 0x05}; - // q - static constexpr CryptoPP::byte Prime2[] = { - 0xD9, 0x6C, 0xC2, 0x0C, 0xF7, 0xAE, 0xD1, 0xF3, 0x3B, 0x3B, 0x49, 0x1E, 0x9F, 0x12, 0x9C, - 0xA1, 0x78, 0x1F, 0x35, 0x1D, 0x98, 0x26, 0x13, 0x71, 0xF9, 0x09, 0xFD, 0xF0, 0xAD, 0x38, - 0x55, 0xB7, 0xEE, 0x61, 0x04, 0x72, 0x51, 0x87, 0x2E, 0x05, 0x84, 0xB1, 0x1D, 0x0C, 0x0D, - 0xDB, 0xD4, 0x25, 0x3E, 0x26, 0xED, 0xEA, 0xB8, 0xF7, 0x49, 0xFE, 0xA2, 0x94, 0xE6, 0xF2, - 0x08, 0x92, 0xA7, 0x85, 0xF5, 0x30, 0xB9, 0x84, 0x22, 0xBF, 0xCA, 0xF0, 0x5F, 0xCB, 0x31, - 0x20, 0x34, 0x49, 0x16, 0x76, 0x34, 0xCC, 0x7A, 0xCB, 0x96, 0xFE, 0x78, 0x7A, 0x41, 0xFE, - 0x9A, 0xA2, 0x23, 0xF7, 0x68, 0x80, 0xD6, 0xCE, 0x4A, 0x78, 0xA5, 0xB7, 0x05, 0x77, 0x81, - 0x1F, 0xDE, 0x5E, 0xA8, 0x6E, 0x3E, 0x87, 0xEC, 0x44, 0xD2, 0x69, 0xC6, 0x54, 0x91, 0x6B, - 0x5E, 0x13, 0x8A, 0x03, 0x87, 0x05, 0x31, 0x8D}; - static constexpr CryptoPP::byte PrivateExponent[] = { - 0x01, 0x61, 0xAD, 0xD8, 0x9C, 0x06, 0x89, 0xD0, 0x60, 0xC8, 0x41, 0xF0, 0xB3, 0x83, 0x01, - 0x5D, 0xE3, 0xA2, 0x6B, 0xA2, 0xBA, 0x9A, 0x0A, 0x58, 0xCD, 0x1A, 0xA0, 0x97, 0x64, 0xEC, - 0xD0, 0x31, 0x1F, 0xCA, 0x36, 0x0E, 0x69, 0xDD, 0x40, 0xF7, 0x4E, 0xC0, 0xC6, 0xA3, 0x73, - 0xF0, 0x69, 0x84, 0xB2, 0xF4, 0x4B, 0x29, 0x14, 0x2A, 0x6D, 0xB8, 0x23, 0xD8, 0x1B, 0x61, - 0xD4, 0x9E, 0x87, 0xB3, 0xBB, 0xA9, 0xC4, 0x85, 0x4A, 0xF8, 0x03, 0x4A, 0xBF, 0xFE, 0xF9, - 0xFE, 0x8B, 0xDD, 0x54, 0x83, 0xBA, 0xE0, 0x2F, 0x3F, 0xB1, 0xEF, 0xA5, 0x05, 0x5D, 0x28, - 0x8B, 0xAB, 0xB5, 0xD0, 0x23, 0x2F, 0x8A, 0xCF, 0x48, 0x7C, 0xAA, 0xBB, 0xC8, 0x5B, 0x36, - 0x27, 0xC5, 0x16, 0xA4, 0xB6, 0x61, 0xAC, 0x0C, 0x28, 0x47, 0x79, 0x3F, 0x38, 0xAE, 0x5E, - 0x25, 0xC6, 0xAF, 0x35, 0xAE, 0xBC, 0xB0, 0xF3, 0xBC, 0xBD, 0xFD, 0xA4, 0x87, 0x0D, 0x14, - 0x3D, 0x90, 0xE4, 0xDE, 0x5D, 0x1D, 0x46, 0x81, 0xF1, 0x28, 0x6D, 0x2F, 0x2C, 0x5E, 0x97, - 0x2D, 0x89, 0x2A, 0x51, 0x72, 0x3C, 0x20, 0x02, 0x59, 0xB1, 0x98, 0x93, 0x05, 0x1E, 0x3F, - 0xA1, 0x8A, 0x69, 0x30, 0x0E, 0x70, 0x84, 0x8B, 0xAE, 0x97, 0xA1, 0x08, 0x95, 0x63, 0x4C, - 0xC7, 0xE8, 0x5D, 0x59, 0xCA, 0x78, 0x2A, 0x23, 0x87, 0xAC, 0x6F, 0x04, 0x33, 0xB1, 0x61, - 0xB9, 0xF0, 0x95, 0xDA, 0x33, 0xCC, 0xE0, 0x4C, 0x82, 0x68, 0x82, 0x14, 0x51, 0xBE, 0x49, - 0x1C, 0x58, 0xA2, 0x8B, 0x05, 0x4E, 0x98, 0x37, 0xEB, 0x94, 0x0B, 0x01, 0x22, 0xDC, 0xB3, - 0x19, 0xCA, 0x77, 0xA6, 0x6E, 0x97, 0xFF, 0x8A, 0x53, 0x5A, 0xC5, 0x24, 0xE4, 0xAF, 0x6E, - 0xA8, 0x2B, 0x53, 0xA4, 0xBE, 0x96, 0xA5, 0x7B, 0xCE, 0x22, 0x56, 0xA3, 0xF1, 0xCF, 0x14, - 0xA5}; -}; - -class PkgDerivedKey3Keyset { -public: - // std::uint8_t* PrivateExponent; - static constexpr CryptoPP::byte Exponent1[] = { - 0x52, 0xCC, 0x2D, 0xA0, 0x9C, 0x9E, 0x75, 0xE7, 0x28, 0xEE, 0x3D, 0xDE, 0xE3, 0x45, 0xD1, - 0x4F, 0x94, 0x1C, 0xCC, 0xC8, 0x87, 0x29, 0x45, 0x3B, 0x8D, 0x6E, 0xAB, 0x6E, 0x2A, 0xA7, - 0xC7, 0x15, 0x43, 0xA3, 0x04, 0x8F, 0x90, 0x5F, 0xEB, 0xF3, 0x38, 0x4A, 0x77, 0xFA, 0x36, - 0xB7, 0x15, 0x76, 0xB6, 0x01, 0x1A, 0x8E, 0x25, 0x87, 0x82, 0xF1, 0x55, 0xD8, 0xC6, 0x43, - 0x2A, 0xC0, 0xE5, 0x98, 0xC9, 0x32, 0xD1, 0x94, 0x6F, 0xD9, 0x01, 0xBA, 0x06, 0x81, 0xE0, - 0x6D, 0x88, 0xF2, 0x24, 0x2A, 0x25, 0x01, 0x64, 0x5C, 0xBF, 0xF2, 0xD9, 0x99, 0x67, 0x3E, - 0xF6, 0x72, 0xEE, 0xE4, 0xE2, 0x33, 0x5C, 0xF8, 0x00, 0x40, 0xE3, 0x2A, 0x9A, 0xF4, 0x3D, - 0x22, 0x86, 0x44, 0x3C, 0xFB, 0x0A, 0xA5, 0x7C, 0x3F, 0xCC, 0xF5, 0xF1, 0x16, 0xC4, 0xAC, - 0x88, 0xB4, 0xDE, 0x62, 0x94, 0x92, 0x6A, 0x13}; - // exponent2 = d mod (q - 1) - static constexpr CryptoPP::byte Exponent2[] = { - 0x7C, 0x9D, 0xAD, 0x39, 0xE0, 0xD5, 0x60, 0x14, 0x94, 0x48, 0x19, 0x7F, 0x88, 0x95, 0xD5, - 0x8B, 0x80, 0xAD, 0x85, 0x8A, 0x4B, 0x77, 0x37, 0x85, 0xD0, 0x77, 0xBB, 0xBF, 0x89, 0x71, - 0x4A, 0x72, 0xCB, 0x72, 0x68, 0x38, 0xEC, 0x02, 0xC6, 0x7D, 0xC6, 0x44, 0x06, 0x33, 0x51, - 0x1C, 0xC0, 0xFF, 0x95, 0x8F, 0x0D, 0x75, 0xDC, 0x25, 0xBB, 0x0B, 0x73, 0x91, 0xA9, 0x6D, - 0x42, 0xD8, 0x03, 0xB7, 0x68, 0xD4, 0x1E, 0x75, 0x62, 0xA3, 0x70, 0x35, 0x79, 0x78, 0x00, - 0xC8, 0xF5, 0xEF, 0x15, 0xB9, 0xFC, 0x4E, 0x47, 0x5A, 0xC8, 0x70, 0x70, 0x5B, 0x52, 0x98, - 0xC0, 0xC2, 0x58, 0x4A, 0x70, 0x96, 0xCC, 0xB8, 0x10, 0xE1, 0x2F, 0x78, 0x8B, 0x2B, 0xA1, - 0x7F, 0xF9, 0xAC, 0xDE, 0xF0, 0xBB, 0x2B, 0xE2, 0x66, 0xE3, 0x22, 0x92, 0x31, 0x21, 0x57, - 0x92, 0xC4, 0xB8, 0xF2, 0x3E, 0x76, 0x20, 0x37}; - // e - static constexpr CryptoPP::byte PublicExponent[] = {0, 1, 0, 1}; - // (InverseQ)(q) = 1 mod p - static constexpr CryptoPP::byte Coefficient[] = { - 0x45, 0x97, 0x55, 0xD4, 0x22, 0x08, 0x5E, 0xF3, 0x5C, 0xB4, 0x05, 0x7A, 0xFD, 0xAA, 0x42, - 0x42, 0xAD, 0x9A, 0x8C, 0xA0, 0x6C, 0xBB, 0x1D, 0x68, 0x54, 0x54, 0x6E, 0x3E, 0x32, 0xE3, - 0x53, 0x73, 0x76, 0xF1, 0x3E, 0x01, 0xEA, 0xD3, 0xCF, 0xEB, 0xEB, 0x23, 0x3E, 0xC0, 0xBE, - 0xCE, 0xEC, 0x2C, 0x89, 0x5F, 0xA8, 0x27, 0x3A, 0x4C, 0xB7, 0xE6, 0x74, 0xBC, 0x45, 0x4C, - 0x26, 0xC8, 0x25, 0xFF, 0x34, 0x63, 0x25, 0x37, 0xE1, 0x48, 0x10, 0xC1, 0x93, 0xA6, 0xAF, - 0xEB, 0xBA, 0xE3, 0xA2, 0xF1, 0x3D, 0xEF, 0x63, 0xD8, 0xF4, 0xFD, 0xD3, 0xEE, 0xE2, 0x5D, - 0xE9, 0x33, 0xCC, 0xAD, 0xBA, 0x75, 0x5C, 0x85, 0xAF, 0xCE, 0xA9, 0x3D, 0xD1, 0xA2, 0x17, - 0xF3, 0xF6, 0x98, 0xB3, 0x50, 0x8E, 0x5E, 0xF6, 0xEB, 0x02, 0x8E, 0xA1, 0x62, 0xA7, 0xD6, - 0x2C, 0xEC, 0x91, 0xFF, 0x15, 0x40, 0xD2, 0xE3}; - // n = p * q - static constexpr CryptoPP::byte Modulus[] = { - 0xd2, 0x12, 0xfc, 0x33, 0x5f, 0x6d, 0xdb, 0x83, 0x16, 0x09, 0x62, 0x8b, 0x03, 0x56, 0x27, - 0x37, 0x82, 0xd4, 0x77, 0x85, 0x35, 0x29, 0x39, 0x2d, 0x52, 0x6b, 0x8c, 0x4c, 0x8c, 0xfb, - 0x06, 0xc1, 0x84, 0x5b, 0xe7, 0xd4, 0xf7, 0xbc, 0xd2, 0x4e, 0x62, 0x45, 0xcd, 0x2a, 0xbb, - 0xd7, 0x77, 0x76, 0x45, 0x36, 0x55, 0x27, 0x3f, 0xb3, 0xf5, 0xf9, 0x8e, 0xda, 0x4b, 0xef, - 0xaa, 0x59, 0xae, 0xb3, 0x9b, 0xea, 0x54, 0x98, 0xd2, 0x06, 0x32, 0x6a, 0x58, 0x31, 0x2a, - 0xe0, 0xd4, 0x4f, 0x90, 0xb5, 0x0a, 0x7d, 0xec, 0xf4, 0x3a, 0x9c, 0x52, 0x67, 0x2d, 0x99, - 0x31, 0x8e, 0x0c, 0x43, 0xe6, 0x82, 0xfe, 0x07, 0x46, 0xe1, 0x2e, 0x50, 0xd4, 0x1f, 0x2d, - 0x2f, 0x7e, 0xd9, 0x08, 0xba, 0x06, 0xb3, 0xbf, 0x2e, 0x20, 0x3f, 0x4e, 0x3f, 0xfe, 0x44, - 0xff, 0xaa, 0x50, 0x43, 0x57, 0x91, 0x69, 0x94, 0x49, 0x15, 0x82, 0x82, 0xe4, 0x0f, 0x4c, - 0x8d, 0x9d, 0x2c, 0xc9, 0x5b, 0x1d, 0x64, 0xbf, 0x88, 0x8b, 0xd4, 0xc5, 0x94, 0xe7, 0x65, - 0x47, 0x84, 0x1e, 0xe5, 0x79, 0x10, 0xfb, 0x98, 0x93, 0x47, 0xb9, 0x7d, 0x85, 0x12, 0xa6, - 0x40, 0x98, 0x2c, 0xf7, 0x92, 0xbc, 0x95, 0x19, 0x32, 0xed, 0xe8, 0x90, 0x56, 0x0d, 0x65, - 0xc1, 0xaa, 0x78, 0xc6, 0x2e, 0x54, 0xfd, 0x5f, 0x54, 0xa1, 0xf6, 0x7e, 0xe5, 0xe0, 0x5f, - 0x61, 0xc1, 0x20, 0xb4, 0xb9, 0xb4, 0x33, 0x08, 0x70, 0xe4, 0xdf, 0x89, 0x56, 0xed, 0x01, - 0x29, 0x46, 0x77, 0x5f, 0x8c, 0xb8, 0xa9, 0xf5, 0x1e, 0x2e, 0xb3, 0xb9, 0xbf, 0xe0, 0x09, - 0xb7, 0x8d, 0x28, 0xd4, 0xa6, 0xc3, 0xb8, 0x1e, 0x1f, 0x07, 0xeb, 0xb4, 0x12, 0x0b, 0x95, - 0xb8, 0x85, 0x30, 0xfd, 0xdc, 0x39, 0x13, 0xd0, 0x7c, 0xdc, 0x8f, 0xed, 0xf9, 0xc9, 0xa3, - 0xc1}; - // p - static constexpr CryptoPP::byte Prime1[] = { - 0xF9, 0x67, 0xAD, 0x99, 0x12, 0x31, 0x0C, 0x56, 0xA2, 0x2E, 0x16, 0x1C, 0x46, 0xB3, 0x4D, - 0x5B, 0x43, 0xBE, 0x42, 0xA2, 0xF6, 0x86, 0x96, 0x80, 0x42, 0xC3, 0xC7, 0x3F, 0xC3, 0x42, - 0xF5, 0x87, 0x49, 0x33, 0x9F, 0x07, 0x5D, 0x6E, 0x2C, 0x04, 0xFD, 0xE3, 0xE1, 0xB2, 0xAE, - 0x0A, 0x0C, 0xF0, 0xC7, 0xA6, 0x1C, 0xA1, 0x63, 0x50, 0xC8, 0x09, 0x9C, 0x51, 0x24, 0x52, - 0x6C, 0x5E, 0x5E, 0xBD, 0x1E, 0x27, 0x06, 0xBB, 0xBC, 0x9E, 0x94, 0xE1, 0x35, 0xD4, 0x6D, - 0xB3, 0xCB, 0x3C, 0x68, 0xDD, 0x68, 0xB3, 0xFE, 0x6C, 0xCB, 0x8D, 0x82, 0x20, 0x76, 0x23, - 0x63, 0xB7, 0xE9, 0x68, 0x10, 0x01, 0x4E, 0xDC, 0xBA, 0x27, 0x5D, 0x01, 0xC1, 0x2D, 0x80, - 0x5E, 0x2B, 0xAF, 0x82, 0x6B, 0xD8, 0x84, 0xB6, 0x10, 0x52, 0x86, 0xA7, 0x89, 0x8E, 0xAE, - 0x9A, 0xE2, 0x89, 0xC6, 0xF7, 0xD5, 0x87, 0xFB}; - // q - static constexpr CryptoPP::byte Prime2[] = { - 0xD7, 0xA1, 0x0F, 0x9A, 0x8B, 0xF2, 0xC9, 0x11, 0x95, 0x32, 0x9A, 0x8C, 0xF0, 0xD9, 0x40, - 0x47, 0xF5, 0x68, 0xA0, 0x0D, 0xBD, 0xC1, 0xFC, 0x43, 0x2F, 0x65, 0xF9, 0xC3, 0x61, 0x0F, - 0x25, 0x77, 0x54, 0xAD, 0xD7, 0x58, 0xAC, 0x84, 0x40, 0x60, 0x8D, 0x3F, 0xF3, 0x65, 0x89, - 0x75, 0xB5, 0xC6, 0x2C, 0x51, 0x1A, 0x2F, 0x1F, 0x22, 0xE4, 0x43, 0x11, 0x54, 0xBE, 0xC9, - 0xB4, 0xC7, 0xB5, 0x1B, 0x05, 0x0B, 0xBC, 0x56, 0x9A, 0xCD, 0x4A, 0xD9, 0x73, 0x68, 0x5E, - 0x5C, 0xFB, 0x92, 0xB7, 0x8B, 0x0D, 0xFF, 0xF5, 0x07, 0xCA, 0xB4, 0xC8, 0x9B, 0x96, 0x3C, - 0x07, 0x9E, 0x3E, 0x6B, 0x2A, 0x11, 0xF2, 0x8A, 0xB1, 0x8A, 0xD7, 0x2E, 0x1B, 0xA5, 0x53, - 0x24, 0x06, 0xED, 0x50, 0xB8, 0x90, 0x67, 0xB1, 0xE2, 0x41, 0xC6, 0x92, 0x01, 0xEE, 0x10, - 0xF0, 0x61, 0xBB, 0xFB, 0xB2, 0x7D, 0x4A, 0x73}; - static constexpr CryptoPP::byte PrivateExponent[] = { - 0x32, 0xD9, 0x03, 0x90, 0x8F, 0xBD, 0xB0, 0x8F, 0x57, 0x2B, 0x28, 0x5E, 0x0B, 0x8D, 0xB3, - 0xEA, 0x5C, 0xD1, 0x7E, 0xA8, 0x90, 0x88, 0x8C, 0xDD, 0x6A, 0x80, 0xBB, 0xB1, 0xDF, 0xC1, - 0xF7, 0x0D, 0xAA, 0x32, 0xF0, 0xB7, 0x7C, 0xCB, 0x88, 0x80, 0x0E, 0x8B, 0x64, 0xB0, 0xBE, - 0x4C, 0xD6, 0x0E, 0x9B, 0x8C, 0x1E, 0x2A, 0x64, 0xE1, 0xF3, 0x5C, 0xD7, 0x76, 0x01, 0x41, - 0x5E, 0x93, 0x5C, 0x94, 0xFE, 0xDD, 0x46, 0x62, 0xC3, 0x1B, 0x5A, 0xE2, 0xA0, 0xBC, 0x2D, - 0xEB, 0xC3, 0x98, 0x0A, 0xA7, 0xB7, 0x85, 0x69, 0x70, 0x68, 0x2B, 0x64, 0x4A, 0xB3, 0x1F, - 0xCC, 0x7D, 0xDC, 0x7C, 0x26, 0xF4, 0x77, 0xF6, 0x5C, 0xF2, 0xAE, 0x5A, 0x44, 0x2D, 0xD3, - 0xAB, 0x16, 0x62, 0x04, 0x19, 0xBA, 0xFB, 0x90, 0xFF, 0xE2, 0x30, 0x50, 0x89, 0x6E, 0xCB, - 0x56, 0xB2, 0xEB, 0xC0, 0x91, 0x16, 0x92, 0x5E, 0x30, 0x8E, 0xAE, 0xC7, 0x94, 0x5D, 0xFD, - 0x35, 0xE1, 0x20, 0xF8, 0xAD, 0x3E, 0xBC, 0x08, 0xBF, 0xC0, 0x36, 0x74, 0x9F, 0xD5, 0xBB, - 0x52, 0x08, 0xFD, 0x06, 0x66, 0xF3, 0x7A, 0xB3, 0x04, 0xF4, 0x75, 0x29, 0x5D, 0xE9, 0x5F, - 0xAA, 0x10, 0x30, 0xB2, 0x0F, 0x5A, 0x1A, 0xC1, 0x2A, 0xB3, 0xFE, 0xCB, 0x21, 0xAD, 0x80, - 0xEC, 0x8F, 0x20, 0x09, 0x1C, 0xDB, 0xC5, 0x58, 0x94, 0xC2, 0x9C, 0xC6, 0xCE, 0x82, 0x65, - 0x3E, 0x57, 0x90, 0xBC, 0xA9, 0x8B, 0x06, 0xB4, 0xF0, 0x72, 0xF6, 0x77, 0xDF, 0x98, 0x64, - 0xF1, 0xEC, 0xFE, 0x37, 0x2D, 0xBC, 0xAE, 0x8C, 0x08, 0x81, 0x1F, 0xC3, 0xC9, 0x89, 0x1A, - 0xC7, 0x42, 0x82, 0x4B, 0x2E, 0xDC, 0x8E, 0x8D, 0x73, 0xCE, 0xB1, 0xCC, 0x01, 0xD9, 0x08, - 0x70, 0x87, 0x3C, 0x44, 0x08, 0xEC, 0x49, 0x8F, 0x81, 0x5A, 0xE2, 0x40, 0xFF, 0x77, 0xFC, - 0x0D}; -}; \ No newline at end of file diff --git a/src/core/debug_state.h b/src/core/debug_state.h index 217efd1a9..b1b8c00d6 100644 --- a/src/core/debug_state.h +++ b/src/core/debug_state.h @@ -158,6 +158,10 @@ public: float Framerate = 1.0f / 60.0f; float FrameDeltaTime; + std::pair game_resolution{}; + std::pair output_resolution{}; + bool is_using_fsr{}; + void ShowDebugMessage(std::string message) { if (message.empty()) { return; diff --git a/src/core/devices/base_device.h b/src/core/devices/base_device.h index 36614b8f4..0cbbd3a00 100644 --- a/src/core/devices/base_device.h +++ b/src/core/devices/base_device.h @@ -40,6 +40,10 @@ public: return ORBIS_KERNEL_ERROR_EBADF; } + virtual size_t pwritev(const Libraries::Kernel::SceKernelIovec* iov, int iovcnt, u64 offset) { + return ORBIS_KERNEL_ERROR_EBADF; + } + virtual s64 lseek(s64 offset, int whence) { return ORBIS_KERNEL_ERROR_EBADF; } diff --git a/src/core/devtools/layer.cpp b/src/core/devtools/layer.cpp index 603d76df5..a93178de5 100644 --- a/src/core/devtools/layer.cpp +++ b/src/core/devtools/layer.cpp @@ -5,6 +5,7 @@ #include +#include "SDL3/SDL_log.h" #include "common/config.h" #include "common/singleton.h" #include "common/types.h" @@ -21,8 +22,8 @@ extern std::unique_ptr presenter; using namespace ImGui; -using namespace Core::Devtools; -using L = Core::Devtools::Layer; +using namespace ::Core::Devtools; +using L = ::Core::Devtools::Layer; static bool show_simple_fps = false; static bool visibility_toggled = false; @@ -81,8 +82,24 @@ void L::DrawMenuBar() { ImGui::EndMenu(); } if (BeginMenu("Display")) { + auto& pp_settings = presenter->GetPPSettingsRef(); if (BeginMenu("Brightness")) { - SliderFloat("Gamma", &presenter->GetGammaRef(), 0.1f, 2.0f); + SliderFloat("Gamma", &pp_settings.gamma, 0.1f, 2.0f); + ImGui::EndMenu(); + } + if (BeginMenu("FSR")) { + auto& fsr = presenter->GetFsrSettingsRef(); + Checkbox("FSR Enabled", &fsr.enable); + BeginDisabled(!fsr.enable); + { + Checkbox("RCAS", &fsr.use_rcas); + BeginDisabled(!fsr.use_rcas); + { + SliderFloat("RCAS Attenuation", &fsr.rcas_attenuation, 0.0, 3.0); + } + EndDisabled(); + } + EndDisabled(); ImGui::EndMenu(); } ImGui::EndMenu(); @@ -101,22 +118,6 @@ void L::DrawMenuBar() { EndMainMenuBar(); } - - if (IsKeyPressed(ImGuiKey_F9, false)) { - if (io.KeyCtrl && io.KeyAlt) { - if (!DebugState.ShouldPauseInSubmit()) { - DebugState.RequestFrameDump(dump_frame_count); - } - } - if (!io.KeyCtrl && !io.KeyAlt) { - if (isSystemPaused) { - DebugState.ResumeGuestThreads(); - } else { - DebugState.PauseGuestThreads(); - } - } - } - if (open_popup_options) { OpenPopup("GPU Tools Options"); just_opened_options = true; @@ -365,6 +366,32 @@ void L::Draw() { visibility_toggled = true; } + if (IsKeyPressed(ImGuiKey_F9, false)) { + if (io.KeyCtrl && io.KeyAlt) { + if (!DebugState.ShouldPauseInSubmit()) { + DebugState.RequestFrameDump(dump_frame_count); + } + } else { + if (DebugState.IsGuestThreadsPaused()) { + DebugState.ResumeGuestThreads(); + SDL_Log("Game resumed from Keyboard"); + show_pause_status = false; + } else { + DebugState.PauseGuestThreads(); + SDL_Log("Game paused from Keyboard"); + show_pause_status = true; + } + visibility_toggled = true; + } + } + + if (show_pause_status) { + ImVec2 pos = ImVec2(10, 10); + ImU32 color = IM_COL32(255, 255, 255, 255); + + ImGui::GetForegroundDrawList()->AddText(pos, color, "Game Paused Press F9 to Resume"); + } + if (show_simple_fps) { if (Begin("Video Info", nullptr, ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoDecoration | diff --git a/src/core/devtools/layer.h b/src/core/devtools/layer.h index 5bb53fbdb..9e949c8e9 100644 --- a/src/core/devtools/layer.h +++ b/src/core/devtools/layer.h @@ -19,6 +19,7 @@ public: static void SetupSettings(); void Draw() override; + bool show_pause_status = false; }; } // namespace Core::Devtools diff --git a/src/core/devtools/options.cpp b/src/core/devtools/options.cpp index 2def42071..f4b0ceb9a 100644 --- a/src/core/devtools/options.cpp +++ b/src/core/devtools/options.cpp @@ -1,9 +1,14 @@ // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include "options.h" + +#include #include -#include "options.h" +#include "video_core/renderer_vulkan/vk_presenter.h" + +extern std::unique_ptr presenter; namespace Core::Devtools { @@ -12,6 +17,7 @@ TOptions Options; void LoadOptionsConfig(const char* line) { char str[512]; int i; + float f; if (sscanf(line, "disassembler_cli_isa=%511[^\n]", str) == 1) { Options.disassembler_cli_isa = str; return; @@ -24,12 +30,26 @@ void LoadOptionsConfig(const char* line) { Options.frame_dump_render_on_collapse = i != 0; return; } + if (sscanf(line, "fsr_enabled=%d", &i) == 1) { + presenter->GetFsrSettingsRef().enable = i != 0; + return; + } + if (sscanf(line, "fsr_rcas_enabled=%d", &i) == 1) { + presenter->GetFsrSettingsRef().use_rcas = i != 0; + return; + } + if (sscanf(line, "fsr_rcas_attenuation=%f", &f) == 1) { + presenter->GetFsrSettingsRef().rcas_attenuation = f; + } } void SerializeOptionsConfig(ImGuiTextBuffer* buf) { buf->appendf("disassembler_cli_isa=%s\n", Options.disassembler_cli_isa.c_str()); buf->appendf("disassembler_cli_spv=%s\n", Options.disassembler_cli_spv.c_str()); buf->appendf("frame_dump_render_on_collapse=%d\n", Options.frame_dump_render_on_collapse); + buf->appendf("fsr_enabled=%d\n", presenter->GetFsrSettingsRef().enable); + buf->appendf("fsr_rcas_enabled=%d\n", presenter->GetFsrSettingsRef().use_rcas); + buf->appendf("fsr_rcas_attenuation=%f\n", presenter->GetFsrSettingsRef().rcas_attenuation); } } // namespace Core::Devtools diff --git a/src/core/devtools/widget/frame_graph.cpp b/src/core/devtools/widget/frame_graph.cpp index d93de571a..8f3e133f5 100644 --- a/src/core/devtools/widget/frame_graph.cpp +++ b/src/core/devtools/widget/frame_graph.cpp @@ -74,7 +74,7 @@ void FrameGraph::Draw() { if (!is_open) { return; } - SetNextWindowSize({340.0, 185.0f}, ImGuiCond_FirstUseEver); + SetNextWindowSize({308.0, 270.0f}, ImGuiCond_FirstUseEver); if (Begin("Video debug info", &is_open)) { const auto& ctx = *GImGui; const auto& io = ctx.IO; @@ -88,13 +88,20 @@ void FrameGraph::Draw() { frameRate = 1000.0f / deltaTime; } + SeparatorText("Frame graph"); + DrawFrameGraph(); + + SeparatorText("Renderer info"); + Text("Frame time: %.3f ms (%.1f FPS)", deltaTime, frameRate); Text("Presenter time: %.3f ms (%.1f FPS)", io.DeltaTime * 1000.0f, 1.0f / io.DeltaTime); Text("Flip frame: %d Gnm submit frame: %d", DebugState.flip_frame_count.load(), DebugState.gnm_frame_count.load()); - - SeparatorText("Frame graph"); - DrawFrameGraph(); + Text("Game Res: %dx%d", DebugState.game_resolution.first, + DebugState.game_resolution.second); + Text("Output Res: %dx%d", DebugState.output_resolution.first, + DebugState.output_resolution.second); + Text("FSR: %s", DebugState.is_using_fsr ? "on" : "off"); } End(); } diff --git a/src/core/devtools/widget/text_editor.cpp b/src/core/devtools/widget/text_editor.cpp index 7171cac47..12031d1ef 100644 --- a/src/core/devtools/widget/text_editor.cpp +++ b/src/core/devtools/widget/text_editor.cpp @@ -627,65 +627,56 @@ void TextEditor::HandleKeyboardInputs() { io.WantCaptureKeyboard = true; io.WantTextInput = true; - if (!IsReadOnly() && ctrl && !shift && !alt && - ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Z))) + if (!IsReadOnly() && ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGuiKey_Z)) Undo(); - else if (!IsReadOnly() && !ctrl && !shift && alt && - ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Backspace))) + else if (!IsReadOnly() && !ctrl && !shift && alt && ImGui::IsKeyPressed(ImGuiKey_Backspace)) Undo(); - else if (!IsReadOnly() && ctrl && !shift && !alt && - ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Y))) + else if (!IsReadOnly() && ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGuiKey_Y)) Redo(); - else if (!ctrl && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_UpArrow))) + else if (!ctrl && !alt && ImGui::IsKeyPressed(ImGuiKey_UpArrow)) MoveUp(1, shift); - else if (!ctrl && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_DownArrow))) + else if (!ctrl && !alt && ImGui::IsKeyPressed(ImGuiKey_DownArrow)) MoveDown(1, shift); - else if (!alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_LeftArrow))) + else if (!alt && ImGui::IsKeyPressed(ImGuiKey_LeftArrow)) MoveLeft(1, shift, ctrl); - else if (!alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_RightArrow))) + else if (!alt && ImGui::IsKeyPressed(ImGuiKey_RightArrow)) MoveRight(1, shift, ctrl); - else if (!alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_PageUp))) + else if (!alt && ImGui::IsKeyPressed(ImGuiKey_PageUp)) MoveUp(GetPageSize() - 4, shift); - else if (!alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_PageDown))) + else if (!alt && ImGui::IsKeyPressed(ImGuiKey_PageDown)) MoveDown(GetPageSize() - 4, shift); - else if (!alt && ctrl && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Home))) + else if (!alt && ctrl && ImGui::IsKeyPressed(ImGuiKey_Home)) MoveTop(shift); - else if (ctrl && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_End))) + else if (ctrl && !alt && ImGui::IsKeyPressed(ImGuiKey_End)) MoveBottom(shift); - else if (!ctrl && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Home))) + else if (!ctrl && !alt && ImGui::IsKeyPressed(ImGuiKey_Home)) MoveHome(shift); - else if (!ctrl && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_End))) + else if (!ctrl && !alt && ImGui::IsKeyPressed(ImGuiKey_End)) MoveEnd(shift); - else if (!IsReadOnly() && !ctrl && !shift && !alt && - ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Delete))) + else if (!IsReadOnly() && !ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGuiKey_Delete)) Delete(); else if (!IsReadOnly() && !ctrl && !shift && !alt && - ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Backspace))) + ImGui::IsKeyPressed(ImGuiKey_Backspace)) Backspace(); - else if (!ctrl && !shift && !alt && - ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Insert))) + else if (!ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGuiKey_Insert)) mOverwrite ^= true; - else if (ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Insert))) + else if (ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGuiKey_Insert)) Copy(); - else if (ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_C))) + else if (ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGuiKey_C)) Copy(); - else if (!IsReadOnly() && !ctrl && shift && !alt && - ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Insert))) + else if (!IsReadOnly() && !ctrl && shift && !alt && ImGui::IsKeyPressed(ImGuiKey_Insert)) Paste(); - else if (!IsReadOnly() && ctrl && !shift && !alt && - ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_V))) + else if (!IsReadOnly() && ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGuiKey_V)) Paste(); - else if (ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_X))) + else if (ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGuiKey_X)) Cut(); - else if (!ctrl && shift && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Delete))) + else if (!ctrl && shift && !alt && ImGui::IsKeyPressed(ImGuiKey_Delete)) Cut(); - else if (ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_A))) + else if (ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGuiKey_A)) SelectAll(); - else if (!IsReadOnly() && !ctrl && !shift && !alt && - ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Enter))) + else if (!IsReadOnly() && !ctrl && !shift && !alt && ImGui::IsKeyPressed(ImGuiKey_Enter)) EnterCharacter('\n', false); - else if (!IsReadOnly() && !ctrl && !alt && - ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Tab))) + else if (!IsReadOnly() && !ctrl && !alt && ImGui::IsKeyPressed(ImGuiKey_Tab)) EnterCharacter('\t', shift); if (!IsReadOnly() && !io.InputQueueCharacters.empty()) { diff --git a/src/core/file_format/pkg.cpp b/src/core/file_format/pkg.cpp deleted file mode 100644 index a6b5eb9a8..000000000 --- a/src/core/file_format/pkg.cpp +++ /dev/null @@ -1,473 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include -#include "common/io_file.h" -#include "common/logging/formatter.h" -#include "core/file_format/pkg.h" -#include "core/file_format/pkg_type.h" - -static void DecompressPFSC(std::span compressed_data, std::span decompressed_data) { - z_stream decompressStream; - decompressStream.zalloc = Z_NULL; - decompressStream.zfree = Z_NULL; - decompressStream.opaque = Z_NULL; - - if (inflateInit(&decompressStream) != Z_OK) { - // std::cerr << "Error initializing zlib for deflation." << std::endl; - } - - decompressStream.avail_in = compressed_data.size(); - decompressStream.next_in = reinterpret_cast(compressed_data.data()); - decompressStream.avail_out = decompressed_data.size(); - decompressStream.next_out = reinterpret_cast(decompressed_data.data()); - - if (inflate(&decompressStream, Z_FINISH)) { - } - if (inflateEnd(&decompressStream) != Z_OK) { - // std::cerr << "Error ending zlib inflate" << std::endl; - } -} - -u32 GetPFSCOffset(std::span pfs_image) { - static constexpr u32 PfscMagic = 0x43534650; - u32 value; - for (u32 i = 0x20000; i < pfs_image.size(); i += 0x10000) { - std::memcpy(&value, &pfs_image[i], sizeof(u32)); - if (value == PfscMagic) - return i; - } - return -1; -} - -PKG::PKG() = default; - -PKG::~PKG() = default; - -bool PKG::Open(const std::filesystem::path& filepath, std::string& failreason) { - Common::FS::IOFile file(filepath, Common::FS::FileAccessMode::Read); - if (!file.IsOpen()) { - return false; - } - pkgSize = file.GetSize(); - - file.Read(pkgheader); - if (pkgheader.magic != 0x7F434E54) - return false; - - for (const auto& flag : flagNames) { - if (isFlagSet(pkgheader.pkg_content_flags, flag.first)) { - if (!pkgFlags.empty()) - pkgFlags += (", "); - pkgFlags += (flag.second); - } - } - - // Find title id it is part of pkg_content_id starting at offset 0x40 - file.Seek(0x47); // skip first 7 characters of content_id - file.Read(pkgTitleID); - - u32 offset = pkgheader.pkg_table_entry_offset; - u32 n_files = pkgheader.pkg_table_entry_count; - - if (!file.Seek(offset)) { - failreason = "Failed to seek to PKG table entry offset"; - return false; - } - - for (int i = 0; i < n_files; i++) { - PKGEntry entry{}; - file.Read(entry.id); - file.Read(entry.filename_offset); - file.Read(entry.flags1); - file.Read(entry.flags2); - file.Read(entry.offset); - file.Read(entry.size); - file.Seek(8, Common::FS::SeekOrigin::CurrentPosition); - - // Try to figure out the name - const auto name = GetEntryNameByType(entry.id); - if (name == "param.sfo") { - sfo.clear(); - if (!file.Seek(entry.offset)) { - failreason = "Failed to seek to param.sfo offset"; - return false; - } - sfo.resize(entry.size); - file.ReadRaw(sfo.data(), entry.size); - } - } - file.Close(); - - return true; -} - -bool PKG::Extract(const std::filesystem::path& filepath, const std::filesystem::path& extract, - std::string& failreason) { - extract_path = extract; - pkgpath = filepath; - Common::FS::IOFile file(filepath, Common::FS::FileAccessMode::Read); - if (!file.IsOpen()) { - return false; - } - pkgSize = file.GetSize(); - file.ReadRaw(&pkgheader, sizeof(PKGHeader)); - - if (pkgheader.magic != 0x7F434E54) - return false; - - if (pkgheader.pkg_size > pkgSize) { - failreason = "PKG file size is different"; - return false; - } - if ((pkgheader.pkg_content_size + pkgheader.pkg_content_offset) > pkgheader.pkg_size) { - failreason = "Content size is bigger than pkg size"; - return false; - } - - u32 offset = pkgheader.pkg_table_entry_offset; - u32 n_files = pkgheader.pkg_table_entry_count; - - std::array concatenated_ivkey_dk3; - std::array seed_digest; - std::array, 7> digest1; - std::array, 7> key1; - std::array imgkeydata; - - if (!file.Seek(offset)) { - failreason = "Failed to seek to PKG table entry offset"; - return false; - } - - for (int i = 0; i < n_files; i++) { - PKGEntry entry{}; - file.Read(entry.id); - file.Read(entry.filename_offset); - file.Read(entry.flags1); - file.Read(entry.flags2); - file.Read(entry.offset); - file.Read(entry.size); - file.Seek(8, Common::FS::SeekOrigin::CurrentPosition); - - auto currentPos = file.Tell(); - - // Try to figure out the name - const auto name = GetEntryNameByType(entry.id); - const auto filepath = extract_path / "sce_sys" / name; - std::filesystem::create_directories(filepath.parent_path()); - - if (name.empty()) { - // Just print with id - Common::FS::IOFile out(extract_path / "sce_sys" / std::to_string(entry.id), - Common::FS::FileAccessMode::Write); - if (!file.Seek(entry.offset)) { - failreason = "Failed to seek to PKG entry offset"; - return false; - } - - std::vector data; - data.resize(entry.size); - file.ReadRaw(data.data(), entry.size); - out.WriteRaw(data.data(), entry.size); - out.Close(); - - file.Seek(currentPos); - continue; - } - - if (entry.id == 0x1) { // DIGESTS, seek; - // file.Seek(entry.offset, fsSeekSet); - } else if (entry.id == 0x10) { // ENTRY_KEYS, seek; - file.Seek(entry.offset); - file.Read(seed_digest); - - for (int i = 0; i < 7; i++) { - file.Read(digest1[i]); - } - - for (int i = 0; i < 7; i++) { - file.Read(key1[i]); - } - - PKG::crypto.RSA2048Decrypt(dk3_, key1[3], true); // decrypt DK3 - } else if (entry.id == 0x20) { // IMAGE_KEY, seek; IV_KEY - file.Seek(entry.offset); - file.Read(imgkeydata); - - // The Concatenated iv + dk3 imagekey for HASH256 - std::memcpy(concatenated_ivkey_dk3.data(), &entry, sizeof(entry)); - std::memcpy(concatenated_ivkey_dk3.data() + sizeof(entry), dk3_.data(), sizeof(dk3_)); - - PKG::crypto.ivKeyHASH256(concatenated_ivkey_dk3, ivKey); // ivkey_ - // imgkey_ to use for last step to get ekpfs - PKG::crypto.aesCbcCfb128Decrypt(ivKey, imgkeydata, imgKey); - // ekpfs key to get data and tweak keys. - PKG::crypto.RSA2048Decrypt(ekpfsKey, imgKey, false); - } else if (entry.id == 0x80) { - // GENERAL_DIGESTS, seek; - // file.Seek(entry.offset, fsSeekSet); - } - - Common::FS::IOFile out(extract_path / "sce_sys" / name, Common::FS::FileAccessMode::Write); - if (!file.Seek(entry.offset)) { - failreason = "Failed to seek to PKG entry offset"; - return false; - } - - std::vector data; - data.resize(entry.size); - file.ReadRaw(data.data(), entry.size); - out.WriteRaw(data.data(), entry.size); - out.Close(); - - // Decrypt Np stuff and overwrite. - if (entry.id == 0x400 || entry.id == 0x401 || entry.id == 0x402 || - entry.id == 0x403) { // somehow 0x401 is not decrypting - decNp.resize(entry.size); - if (!file.Seek(entry.offset)) { - failreason = "Failed to seek to PKG entry offset"; - return false; - } - - std::vector data; - data.resize(entry.size); - file.ReadRaw(data.data(), entry.size); - - std::span cipherNp(data.data(), entry.size); - std::array concatenated_ivkey_dk3_; - std::memcpy(concatenated_ivkey_dk3_.data(), &entry, sizeof(entry)); - std::memcpy(concatenated_ivkey_dk3_.data() + sizeof(entry), dk3_.data(), sizeof(dk3_)); - PKG::crypto.ivKeyHASH256(concatenated_ivkey_dk3_, ivKey); - PKG::crypto.aesCbcCfb128DecryptEntry(ivKey, cipherNp, decNp); - - Common::FS::IOFile out(extract_path / "sce_sys" / name, - Common::FS::FileAccessMode::Write); - out.Write(decNp); - out.Close(); - } - - file.Seek(currentPos); - } - - // Read the seed - std::array seed; - if (!file.Seek(pkgheader.pfs_image_offset + 0x370)) { - failreason = "Failed to seek to PFS image offset"; - return false; - } - file.Read(seed); - - // Get data and tweak keys. - PKG::crypto.PfsGenCryptoKey(ekpfsKey, seed, dataKey, tweakKey); - const u32 length = pkgheader.pfs_cache_size * 0x2; // Seems to be ok. - - int num_blocks = 0; - std::vector pfsc(length); - if (length != 0) { - // Read encrypted pfs_image - std::vector pfs_encrypted(length); - file.Seek(pkgheader.pfs_image_offset); - file.Read(pfs_encrypted); - file.Close(); - // Decrypt the pfs_image. - std::vector pfs_decrypted(length); - PKG::crypto.decryptPFS(dataKey, tweakKey, pfs_encrypted, pfs_decrypted, 0); - - // Retrieve PFSC from decrypted pfs_image. - pfsc_offset = GetPFSCOffset(pfs_decrypted); - std::memcpy(pfsc.data(), pfs_decrypted.data() + pfsc_offset, length - pfsc_offset); - - PFSCHdr pfsChdr; - std::memcpy(&pfsChdr, pfsc.data(), sizeof(pfsChdr)); - - num_blocks = (int)(pfsChdr.data_length / pfsChdr.block_sz2); - sectorMap.resize(num_blocks + 1); // 8 bytes, need extra 1 to get the last offset. - - for (int i = 0; i < num_blocks + 1; i++) { - std::memcpy(§orMap[i], pfsc.data() + pfsChdr.block_offsets + i * 8, 8); - } - } - - u32 ent_size = 0; - u32 ndinode = 0; - int ndinode_counter = 0; - bool dinode_reached = false; - bool uroot_reached = false; - std::vector compressedData; - std::vector decompressedData(0x10000); - - // Get iNdoes and Dirents. - for (int i = 0; i < num_blocks; i++) { - const u64 sectorOffset = sectorMap[i]; - const u64 sectorSize = sectorMap[i + 1] - sectorOffset; - - compressedData.resize(sectorSize); - std::memcpy(compressedData.data(), pfsc.data() + sectorOffset, sectorSize); - - if (sectorSize == 0x10000) // Uncompressed data - std::memcpy(decompressedData.data(), compressedData.data(), 0x10000); - else if (sectorSize < 0x10000) // Compressed data - DecompressPFSC(compressedData, decompressedData); - - if (i == 0) { - std::memcpy(&ndinode, decompressedData.data() + 0x30, 4); // number of folders and files - } - - int occupied_blocks = - (ndinode * 0xA8) / 0x10000; // how many blocks(0x10000) are taken by iNodes. - if (((ndinode * 0xA8) % 0x10000) != 0) - occupied_blocks += 1; - - if (i >= 1 && i <= occupied_blocks) { // Get all iNodes, gives type, file size and location. - for (int p = 0; p < 0x10000; p += 0xA8) { - Inode node; - std::memcpy(&node, &decompressedData[p], sizeof(node)); - if (node.Mode == 0) { - break; - } - iNodeBuf.push_back(node); - } - } - - // let's deal with the root/uroot entries here. - // Sometimes it's more than 2 entries (Tomb Raider Remastered) - const std::string_view flat_path_table(&decompressedData[0x10], 15); - if (flat_path_table == "flat_path_table") { - uroot_reached = true; - } - - if (uroot_reached) { - for (int i = 0; i < 0x10000; i += ent_size) { - Dirent dirent; - std::memcpy(&dirent, &decompressedData[i], sizeof(dirent)); - ent_size = dirent.entsize; - if (dirent.ino != 0) { - ndinode_counter++; - } else { - // Set the the folder according to the current inode. - // Can be 2 or more (rarely) - auto parent_path = extract_path.parent_path(); - auto title_id = GetTitleID(); - - if (parent_path.filename() != title_id && - !fmt::UTF(extract_path.u8string()).data.ends_with("-UPDATE")) { - extractPaths[ndinode_counter] = parent_path / title_id; - } else { - // DLCs path has different structure - extractPaths[ndinode_counter] = extract_path; - } - uroot_reached = false; - break; - } - } - } - - const char dot = decompressedData[0x10]; - const std::string_view dotdot(&decompressedData[0x28], 2); - if (dot == '.' && dotdot == "..") { - dinode_reached = true; - } - - // Get folder and file names. - bool end_reached = false; - if (dinode_reached) { - for (int j = 0; j < 0x10000; j += ent_size) { // Skip the first parent and child. - Dirent dirent; - std::memcpy(&dirent, &decompressedData[j], sizeof(dirent)); - - // Stop here and continue the main loop - if (dirent.ino == 0) { - break; - } - - ent_size = dirent.entsize; - auto& table = fsTable.emplace_back(); - table.name = std::string(dirent.name, dirent.namelen); - table.inode = dirent.ino; - table.type = dirent.type; - - if (table.type == PFS_CURRENT_DIR) { - current_dir = extractPaths[table.inode]; - } - extractPaths[table.inode] = current_dir / std::filesystem::path(table.name); - - if (table.type == PFS_FILE || table.type == PFS_DIR) { - if (table.type == PFS_DIR) { // Create dirs. - std::filesystem::create_directory(extractPaths[table.inode]); - } - ndinode_counter++; - if ((ndinode_counter + 1) == ndinode) // 1 for the image itself (root). - end_reached = true; - } - } - if (end_reached) { - break; - } - } - } - return true; -} - -void PKG::ExtractFiles(const int index) { - int inode_number = fsTable[index].inode; - int inode_type = fsTable[index].type; - std::string inode_name = fsTable[index].name; - - if (inode_type == PFS_FILE) { - int sector_loc = iNodeBuf[inode_number].loc; - int nblocks = iNodeBuf[inode_number].Blocks; - int bsize = iNodeBuf[inode_number].Size; - - Common::FS::IOFile inflated; - inflated.Open(extractPaths[inode_number], Common::FS::FileAccessMode::Write); - - Common::FS::IOFile pkgFile; // Open the file for each iteration to avoid conflict. - pkgFile.Open(pkgpath, Common::FS::FileAccessMode::Read); - - int size_decompressed = 0; - std::vector compressedData; - std::vector decompressedData(0x10000); - - u64 pfsc_buf_size = 0x11000; // extra 0x1000 - std::vector pfsc(pfsc_buf_size); - std::vector pfs_decrypted(pfsc_buf_size); - - for (int j = 0; j < nblocks; j++) { - u64 sectorOffset = - sectorMap[sector_loc + j]; // offset into PFSC_image and not pfs_image. - u64 sectorSize = sectorMap[sector_loc + j + 1] - - sectorOffset; // indicates if data is compressed or not. - u64 fileOffset = (pkgheader.pfs_image_offset + pfsc_offset + sectorOffset); - u64 currentSector1 = - (pfsc_offset + sectorOffset) / 0x1000; // block size is 0x1000 for xts decryption. - - int sectorOffsetMask = (sectorOffset + pfsc_offset) & 0xFFFFF000; - int previousData = (sectorOffset + pfsc_offset) - sectorOffsetMask; - - pkgFile.Seek(fileOffset - previousData); - pkgFile.Read(pfsc); - - PKG::crypto.decryptPFS(dataKey, tweakKey, pfsc, pfs_decrypted, currentSector1); - - compressedData.resize(sectorSize); - std::memcpy(compressedData.data(), pfs_decrypted.data() + previousData, sectorSize); - - if (sectorSize == 0x10000) // Uncompressed data - std::memcpy(decompressedData.data(), compressedData.data(), 0x10000); - else if (sectorSize < 0x10000) // Compressed data - DecompressPFSC(compressedData, decompressedData); - - size_decompressed += 0x10000; - - if (j < nblocks - 1) { - inflated.WriteRaw(decompressedData.data(), decompressedData.size()); - } else { - // This is to remove the zeros at the end of the file. - const u32 write_size = decompressedData.size() - (size_decompressed - bsize); - inflated.WriteRaw(decompressedData.data(), write_size); - } - } - pkgFile.Close(); - inflated.Close(); - } -} diff --git a/src/core/file_format/pkg.h b/src/core/file_format/pkg.h deleted file mode 100644 index a488a2df8..000000000 --- a/src/core/file_format/pkg.h +++ /dev/null @@ -1,174 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include -#include -#include -#include -#include -#include "common/endian.h" -#include "core/crypto/crypto.h" -#include "pfs.h" -#include "trp.h" - -struct PKGHeader { - u32_be magic; // Magic - u32_be pkg_type; - u32_be pkg_0x8; // unknown field - u32_be pkg_file_count; - u32_be pkg_table_entry_count; - u16_be pkg_sc_entry_count; - u16_be pkg_table_entry_count_2; // same as pkg_entry_count - u32_be pkg_table_entry_offset; // file table offset - u32_be pkg_sc_entry_data_size; - u64_be pkg_body_offset; // offset of PKG entries - u64_be pkg_body_size; // length of all PKG entries - u64_be pkg_content_offset; - u64_be pkg_content_size; - u8 pkg_content_id[0x24]; // packages' content ID as a 36-byte string - u8 pkg_padding[0xC]; // padding - u32_be pkg_drm_type; // DRM type - u32_be pkg_content_type; // Content type - u32_be pkg_content_flags; // Content flags - u32_be pkg_promote_size; - u32_be pkg_version_date; - u32_be pkg_version_hash; - u32_be pkg_0x088; - u32_be pkg_0x08C; - u32_be pkg_0x090; - u32_be pkg_0x094; - u32_be pkg_iro_tag; - u32_be pkg_drm_type_version; - - u8 pkg_zeroes_1[0x60]; - - /* Digest table */ - u8 digest_entries1[0x20]; // sha256 digest for main entry 1 - u8 digest_entries2[0x20]; // sha256 digest for main entry 2 - u8 digest_table_digest[0x20]; // sha256 digest for digest table - u8 digest_body_digest[0x20]; // sha256 digest for main table - - u8 pkg_zeroes_2[0x280]; - - u32_be pkg_0x400; - - u32_be pfs_image_count; // count of PFS images - u64_be pfs_image_flags; // PFS flags - u64_be pfs_image_offset; // offset to start of external PFS image - u64_be pfs_image_size; // size of external PFS image - u64_be mount_image_offset; - u64_be mount_image_size; - u64_be pkg_size; - u32_be pfs_signed_size; - u32_be pfs_cache_size; - u8 pfs_image_digest[0x20]; - u8 pfs_signed_digest[0x20]; - u64_be pfs_split_size_nth_0; - u64_be pfs_split_size_nth_1; - - u8 pkg_zeroes_3[0xB50]; - - u8 pkg_digest[0x20]; -}; - -enum class PKGContentFlag { - FIRST_PATCH = 0x100000, - PATCHGO = 0x200000, - REMASTER = 0x400000, - PS_CLOUD = 0x800000, - GD_AC = 0x2000000, - NON_GAME = 0x4000000, - UNKNOWN_0x8000000 = 0x8000000, - SUBSEQUENT_PATCH = 0x40000000, - DELTA_PATCH = 0x41000000, - CUMULATIVE_PATCH = 0x60000000 -}; - -struct PKGEntry { - u32_be id; // File ID, useful for files without a filename entry - u32_be filename_offset; // Offset into the filenames table (ID 0x200) where this file's name is - // located - u32_be flags1; // Flags including encrypted flag, etc - u32_be flags2; // Flags including encryption key index, etc - u32_be offset; // Offset into PKG to find the file - u32_be size; // Size of the file - u64_be padding; // blank padding -}; -static_assert(sizeof(PKGEntry) == 32); - -class PKG { -public: - PKG(); - ~PKG(); - - bool Open(const std::filesystem::path& filepath, std::string& failreason); - void ExtractFiles(const int index); - bool Extract(const std::filesystem::path& filepath, const std::filesystem::path& extract, - std::string& failreason); - - std::vector sfo; - - u32 GetNumberOfFiles() { - return fsTable.size(); - } - - u64 GetPkgSize() { - return pkgSize; - } - - std::string GetPkgFlags() { - return pkgFlags; - } - - std::string_view GetTitleID() { - return std::string_view(pkgTitleID, 9); - } - - PKGHeader GetPkgHeader() { - return pkgheader; - } - - static bool isFlagSet(u32_be variable, PKGContentFlag flag) { - return (variable) & static_cast(flag); - } - - static constexpr std::array, 10> flagNames = { - {{PKGContentFlag::FIRST_PATCH, "FIRST_PATCH"}, - {PKGContentFlag::PATCHGO, "PATCHGO"}, - {PKGContentFlag::REMASTER, "REMASTER"}, - {PKGContentFlag::PS_CLOUD, "PS_CLOUD"}, - {PKGContentFlag::GD_AC, "GD_AC"}, - {PKGContentFlag::NON_GAME, "NON_GAME"}, - {PKGContentFlag::UNKNOWN_0x8000000, "UNKNOWN_0x8000000"}, - {PKGContentFlag::SUBSEQUENT_PATCH, "SUBSEQUENT_PATCH"}, - {PKGContentFlag::DELTA_PATCH, "DELTA_PATCH"}, - {PKGContentFlag::CUMULATIVE_PATCH, "CUMULATIVE_PATCH"}}}; - -private: - Crypto crypto; - TRP trp; - u64 pkgSize = 0; - char pkgTitleID[9]; - PKGHeader pkgheader; - std::string pkgFlags; - - std::unordered_map extractPaths; - std::vector fsTable; - std::vector iNodeBuf; - std::vector sectorMap; - u64 pfsc_offset; - - std::array dk3_; - std::array ivKey; - std::array imgKey; - std::array ekpfsKey; - std::array dataKey; - std::array tweakKey; - std::vector decNp; - - std::filesystem::path pkgpath; - std::filesystem::path current_dir; - std::filesystem::path extract_path; -}; diff --git a/src/core/file_format/pkg_type.cpp b/src/core/file_format/pkg_type.cpp deleted file mode 100644 index 464f0b993..000000000 --- a/src/core/file_format/pkg_type.cpp +++ /dev/null @@ -1,638 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include -#include -#include "pkg_type.h" - -struct PkgEntryValue { - u32 type; - std::string_view name; - - operator u32() const noexcept { - return type; - } -}; - -constexpr static std::array PkgEntries = {{ - {0x0001, "digests"}, - {0x0010, "entry_keys"}, - {0x0020, "image_key"}, - {0x0080, "general_digests"}, - {0x0100, "metas"}, - {0x0200, "entry_names"}, - {0x0400, "license.dat"}, - {0x0401, "license.info"}, - {0x0402, "nptitle.dat"}, - {0x0403, "npbind.dat"}, - {0x0404, "selfinfo.dat"}, - {0x0406, "imageinfo.dat"}, - {0x0407, "target-deltainfo.dat"}, - {0x0408, "origin-deltainfo.dat"}, - {0x0409, "psreserved.dat"}, - {0x1000, "param.sfo"}, - {0x1001, "playgo-chunk.dat"}, - {0x1002, "playgo-chunk.sha"}, - {0x1003, "playgo-manifest.xml"}, - {0x1004, "pronunciation.xml"}, - {0x1005, "pronunciation.sig"}, - {0x1006, "pic1.png"}, - {0x1007, "pubtoolinfo.dat"}, - {0x1008, "app/playgo-chunk.dat"}, - {0x1009, "app/playgo-chunk.sha"}, - {0x100A, "app/playgo-manifest.xml"}, - {0x100B, "shareparam.json"}, - {0x100C, "shareoverlayimage.png"}, - {0x100D, "save_data.png"}, - {0x100E, "shareprivacyguardimage.png"}, - {0x1200, "icon0.png"}, - {0x1201, "icon0_00.png"}, - {0x1202, "icon0_01.png"}, - {0x1203, "icon0_02.png"}, - {0x1204, "icon0_03.png"}, - {0x1205, "icon0_04.png"}, - {0x1206, "icon0_05.png"}, - {0x1207, "icon0_06.png"}, - {0x1208, "icon0_07.png"}, - {0x1209, "icon0_08.png"}, - {0x120A, "icon0_09.png"}, - {0x120B, "icon0_10.png"}, - {0x120C, "icon0_11.png"}, - {0x120D, "icon0_12.png"}, - {0x120E, "icon0_13.png"}, - {0x120F, "icon0_14.png"}, - {0x1210, "icon0_15.png"}, - {0x1211, "icon0_16.png"}, - {0x1212, "icon0_17.png"}, - {0x1213, "icon0_18.png"}, - {0x1214, "icon0_19.png"}, - {0x1215, "icon0_20.png"}, - {0x1216, "icon0_21.png"}, - {0x1217, "icon0_22.png"}, - {0x1218, "icon0_23.png"}, - {0x1219, "icon0_24.png"}, - {0x121A, "icon0_25.png"}, - {0x121B, "icon0_26.png"}, - {0x121C, "icon0_27.png"}, - {0x121D, "icon0_28.png"}, - {0x121E, "icon0_29.png"}, - {0x121F, "icon0_30.png"}, - {0x1220, "pic0.png"}, - {0x1240, "snd0.at9"}, - {0x1241, "pic1_00.png"}, - {0x1242, "pic1_01.png"}, - {0x1243, "pic1_02.png"}, - {0x1244, "pic1_03.png"}, - {0x1245, "pic1_04.png"}, - {0x1246, "pic1_05.png"}, - {0x1247, "pic1_06.png"}, - {0x1248, "pic1_07.png"}, - {0x1249, "pic1_08.png"}, - {0x124A, "pic1_09.png"}, - {0x124B, "pic1_10.png"}, - {0x124C, "pic1_11.png"}, - {0x124D, "pic1_12.png"}, - {0x124E, "pic1_13.png"}, - {0x124F, "pic1_14.png"}, - {0x1250, "pic1_15.png"}, - {0x1251, "pic1_16.png"}, - {0x1252, "pic1_17.png"}, - {0x1253, "pic1_18.png"}, - {0x1254, "pic1_19.png"}, - {0x1255, "pic1_20.png"}, - {0x1256, "pic1_21.png"}, - {0x1257, "pic1_22.png"}, - {0x1258, "pic1_23.png"}, - {0x1259, "pic1_24.png"}, - {0x125A, "pic1_25.png"}, - {0x125B, "pic1_26.png"}, - {0x125C, "pic1_27.png"}, - {0x125D, "pic1_28.png"}, - {0x125E, "pic1_29.png"}, - {0x125F, "pic1_30.png"}, - {0x1260, "changeinfo/changeinfo.xml"}, - {0x1261, "changeinfo/changeinfo_00.xml"}, - {0x1262, "changeinfo/changeinfo_01.xml"}, - {0x1263, "changeinfo/changeinfo_02.xml"}, - {0x1264, "changeinfo/changeinfo_03.xml"}, - {0x1265, "changeinfo/changeinfo_04.xml"}, - {0x1266, "changeinfo/changeinfo_05.xml"}, - {0x1267, "changeinfo/changeinfo_06.xml"}, - {0x1268, "changeinfo/changeinfo_07.xml"}, - {0x1269, "changeinfo/changeinfo_08.xml"}, - {0x126A, "changeinfo/changeinfo_09.xml"}, - {0x126B, "changeinfo/changeinfo_10.xml"}, - {0x126C, "changeinfo/changeinfo_11.xml"}, - {0x126D, "changeinfo/changeinfo_12.xml"}, - {0x126E, "changeinfo/changeinfo_13.xml"}, - {0x126F, "changeinfo/changeinfo_14.xml"}, - {0x1270, "changeinfo/changeinfo_15.xml"}, - {0x1271, "changeinfo/changeinfo_16.xml"}, - {0x1272, "changeinfo/changeinfo_17.xml"}, - {0x1273, "changeinfo/changeinfo_18.xml"}, - {0x1274, "changeinfo/changeinfo_19.xml"}, - {0x1275, "changeinfo/changeinfo_20.xml"}, - {0x1276, "changeinfo/changeinfo_21.xml"}, - {0x1277, "changeinfo/changeinfo_22.xml"}, - {0x1278, "changeinfo/changeinfo_23.xml"}, - {0x1279, "changeinfo/changeinfo_24.xml"}, - {0x127A, "changeinfo/changeinfo_25.xml"}, - {0x127B, "changeinfo/changeinfo_26.xml"}, - {0x127C, "changeinfo/changeinfo_27.xml"}, - {0x127D, "changeinfo/changeinfo_28.xml"}, - {0x127E, "changeinfo/changeinfo_29.xml"}, - {0x127F, "changeinfo/changeinfo_30.xml"}, - {0x1280, "icon0.dds"}, - {0x1281, "icon0_00.dds"}, - {0x1282, "icon0_01.dds"}, - {0x1283, "icon0_02.dds"}, - {0x1284, "icon0_03.dds"}, - {0x1285, "icon0_04.dds"}, - {0x1286, "icon0_05.dds"}, - {0x1287, "icon0_06.dds"}, - {0x1288, "icon0_07.dds"}, - {0x1289, "icon0_08.dds"}, - {0x128A, "icon0_09.dds"}, - {0x128B, "icon0_10.dds"}, - {0x128C, "icon0_11.dds"}, - {0x128D, "icon0_12.dds"}, - {0x128E, "icon0_13.dds"}, - {0x128F, "icon0_14.dds"}, - {0x1290, "icon0_15.dds"}, - {0x1291, "icon0_16.dds"}, - {0x1292, "icon0_17.dds"}, - {0x1293, "icon0_18.dds"}, - {0x1294, "icon0_19.dds"}, - {0x1295, "icon0_20.dds"}, - {0x1296, "icon0_21.dds"}, - {0x1297, "icon0_22.dds"}, - {0x1298, "icon0_23.dds"}, - {0x1299, "icon0_24.dds"}, - {0x129A, "icon0_25.dds"}, - {0x129B, "icon0_26.dds"}, - {0x129C, "icon0_27.dds"}, - {0x129D, "icon0_28.dds"}, - {0x129E, "icon0_29.dds"}, - {0x129F, "icon0_30.dds"}, - {0x12A0, "pic0.dds"}, - {0x12C0, "pic1.dds"}, - {0x12C1, "pic1_00.dds"}, - {0x12C2, "pic1_01.dds"}, - {0x12C3, "pic1_02.dds"}, - {0x12C4, "pic1_03.dds"}, - {0x12C5, "pic1_04.dds"}, - {0x12C6, "pic1_05.dds"}, - {0x12C7, "pic1_06.dds"}, - {0x12C8, "pic1_07.dds"}, - {0x12C9, "pic1_08.dds"}, - {0x12CA, "pic1_09.dds"}, - {0x12CB, "pic1_10.dds"}, - {0x12CC, "pic1_11.dds"}, - {0x12CD, "pic1_12.dds"}, - {0x12CE, "pic1_13.dds"}, - {0x12CF, "pic1_14.dds"}, - {0x12D0, "pic1_15.dds"}, - {0x12D1, "pic1_16.dds"}, - {0x12D2, "pic1_17.dds"}, - {0x12D3, "pic1_18.dds"}, - {0x12D4, "pic1_19.dds"}, - {0x12D5, "pic1_20.dds"}, - {0x12D6, "pic1_21.dds"}, - {0x12D7, "pic1_22.dds"}, - {0x12D8, "pic1_23.dds"}, - {0x12D9, "pic1_24.dds"}, - {0x12DA, "pic1_25.dds"}, - {0x12DB, "pic1_26.dds"}, - {0x12DC, "pic1_27.dds"}, - {0x12DD, "pic1_28.dds"}, - {0x12DE, "pic1_29.dds"}, - {0x12DF, "pic1_30.dds"}, - {0x1400, "trophy/trophy00.trp"}, - {0x1401, "trophy/trophy01.trp"}, - {0x1402, "trophy/trophy02.trp"}, - {0x1403, "trophy/trophy03.trp"}, - {0x1404, "trophy/trophy04.trp"}, - {0x1405, "trophy/trophy05.trp"}, - {0x1406, "trophy/trophy06.trp"}, - {0x1407, "trophy/trophy07.trp"}, - {0x1408, "trophy/trophy08.trp"}, - {0x1409, "trophy/trophy09.trp"}, - {0x140A, "trophy/trophy10.trp"}, - {0x140B, "trophy/trophy11.trp"}, - {0x140C, "trophy/trophy12.trp"}, - {0x140D, "trophy/trophy13.trp"}, - {0x140E, "trophy/trophy14.trp"}, - {0x140F, "trophy/trophy15.trp"}, - {0x1410, "trophy/trophy16.trp"}, - {0x1411, "trophy/trophy17.trp"}, - {0x1412, "trophy/trophy18.trp"}, - {0x1413, "trophy/trophy19.trp"}, - {0x1414, "trophy/trophy20.trp"}, - {0x1415, "trophy/trophy21.trp"}, - {0x1416, "trophy/trophy22.trp"}, - {0x1417, "trophy/trophy23.trp"}, - {0x1418, "trophy/trophy24.trp"}, - {0x1419, "trophy/trophy25.trp"}, - {0x141A, "trophy/trophy26.trp"}, - {0x141B, "trophy/trophy27.trp"}, - {0x141C, "trophy/trophy28.trp"}, - {0x141D, "trophy/trophy29.trp"}, - {0x141E, "trophy/trophy30.trp"}, - {0x141F, "trophy/trophy31.trp"}, - {0x1420, "trophy/trophy32.trp"}, - {0x1421, "trophy/trophy33.trp"}, - {0x1422, "trophy/trophy34.trp"}, - {0x1423, "trophy/trophy35.trp"}, - {0x1424, "trophy/trophy36.trp"}, - {0x1425, "trophy/trophy37.trp"}, - {0x1426, "trophy/trophy38.trp"}, - {0x1427, "trophy/trophy39.trp"}, - {0x1428, "trophy/trophy40.trp"}, - {0x1429, "trophy/trophy41.trp"}, - {0x142A, "trophy/trophy42.trp"}, - {0x142B, "trophy/trophy43.trp"}, - {0x142C, "trophy/trophy44.trp"}, - {0x142D, "trophy/trophy45.trp"}, - {0x142E, "trophy/trophy46.trp"}, - {0x142F, "trophy/trophy47.trp"}, - {0x1430, "trophy/trophy48.trp"}, - {0x1431, "trophy/trophy49.trp"}, - {0x1432, "trophy/trophy50.trp"}, - {0x1433, "trophy/trophy51.trp"}, - {0x1434, "trophy/trophy52.trp"}, - {0x1435, "trophy/trophy53.trp"}, - {0x1436, "trophy/trophy54.trp"}, - {0x1437, "trophy/trophy55.trp"}, - {0x1438, "trophy/trophy56.trp"}, - {0x1439, "trophy/trophy57.trp"}, - {0x143A, "trophy/trophy58.trp"}, - {0x143B, "trophy/trophy59.trp"}, - {0x143C, "trophy/trophy60.trp"}, - {0x143D, "trophy/trophy61.trp"}, - {0x143E, "trophy/trophy62.trp"}, - {0x143F, "trophy/trophy63.trp"}, - {0x1440, "trophy/trophy64.trp"}, - {0x1441, "trophy/trophy65.trp"}, - {0x1442, "trophy/trophy66.trp"}, - {0x1443, "trophy/trophy67.trp"}, - {0x1444, "trophy/trophy68.trp"}, - {0x1445, "trophy/trophy69.trp"}, - {0x1446, "trophy/trophy70.trp"}, - {0x1447, "trophy/trophy71.trp"}, - {0x1448, "trophy/trophy72.trp"}, - {0x1449, "trophy/trophy73.trp"}, - {0x144A, "trophy/trophy74.trp"}, - {0x144B, "trophy/trophy75.trp"}, - {0x144C, "trophy/trophy76.trp"}, - {0x144D, "trophy/trophy77.trp"}, - {0x144E, "trophy/trophy78.trp"}, - {0x144F, "trophy/trophy79.trp"}, - {0x1450, "trophy/trophy80.trp"}, - {0x1451, "trophy/trophy81.trp"}, - {0x1452, "trophy/trophy82.trp"}, - {0x1453, "trophy/trophy83.trp"}, - {0x1454, "trophy/trophy84.trp"}, - {0x1455, "trophy/trophy85.trp"}, - {0x1456, "trophy/trophy86.trp"}, - {0x1457, "trophy/trophy87.trp"}, - {0x1458, "trophy/trophy88.trp"}, - {0x1459, "trophy/trophy89.trp"}, - {0x145A, "trophy/trophy90.trp"}, - {0x145B, "trophy/trophy91.trp"}, - {0x145C, "trophy/trophy92.trp"}, - {0x145D, "trophy/trophy93.trp"}, - {0x145E, "trophy/trophy94.trp"}, - {0x145F, "trophy/trophy95.trp"}, - {0x1460, "trophy/trophy96.trp"}, - {0x1461, "trophy/trophy97.trp"}, - {0x1462, "trophy/trophy98.trp"}, - {0x1463, "trophy/trophy99.trp"}, - {0x1600, "keymap_rp/001.png"}, - {0x1601, "keymap_rp/002.png"}, - {0x1602, "keymap_rp/003.png"}, - {0x1603, "keymap_rp/004.png"}, - {0x1604, "keymap_rp/005.png"}, - {0x1605, "keymap_rp/006.png"}, - {0x1606, "keymap_rp/007.png"}, - {0x1607, "keymap_rp/008.png"}, - {0x1608, "keymap_rp/009.png"}, - {0x1609, "keymap_rp/010.png"}, - {0x1610, "keymap_rp/00/001.png"}, - {0x1611, "keymap_rp/00/002.png"}, - {0x1612, "keymap_rp/00/003.png"}, - {0x1613, "keymap_rp/00/004.png"}, - {0x1614, "keymap_rp/00/005.png"}, - {0x1615, "keymap_rp/00/006.png"}, - {0x1616, "keymap_rp/00/007.png"}, - {0x1617, "keymap_rp/00/008.png"}, - {0x1618, "keymap_rp/00/009.png"}, - {0x1619, "keymap_rp/00/010.png"}, - {0x1620, "keymap_rp/01/001.png"}, - {0x1621, "keymap_rp/01/002.png"}, - {0x1622, "keymap_rp/01/003.png"}, - {0x1623, "keymap_rp/01/004.png"}, - {0x1624, "keymap_rp/01/005.png"}, - {0x1625, "keymap_rp/01/006.png"}, - {0x1626, "keymap_rp/01/007.png"}, - {0x1627, "keymap_rp/01/008.png"}, - {0x1628, "keymap_rp/01/009.png"}, - {0x1629, "keymap_rp/01/010.png"}, - {0x1630, "keymap_rp/02/001.png"}, - {0x1631, "keymap_rp/02/002.png"}, - {0x1632, "keymap_rp/02/003.png"}, - {0x1633, "keymap_rp/02/004.png"}, - {0x1634, "keymap_rp/02/005.png"}, - {0x1635, "keymap_rp/02/006.png"}, - {0x1636, "keymap_rp/02/007.png"}, - {0x1637, "keymap_rp/02/008.png"}, - {0x1638, "keymap_rp/02/009.png"}, - {0x1639, "keymap_rp/02/010.png"}, - {0x1640, "keymap_rp/03/001.png"}, - {0x1641, "keymap_rp/03/002.png"}, - {0x1642, "keymap_rp/03/003.png"}, - {0x1643, "keymap_rp/03/004.png"}, - {0x1644, "keymap_rp/03/005.png"}, - {0x1645, "keymap_rp/03/006.png"}, - {0x1646, "keymap_rp/03/007.png"}, - {0x1647, "keymap_rp/03/008.png"}, - {0x1648, "keymap_rp/03/0010.png"}, - {0x1650, "keymap_rp/04/001.png"}, - {0x1651, "keymap_rp/04/002.png"}, - {0x1652, "keymap_rp/04/003.png"}, - {0x1653, "keymap_rp/04/004.png"}, - {0x1654, "keymap_rp/04/005.png"}, - {0x1655, "keymap_rp/04/006.png"}, - {0x1656, "keymap_rp/04/007.png"}, - {0x1657, "keymap_rp/04/008.png"}, - {0x1658, "keymap_rp/04/009.png"}, - {0x1659, "keymap_rp/04/010.png"}, - {0x1660, "keymap_rp/05/001.png"}, - {0x1661, "keymap_rp/05/002.png"}, - {0x1662, "keymap_rp/05/003.png"}, - {0x1663, "keymap_rp/05/004.png"}, - {0x1664, "keymap_rp/05/005.png"}, - {0x1665, "keymap_rp/05/006.png"}, - {0x1666, "keymap_rp/05/007.png"}, - {0x1667, "keymap_rp/05/008.png"}, - {0x1668, "keymap_rp/05/009.png"}, - {0x1669, "keymap_rp/05/010.png"}, - {0x1670, "keymap_rp/06/001.png"}, - {0x1671, "keymap_rp/06/002.png"}, - {0x1672, "keymap_rp/06/003.png"}, - {0x1673, "keymap_rp/06/004.png"}, - {0x1674, "keymap_rp/06/005.png"}, - {0x1675, "keymap_rp/06/006.png"}, - {0x1676, "keymap_rp/06/007.png"}, - {0x1677, "keymap_rp/06/008.png"}, - {0x1678, "keymap_rp/06/009.png"}, - {0x1679, "keymap_rp/06/010.png"}, - {0x1680, "keymap_rp/07/001.png"}, - {0x1681, "keymap_rp/07/002.png"}, - {0x1682, "keymap_rp/07/003.png"}, - {0x1683, "keymap_rp/07/004.png"}, - {0x1684, "keymap_rp/07/005.png"}, - {0x1685, "keymap_rp/07/006.png"}, - {0x1686, "keymap_rp/07/007.png"}, - {0x1687, "keymap_rp/07/008.png"}, - {0x1688, "keymap_rp/07/009.png"}, - {0x1689, "keymap_rp/07/010.png"}, - {0x1690, "keymap_rp/08/001.png"}, - {0x1691, "keymap_rp/08/002.png"}, - {0x1692, "keymap_rp/08/003.png"}, - {0x1693, "keymap_rp/08/004.png"}, - {0x1694, "keymap_rp/08/005.png"}, - {0x1695, "keymap_rp/08/006.png"}, - {0x1696, "keymap_rp/08/007.png"}, - {0x1697, "keymap_rp/08/008.png"}, - {0x1698, "keymap_rp/08/009.png"}, - {0x1699, "keymap_rp/08/010.png"}, - {0x16A0, "keymap_rp/09/001.png"}, - {0x16A1, "keymap_rp/09/002.png"}, - {0x16A2, "keymap_rp/09/003.png"}, - {0x16A3, "keymap_rp/09/004.png"}, - {0x16A4, "keymap_rp/09/005.png"}, - {0x16A5, "keymap_rp/09/006.png"}, - {0x16A6, "keymap_rp/09/007.png"}, - {0x16A7, "keymap_rp/09/008.png"}, - {0x16A8, "keymap_rp/09/009.png"}, - {0x16A9, "keymap_rp/09/010.png"}, - {0x16B0, "keymap_rp/10/001.png"}, - {0x16B1, "keymap_rp/10/002.png"}, - {0x16B2, "keymap_rp/10/003.png"}, - {0x16B3, "keymap_rp/10/004.png"}, - {0x16B4, "keymap_rp/10/005.png"}, - {0x16B5, "keymap_rp/10/006.png"}, - {0x16B6, "keymap_rp/10/007.png"}, - {0x16B7, "keymap_rp/10/008.png"}, - {0x16B8, "keymap_rp/10/009.png"}, - {0x16B9, "keymap_rp/10/010.png"}, - {0x16C0, "keymap_rp/11/001.png"}, - {0x16C1, "keymap_rp/11/002.png"}, - {0x16C2, "keymap_rp/11/003.png"}, - {0x16C3, "keymap_rp/11/004.png"}, - {0x16C4, "keymap_rp/11/005.png"}, - {0x16C5, "keymap_rp/11/006.png"}, - {0x16C6, "keymap_rp/11/007.png"}, - {0x16C7, "keymap_rp/11/008.png"}, - {0x16C8, "keymap_rp/11/009.png"}, - {0x16C9, "keymap_rp/11/010.png"}, - {0x16D0, "keymap_rp/12/001.png"}, - {0x16D1, "keymap_rp/12/002.png"}, - {0x16D2, "keymap_rp/12/003.png"}, - {0x16D3, "keymap_rp/12/004.png"}, - {0x16D4, "keymap_rp/12/005.png"}, - {0x16D5, "keymap_rp/12/006.png"}, - {0x16D6, "keymap_rp/12/007.png"}, - {0x16D7, "keymap_rp/12/008.png"}, - {0x16D8, "keymap_rp/12/009.png"}, - {0x16D9, "keymap_rp/12/010.png"}, - {0x16E0, "keymap_rp/13/001.png"}, - {0x16E1, "keymap_rp/13/002.png"}, - {0x16E2, "keymap_rp/13/003.png"}, - {0x16E3, "keymap_rp/13/004.png"}, - {0x16E4, "keymap_rp/13/005.png"}, - {0x16E5, "keymap_rp/13/006.png"}, - {0x16E6, "keymap_rp/13/007.png"}, - {0x16E7, "keymap_rp/13/008.png"}, - {0x16E8, "keymap_rp/13/009.png"}, - {0x16E9, "keymap_rp/13/010.png"}, - {0x16F0, "keymap_rp/14/001.png"}, - {0x16F1, "keymap_rp/14/002.png"}, - {0x16F2, "keymap_rp/14/003.png"}, - {0x16F3, "keymap_rp/14/004.png"}, - {0x16F4, "keymap_rp/14/005.png"}, - {0x16F5, "keymap_rp/14/006.png"}, - {0x16F6, "keymap_rp/14/007.png"}, - {0x16F7, "keymap_rp/14/008.png"}, - {0x16F8, "keymap_rp/14/009.png"}, - {0x16F9, "keymap_rp/14/010.png"}, - {0x1700, "keymap_rp/15/001.png"}, - {0x1701, "keymap_rp/15/002.png"}, - {0x1702, "keymap_rp/15/003.png"}, - {0x1703, "keymap_rp/15/004.png"}, - {0x1704, "keymap_rp/15/005.png"}, - {0x1705, "keymap_rp/15/006.png"}, - {0x1706, "keymap_rp/15/007.png"}, - {0x1707, "keymap_rp/15/008.png"}, - {0x1708, "keymap_rp/15/009.png"}, - {0x1709, "keymap_rp/15/010.png"}, - {0x1710, "keymap_rp/16/001.png"}, - {0x1711, "keymap_rp/16/002.png"}, - {0x1712, "keymap_rp/16/003.png"}, - {0x1713, "keymap_rp/16/004.png"}, - {0x1714, "keymap_rp/16/005.png"}, - {0x1715, "keymap_rp/16/006.png"}, - {0x1716, "keymap_rp/16/007.png"}, - {0x1717, "keymap_rp/16/008.png"}, - {0x1718, "keymap_rp/16/009.png"}, - {0x1719, "keymap_rp/16/010.png"}, - {0x1720, "keymap_rp/17/001.png"}, - {0x1721, "keymap_rp/17/002.png"}, - {0x1722, "keymap_rp/17/003.png"}, - {0x1723, "keymap_rp/17/004.png"}, - {0x1724, "keymap_rp/17/005.png"}, - {0x1725, "keymap_rp/17/006.png"}, - {0x1726, "keymap_rp/17/007.png"}, - {0x1727, "keymap_rp/17/008.png"}, - {0x1728, "keymap_rp/17/009.png"}, - {0x1729, "keymap_rp/17/010.png"}, - {0x1730, "keymap_rp/18/001.png"}, - {0x1731, "keymap_rp/18/002.png"}, - {0x1732, "keymap_rp/18/003.png"}, - {0x1733, "keymap_rp/18/004.png"}, - {0x1734, "keymap_rp/18/005.png"}, - {0x1735, "keymap_rp/18/006.png"}, - {0x1736, "keymap_rp/18/007.png"}, - {0x1737, "keymap_rp/18/008.png"}, - {0x1738, "keymap_rp/18/009.png"}, - {0x1739, "keymap_rp/18/010.png"}, - {0x1740, "keymap_rp/19/001.png"}, - {0x1741, "keymap_rp/19/002.png"}, - {0x1742, "keymap_rp/19/003.png"}, - {0x1743, "keymap_rp/19/004.png"}, - {0x1744, "keymap_rp/19/005.png"}, - {0x1745, "keymap_rp/19/006.png"}, - {0x1746, "keymap_rp/19/007.png"}, - {0x1747, "keymap_rp/19/008.png"}, - {0x1748, "keymap_rp/19/009.png"}, - {0x1749, "keymap_rp/19/010.png"}, - {0x1750, "keymap_rp/20/001.png"}, - {0x1751, "keymap_rp/20/002.png"}, - {0x1752, "keymap_rp/20/003.png"}, - {0x1753, "keymap_rp/20/004.png"}, - {0x1754, "keymap_rp/20/005.png"}, - {0x1755, "keymap_rp/20/006.png"}, - {0x1756, "keymap_rp/20/007.png"}, - {0x1757, "keymap_rp/20/008.png"}, - {0x1758, "keymap_rp/20/009.png"}, - {0x1759, "keymap_rp/20/010.png"}, - {0x1760, "keymap_rp/21/001.png"}, - {0x1761, "keymap_rp/21/002.png"}, - {0x1762, "keymap_rp/21/003.png"}, - {0x1763, "keymap_rp/21/004.png"}, - {0x1764, "keymap_rp/21/005.png"}, - {0x1765, "keymap_rp/21/006.png"}, - {0x1766, "keymap_rp/21/007.png"}, - {0x1767, "keymap_rp/21/008.png"}, - {0x1768, "keymap_rp/21/009.png"}, - {0x1769, "keymap_rp/21/010.png"}, - {0x1770, "keymap_rp/22/001.png"}, - {0x1771, "keymap_rp/22/002.png"}, - {0x1772, "keymap_rp/22/003.png"}, - {0x1773, "keymap_rp/22/004.png"}, - {0x1774, "keymap_rp/22/005.png"}, - {0x1775, "keymap_rp/22/006.png"}, - {0x1776, "keymap_rp/22/007.png"}, - {0x1777, "keymap_rp/22/008.png"}, - {0x1778, "keymap_rp/22/009.png"}, - {0x1779, "keymap_rp/22/010.png"}, - {0x1780, "keymap_rp/23/001.png"}, - {0x1781, "keymap_rp/23/002.png"}, - {0x1782, "keymap_rp/23/003.png"}, - {0x1783, "keymap_rp/23/004.png"}, - {0x1784, "keymap_rp/23/005.png"}, - {0x1785, "keymap_rp/23/006.png"}, - {0x1786, "keymap_rp/23/007.png"}, - {0x1787, "keymap_rp/23/008.png"}, - {0x1788, "keymap_rp/23/009.png"}, - {0x1789, "keymap_rp/23/010.png"}, - {0x1790, "keymap_rp/24/001.png"}, - {0x1791, "keymap_rp/24/002.png"}, - {0x1792, "keymap_rp/24/003.png"}, - {0x1793, "keymap_rp/24/004.png"}, - {0x1794, "keymap_rp/24/005.png"}, - {0x1795, "keymap_rp/24/006.png"}, - {0x1796, "keymap_rp/24/007.png"}, - {0x1797, "keymap_rp/24/008.png"}, - {0x1798, "keymap_rp/24/009.png"}, - {0x1799, "keymap_rp/24/010.png"}, - {0x17A0, "keymap_rp/25/001.png"}, - {0x17A1, "keymap_rp/25/002.png"}, - {0x17A2, "keymap_rp/25/003.png"}, - {0x17A3, "keymap_rp/25/004.png"}, - {0x17A4, "keymap_rp/25/005.png"}, - {0x17A5, "keymap_rp/25/006.png"}, - {0x17A6, "keymap_rp/25/007.png"}, - {0x17A7, "keymap_rp/25/008.png"}, - {0x17A8, "keymap_rp/25/009.png"}, - {0x17A9, "keymap_rp/25/010.png"}, - {0x17B0, "keymap_rp/26/001.png"}, - {0x17B1, "keymap_rp/26/002.png"}, - {0x17B2, "keymap_rp/26/003.png"}, - {0x17B3, "keymap_rp/26/004.png"}, - {0x17B4, "keymap_rp/26/005.png"}, - {0x17B5, "keymap_rp/26/006.png"}, - {0x17B6, "keymap_rp/26/007.png"}, - {0x17B7, "keymap_rp/26/008.png"}, - {0x17B8, "keymap_rp/26/009.png"}, - {0x17B9, "keymap_rp/26/010.png"}, - {0x17C0, "keymap_rp/27/001.png"}, - {0x17C1, "keymap_rp/27/002.png"}, - {0x17C2, "keymap_rp/27/003.png"}, - {0x17C3, "keymap_rp/27/004.png"}, - {0x17C4, "keymap_rp/27/005.png"}, - {0x17C5, "keymap_rp/27/006.png"}, - {0x17C6, "keymap_rp/27/007.png"}, - {0x17C7, "keymap_rp/27/008.png"}, - {0x17C8, "keymap_rp/27/009.png"}, - {0x17C9, "keymap_rp/27/010.png"}, - {0x17D0, "keymap_rp/28/001.png"}, - {0x17D1, "keymap_rp/28/002.png"}, - {0x17D2, "keymap_rp/28/003.png"}, - {0x17D3, "keymap_rp/28/004.png"}, - {0x17D4, "keymap_rp/28/005.png"}, - {0x17D5, "keymap_rp/28/006.png"}, - {0x17D6, "keymap_rp/28/007.png"}, - {0x17D7, "keymap_rp/28/008.png"}, - {0x17D8, "keymap_rp/28/009.png"}, - {0x17D9, "keymap_rp/28/010.png"}, - {0x17E0, "keymap_rp/29/001.png"}, - {0x17E1, "keymap_rp/29/002.png"}, - {0x17E2, "keymap_rp/29/003.png"}, - {0x17E3, "keymap_rp/29/004.png"}, - {0x17E4, "keymap_rp/29/005.png"}, - {0x17E5, "keymap_rp/29/006.png"}, - {0x17E6, "keymap_rp/29/007.png"}, - {0x17E7, "keymap_rp/29/008.png"}, - {0x17E8, "keymap_rp/29/009.png"}, - {0x17E9, "keymap_rp/29/010.png"}, - {0x17F0, "keymap_rp/30/001.png"}, - {0x17F1, "keymap_rp/30/002.png"}, - {0x17F2, "keymap_rp/30/003.png"}, - {0x17F3, "keymap_rp/30/004.png"}, - {0x17F4, "keymap_rp/30/005.png"}, - {0x17F5, "keymap_rp/30/006.png"}, - {0x17F6, "keymap_rp/30/007.png"}, - {0x17F7, "keymap_rp/30/008.png"}, - {0x17F8, "keymap_rp/30/009.png"}, - {0x17F9, "keymap_rp/30/010.png"}, -}}; - -std::string_view GetEntryNameByType(u32 type) { - const auto key = PkgEntryValue{type}; - const auto it = std::ranges::lower_bound(PkgEntries, key); - if (it != PkgEntries.end() && it->type == type) { - return it->name; - } - return ""; -} diff --git a/src/core/file_format/pkg_type.h b/src/core/file_format/pkg_type.h deleted file mode 100644 index 6b010e3a3..000000000 --- a/src/core/file_format/pkg_type.h +++ /dev/null @@ -1,10 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include -#include "common/types.h" - -/// Retrieves the PKG entry name from its type identifier. -std::string_view GetEntryNameByType(u32 type); diff --git a/src/core/file_format/splash.cpp b/src/core/file_format/splash.cpp deleted file mode 100644 index 4eb701cf7..000000000 --- a/src/core/file_format/splash.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include - -#include "common/assert.h" -#include "common/io_file.h" -#include "common/stb.h" -#include "splash.h" - -bool Splash::Open(const std::filesystem::path& filepath) { - ASSERT_MSG(filepath.extension().string() == ".png", "Unexpected file format passed"); - - Common::FS::IOFile file(filepath, Common::FS::FileAccessMode::Read); - if (!file.IsOpen()) { - return false; - } - - std::vector png_file{}; - const auto png_size = file.GetSize(); - png_file.resize(png_size); - file.Seek(0); - file.Read(png_file); - - auto* img_mem = stbi_load_from_memory(png_file.data(), png_file.size(), - reinterpret_cast(&img_info.width), - reinterpret_cast(&img_info.height), - reinterpret_cast(&img_info.num_channels), 4); - if (!img_mem) { - return false; - } - - const auto img_size = img_info.GetSizeBytes(); - img_data.resize(img_size); - std::memcpy(img_data.data(), img_mem, img_size); - stbi_image_free(img_mem); - return true; -} diff --git a/src/core/file_format/splash.h b/src/core/file_format/splash.h deleted file mode 100644 index 7c563f317..000000000 --- a/src/core/file_format/splash.h +++ /dev/null @@ -1,42 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include -#include -#include -#include "common/types.h" - -class Splash { -public: - struct ImageInfo { - u32 width; - u32 height; - u32 num_channels; - - u32 GetSizeBytes() const { - return width * height * 4; // we always forcing rgba8 for simplicity - } - }; - - Splash() = default; - ~Splash() = default; - - bool Open(const std::filesystem::path& filepath); - [[nodiscard]] bool IsLoaded() const { - return img_data.size(); - } - - const auto& GetImageData() const { - return img_data; - } - - ImageInfo GetImageInfo() const { - return img_info; - } - -private: - ImageInfo img_info{}; - std::vector img_data{}; -}; diff --git a/src/core/file_format/trp.cpp b/src/core/file_format/trp.cpp index d25c93c3f..a5d11b0eb 100644 --- a/src/core/file_format/trp.cpp +++ b/src/core/file_format/trp.cpp @@ -1,10 +1,25 @@ // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include "common/aes.h" #include "common/config.h" #include "common/logging/log.h" #include "common/path_util.h" -#include "trp.h" +#include "core/file_format/trp.h" + +static void DecryptEFSM(std::span trophyKey, std::span NPcommID, + std::span efsmIv, std::span ciphertext, + std::span decrypted) { + // Step 1: Encrypt NPcommID + std::array trophyIv{}; + std::array trpKey; + aes::encrypt_cbc(NPcommID.data(), NPcommID.size(), trophyKey.data(), trophyKey.size(), + trophyIv.data(), trpKey.data(), trpKey.size(), false); + + // Step 2: Decrypt EFSM + aes::decrypt_cbc(ciphertext.data(), ciphertext.size(), trpKey.data(), trpKey.size(), + efsmIv.data(), decrypted.data(), decrypted.size(), nullptr); +} TRP::TRP() = default; TRP::~TRP() = default; @@ -54,7 +69,7 @@ bool TRP::Extract(const std::filesystem::path& trophyPath, const std::string tit return false; } - std::array user_key{}; + std::array user_key{}; hexToBytes(user_key_str.c_str(), user_key.data()); for (int index = 0; const auto& it : std::filesystem::directory_iterator(gameSysDir)) { @@ -115,7 +130,7 @@ bool TRP::Extract(const std::filesystem::path& trophyPath, const std::string tit return false; } file.Read(ESFM); - crypto.decryptEFSM(user_key, np_comm_id, esfmIv, ESFM, XML); // decrypt + DecryptEFSM(user_key, np_comm_id, esfmIv, ESFM, XML); // decrypt removePadding(XML); std::string xml_name = entry.entry_name; size_t pos = xml_name.find("ESFM"); diff --git a/src/core/file_format/trp.h b/src/core/file_format/trp.h index aec129f0e..01207475b 100644 --- a/src/core/file_format/trp.h +++ b/src/core/file_format/trp.h @@ -7,7 +7,6 @@ #include "common/endian.h" #include "common/io_file.h" #include "common/types.h" -#include "core/crypto/crypto.h" struct TrpHeader { u32_be magic; // (0xDCA24D00) @@ -37,10 +36,9 @@ public: void GetNPcommID(const std::filesystem::path& trophyPath, int index); private: - Crypto crypto; std::vector NPcommID = std::vector(12); std::array np_comm_id{}; std::array esfmIv{}; std::filesystem::path trpFilesPath; static constexpr int iv_len = 16; -}; \ No newline at end of file +}; diff --git a/src/core/file_sys/fs.cpp b/src/core/file_sys/fs.cpp index ec940503f..4dad44874 100644 --- a/src/core/file_sys/fs.cpp +++ b/src/core/file_sys/fs.cpp @@ -70,6 +70,10 @@ std::filesystem::path MntPoints::GetHostPath(std::string_view path, bool* is_rea std::filesystem::path host_path = mount->host_path / rel_path; std::filesystem::path patch_path = mount->host_path; patch_path += "-UPDATE"; + if (!std::filesystem::exists(patch_path)) { + patch_path = mount->host_path; + patch_path += "-patch"; + } patch_path /= rel_path; if ((corrected_path.starts_with("/app0") || corrected_path.starts_with("/hostapp")) && diff --git a/src/core/libraries/audio/audioout.cpp b/src/core/libraries/audio/audioout.cpp index dea8115e9..92488443f 100644 --- a/src/core/libraries/audio/audioout.cpp +++ b/src/core/libraries/audio/audioout.cpp @@ -191,6 +191,7 @@ int PS4_SYSV_ABI sceAudioOutGetPortState(s32 handle, OrbisAudioOutPortState* sta case OrbisAudioOutPort::Main: case OrbisAudioOutPort::Bgm: case OrbisAudioOutPort::Voice: + case OrbisAudioOutPort::Audio3d: state->output = 1; state->channel = port.format_info.num_channels > 2 ? 2 : port.format_info.num_channels; break; @@ -316,7 +317,7 @@ s32 PS4_SYSV_ABI sceAudioOutOpen(UserService::OrbisUserServiceUserId user_id, return ORBIS_AUDIO_OUT_ERROR_NOT_INIT; } if ((port_type < OrbisAudioOutPort::Main || port_type > OrbisAudioOutPort::Padspk) && - (port_type != OrbisAudioOutPort::Aux)) { + (port_type != OrbisAudioOutPort::Audio3d && port_type != OrbisAudioOutPort::Aux)) { LOG_ERROR(Lib_AudioOut, "Invalid port type"); return ORBIS_AUDIO_OUT_ERROR_INVALID_PORT_TYPE; } diff --git a/src/core/libraries/audio/audioout.h b/src/core/libraries/audio/audioout.h index 5eafb43a1..7fcc25095 100644 --- a/src/core/libraries/audio/audioout.h +++ b/src/core/libraries/audio/audioout.h @@ -20,7 +20,15 @@ class PortBackend; constexpr s32 SCE_AUDIO_OUT_NUM_PORTS = 22; constexpr s32 SCE_AUDIO_OUT_VOLUME_0DB = 32768; // max volume value -enum class OrbisAudioOutPort { Main = 0, Bgm = 1, Voice = 2, Personal = 3, Padspk = 4, Aux = 127 }; +enum class OrbisAudioOutPort { + Main = 0, + Bgm = 1, + Voice = 2, + Personal = 3, + Padspk = 4, + Audio3d = 126, + Aux = 127, +}; enum class OrbisAudioOutParamFormat : u32 { S16Mono = 0, diff --git a/src/core/libraries/audio3d/audio3d.cpp b/src/core/libraries/audio3d/audio3d.cpp index d896524c6..646c28949 100644 --- a/src/core/libraries/audio3d/audio3d.cpp +++ b/src/core/libraries/audio3d/audio3d.cpp @@ -1,8 +1,13 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include +#include + +#include "common/assert.h" #include "common/logging/log.h" #include "core/libraries/audio/audioout.h" +#include "core/libraries/audio/audioout_error.h" #include "core/libraries/audio3d/audio3d.h" #include "core/libraries/audio3d/audio3d_error.h" #include "core/libraries/error_codes.h" @@ -10,331 +15,577 @@ namespace Libraries::Audio3d { -int PS4_SYSV_ABI sceAudio3dInitialize(s64 iReserved) { - LOG_INFO(Lib_Audio3d, "iReserved = {}", iReserved); - return ORBIS_OK; +static constexpr u32 AUDIO3D_SAMPLE_RATE = 48000; + +static constexpr AudioOut::OrbisAudioOutParamFormat AUDIO3D_OUTPUT_FORMAT = + AudioOut::OrbisAudioOutParamFormat::S16Stereo; +static constexpr u32 AUDIO3D_OUTPUT_NUM_CHANNELS = 2; +static constexpr u32 AUDIO3D_OUTPUT_BUFFER_FRAMES = 0x100; + +static std::unique_ptr state; + +s32 PS4_SYSV_ABI sceAudio3dAudioOutClose(const s32 handle) { + LOG_INFO(Lib_Audio3d, "called, handle = {}", handle); + return AudioOut::sceAudioOutClose(handle); } -int PS4_SYSV_ABI sceAudio3dTerminate() { - // TODO: When not initialized or some ports still open, return ORBIS_AUDIO3D_ERROR_NOT_READY - LOG_INFO(Lib_Audio3d, "called"); - return ORBIS_OK; -} - -void PS4_SYSV_ABI sceAudio3dGetDefaultOpenParameters(OrbisAudio3dOpenParameters* parameters) { - if (parameters == nullptr) { - LOG_ERROR(Lib_Audio3d, "Invalid OpenParameters ptr"); - return; - } - - parameters->size_this = sizeof(OrbisAudio3dOpenParameters); - parameters->granularity = 256; - parameters->rate = OrbisAudio3dRate::Rate48000; - parameters->max_objects = 512; - parameters->queue_depth = 2; - parameters->buffer_mode = OrbisAudio3dBufferMode::AdvanceAndPush; - parameters->num_beds = 2; -} - -int PS4_SYSV_ABI sceAudio3dPortOpen(OrbisUserServiceUserId iUserId, - const OrbisAudio3dOpenParameters* pParameters, - OrbisAudio3dPortId* pId) { - LOG_INFO(Lib_Audio3d, "iUserId = {}", iUserId); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceAudio3dPortClose(OrbisAudio3dPortId uiPortId) { - LOG_INFO(Lib_Audio3d, "uiPortId = {}", uiPortId); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceAudio3dPortSetAttribute(OrbisAudio3dPortId uiPortId, - OrbisAudio3dAttributeId uiAttributeId, - const void* pAttribute, size_t szAttribute) { - LOG_INFO(Lib_Audio3d, "uiPortId = {}, uiAttributeId = {}, szAttribute = {}", uiPortId, - uiAttributeId, szAttribute); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceAudio3dPortFlush(OrbisAudio3dPortId uiPortId) { - LOG_INFO(Lib_Audio3d, "uiPortId = {}", uiPortId); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceAudio3dPortAdvance(OrbisAudio3dPortId uiPortId) { - LOG_TRACE(Lib_Audio3d, "uiPortId = {}", uiPortId); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceAudio3dPortPush(OrbisAudio3dPortId uiPortId, OrbisAudio3dBlocking eBlocking) { - LOG_TRACE(Lib_Audio3d, "uiPortId = {}", uiPortId); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceAudio3dPortGetAttributesSupported(OrbisAudio3dPortId uiPortId, - OrbisAudio3dAttributeId* pCapabilities, - u32* pNumCapabilities) { - LOG_INFO(Lib_Audio3d, "uiPortId = {}", uiPortId); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceAudio3dPortGetQueueLevel(OrbisAudio3dPortId uiPortId, u32* pQueueLevel, - u32* pQueueAvailable) { - LOG_TRACE(Lib_Audio3d, "uiPortId = {}", uiPortId); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceAudio3dObjectReserve(OrbisAudio3dPortId uiPortId, OrbisAudio3dObjectId* pId) { - LOG_INFO(Lib_Audio3d, "uiPortId = {}", uiPortId); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceAudio3dObjectUnreserve(OrbisAudio3dPortId uiPortId, - OrbisAudio3dObjectId uiObjectId) { - LOG_INFO(Lib_Audio3d, "uiPortId = {}, uiObjectId = {}", uiPortId, uiObjectId); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceAudio3dObjectSetAttributes(OrbisAudio3dPortId uiPortId, - OrbisAudio3dObjectId uiObjectId, - size_t szNumAttributes, - const OrbisAudio3dAttribute* pAttributeArray) { - LOG_INFO(Lib_Audio3d, "uiPortId = {}, uiObjectId = {}, szNumAttributes = {}", uiPortId, - uiObjectId, szNumAttributes); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceAudio3dBedWrite(OrbisAudio3dPortId uiPortId, u32 uiNumChannels, - OrbisAudio3dFormat eFormat, const void* pBuffer, - u32 uiNumSamples) { - LOG_TRACE(Lib_Audio3d, "uiPortId = {}, uiNumChannels = {}, uiNumSamples = {}", uiPortId, - uiNumChannels, uiNumSamples); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceAudio3dBedWrite2(OrbisAudio3dPortId uiPortId, u32 uiNumChannels, - OrbisAudio3dFormat eFormat, const void* pBuffer, - u32 uiNumSamples, OrbisAudio3dOutputRoute eOutputRoute, - bool bRestricted) { - LOG_INFO(Lib_Audio3d, "uiPortId = {}, uiNumChannels = {}, uiNumSamples = {}, bRestricted = {}", - uiPortId, uiNumChannels, uiNumSamples, bRestricted); - return ORBIS_OK; -} - -size_t PS4_SYSV_ABI sceAudio3dGetSpeakerArrayMemorySize(u32 uiNumSpeakers, bool bIs3d) { - LOG_INFO(Lib_Audio3d, "uiNumSpeakers = {}, bIs3d = {}", uiNumSpeakers, bIs3d); - return ORBIS_OK; -} - -int PS4_SYSV_ABI -sceAudio3dCreateSpeakerArray(OrbisAudio3dSpeakerArrayHandle* pHandle, - const OrbisAudio3dSpeakerArrayParameters* pParameters) { - if (pHandle == nullptr || pParameters == nullptr) { - LOG_ERROR(Lib_Audio3d, "invalid SpeakerArray parameters"); - return ORBIS_AUDIO3D_ERROR_INVALID_PARAMETER; - } - LOG_INFO(Lib_Audio3d, "called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceAudio3dDeleteSpeakerArray(OrbisAudio3dSpeakerArrayHandle handle) { - if (handle == nullptr) { - LOG_ERROR(Lib_Audio3d, "invalid SpeakerArrayHandle"); - return ORBIS_AUDIO3D_ERROR_INVALID_PARAMETER; - } - LOG_INFO(Lib_Audio3d, "called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceAudio3dGetSpeakerArrayMixCoefficients(OrbisAudio3dSpeakerArrayHandle handle, - OrbisAudio3dPosition pos, float fSpread, - float* pCoefficients, - u32 uiNumCoefficients) { - LOG_INFO(Lib_Audio3d, "fSpread = {}, uiNumCoefficients = {}", fSpread, uiNumCoefficients); - if (handle == nullptr) { - LOG_ERROR(Lib_Audio3d, "invalid SpeakerArrayHandle"); - return ORBIS_AUDIO3D_ERROR_INVALID_PARAMETER; - } - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceAudio3dGetSpeakerArrayMixCoefficients2(OrbisAudio3dSpeakerArrayHandle handle, - OrbisAudio3dPosition pos, float fSpread, - float* pCoefficients, - u32 uiNumCoefficients, bool bHeightAware, - float fDownmixSpreadRadius) { +s32 PS4_SYSV_ABI +sceAudio3dAudioOutOpen(const OrbisAudio3dPortId port_id, const OrbisUserServiceUserId user_id, + s32 type, const s32 index, const u32 len, const u32 freq, + const AudioOut::OrbisAudioOutParamExtendedInformation param) { LOG_INFO(Lib_Audio3d, - "fSpread = {}, uiNumCoefficients = {}, bHeightAware = {}, fDownmixSpreadRadius = {}", - fSpread, uiNumCoefficients, bHeightAware, fDownmixSpreadRadius); - if (handle == nullptr) { - LOG_ERROR(Lib_Audio3d, "invalid SpeakerArrayHandle"); + "called, port_id = {}, user_id = {}, type = {}, index = {}, len = {}, freq = {}", + port_id, user_id, type, index, len, freq); + + if (!state->ports.contains(port_id)) { + LOG_ERROR(Lib_Audio3d, "!state->ports.contains(port_id)"); + return ORBIS_AUDIO3D_ERROR_INVALID_PORT; + } + + if (len != state->ports[port_id].parameters.granularity) { + LOG_ERROR(Lib_Audio3d, "len != state->ports[port_id].parameters.granularity"); return ORBIS_AUDIO3D_ERROR_INVALID_PARAMETER; } + + return sceAudioOutOpen(user_id, static_cast(type), index, len, + freq, param); +} + +s32 PS4_SYSV_ABI sceAudio3dAudioOutOutput(const s32 handle, void* ptr) { + LOG_DEBUG(Lib_Audio3d, "called, handle = {}, ptr = {}", handle, ptr); + + if (!ptr) { + LOG_ERROR(Lib_Audio3d, "!ptr"); + return ORBIS_AUDIO3D_ERROR_INVALID_PARAMETER; + } + + if (handle < 0 || (handle & 0xFFFF) > 25) { + LOG_ERROR(Lib_Audio3d, "handle < 0 || (handle & 0xFFFF) > 25"); + return ORBIS_AUDIO3D_ERROR_INVALID_PORT; + } + + return AudioOut::sceAudioOutOutput(handle, ptr); +} + +s32 PS4_SYSV_ABI sceAudio3dAudioOutOutputs(AudioOut::OrbisAudioOutOutputParam* param, + const u32 num) { + LOG_DEBUG(Lib_Audio3d, "called, param = {}, num = {}", static_cast(param), num); + + if (!param || !num) { + LOG_ERROR(Lib_Audio3d, "!param || !num"); + return ORBIS_AUDIO3D_ERROR_INVALID_PARAMETER; + } + + return AudioOut::sceAudioOutOutputs(param, num); +} + +static s32 PortQueueAudio(Port& port, const OrbisAudio3dPcm& pcm, const u32 num_channels) { + // Audio3d output is configured for stereo signed 16-bit PCM. Convert the data to match. + const SDL_AudioSpec src_spec = { + .format = pcm.format == OrbisAudio3dFormat::ORBIS_AUDIO3D_FORMAT_S16 ? SDL_AUDIO_S16LE + : SDL_AUDIO_F32LE, + .channels = static_cast(num_channels), + .freq = AUDIO3D_SAMPLE_RATE, + }; + constexpr SDL_AudioSpec dst_spec = { + .format = SDL_AUDIO_S16LE, + .channels = AUDIO3D_OUTPUT_NUM_CHANNELS, + .freq = AUDIO3D_SAMPLE_RATE, + }; + const auto src_size = pcm.num_samples * + (pcm.format == OrbisAudio3dFormat::ORBIS_AUDIO3D_FORMAT_S16 ? 2 : 4) * + num_channels; + + u8* dst_data; + int dst_len; + if (!SDL_ConvertAudioSamples(&src_spec, static_cast(pcm.sample_buffer), + static_cast(src_size), &dst_spec, &dst_data, &dst_len)) { + LOG_ERROR(Lib_Audio3d, "SDL_ConvertAudioSamples failed: {}", SDL_GetError()); + return ORBIS_AUDIO3D_ERROR_OUT_OF_MEMORY; + } + + port.queue.emplace_back(AudioData{ + .sample_buffer = dst_data, + .num_samples = pcm.num_samples, + }); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceAudio3dBedWrite(const OrbisAudio3dPortId port_id, const u32 num_channels, + const OrbisAudio3dFormat format, void* buffer, + const u32 num_samples) { + return sceAudio3dBedWrite2(port_id, num_channels, format, buffer, num_samples, + OrbisAudio3dOutputRoute::ORBIS_AUDIO3D_OUTPUT_BOTH, false); +} + +s32 PS4_SYSV_ABI sceAudio3dBedWrite2(const OrbisAudio3dPortId port_id, const u32 num_channels, + const OrbisAudio3dFormat format, void* buffer, + const u32 num_samples, + const OrbisAudio3dOutputRoute output_route, + const bool restricted) { + LOG_DEBUG( + Lib_Audio3d, + "called, port_id = {}, num_channels = {}, format = {}, num_samples = {}, output_route " + "= {}, restricted = {}", + port_id, num_channels, magic_enum::enum_name(format), num_samples, + magic_enum::enum_name(output_route), restricted); + + if (!state->ports.contains(port_id)) { + LOG_ERROR(Lib_Audio3d, "!state->ports.contains(port_id)"); + return ORBIS_AUDIO3D_ERROR_INVALID_PORT; + } + + if (output_route > OrbisAudio3dOutputRoute::ORBIS_AUDIO3D_OUTPUT_BOTH) { + LOG_ERROR(Lib_Audio3d, "output_route > ORBIS_AUDIO3D_OUTPUT_BOTH"); + return ORBIS_AUDIO3D_ERROR_INVALID_PARAMETER; + } + + if (format > OrbisAudio3dFormat::ORBIS_AUDIO3D_FORMAT_FLOAT) { + LOG_ERROR(Lib_Audio3d, "format > ORBIS_AUDIO3D_FORMAT_FLOAT"); + return ORBIS_AUDIO3D_ERROR_INVALID_PARAMETER; + } + + if (num_channels != 2 && num_channels != 8) { + LOG_ERROR(Lib_Audio3d, "num_channels != 2 && num_channels != 8"); + return ORBIS_AUDIO3D_ERROR_INVALID_PARAMETER; + } + + if (!buffer || !num_samples) { + LOG_ERROR(Lib_Audio3d, "!buffer || !num_samples"); + return ORBIS_AUDIO3D_ERROR_INVALID_PARAMETER; + } + + if (format == OrbisAudio3dFormat::ORBIS_AUDIO3D_FORMAT_FLOAT) { + if ((reinterpret_cast(buffer) & 3) != 0) { + LOG_ERROR(Lib_Audio3d, "buffer & 3 != 0"); + return ORBIS_AUDIO3D_ERROR_INVALID_PARAMETER; + } + } else if (format == OrbisAudio3dFormat::ORBIS_AUDIO3D_FORMAT_S16) { + if ((reinterpret_cast(buffer) & 1) != 0) { + LOG_ERROR(Lib_Audio3d, "buffer & 1 != 0"); + return ORBIS_AUDIO3D_ERROR_INVALID_PARAMETER; + } + } + + return PortQueueAudio(state->ports[port_id], + OrbisAudio3dPcm{ + .format = format, + .sample_buffer = buffer, + .num_samples = num_samples, + }, + num_channels); +} + +s32 PS4_SYSV_ABI sceAudio3dCreateSpeakerArray() { + LOG_ERROR(Lib_Audio3d, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceAudio3dDeleteSpeakerArray() { + LOG_ERROR(Lib_Audio3d, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceAudio3dGetDefaultOpenParameters(OrbisAudio3dOpenParameters* params) { + LOG_DEBUG(Lib_Audio3d, "called"); + if (params) { + *params = OrbisAudio3dOpenParameters{ + .size_this = 0x20, + .granularity = 0x100, + .rate = OrbisAudio3dRate::ORBIS_AUDIO3D_RATE_48000, + .max_objects = 512, + .queue_depth = 2, + .buffer_mode = OrbisAudio3dBufferMode::ORBIS_AUDIO3D_BUFFER_ADVANCE_AND_PUSH, + }; + } return ORBIS_OK; } -s32 PS4_SYSV_ABI sceAudio3dAudioOutOpen(OrbisAudio3dPortId uiPortId, OrbisUserServiceUserId userId, - s32 type, s32 index, u32 len, u32 freq, u32 param) { +s32 PS4_SYSV_ABI sceAudio3dGetSpeakerArrayMemorySize() { + LOG_ERROR(Lib_Audio3d, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceAudio3dGetSpeakerArrayMixCoefficients() { + LOG_ERROR(Lib_Audio3d, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceAudio3dGetSpeakerArrayMixCoefficients2() { + LOG_ERROR(Lib_Audio3d, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceAudio3dInitialize(const s64 reserved) { + LOG_INFO(Lib_Audio3d, "called, reserved = {}", reserved); + + if (reserved != 0) { + LOG_ERROR(Lib_Audio3d, "reserved != 0"); + return ORBIS_AUDIO3D_ERROR_INVALID_PARAMETER; + } + + if (state) { + LOG_ERROR(Lib_Audio3d, "already initialized"); + return ORBIS_AUDIO3D_ERROR_NOT_READY; + } + + state = std::make_unique(); + + if (const auto init_ret = AudioOut::sceAudioOutInit(); + init_ret < 0 && init_ret != ORBIS_AUDIO_OUT_ERROR_ALREADY_INIT) { + return init_ret; + } + + AudioOut::OrbisAudioOutParamExtendedInformation ext_info{}; + ext_info.data_format.Assign(AUDIO3D_OUTPUT_FORMAT); + state->audio_out_handle = + AudioOut::sceAudioOutOpen(0xFF, AudioOut::OrbisAudioOutPort::Audio3d, 0, + AUDIO3D_OUTPUT_BUFFER_FRAMES, AUDIO3D_SAMPLE_RATE, ext_info); + if (state->audio_out_handle < 0) { + return state->audio_out_handle; + } + + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceAudio3dObjectReserve(const OrbisAudio3dPortId port_id, + OrbisAudio3dObjectId* object_id) { + LOG_INFO(Lib_Audio3d, "called, port_id = {}, object_id = {}", port_id, + static_cast(object_id)); + + if (!state->ports.contains(port_id)) { + LOG_ERROR(Lib_Audio3d, "!state->ports.contains(port_id)"); + return ORBIS_AUDIO3D_ERROR_INVALID_PORT; + } + + if (!object_id) { + LOG_ERROR(Lib_Audio3d, "!object_id"); + return ORBIS_AUDIO3D_ERROR_INVALID_PARAMETER; + } + + static int last_id = 0; + *object_id = ++last_id; + + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceAudio3dObjectSetAttributes(const OrbisAudio3dPortId port_id, + OrbisAudio3dObjectId object_id, + const u64 num_attributes, + const OrbisAudio3dAttribute* attribute_array) { + LOG_DEBUG(Lib_Audio3d, + "called, port_id = {}, object_id = {}, num_attributes = {}, attribute_array = {}", + port_id, object_id, num_attributes, fmt::ptr(attribute_array)); + + if (!state->ports.contains(port_id)) { + LOG_ERROR(Lib_Audio3d, "!state->ports.contains(port_id)"); + return ORBIS_AUDIO3D_ERROR_INVALID_PORT; + } + + auto& port = state->ports[port_id]; + + for (u64 i = 0; i < num_attributes; i++) { + const auto& attribute = attribute_array[i]; + + switch (attribute.attribute_id) { + case OrbisAudio3dAttributeId::ORBIS_AUDIO3D_ATTRIBUTE_PCM: { + const auto pcm = static_cast(attribute.value); + // Object audio has 1 channel. + if (const auto ret = PortQueueAudio(port, *pcm, 1); ret != ORBIS_OK) { + return ret; + } + break; + } + default: + LOG_ERROR(Lib_Audio3d, "Unsupported attribute ID: {:#x}", + static_cast(attribute.attribute_id)); + break; + } + } + + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceAudio3dObjectUnreserve() { + LOG_ERROR(Lib_Audio3d, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceAudio3dPortAdvance(const OrbisAudio3dPortId port_id) { + LOG_DEBUG(Lib_Audio3d, "called, port_id = {}", port_id); + + if (!state->ports.contains(port_id)) { + LOG_ERROR(Lib_Audio3d, "!state->ports.contains(port_id)"); + return ORBIS_AUDIO3D_ERROR_INVALID_PORT; + } + + if (state->ports[port_id].parameters.buffer_mode == + OrbisAudio3dBufferMode::ORBIS_AUDIO3D_BUFFER_NO_ADVANCE) { + LOG_ERROR(Lib_Audio3d, "port doesn't have advance capability"); + return ORBIS_AUDIO3D_ERROR_NOT_SUPPORTED; + } + + auto& port = state->ports[port_id]; + if (port.current_buffer.has_value()) { + // Free existing buffer before replacing. + SDL_free(port.current_buffer->sample_buffer); + } + + if (!port.queue.empty()) { + port.current_buffer = port.queue.front(); + port.queue.pop_front(); + } else { + // Nothing to advance to. + LOG_DEBUG(Lib_Audio3d, "Port advance with no buffer queued"); + port.current_buffer = std::nullopt; + } + + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceAudio3dPortClose() { + LOG_ERROR(Lib_Audio3d, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceAudio3dPortCreate() { + LOG_ERROR(Lib_Audio3d, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceAudio3dPortDestroy() { + LOG_ERROR(Lib_Audio3d, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceAudio3dPortFlush() { + LOG_ERROR(Lib_Audio3d, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceAudio3dPortFreeState() { + LOG_ERROR(Lib_Audio3d, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceAudio3dPortGetAttributesSupported() { + LOG_ERROR(Lib_Audio3d, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceAudio3dPortGetList() { + LOG_ERROR(Lib_Audio3d, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceAudio3dPortGetParameters() { + LOG_ERROR(Lib_Audio3d, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceAudio3dPortGetQueueLevel(const OrbisAudio3dPortId port_id, u32* queue_level, + u32* queue_available) { + LOG_DEBUG(Lib_Audio3d, "called, port_id = {}, queue_level = {}, queue_available = {}", port_id, + static_cast(queue_level), static_cast(queue_available)); + + if (!state->ports.contains(port_id)) { + LOG_ERROR(Lib_Audio3d, "!state->ports.contains(port_id)"); + return ORBIS_AUDIO3D_ERROR_INVALID_PORT; + } + + if (!queue_level && !queue_available) { + return ORBIS_AUDIO3D_ERROR_INVALID_PARAMETER; + } + + const auto port = state->ports[port_id]; + const size_t size = port.queue.size(); + + if (queue_level) { + *queue_level = size; + } + + if (queue_available) { + *queue_available = port.parameters.queue_depth - size; + } + + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceAudio3dPortGetState() { + LOG_ERROR(Lib_Audio3d, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceAudio3dPortGetStatus() { + LOG_ERROR(Lib_Audio3d, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceAudio3dPortOpen(const OrbisUserServiceUserId user_id, + const OrbisAudio3dOpenParameters* parameters, + OrbisAudio3dPortId* port_id) { + LOG_INFO(Lib_Audio3d, "called, user_id = {}, parameters = {}, id = {}", user_id, + static_cast(parameters), static_cast(port_id)); + + if (!state) { + LOG_ERROR(Lib_Audio3d, "!initialized"); + return ORBIS_AUDIO3D_ERROR_NOT_READY; + } + + if (!parameters || !port_id) { + LOG_ERROR(Lib_Audio3d, "!parameters || !id"); + return ORBIS_AUDIO3D_ERROR_INVALID_PARAMETER; + } + + const int id = static_cast(state->ports.size()) + 1; + + if (id > 3) { + LOG_ERROR(Lib_Audio3d, "id > 3"); + return ORBIS_AUDIO3D_ERROR_OUT_OF_RESOURCES; + } + + *port_id = id; + std::memcpy(&state->ports[id].parameters, parameters, sizeof(OrbisAudio3dOpenParameters)); + + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceAudio3dPortPush(const OrbisAudio3dPortId port_id, + const OrbisAudio3dBlocking blocking) { + LOG_DEBUG(Lib_Audio3d, "called, port_id = {}, blocking = {}", port_id, + magic_enum::enum_name(blocking)); + + if (!state->ports.contains(port_id)) { + LOG_ERROR(Lib_Audio3d, "!state->ports.contains(port_id)"); + return ORBIS_AUDIO3D_ERROR_INVALID_PORT; + } + + const auto& port = state->ports[port_id]; + if (port.parameters.buffer_mode != + OrbisAudio3dBufferMode::ORBIS_AUDIO3D_BUFFER_ADVANCE_AND_PUSH) { + LOG_ERROR(Lib_Audio3d, "port doesn't have push capability"); + return ORBIS_AUDIO3D_ERROR_NOT_SUPPORTED; + } + + if (!port.current_buffer.has_value()) { + // Nothing to push. + LOG_DEBUG(Lib_Audio3d, "Port push with no buffer ready"); + return ORBIS_OK; + } + + // TODO: Implement asynchronous blocking mode. + const auto& [sample_buffer, num_samples] = port.current_buffer.value(); + return AudioOut::sceAudioOutOutput(state->audio_out_handle, sample_buffer); +} + +s32 PS4_SYSV_ABI sceAudio3dPortQueryDebug() { + LOG_ERROR(Lib_Audio3d, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceAudio3dPortSetAttribute(const OrbisAudio3dPortId port_id, + const OrbisAudio3dAttributeId attribute_id, + void* attribute, const u64 attribute_size) { LOG_INFO(Lib_Audio3d, - "uiPortId = {}, userId = {}, type = {}, index = {}, len = {}, freq = {}, param = {}", - uiPortId, userId, type, index, len, freq, param); - return ORBIS_OK; -} + "called, port_id = {}, attribute_id = {}, attribute = {}, attribute_size = {}", + port_id, static_cast(attribute_id), attribute, attribute_size); -s32 PS4_SYSV_ABI sceAudio3dAudioOutClose(s32 handle) { - LOG_INFO(Lib_Audio3d, "handle = {}", handle); - return ORBIS_OK; -} + if (!state->ports.contains(port_id)) { + LOG_ERROR(Lib_Audio3d, "!state->ports.contains(port_id)"); + return ORBIS_AUDIO3D_ERROR_INVALID_PORT; + } -s32 PS4_SYSV_ABI sceAudio3dAudioOutOutput(s32 handle, const void* ptr) { - LOG_TRACE(Lib_Audio3d, "handle = {}", handle); - if (ptr == nullptr) { - LOG_ERROR(Lib_Audio3d, "invalid Output ptr"); + if (!attribute) { + LOG_ERROR(Lib_Audio3d, "!attribute"); return ORBIS_AUDIO3D_ERROR_INVALID_PARAMETER; } + + // TODO + return ORBIS_OK; } -s32 PS4_SYSV_ABI sceAudio3dAudioOutOutputs(::Libraries::AudioOut::OrbisAudioOutOutputParam* param, - s32 num) { - LOG_INFO(Lib_Audio3d, "num = {}", num); - if (param == nullptr) { - LOG_ERROR(Lib_Audio3d, "invalid OutputParam ptr"); - return ORBIS_AUDIO3D_ERROR_INVALID_PARAMETER; - } - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceAudio3dPortCreate(u32 uiGranularity, OrbisAudio3dRate eRate, s64 iReserved, - OrbisAudio3dPortId* pId) { - LOG_INFO(Lib_Audio3d, "uiGranularity = {}, iReserved = {}", uiGranularity, iReserved); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceAudio3dPortDestroy(OrbisAudio3dPortId uiPortId) { - LOG_INFO(Lib_Audio3d, "uiPortId = {}", uiPortId); - return ORBIS_OK; -} - -// Audio3dPrivate - -const char* PS4_SYSV_ABI sceAudio3dStrError(int iErrorCode) { - LOG_ERROR(Lib_Audio3d, "(PRIVATE) called, iErrorCode = {}", iErrorCode); - return "NOT_IMPLEMENTED"; -} - -// Audio3dDebug - -int PS4_SYSV_ABI sceAudio3dPortQueryDebug() { - LOG_WARNING(Lib_Audio3d, "(DEBUG) sceAudio3dPortQueryDebug called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceAudio3dPortGetList() { - LOG_WARNING(Lib_Audio3d, "(DEBUG) sceAudio3dPortGetList called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceAudio3dPortGetParameters() { - LOG_WARNING(Lib_Audio3d, "(DEBUG) sceAudio3dPortGetParameters called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceAudio3dPortGetState() { - LOG_WARNING(Lib_Audio3d, "(DEBUG) sceAudio3dPortGetState called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceAudio3dPortFreeState() { - LOG_WARNING(Lib_Audio3d, "(DEBUG) sceAudio3dPortFreeState called"); - return ORBIS_OK; -} - -// Unknown - -int PS4_SYSV_ABI sceAudio3dPortGetBufferLevel() { +s32 PS4_SYSV_ABI sceAudio3dReportRegisterHandler() { LOG_ERROR(Lib_Audio3d, "(STUBBED) called"); return ORBIS_OK; } -int PS4_SYSV_ABI sceAudio3dPortGetStatus() { +s32 PS4_SYSV_ABI sceAudio3dReportUnregisterHandler() { LOG_ERROR(Lib_Audio3d, "(STUBBED) called"); return ORBIS_OK; } -int PS4_SYSV_ABI sceAudio3dReportRegisterHandler() { +s32 PS4_SYSV_ABI sceAudio3dSetGpuRenderer() { LOG_ERROR(Lib_Audio3d, "(STUBBED) called"); return ORBIS_OK; } -int PS4_SYSV_ABI sceAudio3dReportUnregisterHandler() { +s32 PS4_SYSV_ABI sceAudio3dStrError() { LOG_ERROR(Lib_Audio3d, "(STUBBED) called"); return ORBIS_OK; } -int PS4_SYSV_ABI sceAudio3dSetGpuRenderer() { +s32 PS4_SYSV_ABI sceAudio3dTerminate() { LOG_ERROR(Lib_Audio3d, "(STUBBED) called"); return ORBIS_OK; } void RegisterlibSceAudio3d(Core::Loader::SymbolsResolver* sym) { + LIB_FUNCTION("pZlOm1aF3aA", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dAudioOutClose); + LIB_FUNCTION("ucEsi62soTo", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dAudioOutOpen); + LIB_FUNCTION("7NYEzJ9SJbM", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dAudioOutOutput); + LIB_FUNCTION("HbxYY27lK6E", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dAudioOutOutputs); + LIB_FUNCTION("9tEwE0GV0qo", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dBedWrite); + LIB_FUNCTION("xH4Q9UILL3o", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dBedWrite2); + LIB_FUNCTION("lvWMW6vEqFU", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dCreateSpeakerArray); + LIB_FUNCTION("8hm6YdoQgwg", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dDeleteSpeakerArray); + LIB_FUNCTION("Im+jOoa5WAI", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dGetDefaultOpenParameters); + LIB_FUNCTION("kEqqyDkmgdI", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dGetSpeakerArrayMemorySize); LIB_FUNCTION("-R1DukFq7Dk", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dGetSpeakerArrayMixCoefficients); LIB_FUNCTION("-Re+pCWvwjQ", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dGetSpeakerArrayMixCoefficients2); - LIB_FUNCTION("-pzYDZozm+M", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, - sceAudio3dPortQueryDebug); - LIB_FUNCTION("1HXxo-+1qCw", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, - sceAudio3dObjectUnreserve); + LIB_FUNCTION("UmCvjSmuZIw", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dInitialize); + LIB_FUNCTION("jO2tec4dJ2M", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dObjectReserve); LIB_FUNCTION("4uyHN9q4ZeU", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dObjectSetAttributes); - LIB_FUNCTION("7NYEzJ9SJbM", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, - sceAudio3dAudioOutOutput); - LIB_FUNCTION("8hm6YdoQgwg", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, - sceAudio3dDeleteSpeakerArray); + LIB_FUNCTION("1HXxo-+1qCw", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dObjectUnreserve); + LIB_FUNCTION("lw0qrdSjZt8", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortAdvance); + LIB_FUNCTION("OyVqOeVNtSk", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortClose); + LIB_FUNCTION("UHFOgVNz0kk", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortCreate); + LIB_FUNCTION("Mw9mRQtWepY", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortDestroy); + LIB_FUNCTION("ZOGrxWLgQzE", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortFlush); + LIB_FUNCTION("uJ0VhGcxCTQ", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortFreeState); LIB_FUNCTION("9ZA23Ia46Po", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortGetAttributesSupported); - LIB_FUNCTION("9tEwE0GV0qo", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dBedWrite); - LIB_FUNCTION("Aacl5qkRU6U", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dStrError); - LIB_FUNCTION("CKHlRW2E9dA", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortGetState); - LIB_FUNCTION("HbxYY27lK6E", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, - sceAudio3dAudioOutOutputs); - LIB_FUNCTION("Im+jOoa5WAI", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, - sceAudio3dGetDefaultOpenParameters); - LIB_FUNCTION("Mw9mRQtWepY", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortDestroy); - LIB_FUNCTION("OyVqOeVNtSk", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortClose); - LIB_FUNCTION("QfNXBrKZeI0", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, - sceAudio3dReportRegisterHandler); - LIB_FUNCTION("QqgTQQdzEMY", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, - sceAudio3dPortGetBufferLevel); LIB_FUNCTION("SEggctIeTcI", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortGetList); - LIB_FUNCTION("UHFOgVNz0kk", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortCreate); - LIB_FUNCTION("UmCvjSmuZIw", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dInitialize); - LIB_FUNCTION("VEVhZ9qd4ZY", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortPush); - LIB_FUNCTION("WW1TS2iz5yc", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dTerminate); - LIB_FUNCTION("XeDDK0xJWQA", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortOpen); - LIB_FUNCTION("YaaDbDwKpFM", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, - sceAudio3dPortGetQueueLevel); - LIB_FUNCTION("Yq9bfUQ0uJg", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, - sceAudio3dPortSetAttribute); - LIB_FUNCTION("ZOGrxWLgQzE", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortFlush); LIB_FUNCTION("flPcUaXVXcw", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortGetParameters); + LIB_FUNCTION("YaaDbDwKpFM", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dPortGetQueueLevel); + LIB_FUNCTION("CKHlRW2E9dA", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortGetState); LIB_FUNCTION("iRX6GJs9tvE", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortGetStatus); - LIB_FUNCTION("jO2tec4dJ2M", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dObjectReserve); - LIB_FUNCTION("kEqqyDkmgdI", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, - sceAudio3dGetSpeakerArrayMemorySize); - LIB_FUNCTION("lvWMW6vEqFU", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, - sceAudio3dCreateSpeakerArray); - LIB_FUNCTION("lw0qrdSjZt8", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortAdvance); - LIB_FUNCTION("pZlOm1aF3aA", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dAudioOutClose); + LIB_FUNCTION("XeDDK0xJWQA", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortOpen); + LIB_FUNCTION("VEVhZ9qd4ZY", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortPush); + LIB_FUNCTION("-pzYDZozm+M", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dPortQueryDebug); + LIB_FUNCTION("Yq9bfUQ0uJg", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dPortSetAttribute); + LIB_FUNCTION("QfNXBrKZeI0", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, + sceAudio3dReportRegisterHandler); LIB_FUNCTION("psv2gbihC1A", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dReportUnregisterHandler); - LIB_FUNCTION("uJ0VhGcxCTQ", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dPortFreeState); - LIB_FUNCTION("ucEsi62soTo", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dAudioOutOpen); - LIB_FUNCTION("xH4Q9UILL3o", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dBedWrite2); LIB_FUNCTION("yEYXcbAGK14", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dSetGpuRenderer); + LIB_FUNCTION("Aacl5qkRU6U", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dStrError); + LIB_FUNCTION("WW1TS2iz5yc", "libSceAudio3d", 1, "libSceAudio3d", 1, 1, sceAudio3dTerminate); }; } // namespace Libraries::Audio3d diff --git a/src/core/libraries/audio3d/audio3d.h b/src/core/libraries/audio3d/audio3d.h index 6f344226f..f4e9ada8a 100644 --- a/src/core/libraries/audio3d/audio3d.h +++ b/src/core/libraries/audio3d/audio3d.h @@ -1,11 +1,13 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once -#include "common/types.h" +#include +#include -#include +#include "common/types.h" +#include "core/libraries/audio/audioout.h" namespace Core::Loader { class SymbolsResolver; @@ -13,123 +15,131 @@ class SymbolsResolver; namespace Libraries::Audio3d { -class Audio3d; - using OrbisUserServiceUserId = s32; -using OrbisAudio3dPortId = u32; -using OrbisAudio3dObjectId = u32; -using OrbisAudio3dAttributeId = u32; -enum class OrbisAudio3dFormat { - S16 = 0, - Float = 1, +enum class OrbisAudio3dRate : u32 { + ORBIS_AUDIO3D_RATE_48000 = 0, }; -enum class OrbisAudio3dRate { - Rate48000 = 0, +enum class OrbisAudio3dBufferMode : u32 { + ORBIS_AUDIO3D_BUFFER_NO_ADVANCE = 0, + ORBIS_AUDIO3D_BUFFER_ADVANCE_NO_PUSH = 1, + ORBIS_AUDIO3D_BUFFER_ADVANCE_AND_PUSH = 2, }; -enum class OrbisAudio3dBufferMode { NoAdvance = 0, AdvanceNoPush = 1, AdvanceAndPush = 2 }; - -enum class OrbisAudio3dBlocking { - Async = 0, - Sync = 1, -}; - -enum class OrbisAudio3dPassthrough { - None = 0, - Left = 1, - Right = 2, -}; - -enum class OrbisAudio3dOutputRoute { - Both = 0, - HmuOnly = 1, - TvOnly = 2, -}; - -enum class OrbisAudio3dAmbisonics : u32 { - None = ~0U, - W = 0, - X = 1, - Y = 2, - Z = 3, - R = 4, - S = 5, - T = 6, - U = 7, - V = 8, - K = 9, - L = 10, - M = 11, - N = 12, - O = 13, - P = 14, - Q = 15 -}; - -static const OrbisAudio3dAttributeId s_sceAudio3dAttributePcm = 0x00000001; -static const OrbisAudio3dAttributeId s_sceAudio3dAttributePriority = 0x00000002; -static const OrbisAudio3dAttributeId s_sceAudio3dAttributePosition = 0x00000003; -static const OrbisAudio3dAttributeId s_sceAudio3dAttributeSpread = 0x00000004; -static const OrbisAudio3dAttributeId s_sceAudio3dAttributeGain = 0x00000005; -static const OrbisAudio3dAttributeId s_sceAudio3dAttributePassthrough = 0x00000006; -static const OrbisAudio3dAttributeId s_sceAudio3dAttributeResetState = 0x00000007; -static const OrbisAudio3dAttributeId s_sceAudio3dAttributeApplicationSpecific = 0x00000008; -static const OrbisAudio3dAttributeId s_sceAudio3dAttributeAmbisonics = 0x00000009; -static const OrbisAudio3dAttributeId s_sceAudio3dAttributeRestricted = 0x0000000A; -static const OrbisAudio3dAttributeId s_sceAudio3dAttributeOutputRoute = 0x0000000B; -static const OrbisAudio3dAttributeId s_sceAudio3dAttributeLateReverbLevel = 0x00010001; -static const OrbisAudio3dAttributeId s_sceAudio3dAttributeDownmixSpreadRadius = 0x00010002; -static const OrbisAudio3dAttributeId s_sceAudio3dAttributeDownmixSpreadHeightAware = 0x00010003; - -struct OrbisAudio3dSpeakerArray; -using OrbisAudio3dSpeakerArrayHandle = OrbisAudio3dSpeakerArray*; // head - struct OrbisAudio3dOpenParameters { - size_t size_this; + u64 size_this; u32 granularity; OrbisAudio3dRate rate; u32 max_objects; u32 queue_depth; OrbisAudio3dBufferMode buffer_mode; - char padding[32]; + int : 32; u32 num_beds; }; -struct OrbisAudio3dAttribute { - OrbisAudio3dAttributeId attribute_id; - char padding[32]; - const void* p_value; - size_t value; +enum class OrbisAudio3dFormat : u32 { + ORBIS_AUDIO3D_FORMAT_S16 = 0, + ORBIS_AUDIO3D_FORMAT_FLOAT = 1, }; -struct OrbisAudio3dPosition { - float fX; - float fY; - float fZ; +enum class OrbisAudio3dOutputRoute : u32 { + ORBIS_AUDIO3D_OUTPUT_BOTH = 0, + ORBIS_AUDIO3D_OUTPUT_HMU_ONLY = 1, + ORBIS_AUDIO3D_OUTPUT_TV_ONLY = 2, +}; + +enum class OrbisAudio3dBlocking : u32 { + ORBIS_AUDIO3D_BLOCKING_ASYNC = 0, + ORBIS_AUDIO3D_BLOCKING_SYNC = 1, }; struct OrbisAudio3dPcm { OrbisAudio3dFormat format; - const void* sample_buffer; + void* sample_buffer; u32 num_samples; }; -struct OrbisAudio3dSpeakerArrayParameters { - OrbisAudio3dPosition* speaker_position; - u32 num_speakers; - bool is_3d; - void* buffer; - size_t size; +enum class OrbisAudio3dAttributeId : u32 { + ORBIS_AUDIO3D_ATTRIBUTE_PCM = 1, }; -struct OrbisAudio3dApplicationSpecific { - size_t size_this; - u8 application_specific[32]; +using OrbisAudio3dPortId = u32; +using OrbisAudio3dObjectId = u32; + +struct OrbisAudio3dAttribute { + OrbisAudio3dAttributeId attribute_id; + int : 32; + void* value; + u64 value_size; }; -void PS4_SYSV_ABI sceAudio3dGetDefaultOpenParameters(OrbisAudio3dOpenParameters* sParameters); +struct AudioData { + u8* sample_buffer; + u32 num_samples; +}; + +struct Port { + OrbisAudio3dOpenParameters parameters{}; + std::deque queue; // Only stores PCM buffers for now + std::optional current_buffer{}; +}; + +struct Audio3dState { + std::unordered_map ports; + s32 audio_out_handle; +}; + +s32 PS4_SYSV_ABI sceAudio3dAudioOutClose(s32 handle); +s32 PS4_SYSV_ABI sceAudio3dAudioOutOpen(OrbisAudio3dPortId port_id, OrbisUserServiceUserId user_id, + s32 type, s32 index, u32 len, u32 freq, + AudioOut::OrbisAudioOutParamExtendedInformation param); +s32 PS4_SYSV_ABI sceAudio3dAudioOutOutput(s32 handle, void* ptr); +s32 PS4_SYSV_ABI sceAudio3dAudioOutOutputs(AudioOut::OrbisAudioOutOutputParam* param, u32 num); +s32 PS4_SYSV_ABI sceAudio3dBedWrite(OrbisAudio3dPortId port_id, u32 num_channels, + OrbisAudio3dFormat format, void* buffer, u32 num_samples); +s32 PS4_SYSV_ABI sceAudio3dBedWrite2(OrbisAudio3dPortId port_id, u32 num_channels, + OrbisAudio3dFormat format, void* buffer, u32 num_samples, + OrbisAudio3dOutputRoute output_route, bool restricted); +s32 PS4_SYSV_ABI sceAudio3dCreateSpeakerArray(); +s32 PS4_SYSV_ABI sceAudio3dDeleteSpeakerArray(); +s32 PS4_SYSV_ABI sceAudio3dGetDefaultOpenParameters(OrbisAudio3dOpenParameters* params); +s32 PS4_SYSV_ABI sceAudio3dGetSpeakerArrayMemorySize(); +s32 PS4_SYSV_ABI sceAudio3dGetSpeakerArrayMixCoefficients(); +s32 PS4_SYSV_ABI sceAudio3dGetSpeakerArrayMixCoefficients2(); +s32 PS4_SYSV_ABI sceAudio3dInitialize(s64 reserved); +s32 PS4_SYSV_ABI sceAudio3dObjectReserve(OrbisAudio3dPortId port_id, + OrbisAudio3dObjectId* object_id); +s32 PS4_SYSV_ABI sceAudio3dObjectSetAttributes(OrbisAudio3dPortId port_id, + OrbisAudio3dObjectId object_id, u64 num_attributes, + const OrbisAudio3dAttribute* attribute_array); +s32 PS4_SYSV_ABI sceAudio3dObjectUnreserve(); +s32 PS4_SYSV_ABI sceAudio3dPortAdvance(OrbisAudio3dPortId port_id); +s32 PS4_SYSV_ABI sceAudio3dPortClose(); +s32 PS4_SYSV_ABI sceAudio3dPortCreate(); +s32 PS4_SYSV_ABI sceAudio3dPortDestroy(); +s32 PS4_SYSV_ABI sceAudio3dPortFlush(); +s32 PS4_SYSV_ABI sceAudio3dPortFreeState(); +s32 PS4_SYSV_ABI sceAudio3dPortGetAttributesSupported(); +s32 PS4_SYSV_ABI sceAudio3dPortGetList(); +s32 PS4_SYSV_ABI sceAudio3dPortGetParameters(); +s32 PS4_SYSV_ABI sceAudio3dPortGetQueueLevel(OrbisAudio3dPortId port_id, u32* queue_level, + u32* queue_available); +s32 PS4_SYSV_ABI sceAudio3dPortGetState(); +s32 PS4_SYSV_ABI sceAudio3dPortGetStatus(); +s32 PS4_SYSV_ABI sceAudio3dPortOpen(OrbisUserServiceUserId user_id, + const OrbisAudio3dOpenParameters* parameters, + OrbisAudio3dPortId* port_id); +s32 PS4_SYSV_ABI sceAudio3dPortPush(OrbisAudio3dPortId port_id, OrbisAudio3dBlocking blocking); +s32 PS4_SYSV_ABI sceAudio3dPortQueryDebug(); +s32 PS4_SYSV_ABI sceAudio3dPortSetAttribute(OrbisAudio3dPortId port_id, + OrbisAudio3dAttributeId attribute_id, void* attribute, + u64 attribute_size); +s32 PS4_SYSV_ABI sceAudio3dReportRegisterHandler(); +s32 PS4_SYSV_ABI sceAudio3dReportUnregisterHandler(); +s32 PS4_SYSV_ABI sceAudio3dSetGpuRenderer(); +s32 PS4_SYSV_ABI sceAudio3dStrError(); +s32 PS4_SYSV_ABI sceAudio3dTerminate(); void RegisterlibSceAudio3d(Core::Loader::SymbolsResolver* sym); } // namespace Libraries::Audio3d diff --git a/src/core/libraries/audio3d/audio3d_error.h b/src/core/libraries/audio3d/audio3d_error.h index 626ac8699..ff9d9749c 100644 --- a/src/core/libraries/audio3d/audio3d_error.h +++ b/src/core/libraries/audio3d/audio3d_error.h @@ -3,8 +3,6 @@ #pragma once -#include "core/libraries/error_codes.h" - constexpr int ORBIS_AUDIO3D_ERROR_UNKNOWN = 0x80EA0001; constexpr int ORBIS_AUDIO3D_ERROR_INVALID_PORT = 0x80EA0002; constexpr int ORBIS_AUDIO3D_ERROR_INVALID_OBJECT = 0x80EA0003; diff --git a/src/core/libraries/audio3d/audio3d_impl.h b/src/core/libraries/audio3d/audio3d_impl.h deleted file mode 100644 index 1213a030e..000000000 --- a/src/core/libraries/audio3d/audio3d_impl.h +++ /dev/null @@ -1,16 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include "audio3d.h" - -namespace Libraries::Audio3d { - -class Audio3d { -public: -private: - using OrbisAudio3dPluginId = u32; -}; - -} // namespace Libraries::Audio3d diff --git a/src/core/libraries/disc_map/disc_map.cpp b/src/core/libraries/disc_map/disc_map.cpp index bb566a149..e8b40e624 100644 --- a/src/core/libraries/disc_map/disc_map.cpp +++ b/src/core/libraries/disc_map/disc_map.cpp @@ -9,29 +9,29 @@ namespace Libraries::DiscMap { -int PS4_SYSV_ABI sceDiscMapGetPackageSize() { - LOG_WARNING(Lib_DiscMap, "(DUMMY) called"); +int PS4_SYSV_ABI sceDiscMapGetPackageSize(s64 fflags, int* ret1, int* ret2) { return ORBIS_DISC_MAP_ERROR_NO_BITMAP_INFO; } -int PS4_SYSV_ABI sceDiscMapIsRequestOnHDD() { - LOG_WARNING(Lib_DiscMap, "(DUMMY) called"); +int PS4_SYSV_ABI sceDiscMapIsRequestOnHDD(char* path, s64 offset, s64 nbytes, int* ret) { return ORBIS_DISC_MAP_ERROR_NO_BITMAP_INFO; } -int PS4_SYSV_ABI Func_7C980FFB0AA27E7A() { - LOG_ERROR(Lib_DiscMap, "(STUBBED) called"); +int PS4_SYSV_ABI Func_7C980FFB0AA27E7A(char* path, s64 offset, s64 nbytes, int* flags, int* ret1, + int* ret2) { + *flags = 0; + *ret1 = 0; + *ret2 = 0; return ORBIS_OK; } -int PS4_SYSV_ABI Func_8A828CAEE7EDD5E9() { - LOG_ERROR(Lib_DiscMap, "(STUBBED) called"); - return ORBIS_OK; +int PS4_SYSV_ABI Func_8A828CAEE7EDD5E9(char* path, s64 offset, s64 nbytes, int* flags, int* ret1, + int* ret2) { + return ORBIS_DISC_MAP_ERROR_NO_BITMAP_INFO; } int PS4_SYSV_ABI Func_E7EBCE96E92F91F8() { - LOG_ERROR(Lib_DiscMap, "(STUBBED) called"); - return ORBIS_OK; + return ORBIS_DISC_MAP_ERROR_NO_BITMAP_INFO; } void RegisterlibSceDiscMap(Core::Loader::SymbolsResolver* sym) { diff --git a/src/core/libraries/disc_map/disc_map.h b/src/core/libraries/disc_map/disc_map.h index 08abee632..dc8b875ac 100644 --- a/src/core/libraries/disc_map/disc_map.h +++ b/src/core/libraries/disc_map/disc_map.h @@ -10,10 +10,12 @@ class SymbolsResolver; } namespace Libraries::DiscMap { -int PS4_SYSV_ABI sceDiscMapGetPackageSize(); -int PS4_SYSV_ABI sceDiscMapIsRequestOnHDD(); -int PS4_SYSV_ABI Func_7C980FFB0AA27E7A(); -int PS4_SYSV_ABI Func_8A828CAEE7EDD5E9(); +int PS4_SYSV_ABI sceDiscMapGetPackageSize(s64 fflags, int* ret1, int* ret2); +int PS4_SYSV_ABI sceDiscMapIsRequestOnHDD(char* path, s64 offset, s64 nbytes, int* ret); +int PS4_SYSV_ABI Func_7C980FFB0AA27E7A(char* path, s64 offset, s64 nbytes, int* flags, int* ret1, + int* ret2); +int PS4_SYSV_ABI Func_8A828CAEE7EDD5E9(char* path, s64 offset, s64 nbytes, int* flags, int* ret1, + int* ret2); int PS4_SYSV_ABI Func_E7EBCE96E92F91F8(); void RegisterlibSceDiscMap(Core::Loader::SymbolsResolver* sym); diff --git a/src/core/libraries/gnmdriver/gnmdriver.cpp b/src/core/libraries/gnmdriver/gnmdriver.cpp index e2e865def..25ac4921c 100644 --- a/src/core/libraries/gnmdriver/gnmdriver.cpp +++ b/src/core/libraries/gnmdriver/gnmdriver.cpp @@ -1087,7 +1087,8 @@ s32 PS4_SYSV_ABI sceGnmInsertWaitFlipDone(u32* cmdbuf, u32 size, s32 vo_handle, } uintptr_t label_addr{}; - VideoOut::sceVideoOutGetBufferLabelAddress(vo_handle, &label_addr); + ASSERT_MSG(VideoOut::sceVideoOutGetBufferLabelAddress(vo_handle, &label_addr) == 16, + "sceVideoOutGetBufferLabelAddress call failed"); auto* wait_reg_mem = reinterpret_cast(cmdbuf); wait_reg_mem->header = PM4Type3Header{PM4ItOpcode::WaitRegMem, 5}; @@ -2041,7 +2042,8 @@ static inline s32 PatchFlipRequest(u32* cmdbuf, u32 size, u32 vo_handle, u32 buf } uintptr_t label_addr{}; - VideoOut::sceVideoOutGetBufferLabelAddress(vo_handle, &label_addr); + ASSERT_MSG(VideoOut::sceVideoOutGetBufferLabelAddress(vo_handle, &label_addr) == 16, + "sceVideoOutGetBufferLabelAddress call failed"); // Write event to lock the VO surface auto* write_lock = reinterpret_cast(cmdbuf); @@ -2802,7 +2804,7 @@ void RegisterlibSceGnmDriver(Core::Loader::SymbolsResolver* sym) { liverpool = std::make_unique(); presenter = std::make_unique(*g_window, liverpool.get()); - const int result = sceKernelGetCompiledSdkVersion(&sdk_version); + const s32 result = sceKernelGetCompiledSdkVersion(&sdk_version); if (result != ORBIS_OK) { sdk_version = 0; } diff --git a/src/core/libraries/ime/ime.cpp b/src/core/libraries/ime/ime.cpp index dfd659db8..1c61bc276 100644 --- a/src/core/libraries/ime/ime.cpp +++ b/src/core/libraries/ime/ime.cpp @@ -49,9 +49,9 @@ public: // Are we supposed to call the event handler on init with // ADD_OSK? - if (!ime_mode && False(m_param.key.option & OrbisImeKeyboardOption::AddOsk)) { + /* if (!ime_mode && False(m_param.key.option & OrbisImeKeyboardOption::AddOsk)) { Execute(nullptr, &openEvent, true); - } + }*/ if (ime_mode) { g_ime_state = ImeState(&m_param.ime); @@ -274,6 +274,13 @@ s32 PS4_SYSV_ABI sceImeKeyboardOpen(s32 userId, const OrbisImeKeyboardParam* par if (!param) { return ORBIS_IME_ERROR_INVALID_ADDRESS; } + if (!param->arg) { + return ORBIS_IME_ERROR_INVALID_ARG; + } + if (!param->handler) { + return ORBIS_IME_ERROR_INVALID_HANDLER; + } + if (g_keyboard_handler) { return ORBIS_IME_ERROR_BUSY; } diff --git a/src/core/libraries/ime/ime.h b/src/core/libraries/ime/ime.h index 448ee6896..fcf381048 100644 --- a/src/core/libraries/ime/ime.h +++ b/src/core/libraries/ime/ime.h @@ -20,7 +20,7 @@ enum class OrbisImeKeyboardOption : u32 { Repeat = 1, RepeatEachKey = 2, AddOsk = 4, - EffectiveWithTime = 8, + EffectiveWithIme = 8, DisableResume = 16, DisableCapslockWithoutShift = 32, }; diff --git a/src/core/libraries/ime/ime_dialog.cpp b/src/core/libraries/ime/ime_dialog.cpp index 9151aa64e..bee185787 100644 --- a/src/core/libraries/ime/ime_dialog.cpp +++ b/src/core/libraries/ime/ime_dialog.cpp @@ -83,9 +83,35 @@ int PS4_SYSV_ABI sceImeDialogGetPanelPositionAndForm() { return ORBIS_OK; } -int PS4_SYSV_ABI sceImeDialogGetPanelSize() { - LOG_ERROR(Lib_ImeDialog, "(STUBBED) called"); - return ORBIS_OK; +Error PS4_SYSV_ABI sceImeDialogGetPanelSize(const OrbisImeDialogParam* param, u32* width, + u32* height) { + LOG_INFO(Lib_ImeDialog, "called"); + + if (!width || !height) { + return Error::INVALID_ADDRESS; + } + switch (param->type) { + case OrbisImeType::Default: + case OrbisImeType::BasicLatin: + case OrbisImeType::Url: + case OrbisImeType::Mail: + *width = 500; // original: 793 + if (True(param->option & OrbisImeDialogOption::Multiline)) { + *height = 300; // original: 576 + } else { + *height = 150; // original: 476 + } + break; + case OrbisImeType::Number: + *width = 370; + *height = 470; + break; + default: + LOG_ERROR(Lib_ImeDialog, "Unknown OrbisImeType: {}", (u32)param->type); + return Error::INVALID_PARAM; + } + + return Error::OK; } int PS4_SYSV_ABI sceImeDialogGetPanelSizeExtended() { diff --git a/src/core/libraries/ime/ime_dialog.h b/src/core/libraries/ime/ime_dialog.h index c8b228498..526e5f022 100644 --- a/src/core/libraries/ime/ime_dialog.h +++ b/src/core/libraries/ime/ime_dialog.h @@ -13,7 +13,7 @@ class SymbolsResolver; namespace Libraries::ImeDialog { -constexpr u32 ORBIS_IME_DIALOG_MAX_TEXT_LENGTH = 0x78; +constexpr u32 ORBIS_IME_DIALOG_MAX_TEXT_LENGTH = 2048; enum class Error : u32 { OK = 0x0, @@ -155,7 +155,8 @@ Error PS4_SYSV_ABI sceImeDialogForceClose(); Error PS4_SYSV_ABI sceImeDialogForTestFunction(); int PS4_SYSV_ABI sceImeDialogGetCurrentStarState(); int PS4_SYSV_ABI sceImeDialogGetPanelPositionAndForm(); -int PS4_SYSV_ABI sceImeDialogGetPanelSize(); +Error PS4_SYSV_ABI sceImeDialogGetPanelSize(const OrbisImeDialogParam* param, u32* width, + u32* height); int PS4_SYSV_ABI sceImeDialogGetPanelSizeExtended(); Error PS4_SYSV_ABI sceImeDialogGetResult(OrbisImeDialogResult* result); OrbisImeDialogStatus PS4_SYSV_ABI sceImeDialogGetStatus(); diff --git a/src/core/libraries/kernel/debug.cpp b/src/core/libraries/kernel/debug.cpp new file mode 100644 index 000000000..0de67b8b5 --- /dev/null +++ b/src/core/libraries/kernel/debug.cpp @@ -0,0 +1,20 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "common/assert.h" +#include "core/libraries/kernel/file_system.h" +#include "core/libraries/kernel/orbis_error.h" +#include "core/libraries/libs.h" + +namespace Libraries::Kernel { + +void PS4_SYSV_ABI sceKernelDebugOutText(void* unk, char* text) { + sceKernelWrite(1, text, strlen(text)); + return; +} + +void RegisterDebug(Core::Loader::SymbolsResolver* sym) { + LIB_FUNCTION("9JYNqN6jAKI", "libkernel", 1, "libkernel", 1, 1, sceKernelDebugOutText); +} + +} // namespace Libraries::Kernel \ No newline at end of file diff --git a/src/core/libraries/kernel/debug.h b/src/core/libraries/kernel/debug.h new file mode 100644 index 000000000..177046862 --- /dev/null +++ b/src/core/libraries/kernel/debug.h @@ -0,0 +1,14 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +namespace Core::Loader { +class SymbolsResolver; +} + +namespace Libraries::Kernel { + +void RegisterDebug(Core::Loader::SymbolsResolver* sym); + +} // namespace Libraries::Kernel \ No newline at end of file diff --git a/src/core/libraries/kernel/equeue.h b/src/core/libraries/kernel/equeue.h index 11c09bb37..2bd7ef510 100644 --- a/src/core/libraries/kernel/equeue.h +++ b/src/core/libraries/kernel/equeue.h @@ -61,6 +61,18 @@ struct SceKernelEvent { void* udata = nullptr; /* opaque user data identifier */ }; +struct OrbisVideoOutEventHint { + u64 event_id : 8; + u64 video_id : 8; + u64 flip_arg : 48; +}; + +struct OrbisVideoOutEventData { + u64 time : 12; + u64 count : 4; + u64 flip_arg : 48; +}; + struct EqueueEvent { SceKernelEvent event; void* data = nullptr; @@ -84,19 +96,18 @@ struct EqueueEvent { void TriggerDisplay(void* data) { is_triggered = true; - auto hint = reinterpret_cast(data); - if (hint != 0) { - auto hint_h = static_cast(hint >> 8) & 0xFFFFFF; - auto ident_h = static_cast(event.ident >> 40); - if ((static_cast(hint) & 0xFF) == event.ident && event.ident != 0xFE && - ((hint_h ^ ident_h) & 0xFF) == 0) { + if (data != nullptr) { + auto event_data = static_cast(event.data); + auto event_hint_raw = reinterpret_cast(data); + auto event_hint = static_cast(event_hint_raw); + if (event_hint.event_id == event.ident && event.ident != 0xfe) { auto time = Common::FencedRDTSC(); - auto mask = 0xF000; - if ((static_cast(event.data) & 0xF000) != 0xF000) { - mask = (static_cast(event.data) + 0x1000) & 0xF000; + auto counter = event_data.count; + if (counter != 0xf) { + counter++; } - event.data = (mask | static_cast(static_cast(time) & 0xFFF) | - (hint & 0xFFFFFFFFFFFF0000)); + event.data = + (time & 0xfff) | (counter << 0xc) | (event_hint_raw & 0xffffffffffff0000); } } } diff --git a/src/core/libraries/kernel/file_system.cpp b/src/core/libraries/kernel/file_system.cpp index 0150c11f5..bcfa15a62 100644 --- a/src/core/libraries/kernel/file_system.cpp +++ b/src/core/libraries/kernel/file_system.cpp @@ -18,6 +18,7 @@ #include "core/file_sys/fs.h" #include "core/libraries/kernel/file_system.h" #include "core/libraries/kernel/orbis_error.h" +#include "core/libraries/kernel/posix_error.h" #include "core/libraries/libs.h" #include "core/memory.h" #include "kernel.h" @@ -57,7 +58,7 @@ static std::map available_device = { namespace Libraries::Kernel { -int PS4_SYSV_ABI sceKernelOpen(const char* raw_path, int flags, u16 mode) { +s32 PS4_SYSV_ABI open(const char* raw_path, s32 flags, u16 mode) { LOG_INFO(Kernel_Fs, "path = {} flags = {:#x} mode = {}", raw_path, flags, mode); auto* h = Common::Singleton::Instance(); auto* mnt = Common::Singleton::Instance(); @@ -99,7 +100,8 @@ int PS4_SYSV_ABI sceKernelOpen(const char* raw_path, int flags, u16 mode) { file->m_host_name = mnt->GetHostPath(file->m_guest_name); if (!std::filesystem::is_directory(file->m_host_name)) { // directory doesn't exist h->DeleteHandle(handle); - return ORBIS_KERNEL_ERROR_ENOTDIR; + *__Error() = POSIX_ENOENT; + return -1; } else { if (create) { return handle; // dir already exists @@ -116,61 +118,87 @@ int PS4_SYSV_ABI sceKernelOpen(const char* raw_path, int flags, u16 mode) { } else { file->m_guest_name = path; file->m_host_name = mnt->GetHostPath(file->m_guest_name); + bool exists = std::filesystem::exists(file->m_host_name); int e = 0; - if (read) { - e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::Read); - } else if (write && (create || truncate)) { - e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::Write); - } else if (write && create && append) { // CUSA04729 (appends app0/shaderlist.txt) - e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::Append); - } else if (rdwr) { - if (create) { // Create an empty file first. - Common::FS::IOFile out(file->m_host_name, Common::FS::FileAccessMode::Write); + + if (create) { + if (excl && exists) { + // Error if file exists + h->DeleteHandle(handle); + *__Error() = POSIX_EEXIST; + return -1; } - // RW, then scekernelWrite is called and savedata is written just fine now. - e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::ReadWrite); - } else if (write) { - e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::Write); - } else { - UNREACHABLE(); - } - if (e != 0) { + // Create file if it doesn't exist + Common::FS::IOFile out(file->m_host_name, Common::FS::FileAccessMode::Write); + } else if (!exists) { + // File to open doesn't exist, return ENOENT h->DeleteHandle(handle); - return ErrnoToSceKernelError(e); + *__Error() = POSIX_ENOENT; + return -1; + } + + if (read) { + // Read only + e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::Read); + } else if (write) { + // Write only + if (append) { + e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::Append); + } else { + e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::Write); + } + } else if (rdwr) { + // Read and write + if (append) { + e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::Append); + } else { + e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::ReadWrite); + } + } else { + // Invalid flags + *__Error() = POSIX_EINVAL; + return -1; + } + + if (truncate && e == 0) { + // If the file was opened successfully and truncate was enabled, reduce size to 0 + file->f.SetSize(0); + } + + if (e != 0) { + // Open failed in platform-specific code, errno needs to be converted. + h->DeleteHandle(handle); + SetPosixErrno(e); + return -1; } } file->is_opened = true; return handle; } -int PS4_SYSV_ABI posix_open(const char* path, int flags, /* SceKernelMode*/ u16 mode) { - LOG_INFO(Kernel_Fs, "posix open redirect to sceKernelOpen"); - int result = sceKernelOpen(path, flags, mode); - // Posix calls different only for their return values +s32 PS4_SYSV_ABI posix_open(const char* filename, s32 flags, u16 mode) { + return open(filename, flags, mode); +} + +s32 PS4_SYSV_ABI sceKernelOpen(const char* path, s32 flags, /* SceKernelMode*/ u16 mode) { + s32 result = open(path, flags, mode); if (result < 0) { - ErrSceToPosix(result); - return -1; + LOG_ERROR(Kernel_Fs, "error = {}", *__Error()); + return ErrnoToSceKernelError(*__Error()); } return result; } -int PS4_SYSV_ABI open(const char* filename, const char* mode) { - LOG_INFO(Kernel_Fs, "open redirect to sceKernelOpen"); - int result = sceKernelOpen(filename, ORBIS_KERNEL_O_RDWR, 0); - if (result < 0) { - return -1; - } - return result; -} - -int PS4_SYSV_ABI sceKernelClose(int d) { - if (d < 3) { // d probably hold an error code - return ORBIS_KERNEL_ERROR_EPERM; - } +s32 PS4_SYSV_ABI close(s32 fd) { auto* h = Common::Singleton::Instance(); - auto* file = h->GetFile(d); + auto* file = h->GetFile(fd); if (file == nullptr) { - return ORBIS_KERNEL_ERROR_EBADF; + *__Error() = POSIX_EBADF; + return -1; + } + if (fd < 3) { + // This is technically possible, but it's usually caused by some stubbed function instead. + LOG_WARNING(Kernel_Fs, "called on an std handle, fd = {}", fd); } if (file->type == Core::FileSys::FileType::Regular) { file->f.Close(); @@ -178,63 +206,54 @@ int PS4_SYSV_ABI sceKernelClose(int d) { file->is_opened = false; LOG_INFO(Kernel_Fs, "Closing {}", file->m_guest_name); // FIXME: Lock file mutex before deleting it? - h->DeleteHandle(d); + h->DeleteHandle(fd); return ORBIS_OK; } -int PS4_SYSV_ABI posix_close(int d) { - int result = sceKernelClose(d); +s32 PS4_SYSV_ABI posix_close(s32 fd) { + return close(fd); +} + +s32 PS4_SYSV_ABI sceKernelClose(s32 fd) { + s32 result = close(fd); if (result < 0) { - LOG_ERROR(Kernel_Pthread, "posix_close: error = {}", result); - ErrSceToPosix(result); - return -1; + LOG_ERROR(Kernel_Fs, "error = {}", *__Error()); + return ErrnoToSceKernelError(*__Error()); } return result; } -s64 PS4_SYSV_ABI sceKernelWrite(int d, const void* buf, size_t nbytes) { +s64 PS4_SYSV_ABI write(s32 fd, const void* buf, size_t nbytes) { auto* h = Common::Singleton::Instance(); - auto* file = h->GetFile(d); + auto* file = h->GetFile(fd); if (file == nullptr) { - return ORBIS_KERNEL_ERROR_EBADF; + *__Error() = POSIX_EBADF; + return -1; } std::scoped_lock lk{file->m_mutex}; if (file->type == Core::FileSys::FileType::Device) { - return file->device->write(buf, nbytes); + s64 result = file->device->write(buf, nbytes); + if (result < 0) { + ErrSceToPosix(result); + return -1; + } + return result; } return file->f.WriteRaw(buf, nbytes); } -int PS4_SYSV_ABI sceKernelUnlink(const char* path) { - if (path == nullptr) { - return ORBIS_KERNEL_ERROR_EINVAL; +s64 PS4_SYSV_ABI posix_write(s32 fd, const void* buf, size_t nbytes) { + return write(fd, buf, nbytes); +} + +s64 PS4_SYSV_ABI sceKernelWrite(s32 fd, const void* buf, size_t nbytes) { + s64 result = write(fd, buf, nbytes); + if (result < 0) { + LOG_ERROR(Kernel_Fs, "error = {}", *__Error()); + return ErrnoToSceKernelError(*__Error()); } - - auto* h = Common::Singleton::Instance(); - auto* mnt = Common::Singleton::Instance(); - - bool ro = false; - const auto host_path = mnt->GetHostPath(path, &ro); - if (host_path.empty()) { - return ORBIS_KERNEL_ERROR_EACCES; - } - - if (ro) { - return ORBIS_KERNEL_ERROR_EROFS; - } - - if (std::filesystem::is_directory(host_path)) { - return ORBIS_KERNEL_ERROR_EPERM; - } - - auto* file = h->GetFile(host_path); - if (file != nullptr) { - file->f.Unlink(); - } - - LOG_INFO(Kernel_Fs, "Unlinked {}", path); - return ORBIS_OK; + return result; } size_t ReadFile(Common::FS::IOFile& file, void* buf, size_t nbytes) { @@ -246,58 +265,97 @@ size_t ReadFile(Common::FS::IOFile& file, void* buf, size_t nbytes) { return file.ReadRaw(buf, nbytes); } -size_t PS4_SYSV_ABI _readv(int d, const SceKernelIovec* iov, int iovcnt) { +size_t PS4_SYSV_ABI readv(s32 fd, const SceKernelIovec* iov, s32 iovcnt) { auto* h = Common::Singleton::Instance(); - auto* file = h->GetFile(d); + auto* file = h->GetFile(fd); if (file == nullptr) { - return ORBIS_KERNEL_ERROR_EBADF; + *__Error() = POSIX_EBADF; + return -1; } std::scoped_lock lk{file->m_mutex}; if (file->type == Core::FileSys::FileType::Device) { - int r = file->device->readv(iov, iovcnt); - if (r < 0) { - ErrSceToPosix(r); + size_t result = file->device->readv(iov, iovcnt); + if (result < 0) { + ErrSceToPosix(result); return -1; } - return r; + return result; } size_t total_read = 0; - for (int i = 0; i < iovcnt; i++) { + for (s32 i = 0; i < iovcnt; i++) { total_read += ReadFile(file->f, iov[i].iov_base, iov[i].iov_len); } return total_read; } -size_t PS4_SYSV_ABI _writev(int fd, const SceKernelIovec* iov, int iovcn) { +size_t PS4_SYSV_ABI posix_readv(s32 fd, const SceKernelIovec* iov, s32 iovcnt) { + return readv(fd, iov, iovcnt); +} + +size_t PS4_SYSV_ABI sceKernelReadv(s32 fd, const SceKernelIovec* iov, s32 iovcnt) { + size_t result = readv(fd, iov, iovcnt); + if (result < 0) { + LOG_ERROR(Kernel_Fs, "error = {}", *__Error()); + return ErrnoToSceKernelError(*__Error()); + } + return result; +} + +size_t PS4_SYSV_ABI writev(s32 fd, const SceKernelIovec* iov, s32 iovcnt) { auto* h = Common::Singleton::Instance(); auto* file = h->GetFile(fd); if (file == nullptr) { - return ORBIS_KERNEL_ERROR_EBADF; + *__Error() = POSIX_EBADF; + return -1; } std::scoped_lock lk{file->m_mutex}; if (file->type == Core::FileSys::FileType::Device) { - return file->device->writev(iov, iovcn); + size_t result = file->device->writev(iov, iovcnt); + if (result < 0) { + ErrSceToPosix(result); + return -1; + } + return result; } size_t total_written = 0; - for (int i = 0; i < iovcn; i++) { + for (s32 i = 0; i < iovcnt; i++) { total_written += file->f.WriteRaw(iov[i].iov_base, iov[i].iov_len); } return total_written; } -s64 PS4_SYSV_ABI sceKernelLseek(int d, s64 offset, int whence) { +size_t PS4_SYSV_ABI posix_writev(s32 fd, const SceKernelIovec* iov, s32 iovcnt) { + return writev(fd, iov, iovcnt); +} + +size_t PS4_SYSV_ABI sceKernelWritev(s32 fd, const SceKernelIovec* iov, s32 iovcnt) { + size_t result = writev(fd, iov, iovcnt); + if (result < 0) { + LOG_ERROR(Kernel_Fs, "error = {}", *__Error()); + return ErrnoToSceKernelError(*__Error()); + } + return result; +} + +s64 PS4_SYSV_ABI posix_lseek(s32 fd, s64 offset, s32 whence) { auto* h = Common::Singleton::Instance(); - auto* file = h->GetFile(d); + auto* file = h->GetFile(fd); if (file == nullptr) { - return ORBIS_KERNEL_ERROR_EBADF; + *__Error() = POSIX_EBADF; + return -1; } std::scoped_lock lk{file->m_mutex}; if (file->type == Core::FileSys::FileType::Device) { - return file->device->lseek(offset, whence); + s64 result = file->device->lseek(offset, whence); + if (result < 0) { + ErrSceToPosix(result); + return -1; + } + return result; } Common::FS::SeekOrigin origin{}; @@ -307,53 +365,82 @@ s64 PS4_SYSV_ABI sceKernelLseek(int d, s64 offset, int whence) { origin = Common::FS::SeekOrigin::CurrentPosition; } else if (whence == 2) { origin = Common::FS::SeekOrigin::End; + } else if (whence == 3) { + origin = Common::FS::SeekOrigin::SeekHole; + } else if (whence == 4) { + origin = Common::FS::SeekOrigin::SeekData; + } else { + // whence parameter is invalid + *__Error() = POSIX_EINVAL; + return -1; } if (!file->f.Seek(offset, origin)) { - LOG_CRITICAL(Kernel_Fs, "sceKernelLseek: failed to seek"); - return ORBIS_KERNEL_ERROR_EINVAL; + if (errno != 0) { + // Seek failed in platform-specific code, errno needs to be converted. + SetPosixErrno(errno); + return -1; + } + // Shouldn't be possible, but just in case. + return -1; } - return file->f.Tell(); -} -s64 PS4_SYSV_ABI posix_lseek(int d, s64 offset, int whence) { - s64 result = sceKernelLseek(d, offset, whence); + s64 result = file->f.Tell(); if (result < 0) { - LOG_ERROR(Kernel_Pthread, "posix_lseek: error = {}", result); - ErrSceToPosix(result); + // Tell failed in platform-specific code, errno needs to be converted. + SetPosixErrno(errno); return -1; } return result; } -s64 PS4_SYSV_ABI sceKernelRead(int d, void* buf, size_t nbytes) { +s64 PS4_SYSV_ABI sceKernelLseek(s32 fd, s64 offset, s32 whence) { + s64 result = posix_lseek(fd, offset, whence); + if (result < 0) { + LOG_ERROR(Kernel_Fs, "error = {}", *__Error()); + return ErrnoToSceKernelError(*__Error()); + } + return result; +} + +s64 PS4_SYSV_ABI read(s32 fd, void* buf, size_t nbytes) { auto* h = Common::Singleton::Instance(); - auto* file = h->GetFile(d); + auto* file = h->GetFile(fd); if (file == nullptr) { - return ORBIS_KERNEL_ERROR_EBADF; + *__Error() = POSIX_EBADF; + return -1; } std::scoped_lock lk{file->m_mutex}; if (file->type == Core::FileSys::FileType::Device) { - return file->device->read(buf, nbytes); + s64 result = file->device->read(buf, nbytes); + if (result < 0) { + ErrSceToPosix(result); + return -1; + } + return result; } return ReadFile(file->f, buf, nbytes); } -int PS4_SYSV_ABI posix_read(int d, void* buf, size_t nbytes) { - int result = sceKernelRead(d, buf, nbytes); +s64 PS4_SYSV_ABI posix_read(s32 fd, void* buf, size_t nbytes) { + return read(fd, buf, nbytes); +} + +s64 PS4_SYSV_ABI sceKernelRead(s32 fd, void* buf, size_t nbytes) { + s64 result = read(fd, buf, nbytes); if (result < 0) { - LOG_ERROR(Kernel_Pthread, "posix_read: error = {}", result); - ErrSceToPosix(result); - return -1; + LOG_ERROR(Kernel_Fs, "error = {}", *__Error()); + return ErrnoToSceKernelError(*__Error()); } return result; } -int PS4_SYSV_ABI sceKernelMkdir(const char* path, u16 mode) { +s32 PS4_SYSV_ABI posix_mkdir(const char* path, u16 mode) { LOG_INFO(Kernel_Fs, "path = {} mode = {}", path, mode); if (path == nullptr) { - return ORBIS_KERNEL_ERROR_EINVAL; + *__Error() = POSIX_ENOTDIR; + return -1; } auto* mnt = Common::Singleton::Instance(); @@ -361,88 +448,79 @@ int PS4_SYSV_ABI sceKernelMkdir(const char* path, u16 mode) { const auto dir_name = mnt->GetHostPath(path, &ro); if (std::filesystem::exists(dir_name)) { - return ORBIS_KERNEL_ERROR_EEXIST; + *__Error() = POSIX_EEXIST; + return -1; } if (ro) { - return ORBIS_KERNEL_ERROR_EROFS; + *__Error() = POSIX_EROFS; + return -1; } // CUSA02456: path = /aotl after sceSaveDataMount(mode = 1) std::error_code ec; if (dir_name.empty() || !std::filesystem::create_directory(dir_name, ec)) { - return ORBIS_KERNEL_ERROR_EIO; + *__Error() = POSIX_EIO; + return -1; } if (!std::filesystem::exists(dir_name)) { - return ORBIS_KERNEL_ERROR_ENOENT; + *__Error() = POSIX_ENOENT; + return -1; } return ORBIS_OK; } -int PS4_SYSV_ABI posix_mkdir(const char* path, u16 mode) { - int result = sceKernelMkdir(path, mode); +s32 PS4_SYSV_ABI sceKernelMkdir(const char* path, u16 mode) { + s32 result = posix_mkdir(path, mode); if (result < 0) { - LOG_ERROR(Kernel_Pthread, "posix_mkdir: error = {}", result); - ErrSceToPosix(result); - return -1; + LOG_ERROR(Kernel_Fs, "error = {}", *__Error()); + return ErrnoToSceKernelError(*__Error()); } return result; } -int PS4_SYSV_ABI sceKernelRmdir(const char* path) { +s32 PS4_SYSV_ABI posix_rmdir(const char* path) { auto* mnt = Common::Singleton::Instance(); bool ro = false; const std::filesystem::path dir_name = mnt->GetHostPath(path, &ro); - if (dir_name.empty()) { - LOG_ERROR(Kernel_Fs, "Failed to remove directory: {}, permission denied", - fmt::UTF(dir_name.u8string())); - return ORBIS_KERNEL_ERROR_EACCES; + if (dir_name.empty() || !std::filesystem::is_directory(dir_name)) { + *__Error() = POSIX_ENOTDIR; + return -1; } if (ro) { - LOG_ERROR(Kernel_Fs, "Failed to remove directory: {}, directory is read only", - fmt::UTF(dir_name.u8string())); - return ORBIS_KERNEL_ERROR_EROFS; - } - - if (!std::filesystem::is_directory(dir_name)) { - LOG_ERROR(Kernel_Fs, "Failed to remove directory: {}, path is not a directory", - fmt::UTF(dir_name.u8string())); - return ORBIS_KERNEL_ERROR_ENOTDIR; + *__Error() = POSIX_EROFS; + return -1; } if (!std::filesystem::exists(dir_name)) { - LOG_ERROR(Kernel_Fs, "Failed to remove directory: {}, no such file or directory", - fmt::UTF(dir_name.u8string())); - return ORBIS_KERNEL_ERROR_ENOENT; + *__Error() = POSIX_ENOENT; + return -1; } std::error_code ec; - int result = std::filesystem::remove_all(dir_name, ec); + s32 result = std::filesystem::remove_all(dir_name, ec); - if (!ec) { - LOG_INFO(Kernel_Fs, "Removed directory: {}", fmt::UTF(dir_name.u8string())); - return ORBIS_OK; + if (ec) { + *__Error() = POSIX_EIO; + return -1; } - LOG_ERROR(Kernel_Fs, "Failed to remove directory: {}, error_code={}", - fmt::UTF(dir_name.u8string()), ec.message()); - return ErrnoToSceKernelError(ec.value()); + return ORBIS_OK; } -int PS4_SYSV_ABI posix_rmdir(const char* path) { - int result = sceKernelRmdir(path); +s32 PS4_SYSV_ABI sceKernelRmdir(const char* path) { + s32 result = posix_rmdir(path); if (result < 0) { - LOG_ERROR(Kernel_Pthread, "posix_rmdir: error = {}", result); - ErrSceToPosix(result); - return -1; + LOG_ERROR(Kernel_Fs, "error = {}", *__Error()); + return ErrnoToSceKernelError(*__Error()); } return result; } -int PS4_SYSV_ABI sceKernelStat(const char* path, OrbisKernelStat* sb) { +s32 PS4_SYSV_ABI posix_stat(const char* path, OrbisKernelStat* sb) { LOG_INFO(Kernel_Fs, "(PARTIAL) path = {}", path); auto* mnt = Common::Singleton::Instance(); bool ro = false; @@ -451,7 +529,8 @@ int PS4_SYSV_ABI sceKernelStat(const char* path, OrbisKernelStat* sb) { const bool is_dir = std::filesystem::is_directory(path_name); const bool is_file = std::filesystem::is_regular_file(path_name); if (!is_dir && !is_file) { - return ORBIS_KERNEL_ERROR_ENOENT; + *__Error() = POSIX_ENOENT; + return -1; } if (std::filesystem::is_directory(path_name)) { sb->st_mode = 0000777u | 0040000u; @@ -461,7 +540,7 @@ int PS4_SYSV_ABI sceKernelStat(const char* path, OrbisKernelStat* sb) { // TODO incomplete } else { sb->st_mode = 0000777u | 0100000u; - sb->st_size = static_cast(std::filesystem::file_size(path_name)); + sb->st_size = static_cast(std::filesystem::file_size(path_name)); sb->st_blksize = 512; sb->st_blocks = (sb->st_size + 511) / 512; // TODO incomplete @@ -473,17 +552,16 @@ int PS4_SYSV_ABI sceKernelStat(const char* path, OrbisKernelStat* sb) { return ORBIS_OK; } -int PS4_SYSV_ABI posix_stat(const char* path, OrbisKernelStat* sb) { - int result = sceKernelStat(path, sb); +s32 PS4_SYSV_ABI sceKernelStat(const char* path, OrbisKernelStat* sb) { + s32 result = posix_stat(path, sb); if (result < 0) { - LOG_ERROR(Kernel_Pthread, "posix_stat: error = {}", result); - ErrSceToPosix(result); - return -1; + LOG_ERROR(Kernel_Fs, "error = {}", *__Error()); + return ErrnoToSceKernelError(*__Error()); } return result; } -int PS4_SYSV_ABI sceKernelCheckReachability(const char* path) { +s32 PS4_SYSV_ABI sceKernelCheckReachability(const char* path) { auto* mnt = Common::Singleton::Instance(); std::string_view guest_path{path}; for (const auto& prefix : available_device | std::views::keys) { @@ -498,23 +576,165 @@ int PS4_SYSV_ABI sceKernelCheckReachability(const char* path) { return ORBIS_OK; } -s64 PS4_SYSV_ABI sceKernelPreadv(int d, SceKernelIovec* iov, int iovcnt, s64 offset) { - if (d < 3) { - return ORBIS_KERNEL_ERROR_EPERM; +s32 PS4_SYSV_ABI fstat(s32 fd, OrbisKernelStat* sb) { + LOG_INFO(Kernel_Fs, "(PARTIAL) fd = {}", fd); + if (sb == nullptr) { + *__Error() = POSIX_EFAULT; + return -1; } + auto* h = Common::Singleton::Instance(); + auto* file = h->GetFile(fd); + if (file == nullptr) { + *__Error() = POSIX_EBADF; + return -1; + } + std::memset(sb, 0, sizeof(OrbisKernelStat)); + + switch (file->type) { + case Core::FileSys::FileType::Device: { + s32 result = file->device->fstat(sb); + if (result < 0) { + ErrSceToPosix(result); + return -1; + } + return result; + } + case Core::FileSys::FileType::Regular: { + sb->st_mode = 0000777u | 0100000u; + sb->st_size = file->f.GetSize(); + sb->st_blksize = 512; + sb->st_blocks = (sb->st_size + 511) / 512; + // TODO incomplete + break; + } + case Core::FileSys::FileType::Directory: { + sb->st_mode = 0000777u | 0040000u; + sb->st_size = 0; + sb->st_blksize = 512; + sb->st_blocks = 0; + // TODO incomplete + break; + } + default: + UNREACHABLE(); + } + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI posix_fstat(s32 fd, OrbisKernelStat* sb) { + return fstat(fd, sb); +} + +s32 PS4_SYSV_ABI sceKernelFstat(s32 fd, OrbisKernelStat* sb) { + s32 result = fstat(fd, sb); + if (result < 0) { + LOG_ERROR(Kernel_Fs, "error = {}", *__Error()); + return ErrnoToSceKernelError(*__Error()); + } + return result; +} + +s32 PS4_SYSV_ABI posix_ftruncate(s32 fd, s64 length) { + auto* h = Common::Singleton::Instance(); + auto* file = h->GetFile(fd); + + if (file == nullptr) { + *__Error() = POSIX_EBADF; + return -1; + } + + if (file->type == Core::FileSys::FileType::Device) { + s32 result = file->device->ftruncate(length); + if (result < 0) { + ErrSceToPosix(result); + return -1; + } + return result; + } + + if (file->m_host_name.empty()) { + *__Error() = POSIX_EACCES; + return -1; + } + + file->f.SetSize(length); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceKernelFtruncate(s32 fd, s64 length) { + s32 result = posix_ftruncate(fd, length); + if (result < 0) { + LOG_ERROR(Kernel_Fs, "error = {}", *__Error()); + return ErrnoToSceKernelError(*__Error()); + } + return result; +} + +s32 PS4_SYSV_ABI posix_rename(const char* from, const char* to) { + auto* mnt = Common::Singleton::Instance(); + bool ro = false; + const auto src_path = mnt->GetHostPath(from, &ro); + if (!std::filesystem::exists(src_path)) { + *__Error() = POSIX_ENOENT; + return -1; + } + if (ro) { + *__Error() = POSIX_EROFS; + return -1; + } + const auto dst_path = mnt->GetHostPath(to, &ro); + if (ro) { + *__Error() = POSIX_EROFS; + return -1; + } + const bool src_is_dir = std::filesystem::is_directory(src_path); + const bool dst_is_dir = std::filesystem::is_directory(dst_path); + if (src_is_dir && !dst_is_dir) { + *__Error() = POSIX_ENOTDIR; + return -1; + } + if (!src_is_dir && dst_is_dir) { + *__Error() = POSIX_EISDIR; + return -1; + } + if (dst_is_dir && !std::filesystem::is_empty(dst_path)) { + *__Error() = POSIX_ENOTEMPTY; + return -1; + } + std::filesystem::copy(src_path, dst_path, std::filesystem::copy_options::overwrite_existing); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceKernelRename(const char* from, const char* to) { + s32 result = posix_rename(from, to); + if (result < 0) { + LOG_ERROR(Kernel_Fs, "error = {}", *__Error()); + return ErrnoToSceKernelError(*__Error()); + } + return result; +} + +s64 PS4_SYSV_ABI posix_preadv(s32 fd, SceKernelIovec* iov, s32 iovcnt, s64 offset) { if (offset < 0) { - return ORBIS_KERNEL_ERROR_EINVAL; + *__Error() = POSIX_EINVAL; + return -1; } auto* h = Common::Singleton::Instance(); - auto* file = h->GetFile(d); + auto* file = h->GetFile(fd); if (file == nullptr) { - return ORBIS_KERNEL_ERROR_EBADF; + *__Error() = POSIX_EBADF; + return -1; } std::scoped_lock lk{file->m_mutex}; if (file->type == Core::FileSys::FileType::Device) { - return file->device->preadv(iov, iovcnt, offset); + s64 result = file->device->preadv(iov, iovcnt, offset); + if (result < 0) { + ErrSceToPosix(result); + return -1; + } + return result; } const s64 pos = file->f.Tell(); @@ -522,8 +742,8 @@ s64 PS4_SYSV_ABI sceKernelPreadv(int d, SceKernelIovec* iov, int iovcnt, s64 off file->f.Seek(pos); }; if (!file->f.Seek(offset)) { - LOG_CRITICAL(Kernel_Fs, "failed to seek"); - return ORBIS_KERNEL_ERROR_EINVAL; + *__Error() = POSIX_EIO; + return -1; } size_t total_read = 0; for (int i = 0; i < iovcnt; i++) { @@ -532,118 +752,72 @@ s64 PS4_SYSV_ABI sceKernelPreadv(int d, SceKernelIovec* iov, int iovcnt, s64 off return total_read; } -s64 PS4_SYSV_ABI sceKernelPread(int d, void* buf, size_t nbytes, s64 offset) { - SceKernelIovec iovec{buf, nbytes}; - return sceKernelPreadv(d, &iovec, 1, offset); -} - -int PS4_SYSV_ABI sceKernelFStat(int fd, OrbisKernelStat* sb) { - LOG_INFO(Kernel_Fs, "(PARTIAL) fd = {}", fd); - if (fd < 3) { - return ORBIS_KERNEL_ERROR_EPERM; - } - if (sb == nullptr) { - return ORBIS_KERNEL_ERROR_EFAULT; - } - auto* h = Common::Singleton::Instance(); - auto* file = h->GetFile(fd); - if (file == nullptr) { - return ORBIS_KERNEL_ERROR_EBADF; - } - std::memset(sb, 0, sizeof(OrbisKernelStat)); - - switch (file->type) { - case Core::FileSys::FileType::Device: - return file->device->fstat(sb); - case Core::FileSys::FileType::Regular: - sb->st_mode = 0000777u | 0100000u; - sb->st_size = file->f.GetSize(); - sb->st_blksize = 512; - sb->st_blocks = (sb->st_size + 511) / 512; - // TODO incomplete - break; - case Core::FileSys::FileType::Directory: - sb->st_mode = 0000777u | 0040000u; - sb->st_size = 0; - sb->st_blksize = 512; - sb->st_blocks = 0; - // TODO incomplete - break; - default: - UNREACHABLE(); - } - return ORBIS_OK; -} - -int PS4_SYSV_ABI posix_fstat(int fd, OrbisKernelStat* sb) { - int result = sceKernelFStat(fd, sb); +s64 PS4_SYSV_ABI sceKernelPreadv(s32 fd, SceKernelIovec* iov, s32 iovcnt, s64 offset) { + s64 result = posix_preadv(fd, iov, iovcnt, offset); if (result < 0) { - LOG_ERROR(Kernel_Pthread, "posix_fstat: error = {}", result); - ErrSceToPosix(result); - return -1; + LOG_ERROR(Kernel_Fs, "error = {}", *__Error()); + return ErrnoToSceKernelError(*__Error()); } return result; } -s32 PS4_SYSV_ABI sceKernelFsync(int fd) { +s64 PS4_SYSV_ABI posix_pread(s32 fd, void* buf, size_t nbytes, s64 offset) { + SceKernelIovec iovec{buf, nbytes}; + return posix_preadv(fd, &iovec, 1, offset); +} + +s64 PS4_SYSV_ABI sceKernelPread(s32 fd, void* buf, size_t nbytes, s64 offset) { + SceKernelIovec iovec{buf, nbytes}; + return sceKernelPreadv(fd, &iovec, 1, offset); +} + +s32 PS4_SYSV_ABI posix_fsync(s32 fd) { auto* h = Common::Singleton::Instance(); auto* file = h->GetFile(fd); if (file == nullptr) { - return ORBIS_KERNEL_ERROR_EBADF; + *__Error() = POSIX_EBADF; + return -1; } if (file->type == Core::FileSys::FileType::Device) { - return file->device->fsync(); + s32 result = file->device->fsync(); + if (result < 0) { + ErrSceToPosix(result); + return -1; + } + return result; } file->f.Flush(); return ORBIS_OK; } -s32 PS4_SYSV_ABI posix_fsync(int fd) { - s32 result = sceKernelFsync(fd); +s32 PS4_SYSV_ABI sceKernelFsync(s32 fd) { + s32 result = posix_fsync(fd); if (result < 0) { - LOG_ERROR(Kernel_Pthread, "posix_fsync: error = {}", result); - ErrSceToPosix(result); - return -1; + LOG_ERROR(Kernel_Fs, "error = {}", *__Error()); + return ErrnoToSceKernelError(*__Error()); } return result; } -int PS4_SYSV_ABI sceKernelFtruncate(int fd, s64 length) { - auto* h = Common::Singleton::Instance(); - auto* file = h->GetFile(fd); - - if (file == nullptr) { - return ORBIS_KERNEL_ERROR_EBADF; - } - - if (file->type == Core::FileSys::FileType::Device) { - return file->device->ftruncate(length); - } - - if (file->m_host_name.empty()) { - return ORBIS_KERNEL_ERROR_EACCES; - } - - file->f.SetSize(length); - return ORBIS_OK; -} - -static int GetDents(int fd, char* buf, int nbytes, s64* basep) { - if (fd < 3) { - return ORBIS_KERNEL_ERROR_EBADF; - } - +static s32 GetDents(s32 fd, char* buf, s32 nbytes, s64* basep) { if (buf == nullptr) { - return ORBIS_KERNEL_ERROR_EFAULT; + *__Error() = POSIX_EFAULT; + return -1; } auto* h = Common::Singleton::Instance(); auto* file = h->GetFile(fd); if (file == nullptr) { - return ORBIS_KERNEL_ERROR_EBADF; + *__Error() = POSIX_EBADF; + return -1; } if (file->type == Core::FileSys::FileType::Device) { - return file->device->getdents(buf, nbytes, basep); + s32 result = file->device->getdents(buf, nbytes, basep); + if (result < 0) { + ErrSceToPosix(result); + return -1; + } + return result; } if (file->dirents_index == file->dirents.size()) { @@ -651,7 +825,8 @@ static int GetDents(int fd, char* buf, int nbytes, s64* basep) { } if (file->type != Core::FileSys::FileType::Directory || nbytes < 512 || file->dirents_index > file->dirents.size()) { - return ORBIS_KERNEL_ERROR_EINVAL; + *__Error() = POSIX_EINVAL; + return -1; } const auto& entry = file->dirents.at(file->dirents_index++); auto str = entry.name; @@ -672,118 +847,199 @@ static int GetDents(int fd, char* buf, int nbytes, s64* basep) { return sizeof(OrbisKernelDirent); } -int PS4_SYSV_ABI sceKernelGetdents(int fd, char* buf, int nbytes) { +s32 PS4_SYSV_ABI posix_getdents(s32 fd, char* buf, s32 nbytes) { return GetDents(fd, buf, nbytes, nullptr); } -int PS4_SYSV_ABI sceKernelGetdirentries(int fd, char* buf, int nbytes, s64* basep) { +s32 PS4_SYSV_ABI sceKernelGetdents(s32 fd, char* buf, s32 nbytes) { + s32 result = GetDents(fd, buf, nbytes, nullptr); + if (result < 0) { + LOG_ERROR(Kernel_Fs, "error = {}", *__Error()); + return ErrnoToSceKernelError(*__Error()); + } + return result; +} + +s32 PS4_SYSV_ABI getdirentries(s32 fd, char* buf, s32 nbytes, s64* basep) { return GetDents(fd, buf, nbytes, basep); } -s64 PS4_SYSV_ABI sceKernelPwrite(int d, void* buf, size_t nbytes, s64 offset) { - if (d < 3) { - return ORBIS_KERNEL_ERROR_EPERM; +s32 PS4_SYSV_ABI posix_getdirentries(s32 fd, char* buf, s32 nbytes, s64* basep) { + return GetDents(fd, buf, nbytes, basep); +} + +s32 PS4_SYSV_ABI sceKernelGetdirentries(s32 fd, char* buf, s32 nbytes, s64* basep) { + s32 result = GetDents(fd, buf, nbytes, basep); + if (result < 0) { + LOG_ERROR(Kernel_Fs, "error = {}", *__Error()); + return ErrnoToSceKernelError(*__Error()); } + return result; +} + +s64 PS4_SYSV_ABI posix_pwritev(s32 fd, const SceKernelIovec* iov, s32 iovcnt, s64 offset) { if (offset < 0) { - return ORBIS_KERNEL_ERROR_EINVAL; + *__Error() = POSIX_EINVAL; + return -1; } auto* h = Common::Singleton::Instance(); - auto* file = h->GetFile(d); + auto* file = h->GetFile(fd); if (file == nullptr) { - return ORBIS_KERNEL_ERROR_EBADF; + *__Error() = POSIX_EBADF; + return -1; } std::scoped_lock lk{file->m_mutex}; if (file->type == Core::FileSys::FileType::Device) { - return file->device->pwrite(buf, nbytes, offset); + s64 result = file->device->pwritev(iov, iovcnt, offset); + if (result < 0) { + ErrSceToPosix(result); + return -1; + } + return result; } const s64 pos = file->f.Tell(); SCOPE_EXIT { file->f.Seek(pos); }; if (!file->f.Seek(offset)) { - LOG_CRITICAL(Kernel_Fs, "sceKernelPwrite: failed to seek"); - return ORBIS_KERNEL_ERROR_EINVAL; + *__Error() = POSIX_EIO; + return -1; } - return file->f.WriteRaw(buf, nbytes); + size_t total_written = 0; + for (int i = 0; i < iovcnt; i++) { + total_written += file->f.WriteRaw(iov[i].iov_base, iov[i].iov_len); + } + return total_written; } -s32 PS4_SYSV_ABI sceKernelRename(const char* from, const char* to) { +s64 PS4_SYSV_ABI posix_pwrite(s32 fd, void* buf, size_t nbytes, s64 offset) { + SceKernelIovec iovec{buf, nbytes}; + return posix_pwritev(fd, &iovec, 1, offset); +} + +s64 PS4_SYSV_ABI sceKernelPwrite(s32 fd, void* buf, size_t nbytes, s64 offset) { + s64 result = posix_pwrite(fd, buf, nbytes, offset); + if (result < 0) { + LOG_ERROR(Kernel_Fs, "error = {}", *__Error()); + return ErrnoToSceKernelError(*__Error()); + } + return result; +} + +s64 PS4_SYSV_ABI sceKernelPwritev(s32 fd, const SceKernelIovec* iov, s32 iovcnt, s64 offset) { + s64 result = posix_pwritev(fd, iov, iovcnt, offset); + if (result < 0) { + LOG_ERROR(Kernel_Fs, "error = {}", *__Error()); + return ErrnoToSceKernelError(*__Error()); + } + return result; +} + +s32 PS4_SYSV_ABI posix_unlink(const char* path) { + if (path == nullptr) { + *__Error() = POSIX_EINVAL; + return -1; + } + + auto* h = Common::Singleton::Instance(); auto* mnt = Common::Singleton::Instance(); + bool ro = false; - const auto src_path = mnt->GetHostPath(from, &ro); - if (!std::filesystem::exists(src_path)) { - return ORBIS_KERNEL_ERROR_ENOENT; + const auto host_path = mnt->GetHostPath(path, &ro); + if (host_path.empty()) { + *__Error() = POSIX_ENOENT; + return -1; } + if (ro) { - return ORBIS_KERNEL_ERROR_EROFS; + *__Error() = POSIX_EROFS; + return -1; } - const auto dst_path = mnt->GetHostPath(to, &ro); - if (ro) { - return ORBIS_KERNEL_ERROR_EROFS; + + if (std::filesystem::is_directory(host_path)) { + *__Error() = POSIX_EPERM; + return -1; } - const bool src_is_dir = std::filesystem::is_directory(src_path); - const bool dst_is_dir = std::filesystem::is_directory(dst_path); - if (src_is_dir && !dst_is_dir) { - return ORBIS_KERNEL_ERROR_ENOTDIR; + + auto* file = h->GetFile(host_path); + if (file == nullptr) { + // File to unlink hasn't been opened, manually open and unlink it. + Common::FS::IOFile file(host_path, Common::FS::FileAccessMode::ReadWrite); + file.Unlink(); + } else { + file->f.Unlink(); } - if (!src_is_dir && dst_is_dir) { - return ORBIS_KERNEL_ERROR_EISDIR; - } - if (dst_is_dir && !std::filesystem::is_empty(dst_path)) { - return ORBIS_KERNEL_ERROR_ENOTEMPTY; - } - std::filesystem::copy(src_path, dst_path, std::filesystem::copy_options::overwrite_existing); + + LOG_INFO(Kernel_Fs, "Unlinked {}", path); return ORBIS_OK; } -void RegisterFileSystem(Core::Loader::SymbolsResolver* sym) { - LIB_FUNCTION("1G3lF1Gg1k8", "libkernel", 1, "libkernel", 1, 1, sceKernelOpen); - LIB_FUNCTION("wuCroIGjt2g", "libScePosix", 1, "libkernel", 1, 1, posix_open); - LIB_FUNCTION("wuCroIGjt2g", "libkernel", 1, "libkernel", 1, 1, open); - LIB_FUNCTION("UK2Tl2DWUns", "libkernel", 1, "libkernel", 1, 1, sceKernelClose); - LIB_FUNCTION("bY-PO6JhzhQ", "libkernel", 1, "libkernel", 1, 1, posix_close); - LIB_FUNCTION("bY-PO6JhzhQ", "libScePosix", 1, "libkernel", 1, 1, posix_close); - LIB_FUNCTION("4wSze92BhLI", "libkernel", 1, "libkernel", 1, 1, sceKernelWrite); +s32 PS4_SYSV_ABI sceKernelUnlink(const char* path) { + s32 result = posix_unlink(path); + if (result < 0) { + LOG_ERROR(Kernel_Fs, "error = {}", *__Error()); + return ErrnoToSceKernelError(*__Error()); + } + return result; +} - LIB_FUNCTION("+WRlkKjZvag", "libkernel", 1, "libkernel", 1, 1, _readv); - LIB_FUNCTION("YSHRBRLn2pI", "libkernel", 1, "libkernel", 1, 1, _writev); - LIB_FUNCTION("Oy6IpwgtYOk", "libkernel", 1, "libkernel", 1, 1, posix_lseek); +void RegisterFileSystem(Core::Loader::SymbolsResolver* sym) { + LIB_FUNCTION("6c3rCVE-fTU", "libkernel", 1, "libkernel", 1, 1, open); + LIB_FUNCTION("wuCroIGjt2g", "libScePosix", 1, "libkernel", 1, 1, posix_open); + LIB_FUNCTION("wuCroIGjt2g", "libkernel", 1, "libkernel", 1, 1, posix_open); + LIB_FUNCTION("1G3lF1Gg1k8", "libkernel", 1, "libkernel", 1, 1, sceKernelOpen); + LIB_FUNCTION("NNtFaKJbPt0", "libkernel", 1, "libkernel", 1, 1, close); + LIB_FUNCTION("bY-PO6JhzhQ", "libScePosix", 1, "libkernel", 1, 1, posix_close); + LIB_FUNCTION("bY-PO6JhzhQ", "libkernel", 1, "libkernel", 1, 1, posix_close); + LIB_FUNCTION("UK2Tl2DWUns", "libkernel", 1, "libkernel", 1, 1, sceKernelClose); + LIB_FUNCTION("FxVZqBAA7ks", "libkernel", 1, "libkernel", 1, 1, write); + LIB_FUNCTION("FN4gaPmuFV8", "libScePosix", 1, "libkernel", 1, 1, posix_write); + LIB_FUNCTION("FN4gaPmuFV8", "libkernel", 1, "libkernel", 1, 1, posix_write); + LIB_FUNCTION("4wSze92BhLI", "libkernel", 1, "libkernel", 1, 1, sceKernelWrite); + LIB_FUNCTION("+WRlkKjZvag", "libkernel", 1, "libkernel", 1, 1, readv); + LIB_FUNCTION("YSHRBRLn2pI", "libkernel", 1, "libkernel", 1, 1, writev); LIB_FUNCTION("Oy6IpwgtYOk", "libScePosix", 1, "libkernel", 1, 1, posix_lseek); + LIB_FUNCTION("Oy6IpwgtYOk", "libkernel", 1, "libkernel", 1, 1, posix_lseek); LIB_FUNCTION("oib76F-12fk", "libkernel", 1, "libkernel", 1, 1, sceKernelLseek); - LIB_FUNCTION("Cg4srZ6TKbU", "libkernel", 1, "libkernel", 1, 1, sceKernelRead); + LIB_FUNCTION("DRuBt2pvICk", "libkernel", 1, "libkernel", 1, 1, read); LIB_FUNCTION("AqBioC2vF3I", "libScePosix", 1, "libkernel", 1, 1, posix_read); - LIB_FUNCTION("1-LFLmRFxxM", "libkernel", 1, "libkernel", 1, 1, sceKernelMkdir); + LIB_FUNCTION("AqBioC2vF3I", "libkernel", 1, "libkernel", 1, 1, posix_read); + LIB_FUNCTION("Cg4srZ6TKbU", "libkernel", 1, "libkernel", 1, 1, sceKernelRead); LIB_FUNCTION("JGMio+21L4c", "libScePosix", 1, "libkernel", 1, 1, posix_mkdir); LIB_FUNCTION("JGMio+21L4c", "libkernel", 1, "libkernel", 1, 1, posix_mkdir); - LIB_FUNCTION("naInUjYt3so", "libkernel", 1, "libkernel", 1, 1, sceKernelRmdir); + LIB_FUNCTION("1-LFLmRFxxM", "libkernel", 1, "libkernel", 1, 1, sceKernelMkdir); LIB_FUNCTION("c7ZnT7V1B98", "libScePosix", 1, "libkernel", 1, 1, posix_rmdir); LIB_FUNCTION("c7ZnT7V1B98", "libkernel", 1, "libkernel", 1, 1, posix_rmdir); - LIB_FUNCTION("eV9wAD2riIA", "libkernel", 1, "libkernel", 1, 1, sceKernelStat); - LIB_FUNCTION("kBwCPsYX-m4", "libkernel", 1, "libkernel", 1, 1, sceKernelFStat); - LIB_FUNCTION("mqQMh1zPPT8", "libScePosix", 1, "libkernel", 1, 1, posix_fstat); - LIB_FUNCTION("mqQMh1zPPT8", "libkernel", 1, "libkernel", 1, 1, posix_fstat); - LIB_FUNCTION("VW3TVZiM4-E", "libkernel", 1, "libkernel", 1, 1, sceKernelFtruncate); - LIB_FUNCTION("52NcYU9+lEo", "libkernel", 1, "libkernel", 1, 1, sceKernelRename); - + LIB_FUNCTION("naInUjYt3so", "libkernel", 1, "libkernel", 1, 1, sceKernelRmdir); LIB_FUNCTION("E6ao34wPw+U", "libScePosix", 1, "libkernel", 1, 1, posix_stat); LIB_FUNCTION("E6ao34wPw+U", "libkernel", 1, "libkernel", 1, 1, posix_stat); - LIB_FUNCTION("+r3rMFwItV4", "libkernel", 1, "libkernel", 1, 1, sceKernelPread); - LIB_FUNCTION("yTj62I7kw4s", "libkernel", 1, "libkernel", 1, 1, sceKernelPreadv); + LIB_FUNCTION("eV9wAD2riIA", "libkernel", 1, "libkernel", 1, 1, sceKernelStat); LIB_FUNCTION("uWyW3v98sU4", "libkernel", 1, "libkernel", 1, 1, sceKernelCheckReachability); - LIB_FUNCTION("fTx66l5iWIA", "libkernel", 1, "libkernel", 1, 1, sceKernelFsync); - LIB_FUNCTION("juWbTNM+8hw", "libkernel", 1, "libkernel", 1, 1, posix_fsync); + LIB_FUNCTION("mqQMh1zPPT8", "libScePosix", 1, "libkernel", 1, 1, posix_fstat); + LIB_FUNCTION("mqQMh1zPPT8", "libkernel", 1, "libkernel", 1, 1, posix_fstat); + LIB_FUNCTION("kBwCPsYX-m4", "libkernel", 1, "libkernel", 1, 1, sceKernelFstat); + LIB_FUNCTION("ih4CD9-gghM", "libkernel", 1, "libkernel", 1, 1, posix_ftruncate); + LIB_FUNCTION("VW3TVZiM4-E", "libkernel", 1, "libkernel", 1, 1, sceKernelFtruncate); + LIB_FUNCTION("52NcYU9+lEo", "libkernel", 1, "libkernel", 1, 1, sceKernelRename); + LIB_FUNCTION("yTj62I7kw4s", "libkernel", 1, "libkernel", 1, 1, sceKernelPreadv); + LIB_FUNCTION("ezv-RSBNKqI", "libScePosix", 1, "libkernel", 1, 1, posix_pread); + LIB_FUNCTION("ezv-RSBNKqI", "libkernel", 1, "libkernel", 1, 1, posix_pread); + LIB_FUNCTION("+r3rMFwItV4", "libkernel", 1, "libkernel", 1, 1, sceKernelPread); LIB_FUNCTION("juWbTNM+8hw", "libScePosix", 1, "libkernel", 1, 1, posix_fsync); + LIB_FUNCTION("juWbTNM+8hw", "libkernel", 1, "libkernel", 1, 1, posix_fsync); + LIB_FUNCTION("fTx66l5iWIA", "libkernel", 1, "libkernel", 1, 1, sceKernelFsync); LIB_FUNCTION("j2AIqSqJP0w", "libkernel", 1, "libkernel", 1, 1, sceKernelGetdents); + LIB_FUNCTION("sfKygSjIbI8", "libkernel", 1, "libkernel", 1, 1, getdirentries); LIB_FUNCTION("taRWhTJFTgE", "libkernel", 1, "libkernel", 1, 1, sceKernelGetdirentries); + LIB_FUNCTION("C2kJ-byS5rM", "libkernel", 1, "libkernel", 1, 1, posix_pwrite); + LIB_FUNCTION("FCcmRZhWtOk", "libScePosix", 1, "libkernel", 1, 1, posix_pwritev); + LIB_FUNCTION("FCcmRZhWtOk", "libkernel", 1, "libkernel", 1, 1, posix_pwritev); LIB_FUNCTION("nKWi-N2HBV4", "libkernel", 1, "libkernel", 1, 1, sceKernelPwrite); + LIB_FUNCTION("mBd4AfLP+u8", "libkernel", 1, "libkernel", 1, 1, sceKernelPwritev); LIB_FUNCTION("AUXVxWeJU-A", "libkernel", 1, "libkernel", 1, 1, sceKernelUnlink); - - // openOrbis (to check if it is valid out of OpenOrbis - LIB_FUNCTION("6c3rCVE-fTU", "libkernel", 1, "libkernel", 1, 1, - posix_open); // _open should be equal to open function } } // namespace Libraries::Kernel diff --git a/src/core/libraries/kernel/file_system.h b/src/core/libraries/kernel/file_system.h index 1838df2fe..77ce3ec3d 100644 --- a/src/core/libraries/kernel/file_system.h +++ b/src/core/libraries/kernel/file_system.h @@ -65,10 +65,10 @@ constexpr int ORBIS_KERNEL_O_DSYNC = 0x1000; constexpr int ORBIS_KERNEL_O_DIRECT = 0x00010000; constexpr int ORBIS_KERNEL_O_DIRECTORY = 0x00020000; -s64 PS4_SYSV_ABI sceKernelWrite(int d, const void* buf, size_t nbytes); -s64 PS4_SYSV_ABI sceKernelRead(int d, void* buf, size_t nbytes); -s64 PS4_SYSV_ABI sceKernelPread(int d, void* buf, size_t nbytes, s64 offset); -s64 PS4_SYSV_ABI sceKernelPwrite(int d, void* buf, size_t nbytes, s64 offset); +s64 PS4_SYSV_ABI sceKernelWrite(s32 fd, const void* buf, size_t nbytes); +s64 PS4_SYSV_ABI sceKernelRead(s32 fd, void* buf, size_t nbytes); +s64 PS4_SYSV_ABI sceKernelPread(s32 fd, void* buf, size_t nbytes, s64 offset); +s64 PS4_SYSV_ABI sceKernelPwrite(s32 fd, void* buf, size_t nbytes, s64 offset); void RegisterFileSystem(Core::Loader::SymbolsResolver* sym); } // namespace Libraries::Kernel diff --git a/src/core/libraries/kernel/kernel.cpp b/src/core/libraries/kernel/kernel.cpp index 2b7735219..33602bfe8 100644 --- a/src/core/libraries/kernel/kernel.cpp +++ b/src/core/libraries/kernel/kernel.cpp @@ -12,6 +12,7 @@ #include "common/va_ctx.h" #include "core/file_sys/fs.h" #include "core/libraries/error_codes.h" +#include "core/libraries/kernel/debug.h" #include "core/libraries/kernel/equeue.h" #include "core/libraries/kernel/file_system.h" #include "core/libraries/kernel/kernel.h" @@ -85,17 +86,23 @@ int ErrnoToSceKernelError(int error) { } void SetPosixErrno(int e) { - // Some error numbers are different between supported OSes or the PS4 + // Some error numbers are different between supported OSes switch (e) { case EPERM: g_posix_errno = POSIX_EPERM; break; - case EAGAIN: - g_posix_errno = POSIX_EAGAIN; + case ENOENT: + g_posix_errno = POSIX_ENOENT; + break; + case EDEADLK: + g_posix_errno = POSIX_EDEADLK; break; case ENOMEM: g_posix_errno = POSIX_ENOMEM; break; + case EACCES: + g_posix_errno = POSIX_EACCES; + break; case EINVAL: g_posix_errno = POSIX_EINVAL; break; @@ -105,13 +112,14 @@ void SetPosixErrno(int e) { case ERANGE: g_posix_errno = POSIX_ERANGE; break; - case EDEADLK: - g_posix_errno = POSIX_EDEADLK; + case EAGAIN: + g_posix_errno = POSIX_EAGAIN; break; case ETIMEDOUT: g_posix_errno = POSIX_ETIMEDOUT; break; default: + LOG_WARNING(Kernel, "Unhandled errno {}", e); g_posix_errno = e; } } @@ -133,14 +141,6 @@ void PS4_SYSV_ABI sceLibcHeapGetTraceInfo(HeapInfoInfo* info) { info->getSegmentInfo = 0; } -s64 PS4_SYSV_ABI ps4__write(int d, const char* buf, std::size_t nbytes) { - return sceKernelWrite(d, buf, nbytes); -} - -s64 PS4_SYSV_ABI ps4__read(int d, void* buf, u64 nbytes) { - return sceKernelRead(d, buf, nbytes); -} - struct OrbisKernelUuid { u32 timeLow; u16 timeMid; @@ -220,6 +220,7 @@ void RegisterKernel(Core::Loader::SymbolsResolver* sym) { Libraries::Kernel::RegisterProcess(sym); Libraries::Kernel::RegisterException(sym); Libraries::Kernel::RegisterAio(sym); + Libraries::Kernel::RegisterDebug(sym); LIB_OBJ("f7uOxY9mM1U", "libkernel", 1, "libkernel", 1, 1, &g_stack_chk_guard); LIB_FUNCTION("PfccT7qURYE", "libkernel", 1, "libkernel", 1, 1, kernel_ioctl); @@ -229,13 +230,10 @@ void RegisterKernel(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("Xjoosiw+XPI", "libkernel", 1, "libkernel", 1, 1, sceKernelUuidCreate); LIB_FUNCTION("Ou3iL1abvng", "libkernel", 1, "libkernel", 1, 1, stack_chk_fail); LIB_FUNCTION("9BcDykPmo1I", "libkernel", 1, "libkernel", 1, 1, __Error); - LIB_FUNCTION("DRuBt2pvICk", "libkernel", 1, "libkernel", 1, 1, ps4__read); LIB_FUNCTION("k+AXqu2-eBc", "libkernel", 1, "libkernel", 1, 1, posix_getpagesize); LIB_FUNCTION("k+AXqu2-eBc", "libScePosix", 1, "libkernel", 1, 1, posix_getpagesize); LIB_FUNCTION("NWtTN10cJzE", "libSceLibcInternalExt", 1, "libSceLibcInternal", 1, 1, sceLibcHeapGetTraceInfo); - LIB_FUNCTION("FxVZqBAA7ks", "libkernel", 1, "libkernel", 1, 1, ps4__write); - LIB_FUNCTION("FN4gaPmuFV8", "libScePosix", 1, "libkernel", 1, 1, ps4__write); } } // namespace Libraries::Kernel diff --git a/src/core/libraries/kernel/kernel.h b/src/core/libraries/kernel/kernel.h index 8e7f475ad..58911727d 100644 --- a/src/core/libraries/kernel/kernel.h +++ b/src/core/libraries/kernel/kernel.h @@ -5,6 +5,7 @@ #include #include +#include "common/string_literal.h" #include "common/types.h" #include "core/libraries/kernel/orbis_error.h" @@ -18,15 +19,6 @@ void ErrSceToPosix(int result); int ErrnoToSceKernelError(int e); void SetPosixErrno(int e); -template -struct StringLiteral { - constexpr StringLiteral(const char (&str)[N]) { - std::copy_n(str, N, value); - } - - char value[N]; -}; - template struct WrapperImpl; diff --git a/src/core/libraries/kernel/memory.cpp b/src/core/libraries/kernel/memory.cpp index 82c5115f1..8a0c91479 100644 --- a/src/core/libraries/kernel/memory.cpp +++ b/src/core/libraries/kernel/memory.cpp @@ -19,7 +19,7 @@ namespace Libraries::Kernel { u64 PS4_SYSV_ABI sceKernelGetDirectMemorySize() { - LOG_WARNING(Kernel_Vmm, "called"); + LOG_TRACE(Kernel_Vmm, "called"); const auto* memory = Core::Memory::Instance(); return memory->GetTotalDirectSize(); } @@ -79,6 +79,9 @@ s32 PS4_SYSV_ABI sceKernelAllocateMainDirectMemory(size_t len, size_t alignment, } s32 PS4_SYSV_ABI sceKernelCheckedReleaseDirectMemory(u64 start, size_t len) { + if (len == 0) { + return ORBIS_OK; + } LOG_INFO(Kernel_Vmm, "called start = {:#x}, len = {:#x}", start, len); auto* memory = Core::Memory::Instance(); memory->Free(start, len); @@ -86,6 +89,9 @@ s32 PS4_SYSV_ABI sceKernelCheckedReleaseDirectMemory(u64 start, size_t len) { } s32 PS4_SYSV_ABI sceKernelReleaseDirectMemory(u64 start, size_t len) { + if (len == 0) { + return ORBIS_OK; + } auto* memory = Core::Memory::Instance(); memory->Free(start, len); return ORBIS_OK; @@ -100,12 +106,6 @@ s32 PS4_SYSV_ABI sceKernelAvailableDirectMemorySize(u64 searchStart, u64 searchE if (physAddrOut == nullptr || sizeOut == nullptr) { return ORBIS_KERNEL_ERROR_EINVAL; } - if (searchEnd > sceKernelGetDirectMemorySize()) { - return ORBIS_KERNEL_ERROR_EINVAL; - } - if (searchEnd <= searchStart) { - return ORBIS_KERNEL_ERROR_ENOMEM; - } auto* memory = Core::Memory::Instance(); @@ -507,7 +507,7 @@ s32 PS4_SYSV_ABI sceKernelConfiguredFlexibleMemorySize(u64* sizeOut) { int PS4_SYSV_ABI sceKernelMunmap(void* addr, size_t len) { LOG_INFO(Kernel_Vmm, "addr = {}, len = {:#x}", fmt::ptr(addr), len); if (len == 0) { - return ORBIS_OK; + return ORBIS_KERNEL_ERROR_EINVAL; } auto* memory = Core::Memory::Instance(); return memory->UnmapMemory(std::bit_cast(addr), len); diff --git a/src/core/libraries/kernel/process.cpp b/src/core/libraries/kernel/process.cpp index 58628867a..8a37e78d5 100644 --- a/src/core/libraries/kernel/process.cpp +++ b/src/core/libraries/kernel/process.cpp @@ -32,44 +32,44 @@ void* PS4_SYSV_ABI sceKernelGetProcParam() { return linker->GetProcParam(); } -s32 PS4_SYSV_ABI sceKernelLoadStartModule(const char* moduleFileName, size_t args, const void* argp, +s32 PS4_SYSV_ABI sceKernelLoadStartModule(const char* moduleFileName, u64 args, const void* argp, u32 flags, const void* pOpt, int* pRes) { LOG_INFO(Lib_Kernel, "called filename = {}, args = {}", moduleFileName, args); - - if (flags != 0) { - return ORBIS_KERNEL_ERROR_EINVAL; - } + ASSERT(flags == 0); auto* mnt = Common::Singleton::Instance(); - const auto path = mnt->GetHostPath(moduleFileName); - - // Load PRX module and relocate any modules that import it. auto* linker = Common::Singleton::Instance(); - u32 handle = linker->FindByName(path); - if (handle != -1) { - return handle; - } - handle = linker->LoadModule(path, true); - if (handle == -1) { - return ORBIS_KERNEL_ERROR_ESRCH; - } - auto* module = linker->GetModule(handle); - linker->RelocateAnyImports(module); - // If the new module has a TLS image, trigger its load when TlsGetAddr is called. - if (module->tls.image_size != 0) { - linker->AdvanceGenerationCounter(); + std::filesystem::path path; + std::string guest_path(moduleFileName); + + s32 handle = -1; + + if (guest_path[0] == '/') { + // try load /system/common/lib/ +path + // try load /system/priv/lib/ +path + path = mnt->GetHostPath(guest_path); + handle = linker->LoadAndStartModule(path, args, argp, pRes); + if (handle != -1) + return handle; + } else { + if (!guest_path.contains('/')) { + path = mnt->GetHostPath("/app0/" + guest_path); + handle = linker->LoadAndStartModule(path, args, argp, pRes); + if (handle != -1) + return handle; + // if ((flags & 0x10000) != 0) + // try load /system/priv/lib/ +basename + // try load /system/common/lib/ +basename + } else { + path = mnt->GetHostPath(guest_path); + handle = linker->LoadAndStartModule(path, args, argp, pRes); + if (handle != -1) + return handle; + } } - // Retrieve and verify proc param according to libkernel. - u64* param = module->GetProcParam(); - ASSERT_MSG(!param || param[0] >= 0x18, "Invalid module param size: {}", param[0]); - s32 ret = module->Start(args, argp, param); - if (pRes) { - *pRes = ret; - } - - return handle; + return ORBIS_KERNEL_ERROR_ENOENT; } s32 PS4_SYSV_ABI sceKernelDlsym(s32 handle, const char* symbol, void** addrp) { @@ -85,19 +85,7 @@ s32 PS4_SYSV_ABI sceKernelDlsym(s32 handle, const char* symbol, void** addrp) { return ORBIS_OK; } -static constexpr size_t ORBIS_DBG_MAX_NAME_LENGTH = 256; - -struct OrbisModuleInfoForUnwind { - u64 st_size; - std::array name; - VAddr eh_frame_hdr_addr; - VAddr eh_frame_addr; - u64 eh_frame_size; - VAddr seg0_addr; - u64 seg0_size; -}; - -s32 PS4_SYSV_ABI sceKernelGetModuleInfoForUnwind(VAddr addr, int flags, +s32 PS4_SYSV_ABI sceKernelGetModuleInfoForUnwind(VAddr addr, s32 flags, OrbisModuleInfoForUnwind* info) { if (flags >= 3) { std::memset(info, 0, sizeof(OrbisModuleInfoForUnwind)); @@ -139,6 +127,67 @@ int PS4_SYSV_ABI sceKernelGetModuleInfoFromAddr(VAddr addr, int flags, return ORBIS_OK; } +s32 PS4_SYSV_ABI sceKernelGetModuleInfo(s32 handle, Core::OrbisKernelModuleInfo* info) { + if (info == nullptr) { + return ORBIS_KERNEL_ERROR_EFAULT; + } + if (info->st_size != sizeof(Core::OrbisKernelModuleInfo)) { + return ORBIS_KERNEL_ERROR_EINVAL; + } + + auto* linker = Common::Singleton::Instance(); + auto* module = linker->GetModule(handle); + if (module == nullptr) { + return ORBIS_KERNEL_ERROR_ESRCH; + } + *info = module->GetModuleInfo(); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceKernelGetModuleInfoInternal(s32 handle, Core::OrbisKernelModuleInfoEx* info) { + if (info == nullptr) { + return ORBIS_KERNEL_ERROR_EFAULT; + } + if (info->st_size != sizeof(Core::OrbisKernelModuleInfoEx)) { + return ORBIS_KERNEL_ERROR_EINVAL; + } + + auto* linker = Common::Singleton::Instance(); + auto* module = linker->GetModule(handle); + if (module == nullptr) { + return ORBIS_KERNEL_ERROR_ESRCH; + } + *info = module->GetModuleInfoEx(); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceKernelGetModuleList(s32* handles, u64 num_array, u64* out_count) { + if (handles == nullptr || out_count == nullptr) { + return ORBIS_KERNEL_ERROR_EFAULT; + } + + auto* linker = Common::Singleton::Instance(); + u64 count = 0; + auto* module = linker->GetModule(count); + while (module != nullptr && count < num_array) { + handles[count] = count; + count++; + module = linker->GetModule(count); + } + + if (count == num_array && module != nullptr) { + return ORBIS_KERNEL_ERROR_ENOMEM; + } + + *out_count = count; + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI exit(s32 status) { + UNREACHABLE_MSG("Exiting with status code {}", status); + return 0; +} + void RegisterProcess(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("WB66evu8bsU", "libkernel", 1, "libkernel", 1, 1, sceKernelGetCompiledSdkVersion); LIB_FUNCTION("WslcK1FQcGI", "libkernel", 1, "libkernel", 1, 1, sceKernelIsNeoMode); @@ -148,6 +197,10 @@ void RegisterProcess(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("LwG8g3niqwA", "libkernel", 1, "libkernel", 1, 1, sceKernelDlsym); LIB_FUNCTION("RpQJJVKTiFM", "libkernel", 1, "libkernel", 1, 1, sceKernelGetModuleInfoForUnwind); LIB_FUNCTION("f7KBOafysXo", "libkernel", 1, "libkernel", 1, 1, sceKernelGetModuleInfoFromAddr); + LIB_FUNCTION("kUpgrXIrz7Q", "libkernel", 1, "libkernel", 1, 1, sceKernelGetModuleInfo); + LIB_FUNCTION("HZO7xOos4xc", "libkernel", 1, "libkernel", 1, 1, sceKernelGetModuleInfoInternal); + LIB_FUNCTION("IuxnUuXk6Bg", "libkernel", 1, "libkernel", 1, 1, sceKernelGetModuleList); + LIB_FUNCTION("6Z83sYWFlA8", "libkernel", 1, "libkernel", 1, 1, exit); } } // namespace Libraries::Kernel diff --git a/src/core/libraries/kernel/process.h b/src/core/libraries/kernel/process.h index 0340a9793..09e4276fb 100644 --- a/src/core/libraries/kernel/process.h +++ b/src/core/libraries/kernel/process.h @@ -11,10 +11,25 @@ class SymbolsResolver; namespace Libraries::Kernel { +static constexpr size_t ORBIS_DBG_MAX_NAME_LENGTH = 256; + +struct OrbisModuleInfoForUnwind { + u64 st_size; + std::array name; + VAddr eh_frame_hdr_addr; + VAddr eh_frame_addr; + u64 eh_frame_size; + VAddr seg0_addr; + u64 seg0_size; +}; + int PS4_SYSV_ABI sceKernelIsNeoMode(); int PS4_SYSV_ABI sceKernelGetCompiledSdkVersion(int* ver); +s32 PS4_SYSV_ABI sceKernelGetModuleInfoForUnwind(VAddr addr, s32 flags, + OrbisModuleInfoForUnwind* info); + void RegisterProcess(Core::Loader::SymbolsResolver* sym); } // namespace Libraries::Kernel diff --git a/src/core/libraries/kernel/threads/exception.cpp b/src/core/libraries/kernel/threads/exception.cpp index 5e2f35d69..e257cbea0 100644 --- a/src/core/libraries/kernel/threads/exception.cpp +++ b/src/core/libraries/kernel/threads/exception.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "common/assert.h" +#include "core/libraries/kernel/orbis_error.h" #include "core/libraries/kernel/threads/exception.h" #include "core/libraries/kernel/threads/pthread.h" #include "core/libraries/libs.h" @@ -148,13 +149,19 @@ int PS4_SYSV_ABI sceKernelRaiseException(PthreadT thread, int signum) { return 0; } -int PS4_SYSV_ABI sceKernelDebugRaiseException() { - UNREACHABLE(); +s32 PS4_SYSV_ABI sceKernelDebugRaiseException(s32 error, s64 unk) { + if (unk != 0) { + return ORBIS_KERNEL_ERROR_EINVAL; + } + UNREACHABLE_MSG("error {:#x}", error); return 0; } -int PS4_SYSV_ABI sceKernelDebugRaiseExceptionOnReleaseMode() { - UNREACHABLE(); +s32 PS4_SYSV_ABI sceKernelDebugRaiseExceptionOnReleaseMode(s32 error, s64 unk) { + if (unk != 0) { + return ORBIS_KERNEL_ERROR_EINVAL; + } + UNREACHABLE_MSG("error {:#x}", error); return 0; } @@ -163,7 +170,7 @@ void RegisterException(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("WkwEd3N7w0Y", "libkernel_unity", 1, "libkernel", 1, 1, sceKernelInstallExceptionHandler); LIB_FUNCTION("Qhv5ARAoOEc", "libkernel_unity", 1, "libkernel", 1, 1, - sceKernelRemoveExceptionHandler) + sceKernelRemoveExceptionHandler); LIB_FUNCTION("OMDRKKAZ8I4", "libkernel", 1, "libkernel", 1, 1, sceKernelDebugRaiseException); LIB_FUNCTION("zE-wXIZjLoM", "libkernel", 1, "libkernel", 1, 1, sceKernelDebugRaiseExceptionOnReleaseMode); diff --git a/src/core/libraries/kernel/threads/pthread_spec.cpp b/src/core/libraries/kernel/threads/pthread_spec.cpp index 9e625da32..b36e302d4 100644 --- a/src/core/libraries/kernel/threads/pthread_spec.cpp +++ b/src/core/libraries/kernel/threads/pthread_spec.cpp @@ -147,6 +147,11 @@ void RegisterSpec(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("0-KXaS70xy4", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_getspecific); LIB_FUNCTION("WrOLvHU0yQM", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_setspecific); + // Posix-Kernel + LIB_FUNCTION("mqULNdimTn0", "libkernel", 1, "libkernel", 1, 1, posix_pthread_key_create); + LIB_FUNCTION("0-KXaS70xy4", "libkernel", 1, "libkernel", 1, 1, posix_pthread_getspecific); + LIB_FUNCTION("WrOLvHU0yQM", "libkernel", 1, "libkernel", 1, 1, posix_pthread_setspecific); + // Orbis LIB_FUNCTION("geDaqgH9lTg", "libkernel", 1, "libkernel", 1, 1, ORBIS(posix_pthread_key_create)); LIB_FUNCTION("PrdHuuDekhY", "libkernel", 1, "libkernel", 1, 1, ORBIS(posix_pthread_key_delete)); diff --git a/src/core/libraries/kernel/time.cpp b/src/core/libraries/kernel/time.cpp index 2565b8078..b7e4c1756 100644 --- a/src/core/libraries/kernel/time.cpp +++ b/src/core/libraries/kernel/time.cpp @@ -5,6 +5,7 @@ #include "common/assert.h" #include "common/native_clock.h" +#include "core/libraries/kernel/kernel.h" #include "core/libraries/kernel/orbis_error.h" #include "core/libraries/kernel/time.h" #include "core/libraries/libs.h" @@ -19,6 +20,7 @@ #if __APPLE__ #include #endif +#include #include #include #include @@ -93,44 +95,189 @@ u32 PS4_SYSV_ABI sceKernelSleep(u32 seconds) { return 0; } -int PS4_SYSV_ABI sceKernelClockGettime(s32 clock_id, OrbisKernelTimespec* tp) { - if (tp == nullptr) { +#ifdef _WIN64 +#ifndef CLOCK_REALTIME +#define CLOCK_REALTIME 0 +#endif +#ifndef CLOCK_MONOTONIC +#define CLOCK_MONOTONIC 1 +#endif +#ifndef CLOCK_PROCESS_CPUTIME_ID +#define CLOCK_PROCESS_CPUTIME_ID 2 +#endif +#ifndef CLOCK_THREAD_CPUTIME_ID +#define CLOCK_THREAD_CPUTIME_ID 3 +#endif +#ifndef CLOCK_REALTIME_COARSE +#define CLOCK_REALTIME_COARSE 5 +#endif +#ifndef CLOCK_MONOTONIC_COARSE +#define CLOCK_MONOTONIC_COARSE 6 +#endif + +#define DELTA_EPOCH_IN_100NS 116444736000000000ULL + +static u64 FileTimeTo100Ns(FILETIME& ft) { + return *reinterpret_cast(&ft); +} + +static s32 clock_gettime(u32 clock_id, struct timespec* ts) { + switch (clock_id) { + case CLOCK_REALTIME: + case CLOCK_REALTIME_COARSE: { + FILETIME ft; + GetSystemTimeAsFileTime(&ft); + const u64 ns = FileTimeTo100Ns(ft) - DELTA_EPOCH_IN_100NS; + ts->tv_sec = ns / 10'000'000; + ts->tv_nsec = (ns % 10'000'000) * 100; + return 0; + } + case CLOCK_MONOTONIC: + case CLOCK_MONOTONIC_COARSE: { + static LARGE_INTEGER pf = [] { + LARGE_INTEGER res{}; + QueryPerformanceFrequency(&pf); + return res; + }(); + + LARGE_INTEGER pc{}; + QueryPerformanceCounter(&pc); + ts->tv_sec = pc.QuadPart / pf.QuadPart; + ts->tv_nsec = ((pc.QuadPart % pf.QuadPart) * 1000'000'000) / pf.QuadPart; + return 0; + } + case CLOCK_PROCESS_CPUTIME_ID: { + FILETIME ct, et, kt, ut; + if (!GetProcessTimes(GetCurrentProcess(), &ct, &et, &kt, &ut)) { + return EFAULT; + } + const u64 ns = FileTimeTo100Ns(ut) + FileTimeTo100Ns(kt); + ts->tv_sec = ns / 10'000'000; + ts->tv_nsec = (ns % 10'000'000) * 100; + return 0; + } + case CLOCK_THREAD_CPUTIME_ID: { + FILETIME ct, et, kt, ut; + if (!GetThreadTimes(GetCurrentThread(), &ct, &et, &kt, &ut)) { + return EFAULT; + } + const u64 ns = FileTimeTo100Ns(ut) + FileTimeTo100Ns(kt); + ts->tv_sec = ns / 10'000'000; + ts->tv_nsec = (ns % 10'000'000) * 100; + return 0; + } + default: + return EINVAL; + } +} +#endif + +int PS4_SYSV_ABI orbis_clock_gettime(s32 clock_id, struct OrbisKernelTimespec* ts) { + if (ts == nullptr) { return ORBIS_KERNEL_ERROR_EFAULT; } - clockid_t pclock_id = CLOCK_REALTIME; + + clockid_t pclock_id = CLOCK_MONOTONIC; switch (clock_id) { case ORBIS_CLOCK_REALTIME: case ORBIS_CLOCK_REALTIME_PRECISE: - case ORBIS_CLOCK_REALTIME_FAST: pclock_id = CLOCK_REALTIME; break; case ORBIS_CLOCK_SECOND: + case ORBIS_CLOCK_REALTIME_FAST: +#ifndef __APPLE__ + pclock_id = CLOCK_REALTIME_COARSE; +#else + pclock_id = CLOCK_REALTIME; +#endif + break; + case ORBIS_CLOCK_UPTIME: + case ORBIS_CLOCK_UPTIME_PRECISE: case ORBIS_CLOCK_MONOTONIC: case ORBIS_CLOCK_MONOTONIC_PRECISE: - case ORBIS_CLOCK_MONOTONIC_FAST: pclock_id = CLOCK_MONOTONIC; break; - default: - LOG_ERROR(Lib_Kernel, "unsupported = {} using CLOCK_REALTIME", clock_id); + case ORBIS_CLOCK_UPTIME_FAST: + case ORBIS_CLOCK_MONOTONIC_FAST: +#ifndef __APPLE__ + pclock_id = CLOCK_MONOTONIC_COARSE; +#else + pclock_id = CLOCK_MONOTONIC; +#endif break; + case ORBIS_CLOCK_THREAD_CPUTIME_ID: + pclock_id = CLOCK_THREAD_CPUTIME_ID; + break; + case ORBIS_CLOCK_PROCTIME: { + const auto us = sceKernelGetProcessTime(); + ts->tv_sec = us / 1'000'000; + ts->tv_nsec = (us % 1'000'000) * 1000; + return 0; + } + case ORBIS_CLOCK_VIRTUAL: { +#ifdef _WIN64 + FILETIME ct, et, kt, ut; + if (!GetProcessTimes(GetCurrentProcess(), &ct, &et, &kt, &ut)) { + return EFAULT; + } + const u64 ns = FileTimeTo100Ns(ut); + ts->tv_sec = ns / 10'000'000; + ts->tv_nsec = (ns % 10'000'000) * 100; +#else + struct rusage ru; + const auto res = getrusage(RUSAGE_SELF, &ru); + if (res < 0) { + return res; + } + ts->tv_sec = ru.ru_utime.tv_sec; + ts->tv_nsec = ru.ru_utime.tv_usec * 1000; +#endif + return 0; + } + case ORBIS_CLOCK_PROF: { +#ifdef _WIN64 + FILETIME ct, et, kt, ut; + if (!GetProcessTimes(GetCurrentProcess(), &ct, &et, &kt, &ut)) { + return EFAULT; + } + const u64 ns = FileTimeTo100Ns(kt); + ts->tv_sec = ns / 10'000'000; + ts->tv_nsec = (ns % 10'000'000) * 100; +#else + struct rusage ru; + const auto res = getrusage(RUSAGE_SELF, &ru); + if (res < 0) { + return res; + } + ts->tv_sec = ru.ru_stime.tv_sec; + ts->tv_nsec = ru.ru_stime.tv_usec * 1000; +#endif + return 0; + } + case ORBIS_CLOCK_EXT_NETWORK: + case ORBIS_CLOCK_EXT_DEBUG_NETWORK: + case ORBIS_CLOCK_EXT_AD_NETWORK: + case ORBIS_CLOCK_EXT_RAW_NETWORK: + pclock_id = CLOCK_MONOTONIC; + LOG_ERROR(Lib_Kernel, "unsupported = {} using CLOCK_MONOTONIC", clock_id); + break; + default: + return EINVAL; } timespec t{}; int result = clock_gettime(pclock_id, &t); - tp->tv_sec = t.tv_sec; - tp->tv_nsec = t.tv_nsec; - if (result == 0) { - return ORBIS_OK; - } - return ORBIS_KERNEL_ERROR_EINVAL; + ts->tv_sec = t.tv_sec; + ts->tv_nsec = t.tv_nsec; + return result; } -int PS4_SYSV_ABI posix_clock_gettime(s32 clock_id, OrbisKernelTimespec* time) { - int result = sceKernelClockGettime(clock_id, time); - if (result < 0) { - UNREACHABLE(); // TODO return posix error code +int PS4_SYSV_ABI sceKernelClockGettime(s32 clock_id, OrbisKernelTimespec* tp) { + const auto res = orbis_clock_gettime(clock_id, tp); + if (res < 0) { + return ErrnoToSceKernelError(res); } - return result; + return ORBIS_OK; } int PS4_SYSV_ABI posix_nanosleep(const OrbisKernelTimespec* rqtp, OrbisKernelTimespec* rmtp) { @@ -316,11 +463,11 @@ void RegisterTime(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("yS8U2TGCe1A", "libScePosix", 1, "libkernel", 1, 1, posix_nanosleep); LIB_FUNCTION("QBi7HCK03hw", "libkernel", 1, "libkernel", 1, 1, sceKernelClockGettime); LIB_FUNCTION("kOcnerypnQA", "libkernel", 1, "libkernel", 1, 1, sceKernelGettimezone); - LIB_FUNCTION("lLMT9vJAck0", "libkernel", 1, "libkernel", 1, 1, posix_clock_gettime); - LIB_FUNCTION("lLMT9vJAck0", "libScePosix", 1, "libkernel", 1, 1, posix_clock_gettime); + LIB_FUNCTION("lLMT9vJAck0", "libkernel", 1, "libkernel", 1, 1, orbis_clock_gettime); + LIB_FUNCTION("lLMT9vJAck0", "libScePosix", 1, "libkernel", 1, 1, orbis_clock_gettime); LIB_FUNCTION("smIj7eqzZE8", "libScePosix", 1, "libkernel", 1, 1, posix_clock_getres); LIB_FUNCTION("0NTHN1NKONI", "libkernel", 1, "libkernel", 1, 1, sceKernelConvertLocaltimeToUtc); LIB_FUNCTION("-o5uEDpN+oY", "libkernel", 1, "libkernel", 1, 1, sceKernelConvertUtcToLocaltime); } -} // namespace Libraries::Kernel +} // namespace Libraries::Kernel \ No newline at end of file diff --git a/src/core/libraries/libs.cpp b/src/core/libraries/libs.cpp index 074cf524e..3f5baf640 100644 --- a/src/core/libraries/libs.cpp +++ b/src/core/libraries/libs.cpp @@ -27,6 +27,7 @@ #include "core/libraries/network/netctl.h" #include "core/libraries/network/ssl.h" #include "core/libraries/network/ssl2.h" +#include "core/libraries/np_auth/np_auth.h" #include "core/libraries/np_common/np_common.h" #include "core/libraries/np_manager/np_manager.h" #include "core/libraries/np_party/np_party.h" @@ -50,6 +51,7 @@ #include "core/libraries/system/sysmodule.h" #include "core/libraries/system/systemservice.h" #include "core/libraries/system/userservice.h" +#include "core/libraries/ulobjmgr/ulobjmgr.h" #include "core/libraries/usbd/usbd.h" #include "core/libraries/videodec/videodec.h" #include "core/libraries/videodec/videodec2.h" @@ -87,6 +89,7 @@ void InitHLELibs(Core::Loader::SymbolsResolver* sym) { Libraries::NpScore::RegisterlibSceNpScore(sym); Libraries::NpTrophy::RegisterlibSceNpTrophy(sym); Libraries::NpWebApi::RegisterlibSceNpWebApi(sym); + Libraries::NpAuth::RegisterlibSceNpAuth(sym); Libraries::ScreenShot::RegisterlibSceScreenShot(sym); Libraries::AppContent::RegisterlibSceAppContent(sym); Libraries::PngDec::RegisterlibScePngDec(sym); @@ -115,6 +118,8 @@ void InitHLELibs(Core::Loader::SymbolsResolver* sym) { Libraries::NpParty::RegisterlibSceNpParty(sym); Libraries::Zlib::RegisterlibSceZlib(sym); Libraries::Hmd::RegisterlibSceHmd(sym); + Libraries::DiscMap::RegisterlibSceDiscMap(sym); + Libraries::Ulobjmgr::RegisterlibSceUlobjmgr(sym); } } // namespace Libraries diff --git a/src/core/libraries/move/move.cpp b/src/core/libraries/move/move.cpp index 626fed9b4..500d89586 100644 --- a/src/core/libraries/move/move.cpp +++ b/src/core/libraries/move/move.cpp @@ -9,7 +9,7 @@ namespace Libraries::Move { int PS4_SYSV_ABI sceMoveOpen() { - LOG_ERROR(Lib_Move, "(STUBBED) called"); + LOG_TRACE(Lib_Move, "(STUBBED) called"); return ORBIS_FAIL; } @@ -18,6 +18,11 @@ int PS4_SYSV_ABI sceMoveGetDeviceInfo() { return ORBIS_OK; } +int PS4_SYSV_ABI sceMoveReadStateLatest() { + LOG_TRACE(Lib_Move, "(STUBBED) called"); + return ORBIS_OK; +} + int PS4_SYSV_ABI sceMoveReadStateRecent() { LOG_TRACE(Lib_Move, "(STUBBED) called"); return ORBIS_OK; @@ -36,6 +41,7 @@ int PS4_SYSV_ABI sceMoveInit() { void RegisterlibSceMove(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("HzC60MfjJxU", "libSceMove", 1, "libSceMove", 1, 1, sceMoveOpen); LIB_FUNCTION("GWXTyxs4QbE", "libSceMove", 1, "libSceMove", 1, 1, sceMoveGetDeviceInfo); + LIB_FUNCTION("ttU+JOhShl4", "libSceMove", 1, "libSceMove", 1, 1, sceMoveReadStateLatest); LIB_FUNCTION("f2bcpK6kJfg", "libSceMove", 1, "libSceMove", 1, 1, sceMoveReadStateRecent); LIB_FUNCTION("tsZi60H4ypY", "libSceMove", 1, "libSceMove", 1, 1, sceMoveTerm); LIB_FUNCTION("j1ITE-EoJmE", "libSceMove", 1, "libSceMove", 1, 1, sceMoveInit); diff --git a/src/core/libraries/network/http.cpp b/src/core/libraries/network/http.cpp index 8e06c76fa..dbb5b096a 100644 --- a/src/core/libraries/network/http.cpp +++ b/src/core/libraries/network/http.cpp @@ -5,6 +5,7 @@ #include "core/libraries/error_codes.h" #include "core/libraries/libs.h" #include "core/libraries/network/http.h" +#include "http_error.h" namespace Libraries::Http { @@ -566,17 +567,277 @@ int PS4_SYSV_ABI sceHttpUriMerge() { return ORBIS_OK; } -int PS4_SYSV_ABI sceHttpUriParse() { +int PS4_SYSV_ABI sceHttpUriParse(OrbisHttpUriElement* out, const char* srcUri, void* pool, + size_t* require, size_t prepare) { + LOG_INFO(Lib_Http, "srcUri = {}", std::string(srcUri)); + if (!srcUri) { + LOG_ERROR(Lib_Http, "invalid url"); + return ORBIS_HTTP_ERROR_INVALID_URL; + } + if (!out && !pool && !require) { + LOG_ERROR(Lib_Http, "invalid values"); + return ORBIS_HTTP_ERROR_INVALID_VALUE; + } + + if (out && pool) { + memset(out, 0, sizeof(OrbisHttpUriElement)); + out->scheme = (char*)pool; + } + + // Track the total required buffer size + size_t requiredSize = 0; + + // Parse the scheme (e.g., "http:", "https:", "file:") + size_t schemeLength = 0; + while (srcUri[schemeLength] && srcUri[schemeLength] != ':') { + if (!isalnum(srcUri[schemeLength])) { + LOG_ERROR(Lib_Http, "invalid url"); + return ORBIS_HTTP_ERROR_INVALID_URL; + } + schemeLength++; + } + + if (pool && prepare < schemeLength + 1) { + LOG_ERROR(Lib_Http, "out of memory"); + return ORBIS_HTTP_ERROR_OUT_OF_MEMORY; + } + + if (out && pool) { + memcpy(out->scheme, srcUri, schemeLength); + out->scheme[schemeLength] = '\0'; + } + + requiredSize += schemeLength + 1; + + // Move past the scheme and ':' character + size_t offset = schemeLength + 1; + + // Check if "//" appears after the scheme + if (strncmp(srcUri + offset, "//", 2) == 0) { + // "//" is present + if (out) { + out->opaque = false; + } + offset += 2; // Move past "//" + } else { + // "//" is not present + if (out) { + out->opaque = true; + } + } + + // Handle "file" scheme + if (strncmp(srcUri, "file", 4) == 0) { + // File URIs typically start with "file://" + if (out && !out->opaque) { + // Skip additional slashes (e.g., "////") + while (srcUri[offset] == '/') { + offset++; + } + + // Parse the path (everything after the slashes) + char* pathStart = (char*)srcUri + offset; + size_t pathLength = 0; + while (pathStart[pathLength] && pathStart[pathLength] != '?' && + pathStart[pathLength] != '#') { + pathLength++; + } + + // Ensure the path starts with '/' + if (pathLength > 0 && pathStart[0] != '/') { + // Prepend '/' to the path + requiredSize += pathLength + 2; // Include '/' and null terminator + + if (pool && prepare < requiredSize) { + LOG_ERROR(Lib_Http, "out of memory"); + return ORBIS_HTTP_ERROR_OUT_OF_MEMORY; + } + + if (out && pool) { + out->path = (char*)pool + (requiredSize - pathLength - 2); + out->path[0] = '/'; // Add leading '/' + memcpy(out->path + 1, pathStart, pathLength); + out->path[pathLength + 1] = '\0'; + } + } else { + // Path already starts with '/' + requiredSize += pathLength + 1; + + if (pool && prepare < requiredSize) { + LOG_ERROR(Lib_Http, "out of memory"); + return ORBIS_HTTP_ERROR_OUT_OF_MEMORY; + } + + if (out && pool) { + memcpy((char*)pool + (requiredSize - pathLength - 1), pathStart, pathLength); + out->path = (char*)pool + (requiredSize - pathLength - 1); + out->path[pathLength] = '\0'; + } + } + + // Move past the path + offset += pathLength; + } + } + + // Handle non-file schemes (e.g., "http", "https") + else { + // Parse the host and port + char* hostStart = (char*)srcUri + offset; + while (*hostStart == '/') { + hostStart++; + } + + size_t hostLength = 0; + while (hostStart[hostLength] && hostStart[hostLength] != '/' && + hostStart[hostLength] != '?' && hostStart[hostLength] != ':') { + hostLength++; + } + + requiredSize += hostLength + 1; + + if (pool && prepare < requiredSize) { + LOG_ERROR(Lib_Http, "out of memory"); + return ORBIS_HTTP_ERROR_OUT_OF_MEMORY; + } + + if (out && pool) { + memcpy((char*)pool + (requiredSize - hostLength - 1), hostStart, hostLength); + out->hostname = (char*)pool + (requiredSize - hostLength - 1); + out->hostname[hostLength] = '\0'; + } + + // Move past the host + offset += hostLength; + + // Parse the port (if present) + if (hostStart[hostLength] == ':') { + char* portStart = hostStart + hostLength + 1; + size_t portLength = 0; + while (portStart[portLength] && isdigit(portStart[portLength])) { + portLength++; + } + + requiredSize += portLength + 1; + + if (pool && prepare < requiredSize) { + LOG_ERROR(Lib_Http, "out of memory"); + return ORBIS_HTTP_ERROR_OUT_OF_MEMORY; + } + + // Convert the port string to a uint16_t + char portStr[6]; // Max length for a port number (65535) + if (portLength > 5) { + LOG_ERROR(Lib_Http, "invalid url"); + return ORBIS_HTTP_ERROR_INVALID_URL; + } + memcpy(portStr, portStart, portLength); + portStr[portLength] = '\0'; + + uint16_t port = (uint16_t)atoi(portStr); + if (port == 0 && portStr[0] != '0') { + LOG_ERROR(Lib_Http, "invalid url"); + return ORBIS_HTTP_ERROR_INVALID_URL; + } + + // Set the port in the output structure + if (out) { + out->port = port; + } + + // Move past the port + offset += portLength + 1; + } + } + + // Parse the path (if present) + if (srcUri[offset] == '/') { + char* pathStart = (char*)srcUri + offset; + size_t pathLength = 0; + while (pathStart[pathLength] && pathStart[pathLength] != '?' && + pathStart[pathLength] != '#') { + pathLength++; + } + + requiredSize += pathLength + 1; + + if (pool && prepare < requiredSize) { + LOG_ERROR(Lib_Http, "out of memory"); + return ORBIS_HTTP_ERROR_OUT_OF_MEMORY; + } + + if (out && pool) { + memcpy((char*)pool + (requiredSize - pathLength - 1), pathStart, pathLength); + out->path = (char*)pool + (requiredSize - pathLength - 1); + out->path[pathLength] = '\0'; + } + + // Move past the path + offset += pathLength; + } + + // Parse the query (if present) + if (srcUri[offset] == '?') { + char* queryStart = (char*)srcUri + offset + 1; + size_t queryLength = 0; + while (queryStart[queryLength] && queryStart[queryLength] != '#') { + queryLength++; + } + + requiredSize += queryLength + 1; + + if (pool && prepare < requiredSize) { + LOG_ERROR(Lib_Http, "out of memory"); + return ORBIS_HTTP_ERROR_OUT_OF_MEMORY; + } + + if (out && pool) { + memcpy((char*)pool + (requiredSize - queryLength - 1), queryStart, queryLength); + out->query = (char*)pool + (requiredSize - queryLength - 1); + out->query[queryLength] = '\0'; + } + + // Move past the query + offset += queryLength + 1; + } + + // Parse the fragment (if present) + if (srcUri[offset] == '#') { + char* fragmentStart = (char*)srcUri + offset + 1; + size_t fragmentLength = 0; + while (fragmentStart[fragmentLength]) { + fragmentLength++; + } + + requiredSize += fragmentLength + 1; + + if (pool && prepare < requiredSize) { + LOG_ERROR(Lib_Http, "out of memory"); + return ORBIS_HTTP_ERROR_OUT_OF_MEMORY; + } + + if (out && pool) { + memcpy((char*)pool + (requiredSize - fragmentLength - 1), fragmentStart, + fragmentLength); + out->fragment = (char*)pool + (requiredSize - fragmentLength - 1); + out->fragment[fragmentLength] = '\0'; + } + } + + // Calculate the total required buffer size + if (require) { + *require = requiredSize; // Update with actual required size + } + + return ORBIS_OK; +} + +int PS4_SYSV_ABI sceHttpUriSweepPath(char* dst, const char* src, size_t srcSize) { LOG_ERROR(Lib_Http, "(STUBBED) called"); return ORBIS_OK; } -int PS4_SYSV_ABI sceHttpUriSweepPath() { - LOG_ERROR(Lib_Http, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceHttpUriUnescape() { +int PS4_SYSV_ABI sceHttpUriUnescape(char* out, size_t* require, size_t prepare, const char* in) { LOG_ERROR(Lib_Http, "(STUBBED) called"); return ORBIS_OK; } diff --git a/src/core/libraries/network/http.h b/src/core/libraries/network/http.h index 24bc83020..c687c60c4 100644 --- a/src/core/libraries/network/http.h +++ b/src/core/libraries/network/http.h @@ -11,6 +11,19 @@ class SymbolsResolver; namespace Libraries::Http { +struct OrbisHttpUriElement { + bool opaque; + char* scheme; + char* username; + char* password; + char* hostname; + char* path; + char* query; + char* fragment; + u16 port; + u8 reserved[10]; +}; + int PS4_SYSV_ABI sceHttpAbortRequest(); int PS4_SYSV_ABI sceHttpAbortRequestForce(); int PS4_SYSV_ABI sceHttpAbortWaitRequest(); @@ -122,9 +135,10 @@ int PS4_SYSV_ABI sceHttpUriBuild(); int PS4_SYSV_ABI sceHttpUriCopy(); int PS4_SYSV_ABI sceHttpUriEscape(); int PS4_SYSV_ABI sceHttpUriMerge(); -int PS4_SYSV_ABI sceHttpUriParse(); -int PS4_SYSV_ABI sceHttpUriSweepPath(); -int PS4_SYSV_ABI sceHttpUriUnescape(); +int PS4_SYSV_ABI sceHttpUriParse(OrbisHttpUriElement* out, const char* srcUri, void* pool, + size_t* require, size_t prepare); +int PS4_SYSV_ABI sceHttpUriSweepPath(char* dst, const char* src, size_t srcSize); +int PS4_SYSV_ABI sceHttpUriUnescape(char* out, size_t* require, size_t prepare, const char* in); int PS4_SYSV_ABI sceHttpWaitRequest(); void RegisterlibSceHttp(Core::Loader::SymbolsResolver* sym); diff --git a/src/core/libraries/network/http_error.h b/src/core/libraries/network/http_error.h new file mode 100644 index 000000000..49cc89766 --- /dev/null +++ b/src/core/libraries/network/http_error.h @@ -0,0 +1,66 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "core/libraries/error_codes.h" + +constexpr int ORBIS_HTTP_ERROR_BEFORE_INIT = 0x80431001; +constexpr int ORBIS_HTTP_ERROR_ALREADY_INITED = 0x80431020; +constexpr int ORBIS_HTTP_ERROR_BUSY = 0x80431021; +constexpr int ORBIS_HTTP_ERROR_OUT_OF_MEMORY = 0x80431022; +constexpr int ORBIS_HTTP_ERROR_NOT_FOUND = 0x80431025; +constexpr int ORBIS_HTTP_ERROR_INVALID_VERSION = 0x8043106a; +constexpr int ORBIS_HTTP_ERROR_INVALID_ID = 0x80431100; +constexpr int ORBIS_HTTP_ERROR_OUT_OF_SIZE = 0x80431104; +constexpr int ORBIS_HTTP_ERROR_INVALID_VALUE = 0x804311fe; + +constexpr int ORBIS_HTTP_ERROR_INVALID_URL = 0x80433060; +constexpr int ORBIS_HTTP_ERROR_UNKNOWN_SCHEME = 0x80431061; +constexpr int ORBIS_HTTP_ERROR_NETWORK = 0x80431063; +constexpr int ORBIS_HTTP_ERROR_BAD_RESPONSE = 0x80431064; +constexpr int ORBIS_HTTP_ERROR_BEFORE_SEND = 0x80431065; +constexpr int ORBIS_HTTP_ERROR_AFTER_SEND = 0x80431066; +constexpr int ORBIS_HTTP_ERROR_TIMEOUT = 0x80431068; +constexpr int ORBIS_HTTP_ERROR_UNKNOWN_AUTH_TYPE = 0x80431069; +constexpr int ORBIS_HTTP_ERROR_UNKNOWN_METHOD = 0x8043106b; +constexpr int ORBIS_HTTP_ERROR_READ_BY_HEAD_METHOD = 0x8043106f; +constexpr int ORBIS_HTTP_ERROR_NOT_IN_COM = 0x80431070; +constexpr int ORBIS_HTTP_ERROR_NO_CONTENT_LENGTH = 0x80431071; +constexpr int ORBIS_HTTP_ERROR_CHUNK_ENC = 0x80431072; +constexpr int ORBIS_HTTP_ERROR_TOO_LARGE_RESPONSE_HEADER = 0x80431073; +constexpr int ORBIS_HTTP_ERROR_SSL = 0x80431075; +constexpr int ORBIS_HTTP_ERROR_INSUFFICIENT_STACKSIZE = 0x80431076; +constexpr int ORBIS_HTTP_ERROR_ABORTED = 0x80431080; +constexpr int ORBIS_HTTP_ERROR_UNKNOWN = 0x80431081; +constexpr int ORBIS_HTTP_ERROR_EAGAIN = 0x80431082; +constexpr int ORBIS_HTTP_ERROR_PROXY = 0x80431084; +constexpr int ORBIS_HTTP_ERROR_BROKEN = 0x80431085; + +constexpr int ORBIS_HTTP_ERROR_PARSE_HTTP_NOT_FOUND = 0x80432025; +constexpr int ORBIS_HTTP_ERROR_PARSE_HTTP_INVALID_RESPONSE = 0x80432060; +constexpr int ORBIS_HTTP_ERROR_PARSE_HTTP_INVALID_VALUE = 0x804321fe; + +constexpr int ORBIS_HTTP_ERROR_RESOLVER_EPACKET = 0x80436001; +constexpr int ORBIS_HTTP_ERROR_RESOLVER_ENODNS = 0x80436002; +constexpr int ORBIS_HTTP_ERROR_RESOLVER_ETIMEDOUT = 0x80436003; +constexpr int ORBIS_HTTP_ERROR_RESOLVER_ENOSUPPORT = 0x80436004; +constexpr int ORBIS_HTTP_ERROR_RESOLVER_EFORMAT = 0x80436005; +constexpr int ORBIS_HTTP_ERROR_RESOLVER_ESERVERFAILURE = 0x80436006; +constexpr int ORBIS_HTTP_ERROR_RESOLVER_ENOHOST = 0x80436007; +constexpr int ORBIS_HTTP_ERROR_RESOLVER_ENOTIMPLEMENTED = 0x80436008; +constexpr int ORBIS_HTTP_ERROR_RESOLVER_ESERVERREFUSED = 0x80436009; +constexpr int ORBIS_HTTP_ERROR_RESOLVER_ENORECORD = 0x8043600a; + +constexpr int ORBIS_HTTPS_ERROR_CERT = 0x80435060; +constexpr int ORBIS_HTTPS_ERROR_HANDSHAKE = 0x80435061; +constexpr int ORBIS_HTTPS_ERROR_IO = 0x80435062; +constexpr int ORBIS_HTTPS_ERROR_INTERNAL = 0x80435063; +constexpr int ORBIS_HTTPS_ERROR_PROXY = 0x80435064; + +constexpr int ORBIS_HTTPS_ERROR_SSL_INTERNAL = 0x01; +constexpr int ORBIS_HTTPS_ERROR_SSL_INVALID_CERT = 0x02; +constexpr int ORBIS_HTTPS_ERROR_SSL_CN_CHECK = 0x04; +constexpr int ORBIS_HTTPS_ERROR_SSL_NOT_AFTER_CHECK = 0x08; +constexpr int ORBIS_HTTPS_ERROR_SSL_NOT_BEFORE_CHECK = 0x10; +constexpr int ORBIS_HTTPS_ERROR_SSL_UNKNOWN_CA = 0x20; diff --git a/src/core/libraries/ngs2/ngs2.cpp b/src/core/libraries/ngs2/ngs2.cpp index 7eb663413..743be5fd6 100644 --- a/src/core/libraries/ngs2/ngs2.cpp +++ b/src/core/libraries/ngs2/ngs2.cpp @@ -5,21 +5,416 @@ #include "core/libraries/error_codes.h" #include "core/libraries/libs.h" #include "core/libraries/ngs2/ngs2.h" +#include "core/libraries/ngs2/ngs2_custom.h" #include "core/libraries/ngs2/ngs2_error.h" +#include "core/libraries/ngs2/ngs2_geom.h" #include "core/libraries/ngs2/ngs2_impl.h" +#include "core/libraries/ngs2/ngs2_pan.h" +#include "core/libraries/ngs2/ngs2_report.h" namespace Libraries::Ngs2 { -int PS4_SYSV_ABI sceNgs2CalcWaveformBlock() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); +// Ngs2 + +s32 PS4_SYSV_ABI sceNgs2CalcWaveformBlock(const OrbisNgs2WaveformFormat* format, u32 samplePos, + u32 numSamples, OrbisNgs2WaveformBlock* outBlock) { + LOG_ERROR(Lib_Ngs2, "samplePos = {}, numSamples = {}", samplePos, numSamples); return ORBIS_OK; } -int PS4_SYSV_ABI sceNgs2CustomRackGetModuleInfo() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); +s32 PS4_SYSV_ABI sceNgs2GetWaveformFrameInfo(const OrbisNgs2WaveformFormat* format, + u32* outFrameSize, u32* outNumFrameSamples, + u32* outUnitsPerFrame, u32* outNumDelaySamples) { + LOG_ERROR(Lib_Ngs2, "called"); return ORBIS_OK; } +s32 PS4_SYSV_ABI sceNgs2ParseWaveformData(const void* data, size_t dataSize, + OrbisNgs2WaveformInfo* outInfo) { + LOG_ERROR(Lib_Ngs2, "dataSize = {}", dataSize); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2ParseWaveformFile(const char* path, u64 offset, + OrbisNgs2WaveformInfo* outInfo) { + LOG_ERROR(Lib_Ngs2, "path = {}, offset = {}", path, offset); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2ParseWaveformUser(OrbisNgs2ParseReadHandler handler, uintptr_t userData, + OrbisNgs2WaveformInfo* outInfo) { + LOG_ERROR(Lib_Ngs2, "userData = {}", userData); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2RackCreate(OrbisNgs2Handle systemHandle, u32 rackId, + const OrbisNgs2RackOption* option, + const OrbisNgs2ContextBufferInfo* bufferInfo, + OrbisNgs2Handle* outHandle) { + LOG_ERROR(Lib_Ngs2, "rackId = {}", rackId); + if (!systemHandle) { + LOG_ERROR(Lib_Ngs2, "systemHandle is nullptr"); + return ORBIS_NGS2_ERROR_INVALID_SYSTEM_HANDLE; + } + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2RackCreateWithAllocator(OrbisNgs2Handle systemHandle, u32 rackId, + const OrbisNgs2RackOption* option, + const OrbisNgs2BufferAllocator* allocator, + OrbisNgs2Handle* outHandle) { + LOG_ERROR(Lib_Ngs2, "rackId = {}", rackId); + if (!systemHandle) { + LOG_ERROR(Lib_Ngs2, "systemHandle is nullptr"); + return ORBIS_NGS2_ERROR_INVALID_SYSTEM_HANDLE; + } + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2RackDestroy(OrbisNgs2Handle rackHandle, + OrbisNgs2ContextBufferInfo* outBufferInfo) { + LOG_ERROR(Lib_Ngs2, "called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2RackGetInfo(OrbisNgs2Handle rackHandle, OrbisNgs2RackInfo* outInfo, + size_t infoSize) { + LOG_ERROR(Lib_Ngs2, "infoSize = {}", infoSize); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2RackGetUserData(OrbisNgs2Handle rackHandle, uintptr_t* outUserData) { + LOG_ERROR(Lib_Ngs2, "called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2RackGetVoiceHandle(OrbisNgs2Handle rackHandle, u32 voiceIndex, + OrbisNgs2Handle* outHandle) { + LOG_DEBUG(Lib_Ngs2, "(STUBBED) voiceIndex = {}", voiceIndex); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2RackLock(OrbisNgs2Handle rackHandle) { + LOG_ERROR(Lib_Ngs2, "called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2RackQueryBufferSize(u32 rackId, const OrbisNgs2RackOption* option, + OrbisNgs2ContextBufferInfo* outBufferInfo) { + LOG_ERROR(Lib_Ngs2, "rackId = {}", rackId); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2RackSetUserData(OrbisNgs2Handle rackHandle, uintptr_t userData) { + LOG_ERROR(Lib_Ngs2, "userData = {}", userData); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2RackUnlock(OrbisNgs2Handle rackHandle) { + LOG_ERROR(Lib_Ngs2, "called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2SystemCreate(const OrbisNgs2SystemOption* option, + const OrbisNgs2ContextBufferInfo* bufferInfo, + OrbisNgs2Handle* outHandle) { + s32 result; + OrbisNgs2ContextBufferInfo localInfo; + if (!bufferInfo || !outHandle) { + if (!bufferInfo) { + result = ORBIS_NGS2_ERROR_INVALID_BUFFER_INFO; + LOG_ERROR(Lib_Ngs2, "Invalid system buffer info {}", (void*)bufferInfo); + } else { + result = ORBIS_NGS2_ERROR_INVALID_OUT_ADDRESS; + LOG_ERROR(Lib_Ngs2, "Invalid system handle address {}", (void*)outHandle); + } + + // TODO: Report errors? + } else { + // Make bufferInfo copy + localInfo.hostBuffer = bufferInfo->hostBuffer; + localInfo.hostBufferSize = bufferInfo->hostBufferSize; + for (int i = 0; i < 5; i++) { + localInfo.reserved[i] = bufferInfo->reserved[i]; + } + localInfo.userData = bufferInfo->userData; + + result = SystemSetup(option, &localInfo, 0, outHandle); + } + + // TODO: API reporting? + + LOG_INFO(Lib_Ngs2, "called"); + return result; +} + +s32 PS4_SYSV_ABI sceNgs2SystemCreateWithAllocator(const OrbisNgs2SystemOption* option, + const OrbisNgs2BufferAllocator* allocator, + OrbisNgs2Handle* outHandle) { + s32 result; + if (allocator && allocator->allocHandler != 0) { + OrbisNgs2BufferAllocHandler hostAlloc = allocator->allocHandler; + if (outHandle) { + OrbisNgs2BufferFreeHandler hostFree = allocator->freeHandler; + OrbisNgs2ContextBufferInfo bufferInfo; + result = SystemSetup(option, &bufferInfo, 0, 0); + if (result >= 0) { + uintptr_t sysUserData = allocator->userData; + result = Core::ExecuteGuest(hostAlloc, &bufferInfo); + if (result >= 0) { + OrbisNgs2Handle* handleCopy = outHandle; + result = SystemSetup(option, &bufferInfo, hostFree, handleCopy); + if (result < 0) { + if (hostFree) { + Core::ExecuteGuest(hostFree, &bufferInfo); + } + } + } + } + } else { + result = ORBIS_NGS2_ERROR_INVALID_OUT_ADDRESS; + LOG_ERROR(Lib_Ngs2, "Invalid system handle address {}", (void*)outHandle); + } + } else { + result = ORBIS_NGS2_ERROR_INVALID_BUFFER_ALLOCATOR; + LOG_ERROR(Lib_Ngs2, "Invalid system buffer allocator {}", (void*)allocator); + } + LOG_INFO(Lib_Ngs2, "called"); + return result; +} + +s32 PS4_SYSV_ABI sceNgs2SystemDestroy(OrbisNgs2Handle systemHandle, + OrbisNgs2ContextBufferInfo* outBufferInfo) { + if (!systemHandle) { + LOG_ERROR(Lib_Ngs2, "systemHandle is nullptr"); + return ORBIS_NGS2_ERROR_INVALID_SYSTEM_HANDLE; + } + LOG_INFO(Lib_Ngs2, "called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2SystemEnumHandles(OrbisNgs2Handle* aOutHandle, u32 maxHandles) { + LOG_ERROR(Lib_Ngs2, "maxHandles = {}", maxHandles); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2SystemEnumRackHandles(OrbisNgs2Handle systemHandle, + OrbisNgs2Handle* aOutHandle, u32 maxHandles) { + LOG_ERROR(Lib_Ngs2, "maxHandles = {}", maxHandles); + if (!systemHandle) { + LOG_ERROR(Lib_Ngs2, "systemHandle is nullptr"); + return ORBIS_NGS2_ERROR_INVALID_SYSTEM_HANDLE; + } + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2SystemGetInfo(OrbisNgs2Handle rackHandle, OrbisNgs2SystemInfo* outInfo, + size_t infoSize) { + LOG_ERROR(Lib_Ngs2, "infoSize = {}", infoSize); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2SystemGetUserData(OrbisNgs2Handle systemHandle, uintptr_t* outUserData) { + if (!systemHandle) { + LOG_ERROR(Lib_Ngs2, "systemHandle is nullptr"); + return ORBIS_NGS2_ERROR_INVALID_SYSTEM_HANDLE; + } + LOG_ERROR(Lib_Ngs2, "called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2SystemLock(OrbisNgs2Handle systemHandle) { + if (!systemHandle) { + LOG_ERROR(Lib_Ngs2, "systemHandle is nullptr"); + return ORBIS_NGS2_ERROR_INVALID_SYSTEM_HANDLE; + } + LOG_ERROR(Lib_Ngs2, "called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2SystemQueryBufferSize(const OrbisNgs2SystemOption* option, + OrbisNgs2ContextBufferInfo* outBufferInfo) { + s32 result; + if (outBufferInfo) { + result = SystemSetup(option, outBufferInfo, 0, 0); + LOG_INFO(Lib_Ngs2, "called"); + } else { + result = ORBIS_NGS2_ERROR_INVALID_OUT_ADDRESS; + LOG_ERROR(Lib_Ngs2, "Invalid system buffer info {}", (void*)outBufferInfo); + } + + return result; +} + +s32 PS4_SYSV_ABI sceNgs2SystemRender(OrbisNgs2Handle systemHandle, + const OrbisNgs2RenderBufferInfo* aBufferInfo, + u32 numBufferInfo) { + LOG_DEBUG(Lib_Ngs2, "(STUBBED) numBufferInfo = {}", numBufferInfo); + if (!systemHandle) { + LOG_ERROR(Lib_Ngs2, "systemHandle is nullptr"); + return ORBIS_NGS2_ERROR_INVALID_SYSTEM_HANDLE; + } + return ORBIS_OK; +} + +static s32 PS4_SYSV_ABI sceNgs2SystemResetOption(OrbisNgs2SystemOption* outOption) { + static const OrbisNgs2SystemOption option = { + sizeof(OrbisNgs2SystemOption), "", 0, 512, 256, 48000, {0}}; + + if (!outOption) { + LOG_ERROR(Lib_Ngs2, "Invalid system option address {}", (void*)outOption); + return ORBIS_NGS2_ERROR_INVALID_OPTION_ADDRESS; + } + *outOption = option; + + LOG_INFO(Lib_Ngs2, "called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2SystemSetGrainSamples(OrbisNgs2Handle systemHandle, u32 numSamples) { + LOG_ERROR(Lib_Ngs2, "numSamples = {}", numSamples); + if (!systemHandle) { + LOG_ERROR(Lib_Ngs2, "systemHandle is nullptr"); + return ORBIS_NGS2_ERROR_INVALID_SYSTEM_HANDLE; + } + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2SystemSetSampleRate(OrbisNgs2Handle systemHandle, u32 sampleRate) { + LOG_ERROR(Lib_Ngs2, "sampleRate = {}", sampleRate); + if (!systemHandle) { + LOG_ERROR(Lib_Ngs2, "systemHandle is nullptr"); + return ORBIS_NGS2_ERROR_INVALID_SYSTEM_HANDLE; + } + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2SystemSetUserData(OrbisNgs2Handle systemHandle, uintptr_t userData) { + LOG_ERROR(Lib_Ngs2, "userData = {}", userData); + if (!systemHandle) { + LOG_ERROR(Lib_Ngs2, "systemHandle is nullptr"); + return ORBIS_NGS2_ERROR_INVALID_SYSTEM_HANDLE; + } + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2SystemUnlock(OrbisNgs2Handle systemHandle) { + if (!systemHandle) { + LOG_ERROR(Lib_Ngs2, "systemHandle is nullptr"); + return ORBIS_NGS2_ERROR_INVALID_SYSTEM_HANDLE; + } + LOG_ERROR(Lib_Ngs2, "called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2VoiceControl(OrbisNgs2Handle voiceHandle, + const OrbisNgs2VoiceParamHeader* paramList) { + LOG_ERROR(Lib_Ngs2, "called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2VoiceGetMatrixInfo(OrbisNgs2Handle voiceHandle, u32 matrixId, + OrbisNgs2VoiceMatrixInfo* outInfo, size_t outInfoSize) { + LOG_ERROR(Lib_Ngs2, "matrixId = {}, outInfoSize = {}", matrixId, outInfoSize); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2VoiceGetOwner(OrbisNgs2Handle voiceHandle, OrbisNgs2Handle* outRackHandle, + u32* outVoiceId) { + LOG_ERROR(Lib_Ngs2, "called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2VoiceGetPortInfo(OrbisNgs2Handle voiceHandle, u32 port, + OrbisNgs2VoicePortInfo* outInfo, size_t outInfoSize) { + LOG_ERROR(Lib_Ngs2, "port = {}, outInfoSize = {}", port, outInfoSize); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2VoiceGetState(OrbisNgs2Handle voiceHandle, OrbisNgs2VoiceState* outState, + size_t stateSize) { + LOG_ERROR(Lib_Ngs2, "stateSize = {}", stateSize); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2VoiceGetStateFlags(OrbisNgs2Handle voiceHandle, u32* outStateFlags) { + LOG_ERROR(Lib_Ngs2, "called"); + return ORBIS_OK; +} + +// Ngs2Custom + +s32 PS4_SYSV_ABI sceNgs2CustomRackGetModuleInfo(OrbisNgs2Handle rackHandle, u32 moduleIndex, + OrbisNgs2CustomModuleInfo* outInfo, + size_t infoSize) { + LOG_ERROR(Lib_Ngs2, "moduleIndex = {}, infoSize = {}", moduleIndex, infoSize); + return ORBIS_OK; +} + +// Ngs2Geom + +s32 PS4_SYSV_ABI sceNgs2GeomResetListenerParam(OrbisNgs2GeomListenerParam* outListenerParam) { + LOG_ERROR(Lib_Ngs2, "called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2GeomResetSourceParam(OrbisNgs2GeomSourceParam* outSourceParam) { + LOG_ERROR(Lib_Ngs2, "called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2GeomCalcListener(const OrbisNgs2GeomListenerParam* param, + OrbisNgs2GeomListenerWork* outWork, u32 flags) { + LOG_ERROR(Lib_Ngs2, "flags = {}", flags); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2GeomApply(const OrbisNgs2GeomListenerWork* listener, + const OrbisNgs2GeomSourceParam* source, + OrbisNgs2GeomAttribute* outAttrib, u32 flags) { + LOG_ERROR(Lib_Ngs2, "flags = {}", flags); + return ORBIS_OK; +} + +// Ngs2Pan + +s32 PS4_SYSV_ABI sceNgs2PanInit(OrbisNgs2PanWork* work, const float* aSpeakerAngle, float unitAngle, + u32 numSpeakers) { + LOG_ERROR(Lib_Ngs2, "aSpeakerAngle = {}, unitAngle = {}, numSpeakers = {}", *aSpeakerAngle, + unitAngle, numSpeakers); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2PanGetVolumeMatrix(OrbisNgs2PanWork* work, const OrbisNgs2PanParam* aParam, + u32 numParams, u32 matrixFormat, + float* outVolumeMatrix) { + LOG_ERROR(Lib_Ngs2, "numParams = {}, matrixFormat = {}", numParams, matrixFormat); + return ORBIS_OK; +} + +// Ngs2Report + +s32 PS4_SYSV_ABI sceNgs2ReportRegisterHandler(u32 reportType, OrbisNgs2ReportHandler handler, + uintptr_t userData, OrbisNgs2Handle* outHandle) { + LOG_INFO(Lib_Ngs2, "reportType = {}, userData = {}", reportType, userData); + if (!handler) { + LOG_ERROR(Lib_Ngs2, "handler is nullptr"); + return ORBIS_NGS2_ERROR_INVALID_REPORT_HANDLE; + } + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNgs2ReportUnregisterHandler(OrbisNgs2Handle reportHandle) { + if (!reportHandle) { + LOG_ERROR(Lib_Ngs2, "reportHandle is nullptr"); + return ORBIS_NGS2_ERROR_INVALID_REPORT_HANDLE; + } + LOG_INFO(Lib_Ngs2, "called"); + return ORBIS_OK; +} + +// Unknown + int PS4_SYSV_ABI sceNgs2FftInit() { LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); return ORBIS_OK; @@ -35,31 +430,6 @@ int PS4_SYSV_ABI sceNgs2FftQuerySize() { return ORBIS_OK; } -int PS4_SYSV_ABI sceNgs2GeomApply() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2GeomCalcListener() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2GeomResetListenerParam() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2GeomResetSourceParam() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2GetWaveformFrameInfo() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - int PS4_SYSV_ABI sceNgs2JobSchedulerResetOption() { LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); return ORBIS_OK; @@ -80,71 +450,6 @@ int PS4_SYSV_ABI sceNgs2ModuleQueueEnumItems() { return ORBIS_OK; } -int PS4_SYSV_ABI sceNgs2PanGetVolumeMatrix() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2PanInit() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2ParseWaveformData() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2ParseWaveformFile() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2ParseWaveformUser() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2RackCreate() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2RackCreateWithAllocator() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2RackDestroy() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2RackGetInfo() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2RackGetUserData() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2RackGetVoiceHandle() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2RackLock() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2RackQueryBufferSize() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - int PS4_SYSV_ABI sceNgs2RackQueryInfo() { LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); return ORBIS_OK; @@ -155,116 +460,21 @@ int PS4_SYSV_ABI sceNgs2RackRunCommands() { return ORBIS_OK; } -int PS4_SYSV_ABI sceNgs2RackSetUserData() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2RackUnlock() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2ReportRegisterHandler() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2ReportUnregisterHandler() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2SystemCreate() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2SystemCreateWithAllocator() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2SystemDestroy() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2SystemEnumHandles() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2SystemEnumRackHandles() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2SystemGetInfo() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2SystemGetUserData() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2SystemLock() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2SystemQueryBufferSize() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - int PS4_SYSV_ABI sceNgs2SystemQueryInfo() { LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); return ORBIS_OK; } -int PS4_SYSV_ABI sceNgs2SystemRender() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2SystemResetOption() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - int PS4_SYSV_ABI sceNgs2SystemRunCommands() { LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); return ORBIS_OK; } -int PS4_SYSV_ABI sceNgs2SystemSetGrainSamples() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - int PS4_SYSV_ABI sceNgs2SystemSetLoudThreshold() { LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); return ORBIS_OK; } -int PS4_SYSV_ABI sceNgs2SystemSetSampleRate() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2SystemSetUserData() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2SystemUnlock() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - int PS4_SYSV_ABI sceNgs2StreamCreate() { LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); return ORBIS_OK; @@ -300,36 +510,6 @@ int PS4_SYSV_ABI sceNgs2StreamRunCommands() { return ORBIS_OK; } -int PS4_SYSV_ABI sceNgs2VoiceControl() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2VoiceGetMatrixInfo() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2VoiceGetOwner() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2VoiceGetPortInfo() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2VoiceGetState() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - -int PS4_SYSV_ABI sceNgs2VoiceGetStateFlags() { - LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); - return ORBIS_OK; -} - int PS4_SYSV_ABI sceNgs2VoiceQueryInfo() { LOG_ERROR(Lib_Ngs2, "(STUBBED) called"); return ORBIS_OK; diff --git a/src/core/libraries/ngs2/ngs2.h b/src/core/libraries/ngs2/ngs2.h index a5f1f52a6..6c499d974 100644 --- a/src/core/libraries/ngs2/ngs2.h +++ b/src/core/libraries/ngs2/ngs2.h @@ -3,7 +3,11 @@ #pragma once +#include "core/libraries/ngs2/ngs2_impl.h" + #include +#include +#include #include "common/types.h" namespace Core::Loader { @@ -12,60 +16,257 @@ class SymbolsResolver; namespace Libraries::Ngs2 { -class Ngs2; +using OrbisNgs2ParseReadHandler = s32 PS4_SYSV_ABI (*)(uintptr_t user_data, u32 offset, void* data, + size_t size); -using SceNgs2Handle = Ngs2*; - -enum class SceNgs2HandleType : u32 { - System = 0, +enum class OrbisNgs2HandleType : u32 { + Invalid = 0, + System = 1, + Rack = 2, + Voice = 3, + VoiceControl = 6 }; -struct Ngs2Handle { - void* selfPointer; - void* dataPointer; - std::atomic* atomicPtr; - u32 handleType; - u32 flags_unk; +static const int ORBIS_NGS2_MAX_VOICE_CHANNELS = 8; +static const int ORBIS_NGS2_WAVEFORM_INFO_MAX_BLOCKS = 4; +static const int ORBIS_NGS2_MAX_MATRIX_LEVELS = + (ORBIS_NGS2_MAX_VOICE_CHANNELS * ORBIS_NGS2_MAX_VOICE_CHANNELS); - u32 uid; - u16 maxGrainSamples; - u16 minGrainSamples; - u16 currentGrainSamples; - u16 numGrainSamples; - u16 unknown2; +struct OrbisNgs2WaveformFormat { + u32 waveformType; + u32 numChannels; u32 sampleRate; - u32 unknown3; - - void* flushMutex; - u32 flushMutexInitialized; - void* processMutex; - u32 processMutexInitialized; - - // Linked list pointers for system list - Ngs2Handle* prev; - Ngs2Handle* next; + u32 configData; + u32 frameOffset; + u32 frameMargin; }; -struct SystemOptions { - char padding[6]; - s32 maxGrainSamples; - s32 numGrainSamples; - s32 sampleRate; +struct OrbisNgs2WaveformBlock { + u32 dataOffset; + u32 dataSize; + u32 numRepeats; + u32 numSkipSamples; + u32 numSamples; + u32 reserved; + uintptr_t userData; }; -struct SystemState { - // TODO +struct OrbisNgs2WaveformInfo { + OrbisNgs2WaveformFormat format; + + u32 dataOffset; + u32 dataSize; + + u32 loopBeginPosition; + u32 loopEndPosition; + u32 numSamples; + + u32 audioUnitSize; + u32 numAudioUnitSamples; + u32 numAudioUnitPerFrame; + + u32 audioFrameSize; + u32 numAudioFrameSamples; + + u32 numDelaySamples; + + u32 numBlocks; + OrbisNgs2WaveformBlock aBlock[ORBIS_NGS2_WAVEFORM_INFO_MAX_BLOCKS]; }; -struct StackBuffer { - void** top; - void* base; - void* curr; - size_t usedSize; - size_t totalSize; - size_t alignment; - char isVerifyEnabled; - char padding[7]; +struct OrbisNgs2EnvelopePoint { + u32 curve; + u32 duration; + float height; +}; + +struct OrbisNgs2UserFxProcessContext { + float** aChannelData; + uintptr_t userData0; + uintptr_t userData1; + uintptr_t userData2; + u32 flags; + u32 numChannels; + u32 numGrainSamples; + u32 sampleRate; +}; + +using OrbisNgs2UserFxProcessHandler = s32 PS4_SYSV_ABI (*)(OrbisNgs2UserFxProcessContext* context); + +struct OrbisNgs2UserFx2SetupContext { + void* common; + void* param; + void* work; + uintptr_t userData; + u32 maxVoices; + u32 voiceIndex; + u64 reserved[4]; +}; + +using OrbisNgs2UserFx2SetupHandler = s32 PS4_SYSV_ABI (*)(OrbisNgs2UserFx2SetupContext* context); + +struct OrbisNgs2UserFx2CleanupContext { + void* common; + void* param; + void* work; + uintptr_t userData; + u32 maxVoices; + u32 voiceIndex; + u64 reserved[4]; +}; + +using OrbisNgs2UserFx2CleanupHandler = + s32 PS4_SYSV_ABI (*)(OrbisNgs2UserFx2CleanupContext* context); + +struct OrbisNgs2UserFx2ControlContext { + const void* data; + size_t dataSize; + void* common; + void* param; + uintptr_t userData; + u64 reserved[4]; +}; + +using OrbisNgs2UserFx2ControlHandler = + s32 PS4_SYSV_ABI (*)(OrbisNgs2UserFx2ControlContext* context); + +struct OrbisNgs2UserFx2ProcessContext { + float** aChannelData; + void* common; + const void* param; + void* work; + void* state; + uintptr_t userData; + u32 flags; + u32 numInputChannels; + u32 numOutputChannels; + u32 numGrainSamples; + u32 sampleRate; + u32 reserved; + u64 reserved2[4]; +}; + +using OrbisNgs2UserFx2ProcessHandler = + s32 PS4_SYSV_ABI (*)(OrbisNgs2UserFx2ProcessContext* context); + +struct OrbisNgs2BufferAllocator { + OrbisNgs2BufferAllocHandler allocHandler; + OrbisNgs2BufferFreeHandler freeHandler; + uintptr_t userData; +}; + +struct OrbisNgs2RenderBufferInfo { + void* buffer; + size_t bufferSize; + u32 waveformType; + u32 numChannels; +}; + +struct OrbisNgs2RackOption { + size_t size; + char name[ORBIS_NGS2_RACK_NAME_LENGTH]; + + u32 flags; + u32 maxGrainSamples; + u32 maxVoices; + u32 maxInputDelayBlocks; + u32 maxMatrices; + u32 maxPorts; + u32 aReserved[20]; +}; + +struct OrbisNgs2VoiceParamHeader { + u16 size; + s16 next; + u32 id; +}; + +struct OrbisNgs2VoiceMatrixLevelsParam { + OrbisNgs2VoiceParamHeader header; + + u32 matrixId; + u32 numLevels; + const float* aLevel; +}; + +struct OrbisNgs2VoicePortMatrixParam { + OrbisNgs2VoiceParamHeader header; + + u32 port; + s32 matrixId; +}; + +struct OrbisNgs2VoicePortVolumeParam { + OrbisNgs2VoiceParamHeader header; + + u32 port; + float level; +}; + +struct OrbisNgs2VoicePortDelayParam { + OrbisNgs2VoiceParamHeader header; + + u32 port; + u32 numSamples; +}; + +struct OrbisNgs2VoicePatchParam { + OrbisNgs2VoiceParamHeader header; + + u32 port; + u32 destInputId; + OrbisNgs2Handle destHandle; +}; + +struct OrbisNgs2VoiceEventParam { + OrbisNgs2VoiceParamHeader header; + + u32 eventId; +}; + +struct OrbisNgs2VoiceCallbackInfo { + uintptr_t callbackData; + OrbisNgs2Handle voiceHandle; + u32 flag; + u32 reserved; + union { + struct { + uintptr_t userData; + const void* data; + u32 dataSize; + u32 repeatedCount; + u32 attributeFlags; + u32 reserved2; + } waveformBlock; + } param; +}; + +using OrbisNgs2VoiceCallbackHandler = void PS4_SYSV_ABI (*)(const OrbisNgs2VoiceCallbackInfo* info); + +struct OrbisNgs2VoiceCallbackParam { + OrbisNgs2VoiceParamHeader header; + OrbisNgs2VoiceCallbackHandler callbackHandler; + + uintptr_t callbackData; + u32 flags; + u32 reserved; +}; + +struct OrbisNgs2VoicePortInfo { + s32 matrixId; + float volume; + u32 numDelaySamples; + u32 destInputId; + OrbisNgs2Handle destHandle; +}; + +struct OrbisNgs2VoiceMatrixInfo { + u32 numLevels; + float aLevel[ORBIS_NGS2_MAX_MATRIX_LEVELS]; +}; + +struct OrbisNgs2VoiceState { + u32 stateFlags; }; void RegisterlibSceNgs2(Core::Loader::SymbolsResolver* sym); diff --git a/src/core/libraries/audio3d/audio3d_impl.cpp b/src/core/libraries/ngs2/ngs2_custom.cpp similarity index 58% rename from src/core/libraries/audio3d/audio3d_impl.cpp rename to src/core/libraries/ngs2/ngs2_custom.cpp index 3069e8800..8c82e4e49 100644 --- a/src/core/libraries/audio3d/audio3d_impl.cpp +++ b/src/core/libraries/ngs2/ngs2_custom.cpp @@ -1,13 +1,12 @@ // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include "audio3d_error.h" -#include "audio3d_impl.h" +#include "ngs2_error.h" +#include "ngs2_impl.h" #include "common/logging/log.h" #include "core/libraries/error_codes.h" -#include "core/libraries/kernel/kernel.h" using namespace Libraries::Kernel; -namespace Libraries::Audio3d {} // namespace Libraries::Audio3d +namespace Libraries::Ngs2 {} // namespace Libraries::Ngs2 diff --git a/src/core/libraries/ngs2/ngs2_custom.h b/src/core/libraries/ngs2/ngs2_custom.h new file mode 100644 index 000000000..0c45a5d81 --- /dev/null +++ b/src/core/libraries/ngs2/ngs2_custom.h @@ -0,0 +1,444 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "ngs2.h" +#include "ngs2_reverb.h" + +namespace Libraries::Ngs2 { + +class Ngs2Custom; + +static const int ORBIS_NGS2_CUSTOM_MAX_MODULES = 24; +static const int ORBIS_NGS2_CUSTOM_MAX_PORTS = 16; +static const int ORBIS_NGS2_CUSTOM_DELAY_MAX_TAPS = 8; + +struct OrbisNgs2CustomModuleOption { + u32 size; +}; + +struct OrbisNgs2CustomEnvelopeModuleOption { + OrbisNgs2CustomModuleOption customModuleOption; + + u32 maxPoints; + u32 reserved; +}; + +struct OrbisNgs2CustomReverbModuleOption { + OrbisNgs2CustomModuleOption customModuleOption; + + u32 reverbSize; + u32 reserved; +}; + +struct OrbisNgs2CustomChorusModuleOption { + OrbisNgs2CustomModuleOption customModuleOption; + + u32 maxPhases; + u32 reserved; +} OrbisNgs2CustomChorusModuleOption; + +struct OrbisNgs2CustomPeakMeterModuleOption { + OrbisNgs2CustomModuleOption customModuleOption; + u32 numBlocks; + u32 reserved; +}; + +struct OrbisNgs2CustomDelayModuleOption { + OrbisNgs2CustomModuleOption customModuleOption; + + u32 type; + u32 maxTaps; + float maxLength; + u32 reserved; +}; + +struct OrbisNgs2CustomPitchShiftModuleOption { + OrbisNgs2CustomModuleOption customModuleOption; + + u32 quality; +}; + +struct OrbisNgs2CustomUserFx2ModuleOption { + OrbisNgs2CustomModuleOption customModuleOption; + + OrbisNgs2UserFx2SetupHandler setupHandler; + OrbisNgs2UserFx2CleanupHandler cleanupHandler; + OrbisNgs2UserFx2ControlHandler controlHandler; + OrbisNgs2UserFx2ProcessHandler processHandler; + + size_t commonSize; + size_t paramSize; + size_t workSize; + uintptr_t userData; +}; + +struct OrbisNgs2CustomRackModuleInfo { + const OrbisNgs2CustomModuleOption* option; + + u32 moduleId; + u32 sourceBufferId; + u32 extraBufferId; + u32 destBufferId; + u32 stateOffset; + u32 stateSize; + u32 reserved; + u32 reserved2; +}; + +struct OrbisNgs2CustomRackPortInfo { + u32 sourceBufferId; + u32 reserved; +}; + +struct OrbisNgs2CustomRackOption { + OrbisNgs2RackOption rackOption; + u32 stateSize; + u32 numBuffers; + u32 numModules; + u32 reserved; + OrbisNgs2CustomRackModuleInfo aModule[ORBIS_NGS2_CUSTOM_MAX_MODULES]; + OrbisNgs2CustomRackPortInfo aPort[ORBIS_NGS2_CUSTOM_MAX_PORTS]; +}; + +struct OrbisNgs2CustomSamplerRackOption { + OrbisNgs2CustomRackOption customRackOption; + + u32 maxChannelWorks; + u32 maxWaveformBlocks; + u32 maxAtrac9Decoders; + u32 maxAtrac9ChannelWorks; + u32 maxAjmAtrac9Decoders; + u32 maxCodecCaches; +}; + +struct OrbisNgs2CustomSubmixerRackOption { + OrbisNgs2CustomRackOption customRackOption; + + u32 maxChannels; + u32 maxInputs; +}; + +struct OrbisNgs2CustomMasteringRackOption { + OrbisNgs2CustomRackOption customRackOption; + + u32 maxChannels; + u32 maxInputs; +}; + +struct OrbisNgs2CustomSamplerVoiceSetupParam { + OrbisNgs2VoiceParamHeader header; + OrbisNgs2WaveformFormat format; + u32 flags; + u32 reserved; +}; + +struct OrbisNgs2CustomSamplerVoiceWaveformBlocksParam { + OrbisNgs2VoiceParamHeader header; + const void* data; + u32 flags; + u32 numBlocks; + const OrbisNgs2WaveformBlock* aBlock; +}; + +struct OrbisNgs2CustomSamplerVoiceWaveformAddressParam { + OrbisNgs2VoiceParamHeader header; + const void* from; + const void* to; +}; + +struct OrbisNgs2CustomSamplerVoiceWaveformFrameOffsetParam { + OrbisNgs2VoiceParamHeader header; + u32 frameOffset; + u32 reserved; +}; + +struct OrbisNgs2CustomSamplerVoiceExitLoopParam { + OrbisNgs2VoiceParamHeader header; +}; + +struct OrbisNgs2CustomSamplerVoicePitchParam { + OrbisNgs2VoiceParamHeader header; + float ratio; + u32 reserved; +}; + +struct OrbisNgs2CustomSamplerVoiceState { + OrbisNgs2VoiceState voiceState; + char padding[32]; + const void* waveformData; + u64 numDecodedSamples; + u64 decodedDataSize; + u64 userData; + u32 reserved; + u32 reserved2; +}; + +struct OrbisNgs2CustomSubmixerVoiceSetupParam { + OrbisNgs2VoiceParamHeader header; + u32 numInputChannels; + u32 numOutputChannels; + u32 flags; + u32 reserved; +}; + +struct OrbisNgs2CustomSubmixerVoiceState { + OrbisNgs2VoiceState voiceState; // Voice state + u32 reserved; + u32 reserved2; +}; + +struct OrbisNgs2CustomMasteringVoiceSetupParam { + OrbisNgs2VoiceParamHeader header; + u32 numInputChannels; + u32 flags; +}; + +struct OrbisNgs2CustomMasteringVoiceOutputParam { + OrbisNgs2VoiceParamHeader header; + u32 outputId; + u32 reserved; +}; + +struct OrbisNgs2CustomMasteringVoiceState { + OrbisNgs2VoiceState voiceState; + u32 reserved; + u32 reserved2; +}; + +struct OrbisNgs2CustomVoiceEnvelopeParam { + OrbisNgs2VoiceParamHeader header; + u32 numForwardPoints; + u32 numReleasePoints; + const OrbisNgs2EnvelopePoint* aPoint; +}; + +struct OrbisNgs2CustomVoiceDistortionParam { + OrbisNgs2VoiceParamHeader header; + u32 flags; + float a; + float b; + float clip; + float gate; + float wetLevel; + float dryLevel; + u32 reserved; +}; + +struct OrbisNgs2CustomVoiceCompressorParam { + OrbisNgs2VoiceParamHeader header; + u32 flags; + float threshold; + float ratio; + float knee; + float attackTime; + float releaseTime; + float level; + u32 reserved; +}; + +struct OrbisNgs2CustomVoiceFilterParam { + OrbisNgs2VoiceParamHeader header; + u32 type; + u32 channelMask; + union { + struct { + float i0; + float i1; + float i2; + float o1; + float o2; + } direct; + struct { + float fc; + float q; + float level; + u32 reserved; + u32 reserved2; + } fcq; + } param; + u32 reserved3; +}; + +struct OrbisNgs2CustomVoiceLfeFilterParam { + OrbisNgs2VoiceParamHeader header; + u32 enableFlag; + u32 fc; +}; + +struct OrbisNgs2CustomVoiceGainParam { + OrbisNgs2VoiceParamHeader header; + float aLevel[ORBIS_NGS2_MAX_VOICE_CHANNELS]; +}; + +struct OrbisNgs2CustomVoiceMixerParam { + OrbisNgs2VoiceParamHeader header; + float aSourceLevel[ORBIS_NGS2_MAX_VOICE_CHANNELS]; + float aDestLevel[ORBIS_NGS2_MAX_VOICE_CHANNELS]; +}; + +struct OrbisNgs2CustomVoiceChannelMixerParam { + OrbisNgs2VoiceParamHeader header; + float aLevel[ORBIS_NGS2_MAX_VOICE_CHANNELS][ORBIS_NGS2_MAX_VOICE_CHANNELS]; +}; + +struct OrbisNgs2CustomVoiceUserFxParam { + OrbisNgs2VoiceParamHeader header; + OrbisNgs2UserFxProcessHandler handler; + + uintptr_t userData0; + uintptr_t userData1; + uintptr_t userData2; +}; + +struct OrbisNgs2CustomVoiceUserFx2Param { + OrbisNgs2VoiceParamHeader header; + const void* data; + size_t dataSize; +}; + +struct OrbisNgs2CustomVoiceOutputParam { + OrbisNgs2VoiceParamHeader header; + u32 outputId; + u32 reserved; +}; + +struct OrbisNgs2CustomVoicePeakMeterParam { + OrbisNgs2VoiceParamHeader header; + u32 enableFlag; + u32 reserved; +} OrbisNgs2CustomVoicePeakMeterParam; + +struct OrbisNgs2CustomVoiceReverbParam { + OrbisNgs2VoiceParamHeader header; + OrbisNgs2ReverbI3DL2Param i3dl2; +}; + +struct OrbisNgs2CustomVoiceChorusParam { + OrbisNgs2VoiceParamHeader header; + u32 flags; + u32 numPhases; + u32 channelMask; + float inputLevel; + float delayTime; + float modulationRatio; + float modulationDepth; + float feedbackLevel; + float wetLevel; + float dryLevel; +}; + +struct OrbisNgs2DelayTapInfo { + float tapLevel; + float delayTime; +}; + +struct OrbisNgs2CustomVoiceDelayParam { + OrbisNgs2VoiceParamHeader header; + float dryLevel; + float wetLevel; + float inputLevel; + float feedbackLevel; + float lowpassFc; + u32 numTaps; + OrbisNgs2DelayTapInfo aTap[ORBIS_NGS2_CUSTOM_DELAY_MAX_TAPS]; + float aInputMixLevel[ORBIS_NGS2_MAX_VOICE_CHANNELS]; + u32 channelMask; + u32 flags; +}; + +struct OrbisNgs2CustomVoiceNoiseGateParam { + OrbisNgs2VoiceParamHeader header; + u32 flags; + float threshold; + float attackTime; + float releaseTime; +}; + +struct OrbisNgs2CustomVoicePitchShiftParam { + OrbisNgs2VoiceParamHeader header; + s32 cent; +}; + +struct OrbisNgs2CustomEnvelopeModuleState { + float height; + u32 reserved; +}; + +struct OrbisNgs2CustomCompressorModuleState { + float peakHeight; + float compressorHeight; +}; + +struct OrbisNgs2CustomPeakMeterModuleState { + float peak; + float aChannelPeak[ORBIS_NGS2_MAX_VOICE_CHANNELS]; + u32 reserved; +}; + +struct OrbisNgs2CustomNoiseGateModuleState { + float gateHeight; +}; + +struct OrbisNgs2CustomRackInfo { + OrbisNgs2RackInfo rackInfo; + u32 stateSize; + u32 numBuffers; + u32 numModules; + u32 reserved; + OrbisNgs2CustomRackModuleInfo aModule[ORBIS_NGS2_CUSTOM_MAX_MODULES]; + OrbisNgs2CustomRackPortInfo aPort[ORBIS_NGS2_CUSTOM_MAX_PORTS]; +}; + +struct OrbisNgs2CustomSamplerRackInfo { + OrbisNgs2CustomRackInfo customRackInfo; + + u32 maxChannelWorks; + u32 maxWaveformBlocks; + u32 maxAtrac9Decoders; + u32 maxAtrac9ChannelWorks; + u32 maxAjmAtrac9Decoders; + u32 maxCodecCaches; +}; + +struct OrbisNgs2CustomSubmixerRackInfo { + OrbisNgs2CustomRackInfo customRackInfo; + + u32 maxChannels; + u32 maxInputs; +}; + +struct OrbisNgs2CustomMasteringRackInfo { + OrbisNgs2CustomRackInfo customRackInfo; + + u32 maxChannels; + u32 maxInputs; +}; + +struct OrbisNgs2CustomModuleInfo { + u32 moduleId; + u32 sourceBufferId; + u32 extraBufferId; + u32 destBufferId; + u32 stateOffset; + u32 stateSize; + u32 reserved; + u32 reserved2; +}; + +struct OrbisNgs2CustomEnvelopeModuleInfo { + OrbisNgs2CustomModuleInfo moduleInfo; + + u32 maxPoints; + u32 reserved; +}; + +struct OrbisNgs2CustomReverbModuleInfo { + OrbisNgs2CustomModuleInfo moduleInfo; + + u32 reverbSize; + u32 reserved; +}; + +} // namespace Libraries::Ngs2 diff --git a/src/core/libraries/ngs2/ngs2_eq.cpp b/src/core/libraries/ngs2/ngs2_eq.cpp new file mode 100644 index 000000000..8c82e4e49 --- /dev/null +++ b/src/core/libraries/ngs2/ngs2_eq.cpp @@ -0,0 +1,12 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "ngs2_error.h" +#include "ngs2_impl.h" + +#include "common/logging/log.h" +#include "core/libraries/error_codes.h" + +using namespace Libraries::Kernel; + +namespace Libraries::Ngs2 {} // namespace Libraries::Ngs2 diff --git a/src/core/libraries/ngs2/ngs2_eq.h b/src/core/libraries/ngs2/ngs2_eq.h new file mode 100644 index 000000000..99688f24e --- /dev/null +++ b/src/core/libraries/ngs2/ngs2_eq.h @@ -0,0 +1,41 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "ngs2.h" + +namespace Libraries::Ngs2 { + +class Ngs2Eq; + +struct OrbisNgs2EqVoiceSetupParam { + u32 numChannels; +}; + +struct OrbisNgs2EqVoiceFilterParam { + u32 type; + u32 channelMask; + union { + struct { + float i0; + float i1; + float i2; + float o1; + float o2; + } direct; + struct { + float fc; + float q; + float level; + u32 reserved; + u32 reserved2; + } fcq; + } param; +}; + +struct OrbisNgs2EqVoiceState { + u32 stateFlags; +}; + +} // namespace Libraries::Ngs2 diff --git a/src/core/libraries/ngs2/ngs2_geom.cpp b/src/core/libraries/ngs2/ngs2_geom.cpp new file mode 100644 index 000000000..8c82e4e49 --- /dev/null +++ b/src/core/libraries/ngs2/ngs2_geom.cpp @@ -0,0 +1,12 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "ngs2_error.h" +#include "ngs2_impl.h" + +#include "common/logging/log.h" +#include "core/libraries/error_codes.h" + +using namespace Libraries::Kernel; + +namespace Libraries::Ngs2 {} // namespace Libraries::Ngs2 diff --git a/src/core/libraries/ngs2/ngs2_geom.h b/src/core/libraries/ngs2/ngs2_geom.h new file mode 100644 index 000000000..93af99d8d --- /dev/null +++ b/src/core/libraries/ngs2/ngs2_geom.h @@ -0,0 +1,80 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "ngs2.h" + +namespace Libraries::Ngs2 { + +class Ngs2Geom; + +struct OrbisNgs2GeomVector { + float x; + float y; + float z; +}; + +struct OrbisNgs2GeomCone { + float innerLevel; + float innerAngle; + float outerLevel; + float outerAngle; +}; + +struct OrbisNgs2GeomRolloff { + u32 model; + float maxDistance; + float rolloffFactor; + float referenceDistance; +}; + +struct OrbisNgs2GeomListenerParam { + OrbisNgs2GeomVector position; + OrbisNgs2GeomVector orientFront; + OrbisNgs2GeomVector orientUp; + OrbisNgs2GeomVector velocity; + float soundSpeed; + u32 reserved[2]; +}; + +struct OrbisNgs2GeomListenerWork { + float matrix[4][4]; + OrbisNgs2GeomVector velocity; + float soundSpeed; + u32 coordinate; + u32 reserved[3]; +}; + +struct OrbisNgs2GeomSourceParam { + OrbisNgs2GeomVector position; + OrbisNgs2GeomVector velocity; + OrbisNgs2GeomVector direction; + OrbisNgs2GeomCone cone; + OrbisNgs2GeomRolloff rolloff; + float dopplerFactor; + float fbwLevel; + float lfeLevel; + float maxLevel; + float minLevel; + float radius; + u32 numSpeakers; + u32 matrixFormat; + u32 reserved[2]; +}; + +struct OrbisNgs2GeomA3dAttribute { + OrbisNgs2GeomVector position; + float volume; + u32 reserved[4]; +}; + +struct OrbisNgs2GeomAttribute { + float pitchRatio; + float aLevel[ORBIS_NGS2_MAX_VOICE_CHANNELS * ORBIS_NGS2_MAX_VOICE_CHANNELS]; + + OrbisNgs2GeomA3dAttribute a3dAttrib; + u32 reserved[4]; +}; + +} // namespace Libraries::Ngs2 diff --git a/src/core/libraries/ngs2/ngs2_impl.cpp b/src/core/libraries/ngs2/ngs2_impl.cpp index b358a05f7..1248f76d7 100644 --- a/src/core/libraries/ngs2/ngs2_impl.cpp +++ b/src/core/libraries/ngs2/ngs2_impl.cpp @@ -12,153 +12,171 @@ using namespace Libraries::Kernel; namespace Libraries::Ngs2 { -s32 Ngs2::ReportInvalid(Ngs2Handle* handle, u32 handle_type) const { - uintptr_t hAddress = reinterpret_cast(handle); - switch (handle_type) { +s32 HandleReportInvalid(OrbisNgs2Handle handle, u32 handleType) { + switch (handleType) { case 1: - LOG_ERROR(Lib_Ngs2, "Invalid system handle {}", hAddress); + LOG_ERROR(Lib_Ngs2, "Invalid system handle {}", handle); return ORBIS_NGS2_ERROR_INVALID_SYSTEM_HANDLE; case 2: - LOG_ERROR(Lib_Ngs2, "Invalid rack handle {}", hAddress); + LOG_ERROR(Lib_Ngs2, "Invalid rack handle {}", handle); return ORBIS_NGS2_ERROR_INVALID_RACK_HANDLE; case 4: - LOG_ERROR(Lib_Ngs2, "Invalid voice handle {}", hAddress); + LOG_ERROR(Lib_Ngs2, "Invalid voice handle {}", handle); return ORBIS_NGS2_ERROR_INVALID_VOICE_HANDLE; case 8: - LOG_ERROR(Lib_Ngs2, "Invalid report handle {}", hAddress); + LOG_ERROR(Lib_Ngs2, "Invalid report handle {}", handle); return ORBIS_NGS2_ERROR_INVALID_REPORT_HANDLE; default: - LOG_ERROR(Lib_Ngs2, "Invalid handle {}", hAddress); + LOG_ERROR(Lib_Ngs2, "Invalid handle {}", handle); return ORBIS_NGS2_ERROR_INVALID_HANDLE; } } -s32 Ngs2::HandleSetup(Ngs2Handle* handle, void* data, std::atomic* atomic, u32 type, - u32 flags) { - handle->dataPointer = data; - handle->atomicPtr = atomic; - handle->handleType = type; - handle->flags_unk = flags; - return ORBIS_OK; +void* MemoryClear(void* buffer, size_t size) { + return memset(buffer, 0, size); } -s32 Ngs2::HandleCleanup(Ngs2Handle* handle, u32 hType, void* dataOut) { - if (handle && handle->selfPointer == handle) { - std::atomic* tmp_atomic = handle->atomicPtr; - if (tmp_atomic && handle->handleType == hType) { - while (tmp_atomic->load() != 0) { - u32 expected = 1; - if (tmp_atomic->compare_exchange_strong(expected, 0)) { - if (dataOut) { - dataOut = handle->dataPointer; - } - // sceNgs2MemoryClear(handle, 32); - return ORBIS_OK; - } - tmp_atomic = handle->atomicPtr; - } - } - } - return this->ReportInvalid(handle, hType); -} - -s32 Ngs2::HandleEnter(Ngs2Handle* handle, u32 hType, Ngs2Handle* handleOut) { - if (!handle) { - return this->ReportInvalid(handle, 0); - } - - if (handle->selfPointer != handle || !handle->atomicPtr || !handle->dataPointer || - (~hType & handle->handleType)) { - return this->ReportInvalid(handle, handle->handleType); - } - - std::atomic* atomic = handle->atomicPtr; - while (true) { - u32 i = atomic->load(); - if (i == 0) { - return this->ReportInvalid(handle, handle->handleType); - } - if (atomic->compare_exchange_strong(i, i + 1)) { - break; - } - } - - if (handleOut) { - handleOut = handle; +s32 StackBufferClose(StackBuffer* stackBuffer, size_t* outTotalSize) { + if (outTotalSize) { + *outTotalSize = stackBuffer->usedSize + stackBuffer->alignment; } return ORBIS_OK; } -s32 Ngs2::HandleLeave(Ngs2Handle* handle) { - std::atomic* tmp_atomic; - u32 i; - do { - tmp_atomic = handle->atomicPtr; - i = tmp_atomic->load(); - } while (!tmp_atomic->compare_exchange_strong(i, i - 1)); - return ORBIS_OK; -} +s32 StackBufferOpen(StackBuffer* stackBuffer, void* bufferStart, size_t bufferSize, + void** outBuffer, u8 flags) { + stackBuffer->top = outBuffer; + stackBuffer->base = bufferStart; + stackBuffer->size = (size_t)bufferStart; + stackBuffer->currentOffset = (size_t)bufferStart; + stackBuffer->usedSize = 0; + stackBuffer->totalSize = bufferSize; + stackBuffer->alignment = 8; // this is a fixed value + stackBuffer->flags = flags; -s32 Ngs2::StackBufferOpen(StackBuffer* buf, void* base_addr, size_t size, void** stackTop, - bool verify) { - buf->top = stackTop; - buf->base = base_addr; - buf->curr = base_addr; - buf->usedSize = 0; - buf->totalSize = size; - buf->alignment = 8; - buf->isVerifyEnabled = verify; - - if (stackTop) { - *stackTop = nullptr; + if (outBuffer != NULL) { + *outBuffer = NULL; } return ORBIS_OK; } -s32 Ngs2::StackBufferClose(StackBuffer* buf, size_t* usedSize) { - if (usedSize) { - *usedSize = buf->usedSize + buf->alignment; +s32 SystemCleanup(OrbisNgs2Handle systemHandle, OrbisNgs2ContextBufferInfo* outInfo) { + if (!systemHandle) { + return ORBIS_NGS2_ERROR_INVALID_HANDLE; } + // TODO + return ORBIS_OK; } -s32 Ngs2::SystemSetupCore(StackBuffer* buf, SystemOptions* options, Ngs2Handle** sysOut) { +s32 SystemSetupCore(StackBuffer* stackBuffer, const OrbisNgs2SystemOption* option, + SystemInternal* outSystem) { u32 maxGrainSamples = 512; u32 numGrainSamples = 256; u32 sampleRate = 48000; - if (options) { - maxGrainSamples = options->maxGrainSamples; - numGrainSamples = options->numGrainSamples; - sampleRate = options->sampleRate; + if (option) { + sampleRate = option->sampleRate; + maxGrainSamples = option->maxGrainSamples; + numGrainSamples = option->numGrainSamples; } - // Validate maxGrainSamples - if (maxGrainSamples < 64 || maxGrainSamples > 1024 || (maxGrainSamples & 0x3F) != 0) { + if (maxGrainSamples < 64 || maxGrainSamples > 1024 || (maxGrainSamples & 63) != 0) { LOG_ERROR(Lib_Ngs2, "Invalid system option (maxGrainSamples={},x64)", maxGrainSamples); return ORBIS_NGS2_ERROR_INVALID_MAX_GRAIN_SAMPLES; } - // Validate numGrainSamples - if (numGrainSamples < 64 || numGrainSamples > 1024 || (numGrainSamples & 0x3F) != 0) { + if (numGrainSamples < 64 || numGrainSamples > 1024 || (numGrainSamples & 63) != 0) { LOG_ERROR(Lib_Ngs2, "Invalid system option (numGrainSamples={},x64)", numGrainSamples); return ORBIS_NGS2_ERROR_INVALID_NUM_GRAIN_SAMPLES; } - // Validate sampleRate if (sampleRate != 11025 && sampleRate != 12000 && sampleRate != 22050 && sampleRate != 24000 && - sampleRate != 44100 && sampleRate != 48000 && sampleRate != 88200 && sampleRate != 96000) { + sampleRate != 44100 && sampleRate != 48000 && sampleRate != 88200 && sampleRate != 96000 && + sampleRate != 176400 && sampleRate != 192000) { LOG_ERROR(Lib_Ngs2, "Invalid system option(sampleRate={}:44.1/48kHz series)", sampleRate); return ORBIS_NGS2_ERROR_INVALID_SAMPLE_RATE; } - int result = ORBIS_OK; + return ORBIS_OK; +} +s32 SystemSetup(const OrbisNgs2SystemOption* option, OrbisNgs2ContextBufferInfo* hostBufferInfo, + OrbisNgs2BufferFreeHandler hostFree, OrbisNgs2Handle* outHandle) { + u8 optionFlags = 0; + StackBuffer stackBuffer; + SystemInternal setupResult; + void* systemList = NULL; + size_t requiredBufferSize = 0; + u32 result = ORBIS_NGS2_ERROR_INVALID_BUFFER_SIZE; + + if (option) { + if (option->size != 64) { + LOG_ERROR(Lib_Ngs2, "Invalid system option size ({})", option->size); + return ORBIS_NGS2_ERROR_INVALID_OPTION_SIZE; + } + optionFlags = option->flags >> 31; + } + + // Init + StackBufferOpen(&stackBuffer, NULL, 0, NULL, optionFlags); + result = SystemSetupCore(&stackBuffer, option, 0); + + if (result < 0) { + return result; + } + + StackBufferClose(&stackBuffer, &requiredBufferSize); + + // outHandle unprovided + if (!outHandle) { + hostBufferInfo->hostBuffer = NULL; + hostBufferInfo->hostBufferSize = requiredBufferSize; + MemoryClear(&hostBufferInfo->reserved, sizeof(hostBufferInfo->reserved)); + return ORBIS_OK; + } + + if (!hostBufferInfo->hostBuffer) { + LOG_ERROR(Lib_Ngs2, "Invalid system buffer address ({})", hostBufferInfo->hostBuffer); + return ORBIS_NGS2_ERROR_INVALID_BUFFER_ADDRESS; + } + + if (hostBufferInfo->hostBufferSize < requiredBufferSize) { + LOG_ERROR(Lib_Ngs2, "Invalid system buffer size ({}<{}[byte])", + hostBufferInfo->hostBufferSize, requiredBufferSize); + return ORBIS_NGS2_ERROR_INVALID_BUFFER_SIZE; + } + + // Setup + StackBufferOpen(&stackBuffer, hostBufferInfo->hostBuffer, hostBufferInfo->hostBufferSize, + &systemList, optionFlags); + result = SystemSetupCore(&stackBuffer, option, &setupResult); + + if (result < 0) { + return result; + } + + StackBufferClose(&stackBuffer, &requiredBufferSize); + + // Copy buffer results + setupResult.bufferInfo = *hostBufferInfo; + setupResult.hostFree = hostFree; // TODO + // setupResult.systemList = systemList; - return result; // Success + OrbisNgs2Handle systemHandle = setupResult.systemHandle; + if (hostBufferInfo->hostBufferSize >= requiredBufferSize) { + *outHandle = systemHandle; + return ORBIS_OK; + } + + SystemCleanup(systemHandle, 0); + + LOG_ERROR(Lib_Ngs2, "Invalid system buffer size ({}<{}[byte])", hostBufferInfo->hostBufferSize, + requiredBufferSize); + return ORBIS_NGS2_ERROR_INVALID_BUFFER_SIZE; } } // namespace Libraries::Ngs2 diff --git a/src/core/libraries/ngs2/ngs2_impl.h b/src/core/libraries/ngs2/ngs2_impl.h index fea87c51c..a433e84fd 100644 --- a/src/core/libraries/ngs2/ngs2_impl.h +++ b/src/core/libraries/ngs2/ngs2_impl.h @@ -3,23 +3,177 @@ #pragma once -#include "ngs2.h" +#include "core/libraries/kernel/threads/pthread.h" namespace Libraries::Ngs2 { -class Ngs2 { -public: - s32 ReportInvalid(Ngs2Handle* handle, u32 handle_type) const; - s32 HandleSetup(Ngs2Handle* handle, void* data, std::atomic* atomic, u32 type, u32 flags); - s32 HandleCleanup(Ngs2Handle* handle, u32 hType, void* dataOut); - s32 HandleEnter(Ngs2Handle* handle, u32 hType, Ngs2Handle* handleOut); - s32 HandleLeave(Ngs2Handle* handle); - s32 StackBufferOpen(StackBuffer* buf, void* base_addr, size_t size, void** stackTop, - bool verify); - s32 StackBufferClose(StackBuffer* buf, size_t* usedSize); - s32 SystemSetupCore(StackBuffer* buf, SystemOptions* options, Ngs2Handle** sysOut); +static const int ORBIS_NGS2_SYSTEM_NAME_LENGTH = 16; +static const int ORBIS_NGS2_RACK_NAME_LENGTH = 16; -private: +typedef uintptr_t OrbisNgs2Handle; + +struct OrbisNgs2ContextBufferInfo { + void* hostBuffer; + size_t hostBufferSize; + uintptr_t reserved[5]; + uintptr_t userData; }; +struct OrbisNgs2SystemOption { + size_t size; + char name[ORBIS_NGS2_SYSTEM_NAME_LENGTH]; + + u32 flags; + u32 maxGrainSamples; + u32 numGrainSamples; + u32 sampleRate; + u32 aReserved[6]; +}; + +using OrbisNgs2BufferAllocHandler = + s32 PS4_SYSV_ABI (*)(OrbisNgs2ContextBufferInfo* io_buffer_info); +using OrbisNgs2BufferFreeHandler = s32 PS4_SYSV_ABI (*)(OrbisNgs2ContextBufferInfo* io_buffer_info); + +struct OrbisNgs2SystemInfo { + char name[ORBIS_NGS2_SYSTEM_NAME_LENGTH]; // 0 + + OrbisNgs2Handle systemHandle; // 16 + OrbisNgs2ContextBufferInfo bufferInfo; // 24 + + u32 uid; // 88 + u32 minGrainSamples; // 92 + u32 maxGrainSamples; // 96 + + u32 stateFlags; // 100 + u32 rackCount; // 104 + float lastRenderRatio; // 108 + s64 lastRenderTick; // 112 + s64 renderCount; // 120 + u32 sampleRate; // 128 + u32 numGrainSamples; // 132 +}; + +struct OrbisNgs2RackInfo { + char name[ORBIS_NGS2_RACK_NAME_LENGTH]; // 0 + + OrbisNgs2Handle rackHandle; // 16 + OrbisNgs2ContextBufferInfo bufferInfo; // 24 + + OrbisNgs2Handle ownerSystemHandle; // 88 + + u32 type; // 96 + u32 rackId; // 100 + u32 uid; // 104 + u32 minGrainSamples; // 108 + u32 maxGrainSamples; // 112 + u32 maxVoices; // 116 + u32 maxChannelWorks; // 120 + u32 maxInputs; // 124 + u32 maxMatrices; // 128 + u32 maxPorts; // 132 + + u32 stateFlags; // 136 + float lastProcessRatio; // 140 + u64 lastProcessTick; // 144 + u64 renderCount; // 152 + u32 activeVoiceCount; // 160 + u32 activeChannelWorkCount; // 164 +}; + +struct StackBuffer { + void** top; + void* base; + size_t size; + size_t currentOffset; + size_t usedSize; + size_t totalSize; + size_t alignment; + u8 flags; + char padding[7]; +}; + +struct SystemInternal { + // setup init + char name[ORBIS_NGS2_SYSTEM_NAME_LENGTH]; // 0 + OrbisNgs2ContextBufferInfo bufferInfo; // 16 + OrbisNgs2BufferFreeHandler hostFree; // 80 + OrbisNgs2Handle systemHandle; // 88 + void* unknown1; // 96 + void* unknown2; // 104 + OrbisNgs2Handle rackHandle; // 112 + uintptr_t* userData; // 120 + SystemInternal* systemList; // 128 + StackBuffer* stackBuffer; // 136 + OrbisNgs2SystemInfo ownerSystemInfo; // 144 + + struct rackList { + void* prev; + void* next; + void* unknown; + }; + + rackList rackListPreset; // 152 + rackList rackListNormal; // 176 + rackList rackListMaster; // 200 + + void* unknown3; // 208 + void* systemListPrev; // 216 + void* unknown4; // 224 + void* systemListNext; // 232 + void* rackFunction; // 240 + + Kernel::PthreadMutex processLock; // 248 + u32 hasProcessMutex; // 256 + u32 unknown5; // 260 + Kernel::PthreadMutex flushLock; // 264 + u32 hasFlushMutex; // 272 + u32 unknown6; // 276 + + // info + u64 lastRenderTick; // 280 + u64 renderCount; // 288 + u32 isActive; // 296 + std::atomic lockCount; // 300 + u32 uid; // 304 + u32 systemType; // 308 + + struct { + u8 isBufferValid : 1; + u8 isRendering : 1; + u8 isSorted : 1; + u8 isFlushReady : 1; + } flags; // 312 + + u16 currentMaxGrainSamples; // 316 + u16 minGrainSamples; // 318 + u16 maxGrainSamples; // 320 + u16 numGrainSamples; // 322 + u32 currentNumGrainSamples; // 324 + u32 sampleRate; // 328 + u32 currentSampleRate; // 332 + u32 rackCount; // 336 + float lastRenderRatio; // 340 + float cpuLoad; // 344 +}; + +struct HandleInternal { + HandleInternal* selfPtr; // 0 + SystemInternal* systemData; // 8 + std::atomic refCount; // 16 + u32 handleType; // 24 + u32 handleID; // 28 +}; + +s32 StackBufferClose(StackBuffer* stackBuffer, size_t* outTotalSize); +s32 StackBufferOpen(StackBuffer* stackBuffer, void* buffer, size_t bufferSize, void** outBuffer, + u8 flags); +s32 SystemSetupCore(StackBuffer* stackBuffer, const OrbisNgs2SystemOption* option, + SystemInternal* outSystem); + +s32 HandleReportInvalid(OrbisNgs2Handle handle, u32 handleType); +void* MemoryClear(void* buffer, size_t size); +s32 SystemCleanup(OrbisNgs2Handle systemHandle, OrbisNgs2ContextBufferInfo* outInfo); +s32 SystemSetup(const OrbisNgs2SystemOption* option, OrbisNgs2ContextBufferInfo* hostBufferInfo, + OrbisNgs2BufferFreeHandler hostFree, OrbisNgs2Handle* outHandle); + } // namespace Libraries::Ngs2 diff --git a/src/core/libraries/ngs2/ngs2_mastering.cpp b/src/core/libraries/ngs2/ngs2_mastering.cpp new file mode 100644 index 000000000..8c82e4e49 --- /dev/null +++ b/src/core/libraries/ngs2/ngs2_mastering.cpp @@ -0,0 +1,12 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "ngs2_error.h" +#include "ngs2_impl.h" + +#include "common/logging/log.h" +#include "core/libraries/error_codes.h" + +using namespace Libraries::Kernel; + +namespace Libraries::Ngs2 {} // namespace Libraries::Ngs2 diff --git a/src/core/libraries/ngs2/ngs2_mastering.h b/src/core/libraries/ngs2/ngs2_mastering.h new file mode 100644 index 000000000..e0ba478c3 --- /dev/null +++ b/src/core/libraries/ngs2/ngs2_mastering.h @@ -0,0 +1,81 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "ngs2.h" + +namespace Libraries::Ngs2 { + +class Ngs2Mastering; + +struct OrbisNgs2MasteringRackOption { + OrbisNgs2RackOption rackOption; + u32 maxChannels; + u32 numPeakMeterBlocks; +}; + +struct OrbisNgs2MasteringVoiceSetupParam { + OrbisNgs2VoiceParamHeader header; + + u32 numInputChannels; + u32 flags; +}; + +struct OrbisNgs2MasteringVoiceMatrixParam { + OrbisNgs2VoiceParamHeader header; + + u32 type; + u32 numLevels; + const float* aLevel; +}; + +struct OrbisNgs2MasteringVoiceLfeParam { + OrbisNgs2VoiceParamHeader header; + + u32 enableFlag; + u32 fc; +}; + +struct OrbisNgs2MasteringVoiceLimiterParam { + OrbisNgs2VoiceParamHeader header; + + u32 enableFlag; + float threshold; +}; + +struct OrbisNgs2MasteringVoiceGainParam { + OrbisNgs2VoiceParamHeader header; + + float fbwLevel; + float lfeLevel; +}; + +struct OrbisNgs2MasteringVoiceOutputParam { + OrbisNgs2VoiceParamHeader header; + + u32 outputId; + u32 reserved; +}; + +struct OrbisNgs2MasteringVoicePeakMeterParam { + OrbisNgs2VoiceParamHeader header; + u32 enableFlag; + u32 reserved; +}; + +struct OrbisNgs2MasteringVoiceState { + OrbisNgs2VoiceState voiceState; + float limiterPeakLevel; + float limiterPressLevel; + float aInputPeakHeight[ORBIS_NGS2_MAX_VOICE_CHANNELS]; + float aOutputPeakHeight[ORBIS_NGS2_MAX_VOICE_CHANNELS]; +}; + +struct OrbisNgs2MasteringRackInfo { + OrbisNgs2RackInfo rackInfo; + u32 maxChannels; + u32 reserved; +}; + +} // namespace Libraries::Ngs2 diff --git a/src/core/libraries/ngs2/ngs2_pan.cpp b/src/core/libraries/ngs2/ngs2_pan.cpp new file mode 100644 index 000000000..8c82e4e49 --- /dev/null +++ b/src/core/libraries/ngs2/ngs2_pan.cpp @@ -0,0 +1,12 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "ngs2_error.h" +#include "ngs2_impl.h" + +#include "common/logging/log.h" +#include "core/libraries/error_codes.h" + +using namespace Libraries::Kernel; + +namespace Libraries::Ngs2 {} // namespace Libraries::Ngs2 diff --git a/src/core/libraries/ngs2/ngs2_pan.h b/src/core/libraries/ngs2/ngs2_pan.h new file mode 100644 index 000000000..d39ec67cd --- /dev/null +++ b/src/core/libraries/ngs2/ngs2_pan.h @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "ngs2.h" + +namespace Libraries::Ngs2 { + +class Ngs2Pan; + +struct OrbisNgs2PanParam { + float angle; + float distance; + float fbwLevel; + float lfeLevel; +}; + +struct OrbisNgs2PanWork { + float aSpeakerAngle[ORBIS_NGS2_MAX_VOICE_CHANNELS]; + float unitAngle; + u32 numSpeakers; +}; + +} // namespace Libraries::Ngs2 diff --git a/src/core/libraries/ngs2/ngs2_report.cpp b/src/core/libraries/ngs2/ngs2_report.cpp new file mode 100644 index 000000000..8c82e4e49 --- /dev/null +++ b/src/core/libraries/ngs2/ngs2_report.cpp @@ -0,0 +1,12 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "ngs2_error.h" +#include "ngs2_impl.h" + +#include "common/logging/log.h" +#include "core/libraries/error_codes.h" + +using namespace Libraries::Kernel; + +namespace Libraries::Ngs2 {} // namespace Libraries::Ngs2 diff --git a/src/core/libraries/ngs2/ngs2_report.h b/src/core/libraries/ngs2/ngs2_report.h new file mode 100644 index 000000000..0f46f5081 --- /dev/null +++ b/src/core/libraries/ngs2/ngs2_report.h @@ -0,0 +1,79 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "ngs2.h" + +#include // va_list + +namespace Libraries::Ngs2 { + +class Ngs2Report; + +struct OrbisNgs2ReportDataHeader { + size_t size; + OrbisNgs2Handle handle; + u32 type; + s32 result; +}; + +using OrbisNgs2ReportHandler = void PS4_SYSV_ABI (*)(const OrbisNgs2ReportDataHeader* data, + uintptr_t user_data); + +struct OrbisNgs2ReportMessageData { + OrbisNgs2ReportDataHeader header; + const char* message; +}; + +struct OrbisNgs2ReportApiData { + OrbisNgs2ReportDataHeader header; + const char* functionName; + const char* format; + va_list argument; +}; + +struct OrbisNgs2ReportControlData { + OrbisNgs2ReportDataHeader header; + const OrbisNgs2VoiceParamHeader* param; +}; + +struct OrbisNgs2ReportOutputData { + OrbisNgs2ReportDataHeader header; + const OrbisNgs2RenderBufferInfo* bufferInfo; + + u32 bufferIndex; + u32 sampleRate; + u32 numGrainSamples; + u32 reserved; +}; + +struct OrbisNgs2ReportCpuLoadData { + OrbisNgs2ReportDataHeader header; + float totalRatio; + float flushRatio; + float processRatio; + float feedbackRatio; +}; + +struct OrbisNgs2ReportRenderStateData { + OrbisNgs2ReportDataHeader header; + u32 state; + u32 reserved; +}; + +struct OrbisNgs2ReportVoiceWaveformData { + OrbisNgs2ReportDataHeader header; + u32 location; + u32 waveformType; + u32 numChannels; + u32 sampleRate; + u32 numGrainSamples; + u32 reserved; + void* const* aData; +}; + +s32 PS4_SYSV_ABI sceNgs2ReportRegisterHandler(u32 reportType, OrbisNgs2ReportHandler handler, + uintptr_t userData, OrbisNgs2Handle* outHandle); + +} // namespace Libraries::Ngs2 diff --git a/src/core/libraries/ngs2/ngs2_reverb.cpp b/src/core/libraries/ngs2/ngs2_reverb.cpp new file mode 100644 index 000000000..8c82e4e49 --- /dev/null +++ b/src/core/libraries/ngs2/ngs2_reverb.cpp @@ -0,0 +1,12 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "ngs2_error.h" +#include "ngs2_impl.h" + +#include "common/logging/log.h" +#include "core/libraries/error_codes.h" + +using namespace Libraries::Kernel; + +namespace Libraries::Ngs2 {} // namespace Libraries::Ngs2 diff --git a/src/core/libraries/ngs2/ngs2_reverb.h b/src/core/libraries/ngs2/ngs2_reverb.h new file mode 100644 index 000000000..715d7480a --- /dev/null +++ b/src/core/libraries/ngs2/ngs2_reverb.h @@ -0,0 +1,61 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "ngs2.h" + +namespace Libraries::Ngs2 { + +class Ngs2Reverb; + +struct OrbisNgs2ReverbRackOption { + OrbisNgs2RackOption rackOption; + u32 maxChannels; + u32 reverbSize; +}; + +struct OrbisNgs2ReverbI3DL2Param { + float wet; + float dry; + s32 room; + s32 roomHF; + u32 reflectionPattern; + float decayTime; + float decayHFRatio; + s32 reflections; + float reflectionsDelay; + s32 reverb; + float reverbDelay; + float diffusion; + float density; + float HFReference; + u32 reserve[8]; +}; + +struct OrbisNgs2ReverbVoiceSetupParam { + OrbisNgs2VoiceParamHeader header; + + u32 numInputChannels; + u32 numOutputChannels; + u32 flags; + u32 reserved; +}; + +struct OrbisNgs2ReverbVoiceI3DL2Param { + OrbisNgs2VoiceParamHeader header; + + OrbisNgs2ReverbI3DL2Param i3dl2; +}; + +struct OrbisNgs2ReverbVoiceState { + OrbisNgs2VoiceState voiceState; +}; + +struct OrbisNgs2ReverbRackInfo { + OrbisNgs2RackInfo rackInfo; + u32 maxChannels; + u32 reverbSize; +}; + +} // namespace Libraries::Ngs2 diff --git a/src/core/libraries/ngs2/ngs2_sampler.cpp b/src/core/libraries/ngs2/ngs2_sampler.cpp new file mode 100644 index 000000000..8c82e4e49 --- /dev/null +++ b/src/core/libraries/ngs2/ngs2_sampler.cpp @@ -0,0 +1,12 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "ngs2_error.h" +#include "ngs2_impl.h" + +#include "common/logging/log.h" +#include "core/libraries/error_codes.h" + +using namespace Libraries::Kernel; + +namespace Libraries::Ngs2 {} // namespace Libraries::Ngs2 diff --git a/src/core/libraries/ngs2/ngs2_sampler.h b/src/core/libraries/ngs2/ngs2_sampler.h new file mode 100644 index 000000000..0842b9cb2 --- /dev/null +++ b/src/core/libraries/ngs2/ngs2_sampler.h @@ -0,0 +1,162 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "ngs2.h" + +namespace Libraries::Ngs2 { + +class Ngs2Sampler; + +struct OrbisNgs2SamplerRackOption { + OrbisNgs2RackOption rackOption; + u32 maxChannelWorks; + u32 maxCodecCaches; + u32 maxWaveformBlocks; + u32 maxEnvelopePoints; + u32 maxFilters; + u32 maxAtrac9Decoders; + u32 maxAtrac9ChannelWorks; + u32 maxAjmAtrac9Decoders; + u32 numPeakMeterBlocks; +}; + +struct OrbisNgs2SamplerVoiceSetupParam { + OrbisNgs2VoiceParamHeader header; + + OrbisNgs2WaveformFormat format; + u32 flags; + u32 reserved; +}; + +struct OrbisNgs2SamplerVoiceWaveformBlocksParam { + OrbisNgs2VoiceParamHeader header; + + const void* data; + u32 flags; + u32 numBlocks; + const OrbisNgs2WaveformBlock* aBlock; + // Blocks +}; + +struct OrbisNgs2SamplerVoiceWaveformAddressParam { + OrbisNgs2VoiceParamHeader header; + + const void* from; + const void* to; +}; + +struct OrbisNgs2SamplerVoiceWaveformFrameOffsetParam { + OrbisNgs2VoiceParamHeader header; + + u32 frameOffset; + u32 reserved; +}; + +struct OrbisNgs2SamplerVoiceExitLoopParam { + OrbisNgs2VoiceParamHeader header; +}; + +struct OrbisNgs2SamplerVoicePitchParam { + OrbisNgs2VoiceParamHeader header; + + float ratio; + u32 reserved; +}; + +struct OrbisNgs2SamplerVoiceEnvelopeParam { + OrbisNgs2VoiceParamHeader header; + + u32 numForwardPoints; + u32 numReleasePoints; + const OrbisNgs2EnvelopePoint* aPoint; +}; + +struct OrbisNgs2SamplerVoiceDistortionParam { + OrbisNgs2VoiceParamHeader header; + + u32 flags; + float a; + float b; + float clip; + float gate; + float wetLevel; + float dryLevel; + u32 reserved; +}; + +struct OrbisNgs2SamplerVoiceUserFxParam { + OrbisNgs2VoiceParamHeader header; + + OrbisNgs2UserFxProcessHandler handler; + + uintptr_t userData0; + uintptr_t userData1; + uintptr_t userData2; +}; + +struct OrbisNgs2SamplerVoicePeakMeterParam { + OrbisNgs2VoiceParamHeader header; + + u32 enableFlag; + u32 reserved; +}; + +struct OrbisNgs2SamplerVoiceFilterParam { + OrbisNgs2VoiceParamHeader header; + + u32 index; + u32 location; + u32 type; + u32 channelMask; + union { + struct { + float i0; + float i1; + float i2; + float o1; + float o2; + } direct; + struct { + float fc; + float q; + float level; + u32 reserved; + u32 reserved2; + } fcq; + } param; + u32 reserved3; +}; + +struct OrbisNgs2SamplerVoiceNumFilters { + OrbisNgs2VoiceParamHeader header; + + u32 numFilters; + u32 reserved; +}; + +struct OrbisNgs2SamplerVoiceState { + OrbisNgs2VoiceState voiceState; + float envelopeHeight; + float peakHeight; + u32 reserved; + u64 numDecodedSamples; + u64 decodedDataSize; + u64 userData; + const void* waveformData; +}; + +struct OrbisNgs2SamplerRackInfo { + OrbisNgs2RackInfo rackInfo; + u32 maxChannelWorks; + u32 maxCodecCaches; + u32 maxWaveformBlocks; + u32 maxEnvelopePoints; + u32 maxFilters; + u32 maxAtrac9Decoders; + u32 maxAtrac9ChannelWorks; + u32 maxAjmAtrac9Decoders; +}; + +} // namespace Libraries::Ngs2 diff --git a/src/core/libraries/ngs2/ngs2_submixer.cpp b/src/core/libraries/ngs2/ngs2_submixer.cpp new file mode 100644 index 000000000..8c82e4e49 --- /dev/null +++ b/src/core/libraries/ngs2/ngs2_submixer.cpp @@ -0,0 +1,12 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "ngs2_error.h" +#include "ngs2_impl.h" + +#include "common/logging/log.h" +#include "core/libraries/error_codes.h" + +using namespace Libraries::Kernel; + +namespace Libraries::Ngs2 {} // namespace Libraries::Ngs2 diff --git a/src/core/libraries/ngs2/ngs2_submixer.h b/src/core/libraries/ngs2/ngs2_submixer.h new file mode 100644 index 000000000..df2d8a835 --- /dev/null +++ b/src/core/libraries/ngs2/ngs2_submixer.h @@ -0,0 +1,126 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "ngs2.h" + +namespace Libraries::Ngs2 { + +class Ngs2Submixer; + +struct OrbisNgs2SubmixerRackOption { + OrbisNgs2RackOption rackOption; + u32 maxChannels; + u32 maxEnvelopePoints; + u32 maxFilters; + u32 maxInputs; + u32 numPeakMeterBlocks; +}; + +struct OrbisNgs2SubmixerVoiceSetupParam { + OrbisNgs2VoiceParamHeader header; + u32 numIoChannels; + u32 flags; +}; + +struct OrbisNgs2SubmixerVoiceEnvelopeParam { + OrbisNgs2VoiceParamHeader header; + + u32 numForwardPoints; + u32 numReleasePoints; + const OrbisNgs2EnvelopePoint* aPoint; +}; + +struct OrbisNgs2SubmixerVoiceCompressorParam { + OrbisNgs2VoiceParamHeader header; + + u32 flags; + float threshold; + float ratio; + float knee; + float attackTime; + float releaseTime; + float level; + u32 reserved; +}; + +struct OrbisNgs2SubmixerVoiceDistortionParam { + OrbisNgs2VoiceParamHeader header; + + u32 flags; + float a; + float b; + float clip; + float gate; + float wetLevel; + float dryLevel; + u32 reserved; +}; + +struct OrbisNgs2SubmixerVoiceUserFxParam { + OrbisNgs2VoiceParamHeader header; + + OrbisNgs2UserFxProcessHandler handler; + + uintptr_t userData0; + uintptr_t userData1; + uintptr_t userData2; +}; + +struct OrbisNgs2SubmixerVoicePeakMeterParam { + OrbisNgs2VoiceParamHeader header; + + u32 enableFlag; + u32 reserved; +}; + +struct OrbisNgs2SubmixerVoiceFilterParam { + OrbisNgs2VoiceParamHeader header; + + u32 index; + u32 location; + u32 type; + u32 channelMask; + union { + struct { + float i0; + float i1; + float i2; + float o1; + float o2; + } direct; + struct { + float fc; + float q; + float level; + u32 reserved; + u32 reserved2; + } fcq; + } param; + u32 reserved3; +}; + +struct OrbisNgs2SubmixerVoiceNumFilters { + OrbisNgs2VoiceParamHeader header; + + u32 numFilters; + u32 reserved; +}; + +struct OrbisNgs2SubmixerVoiceState { + OrbisNgs2VoiceState voiceState; + float envelopeHeight; + float peakHeight; + float compressorHeight; +}; + +struct OrbisNgs2SubmixerRackInfo { + OrbisNgs2RackInfo rackInfo; + u32 maxChannels; + u32 maxEnvelopePoints; + u32 maxFilters; + u32 maxInputs; +}; + +} // namespace Libraries::Ngs2 diff --git a/src/core/libraries/np_auth/np_auth.cpp b/src/core/libraries/np_auth/np_auth.cpp new file mode 100644 index 000000000..9ec986f3c --- /dev/null +++ b/src/core/libraries/np_auth/np_auth.cpp @@ -0,0 +1,99 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "common/logging/log.h" +#include "core/libraries/error_codes.h" +#include "core/libraries/libs.h" +#include "core/libraries/np_auth/np_auth.h" + +namespace Libraries::NpAuth { + +s32 PS4_SYSV_ABI sceNpAuthGetAuthorizationCode() { + LOG_ERROR(Lib_NpAuth, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpAuthGetIdToken() { + LOG_ERROR(Lib_NpAuth, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpAuthAbortRequest() { + LOG_ERROR(Lib_NpAuth, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpAuthCreateAsyncRequest() { + LOG_ERROR(Lib_NpAuth, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpAuthCreateRequest() { + LOG_WARNING(Lib_NpAuth, "(DUMMY) called"); + return 1; +} + +s32 PS4_SYSV_ABI sceNpAuthDeleteRequest(s32 id) { + LOG_WARNING(Lib_NpAuth, "(DUMMY) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpAuthGetAuthorizationCodeA() { + LOG_ERROR(Lib_NpAuth, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpAuthGetAuthorizationCodeV3() { + LOG_ERROR(Lib_NpAuth, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpAuthGetIdTokenA() { + LOG_ERROR(Lib_NpAuth, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpAuthGetIdTokenV3() { + LOG_ERROR(Lib_NpAuth, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpAuthPollAsync() { + LOG_ERROR(Lib_NpAuth, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpAuthSetTimeout() { + LOG_ERROR(Lib_NpAuth, "(STUBBED) called"); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpAuthWaitAsync() { + LOG_ERROR(Lib_NpAuth, "(STUBBED) called"); + return ORBIS_OK; +} + +void RegisterlibSceNpAuth(Core::Loader::SymbolsResolver* sym) { + LIB_FUNCTION("KxGkOrQJTqY", "libSceNpAuthCompat", 1, "libSceNpAuth", 1, 1, + sceNpAuthGetAuthorizationCode); + LIB_FUNCTION("uaB-LoJqHis", "libSceNpAuthCompat", 1, "libSceNpAuth", 1, 1, sceNpAuthGetIdToken); + LIB_FUNCTION("cE7wIsqXdZ8", "libSceNpAuth", 1, "libSceNpAuth", 1, 1, sceNpAuthAbortRequest); + LIB_FUNCTION("N+mr7GjTvr8", "libSceNpAuth", 1, "libSceNpAuth", 1, 1, + sceNpAuthCreateAsyncRequest); + LIB_FUNCTION("6bwFkosYRQg", "libSceNpAuth", 1, "libSceNpAuth", 1, 1, sceNpAuthCreateRequest); + LIB_FUNCTION("H8wG9Bk-nPc", "libSceNpAuth", 1, "libSceNpAuth", 1, 1, sceNpAuthDeleteRequest); + LIB_FUNCTION("KxGkOrQJTqY", "libSceNpAuth", 1, "libSceNpAuth", 1, 1, + sceNpAuthGetAuthorizationCode); + LIB_FUNCTION("qAUXQ9GdWp8", "libSceNpAuth", 1, "libSceNpAuth", 1, 1, + sceNpAuthGetAuthorizationCodeA); + LIB_FUNCTION("KI4dHLlTNl0", "libSceNpAuth", 1, "libSceNpAuth", 1, 1, + sceNpAuthGetAuthorizationCodeV3); + LIB_FUNCTION("uaB-LoJqHis", "libSceNpAuth", 1, "libSceNpAuth", 1, 1, sceNpAuthGetIdToken); + LIB_FUNCTION("CocbHVIKPE8", "libSceNpAuth", 1, "libSceNpAuth", 1, 1, sceNpAuthGetIdTokenA); + LIB_FUNCTION("RdsFVsgSpZY", "libSceNpAuth", 1, "libSceNpAuth", 1, 1, sceNpAuthGetIdTokenV3); + LIB_FUNCTION("gjSyfzSsDcE", "libSceNpAuth", 1, "libSceNpAuth", 1, 1, sceNpAuthPollAsync); + LIB_FUNCTION("PM3IZCw-7m0", "libSceNpAuth", 1, "libSceNpAuth", 1, 1, sceNpAuthSetTimeout); + LIB_FUNCTION("SK-S7daqJSE", "libSceNpAuth", 1, "libSceNpAuth", 1, 1, sceNpAuthWaitAsync); +}; + +} // namespace Libraries::NpAuth \ No newline at end of file diff --git a/src/core/libraries/np_auth/np_auth.h b/src/core/libraries/np_auth/np_auth.h new file mode 100644 index 000000000..a6a66b452 --- /dev/null +++ b/src/core/libraries/np_auth/np_auth.h @@ -0,0 +1,29 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "common/types.h" + +namespace Core::Loader { +class SymbolsResolver; +} + +namespace Libraries::NpAuth { + +s32 PS4_SYSV_ABI sceNpAuthGetAuthorizationCode(); +s32 PS4_SYSV_ABI sceNpAuthGetIdToken(); +s32 PS4_SYSV_ABI sceNpAuthAbortRequest(); +s32 PS4_SYSV_ABI sceNpAuthCreateAsyncRequest(); +s32 PS4_SYSV_ABI sceNpAuthCreateRequest(); +s32 PS4_SYSV_ABI sceNpAuthDeleteRequest(s32 id); +s32 PS4_SYSV_ABI sceNpAuthGetAuthorizationCodeA(); +s32 PS4_SYSV_ABI sceNpAuthGetAuthorizationCodeV3(); +s32 PS4_SYSV_ABI sceNpAuthGetIdTokenA(); +s32 PS4_SYSV_ABI sceNpAuthGetIdTokenV3(); +s32 PS4_SYSV_ABI sceNpAuthPollAsync(); +s32 PS4_SYSV_ABI sceNpAuthSetTimeout(); +s32 PS4_SYSV_ABI sceNpAuthWaitAsync(); + +void RegisterlibSceNpAuth(Core::Loader::SymbolsResolver* sym); +} // namespace Libraries::NpAuth \ No newline at end of file diff --git a/src/core/libraries/np_trophy/trophy_ui.cpp b/src/core/libraries/np_trophy/trophy_ui.cpp index 2564cbf5d..3c9f883b3 100644 --- a/src/core/libraries/np_trophy/trophy_ui.cpp +++ b/src/core/libraries/np_trophy/trophy_ui.cpp @@ -27,14 +27,17 @@ namespace Libraries::NpTrophy { std::optional current_trophy_ui; std::queue trophy_queue; std::mutex queueMtx; -bool isLeftSide; + +std::string side = "right"; + double trophy_timer; TrophyUI::TrophyUI(const std::filesystem::path& trophyIconPath, const std::string& trophyName, const std::string_view& rarity) : trophy_name(trophyName), trophy_type(rarity) { - isLeftSide = Config::leftSideTrophy(); + side = Config::sideTrophy(); + trophy_timer = Config::getTrophyNotificationDuration(); if (std::filesystem::exists(trophyIconPath)) { @@ -89,10 +92,14 @@ TrophyUI::TrophyUI(const std::filesystem::path& trophyIconPath, const std::strin AddLayer(this); #ifdef ENABLE_QT_GUI - QString musicPath = QString::fromStdString(CustomTrophy_Dir.string() + "/trophy.mp3"); - if (fs::exists(musicPath.toStdString())) { + QString musicPathWav = QString::fromStdString(CustomTrophy_Dir.string() + "/trophy.wav"); + QString musicPathMp3 = QString::fromStdString(CustomTrophy_Dir.string() + "/trophy.mp3"); + if (fs::exists(musicPathWav.toStdString())) { BackgroundMusicPlayer::getInstance().setVolume(100); - BackgroundMusicPlayer::getInstance().playMusic(musicPath, false); + BackgroundMusicPlayer::getInstance().playMusic(musicPathWav, false); + } else if (fs::exists(musicPathMp3.toStdString())) { + BackgroundMusicPlayer::getInstance().setVolume(100); + BackgroundMusicPlayer::getInstance().playMusic(musicPathMp3, false); } #endif } @@ -115,8 +122,8 @@ float fade_out_duration = 0.5f; // Final fade duration void TrophyUI::Draw() { const auto& io = GetIO(); - float AdjustWidth = io.DisplaySize.x / 1280; - float AdjustHeight = io.DisplaySize.y / 720; + float AdjustWidth = io.DisplaySize.x / 1920; + float AdjustHeight = io.DisplaySize.y / 1080; const ImVec2 window_size{ std::min(io.DisplaySize.x, (350 * AdjustWidth)), std::min(io.DisplaySize.y, (70 * AdjustHeight)), @@ -125,21 +132,38 @@ void TrophyUI::Draw() { elapsed_time += io.DeltaTime; float progress = std::min(elapsed_time / animation_duration, 1.0f); - // left or right position - float final_pos_x; - if (isLeftSide) { - start_pos.x = -window_size.x; + float final_pos_x, start_x; + float final_pos_y, start_y; + + if (side == "top") { + start_x = (io.DisplaySize.x - window_size.x) * 0.5f; + start_y = -window_size.y; + final_pos_x = start_x; + final_pos_y = 20 * AdjustHeight; + } else if (side == "left") { + start_x = -window_size.x; + start_y = 50 * AdjustHeight; final_pos_x = 20 * AdjustWidth; - } else { - start_pos.x = io.DisplaySize.x; + final_pos_y = start_y; + } else if (side == "right") { + start_x = io.DisplaySize.x; + start_y = 50 * AdjustHeight; final_pos_x = io.DisplaySize.x - window_size.x - 20 * AdjustWidth; + final_pos_y = start_y; + } else if (side == "bottom") { + start_x = (io.DisplaySize.x - window_size.x) * 0.5f; + start_y = io.DisplaySize.y; + final_pos_x = start_x; + final_pos_y = io.DisplaySize.y - window_size.y - 20 * AdjustHeight; } - ImVec2 current_pos = ImVec2(start_pos.x + (final_pos_x - start_pos.x) * progress, - start_pos.y + (target_pos.y - start_pos.y) * progress); + ImVec2 current_pos = ImVec2(start_x + (final_pos_x - start_x) * progress, + start_y + (final_pos_y - start_y) * progress); trophy_timer -= io.DeltaTime; + ImGui::SetNextWindowPos(current_pos); + // If the remaining time of the trophy is less than or equal to 1 second, the fade-out begins. if (trophy_timer <= 1.0f) { float fade_out_time = 1.0f - (trophy_timer / 1.0f); @@ -192,6 +216,13 @@ void TrophyUI::Draw() { const float text_height = ImGui::CalcTextSize(combinedString.c_str()).y; SetCursorPosY((window_size.y - text_height) * 0.5); } + + if (side == "top" || side == "bottom") { + float text_width = ImGui::CalcTextSize(trophy_name.c_str()).x; + float centered_x = (window_size.x - text_width) * 0.5f; + ImGui::SetCursorPosX(std::max(centered_x, 10.0f * AdjustWidth)); + } + ImGui::PushTextWrapPos(window_size.x - (60 * AdjustWidth)); TextWrapped("Trophy earned!\n%s", trophy_name.c_str()); ImGui::SameLine(window_size.x - (60 * AdjustWidth)); diff --git a/src/core/libraries/pad/pad.cpp b/src/core/libraries/pad/pad.cpp index 2e5973144..5dfc68e90 100644 --- a/src/core/libraries/pad/pad.cpp +++ b/src/core/libraries/pad/pad.cpp @@ -250,7 +250,6 @@ int PS4_SYSV_ABI scePadMbusTerm() { } int PS4_SYSV_ABI scePadOpen(s32 userId, s32 type, s32 index, const OrbisPadOpenParam* pParam) { - LOG_INFO(Lib_Pad, "(DUMMY) called user_id = {} type = {} index = {}", userId, type, index); if (userId == -1) { return ORBIS_PAD_ERROR_DEVICE_NO_HANDLE; } @@ -261,6 +260,7 @@ int PS4_SYSV_ABI scePadOpen(s32 userId, s32 type, s32 index, const OrbisPadOpenP if (type != ORBIS_PAD_PORT_TYPE_STANDARD && type != ORBIS_PAD_PORT_TYPE_REMOTE_CONTROL) return ORBIS_PAD_ERROR_DEVICE_NOT_CONNECTED; } + LOG_INFO(Lib_Pad, "(DUMMY) called user_id = {} type = {} index = {}", userId, type, index); scePadResetLightBar(1); return 1; // dummy } diff --git a/src/core/libraries/system/sysmodule.cpp b/src/core/libraries/system/sysmodule.cpp index 350f1317b..d9e78e4ab 100644 --- a/src/core/libraries/system/sysmodule.cpp +++ b/src/core/libraries/system/sysmodule.cpp @@ -7,6 +7,7 @@ #include "common/logging/log.h" #include "core/libraries/error_codes.h" +#include "core/libraries/kernel/process.h" #include "core/libraries/libs.h" #include "core/libraries/system/sysmodule.h" #include "core/libraries/system/system_error.h" @@ -18,9 +19,41 @@ int PS4_SYSV_ABI sceSysmoduleGetModuleHandleInternal() { return ORBIS_OK; } -int PS4_SYSV_ABI sceSysmoduleGetModuleInfoForUnwind() { - LOG_ERROR(Lib_SysModule, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceSysmoduleGetModuleInfoForUnwind(VAddr addr, s32 flags, + Kernel::OrbisModuleInfoForUnwind* info) { + LOG_TRACE(Lib_SysModule, "sceSysmoduleGetModuleInfoForUnwind(addr=0x{:X}, flags=0x{:X})", addr, + flags); + + s32 res = Kernel::sceKernelGetModuleInfoForUnwind(addr, flags, info); + if (res != 0) { + return res; + } + + static constexpr std::array modules_to_hide = { + "libc.prx", + "libc.sprx", + "libSceAudioLatencyEstimation.prx", + "libSceFace.prx", + "libSceFaceTracker.prx", + "libSceFios2.prx", + "libSceFios2.sprx", + "libSceFontGsm.prx", + "libSceHand.prx", + "libSceHandTracker.prx", + "libSceHeadTracker.prx", + "libSceJobManager.prx", + "libSceNpCppWebApi.prx", + "libSceNpToolkit.prx", + "libSceNpToolkit2.prx", + "libSceS3DConversion.prx", + "libSceSmart.prx", + }; + + const std::string_view module_name = info->name.data(); + if (std::ranges::find(modules_to_hide, module_name) != modules_to_hide.end()) { + std::ranges::fill(info->name, '\0'); + } + return res; } int PS4_SYSV_ABI sceSysmoduleIsCalledFromSysModule() { @@ -52,7 +85,6 @@ int PS4_SYSV_ABI sceSysmoduleIsLoadedInternal(OrbisSysModuleInternal id) { } int PS4_SYSV_ABI sceSysmoduleLoadModule(OrbisSysModule id) { - auto color_name = magic_enum::enum_name(id); LOG_ERROR(Lib_SysModule, "(DUMMY) called module = {}", magic_enum::enum_name(id)); return ORBIS_OK; } diff --git a/src/core/libraries/system/sysmodule.h b/src/core/libraries/system/sysmodule.h index 3630fb58e..9a5fe9513 100644 --- a/src/core/libraries/system/sysmodule.h +++ b/src/core/libraries/system/sysmodule.h @@ -4,6 +4,7 @@ #pragma once #include "common/types.h" +#include "core/libraries/kernel/process.h" namespace Core::Loader { class SymbolsResolver; @@ -152,7 +153,8 @@ enum class OrbisSysModuleInternal : u32 { }; int PS4_SYSV_ABI sceSysmoduleGetModuleHandleInternal(); -int PS4_SYSV_ABI sceSysmoduleGetModuleInfoForUnwind(); +s32 PS4_SYSV_ABI sceSysmoduleGetModuleInfoForUnwind(VAddr addr, s32 flags, + Kernel::OrbisModuleInfoForUnwind* info); int PS4_SYSV_ABI sceSysmoduleIsCalledFromSysModule(); int PS4_SYSV_ABI sceSysmoduleIsCameraPreloaded(); int PS4_SYSV_ABI sceSysmoduleIsLoaded(OrbisSysModule id); diff --git a/src/core/libraries/system/systemservice.cpp b/src/core/libraries/system/systemservice.cpp index a67b9a2fc..9dc9dd781 100644 --- a/src/core/libraries/system/systemservice.cpp +++ b/src/core/libraries/system/systemservice.cpp @@ -1893,7 +1893,7 @@ int PS4_SYSV_ABI sceSystemServiceNavigateToGoHome() { s32 PS4_SYSV_ABI sceSystemServiceParamGetInt(OrbisSystemServiceParamId param_id, int* value) { // TODO this probably should be stored in config for UI configuration - LOG_INFO(Lib_SystemService, "called param_id {}", u32(param_id)); + LOG_DEBUG(Lib_SystemService, "called param_id {}", u32(param_id)); if (value == nullptr) { LOG_ERROR(Lib_SystemService, "value is null"); return ORBIS_SYSTEM_SERVICE_ERROR_PARAMETER; diff --git a/src/core/libraries/system/userservice.cpp b/src/core/libraries/system/userservice.cpp index e1f9f75e8..b4bf189ea 100644 --- a/src/core/libraries/system/userservice.cpp +++ b/src/core/libraries/system/userservice.cpp @@ -1043,7 +1043,7 @@ int PS4_SYSV_ABI sceUserServiceGetTraditionalChineseInputType() { s32 PS4_SYSV_ABI sceUserServiceGetUserColor(int user_id, OrbisUserServiceUserColor* color) { // TODO fix me better - LOG_INFO(Lib_UserService, "called user_id = {}", user_id); + LOG_DEBUG(Lib_UserService, "called user_id = {}", user_id); if (color == nullptr) { LOG_ERROR(Lib_UserService, "color is null"); return ORBIS_USER_SERVICE_ERROR_INVALID_ARGUMENT; @@ -1068,7 +1068,7 @@ int PS4_SYSV_ABI sceUserServiceGetUserGroupNum() { } s32 PS4_SYSV_ABI sceUserServiceGetUserName(int user_id, char* user_name, std::size_t size) { - LOG_INFO(Lib_UserService, "called user_id = {} ,size = {} ", user_id, size); + LOG_DEBUG(Lib_UserService, "called user_id = {} ,size = {} ", user_id, size); if (user_name == nullptr) { LOG_ERROR(Lib_UserService, "user_name is null"); return ORBIS_USER_SERVICE_ERROR_INVALID_ARGUMENT; diff --git a/src/core/libraries/ulobjmgr/ulobjmgr.cpp b/src/core/libraries/ulobjmgr/ulobjmgr.cpp new file mode 100644 index 000000000..cad6feda9 --- /dev/null +++ b/src/core/libraries/ulobjmgr/ulobjmgr.cpp @@ -0,0 +1,45 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "common/logging/log.h" +#include "core/libraries/error_codes.h" +#include "core/libraries/kernel/posix_error.h" +#include "core/libraries/libs.h" +#include "core/libraries/ulobjmgr/ulobjmgr.h" + +namespace Libraries::Ulobjmgr { + +s32 PS4_SYSV_ABI Func_046DBA8411A2365C(u64 arg0, s32 arg1, u32* arg2) { + if (arg0 == 0 || arg1 == 0 || arg2 == nullptr) { + return POSIX_EINVAL; + } + *arg2 = 0; + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI Func_1D9F50D9CFB8054E() { + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI Func_4A67FE7D435B94F7(u32 arg0) { + if (arg0 >= 0x4000) { + return POSIX_EINVAL; + } + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI Func_4B07893BBB77A649(u64 arg0) { + if (arg0 == 0) { + return POSIX_EINVAL; + } + return ORBIS_OK; +} + +void RegisterlibSceUlobjmgr(Core::Loader::SymbolsResolver* sym) { + LIB_FUNCTION("BG26hBGiNlw", "ulobjmgr", 1, "ulobjmgr", 1, 1, Func_046DBA8411A2365C); + LIB_FUNCTION("HZ9Q2c+4BU4", "ulobjmgr", 1, "ulobjmgr", 1, 1, Func_1D9F50D9CFB8054E); + LIB_FUNCTION("Smf+fUNblPc", "ulobjmgr", 1, "ulobjmgr", 1, 1, Func_4A67FE7D435B94F7); + LIB_FUNCTION("SweJO7t3pkk", "ulobjmgr", 1, "ulobjmgr", 1, 1, Func_4B07893BBB77A649); +}; + +} // namespace Libraries::Ulobjmgr diff --git a/src/core/libraries/ulobjmgr/ulobjmgr.h b/src/core/libraries/ulobjmgr/ulobjmgr.h new file mode 100644 index 000000000..9a1440e5c --- /dev/null +++ b/src/core/libraries/ulobjmgr/ulobjmgr.h @@ -0,0 +1,14 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "common/types.h" + +namespace Core::Loader { +class SymbolsResolver; +} + +namespace Libraries::Ulobjmgr { +void RegisterlibSceUlobjmgr(Core::Loader::SymbolsResolver* sym); +} // namespace Libraries::Ulobjmgr \ No newline at end of file diff --git a/src/core/libraries/usbd/usbd.cpp b/src/core/libraries/usbd/usbd.cpp index fdfa50b23..e5f6151eb 100644 --- a/src/core/libraries/usbd/usbd.cpp +++ b/src/core/libraries/usbd/usbd.cpp @@ -7,311 +7,455 @@ #include "core/libraries/libs.h" #include "usbd.h" +#include +#include + namespace Libraries::Usbd { -int PS4_SYSV_ABI sceUsbdAllocTransfer() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 libusb_to_orbis_error(int retVal) { + if (retVal == LIBUSB_ERROR_OTHER) + return 0x802400FF; + if (retVal < 0) { + LOG_ERROR(Lib_Usbd, "libusb returned: {}", libusb_error_name(retVal)); + return 0x80240000 - retVal; + } + + return retVal; } -int PS4_SYSV_ABI sceUsbdAttachKernelDriver() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +libusb_context* g_libusb_context; + +#if defined(_WIN32) +bool s_has_removed_driver = false; +#endif + +s32 PS4_SYSV_ABI sceUsbdInit() { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_to_orbis_error(libusb_init(&g_libusb_context)); } -int PS4_SYSV_ABI sceUsbdBulkTransfer() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +void PS4_SYSV_ABI sceUsbdExit() { + LOG_DEBUG(Lib_Usbd, "called"); + + libusb_exit(g_libusb_context); } -int PS4_SYSV_ABI sceUsbdCancelTransfer() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s64 PS4_SYSV_ABI sceUsbdGetDeviceList(SceUsbdDevice*** list) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_to_orbis_error(libusb_get_device_list(g_libusb_context, list)); } -int PS4_SYSV_ABI sceUsbdCheckConnected() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +void PS4_SYSV_ABI sceUsbdFreeDeviceList(SceUsbdDevice** list, s32 unref_devices) { + LOG_DEBUG(Lib_Usbd, "called"); + + libusb_free_device_list(list, unref_devices); } -int PS4_SYSV_ABI sceUsbdClaimInterface() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +SceUsbdDevice* PS4_SYSV_ABI sceUsbdRefDevice(SceUsbdDevice* device) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_ref_device(device); } -int PS4_SYSV_ABI sceUsbdClearHalt() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +void PS4_SYSV_ABI sceUsbdUnrefDevice(SceUsbdDevice* device) { + LOG_DEBUG(Lib_Usbd, "called"); + + libusb_unref_device(device); } -int PS4_SYSV_ABI sceUsbdClose() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdGetConfiguration(SceUsbdDeviceHandle* dev_handle, s32* config) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_to_orbis_error(libusb_get_configuration(dev_handle, config)); } -int PS4_SYSV_ABI sceUsbdControlTransfer() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdGetDeviceDescriptor(SceUsbdDevice* device, SceUsbdDeviceDescriptor* desc) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_to_orbis_error(libusb_get_device_descriptor(device, desc)); } -int PS4_SYSV_ABI sceUsbdControlTransferGetData() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdGetActiveConfigDescriptor(SceUsbdDevice* device, + SceUsbdConfigDescriptor** config) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_to_orbis_error(libusb_get_active_config_descriptor(device, config)); } -int PS4_SYSV_ABI sceUsbdControlTransferGetSetup() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdGetConfigDescriptor(SceUsbdDevice* device, u8 config_index, + SceUsbdConfigDescriptor** config) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_to_orbis_error(libusb_get_config_descriptor(device, config_index, config)); } -int PS4_SYSV_ABI sceUsbdDetachKernelDriver() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdGetConfigDescriptorByValue(SceUsbdDevice* device, u8 bConfigurationValue, + SceUsbdConfigDescriptor** config) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_to_orbis_error( + libusb_get_config_descriptor_by_value(device, bConfigurationValue, config)); } -int PS4_SYSV_ABI sceUsbdEventHandlerActive() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +void PS4_SYSV_ABI sceUsbdFreeConfigDescriptor(SceUsbdConfigDescriptor* config) { + LOG_DEBUG(Lib_Usbd, "called"); + + libusb_free_config_descriptor(config); } -int PS4_SYSV_ABI sceUsbdEventHandlingOk() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +u8 PS4_SYSV_ABI sceUsbdGetBusNumber(SceUsbdDevice* device) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_get_bus_number(device); } -int PS4_SYSV_ABI sceUsbdExit() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +u8 PS4_SYSV_ABI sceUsbdGetDeviceAddress(SceUsbdDevice* device) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_get_device_address(device); } -int PS4_SYSV_ABI sceUsbdFillBulkTransfer() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +SceUsbdSpeed PS4_SYSV_ABI sceUsbdGetDeviceSpeed(SceUsbdDevice* device) { + LOG_DEBUG(Lib_Usbd, "called"); + + return static_cast(libusb_get_device_speed(device)); } -int PS4_SYSV_ABI sceUsbdFillControlSetup() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdGetMaxPacketSize(SceUsbdDevice* device, u8 endpoint) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_to_orbis_error(libusb_get_max_packet_size(device, endpoint)); } -int PS4_SYSV_ABI sceUsbdFillControlTransfer() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdGetMaxIsoPacketSize(SceUsbdDevice* device, u8 endpoint) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_to_orbis_error(libusb_get_max_iso_packet_size(device, endpoint)); } -int PS4_SYSV_ABI sceUsbdFillInterruptTransfer() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdOpen(SceUsbdDevice* device, SceUsbdDeviceHandle** dev_handle) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_to_orbis_error(libusb_open(device, dev_handle)); } -int PS4_SYSV_ABI sceUsbdFillIsoTransfer() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +void PS4_SYSV_ABI sceUsbdClose(SceUsbdDeviceHandle* dev_handle) { + LOG_DEBUG(Lib_Usbd, "called"); + + libusb_close(dev_handle); } -int PS4_SYSV_ABI sceUsbdFreeConfigDescriptor() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +SceUsbdDevice* PS4_SYSV_ABI sceUsbdGetDevice(SceUsbdDeviceHandle* dev_handle) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_get_device(dev_handle); } -int PS4_SYSV_ABI sceUsbdFreeDeviceList() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdSetConfiguration(SceUsbdDeviceHandle* dev_handle, s32 config) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_to_orbis_error(libusb_set_configuration(dev_handle, config)); } -int PS4_SYSV_ABI sceUsbdFreeTransfer() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdClaimInterface(SceUsbdDeviceHandle* dev_handle, s32 interface_number) { + LOG_DEBUG(Lib_Usbd, "called"); + + if (sceUsbdKernelDriverActive(dev_handle, interface_number)) { + sceUsbdDetachKernelDriver(dev_handle, interface_number); + } + + return libusb_to_orbis_error(libusb_claim_interface(dev_handle, interface_number)); } -int PS4_SYSV_ABI sceUsbdGetActiveConfigDescriptor() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdReleaseInterface(SceUsbdDeviceHandle* dev_handle, s32 interface_number) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_to_orbis_error(libusb_release_interface(dev_handle, interface_number)); } -int PS4_SYSV_ABI sceUsbdGetBusNumber() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +SceUsbdDeviceHandle* PS4_SYSV_ABI sceUsbdOpenDeviceWithVidPid(u16 vendor_id, u16 product_id) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_open_device_with_vid_pid(g_libusb_context, vendor_id, product_id); } -int PS4_SYSV_ABI sceUsbdGetConfigDescriptor() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdSetInterfaceAltSetting(SceUsbdDeviceHandle* dev_handle, + int interface_number, int alternate_setting) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_to_orbis_error( + libusb_set_interface_alt_setting(dev_handle, interface_number, alternate_setting)); } -int PS4_SYSV_ABI sceUsbdGetConfigDescriptorByValue() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdClearHalt(SceUsbdDeviceHandle* dev_handle, uint8_t endpoint) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_to_orbis_error(libusb_clear_halt(dev_handle, endpoint)); } -int PS4_SYSV_ABI sceUsbdGetConfiguration() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdResetDevice(SceUsbdDeviceHandle* dev_handle) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_to_orbis_error(libusb_reset_device(dev_handle)); } -int PS4_SYSV_ABI sceUsbdGetDescriptor() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdKernelDriverActive(SceUsbdDeviceHandle* dev_handle, int interface_number) { + LOG_DEBUG(Lib_Usbd, "called"); + +#if defined(_WIN32) + if (!s_has_removed_driver) + return 1; + else + return 0; +#endif + + return libusb_to_orbis_error(libusb_kernel_driver_active(dev_handle, interface_number)); } -int PS4_SYSV_ABI sceUsbdGetDevice() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdDetachKernelDriver(SceUsbdDeviceHandle* dev_handle, int interface_number) { + LOG_DEBUG(Lib_Usbd, "called"); + +#if defined(_WIN32) + s_has_removed_driver = true; + return 0; +#endif + + return libusb_to_orbis_error(libusb_detach_kernel_driver(dev_handle, interface_number)); } -int PS4_SYSV_ABI sceUsbdGetDeviceAddress() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdAttachKernelDriver(SceUsbdDeviceHandle* dev_handle, int interface_number) { + LOG_DEBUG(Lib_Usbd, "called"); + +#if defined(_WIN32) + s_has_removed_driver = false; + return 0; +#endif + + return libusb_to_orbis_error(libusb_attach_kernel_driver(dev_handle, interface_number)); } -int PS4_SYSV_ABI sceUsbdGetDeviceDescriptor() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +u8* PS4_SYSV_ABI sceUsbdControlTransferGetData(SceUsbdTransfer* transfer) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_control_transfer_get_data(transfer); } -int PS4_SYSV_ABI sceUsbdGetDeviceList() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +SceUsbdControlSetup* PS4_SYSV_ABI sceUsbdControlTransferGetSetup(SceUsbdTransfer* transfer) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_control_transfer_get_setup(transfer); } -int PS4_SYSV_ABI sceUsbdGetDeviceSpeed() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +void PS4_SYSV_ABI sceUsbdFillControlSetup(u8* buf, u8 bmRequestType, u8 bRequest, u16 wValue, + u16 wIndex, u16 wLength) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_fill_control_setup(buf, bmRequestType, bRequest, wValue, wIndex, wLength); } -int PS4_SYSV_ABI sceUsbdGetIsoPacketBuffer() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +SceUsbdTransfer* PS4_SYSV_ABI sceUsbdAllocTransfer(int iso_packets) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_alloc_transfer(iso_packets); } -int PS4_SYSV_ABI sceUsbdGetMaxIsoPacketSize() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdSubmitTransfer(SceUsbdTransfer* transfer) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_to_orbis_error(libusb_submit_transfer(transfer)); } -int PS4_SYSV_ABI sceUsbdGetMaxPacketSize() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdCancelTransfer(SceUsbdTransfer* transfer) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_to_orbis_error(libusb_cancel_transfer(transfer)); } -int PS4_SYSV_ABI sceUsbdGetStringDescriptor() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +void PS4_SYSV_ABI sceUsbdFreeTransfer(SceUsbdTransfer* transfer) { + LOG_DEBUG(Lib_Usbd, "called"); + + libusb_free_transfer(transfer); } -int PS4_SYSV_ABI sceUsbdGetStringDescriptorAscii() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +void PS4_SYSV_ABI sceUsbdFillControlTransfer(SceUsbdTransfer* transfer, + SceUsbdDeviceHandle* dev_handle, u8* buffer, + SceUsbdTransferCallback callback, void* user_data, + u32 timeout) { + LOG_DEBUG(Lib_Usbd, "called"); + + libusb_fill_control_transfer(transfer, dev_handle, buffer, callback, user_data, timeout); } -int PS4_SYSV_ABI sceUsbdHandleEvents() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +void PS4_SYSV_ABI sceUsbdFillBulkTransfer(SceUsbdTransfer* transfer, + SceUsbdDeviceHandle* dev_handle, uint8_t endpoint, + u8* buffer, s32 length, SceUsbdTransferCallback callback, + void* user_data, u32 timeout) { + LOG_DEBUG(Lib_Usbd, "called"); + + libusb_fill_bulk_transfer(transfer, dev_handle, endpoint, buffer, length, callback, user_data, + timeout); } -int PS4_SYSV_ABI sceUsbdHandleEventsLocked() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +void PS4_SYSV_ABI sceUsbdFillInterruptTransfer(SceUsbdTransfer* transfer, + SceUsbdDeviceHandle* dev_handle, uint8_t endpoint, + u8* buffer, s32 length, + SceUsbdTransferCallback callback, void* user_data, + u32 timeout) { + LOG_DEBUG(Lib_Usbd, "called"); + + libusb_fill_interrupt_transfer(transfer, dev_handle, endpoint, buffer, length, callback, + user_data, timeout); } -int PS4_SYSV_ABI sceUsbdHandleEventsTimeout() { - LOG_DEBUG(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +void PS4_SYSV_ABI sceUsbdFillIsoTransfer(SceUsbdTransfer* transfer, SceUsbdDeviceHandle* dev_handle, + uint8_t endpoint, u8* buffer, s32 length, + s32 num_iso_packets, SceUsbdTransferCallback callback, + void* user_data, u32 timeout) { + LOG_DEBUG(Lib_Usbd, "called"); + + libusb_fill_iso_transfer(transfer, dev_handle, endpoint, buffer, length, num_iso_packets, + callback, user_data, timeout); } -int PS4_SYSV_ABI sceUsbdInit() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return 0x80240005; // Skip +void PS4_SYSV_ABI sceUsbdSetIsoPacketLengths(SceUsbdTransfer* transfer, u32 length) { + LOG_DEBUG(Lib_Usbd, "called"); + + libusb_set_iso_packet_lengths(transfer, length); } -int PS4_SYSV_ABI sceUsbdInterruptTransfer() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +u8* PS4_SYSV_ABI sceUsbdGetIsoPacketBuffer(SceUsbdTransfer* transfer, u32 packet) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_get_iso_packet_buffer(transfer, packet); } -int PS4_SYSV_ABI sceUsbdKernelDriverActive() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdControlTransfer(SceUsbdDeviceHandle* dev_handle, u8 request_type, + u8 bRequest, u16 wValue, u16 wIndex, u8* data, s32 wLength, + u32 timeout) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_to_orbis_error(libusb_control_transfer(dev_handle, request_type, bRequest, wValue, + wIndex, data, wLength, timeout)); } -int PS4_SYSV_ABI sceUsbdLockEvents() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdBulkTransfer(SceUsbdDeviceHandle* dev_handle, u8 endpoint, u8* data, + s32 length, s32* actual_length, u32 timeout) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_to_orbis_error( + libusb_bulk_transfer(dev_handle, endpoint, data, length, actual_length, timeout)); } -int PS4_SYSV_ABI sceUsbdLockEventWaiters() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdInterruptTransfer(SceUsbdDeviceHandle* dev_handle, u8 endpoint, u8* data, + s32 length, s32* actual_length, u32 timeout) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_to_orbis_error( + libusb_interrupt_transfer(dev_handle, endpoint, data, length, actual_length, timeout)); } -int PS4_SYSV_ABI sceUsbdOpen() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdGetDescriptor(SceUsbdDeviceHandle* dev_handle, u8 descType, u8 descIndex, + u8* data, s32 length) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_to_orbis_error( + libusb_get_descriptor(dev_handle, descType, descIndex, data, length)); } -int PS4_SYSV_ABI sceUsbdOpenDeviceWithVidPid() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdGetStringDescriptor(SceUsbdDeviceHandle* dev_handle, u8 desc_index, + u16 langid, u8* data, s32 length) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_to_orbis_error( + libusb_get_string_descriptor(dev_handle, desc_index, langid, data, length)); } -int PS4_SYSV_ABI sceUsbdRefDevice() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdGetStringDescriptorAscii(SceUsbdDeviceHandle* dev_handle, u8 desc_index, + u8* data, s32 length) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_to_orbis_error( + libusb_get_string_descriptor_ascii(dev_handle, desc_index, data, length)); } -int PS4_SYSV_ABI sceUsbdReleaseInterface() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdTryLockEvents() { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_try_lock_events(g_libusb_context); } -int PS4_SYSV_ABI sceUsbdResetDevice() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +void PS4_SYSV_ABI sceUsbdLockEvents() { + LOG_DEBUG(Lib_Usbd, "called"); + + libusb_lock_events(g_libusb_context); } -int PS4_SYSV_ABI sceUsbdSetConfiguration() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +void PS4_SYSV_ABI sceUsbdUnlockEvents() { + LOG_DEBUG(Lib_Usbd, "called"); + + libusb_unlock_events(g_libusb_context); } -int PS4_SYSV_ABI sceUsbdSetInterfaceAltSetting() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdEventHandlingOk() { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_event_handling_ok(g_libusb_context); } -int PS4_SYSV_ABI sceUsbdSetIsoPacketLengths() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdEventHandlerActive() { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_event_handler_active(g_libusb_context); } -int PS4_SYSV_ABI sceUsbdSubmitTransfer() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +void PS4_SYSV_ABI sceUsbdLockEventWaiters() { + LOG_DEBUG(Lib_Usbd, "called"); + + libusb_lock_event_waiters(g_libusb_context); } -int PS4_SYSV_ABI sceUsbdTryLockEvents() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +void PS4_SYSV_ABI sceUsbdUnlockEventWaiters() { + LOG_DEBUG(Lib_Usbd, "called"); + + libusb_unlock_event_waiters(g_libusb_context); } -int PS4_SYSV_ABI sceUsbdUnlockEvents() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdWaitForEvent(timeval* tv) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_to_orbis_error(libusb_wait_for_event(g_libusb_context, tv)); } -int PS4_SYSV_ABI sceUsbdUnlockEventWaiters() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdHandleEventsTimeout(timeval* tv) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_to_orbis_error(libusb_handle_events_timeout(g_libusb_context, tv)); } -int PS4_SYSV_ABI sceUsbdUnrefDevice() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdHandleEvents() { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_to_orbis_error(libusb_handle_events(g_libusb_context)); } -int PS4_SYSV_ABI sceUsbdWaitForEvent() { - LOG_ERROR(Lib_Usbd, "(STUBBED) called"); - return ORBIS_OK; +s32 PS4_SYSV_ABI sceUsbdHandleEventsLocked(timeval* tv) { + LOG_DEBUG(Lib_Usbd, "called"); + + return libusb_to_orbis_error(libusb_handle_events_locked(g_libusb_context, tv)); +} + +s32 PS4_SYSV_ABI sceUsbdCheckConnected(SceUsbdDeviceHandle* dev_handle) { + LOG_DEBUG(Lib_Usbd, "called"); + + // There's no libusb version of this function. + // Simulate by querying data. + + int config; + int r = libusb_get_configuration(dev_handle, &config); + + return libusb_to_orbis_error(r); } int PS4_SYSV_ABI Func_65F6EF33E38FFF50() { @@ -406,4 +550,4 @@ void RegisterlibSceUsbd(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("1WtDBgcgseA", "libSceUsbd", 1, "libSceUsbd", 1, 1, Func_D56B43060720B1E0); }; -} // namespace Libraries::Usbd +} // namespace Libraries::Usbd \ No newline at end of file diff --git a/src/core/libraries/usbd/usbd.h b/src/core/libraries/usbd/usbd.h index 4ed153587..3bd8134a7 100644 --- a/src/core/libraries/usbd/usbd.h +++ b/src/core/libraries/usbd/usbd.h @@ -1,76 +1,150 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX - FileCopyrightText : Copyright 2024 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once #include "common/types.h" +extern "C" { +struct libusb_device; +struct libusb_device_handle; +struct libusb_device_descriptor; +struct libusb_config_descriptor; +struct libusb_transfer; +struct libusb_control_setup; +struct timeval; +} + namespace Core::Loader { class SymbolsResolver; } + namespace Libraries::Usbd { -int PS4_SYSV_ABI sceUsbdAllocTransfer(); -int PS4_SYSV_ABI sceUsbdAttachKernelDriver(); -int PS4_SYSV_ABI sceUsbdBulkTransfer(); -int PS4_SYSV_ABI sceUsbdCancelTransfer(); -int PS4_SYSV_ABI sceUsbdCheckConnected(); -int PS4_SYSV_ABI sceUsbdClaimInterface(); -int PS4_SYSV_ABI sceUsbdClearHalt(); -int PS4_SYSV_ABI sceUsbdClose(); -int PS4_SYSV_ABI sceUsbdControlTransfer(); -int PS4_SYSV_ABI sceUsbdControlTransferGetData(); -int PS4_SYSV_ABI sceUsbdControlTransferGetSetup(); -int PS4_SYSV_ABI sceUsbdDetachKernelDriver(); -int PS4_SYSV_ABI sceUsbdEventHandlerActive(); -int PS4_SYSV_ABI sceUsbdEventHandlingOk(); -int PS4_SYSV_ABI sceUsbdExit(); -int PS4_SYSV_ABI sceUsbdFillBulkTransfer(); -int PS4_SYSV_ABI sceUsbdFillControlSetup(); -int PS4_SYSV_ABI sceUsbdFillControlTransfer(); -int PS4_SYSV_ABI sceUsbdFillInterruptTransfer(); -int PS4_SYSV_ABI sceUsbdFillIsoTransfer(); -int PS4_SYSV_ABI sceUsbdFreeConfigDescriptor(); -int PS4_SYSV_ABI sceUsbdFreeDeviceList(); -int PS4_SYSV_ABI sceUsbdFreeTransfer(); -int PS4_SYSV_ABI sceUsbdGetActiveConfigDescriptor(); -int PS4_SYSV_ABI sceUsbdGetBusNumber(); -int PS4_SYSV_ABI sceUsbdGetConfigDescriptor(); -int PS4_SYSV_ABI sceUsbdGetConfigDescriptorByValue(); -int PS4_SYSV_ABI sceUsbdGetConfiguration(); -int PS4_SYSV_ABI sceUsbdGetDescriptor(); -int PS4_SYSV_ABI sceUsbdGetDevice(); -int PS4_SYSV_ABI sceUsbdGetDeviceAddress(); -int PS4_SYSV_ABI sceUsbdGetDeviceDescriptor(); -int PS4_SYSV_ABI sceUsbdGetDeviceList(); -int PS4_SYSV_ABI sceUsbdGetDeviceSpeed(); -int PS4_SYSV_ABI sceUsbdGetIsoPacketBuffer(); -int PS4_SYSV_ABI sceUsbdGetMaxIsoPacketSize(); -int PS4_SYSV_ABI sceUsbdGetMaxPacketSize(); -int PS4_SYSV_ABI sceUsbdGetStringDescriptor(); -int PS4_SYSV_ABI sceUsbdGetStringDescriptorAscii(); -int PS4_SYSV_ABI sceUsbdHandleEvents(); -int PS4_SYSV_ABI sceUsbdHandleEventsLocked(); -int PS4_SYSV_ABI sceUsbdHandleEventsTimeout(); -int PS4_SYSV_ABI sceUsbdInit(); -int PS4_SYSV_ABI sceUsbdInterruptTransfer(); -int PS4_SYSV_ABI sceUsbdKernelDriverActive(); -int PS4_SYSV_ABI sceUsbdLockEvents(); -int PS4_SYSV_ABI sceUsbdLockEventWaiters(); -int PS4_SYSV_ABI sceUsbdOpen(); -int PS4_SYSV_ABI sceUsbdOpenDeviceWithVidPid(); -int PS4_SYSV_ABI sceUsbdRefDevice(); -int PS4_SYSV_ABI sceUsbdReleaseInterface(); -int PS4_SYSV_ABI sceUsbdResetDevice(); -int PS4_SYSV_ABI sceUsbdSetConfiguration(); -int PS4_SYSV_ABI sceUsbdSetInterfaceAltSetting(); -int PS4_SYSV_ABI sceUsbdSetIsoPacketLengths(); -int PS4_SYSV_ABI sceUsbdSubmitTransfer(); -int PS4_SYSV_ABI sceUsbdTryLockEvents(); -int PS4_SYSV_ABI sceUsbdUnlockEvents(); -int PS4_SYSV_ABI sceUsbdUnlockEventWaiters(); -int PS4_SYSV_ABI sceUsbdUnrefDevice(); -int PS4_SYSV_ABI sceUsbdWaitForEvent(); +using SceUsbdDevice = libusb_device; +using SceUsbdDeviceHandle = libusb_device_handle; +using SceUsbdDeviceDescriptor = libusb_device_descriptor; +using SceUsbdConfigDescriptor = libusb_config_descriptor; +using SceUsbdTransfer = libusb_transfer; +using SceUsbdControlSetup = libusb_control_setup; +using SceUsbdTransferCallback = void (*)(SceUsbdTransfer* transfer); + +enum class SceUsbdSpeed : u32 { + UNKNOWN = 0, + LOW = 1, + FULL = 2, + HIGH = 3, + SUPER = 4, + SUPER_PLUS = 5 +}; + +s32 PS4_SYSV_ABI sceUsbdInit(); +void PS4_SYSV_ABI sceUsbdExit(); + +s64 PS4_SYSV_ABI sceUsbdGetDeviceList(SceUsbdDevice*** list); +void PS4_SYSV_ABI sceUsbdFreeDeviceList(SceUsbdDevice** list, s32 unref_devices); + +SceUsbdDevice* PS4_SYSV_ABI sceUsbdRefDevice(SceUsbdDevice* device); +void PS4_SYSV_ABI sceUsbdUnrefDevice(SceUsbdDevice* device); + +s32 PS4_SYSV_ABI sceUsbdGetConfiguration(SceUsbdDeviceHandle* dev_handle, s32* config); +s32 PS4_SYSV_ABI sceUsbdGetDeviceDescriptor(SceUsbdDevice* device, SceUsbdDeviceDescriptor* desc); +s32 PS4_SYSV_ABI sceUsbdGetActiveConfigDescriptor(SceUsbdDevice* device, + SceUsbdConfigDescriptor** config); +s32 PS4_SYSV_ABI sceUsbdGetConfigDescriptor(SceUsbdDevice* device, u8 config_index, + SceUsbdConfigDescriptor** config); +s32 PS4_SYSV_ABI sceUsbdGetConfigDescriptorByValue(SceUsbdDevice* device, u8 bConfigurationValue, + SceUsbdConfigDescriptor** config); +void PS4_SYSV_ABI sceUsbdFreeConfigDescriptor(SceUsbdConfigDescriptor* config); + +u8 PS4_SYSV_ABI sceUsbdGetBusNumber(SceUsbdDevice* device); +u8 PS4_SYSV_ABI sceUsbdGetDeviceAddress(SceUsbdDevice* device); + +SceUsbdSpeed PS4_SYSV_ABI sceUsbdGetDeviceSpeed(SceUsbdDevice* device); +s32 PS4_SYSV_ABI sceUsbdGetMaxPacketSize(SceUsbdDevice* device, u8 endpoint); +s32 PS4_SYSV_ABI sceUsbdGetMaxIsoPacketSize(SceUsbdDevice* device, u8 endpoint); + +s32 PS4_SYSV_ABI sceUsbdOpen(SceUsbdDevice* device, SceUsbdDeviceHandle** dev_handle); +void PS4_SYSV_ABI sceUsbdClose(SceUsbdDeviceHandle* dev_handle); +SceUsbdDevice* PS4_SYSV_ABI sceUsbdGetDevice(SceUsbdDeviceHandle* dev_handle); + +s32 PS4_SYSV_ABI sceUsbdSetConfiguration(SceUsbdDeviceHandle* dev_handle, s32 config); +s32 PS4_SYSV_ABI sceUsbdClaimInterface(SceUsbdDeviceHandle* dev_handle, s32 interface_number); +s32 PS4_SYSV_ABI sceUsbdReleaseInterface(SceUsbdDeviceHandle* dev_handle, s32 interface_number); + +SceUsbdDeviceHandle* PS4_SYSV_ABI sceUsbdOpenDeviceWithVidPid(u16 vendor_id, u16 product_id); + +s32 PS4_SYSV_ABI sceUsbdSetInterfaceAltSetting(SceUsbdDeviceHandle* dev_handle, + int interface_number, int alternate_setting); +s32 PS4_SYSV_ABI sceUsbdClearHalt(SceUsbdDeviceHandle* dev_handle, u8 endpoint); +s32 PS4_SYSV_ABI sceUsbdResetDevice(SceUsbdDeviceHandle* dev_handle); + +s32 PS4_SYSV_ABI sceUsbdKernelDriverActive(SceUsbdDeviceHandle* dev_handle, int interface_number); +s32 PS4_SYSV_ABI sceUsbdDetachKernelDriver(SceUsbdDeviceHandle* dev_handle, int interface_number); +s32 PS4_SYSV_ABI sceUsbdAttachKernelDriver(SceUsbdDeviceHandle* dev_handle, int interface_number); + +u8* PS4_SYSV_ABI sceUsbdControlTransferGetData(SceUsbdTransfer* transfer); +SceUsbdControlSetup* PS4_SYSV_ABI sceUsbdControlTransferGetSetup(SceUsbdTransfer* transfer); + +void PS4_SYSV_ABI sceUsbdFillControlSetup(u8* buf, u8 bmRequestType, u8 bRequest, u16 wValue, + u16 wIndex, u16 wLength); + +SceUsbdTransfer* PS4_SYSV_ABI sceUsbdAllocTransfer(int iso_packets); +s32 PS4_SYSV_ABI sceUsbdSubmitTransfer(SceUsbdTransfer* transfer); +s32 PS4_SYSV_ABI sceUsbdCancelTransfer(SceUsbdTransfer* transfer); +void PS4_SYSV_ABI sceUsbdFreeTransfer(SceUsbdTransfer* transfer); + +void PS4_SYSV_ABI sceUsbdFillControlTransfer(SceUsbdTransfer* transfer, + SceUsbdDeviceHandle* dev_handle, u8* buffer, + SceUsbdTransferCallback callback, void* user_data, + u32 timeout); +void PS4_SYSV_ABI sceUsbdFillBulkTransfer(SceUsbdTransfer* transfer, + SceUsbdDeviceHandle* dev_handle, u8 endpoint, u8* buffer, + s32 length, SceUsbdTransferCallback callback, + void* user_data, u32 timeout); +void PS4_SYSV_ABI sceUsbdFillInterruptTransfer(SceUsbdTransfer* transfer, + SceUsbdDeviceHandle* dev_handle, u8 endpoint, + u8* buffer, s32 length, + SceUsbdTransferCallback callback, void* user_data, + u32 timeout); +void PS4_SYSV_ABI sceUsbdFillIsoTransfer(SceUsbdTransfer* transfer, SceUsbdDeviceHandle* dev_handle, + u8 endpoint, u8* buffer, s32 length, s32 num_iso_packets, + SceUsbdTransferCallback callback, void* userData, + u32 timeout); + +void PS4_SYSV_ABI sceUsbdSetIsoPacketLengths(SceUsbdTransfer* transfer, u32 length); +u8* PS4_SYSV_ABI sceUsbdGetIsoPacketBuffer(SceUsbdTransfer* transfer, u32 packet); + +s32 PS4_SYSV_ABI sceUsbdControlTransfer(SceUsbdDeviceHandle* dev_handle, u8 request_type, + u8 bRequest, u16 wValue, u16 wIndex, u8* data, s32 wLength, + u32 timeout); +s32 PS4_SYSV_ABI sceUsbdBulkTransfer(SceUsbdDeviceHandle* dev_handle, u8 endpoint, u8* data, + s32 length, s32* actual_length, u32 timeout); +s32 PS4_SYSV_ABI sceUsbdInterruptTransfer(SceUsbdDeviceHandle* dev_handle, u8 endpoint, u8* data, + s32 length, s32* actual_length, u32 timeout); + +s32 PS4_SYSV_ABI sceUsbdGetDescriptor(SceUsbdDeviceHandle* dev_handle, u8 descType, u8 descIndex, + u8* data, s32 length); +s32 PS4_SYSV_ABI sceUsbdGetStringDescriptor(SceUsbdDeviceHandle* dev_handle, u8 desc_index, + u16 langid, u8* data, s32 length); +s32 PS4_SYSV_ABI sceUsbdGetStringDescriptorAscii(SceUsbdDeviceHandle* dev_handle, u8 desc_index, + u8* data, s32 length); + +s32 PS4_SYSV_ABI sceUsbdTryLockEvents(); +void PS4_SYSV_ABI sceUsbdLockEvents(); +void PS4_SYSV_ABI sceUsbdUnlockEvents(); +s32 PS4_SYSV_ABI sceUsbdEventHandlingOk(); +s32 PS4_SYSV_ABI sceUsbdEventHandlerActive(); +void PS4_SYSV_ABI sceUsbdLockEventWaiters(); +void PS4_SYSV_ABI sceUsbdUnlockEventWaiters(); +s32 PS4_SYSV_ABI sceUsbdWaitForEvent(timeval* tv); + +s32 PS4_SYSV_ABI sceUsbdHandleEventsTimeout(timeval* tv); +s32 PS4_SYSV_ABI sceUsbdHandleEvents(); +s32 PS4_SYSV_ABI sceUsbdHandleEventsLocked(timeval* tv); + +s32 PS4_SYSV_ABI sceUsbdCheckConnected(SceUsbdDeviceHandle* dev_handle); + int PS4_SYSV_ABI Func_65F6EF33E38FFF50(); int PS4_SYSV_ABI Func_97F056BAD90AADE7(); int PS4_SYSV_ABI Func_C55104A33B35B264(); diff --git a/src/core/libraries/videoout/driver.cpp b/src/core/libraries/videoout/driver.cpp index 0f832910c..8f725e549 100644 --- a/src/core/libraries/videoout/driver.cpp +++ b/src/core/libraries/videoout/driver.cpp @@ -63,6 +63,7 @@ void VideoOutDriver::Close(s32 handle) { main_port.is_open = false; main_port.flip_rate = 0; + main_port.prev_index = -1; ASSERT(main_port.flip_events.empty()); } @@ -133,6 +134,10 @@ int VideoOutDriver::RegisterBuffers(VideoOutPort* port, s32 startIndex, void* co .address_right = 0, }; + // Reset flip label also when registering buffer + port->buffer_labels[startIndex + i] = 0; + port->SignalVoLabel(); + presenter->RegisterVideoOutSurface(group, address); LOG_INFO(Lib_VideoOut, "buffers[{}] = {:#x}", i + startIndex, address); } @@ -160,11 +165,8 @@ int VideoOutDriver::UnregisterBuffers(VideoOutPort* port, s32 attributeIndex) { } void VideoOutDriver::Flip(const Request& req) { - // Whatever the game is rendering show splash if it is active - if (!presenter->ShowSplash(req.frame)) { - // Present the frame. - presenter->Present(req.frame); - } + // Present the frame. + presenter->Present(req.frame); // Update flip status. auto* port = req.port; @@ -193,17 +195,16 @@ void VideoOutDriver::Flip(const Request& req) { } } - // Reset flip label - if (req.index != -1) { - port->buffer_labels[req.index] = 0; + // Reset prev flip label + if (port->prev_index != -1) { + port->buffer_labels[port->prev_index] = 0; port->SignalVoLabel(); } + // save to prev buf index + port->prev_index = req.index; } void VideoOutDriver::DrawBlankFrame() { - if (presenter->ShowSplash(nullptr)) { - return; - } const auto empty_frame = presenter->PrepareBlankFrame(false); presenter->Present(empty_frame); } diff --git a/src/core/libraries/videoout/driver.h b/src/core/libraries/videoout/driver.h index e57b189b5..3b0df43b9 100644 --- a/src/core/libraries/videoout/driver.h +++ b/src/core/libraries/videoout/driver.h @@ -32,6 +32,7 @@ struct VideoOutPort { std::condition_variable vo_cv; std::condition_variable vblank_cv; int flip_rate = 0; + int prev_index = -1; bool is_open = false; bool is_mode_changing = false; // Used to prevent flip during mode change diff --git a/src/core/libraries/videoout/video_out.cpp b/src/core/libraries/videoout/video_out.cpp index 91616a5ae..c5208b6dd 100644 --- a/src/core/libraries/videoout/video_out.cpp +++ b/src/core/libraries/videoout/video_out.cpp @@ -104,6 +104,20 @@ s32 PS4_SYSV_ABI sceVideoOutAddVblankEvent(Kernel::SceKernelEqueue eq, s32 handl return ORBIS_OK; } +s32 PS4_SYSV_ABI sceVideoOutDeleteVblankEvent(Kernel::SceKernelEqueue eq, s32 handle) { + auto* port = driver->GetPort(handle); + if (port == nullptr) { + return ORBIS_VIDEO_OUT_ERROR_INVALID_HANDLE; + } + + if (eq == nullptr) { + return ORBIS_VIDEO_OUT_ERROR_INVALID_EVENT_QUEUE; + } + eq->RemoveEvent(handle, Kernel::SceKernelEvent::Filter::VideoOut); + port->vblank_events.erase(find(port->vblank_events.begin(), port->vblank_events.end(), eq)); + return ORBIS_OK; +} + s32 PS4_SYSV_ABI sceVideoOutRegisterBuffers(s32 handle, s32 startIndex, void* const* addresses, s32 bufferNum, const BufferAttribute* attribute) { if (!addresses || !attribute) { @@ -166,7 +180,7 @@ s32 PS4_SYSV_ABI sceVideoOutSubmitFlip(s32 handle, s32 bufferIndex, s32 flipMode return ORBIS_OK; } -int PS4_SYSV_ABI sceVideoOutGetEventId(const Kernel::SceKernelEvent* ev) { +s32 PS4_SYSV_ABI sceVideoOutGetEventId(const Kernel::SceKernelEvent* ev) { if (ev == nullptr) { return ORBIS_VIDEO_OUT_ERROR_INVALID_ADDRESS; } @@ -194,7 +208,7 @@ int PS4_SYSV_ABI sceVideoOutGetEventId(const Kernel::SceKernelEvent* ev) { } } -int PS4_SYSV_ABI sceVideoOutGetEventData(const Kernel::SceKernelEvent* ev, int64_t* data) { +s32 PS4_SYSV_ABI sceVideoOutGetEventData(const Kernel::SceKernelEvent* ev, s64* data) { if (ev == nullptr || data == nullptr) { return ORBIS_VIDEO_OUT_ERROR_INVALID_ADDRESS; } @@ -206,11 +220,23 @@ int PS4_SYSV_ABI sceVideoOutGetEventData(const Kernel::SceKernelEvent* ev, int64 if (ev->ident != static_cast(OrbisVideoOutInternalEventId::Flip) || ev->data == 0) { *data = event_data; } else { - *data = event_data | 0xFFFF000000000000; + *data = event_data | 0xffff000000000000; } return ORBIS_OK; } +s32 PS4_SYSV_ABI sceVideoOutGetEventCount(const Kernel::SceKernelEvent* ev) { + if (ev == nullptr) { + return ORBIS_VIDEO_OUT_ERROR_INVALID_ADDRESS; + } + if (ev->filter != Kernel::SceKernelEvent::Filter::VideoOut) { + return ORBIS_VIDEO_OUT_ERROR_INVALID_EVENT; + } + + auto event_data = static_cast(ev->data); + return event_data.count; +} + s32 PS4_SYSV_ABI sceVideoOutGetFlipStatus(s32 handle, FlipStatus* status) { if (!status) { LOG_ERROR(Lib_VideoOut, "Flip status is null"); @@ -295,10 +321,16 @@ s32 PS4_SYSV_ABI sceVideoOutUnregisterBuffers(s32 handle, s32 attributeIndex) { return driver->UnregisterBuffers(port, attributeIndex); } -void sceVideoOutGetBufferLabelAddress(s32 handle, uintptr_t* label_addr) { +s32 PS4_SYSV_ABI sceVideoOutGetBufferLabelAddress(s32 handle, uintptr_t* label_addr) { + if (label_addr == nullptr) { + return ORBIS_VIDEO_OUT_ERROR_INVALID_ADDRESS; + } auto* port = driver->GetPort(handle); - ASSERT(port); + if (!port) { + return ORBIS_VIDEO_OUT_ERROR_INVALID_HANDLE; + } *label_addr = reinterpret_cast(port->buffer_labels.data()); + return 16; } s32 sceVideoOutSubmitEopFlip(s32 handle, u32 buf_id, u32 mode, u32 arg, void** unk) { @@ -360,7 +392,7 @@ s32 PS4_SYSV_ABI sceVideoOutAdjustColor(s32 handle, const SceVideoOutColorSettin return ORBIS_VIDEO_OUT_ERROR_INVALID_HANDLE; } - presenter->GetGammaRef() = settings->gamma; + presenter->GetPPSettingsRef().gamma = settings->gamma; return ORBIS_OK; } @@ -430,6 +462,8 @@ void RegisterLib(Core::Loader::SymbolsResolver* sym) { sceVideoOutIsFlipPending); LIB_FUNCTION("N5KDtkIjjJ4", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutUnregisterBuffers); + LIB_FUNCTION("OcQybQejHEY", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, + sceVideoOutGetBufferLabelAddress); LIB_FUNCTION("uquVH4-Du78", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutClose); LIB_FUNCTION("1FZBKy8HeNU", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutGetVblankStatus); @@ -439,12 +473,16 @@ void RegisterLib(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("U2JJtSqNKZI", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutGetEventId); LIB_FUNCTION("rWUTcKdkUzQ", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutGetEventData); + LIB_FUNCTION("Mt4QHHkxkOc", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, + sceVideoOutGetEventCount); LIB_FUNCTION("DYhhWbJSeRg", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutColorSettingsSetGamma); LIB_FUNCTION("pv9CI5VC+R0", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutAdjustColor); LIB_FUNCTION("-Ozn0F1AFRg", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutDeleteFlipEvent); + LIB_FUNCTION("oNOQn3knW6s", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, + sceVideoOutDeleteVblankEvent); LIB_FUNCTION("pjkDsgxli6c", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutModeSetAny_); LIB_FUNCTION("N1bEoJ4SRw4", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, @@ -460,6 +498,8 @@ void RegisterLib(Core::Loader::SymbolsResolver* sym) { sceVideoOutSetBufferAttribute); LIB_FUNCTION("w3BY+tAEiQY", "libSceVideoOut", 1, "libSceVideoOut", 1, 1, sceVideoOutRegisterBuffers); + LIB_FUNCTION("OcQybQejHEY", "libSceVideoOut", 1, "libSceVideoOut", 1, 1, + sceVideoOutGetBufferLabelAddress); LIB_FUNCTION("U46NwOiJpys", "libSceVideoOut", 1, "libSceVideoOut", 1, 1, sceVideoOutSubmitFlip); LIB_FUNCTION("SbU3dwp80lQ", "libSceVideoOut", 1, "libSceVideoOut", 1, 1, sceVideoOutGetFlipStatus); diff --git a/src/core/libraries/videoout/video_out.h b/src/core/libraries/videoout/video_out.h index ad8ce9ed2..7db09530b 100644 --- a/src/core/libraries/videoout/video_out.h +++ b/src/core/libraries/videoout/video_out.h @@ -111,6 +111,12 @@ struct SceVideoOutColorSettings { u32 reserved[3]; }; +struct OrbisVideoOutEventData { + u64 time : 12; + u64 count : 4; + u64 flip_arg : 48; +}; + void PS4_SYSV_ABI sceVideoOutSetBufferAttribute(BufferAttribute* attribute, PixelFormat pixelFormat, u32 tilingMode, u32 aspectRatio, u32 width, u32 height, u32 pitchInPixel); @@ -118,6 +124,7 @@ s32 PS4_SYSV_ABI sceVideoOutAddFlipEvent(Kernel::SceKernelEqueue eq, s32 handle, s32 PS4_SYSV_ABI sceVideoOutAddVblankEvent(Kernel::SceKernelEqueue eq, s32 handle, void* udata); s32 PS4_SYSV_ABI sceVideoOutRegisterBuffers(s32 handle, s32 startIndex, void* const* addresses, s32 bufferNum, const BufferAttribute* attribute); +s32 PS4_SYSV_ABI sceVideoOutGetBufferLabelAddress(s32 handle, uintptr_t* label_addr); s32 PS4_SYSV_ABI sceVideoOutSetFlipRate(s32 handle, s32 rate); s32 PS4_SYSV_ABI sceVideoOutIsFlipPending(s32 handle); s32 PS4_SYSV_ABI sceVideoOutWaitVblank(s32 handle); @@ -127,13 +134,12 @@ s32 PS4_SYSV_ABI sceVideoOutGetResolutionStatus(s32 handle, SceVideoOutResolutio s32 PS4_SYSV_ABI sceVideoOutOpen(SceUserServiceUserId userId, s32 busType, s32 index, const void* param); s32 PS4_SYSV_ABI sceVideoOutClose(s32 handle); -int PS4_SYSV_ABI sceVideoOutGetEventId(const Kernel::SceKernelEvent* ev); -int PS4_SYSV_ABI sceVideoOutGetEventData(const Kernel::SceKernelEvent* ev, int64_t* data); +s32 PS4_SYSV_ABI sceVideoOutGetEventId(const Kernel::SceKernelEvent* ev); +s32 PS4_SYSV_ABI sceVideoOutGetEventData(const Kernel::SceKernelEvent* ev, s64* data); s32 PS4_SYSV_ABI sceVideoOutColorSettingsSetGamma(SceVideoOutColorSettings* settings, float gamma); s32 PS4_SYSV_ABI sceVideoOutAdjustColor(s32 handle, const SceVideoOutColorSettings* settings); // Internal system functions -void sceVideoOutGetBufferLabelAddress(s32 handle, uintptr_t* label_addr); s32 sceVideoOutSubmitEopFlip(s32 handle, u32 buf_id, u32 mode, u32 arg, void** unk); void RegisterLib(Core::Loader::SymbolsResolver* sym); diff --git a/src/core/linker.cpp b/src/core/linker.cpp index 2461edcb2..0f86376af 100644 --- a/src/core/linker.cpp +++ b/src/core/linker.cpp @@ -101,6 +101,17 @@ void Linker::Execute(const std::vector args) { memory->SetupMemoryRegions(fmem_size, use_extended_mem1, use_extended_mem2); + // Simulate sceKernelInternalMemory mapping, a mapping usually performed during libkernel init. + // Due to the large size of this mapping, failing to emulate it causes issues in some titles. + // This mapping belongs in the system reserved area, which starts at address 0x880000000. + static constexpr VAddr KernelAllocBase = 0x880000000ULL; + static constexpr s64 InternalMemorySize = 0x1000000; + void* addr_out{reinterpret_cast(KernelAllocBase)}; + + s32 ret = Libraries::Kernel::sceKernelMapNamedFlexibleMemory(&addr_out, InternalMemorySize, 3, + 0, "SceKernelInternalMemory"); + ASSERT_MSG(ret == 0, "Unable to perform sceKernelInternalMemory mapping"); + main_thread.Run([this, module, args](std::stop_token) { Common::SetCurrentThreadName("GAME_MainThread"); LoadSharedLibraries(); @@ -139,6 +150,35 @@ s32 Linker::LoadModule(const std::filesystem::path& elf_name, bool is_dynamic) { return m_modules.size() - 1; } +s32 Linker::LoadAndStartModule(const std::filesystem::path& path, u64 args, const void* argp, + int* pRes) { + u32 handle = FindByName(path); + if (handle != -1) { + return handle; + } + handle = LoadModule(path, true); + if (handle == -1) { + return -1; + } + auto* module = GetModule(handle); + RelocateAnyImports(module); + + // If the new module has a TLS image, trigger its load when TlsGetAddr is called. + if (module->tls.image_size != 0) { + AdvanceGenerationCounter(); + } + + // Retrieve and verify proc param according to libkernel. + u64* param = module->GetProcParam(); + ASSERT_MSG(!param || param[0] >= 0x18, "Invalid module param size: {}", param[0]); + s32 ret = module->Start(args, argp, param); + if (pRes) { + *pRes = ret; + } + + return handle; +} + Module* Linker::FindByAddress(VAddr address) { for (auto& module : m_modules) { const VAddr base = module->GetBaseAddress(); @@ -343,7 +383,8 @@ void* Linker::AllocateTlsForThread(bool is_primary) { // If sceKernelMapNamedFlexibleMemory is being called from libkernel and addr = 0 // it automatically places mappings in system reserved area instead of managed. - static constexpr VAddr KernelAllocBase = 0x880000000ULL; + // Since the system reserved area already has a mapping in it, this address is slightly higher. + static constexpr VAddr KernelAllocBase = 0x881000000ULL; // The kernel module has a few different paths for TLS allocation. // For SDK < 1.7 it allocates both main and secondary thread blocks using libc mspace/malloc. diff --git a/src/core/linker.h b/src/core/linker.h index 9c07400c4..028e18ead 100644 --- a/src/core/linker.h +++ b/src/core/linker.h @@ -83,7 +83,7 @@ public: } Module* GetModule(s32 index) const { - if (index >= 0 || index < m_modules.size()) { + if (index >= 0 && index < m_modules.size()) { return m_modules.at(index).get(); } return nullptr; @@ -144,6 +144,8 @@ public: void FreeTlsForNonPrimaryThread(void* pointer); s32 LoadModule(const std::filesystem::path& elf_name, bool is_dynamic = false); + s32 LoadAndStartModule(const std::filesystem::path& path, u64 args, const void* argp, + int* pRes); Module* FindByAddress(VAddr address); void Relocate(Module* module); diff --git a/src/core/loader.cpp b/src/core/loader.cpp deleted file mode 100644 index f80bfbb81..000000000 --- a/src/core/loader.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "common/io_file.h" -#include "common/types.h" -#include "loader.h" - -namespace Loader { - -FileTypes DetectFileType(const std::filesystem::path& filepath) { - // No file loaded - if (filepath.empty()) { - return FileTypes::Unknown; - } - Common::FS::IOFile file; - file.Open(filepath, Common::FS::FileAccessMode::Read); - file.Seek(0); - u32 magic; - file.Read(magic); - file.Close(); - switch (magic) { - case PkgMagic: - return FileTypes::Pkg; - } - return FileTypes::Unknown; -} - -} // namespace Loader diff --git a/src/core/loader.h b/src/core/loader.h deleted file mode 100644 index 608970dca..000000000 --- a/src/core/loader.h +++ /dev/null @@ -1,18 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include - -namespace Loader { - -constexpr static u32 PkgMagic = 0x544e437f; - -enum class FileTypes { - Unknown, - Pkg, -}; - -FileTypes DetectFileType(const std::filesystem::path& filepath); -} // namespace Loader diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 98d587e00..494ffa70c 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -38,6 +38,16 @@ void MemoryManager::SetupMemoryRegions(u64 flexible_size, bool use_extended_mem1 bool use_extended_mem2) { const bool is_neo = ::Libraries::Kernel::sceKernelIsNeoMode(); auto total_size = is_neo ? SCE_KERNEL_TOTAL_MEM_PRO : SCE_KERNEL_TOTAL_MEM; + if (Config::isDevKitConsole()) { + const auto old_size = total_size; + // Assuming 2gb is neo for now, will need to link it with sceKernelIsDevKit + total_size += is_neo ? 2_GB : 768_MB; + LOG_WARNING(Kernel_Vmm, + "Config::isDevKitConsole is enabled! Added additional {:s} of direct memory.", + is_neo ? "2 GB" : "768 MB"); + LOG_WARNING(Kernel_Vmm, "Old Direct Size: {:#x} -> New Direct Size: {:#x}", old_size, + total_size); + } if (!use_extended_mem1 && is_neo) { total_size -= 256_MB; } @@ -129,35 +139,33 @@ PAddr MemoryManager::Allocate(PAddr search_start, PAddr search_end, size_t size, alignment = alignment > 0 ? alignment : 16_KB; auto dmem_area = FindDmemArea(search_start); + auto mapping_start = search_start > dmem_area->second.base + ? Common::AlignUp(search_start, alignment) + : Common::AlignUp(dmem_area->second.base, alignment); + auto mapping_end = mapping_start + size; - const auto is_suitable = [&] { - if (dmem_area == dmem_map.end()) { - return false; - } - const auto aligned_base = Common::AlignUp(dmem_area->second.base, alignment); - const auto alignment_size = aligned_base - dmem_area->second.base; - const auto remaining_size = - dmem_area->second.size >= alignment_size ? dmem_area->second.size - alignment_size : 0; - return dmem_area->second.is_free && remaining_size >= size; - }; - while (dmem_area != dmem_map.end() && !is_suitable() && - dmem_area->second.GetEnd() <= search_end) { - ++dmem_area; + // Find the first free, large enough dmem area in the range. + while ((!dmem_area->second.is_free || dmem_area->second.GetEnd() < mapping_end) && + dmem_area != dmem_map.end()) { + // The current dmem_area isn't suitable, move to the next one. + dmem_area++; + + // Update local variables based on the new dmem_area + mapping_start = Common::AlignUp(dmem_area->second.base, alignment); + mapping_end = mapping_start + size; } - if (!is_suitable()) { + + if (dmem_area == dmem_map.end()) { + // There are no suitable mappings in this range LOG_ERROR(Kernel_Vmm, "Unable to find free direct memory area: size = {:#x}", size); return -1; } - // Align free position - PAddr free_addr = dmem_area->second.base; - free_addr = Common::AlignUp(free_addr, alignment); - // Add the allocated region to the list and commit its pages. - auto& area = CarveDmemArea(free_addr, size)->second; + auto& area = CarveDmemArea(mapping_start, size)->second; area.memory_type = memory_type; area.is_free = false; - return free_addr; + return mapping_start; } void MemoryManager::Free(PAddr phys_addr, size_t size) { @@ -622,17 +630,34 @@ int MemoryManager::DirectQueryAvailable(PAddr search_start, PAddr search_end, si auto dmem_area = FindDmemArea(search_start); PAddr paddr{}; size_t max_size{}; - while (dmem_area != dmem_map.end() && dmem_area->second.GetEnd() <= search_end) { + + while (dmem_area != dmem_map.end()) { if (!dmem_area->second.is_free) { dmem_area++; continue; } - const auto aligned_base = alignment > 0 ? Common::AlignUp(dmem_area->second.base, alignment) - : dmem_area->second.base; + auto aligned_base = alignment > 0 ? Common::AlignUp(dmem_area->second.base, alignment) + : dmem_area->second.base; const auto alignment_size = aligned_base - dmem_area->second.base; - const auto remaining_size = + auto remaining_size = dmem_area->second.size >= alignment_size ? dmem_area->second.size - alignment_size : 0; + + if (dmem_area->second.base < search_start) { + // We need to trim remaining_size to ignore addresses before search_start + remaining_size = remaining_size > (search_start - dmem_area->second.base) + ? remaining_size - (search_start - dmem_area->second.base) + : 0; + aligned_base = alignment > 0 ? Common::AlignUp(search_start, alignment) : search_start; + } + + if (dmem_area->second.GetEnd() > search_end) { + // We need to trim remaining_size to ignore addresses beyond search_end + remaining_size = remaining_size > (dmem_area->second.GetEnd() - search_end) + ? remaining_size - (dmem_area->second.GetEnd() - search_end) + : 0; + } + if (remaining_size > max_size) { paddr = aligned_base; max_size = remaining_size; diff --git a/src/core/module.cpp b/src/core/module.cpp index 70afb932c..cbe44457c 100644 --- a/src/core/module.cpp +++ b/src/core/module.cpp @@ -1,13 +1,12 @@ // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include - #include "common/alignment.h" #include "common/arch.h" #include "common/assert.h" #include "common/logging/log.h" #include "common/memory_patcher.h" +#include "common/sha1.h" #include "common/string_util.h" #include "core/aerolib/aerolib.h" #include "core/cpu_patches.h" @@ -65,11 +64,13 @@ static std::string StringToNid(std::string_view symbol) { std::memcpy(input.data(), symbol.data(), symbol.size()); std::memcpy(input.data() + symbol.size(), Salt.data(), Salt.size()); - std::array hash; - CryptoPP::SHA1().CalculateDigest(hash.data(), input.data(), input.size()); + sha1::SHA1::digest8_t hash; + sha1::SHA1 sha; + sha.processBytes(input.data(), input.size()); + sha.getDigestBytes(hash); u64 digest; - std::memcpy(&digest, hash.data(), sizeof(digest)); + std::memcpy(&digest, hash, sizeof(digest)); static constexpr std::string_view codes = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-"; @@ -94,7 +95,7 @@ Module::Module(Core::MemoryManager* memory_, const std::filesystem::path& file_, Module::~Module() = default; -s32 Module::Start(size_t args, const void* argp, void* param) { +s32 Module::Start(u64 args, const void* argp, void* param) { LOG_INFO(Core_Linker, "Module started : {}", name); const VAddr addr = dynamic_info.init_virtual_addr + GetBaseAddress(); return ExecuteGuest(reinterpret_cast(addr), args, argp, param); @@ -134,10 +135,14 @@ void Module::LoadModuleToMemory(u32& max_tls_index) { if (do_map) { elf.LoadSegment(segment_addr, phdr.p_offset, phdr.p_filesz); } - auto& segment = info.segments[info.num_segments++]; - segment.address = segment_addr; - segment.prot = phdr.p_flags; - segment.size = GetAlignedSize(phdr); + if (info.num_segments < 4) { + auto& segment = info.segments[info.num_segments++]; + segment.address = segment_addr; + segment.prot = phdr.p_flags; + segment.size = GetAlignedSize(phdr); + } else { + LOG_ERROR(Core_Linker, "Attempting to add too many segments!"); + } }; for (u16 i = 0; i < elf_header.e_phnum; i++) { diff --git a/src/core/module.h b/src/core/module.h index 630c5d583..320680485 100644 --- a/src/core/module.h +++ b/src/core/module.h @@ -203,7 +203,7 @@ public: return (rela_bits[index >> 3] >> (index & 7)) & 1; } - s32 Start(size_t args, const void* argp, void* param); + s32 Start(u64 args, const void* argp, void* param); void LoadModuleToMemory(u32& max_tls_index); void LoadDynamicInfo(); void LoadSymbols(); diff --git a/src/core/tls.cpp b/src/core/tls.cpp index 9b3178171..e13c683e1 100644 --- a/src/core/tls.cpp +++ b/src/core/tls.cpp @@ -5,7 +5,6 @@ #include "common/arch.h" #include "common/assert.h" #include "common/types.h" -#include "core/cpu_patches.h" #include "core/libraries/kernel/threads/pthread.h" #include "core/tls.h" @@ -197,12 +196,7 @@ Tcb* GetTcbBase() { thread_local std::once_flag init_tls_flag; void EnsureThreadInitialized() { - std::call_once(init_tls_flag, [] { -#ifdef ARCH_X86_64 - InitializeThreadPatchStack(); -#endif - SetTcbBase(Libraries::Kernel::g_curthread->tcb); - }); + std::call_once(init_tls_flag, [] { SetTcbBase(Libraries::Kernel::g_curthread->tcb); }); } } // namespace Core diff --git a/src/emulator.cpp b/src/emulator.cpp index 2b770c612..692bac78a 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -22,9 +22,7 @@ #include "common/polyfill_thread.h" #include "common/scm_rev.h" #include "common/singleton.h" -#include "common/version.h" #include "core/file_format/psf.h" -#include "core/file_format/splash.h" #include "core/file_format/trp.h" #include "core/file_sys/fs.h" #include "core/libraries/disc_map/disc_map.h" @@ -81,7 +79,7 @@ void Emulator::Run(const std::filesystem::path& file, const std::vectorGetHostPath("/app0/sce_sys/pic1.png"); if (std::filesystem::exists(pic1_path)) { - auto* splash = Common::Singleton::Instance(); - if (!splash->IsLoaded()) { - if (!splash->Open(pic1_path)) { - LOG_ERROR(Loader, "Game splash: unable to open file"); - } - } + game_info.splash_path = pic1_path; } game_info.initialized = true; @@ -203,8 +196,8 @@ void Emulator::Run(const std::filesystem::path& file, const std::vector", id, title, app_version); std::string window_title = ""; - if (Common::isRelease) { - window_title = fmt::format("shadPS4 v{} | {}", Common::VERSION, game_title); + if (Common::g_is_release) { + window_title = fmt::format("shadPS4 v{} | {}", Common::g_version, game_title); } else { std::string remote_url(Common::g_scm_remote_url); std::string remote_host; @@ -214,10 +207,10 @@ void Emulator::Run(const std::filesystem::path& file, const std::vector ModulesToLoad{ + constexpr std::array ModulesToLoad{ {{"libSceNgs2.sprx", &Libraries::Ngs2::RegisterlibSceNgs2}, {"libSceUlt.sprx", nullptr}, {"libSceJson.sprx", nullptr}, {"libSceJson2.sprx", nullptr}, {"libSceLibcInternal.sprx", &Libraries::LibcInternal::RegisterlibSceLibcInternal}, - {"libSceDiscMap.sprx", &Libraries::DiscMap::RegisterlibSceDiscMap}, {"libSceRtc.sprx", &Libraries::Rtc::RegisterlibSceRtc}, {"libSceCesCs.sprx", nullptr}, {"libSceFont.sprx", nullptr}, diff --git a/src/images/KBM.png b/src/images/KBM.png new file mode 100644 index 000000000..37f52d549 Binary files /dev/null and b/src/images/KBM.png differ diff --git a/src/images/controller_icon.png b/src/images/controller_icon.png index 40c92a89b..0d5556329 100644 Binary files a/src/images/controller_icon.png and b/src/images/controller_icon.png differ diff --git a/src/images/discord.png b/src/images/discord.png index 2fa455fd1..9858f217e 100644 Binary files a/src/images/discord.png and b/src/images/discord.png differ diff --git a/src/images/discord.svg b/src/images/discord.svg new file mode 100644 index 000000000..a2f630923 --- /dev/null +++ b/src/images/discord.svg @@ -0,0 +1,24 @@ + + + + diff --git a/src/images/fullscreen_icon.png b/src/images/fullscreen_icon.png new file mode 100644 index 000000000..719ffe4a1 Binary files /dev/null and b/src/images/fullscreen_icon.png differ diff --git a/src/images/github.png b/src/images/github.png index 22b101798..7b61598cc 100644 Binary files a/src/images/github.png and b/src/images/github.png differ diff --git a/src/images/github.svg b/src/images/github.svg new file mode 100644 index 000000000..1872a00ce --- /dev/null +++ b/src/images/github.svg @@ -0,0 +1,22 @@ + + + + diff --git a/src/images/ko-fi.png b/src/images/ko-fi.png index d19991b5f..ec0c94773 100644 Binary files a/src/images/ko-fi.png and b/src/images/ko-fi.png differ diff --git a/src/images/ko-fi.svg b/src/images/ko-fi.svg new file mode 100644 index 000000000..b8fd694fd --- /dev/null +++ b/src/images/ko-fi.svg @@ -0,0 +1,22 @@ + + + + diff --git a/src/images/pause_icon.png b/src/images/pause_icon.png index 5375689b7..86bbc6acb 100644 Binary files a/src/images/pause_icon.png and b/src/images/pause_icon.png differ diff --git a/src/images/play_icon.png b/src/images/play_icon.png index 2815be39d..d50d404b7 100644 Binary files a/src/images/play_icon.png and b/src/images/play_icon.png differ diff --git a/src/images/refresh_icon.png b/src/images/refresh_icon.png deleted file mode 100644 index 00fe69c20..000000000 Binary files a/src/images/refresh_icon.png and /dev/null differ diff --git a/src/images/refreshlist_icon.png b/src/images/refreshlist_icon.png new file mode 100644 index 000000000..7de6685b2 Binary files /dev/null and b/src/images/refreshlist_icon.png differ diff --git a/src/images/restart_game_icon.png b/src/images/restart_game_icon.png new file mode 100644 index 000000000..1e549e101 Binary files /dev/null and b/src/images/restart_game_icon.png differ diff --git a/src/images/settings_icon.png b/src/images/settings_icon.png index c88cd7a6f..81127bfa3 100644 Binary files a/src/images/settings_icon.png and b/src/images/settings_icon.png differ diff --git a/src/images/shadps4.ico b/src/images/shadps4.ico index bb50f9995..870569def 100644 Binary files a/src/images/shadps4.ico and b/src/images/shadps4.ico differ diff --git a/src/images/shadps4.png b/src/images/shadps4.png new file mode 100644 index 000000000..037732e3b Binary files /dev/null and b/src/images/shadps4.png differ diff --git a/src/images/shadps4.svg b/src/images/shadps4.svg new file mode 100644 index 000000000..0243f550b --- /dev/null +++ b/src/images/shadps4.svg @@ -0,0 +1,105 @@ + + diff --git a/src/images/stop_icon.png b/src/images/stop_icon.png index 74c615f65..55b6b01c7 100644 Binary files a/src/images/stop_icon.png and b/src/images/stop_icon.png differ diff --git a/src/images/trophy_icon.png b/src/images/trophy_icon.png new file mode 100644 index 000000000..559e7dbb2 Binary files /dev/null and b/src/images/trophy_icon.png differ diff --git a/src/images/website.png b/src/images/website.png index 9584f6b82..e872e60a2 100644 Binary files a/src/images/website.png and b/src/images/website.png differ diff --git a/src/images/website.svg b/src/images/website.svg new file mode 100644 index 000000000..eddc0e194 --- /dev/null +++ b/src/images/website.svg @@ -0,0 +1,22 @@ + + + + diff --git a/src/images/youtube.png b/src/images/youtube.png index 362ac5781..2a69760e6 100644 Binary files a/src/images/youtube.png and b/src/images/youtube.png differ diff --git a/src/images/youtube.svg b/src/images/youtube.svg new file mode 100644 index 000000000..977e2b7ff --- /dev/null +++ b/src/images/youtube.svg @@ -0,0 +1,28 @@ + + + + + + diff --git a/src/imgui/imgui_std.h b/src/imgui/imgui_std.h index cd7208064..743702657 100644 --- a/src/imgui/imgui_std.h +++ b/src/imgui/imgui_std.h @@ -50,14 +50,14 @@ inline void KeepWindowInside(ImVec2 display_size = GetIO().DisplaySize) { } inline void KeepNavHighlight() { - GetCurrentContext()->NavDisableHighlight = false; + GetCurrentContext()->NavCursorVisible = true; } inline void SetItemCurrentNavFocus(const ImGuiID id = -1) { const auto ctx = GetCurrentContext(); SetFocusID(id == -1 ? ctx->LastItemData.ID : id, ctx->CurrentWindow); ctx->NavInitResult.Clear(); - ctx->NavDisableHighlight = false; + ctx->NavCursorVisible = true; } inline void DrawPrettyBackground() { diff --git a/src/imgui/imgui_texture.h b/src/imgui/imgui_texture.h index 1a38066d0..d84eda6b7 100644 --- a/src/imgui/imgui_texture.h +++ b/src/imgui/imgui_texture.h @@ -4,8 +4,11 @@ #pragma once #include +#include #include +#include "common/types.h" + namespace ImGui { namespace Core::TextureManager { diff --git a/src/imgui/renderer/imgui_core.cpp b/src/imgui/renderer/imgui_core.cpp index 50ce41ebf..d143232dc 100644 --- a/src/imgui/renderer/imgui_core.cpp +++ b/src/imgui/renderer/imgui_core.cpp @@ -112,6 +112,8 @@ void Initialize(const ::Vulkan::Instance& instance, const Frontend::WindowSDL& w if (const auto dpi = SDL_GetWindowDisplayScale(window.GetSDLWindow()); dpi > 0.0f) { GetIO().FontGlobalScale = dpi; } + + std::at_quick_exit([] { SaveIniSettingsToDisk(GetIO().IniFilename); }); } void OnResize() { diff --git a/src/imgui/renderer/texture_manager.cpp b/src/imgui/renderer/texture_manager.cpp index e217cd130..49f912a92 100644 --- a/src/imgui/renderer/texture_manager.cpp +++ b/src/imgui/renderer/texture_manager.cpp @@ -175,6 +175,7 @@ void WorkerLoop() { auto texture = Vulkan::UploadTexture(pixels, vk::Format::eR8G8B8A8Unorm, width, height, width * height * 4 * sizeof(stbi_uc)); + stbi_image_free((void*)pixels); core->upload_data = texture; core->width = width; diff --git a/src/input/input_handler.cpp b/src/input/input_handler.cpp index 6e961043e..3e2d66a6b 100644 --- a/src/input/input_handler.cpp +++ b/src/input/input_handler.cpp @@ -22,7 +22,6 @@ #include "common/elf_info.h" #include "common/io_file.h" #include "common/path_util.h" -#include "common/version.h" #include "input/controller.h" #include "input/input_mouse.h" @@ -551,18 +550,18 @@ void ControllerOutput::FinalizeUpdate() { break; case Axis::TriggerLeft: ApplyDeadzone(new_param, lefttrigger_deadzone); - controller->Axis(0, c_axis, GetAxis(0x0, 0x80, *new_param)); + controller->Axis(0, c_axis, GetAxis(0x0, 0x7f, *new_param)); controller->CheckButton(0, OrbisPadButtonDataOffset::L2, *new_param > 0x20); return; case Axis::TriggerRight: ApplyDeadzone(new_param, righttrigger_deadzone); - controller->Axis(0, c_axis, GetAxis(0x0, 0x80, *new_param)); + controller->Axis(0, c_axis, GetAxis(0x0, 0x7f, *new_param)); controller->CheckButton(0, OrbisPadButtonDataOffset::R2, *new_param > 0x20); return; default: break; } - controller->Axis(0, c_axis, GetAxis(-0x80, 0x80, *new_param * multiplier)); + controller->Axis(0, c_axis, GetAxis(-0x80, 0x7f, *new_param * multiplier)); } } diff --git a/src/input/input_mouse.cpp b/src/input/input_mouse.cpp index 11feaeebb..c84d14b3f 100644 --- a/src/input/input_mouse.cpp +++ b/src/input/input_mouse.cpp @@ -61,11 +61,11 @@ Uint32 MousePolling(void* param, Uint32 id, Uint32 interval) { float a_x = cos(angle) * output_speed, a_y = sin(angle) * output_speed; if (d_x != 0 && d_y != 0) { - controller->Axis(0, axis_x, GetAxis(-0x80, 0x80, a_x)); - controller->Axis(0, axis_y, GetAxis(-0x80, 0x80, a_y)); + controller->Axis(0, axis_x, GetAxis(-0x80, 0x7f, a_x)); + controller->Axis(0, axis_y, GetAxis(-0x80, 0x7f, a_y)); } else { - controller->Axis(0, axis_x, GetAxis(-0x80, 0x80, 0)); - controller->Axis(0, axis_y, GetAxis(-0x80, 0x80, 0)); + controller->Axis(0, axis_x, GetAxis(-0x80, 0x7f, 0)); + controller->Axis(0, axis_y, GetAxis(-0x80, 0x7f, 0)); } return interval; diff --git a/src/main.cpp b/src/main.cpp index 6b334e446..85581774b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -154,7 +154,7 @@ int main(int argc, char* argv[]) { // If no game directory is set and no command line argument, prompt for it if (Config::getGameInstallDirs().empty()) { std::cout << "Warning: No game folder set, please set it by calling shadps4" - " with the --add-game-folder argument"; + " with the --add-game-folder argument\n"; } if (!has_game_argument) { diff --git a/src/qt_gui/about_dialog.ui b/src/qt_gui/about_dialog.ui index 3842513a5..0e9ef222c 100644 --- a/src/qt_gui/about_dialog.ui +++ b/src/qt_gui/about_dialog.ui @@ -35,7 +35,7 @@ - :/images/shadps4.ico + :/images/shadps4.png true diff --git a/src/qt_gui/background_music_player.cpp b/src/qt_gui/background_music_player.cpp index a63f1d1be..e2b7177b3 100644 --- a/src/qt_gui/background_music_player.cpp +++ b/src/qt_gui/background_music_player.cpp @@ -40,4 +40,5 @@ void BackgroundMusicPlayer::playMusic(const QString& snd0path, bool loops) { void BackgroundMusicPlayer::stopMusic() { m_mediaPlayer->stop(); + m_mediaPlayer->setSource(QUrl("")); } diff --git a/src/qt_gui/cheats_patches.cpp b/src/qt_gui/cheats_patches.cpp index 7239affd5..67f616f87 100644 --- a/src/qt_gui/cheats_patches.cpp +++ b/src/qt_gui/cheats_patches.cpp @@ -1387,7 +1387,7 @@ void CheatsPatches::applyPatch(const QString& patchName, bool enabled) { if (type == "mask_jump32") patchMask = MemoryPatcher::PatchMask::Mask_Jump32; - if (type == "mask" || type == "mask_jump32" && !maskOffsetStr.toStdString().empty()) { + if ((type == "mask" || type == "mask_jump32") && !maskOffsetStr.toStdString().empty()) { maskOffsetValue = std::stoi(maskOffsetStr.toStdString(), 0, 10); } diff --git a/src/qt_gui/check_update.cpp b/src/qt_gui/check_update.cpp index 5cae6c41a..550fdddb5 100644 --- a/src/qt_gui/check_update.cpp +++ b/src/qt_gui/check_update.cpp @@ -19,12 +19,11 @@ #include #include #include -#include +#include #include #include #include #include -#include #include "check_update.h" using namespace Common::FS; @@ -52,7 +51,7 @@ void CheckUpdate::CheckForUpdates(const bool showMessage) { url = QUrl("https://api.github.com/repos/shadps4-emu/shadPS4/releases/latest"); checkName = false; } else { - if (Common::isRelease) { + if (Common::g_is_release) { Config::setUpdateChannel("Release"); } else { Config::setUpdateChannel("Nightly"); @@ -162,7 +161,7 @@ tr("The Auto Updater allows up to 60 update checks per hour.\\nYou have reached QString currentRev = (updateChannel == "Nightly") ? QString::fromStdString(Common::g_scm_rev) - : "v." + QString::fromStdString(Common::VERSION); + : "v." + QString::fromStdString(Common::g_version); QString currentDate = Common::g_scm_date; QDateTime dateTime = QDateTime::fromString(latestDate, Qt::ISODate); @@ -189,7 +188,7 @@ void CheckUpdate::setupUI(const QString& downloadUrl, const QString& latestDate, QHBoxLayout* titleLayout = new QHBoxLayout(); QLabel* imageLabel = new QLabel(this); - QPixmap pixmap(":/images/shadps4.ico"); + QPixmap pixmap(":/images/shadps4.png"); imageLabel->setPixmap(pixmap); imageLabel->setScaledContents(true); imageLabel->setFixedSize(50, 50); @@ -247,7 +246,7 @@ void CheckUpdate::setupUI(const QString& downloadUrl, const QString& latestDate, bool latest_isWIP = latestRev.endsWith("WIP", Qt::CaseInsensitive); if (current_isWIP && !latest_isWIP) { } else { - QTextEdit* textField = new QTextEdit(this); + QTextBrowser* textField = new QTextBrowser(this); textField->setReadOnly(true); textField->setFixedWidth(500); textField->setFixedHeight(200); @@ -349,8 +348,28 @@ void CheckUpdate::requestChangelog(const QString& currentRev, const QString& lat } // Update the text field with the changelog - QTextEdit* textField = findChild(); + QTextBrowser* textField = findChild(); if (textField) { + QRegularExpression re("\\(\\#(\\d+)\\)"); + QString newChanges; + int lastIndex = 0; + QRegularExpressionMatchIterator i = re.globalMatch(changes); + while (i.hasNext()) { + QRegularExpressionMatch match = i.next(); + newChanges += changes.mid(lastIndex, match.capturedStart() - lastIndex); + QString num = match.captured(1); + newChanges += + QString( + "(#%1)") + .arg(num); + lastIndex = match.capturedEnd(); + } + + newChanges += changes.mid(lastIndex); + changes = newChanges; + + textField->setOpenExternalLinks(true); textField->setHtml("

" + tr("Changes") + ":

" + changes); } diff --git a/src/qt_gui/control_settings.cpp b/src/qt_gui/control_settings.cpp index 820a490a0..4206e45b8 100644 --- a/src/qt_gui/control_settings.cpp +++ b/src/qt_gui/control_settings.cpp @@ -28,6 +28,11 @@ ControlSettings::ControlSettings(std::shared_ptr game_info_get, Q } }); + ui->buttonBox->button(QDialogButtonBox::Save)->setText(tr("Save")); + ui->buttonBox->button(QDialogButtonBox::Apply)->setText(tr("Apply")); + ui->buttonBox->button(QDialogButtonBox::RestoreDefaults)->setText(tr("Restore Defaults")); + ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Cancel")); + connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QWidget::close); connect(ui->ProfileComboBox, &QComboBox::currentTextChanged, this, [this] { @@ -100,8 +105,8 @@ void ControlSettings::SaveControllerConfig(bool CloseOnSave) { if (count_axis_left_x > 1 | count_axis_left_y > 1 | count_axis_right_x > 1 | count_axis_right_y > 1) { QMessageBox::StandardButton nosave; - nosave = QMessageBox::information(this, "Unable to Save", - "Cannot bind axis values more than once"); + nosave = QMessageBox::information(this, tr("Unable to Save"), + tr("Cannot bind axis values more than once")); return; } diff --git a/src/qt_gui/game_info.cpp b/src/qt_gui/game_info.cpp index 947f25d84..19b6adc1e 100644 --- a/src/qt_gui/game_info.cpp +++ b/src/qt_gui/game_info.cpp @@ -20,7 +20,7 @@ void ScanDirectoryRecursively(const QString& dir, QStringList& filePaths, int cu QFileInfoList entries = directory.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot); for (const auto& entry : entries) { - if (entry.fileName().endsWith("-UPDATE")) { + if (entry.fileName().endsWith("-UPDATE") || entry.fileName().endsWith("-patch")) { continue; } diff --git a/src/qt_gui/game_info.h b/src/qt_gui/game_info.h index 0759ccc52..09e5a4557 100644 --- a/src/qt_gui/game_info.h +++ b/src/qt_gui/game_info.h @@ -34,6 +34,12 @@ public: game_update_path += "-UPDATE"; if (std::filesystem::exists(game_update_path / "sce_sys" / "param.sfo")) { sce_folder_path = game_update_path / "sce_sys" / "param.sfo"; + } else { + game_update_path = filePath; + game_update_path += "-patch"; + if (std::filesystem::exists(game_update_path / "sce_sys" / "param.sfo")) { + sce_folder_path = game_update_path / "sce_sys" / "param.sfo"; + } } PSF psf; diff --git a/src/qt_gui/game_list_frame.cpp b/src/qt_gui/game_list_frame.cpp index 4c0607571..170215f3d 100644 --- a/src/qt_gui/game_list_frame.cpp +++ b/src/qt_gui/game_list_frame.cpp @@ -185,7 +185,8 @@ void GameListFrame::SetListBackgroundImage(QTableWidgetItem* item) { // Recompute if opacity changed or we switched to a different game if (opacity != m_last_opacity || game.pic_path != m_current_game_path) { - QImage original_image(QString::fromStdString(game.pic_path.string())); + auto image_path = game.pic_path.u8string(); + QImage original_image(QString::fromStdString({image_path.begin(), image_path.end()})); if (!original_image.isNull()) { backgroundImage = m_game_list_utils.ChangeImageOpacity( original_image, original_image.rect(), opacity / 100.0f); diff --git a/src/qt_gui/gui_context_menus.h b/src/qt_gui/gui_context_menus.h index 8a6e07847..2fd4588d2 100644 --- a/src/qt_gui/gui_context_menus.h +++ b/src/qt_gui/gui_context_menus.h @@ -7,12 +7,13 @@ #include #include #include -#include #include +#include #include "cheats_patches.h" #include "common/config.h" -#include "common/version.h" +#include "common/path_util.h" +#include "common/scm_rev.h" #include "compatibility_info.h" #include "game_info.h" #include "trophy_viewer.h" @@ -25,12 +26,11 @@ #include #include #endif -#include "common/path_util.h" class GuiContextMenus : public QObject { Q_OBJECT public: - void RequestGameMenu(const QPoint& pos, QVector m_games, + void RequestGameMenu(const QPoint& pos, QVector& m_games, std::shared_ptr m_compat_info, QTableWidget* widget, bool isList) { QPoint global_pos = widget->viewport()->mapToGlobal(pos); @@ -115,12 +115,15 @@ public: compatibilityMenu->addAction(updateCompatibility); compatibilityMenu->addAction(viewCompatibilityReport); - compatibilityMenu->addAction(submitCompatibilityReport); + if (Common::g_is_release) { + compatibilityMenu->addAction(submitCompatibilityReport); + } menu.addMenu(compatibilityMenu); compatibilityMenu->setEnabled(Config::getCompatibilityEnabled()); - viewCompatibilityReport->setEnabled(!m_games[itemID].compatibility.url.isEmpty()); + viewCompatibilityReport->setEnabled(m_games[itemID].compatibility.status != + CompatibilityStatus::Unknown); // Show menu. auto selected = menu.exec(global_pos); @@ -138,11 +141,17 @@ public: QString open_update_path; Common::FS::PathToQString(open_update_path, m_games[itemID].path); open_update_path += "-UPDATE"; - if (!std::filesystem::exists(Common::FS::PathFromQString(open_update_path))) { - QMessageBox::critical(nullptr, tr("Error"), - QString(tr("This game has no update folder to open!"))); - } else { + if (std::filesystem::exists(Common::FS::PathFromQString(open_update_path))) { QDesktopServices::openUrl(QUrl::fromLocalFile(open_update_path)); + } else { + Common::FS::PathToQString(open_update_path, m_games[itemID].path); + open_update_path += "-patch"; + if (std::filesystem::exists(Common::FS::PathFromQString(open_update_path))) { + QDesktopServices::openUrl(QUrl::fromLocalFile(open_update_path)); + } else { + QMessageBox::critical(nullptr, tr("Error"), + QString(tr("This game has no update folder to open!"))); + } } } @@ -215,6 +224,12 @@ public: game_update_path += "-UPDATE"; if (std::filesystem::exists(game_update_path)) { game_folder_path = game_update_path; + } else { + game_update_path = game_folder_path; + game_update_path += "-patch"; + if (std::filesystem::exists(game_update_path)) { + game_folder_path = game_update_path; + } } if (psf.Open(game_folder_path / "sce_sys" / "param.sfo")) { int rows = psf.GetEntries().size(); @@ -311,8 +326,40 @@ public: game_update_path += "-UPDATE"; if (std::filesystem::exists(game_update_path)) { Common::FS::PathToQString(gameTrpPath, game_update_path); + } else { + game_update_path = Common::FS::PathFromQString(gameTrpPath); + game_update_path += "-patch"; + if (std::filesystem::exists(game_update_path)) { + Common::FS::PathToQString(gameTrpPath, game_update_path); + } } - TrophyViewer* trophyViewer = new TrophyViewer(trophyPath, gameTrpPath); + + // Array with all games and their trophy information + QVector allTrophyGames; + for (const auto& game : m_games) { + TrophyGameInfo gameInfo; + gameInfo.name = QString::fromStdString(game.name); + Common::FS::PathToQString(gameInfo.trophyPath, game.serial); + Common::FS::PathToQString(gameInfo.gameTrpPath, game.path); + + auto update_path = Common::FS::PathFromQString(gameInfo.gameTrpPath); + update_path += "-UPDATE"; + if (std::filesystem::exists(update_path)) { + Common::FS::PathToQString(gameInfo.gameTrpPath, update_path); + } else { + update_path = Common::FS::PathFromQString(gameInfo.gameTrpPath); + update_path += "-patch"; + if (std::filesystem::exists(update_path)) { + Common::FS::PathToQString(gameInfo.gameTrpPath, update_path); + } + } + + allTrophyGames.append(gameInfo); + } + + QString gameName = QString::fromStdString(m_games[itemID].name); + TrophyViewer* trophyViewer = + new TrophyViewer(trophyPath, gameTrpPath, gameName, allTrophyGames); trophyViewer->show(); connect(widget->parent(), &QWidget::destroyed, trophyViewer, [trophyViewer]() { trophyViewer->deleteLater(); }); @@ -431,6 +478,9 @@ public: QString folder_path, game_update_path, dlc_path, save_data_path, trophy_data_path; Common::FS::PathToQString(folder_path, m_games[itemID].path); game_update_path = folder_path + "-UPDATE"; + if (!std::filesystem::exists(Common::FS::PathFromQString(game_update_path))) { + game_update_path = folder_path + "-patch"; + } Common::FS::PathToQString( dlc_path, Config::getAddonInstallDir() / Common::FS::PathFromQString(folder_path).parent_path().filename()); @@ -442,9 +492,12 @@ public: Common::FS::GetUserPath(Common::FS::PathType::MetaDataDir) / m_games[itemID].serial / "TrophyFiles"); - QString message_type = tr("Game"); + QString message_type; - if (selected == deleteUpdate) { + if (selected == deleteGame) { + BackgroundMusicPlayer::getInstance().stopMusic(); + message_type = tr("Game"); + } else if (selected == deleteUpdate) { if (!std::filesystem::exists(Common::FS::PathFromQString(game_update_path))) { QMessageBox::critical(nullptr, tr("Error"), QString(tr("This game has no update to delete!"))); @@ -505,24 +558,36 @@ public: } if (selected == viewCompatibilityReport) { - if (!m_games[itemID].compatibility.url.isEmpty()) - QDesktopServices::openUrl(QUrl(m_games[itemID].compatibility.url)); + if (m_games[itemID].compatibility.issue_number != "") { + auto url_issues = + "https://github.com/shadps4-emu/shadps4-game-compatibility/issues/"; + QDesktopServices::openUrl( + QUrl(url_issues + m_games[itemID].compatibility.issue_number)); + } } if (selected == submitCompatibilityReport) { - QUrl url = QUrl("https://github.com/shadps4-emu/shadps4-game-compatibility/issues/new"); - QUrlQuery query; - query.addQueryItem("template", QString("game_compatibility.yml")); - query.addQueryItem( - "title", QString("%1 - %2").arg(QString::fromStdString(m_games[itemID].serial), - QString::fromStdString(m_games[itemID].name))); - query.addQueryItem("game-name", QString::fromStdString(m_games[itemID].name)); - query.addQueryItem("game-code", QString::fromStdString(m_games[itemID].serial)); - query.addQueryItem("game-version", QString::fromStdString(m_games[itemID].version)); - query.addQueryItem("emulator-version", QString(Common::VERSION)); - url.setQuery(query); + if (m_games[itemID].compatibility.issue_number == "") { + QUrl url = + QUrl("https://github.com/shadps4-emu/shadps4-game-compatibility/issues/new"); + QUrlQuery query; + query.addQueryItem("template", QString("game_compatibility.yml")); + query.addQueryItem( + "title", QString("%1 - %2").arg(QString::fromStdString(m_games[itemID].serial), + QString::fromStdString(m_games[itemID].name))); + query.addQueryItem("game-name", QString::fromStdString(m_games[itemID].name)); + query.addQueryItem("game-serial", QString::fromStdString(m_games[itemID].serial)); + query.addQueryItem("game-version", QString::fromStdString(m_games[itemID].version)); + query.addQueryItem("emulator-version", QString(Common::g_version)); + url.setQuery(query); - QDesktopServices::openUrl(url); + QDesktopServices::openUrl(url); + } else { + auto url_issues = + "https://github.com/shadps4-emu/shadps4-game-compatibility/issues/"; + QDesktopServices::openUrl( + QUrl(url_issues + m_games[itemID].compatibility.issue_number)); + } } } @@ -548,30 +613,6 @@ public: return -1; } - void RequestGameMenuPKGViewer( - const QPoint& pos, QStringList m_pkg_app_list, QTreeWidget* treeWidget, - std::function InstallDragDropPkg) { - QPoint global_pos = treeWidget->viewport()->mapToGlobal(pos); // context menu position - QTreeWidgetItem* currentItem = treeWidget->currentItem(); // current clicked item - int itemIndex = GetRowIndex(treeWidget, currentItem); // row - - QMenu menu(treeWidget); - QAction installPackage(tr("Install PKG"), treeWidget); - - menu.addAction(&installPackage); - - auto selected = menu.exec(global_pos); - if (!selected) { - return; - } - - if (selected == &installPackage) { - QStringList pkg_app_ = m_pkg_app_list[itemIndex].split(";;"); - std::filesystem::path path = Common::FS::PathFromQString(pkg_app_[9]); - InstallDragDropPkg(path, 1, 1); - } - } - private: bool convertPngToIco(const QString& pngFilePath, const QString& icoFilePath) { // Load the PNG image diff --git a/src/qt_gui/install_dir_select.cpp b/src/qt_gui/install_dir_select.cpp deleted file mode 100644 index e90a10ee6..000000000 --- a/src/qt_gui/install_dir_select.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "install_dir_select.h" - -InstallDirSelect::InstallDirSelect() : selected_dir() { - auto install_dirs = Config::getGameInstallDirs(); - selected_dir = install_dirs.empty() ? "" : install_dirs.front(); - - if (!install_dirs.empty() && install_dirs.size() == 1) { - accept(); - } - - auto layout = new QVBoxLayout(this); - - layout->addWidget(SetupInstallDirList()); - layout->addStretch(); - layout->addWidget(SetupDialogActions()); - - setWindowTitle(tr("shadPS4 - Choose directory")); - setWindowIcon(QIcon(":images/shadps4.ico")); -} - -InstallDirSelect::~InstallDirSelect() {} - -QWidget* InstallDirSelect::SetupInstallDirList() { - auto group = new QGroupBox(tr("Select which directory you want to install to.")); - auto vlayout = new QVBoxLayout(); - - auto m_path_list = new QListWidget(); - QList qt_list; - for (const auto& str : Config::getGameInstallDirs()) { - QString installDirPath; - Common::FS::PathToQString(installDirPath, str); - qt_list.append(installDirPath); - } - m_path_list->insertItems(0, qt_list); - m_path_list->setSpacing(1); - - connect(m_path_list, &QListWidget::itemClicked, this, &InstallDirSelect::setSelectedDirectory); - connect(m_path_list, &QListWidget::itemActivated, this, - &InstallDirSelect::setSelectedDirectory); - - vlayout->addWidget(m_path_list); - - auto checkbox = new QCheckBox(tr("Install All Queued to Selected Folder")); - connect(checkbox, &QCheckBox::toggled, this, &InstallDirSelect::setUseForAllQueued); - vlayout->addWidget(checkbox); - - auto checkbox2 = new QCheckBox(tr("Delete PKG File on Install")); - connect(checkbox2, &QCheckBox::toggled, this, &InstallDirSelect::setDeleteFileOnInstall); - vlayout->addWidget(checkbox2); - - group->setLayout(vlayout); - return group; -} - -void InstallDirSelect::setSelectedDirectory(QListWidgetItem* item) { - if (item) { - const auto highlighted_path = Common::FS::PathFromQString(item->text()); - if (!highlighted_path.empty()) { - selected_dir = highlighted_path; - } - } -} - -void InstallDirSelect::setUseForAllQueued(bool enabled) { - use_for_all_queued = enabled; -} - -void InstallDirSelect::setDeleteFileOnInstall(bool enabled) { - delete_file_on_install = enabled; -} - -QWidget* InstallDirSelect::SetupDialogActions() { - auto actions = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - - connect(actions, &QDialogButtonBox::accepted, this, &InstallDirSelect::accept); - connect(actions, &QDialogButtonBox::rejected, this, &InstallDirSelect::reject); - - return actions; -} diff --git a/src/qt_gui/install_dir_select.h b/src/qt_gui/install_dir_select.h deleted file mode 100644 index e11cbf381..000000000 --- a/src/qt_gui/install_dir_select.h +++ /dev/null @@ -1,42 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include -#include - -#include "common/config.h" -#include "common/path_util.h" - -class QLineEdit; - -class InstallDirSelect final : public QDialog { - Q_OBJECT - -public: - InstallDirSelect(); - ~InstallDirSelect(); - - std::filesystem::path getSelectedDirectory() { - return selected_dir; - } - - bool useForAllQueued() { - return use_for_all_queued; - } - - bool deleteFileOnInstall() { - return delete_file_on_install; - } - -private: - QWidget* SetupInstallDirList(); - QWidget* SetupDialogActions(); - void setSelectedDirectory(QListWidgetItem* item); - void setDeleteFileOnInstall(bool enabled); - void setUseForAllQueued(bool enabled); - std::filesystem::path selected_dir; - bool delete_file_on_install = false; - bool use_for_all_queued = false; -}; diff --git a/src/qt_gui/kbm_config_dialog.cpp b/src/qt_gui/kbm_config_dialog.cpp index cfff056a0..1851c591d 100644 --- a/src/qt_gui/kbm_config_dialog.cpp +++ b/src/qt_gui/kbm_config_dialog.cpp @@ -28,7 +28,7 @@ HelpDialog* helpDialog; EditorDialog::EditorDialog(QWidget* parent) : QDialog(parent) { - setWindowTitle("Edit Keyboard + Mouse and Controller input bindings"); + setWindowTitle(tr("Edit Keyboard + Mouse and Controller input bindings")); resize(600, 400); // Create the editor widget @@ -42,7 +42,7 @@ EditorDialog::EditorDialog(QWidget* parent) : QDialog(parent) { // Load all installed games loadInstalledGames(); - QCheckBox* unifiedInputCheckBox = new QCheckBox("Use Per-Game configs", this); + QCheckBox* unifiedInputCheckBox = new QCheckBox(tr("Use Per-Game configs"), this); unifiedInputCheckBox->setChecked(!Config::GetUseUnifiedInputConfig()); // Connect checkbox signal @@ -94,7 +94,7 @@ void EditorDialog::loadFile(QString game) { originalConfig = editor->toPlainText(); file.close(); } else { - QMessageBox::warning(this, "Error", "Could not open the file for reading"); + QMessageBox::warning(this, tr("Error"), tr("Could not open the file for reading")); } } @@ -108,7 +108,7 @@ void EditorDialog::saveFile(QString game) { out << editor->toPlainText(); file.close(); } else { - QMessageBox::warning(this, "Error", "Could not open the file for writing"); + QMessageBox::warning(this, tr("Error"), tr("Could not open the file for writing")); } } @@ -121,7 +121,7 @@ void EditorDialog::closeEvent(QCloseEvent* event) { } if (hasUnsavedChanges()) { QMessageBox::StandardButton reply; - reply = QMessageBox::question(this, "Save Changes", "Do you want to save changes?", + reply = QMessageBox::question(this, tr("Save Changes"), tr("Do you want to save changes?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel); if (reply == QMessageBox::Yes) { @@ -168,7 +168,7 @@ void EditorDialog::onCancelClicked() { void EditorDialog::onHelpClicked() { if (!isHelpOpen) { helpDialog = new HelpDialog(&isHelpOpen, this); - helpDialog->setWindowTitle("Help"); + helpDialog->setWindowTitle(tr("Help")); helpDialog->setAttribute(Qt::WA_DeleteOnClose); // Clean up on close // Get the position and size of the Config window QRect configGeometry = this->geometry(); @@ -188,10 +188,10 @@ void EditorDialog::onResetToDefaultClicked() { bool default_default = gameComboBox->currentText() == "default"; QString prompt = default_default - ? "Do you want to reset your custom default config to the original default config?" - : "Do you want to reset this config to your custom default config?"; - QMessageBox::StandardButton reply = - QMessageBox::question(this, "Reset to Default", prompt, QMessageBox::Yes | QMessageBox::No); + ? tr("Do you want to reset your custom default config to the original default config?") + : tr("Do you want to reset this config to your custom default config?"); + QMessageBox::StandardButton reply = QMessageBox::question(this, tr("Reset to Default"), prompt, + QMessageBox::Yes | QMessageBox::No); if (reply == QMessageBox::Yes) { if (default_default) { @@ -206,7 +206,7 @@ void EditorDialog::onResetToDefaultClicked() { editor->setPlainText(in.readAll()); file.close(); } else { - QMessageBox::warning(this, "Error", "Could not open the file for reading"); + QMessageBox::warning(this, tr("Error"), tr("Could not open the file for reading")); } // saveFile(gameComboBox->currentText()); } @@ -225,7 +225,8 @@ void EditorDialog::loadInstalledGames() { QDir parentFolder(installDir); QFileInfoList fileList = parentFolder.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot); for (const auto& fileInfo : fileList) { - if (fileInfo.isDir() && !fileInfo.filePath().endsWith("-UPDATE")) { + if (fileInfo.isDir() && (!fileInfo.filePath().endsWith("-UPDATE") || + !fileInfo.filePath().endsWith("-patch"))) { gameComboBox->addItem(fileInfo.fileName()); // Add game name to combo box } } diff --git a/src/qt_gui/kbm_gui.cpp b/src/qt_gui/kbm_gui.cpp new file mode 100644 index 000000000..15e9008ab --- /dev/null +++ b/src/qt_gui/kbm_gui.cpp @@ -0,0 +1,1032 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include +#include +#include +#include +#include +#include + +#include "common/path_util.h" +#include "kbm_config_dialog.h" +#include "kbm_gui.h" +#include "kbm_help_dialog.h" +#include "ui_kbm_gui.h" + +HelpDialog* HelpWindow; +KBMSettings::KBMSettings(std::shared_ptr game_info_get, QWidget* parent) + : QDialog(parent), m_game_info(game_info_get), ui(new Ui::KBMSettings) { + + ui->setupUi(this); + ui->PerGameCheckBox->setChecked(!Config::GetUseUnifiedInputConfig()); + ui->TextEditorButton->setFocus(); + this->setFocusPolicy(Qt::StrongFocus); + + ui->MouseJoystickBox->addItem("none"); + ui->MouseJoystickBox->addItem("right"); + ui->MouseJoystickBox->addItem("left"); + + ui->ProfileComboBox->addItem("Common Config"); + for (int i = 0; i < m_game_info->m_games.size(); i++) { + ui->ProfileComboBox->addItem(QString::fromStdString(m_game_info->m_games[i].serial)); + } + + ButtonsList = { + ui->CrossButton, ui->CircleButton, ui->TriangleButton, ui->SquareButton, + ui->L1Button, ui->R1Button, ui->L2Button, ui->R2Button, + ui->L3Button, ui->R3Button, ui->TouchpadButton, ui->OptionsButton, + ui->TouchpadButton, ui->DpadUpButton, ui->DpadDownButton, ui->DpadLeftButton, + ui->DpadRightButton, ui->LStickUpButton, ui->LStickDownButton, ui->LStickLeftButton, + ui->LStickRightButton, ui->RStickUpButton, ui->RStickDownButton, ui->RStickLeftButton, + ui->RStickRightButton, ui->LHalfButton, ui->RHalfButton}; + + ButtonConnects(); + SetUIValuestoMappings("default"); + installEventFilter(this); + + ui->ProfileComboBox->setCurrentText("Common Config"); + ui->TitleLabel->setText("Common Config"); + config_id = "default"; + + connect(ui->buttonBox, &QDialogButtonBox::clicked, this, [this](QAbstractButton* button) { + if (button == ui->buttonBox->button(QDialogButtonBox::Save)) { + if (HelpWindowOpen) { + HelpWindow->close(); + HelpWindowOpen = false; + } + SaveKBMConfig(true); + } else if (button == ui->buttonBox->button(QDialogButtonBox::RestoreDefaults)) { + SetDefault(); + } else if (button == ui->buttonBox->button(QDialogButtonBox::Apply)) { + SaveKBMConfig(false); + } + }); + + ui->buttonBox->button(QDialogButtonBox::Save)->setText(tr("Save")); + ui->buttonBox->button(QDialogButtonBox::Apply)->setText(tr("Apply")); + ui->buttonBox->button(QDialogButtonBox::RestoreDefaults)->setText(tr("Restore Defaults")); + ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Cancel")); + + connect(ui->HelpButton, &QPushButton::clicked, this, &KBMSettings::onHelpClicked); + connect(ui->TextEditorButton, &QPushButton::clicked, this, [this]() { + auto kbmWindow = new EditorDialog(this); + kbmWindow->exec(); + SetUIValuestoMappings(config_id); + }); + + connect(ui->buttonBox, &QDialogButtonBox::rejected, this, [this] { + QWidget::close(); + if (HelpWindowOpen) { + HelpWindow->close(); + HelpWindowOpen = false; + } + }); + + connect(ui->ProfileComboBox, &QComboBox::currentTextChanged, this, [this] { + GetGameTitle(); + SetUIValuestoMappings(config_id); + }); + + connect(ui->CopyCommonButton, &QPushButton::clicked, this, [this] { + if (ui->ProfileComboBox->currentText() == "Common Config") { + QMessageBox::information(this, tr("Common Config Selected"), + // clang-format off +tr("This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config.")); + // clang-format on + } else { + QMessageBox::StandardButton reply = + QMessageBox::question(this, tr("Copy values from Common Config"), + // clang-format off +tr("Do you want to overwrite existing mappings with the mappings from the Common Config?"), + // clang-format on + QMessageBox::Yes | QMessageBox::No); + if (reply == QMessageBox::Yes) { + SetUIValuestoMappings("default"); + } + } + }); + + connect(ui->DeadzoneOffsetSlider, &QSlider::valueChanged, this, [this](int value) { + QString DOSValue = QString::number(value / 100.0, 'f', 2); + QString DOSString = tr("Deadzone Offset (def 0.50):") + " " + DOSValue; + ui->DeadzoneOffsetLabel->setText(DOSString); + }); + + connect(ui->SpeedMultiplierSlider, &QSlider::valueChanged, this, [this](int value) { + QString SMSValue = QString::number(value / 10.0, 'f', 1); + QString SMSString = tr("Speed Multiplier (def 1.0):") + " " + SMSValue; + ui->SpeedMultiplierLabel->setText(SMSString); + }); + + connect(ui->SpeedOffsetSlider, &QSlider::valueChanged, this, [this](int value) { + QString SOSValue = QString::number(value / 1000.0, 'f', 3); + QString SOSString = tr("Speed Offset (def 0.125):") + " " + SOSValue; + ui->SpeedOffsetLabel->setText(SOSString); + }); +} + +void KBMSettings::ButtonConnects() { + for (auto& button : ButtonsList) { + connect(button, &QPushButton::clicked, this, [this, &button]() { StartTimer(button); }); + } +} + +void KBMSettings::DisableMappingButtons() { + for (const auto& i : ButtonsList) { + i->setEnabled(false); + } +} + +void KBMSettings::EnableMappingButtons() { + for (const auto& i : ButtonsList) { + i->setEnabled(true); + } +} + +void KBMSettings::SaveKBMConfig(bool CloseOnSave) { + std::string output_string = "", input_string = ""; + std::vector lines, inputs; + + lines.push_back("#Feeling lost? Check out the Help section!"); + lines.push_back(""); + lines.push_back("#Keyboard bindings"); + lines.push_back(""); + + input_string = ui->CrossButton->text().toStdString(); + output_string = "cross"; + lines.push_back(output_string + " = " + input_string); + if (input_string != "unmapped") + inputs.push_back(input_string); + + input_string = ui->CircleButton->text().toStdString(); + output_string = "circle"; + lines.push_back(output_string + " = " + input_string); + if (input_string != "unmapped") + inputs.push_back(input_string); + + input_string = ui->TriangleButton->text().toStdString(); + output_string = "triangle"; + lines.push_back(output_string + " = " + input_string); + if (input_string != "unmapped") + inputs.push_back(input_string); + + input_string = ui->SquareButton->text().toStdString(); + output_string = "square"; + lines.push_back(output_string + " = " + input_string); + if (input_string != "unmapped") + inputs.push_back(input_string); + + lines.push_back(""); + + input_string = ui->DpadUpButton->text().toStdString(); + output_string = "pad_up"; + lines.push_back(output_string + " = " + input_string); + if (input_string != "unmapped") + inputs.push_back(input_string); + + input_string = ui->DpadDownButton->text().toStdString(); + output_string = "pad_down"; + lines.push_back(output_string + " = " + input_string); + if (input_string != "unmapped") + inputs.push_back(input_string); + + input_string = ui->DpadLeftButton->text().toStdString(); + output_string = "pad_left"; + lines.push_back(output_string + " = " + input_string); + if (input_string != "unmapped") + inputs.push_back(input_string); + + input_string = ui->DpadRightButton->text().toStdString(); + output_string = "pad_right"; + lines.push_back(output_string + " = " + input_string); + if (input_string != "unmapped") + inputs.push_back(input_string); + + lines.push_back(""); + + input_string = ui->L1Button->text().toStdString(); + output_string = "l1"; + lines.push_back(output_string + " = " + input_string); + if (input_string != "unmapped") + inputs.push_back(input_string); + + input_string = ui->R1Button->text().toStdString(); + output_string = "r1"; + lines.push_back(output_string + " = " + input_string); + if (input_string != "unmapped") + inputs.push_back(input_string); + + input_string = ui->L2Button->text().toStdString(); + output_string = "l2"; + lines.push_back(output_string + " = " + input_string); + if (input_string != "unmapped") + inputs.push_back(input_string); + + input_string = ui->R2Button->text().toStdString(); + output_string = "r2"; + lines.push_back(output_string + " = " + input_string); + if (input_string != "unmapped") + inputs.push_back(input_string); + + input_string = ui->L3Button->text().toStdString(); + output_string = "l3"; + lines.push_back(output_string + " = " + input_string); + if (input_string != "unmapped") + inputs.push_back(input_string); + + input_string = ui->R3Button->text().toStdString(); + output_string = "r3"; + lines.push_back(output_string + " = " + input_string); + if (input_string != "unmapped") + inputs.push_back(input_string); + + lines.push_back(""); + + input_string = ui->OptionsButton->text().toStdString(); + output_string = "options"; + lines.push_back(output_string + " = " + input_string); + if (input_string != "unmapped") + inputs.push_back(input_string); + + input_string = ui->TouchpadButton->text().toStdString(); + output_string = "touchpad"; + lines.push_back(output_string + " = " + input_string); + if (input_string != "unmapped") + inputs.push_back(input_string); + + lines.push_back(""); + + input_string = ui->LStickUpButton->text().toStdString(); + output_string = "axis_left_y_minus"; + lines.push_back(output_string + " = " + input_string); + if (input_string != "unmapped") + inputs.push_back(input_string); + + input_string = ui->LStickDownButton->text().toStdString(); + output_string = "axis_left_y_plus"; + lines.push_back(output_string + " = " + input_string); + if (input_string != "unmapped") + inputs.push_back(input_string); + + input_string = ui->LStickLeftButton->text().toStdString(); + output_string = "axis_left_x_minus"; + lines.push_back(output_string + " = " + input_string); + if (input_string != "unmapped") + inputs.push_back(input_string); + + input_string = ui->LStickRightButton->text().toStdString(); + output_string = "axis_left_x_plus"; + lines.push_back(output_string + " = " + input_string); + if (input_string != "unmapped") + inputs.push_back(input_string); + + lines.push_back(""); + + input_string = ui->RStickUpButton->text().toStdString(); + output_string = "axis_right_y_minus"; + lines.push_back(output_string + " = " + input_string); + if (input_string != "unmapped") + inputs.push_back(input_string); + + input_string = ui->RStickDownButton->text().toStdString(); + output_string = "axis_right_y_plus"; + lines.push_back(output_string + " = " + input_string); + if (input_string != "unmapped") + inputs.push_back(input_string); + + input_string = ui->RStickLeftButton->text().toStdString(); + output_string = "axis_right_x_minus"; + lines.push_back(output_string + " = " + input_string); + if (input_string != "unmapped") + inputs.push_back(input_string); + + input_string = ui->RStickRightButton->text().toStdString(); + output_string = "axis_right_x_plus"; + lines.push_back(output_string + " = " + input_string); + if (input_string != "unmapped") + inputs.push_back(input_string); + + lines.push_back(""); + + input_string = ui->MouseJoystickBox->currentText().toStdString(); + output_string = "mouse_to_joystick"; + if (input_string != "unmapped") + lines.push_back(output_string + " = " + input_string); + + input_string = ui->LHalfButton->text().toStdString(); + output_string = "leftjoystick_halfmode"; + lines.push_back(output_string + " = " + input_string); + if (input_string != "unmapped") + inputs.push_back(input_string); + + input_string = ui->RHalfButton->text().toStdString(); + output_string = "rightjoystick_halfmode"; + lines.push_back(output_string + " = " + input_string); + if (input_string != "unmapped") + inputs.push_back(input_string); + + std::string DOString = std::format("{:.2f}", (ui->DeadzoneOffsetSlider->value() / 100.f)); + std::string SMString = std::format("{:.1f}", (ui->SpeedMultiplierSlider->value() / 10.f)); + std::string SOString = std::format("{:.3f}", (ui->SpeedOffsetSlider->value() / 1000.f)); + input_string = DOString + ", " + SMString + ", " + SOString; + output_string = "mouse_movement_params"; + lines.push_back(output_string + " = " + input_string); + + lines.push_back(""); + const auto config_file = Config::GetFoolproofKbmConfigFile(config_id); + std::fstream file(config_file); + int lineCount = 0; + std::string line; + while (std::getline(file, line)) { + lineCount++; + + if (line.empty()) { + lines.push_back(line); + continue; + } + + std::size_t comment_pos = line.find('#'); + if (comment_pos != std::string::npos) { + if (!line.contains("Keyboard bindings") && !line.contains("Feeling lost") && + !line.contains("Alternatives for users")) + lines.push_back(line); + continue; + } + + std::size_t equal_pos = line.find('='); + if (equal_pos == std::string::npos) { + lines.push_back(line); + continue; + } + + output_string = line.substr(0, equal_pos - 1); + input_string = line.substr(equal_pos + 2); + + if (std::find(ControllerInputs.begin(), ControllerInputs.end(), input_string) != + ControllerInputs.end() || + output_string == "analog_deadzone" || output_string == "override_controller_color") { + lines.push_back(line); + } + } + file.close(); + + // Prevent duplicate inputs for KBM as this breaks the engine + for (auto it = inputs.begin(); it != inputs.end(); ++it) { + if (std::find(it + 1, inputs.end(), *it) != inputs.end()) { + QMessageBox::information(this, tr("Unable to Save"), + tr("Cannot bind any unique input more than once")); + return; + } + } + + std::vector save; + bool CurrentLineEmpty = false, LastLineEmpty = false; + for (auto const& line : lines) { + LastLineEmpty = CurrentLineEmpty ? true : false; + CurrentLineEmpty = line.empty() ? true : false; + if (!CurrentLineEmpty || !LastLineEmpty) + save.push_back(line); + } + + std::ofstream output_file(config_file); + for (auto const& line : save) { + output_file << line << '\n'; + } + output_file.close(); + + Config::SetUseUnifiedInputConfig(!ui->PerGameCheckBox->isChecked()); + Config::save(Common::FS::GetUserPath(Common::FS::PathType::UserDir) / "config.toml"); + + if (CloseOnSave) + QWidget::close(); +} + +void KBMSettings::SetDefault() { + ui->CrossButton->setText("kp2"); + ui->CircleButton->setText("kp6"); + ui->TriangleButton->setText("kp8"); + ui->SquareButton->setText("kp4"); + + ui->L1Button->setText("q"); + ui->L2Button->setText("e"); + ui->L3Button->setText("x"); + ui->R1Button->setText("u"); + ui->R2Button->setText("o"); + ui->R3Button->setText("m"); + + ui->TouchpadButton->setText("space"); + ui->OptionsButton->setText("enter"); + + ui->DpadUpButton->setText("up"); + ui->DpadDownButton->setText("down"); + ui->DpadLeftButton->setText("left"); + ui->DpadRightButton->setText("right"); + + ui->LStickUpButton->setText("w"); + ui->LStickDownButton->setText("s"); + ui->LStickLeftButton->setText("a"); + ui->LStickRightButton->setText("d"); + + ui->RStickUpButton->setText("i"); + ui->RStickDownButton->setText("k"); + ui->RStickLeftButton->setText("j"); + ui->RStickRightButton->setText("l"); + + ui->LHalfButton->setText("unmapped"); + ui->RHalfButton->setText("unmapped"); + + ui->MouseJoystickBox->setCurrentText("none"); + ui->DeadzoneOffsetSlider->setValue(50); + ui->SpeedMultiplierSlider->setValue(10); + ui->SpeedOffsetSlider->setValue(125); +} + +void KBMSettings::SetUIValuestoMappings(std::string config_id) { + const auto config_file = Config::GetFoolproofKbmConfigFile(config_id); + std::ifstream file(config_file); + + int lineCount = 0; + std::string line = ""; + while (std::getline(file, line)) { + lineCount++; + + std::size_t comment_pos = line.find('#'); + if (comment_pos != std::string::npos) + line = line.substr(0, comment_pos); + + std::size_t equal_pos = line.find('='); + if (equal_pos == std::string::npos) + continue; + + std::string output_string = line.substr(0, equal_pos - 1); + std::string input_string = line.substr(equal_pos + 2); + + if (std::find(ControllerInputs.begin(), ControllerInputs.end(), input_string) == + ControllerInputs.end()) { + + if (output_string == "cross") { + ui->CrossButton->setText(QString::fromStdString(input_string)); + } else if (output_string == "circle") { + ui->CircleButton->setText(QString::fromStdString(input_string)); + } else if (output_string == "square") { + ui->SquareButton->setText(QString::fromStdString(input_string)); + } else if (output_string == "triangle") { + ui->TriangleButton->setText(QString::fromStdString(input_string)); + } else if (output_string == "l1") { + ui->L1Button->setText(QString::fromStdString(input_string)); + } else if (output_string == "l2") { + ui->L2Button->setText(QString::fromStdString(input_string)); + } else if (output_string == "r1") { + ui->R1Button->setText(QString::fromStdString(input_string)); + } else if (output_string == "r2") { + ui->R2Button->setText(QString::fromStdString(input_string)); + } else if (output_string == "l3") { + ui->L3Button->setText(QString::fromStdString(input_string)); + } else if (output_string == "r3") { + ui->R3Button->setText(QString::fromStdString(input_string)); + } else if (output_string == "pad_up") { + ui->DpadUpButton->setText(QString::fromStdString(input_string)); + } else if (output_string == "pad_down") { + ui->DpadDownButton->setText(QString::fromStdString(input_string)); + } else if (output_string == "pad_left") { + ui->DpadLeftButton->setText(QString::fromStdString(input_string)); + } else if (output_string == "pad_right") { + ui->DpadRightButton->setText(QString::fromStdString(input_string)); + } else if (output_string == "options") { + ui->OptionsButton->setText(QString::fromStdString(input_string)); + } else if (output_string == "touchpad") { + ui->TouchpadButton->setText(QString::fromStdString(input_string)); + } else if (output_string == "axis_left_x_minus") { + ui->LStickLeftButton->setText(QString::fromStdString(input_string)); + } else if (output_string == "axis_left_x_plus") { + ui->LStickRightButton->setText(QString::fromStdString(input_string)); + } else if (output_string == "axis_left_y_minus") { + ui->LStickUpButton->setText(QString::fromStdString(input_string)); + } else if (output_string == "axis_left_y_plus") { + ui->LStickDownButton->setText(QString::fromStdString(input_string)); + } else if (output_string == "axis_right_x_minus") { + ui->RStickLeftButton->setText(QString::fromStdString(input_string)); + } else if (output_string == "axis_right_x_plus") { + ui->RStickRightButton->setText(QString::fromStdString(input_string)); + } else if (output_string == "axis_right_y_minus") { + ui->RStickUpButton->setText(QString::fromStdString(input_string)); + } else if (output_string == "axis_right_y_plus") { + ui->RStickDownButton->setText(QString::fromStdString(input_string)); + } else if (output_string == "mouse_to_joystick") { + ui->MouseJoystickBox->setCurrentText(QString::fromStdString(input_string)); + } else if (output_string == "leftjoystick_halfmode") { + ui->LHalfButton->setText(QString::fromStdString(input_string)); + } else if (output_string == "rightjoystick_halfmode") { + ui->RHalfButton->setText(QString::fromStdString(input_string)); + } else if (output_string.contains("mouse_movement_params")) { + std::size_t comma_pos = line.find(','); + if (comma_pos != std::string::npos) { + std::string DOstring = line.substr(equal_pos + 1, comma_pos); + float DOffsetValue = std::stof(DOstring) * 100.0; + int DOffsetInt = int(DOffsetValue); + ui->DeadzoneOffsetSlider->setValue(DOffsetInt); + QString LabelValue = QString::number(DOffsetInt / 100.0, 'f', 2); + QString LabelString = tr("Deadzone Offset (def 0.50):") + " " + LabelValue; + ui->DeadzoneOffsetLabel->setText(LabelString); + + std::string SMSOstring = line.substr(comma_pos + 1); + std::size_t comma_pos2 = SMSOstring.find(','); + if (comma_pos2 != std::string::npos) { + std::string SMstring = SMSOstring.substr(0, comma_pos2); + float SpeedMultValue = std::stof(SMstring) * 10.0; + int SpeedMultInt = int(SpeedMultValue); + if (SpeedMultInt < 1) + SpeedMultInt = 1; + if (SpeedMultInt > 50) + SpeedMultInt = 50; + ui->SpeedMultiplierSlider->setValue(SpeedMultInt); + LabelValue = QString::number(SpeedMultInt / 10.0, 'f', 1); + LabelString = tr("Speed Multiplier (def 1.0):") + " " + LabelValue; + ui->SpeedMultiplierLabel->setText(LabelString); + + std::string SOstring = SMSOstring.substr(comma_pos2 + 1); + float SOffsetValue = std::stof(SOstring) * 1000.0; + int SOffsetInt = int(SOffsetValue); + ui->SpeedOffsetSlider->setValue(SOffsetInt); + LabelValue = QString::number(SOffsetInt / 1000.0, 'f', 3); + LabelString = tr("Speed Offset (def 0.125):") + " " + LabelValue; + ui->SpeedOffsetLabel->setText(LabelString); + } + } + } + } + } + file.close(); +} + +void KBMSettings::GetGameTitle() { + if (ui->ProfileComboBox->currentText() == "Common Config") { + ui->TitleLabel->setText("Common Config"); + } else { + for (int i = 0; i < m_game_info->m_games.size(); i++) { + if (m_game_info->m_games[i].serial == + ui->ProfileComboBox->currentText().toStdString()) { + ui->TitleLabel->setText(QString::fromStdString(m_game_info->m_games[i].name)); + } + } + } + config_id = (ui->ProfileComboBox->currentText() == "Common Config") + ? "default" + : ui->ProfileComboBox->currentText().toStdString(); +} + +void KBMSettings::onHelpClicked() { + if (!HelpWindowOpen) { + HelpWindow = new HelpDialog(&HelpWindowOpen, this); + HelpWindow->setWindowTitle(tr("Help")); + HelpWindow->setAttribute(Qt::WA_DeleteOnClose); // Clean up on close + HelpWindow->show(); + HelpWindowOpen = true; + } else { + HelpWindow->close(); + HelpWindowOpen = false; + } +} + +void KBMSettings::StartTimer(QPushButton*& button) { + MappingTimer = 3; + EnableMapping = true; + MappingCompleted = false; + modifier = ""; + mapping = button->text(); + + DisableMappingButtons(); + button->setText(tr("Press a key") + " [" + QString::number(MappingTimer) + "]"); + timer = new QTimer(this); + MappingButton = button; + connect(timer, &QTimer::timeout, this, [this]() { CheckMapping(MappingButton); }); + timer->start(1000); +} + +void KBMSettings::CheckMapping(QPushButton*& button) { + MappingTimer -= 1; + button->setText(tr("Press a key") + " [" + QString::number(MappingTimer) + "]"); + + if (pressedKeys.size() > 0) { + QStringList keyStrings; + + for (const QString& buttonAction : pressedKeys) { + keyStrings << buttonAction; + } + + QString combo = keyStrings.join(","); + SetMapping(combo); + MappingCompleted = true; + EnableMapping = false; + + MappingButton->setText(combo); + pressedKeys.clear(); + timer->stop(); + } + if (MappingCompleted) { + EnableMapping = false; + EnableMappingButtons(); + timer->stop(); + + button->setText(mapping); + } + + if (MappingTimer <= 0) { + button->setText(mapping); + EnableMapping = false; + EnableMappingButtons(); + timer->stop(); + } +} + +void KBMSettings::SetMapping(QString input) { + mapping = input; + MappingCompleted = true; +} + +bool KBMSettings::eventFilter(QObject* obj, QEvent* event) { + if (event->type() == QEvent::Close) { + if (HelpWindowOpen) { + HelpWindow->close(); + HelpWindowOpen = false; + } + } + + if (EnableMapping) { + if (event->type() == QEvent::KeyPress) { + QKeyEvent* keyEvent = static_cast(event); + + if (keyEvent->isAutoRepeat()) + return true; + + if (pressedKeys.size() >= 3) { + return true; + } + + switch (keyEvent->key()) { + case Qt::Key_Space: + pressedKeys.insert("space"); + break; + case Qt::Key_Comma: + if (Qt::KeypadModifier & QApplication::keyboardModifiers()) { + pressedKeys.insert("kpcomma"); + } else { + pressedKeys.insert("comma"); + } + break; + case Qt::Key_Period: + if (Qt::KeypadModifier & QApplication::keyboardModifiers()) { + pressedKeys.insert("kpperiod"); + } else { + pressedKeys.insert("period"); + } + break; + case Qt::Key_Slash: + if (Qt::KeypadModifier & QApplication::keyboardModifiers()) + pressedKeys.insert("kpdivide"); + break; + case Qt::Key_Asterisk: + if (Qt::KeypadModifier & QApplication::keyboardModifiers()) + pressedKeys.insert("kpmultiply"); + break; + case Qt::Key_Question: + pressedKeys.insert("question"); + break; + case Qt::Key_Semicolon: + pressedKeys.insert("semicolon"); + break; + case Qt::Key_Minus: + if (Qt::KeypadModifier & QApplication::keyboardModifiers()) { + pressedKeys.insert("kpminus"); + } else { + pressedKeys.insert("minus"); + } + break; + case Qt::Key_Plus: + if (Qt::KeypadModifier & QApplication::keyboardModifiers()) { + pressedKeys.insert("kpplus"); + } else { + pressedKeys.insert("plus"); + } + break; + case Qt::Key_ParenLeft: + pressedKeys.insert("lparenthesis"); + break; + case Qt::Key_ParenRight: + pressedKeys.insert("rparenthesis"); + break; + case Qt::Key_BracketLeft: + pressedKeys.insert("lbracket"); + break; + case Qt::Key_BracketRight: + pressedKeys.insert("rbracket"); + break; + case Qt::Key_BraceLeft: + pressedKeys.insert("lbrace"); + break; + case Qt::Key_BraceRight: + pressedKeys.insert("rbrace"); + break; + case Qt::Key_Backslash: + pressedKeys.insert("backslash"); + break; + case Qt::Key_Tab: + pressedKeys.insert("tab"); + break; + case Qt::Key_Backspace: + pressedKeys.insert("backspace"); + break; + case Qt::Key_Return: + pressedKeys.insert("enter"); + break; + case Qt::Key_Enter: + pressedKeys.insert("kpenter"); + break; + case Qt::Key_Home: + pressedKeys.insert("home"); + break; + case Qt::Key_End: + pressedKeys.insert("end"); + break; + case Qt::Key_PageDown: + pressedKeys.insert("pgdown"); + break; + case Qt::Key_PageUp: + pressedKeys.insert("pgup"); + break; + case Qt::Key_CapsLock: + pressedKeys.insert("capslock"); + break; + case Qt::Key_Escape: + pressedKeys.insert("unmapped"); + break; + case Qt::Key_Shift: + if (keyEvent->nativeScanCode() == rshift) { + pressedKeys.insert("rshift"); + } else { + pressedKeys.insert("lshift"); + } + break; + case Qt::Key_Alt: + if (keyEvent->nativeScanCode() == ralt) { + pressedKeys.insert("ralt"); + } else { + pressedKeys.insert("lalt"); + } + break; + case Qt::Key_Control: + if (keyEvent->nativeScanCode() == rctrl) { + pressedKeys.insert("rctrl"); + } else { + pressedKeys.insert("lctrl"); + } + break; + case Qt::Key_Meta: + activateWindow(); +#ifdef _WIN32 + pressedKeys.insert("lwin"); +#else + pressedKeys.insert("lmeta"); +#endif + case Qt::Key_1: + if (Qt::KeypadModifier & QApplication::keyboardModifiers()) { + pressedKeys.insert("kp1"); + } else { + pressedKeys.insert("1"); + } + break; + case Qt::Key_2: + if (Qt::KeypadModifier & QApplication::keyboardModifiers()) { + pressedKeys.insert("kp2"); + } else { + pressedKeys.insert("2"); + } + break; + case Qt::Key_3: + if (Qt::KeypadModifier & QApplication::keyboardModifiers()) { + pressedKeys.insert("kp3"); + } else { + pressedKeys.insert("3"); + } + break; + case Qt::Key_4: + if (Qt::KeypadModifier & QApplication::keyboardModifiers()) { + pressedKeys.insert("kp4"); + } else { + pressedKeys.insert("4"); + } + break; + case Qt::Key_5: + if (Qt::KeypadModifier & QApplication::keyboardModifiers()) { + pressedKeys.insert("kp5"); + } else { + pressedKeys.insert("5"); + } + break; + case Qt::Key_6: + if (Qt::KeypadModifier & QApplication::keyboardModifiers()) { + pressedKeys.insert("kp6"); + } else { + pressedKeys.insert("6"); + } + break; + case Qt::Key_7: + if (Qt::KeypadModifier & QApplication::keyboardModifiers()) { + pressedKeys.insert("kp7"); + } else { + pressedKeys.insert("7"); + } + break; + case Qt::Key_8: + if (Qt::KeypadModifier & QApplication::keyboardModifiers()) { + pressedKeys.insert("kp8"); + } else { + pressedKeys.insert("8"); + } + break; + case Qt::Key_9: + if (Qt::KeypadModifier & QApplication::keyboardModifiers()) { + pressedKeys.insert("kp9"); + } else { + pressedKeys.insert("9"); + } + break; + case Qt::Key_0: + if (Qt::KeypadModifier & QApplication::keyboardModifiers()) { + pressedKeys.insert("kp0"); + } else { + pressedKeys.insert("0"); + } + break; + case Qt::Key_Up: + activateWindow(); + pressedKeys.insert("up"); + break; + case Qt::Key_Down: + pressedKeys.insert("down"); + break; + case Qt::Key_Left: + pressedKeys.insert("left"); + break; + case Qt::Key_Right: + pressedKeys.insert("right"); + break; + case Qt::Key_A: + pressedKeys.insert("a"); + break; + case Qt::Key_B: + pressedKeys.insert("b"); + break; + case Qt::Key_C: + pressedKeys.insert("c"); + break; + case Qt::Key_D: + pressedKeys.insert("d"); + break; + case Qt::Key_E: + pressedKeys.insert("e"); + break; + case Qt::Key_F: + pressedKeys.insert("f"); + break; + case Qt::Key_G: + pressedKeys.insert("g"); + break; + case Qt::Key_H: + pressedKeys.insert("h"); + break; + case Qt::Key_I: + pressedKeys.insert("i"); + break; + case Qt::Key_J: + pressedKeys.insert("j"); + break; + case Qt::Key_K: + pressedKeys.insert("k"); + break; + case Qt::Key_L: + pressedKeys.insert("l"); + break; + case Qt::Key_M: + pressedKeys.insert("m"); + break; + case Qt::Key_N: + pressedKeys.insert("n"); + break; + case Qt::Key_O: + pressedKeys.insert("o"); + break; + case Qt::Key_P: + pressedKeys.insert("p"); + break; + case Qt::Key_Q: + pressedKeys.insert("q"); + break; + case Qt::Key_R: + pressedKeys.insert("r"); + break; + case Qt::Key_S: + pressedKeys.insert("s"); + break; + case Qt::Key_T: + pressedKeys.insert("t"); + break; + case Qt::Key_U: + pressedKeys.insert("u"); + break; + case Qt::Key_V: + pressedKeys.insert("v"); + break; + case Qt::Key_W: + pressedKeys.insert("w"); + break; + case Qt::Key_X: + pressedKeys.insert("x"); + break; + case Qt::Key_Y: + pressedKeys.insert("Y"); + break; + case Qt::Key_Z: + pressedKeys.insert("z"); + break; + default: + break; + } + return true; + } + } + + if (event->type() == QEvent::MouseButtonPress) { + QMouseEvent* mouseEvent = static_cast(event); + if (pressedKeys.size() < 3) { + switch (mouseEvent->button()) { + case Qt::LeftButton: + pressedKeys.insert("leftbutton"); + break; + case Qt::RightButton: + pressedKeys.insert("rightbutton"); + break; + case Qt::MiddleButton: + pressedKeys.insert("middlebutton"); + break; + default: + break; + } + return true; + } + } + + const QList AxisList = { + ui->LStickUpButton, ui->LStickDownButton, ui->LStickLeftButton, ui->LStickRightButton, + ui->RStickUpButton, ui->LStickDownButton, ui->LStickLeftButton, ui->RStickRightButton}; + + if (event->type() == QEvent::Wheel) { + QWheelEvent* wheelEvent = static_cast(event); + if (pressedKeys.size() < 3) { + if (wheelEvent->angleDelta().y() > 5) { + if (std::find(AxisList.begin(), AxisList.end(), MappingButton) == AxisList.end()) { + pressedKeys.insert("mousewheelup"); + } else { + QMessageBox::information(this, tr("Cannot set mapping"), + tr("Mousewheel cannot be mapped to stick outputs")); + } + } else if (wheelEvent->angleDelta().y() < -5) { + if (std::find(AxisList.begin(), AxisList.end(), MappingButton) == AxisList.end()) { + pressedKeys.insert("mousewheeldown"); + } else { + QMessageBox::information(this, tr("Cannot set mapping"), + tr("Mousewheel cannot be mapped to stick outputs")); + } + } + if (wheelEvent->angleDelta().x() > 5) { + if (std::find(AxisList.begin(), AxisList.end(), MappingButton) == AxisList.end()) { + // QT changes scrolling to horizontal for all widgets with the alt modifier + if (Qt::AltModifier & QApplication::keyboardModifiers()) { + pressedKeys.insert("mousewheelup"); + } else { + pressedKeys.insert("mousewheelright"); + } + } else { + QMessageBox::information(this, tr("Cannot set mapping"), + tr("Mousewheel cannot be mapped to stick outputs")); + } + } else if (wheelEvent->angleDelta().x() < -5) { + if (std::find(AxisList.begin(), AxisList.end(), MappingButton) == AxisList.end()) { + if (Qt::AltModifier & QApplication::keyboardModifiers()) { + pressedKeys.insert("mousewheeldown"); + } else { + pressedKeys.insert("mousewheelleft"); + } + } else { + QMessageBox::information(this, tr("Cannot set mapping"), + tr("Mousewheel cannot be mapped to stick outputs")); + } + } + } + } + + return QDialog::eventFilter(obj, event); +} + +KBMSettings::~KBMSettings() {} diff --git a/src/qt_gui/kbm_gui.h b/src/qt_gui/kbm_gui.h new file mode 100644 index 000000000..bfeed2b01 --- /dev/null +++ b/src/qt_gui/kbm_gui.h @@ -0,0 +1,73 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include +#include "game_info.h" + +namespace Ui { +class KBMSettings; +} + +class KBMSettings : public QDialog { + Q_OBJECT +public: + explicit KBMSettings(std::shared_ptr game_info_get, QWidget* parent = nullptr); + ~KBMSettings(); + +private Q_SLOTS: + void SaveKBMConfig(bool CloseOnSave); + void SetDefault(); + void CheckMapping(QPushButton*& button); + void StartTimer(QPushButton*& button); + void onHelpClicked(); + +private: + std::unique_ptr ui; + std::shared_ptr m_game_info; + +#ifdef _WIN32 + const int lctrl = 29; + const int rctrl = 57373; + const int lalt = 56; + const int ralt = 57400; + const int lshift = 42; + const int rshift = 54; +#else + const int lctrl = 37; + const int rctrl = 105; + const int lalt = 64; + const int ralt = 108; + const int lshift = 50; + const int rshift = 62; +#endif + + bool eventFilter(QObject* obj, QEvent* event) override; + void ButtonConnects(); + void SetUIValuestoMappings(std::string config_id); + void GetGameTitle(); + void DisableMappingButtons(); + void EnableMappingButtons(); + void SetMapping(QString input); + + QSet pressedKeys; + bool EnableMapping = false; + bool MappingCompleted = false; + bool HelpWindowOpen = false; + QString mapping; + QString modifier; + int MappingTimer; + QTimer* timer; + QPushButton* MappingButton; + QList ButtonsList; + std::string config_id; + const std::vector ControllerInputs = { + "cross", "circle", "square", "triangle", "l1", + "r1", "l2", "r2", "l3", + + "r3", "options", "pad_up", + + "pad_down", + + "pad_left", "pad_right", "axis_left_x", "axis_left_y", "axis_right_x", + "axis_right_y", "back"}; +}; diff --git a/src/qt_gui/kbm_gui.ui b/src/qt_gui/kbm_gui.ui new file mode 100644 index 000000000..c8d63cd00 --- /dev/null +++ b/src/qt_gui/kbm_gui.ui @@ -0,0 +1,1942 @@ + + + + KBMSettings + + + Qt::WindowModality::WindowModal + + + + 0 + 0 + 1234 + 796 + + + + + 0 + 0 + + + + Qt::FocusPolicy::StrongFocus + + + Configure Controls + + + true + + + + + + Qt::FocusPolicy::NoFocus + + + true + + + + + 0 + 0 + 1214 + 746 + + + + + + 0 + 0 + 1211 + 741 + + + + + + + 5 + + + + + true + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + D-Pad + + + + 6 + + + 5 + + + 5 + + + 5 + + + 5 + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 160 + 0 + + + + + 0 + 16777215 + + + + Up + + + + + + Qt::FocusPolicy::NoFocus + + + unmapped + + + + + + + + + + + + + + + + 160 + 0 + + + + Left + + + + 5 + + + 5 + + + 5 + + + 5 + + + + + Qt::FocusPolicy::NoFocus + + + unmapped + + + + + + + + + + + 160 + 0 + + + + Right + + + + 5 + + + 5 + + + 5 + + + 5 + + + + + Qt::FocusPolicy::NoFocus + + + unmapped + + + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 160 + 0 + + + + + 124 + 16777215 + + + + Down + + + + + + Qt::FocusPolicy::NoFocus + + + unmapped + + + + + + + + + + + + + + + + Qt::Orientation::Vertical + + + QSizePolicy::Policy::Maximum + + + + 20 + 40 + + + + + + + + + 0 + 0 + + + + + 344 + 16777215 + + + + Left Analog Halfmode + + + + + + Qt::FocusPolicy::NoFocus + + + unmapped + + + + + + + + true + + + + hold to move left stick at half-speed + + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Left Stick + + + + 5 + + + 5 + + + 5 + + + 5 + + + + + + 16777215 + 2121 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 160 + 0 + + + + + 124 + 16777215 + + + + Up + + + + + + Qt::FocusPolicy::NoFocus + + + unmapped + + + + + + + + + + + + + + + + 160 + 0 + + + + Left + + + + 5 + + + 5 + + + 5 + + + 5 + + + + + Qt::FocusPolicy::NoFocus + + + unmapped + + + + + + + + + + + 160 + 0 + + + + + 179 + 16777215 + + + + Right + + + + 5 + + + 5 + + + 5 + + + 5 + + + + + Qt::FocusPolicy::NoFocus + + + unmapped + + + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 160 + 0 + + + + + 124 + 21212 + + + + Down + + + + + + Qt::FocusPolicy::NoFocus + + + unmapped + + + + + + + + + + + + + + + + + + 0 + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 12 + true + + + + Config Selection + + + Qt::AlignmentFlag::AlignCenter + + + + + + + + + 9 + false + + + + Qt::FocusPolicy::NoFocus + + + + + + -1 + + + Common Config + + + + + + + + 10 + true + + + + Common Config + + + Qt::AlignmentFlag::AlignCenter + + + true + + + + + + + + + + + + 0 + 0 + + + + + 9 + false + + + + Qt::FocusPolicy::NoFocus + + + Use per-game configs + + + + + + + + 9 + false + + + + Qt::FocusPolicy::NoFocus + + + Copy from Common Config + + + + + + + + + + + + 0 + + + + + + + + 0 + 0 + + + + + 160 + 0 + + + + L1 + + + + 5 + + + 5 + + + 5 + + + 5 + + + + + + 0 + 0 + + + + Qt::FocusPolicy::NoFocus + + + unmapped + + + + + + + + + + + 0 + 0 + + + + + 160 + 0 + + + + L2 + + + + 5 + + + 5 + + + 5 + + + 5 + + + + + + 0 + 0 + + + + Qt::FocusPolicy::NoFocus + + + unmapped + + + + + + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + true + + + + + + + + + + + 0 + 0 + + + + Qt::FocusPolicy::NoFocus + + + Text Editor + + + + + + + + 0 + 0 + + + + Qt::FocusPolicy::NoFocus + + + Help + + + + + + + + + + + + + + + 0 + 0 + + + + + 160 + 0 + + + + R1 + + + + 5 + + + 5 + + + 5 + + + 5 + + + + + + 0 + 0 + + + + Qt::FocusPolicy::NoFocus + + + unmapped + + + + + + + + + + + 0 + 0 + + + + + 160 + 0 + + + + R2 + + + + 5 + + + 5 + + + 5 + + + 5 + + + + + + 0 + 0 + + + + Qt::FocusPolicy::NoFocus + + + unmapped + + + + + + + + + + + + + + + 0 + 200 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 500 + 200 + + + + :/images/KBM.png + + + true + + + Qt::AlignmentFlag::AlignBottom|Qt::AlignmentFlag::AlignHCenter + + + + + + + + + + 0 + + + QLayout::SizeConstraint::SetDefaultConstraint + + + + + + + + 0 + 0 + + + + + 160 + 0 + + + + L3 + + + + 5 + + + 5 + + + 5 + + + 5 + + + + + + 0 + 0 + + + + Qt::FocusPolicy::NoFocus + + + unmapped + + + + + + + + + + + 0 + 0 + + + + + 160 + 0 + + + + Touchpad Click + + + + + + + 0 + 0 + + + + Qt::FocusPolicy::NoFocus + + + unmapped + + + + + + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Mouse to Joystick + + + + + + Qt::FocusPolicy::NoFocus + + + + + + + + true + + + + *press F7 ingame to activate + + + true + + + + + + + + + + + + + + + 0 + 0 + + + + + 160 + 0 + + + + R3 + + + + 5 + + + 5 + + + 5 + + + 5 + + + + + + 0 + 0 + + + + Qt::FocusPolicy::NoFocus + + + unmapped + + + + + + + + + + + 0 + 0 + + + + + 160 + 0 + + + + Options + + + + 5 + + + 5 + + + 5 + + + 5 + + + + + + 0 + 0 + + + + Qt::FocusPolicy::NoFocus + + + unmapped + + + + + + + + + + + + + + + + + + + 0 + 0 + + + + + false + + + + Mouse Movement Parameters + + + + + + + + + false + + + + Deadzone Offset (def 0.50): 0.50 + + + + + + + + 0 + 0 + + + + Qt::FocusPolicy::NoFocus + + + 100 + + + 50 + + + Qt::Orientation::Horizontal + + + + + + + + + + + + false + + + + Speed Multiplier (def 1.0): 1.0 + + + + + + + + 0 + 0 + + + + Qt::FocusPolicy::NoFocus + + + 1 + + + 50 + + + 5 + + + 10 + + + Qt::Orientation::Horizontal + + + + + + + + + + + + false + + + + Speed Offset (def 0.125): 0.125 + + + + + + + + 0 + 0 + + + + Qt::FocusPolicy::NoFocus + + + 1000 + + + 100 + + + 125 + + + Qt::Orientation::Horizontal + + + + + + + + + + 0 + 0 + + + + + true + false + + + + note: click Help Button/Special Keybindings for more information + + + + + + + + + + + + + + + + 5 + + + + + + 0 + 0 + + + + Face Buttons + + + + 5 + + + 5 + + + 5 + + + 5 + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 160 + 0 + + + + + 0 + 16777215 + + + + Triangle + + + + + + Qt::FocusPolicy::NoFocus + + + unmapped + + + + + + + + + + + + + + + + 160 + 0 + + + + Square + + + + 5 + + + 5 + + + 5 + + + 5 + + + + + Qt::FocusPolicy::NoFocus + + + unmapped + + + + + + + + + + + 160 + 0 + + + + Circle + + + + 5 + + + 5 + + + 5 + + + 5 + + + + + Qt::FocusPolicy::NoFocus + + + unmapped + + + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 160 + 0 + + + + + 124 + 16777215 + + + + Cross + + + + + + Qt::FocusPolicy::NoFocus + + + unmapped + + + + + + + + + + + + + + + + Qt::Orientation::Vertical + + + QSizePolicy::Policy::Maximum + + + + 20 + 40 + + + + + + + + + 0 + 0 + + + + + 344 + 16777215 + + + + Right Analog Halfmode + + + + + + Qt::FocusPolicy::NoFocus + + + unmapped + + + + + + + + true + + + + hold to move right stick at half-speed + + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Right Stick + + + + 5 + + + 5 + + + 5 + + + 5 + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 160 + 0 + + + + + 124 + 1231321 + + + + Up + + + + + + + 0 + 0 + + + + Qt::FocusPolicy::NoFocus + + + unmapped + + + + + + + + + + + + + + + + 160 + 0 + + + + Left + + + + 5 + + + 5 + + + 5 + + + 5 + + + + + Qt::FocusPolicy::NoFocus + + + unmapped + + + + + + + + + + + 160 + 0 + + + + Right + + + + 5 + + + 5 + + + 5 + + + 5 + + + + + Qt::FocusPolicy::NoFocus + + + unmapped + + + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 160 + 0 + + + + + 124 + 2121 + + + + Down + + + + + + Qt::FocusPolicy::NoFocus + + + unmapped + + + + + + + + + + + + + + + + + + + + + + + QDialogButtonBox::StandardButton::Apply|QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::RestoreDefaults|QDialogButtonBox::StandardButton::Save + + + false + + + + + + + + + + diff --git a/src/qt_gui/kbm_help_dialog.cpp b/src/qt_gui/kbm_help_dialog.cpp index 44f75f6f8..c13e18b59 100644 --- a/src/qt_gui/kbm_help_dialog.cpp +++ b/src/qt_gui/kbm_help_dialog.cpp @@ -77,11 +77,11 @@ HelpDialog::HelpDialog(bool* open_flag, QWidget* parent) : QDialog(parent) { QVBoxLayout* containerLayout = new QVBoxLayout(containerWidget); // Add expandable sections to container layout - auto* quickstartSection = new ExpandableSection("Quickstart", quickstart()); - auto* faqSection = new ExpandableSection("FAQ", faq()); - auto* syntaxSection = new ExpandableSection("Syntax", syntax()); - auto* specialSection = new ExpandableSection("Special Bindings", special()); - auto* bindingsSection = new ExpandableSection("Keybindings", bindings()); + auto* quickstartSection = new ExpandableSection(tr("Quickstart"), quickstart()); + auto* faqSection = new ExpandableSection(tr("FAQ"), faq()); + auto* syntaxSection = new ExpandableSection(tr("Syntax"), syntax()); + auto* specialSection = new ExpandableSection(tr("Special Bindings"), special()); + auto* bindingsSection = new ExpandableSection(tr("Keybindings"), bindings()); containerLayout->addWidget(quickstartSection); containerLayout->addWidget(faqSection); @@ -109,4 +109,4 @@ HelpDialog::HelpDialog(bool* open_flag, QWidget* parent) : QDialog(parent) { connect(syntaxSection, &ExpandableSection::expandedChanged, this, &HelpDialog::adjustSize); connect(specialSection, &ExpandableSection::expandedChanged, this, &HelpDialog::adjustSize); connect(bindingsSection, &ExpandableSection::expandedChanged, this, &HelpDialog::adjustSize); -} \ No newline at end of file +} diff --git a/src/qt_gui/main.cpp b/src/qt_gui/main.cpp index 36dc226ae..bd9dca6ce 100644 --- a/src/qt_gui/main.cpp +++ b/src/qt_gui/main.cpp @@ -157,8 +157,8 @@ int main(int argc, char* argv[]) { } } - // If no game directory is set and no command line argument, prompt for it - if (Config::getGameInstallDirs().empty() && !has_command_line_argument) { + // If no game directories are set and no command line argument, prompt for it + if (Config::getGameInstallDirsEnabled().empty() && !has_command_line_argument) { GameInstallDialog dlg; dlg.exec(); } diff --git a/src/qt_gui/main_window.cpp b/src/qt_gui/main_window.cpp index d9fb45fac..36037fd4c 100644 --- a/src/qt_gui/main_window.cpp +++ b/src/qt_gui/main_window.cpp @@ -1,10 +1,13 @@ // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include "SDL3/SDL_events.h" + #include #include #include #include +#include #include "about_dialog.h" #include "cheats_patches.h" @@ -15,17 +18,12 @@ #include "common/path_util.h" #include "common/scm_rev.h" #include "common/string_util.h" -#include "common/version.h" #include "control_settings.h" -#include "core/file_format/pkg.h" -#include "core/loader.h" #include "game_install_dialog.h" -#include "install_dir_select.h" +#include "kbm_gui.h" #include "main_window.h" #include "settings_dialog.h" -#include "kbm_config_dialog.h" - #include "video_core/renderer_vulkan/vk_instance.h" #ifdef ENABLE_DISCORD_RPC #include "common/discord_rpc_handler.h" @@ -46,11 +44,11 @@ MainWindow::~MainWindow() { bool MainWindow::Init() { auto start = std::chrono::steady_clock::now(); // setup ui + LoadTranslation(); AddUiWidgets(); CreateActions(); CreateRecentGameActions(); ConfigureGuiFromSettings(); - LoadTranslation(); CreateDockWindows(); CreateConnects(); SetLastUsedTheme(); @@ -59,8 +57,8 @@ bool MainWindow::Init() { // show ui setMinimumSize(720, 405); std::string window_title = ""; - if (Common::isRelease) { - window_title = fmt::format("shadPS4 v{}", Common::VERSION); + if (Common::g_is_release) { + window_title = fmt::format("shadPS4 v{}", Common::g_version); } else { std::string remote_url(Common::g_scm_remote_url); std::string remote_host; @@ -70,10 +68,10 @@ bool MainWindow::Init() { remote_host = "unknown"; } if (remote_host == "shadps4-emu" || remote_url.length() == 0) { - window_title = fmt::format("shadPS4 v{} {} {}", Common::VERSION, Common::g_scm_branch, + window_title = fmt::format("shadPS4 v{} {} {}", Common::g_version, Common::g_scm_branch, Common::g_scm_desc); } else { - window_title = fmt::format("shadPS4 v{} {}/{} {}", Common::VERSION, remote_host, + window_title = fmt::format("shadPS4 v{} {}/{} {}", Common::g_version, remote_host, Common::g_scm_branch, Common::g_scm_desc); } } @@ -133,23 +131,160 @@ void MainWindow::CreateActions() { m_theme_act_group->addAction(ui->setThemeOled); } +void MainWindow::PauseGame() { + SDL_Event event; + SDL_memset(&event, 0, sizeof(event)); + event.type = SDL_EVENT_TOGGLE_PAUSE; + is_paused = !is_paused; + UpdateToolbarButtons(); + SDL_PushEvent(&event); +} + +void MainWindow::toggleLabelsUnderIcons() { + bool showLabels = ui->toggleLabelsAct->isChecked(); + Config::setShowLabelsUnderIcons(); + UpdateToolbarLabels(); + if (isGameRunning) { + UpdateToolbarButtons(); + } +} + +void MainWindow::toggleFullscreen() { + SDL_Event event; + SDL_memset(&event, 0, sizeof(event)); + event.type = SDL_EVENT_TOGGLE_FULLSCREEN; + SDL_PushEvent(&event); +} + +QWidget* MainWindow::createButtonWithLabel(QPushButton* button, const QString& labelText, + bool showLabel) { + QWidget* container = new QWidget(this); + QVBoxLayout* layout = new QVBoxLayout(container); + layout->setAlignment(Qt::AlignCenter | Qt::AlignBottom); + layout->setContentsMargins(0, 0, 0, 0); + layout->addWidget(button); + + QLabel* label = nullptr; + if (showLabel && ui->toggleLabelsAct->isChecked()) { + label = new QLabel(labelText, this); + label->setAlignment(Qt::AlignCenter | Qt::AlignBottom); + layout->addWidget(label); + button->setToolTip(""); + } else { + button->setToolTip(labelText); + } + + container->setLayout(layout); + container->setProperty("buttonLabel", QVariant::fromValue(label)); + return container; +} + +QWidget* createSpacer(QWidget* parent) { + QWidget* spacer = new QWidget(parent); + spacer->setFixedWidth(15); + spacer->setFixedHeight(15); + return spacer; +} + void MainWindow::AddUiWidgets() { // add toolbar widgets QApplication::setStyle("Fusion"); - ui->toolBar->setObjectName("mw_toolbar"); - ui->toolBar->addWidget(ui->playButton); - ui->toolBar->addWidget(ui->pauseButton); - ui->toolBar->addWidget(ui->stopButton); - ui->toolBar->addWidget(ui->refreshButton); - ui->toolBar->addWidget(ui->settingsButton); - ui->toolBar->addWidget(ui->controllerButton); - ui->toolBar->addWidget(ui->keyboardButton); + + bool showLabels = ui->toggleLabelsAct->isChecked(); + ui->toolBar->clear(); + + ui->toolBar->addWidget(createSpacer(this)); + ui->toolBar->addWidget(createButtonWithLabel(ui->playButton, tr("Play"), showLabels)); + ui->toolBar->addWidget(createButtonWithLabel(ui->pauseButton, tr("Pause"), showLabels)); + ui->toolBar->addWidget(createButtonWithLabel(ui->stopButton, tr("Stop"), showLabels)); + ui->toolBar->addWidget(createButtonWithLabel(ui->restartButton, tr("Restart"), showLabels)); + ui->toolBar->addWidget(createSpacer(this)); + ui->toolBar->addWidget(createButtonWithLabel(ui->settingsButton, tr("Settings"), showLabels)); + ui->toolBar->addWidget( + createButtonWithLabel(ui->fullscreenButton, tr("Full Screen"), showLabels)); + ui->toolBar->addWidget(createSpacer(this)); + ui->toolBar->addWidget( + createButtonWithLabel(ui->controllerButton, tr("Controllers"), showLabels)); + ui->toolBar->addWidget(createButtonWithLabel(ui->keyboardButton, tr("Keyboard"), showLabels)); + ui->toolBar->addWidget(createSpacer(this)); QFrame* line = new QFrame(this); - line->setFrameShape(QFrame::StyledPanel); + line->setFrameShape(QFrame::VLine); line->setFrameShadow(QFrame::Sunken); + line->setMinimumWidth(2); ui->toolBar->addWidget(line); - ui->toolBar->addWidget(ui->sizeSliderContainer); - ui->toolBar->addWidget(ui->mw_searchbar); + ui->toolBar->addWidget(createSpacer(this)); + if (showLabels) { + QLabel* pauseButtonLabel = ui->pauseButton->parentWidget()->findChild(); + if (pauseButtonLabel) { + pauseButtonLabel->setVisible(false); + } + } + ui->toolBar->addWidget( + createButtonWithLabel(ui->refreshButton, tr("Refresh List"), showLabels)); + ui->toolBar->addWidget(createSpacer(this)); + + QBoxLayout* toolbarLayout = new QBoxLayout(QBoxLayout::TopToBottom); + toolbarLayout->setSpacing(2); + toolbarLayout->setContentsMargins(2, 2, 2, 2); + ui->sizeSliderContainer->setFixedWidth(150); + + QWidget* searchSliderContainer = new QWidget(this); + QBoxLayout* searchSliderLayout = new QBoxLayout(QBoxLayout::TopToBottom); + searchSliderLayout->setContentsMargins(0, 0, 6, 6); + searchSliderLayout->setSpacing(2); + ui->mw_searchbar->setFixedWidth(150); + + searchSliderLayout->addWidget(ui->sizeSliderContainer); + searchSliderLayout->addWidget(ui->mw_searchbar); + + searchSliderContainer->setLayout(searchSliderLayout); + + ui->toolBar->addWidget(searchSliderContainer); + + if (!showLabels) { + toolbarLayout->addWidget(searchSliderContainer); + } + + ui->playButton->setVisible(true); + ui->pauseButton->setVisible(false); +} + +void MainWindow::UpdateToolbarButtons() { + // add toolbar widgets when game is running + bool showLabels = ui->toggleLabelsAct->isChecked(); + + ui->playButton->setVisible(false); + ui->pauseButton->setVisible(true); + + if (showLabels) { + QLabel* playButtonLabel = ui->playButton->parentWidget()->findChild(); + if (playButtonLabel) + playButtonLabel->setVisible(false); + } + + if (is_paused) { + ui->pauseButton->setIcon(ui->playButton->icon()); + ui->pauseButton->setToolTip(tr("Resume")); + } else { + if (isIconBlack) { + ui->pauseButton->setIcon(QIcon(":images/pause_icon.png")); + } else { + ui->pauseButton->setIcon(RecolorIcon(QIcon(":images/pause_icon.png"), isWhite)); + } + ui->pauseButton->setToolTip(tr("Pause")); + } + + if (showLabels) { + QLabel* pauseButtonLabel = ui->pauseButton->parentWidget()->findChild(); + if (pauseButtonLabel) { + pauseButtonLabel->setText(is_paused ? tr("Resume") : tr("Pause")); + pauseButtonLabel->setVisible(true); + } + } +} + +void MainWindow::UpdateToolbarLabels() { + AddUiWidgets(); } void MainWindow::CreateDockWindows() { @@ -254,6 +389,8 @@ void MainWindow::CreateConnects() { connect(ui->refreshButton, &QPushButton::clicked, this, &MainWindow::RefreshGameTable); connect(ui->showGameListAct, &QAction::triggered, this, &MainWindow::ShowGameList); connect(this, &MainWindow::ExtractionFinished, this, &MainWindow::RefreshGameTable); + connect(ui->toggleLabelsAct, &QAction::toggled, this, &MainWindow::toggleLabelsUnderIcons); + connect(ui->fullscreenButton, &QPushButton::clicked, this, &MainWindow::toggleFullscreen); connect(ui->sizeSlider, &QSlider::valueChanged, this, [this](int value) { if (isTableList) { @@ -277,6 +414,7 @@ void MainWindow::CreateConnects() { }); connect(ui->playButton, &QPushButton::clicked, this, &MainWindow::StartGame); + connect(ui->pauseButton, &QPushButton::clicked, this, &MainWindow::PauseGame); connect(m_game_grid_frame.get(), &QTableWidget::cellDoubleClicked, this, &MainWindow::StartGame); connect(m_game_list_frame.get(), &QTableWidget::cellDoubleClicked, this, @@ -348,14 +486,13 @@ void MainWindow::CreateConnects() { settingsDialog->exec(); }); - // this is the editor for kbm keybinds connect(ui->controllerButton, &QPushButton::clicked, this, [this]() { auto configWindow = new ControlSettings(m_game_info, this); configWindow->exec(); }); connect(ui->keyboardButton, &QPushButton::clicked, this, [this]() { - auto kbmWindow = new EditorDialog(this); + auto kbmWindow = new KBMSettings(m_game_info, this); kbmWindow->exec(); }); @@ -379,9 +516,11 @@ void MainWindow::CreateConnects() { Config::setIconSize(36); Config::setSliderPosition(0); } else { + m_game_grid_frame->icon_size = 69; ui->sizeSlider->setValue(0); // icone_size - 36 Config::setIconSizeGrid(69); Config::setSliderPositionGrid(0); + m_game_grid_frame->PopulateGameGrid(m_game_info->m_games, false); } }); @@ -392,9 +531,11 @@ void MainWindow::CreateConnects() { Config::setIconSize(64); Config::setSliderPosition(28); } else { + m_game_grid_frame->icon_size = 97; ui->sizeSlider->setValue(28); Config::setIconSizeGrid(97); Config::setSliderPositionGrid(28); + m_game_grid_frame->PopulateGameGrid(m_game_info->m_games, false); } }); @@ -405,9 +546,11 @@ void MainWindow::CreateConnects() { Config::setIconSize(128); Config::setSliderPosition(92); } else { + m_game_grid_frame->icon_size = 161; ui->sizeSlider->setValue(92); - Config::setIconSizeGrid(160); - Config::setSliderPositionGrid(91); + Config::setIconSizeGrid(161); + Config::setSliderPositionGrid(92); + m_game_grid_frame->PopulateGameGrid(m_game_info->m_games, false); } }); @@ -418,9 +561,11 @@ void MainWindow::CreateConnects() { Config::setIconSize(256); Config::setSliderPosition(220); } else { + m_game_grid_frame->icon_size = 256; ui->sizeSlider->setValue(220); Config::setIconSizeGrid(256); Config::setSliderPositionGrid(220); + m_game_grid_frame->PopulateGameGrid(m_game_info->m_games, false); } }); // List @@ -440,6 +585,7 @@ void MainWindow::CreateConnects() { ui->sizeSlider->setEnabled(true); ui->sizeSlider->setSliderPosition(slider_pos); ui->mw_searchbar->setText(""); + SetLastIconSizeBullet(); }); // Grid connect(ui->setlistModeGridAct, &QAction::triggered, m_dock_widget.data(), [this]() { @@ -458,6 +604,7 @@ void MainWindow::CreateConnects() { ui->sizeSlider->setEnabled(true); ui->sizeSlider->setSliderPosition(slider_pos_grid); ui->mw_searchbar->setText(""); + SetLastIconSizeBullet(); }); // Elf Viewer connect(ui->setlistElfAct, &QAction::triggered, m_dock_widget.data(), [this]() { @@ -469,6 +616,7 @@ void MainWindow::CreateConnects() { isTableList = false; ui->sizeSlider->setDisabled(true); Config::setTableMode(2); + SetLastIconSizeBullet(); }); // Cheats/Patches Download. @@ -578,7 +726,6 @@ void MainWindow::CreateConnects() { }); // Package install. - connect(ui->bootInstallPkgAct, &QAction::triggered, this, &MainWindow::InstallPkg); connect(ui->bootGameAct, &QAction::triggered, this, &MainWindow::BootGame); connect(ui->gameInstallPathAct, &QAction::triggered, this, &MainWindow::InstallDirectory); @@ -586,13 +733,58 @@ void MainWindow::CreateConnects() { connect(ui->addElfFolderAct, &QAction::triggered, m_elf_viewer.data(), &ElfViewer::OpenElfFolder); - // Package Viewer. - connect(ui->pkgViewerAct, &QAction::triggered, this, [this]() { - PKGViewer* pkgViewer = new PKGViewer( - m_game_info, this, [this](std::filesystem::path file, int pkgNum, int nPkg) { - this->InstallDragDropPkg(file, pkgNum, nPkg); - }); - pkgViewer->show(); + // Trophy Viewer + connect(ui->trophyViewerAct, &QAction::triggered, this, [this]() { + if (m_game_info->m_games.empty()) { + QMessageBox::information( + this, tr("Trophy Viewer"), + tr("No games found. Please add your games to your library first.")); + return; + } + + const auto& firstGame = m_game_info->m_games[0]; + QString trophyPath, gameTrpPath; + Common::FS::PathToQString(trophyPath, firstGame.serial); + Common::FS::PathToQString(gameTrpPath, firstGame.path); + + auto game_update_path = Common::FS::PathFromQString(gameTrpPath); + game_update_path += "-UPDATE"; + if (std::filesystem::exists(game_update_path)) { + Common::FS::PathToQString(gameTrpPath, game_update_path); + } else { + game_update_path = Common::FS::PathFromQString(gameTrpPath); + game_update_path += "-patch"; + if (std::filesystem::exists(game_update_path)) { + Common::FS::PathToQString(gameTrpPath, game_update_path); + } + } + + QVector allTrophyGames; + for (const auto& game : m_game_info->m_games) { + TrophyGameInfo gameInfo; + gameInfo.name = QString::fromStdString(game.name); + Common::FS::PathToQString(gameInfo.trophyPath, game.serial); + Common::FS::PathToQString(gameInfo.gameTrpPath, game.path); + + auto update_path = Common::FS::PathFromQString(gameInfo.gameTrpPath); + update_path += "-UPDATE"; + if (std::filesystem::exists(update_path)) { + Common::FS::PathToQString(gameInfo.gameTrpPath, update_path); + } else { + update_path = Common::FS::PathFromQString(gameInfo.gameTrpPath); + update_path += "-patch"; + if (std::filesystem::exists(update_path)) { + Common::FS::PathToQString(gameInfo.gameTrpPath, update_path); + } + } + + allTrophyGames.append(gameInfo); + } + + QString gameName = QString::fromStdString(firstGame.name); + TrophyViewer* trophyViewer = + new TrophyViewer(trophyPath, gameTrpPath, gameName, allTrophyGames); + trophyViewer->show(); }); // Themes @@ -691,6 +883,8 @@ void MainWindow::StartGame() { return; } StartEmulator(path); + + UpdateToolbarButtons(); } } @@ -769,22 +963,6 @@ void MainWindow::SaveWindowState() const { this->geometry().width(), this->geometry().height()); } -void MainWindow::InstallPkg() { - QFileDialog dialog; - dialog.setFileMode(QFileDialog::ExistingFiles); - dialog.setNameFilter(tr("PKG File (*.PKG *.pkg)")); - if (dialog.exec()) { - QStringList fileNames = dialog.selectedFiles(); - int nPkg = fileNames.size(); - int pkgNum = 0; - for (const QString& file : fileNames) { - ++pkgNum; - std::filesystem::path path = Common::FS::PathFromQString(file); - MainWindow::InstallDragDropPkg(path, pkgNum, nPkg); - } - } -} - void MainWindow::BootGame() { QFileDialog dialog; dialog.setFileMode(QFileDialog::ExistingFile); @@ -808,260 +986,6 @@ void MainWindow::BootGame() { } } -void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int nPkg) { - if (Loader::DetectFileType(file) == Loader::FileTypes::Pkg) { - std::string failreason; - pkg = PKG(); - if (!pkg.Open(file, failreason)) { - QMessageBox::critical(this, tr("PKG ERROR"), QString::fromStdString(failreason)); - return; - } - if (!psf.Open(pkg.sfo)) { - QMessageBox::critical(this, tr("PKG ERROR"), - "Could not read SFO. Check log for details"); - return; - } - auto category = psf.GetString("CATEGORY"); - - if (!use_for_all_queued || pkgNum == 1) { - InstallDirSelect ids; - const auto selected = ids.exec(); - if (selected == QDialog::Rejected) { - return; - } - - last_install_dir = ids.getSelectedDirectory(); - delete_file_on_install = ids.deleteFileOnInstall(); - use_for_all_queued = ids.useForAllQueued(); - } - std::filesystem::path game_install_dir = last_install_dir; - - QString pkgType = QString::fromStdString(pkg.GetPkgFlags()); - bool use_game_update = pkgType.contains("PATCH") && Config::getSeparateUpdateEnabled(); - - // Default paths - auto game_folder_path = game_install_dir / pkg.GetTitleID(); - auto game_update_path = use_game_update ? game_folder_path.parent_path() / - (std::string{pkg.GetTitleID()} + "-UPDATE") - : game_folder_path; - const int max_depth = 5; - - if (pkgType.contains("PATCH")) { - // For patches, try to find the game recursively - auto found_game = Common::FS::FindGameByID(game_install_dir, - std::string{pkg.GetTitleID()}, max_depth); - if (found_game.has_value()) { - game_folder_path = found_game.value().parent_path(); - game_update_path = use_game_update ? game_folder_path.parent_path() / - (std::string{pkg.GetTitleID()} + "-UPDATE") - : game_folder_path; - } - } else { - // For base games, we check if the game is already installed - auto found_game = Common::FS::FindGameByID(game_install_dir, - std::string{pkg.GetTitleID()}, max_depth); - if (found_game.has_value()) { - game_folder_path = found_game.value().parent_path(); - } - // If the game is not found, we install it in the game install directory - else { - game_folder_path = game_install_dir / pkg.GetTitleID(); - } - game_update_path = use_game_update ? game_folder_path.parent_path() / - (std::string{pkg.GetTitleID()} + "-UPDATE") - : game_folder_path; - } - - QString gameDirPath; - Common::FS::PathToQString(gameDirPath, game_folder_path); - QDir game_dir(gameDirPath); - if (game_dir.exists()) { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("PKG Extraction")); - - std::string content_id; - if (auto value = psf.GetString("CONTENT_ID"); value.has_value()) { - content_id = std::string{*value}; - } else { - QMessageBox::critical(this, tr("PKG ERROR"), "PSF file there is no CONTENT_ID"); - return; - } - std::string entitlement_label = Common::SplitString(content_id, '-')[2]; - - auto addon_extract_path = - Config::getAddonInstallDir() / pkg.GetTitleID() / entitlement_label; - QString addonDirPath; - Common::FS::PathToQString(addonDirPath, addon_extract_path); - QDir addon_dir(addonDirPath); - - if (pkgType.contains("PATCH")) { - QString pkg_app_version; - if (auto app_ver = psf.GetString("APP_VER"); app_ver.has_value()) { - pkg_app_version = QString::fromStdString(std::string{*app_ver}); - } else { - QMessageBox::critical(this, tr("PKG ERROR"), "PSF file there is no APP_VER"); - return; - } - std::filesystem::path sce_folder_path = - std::filesystem::exists(game_update_path / "sce_sys" / "param.sfo") - ? game_update_path / "sce_sys" / "param.sfo" - : game_folder_path / "sce_sys" / "param.sfo"; - psf.Open(sce_folder_path); - QString game_app_version; - if (auto app_ver = psf.GetString("APP_VER"); app_ver.has_value()) { - game_app_version = QString::fromStdString(std::string{*app_ver}); - } else { - QMessageBox::critical(this, tr("PKG ERROR"), "PSF file there is no APP_VER"); - return; - } - double appD = game_app_version.toDouble(); - double pkgD = pkg_app_version.toDouble(); - if (pkgD == appD) { - msgBox.setText(QString(tr("Patch detected!") + "\n" + - tr("PKG and Game versions match: ") + pkg_app_version + - "\n" + tr("Would you like to overwrite?"))); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::No); - } else if (pkgD < appD) { - msgBox.setText(QString(tr("Patch detected!") + "\n" + - tr("PKG Version %1 is older than installed version: ") - .arg(pkg_app_version) + - game_app_version + "\n" + - tr("Would you like to overwrite?"))); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::No); - } else { - msgBox.setText(QString(tr("Patch detected!") + "\n" + - tr("Game is installed: ") + game_app_version + "\n" + - tr("Would you like to install Patch: ") + - pkg_app_version + " ?")); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::No); - } - int result = msgBox.exec(); - if (result == QMessageBox::Yes) { - // Do nothing. - } else { - return; - } - } else if (category == "ac") { - if (!addon_dir.exists()) { - QMessageBox addonMsgBox; - addonMsgBox.setWindowTitle(tr("DLC Installation")); - addonMsgBox.setText(QString(tr("Would you like to install DLC: %1?")) - .arg(QString::fromStdString(entitlement_label))); - - addonMsgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - addonMsgBox.setDefaultButton(QMessageBox::No); - int result = addonMsgBox.exec(); - if (result == QMessageBox::Yes) { - game_update_path = addon_extract_path; - } else { - return; - } - } else { - msgBox.setText(QString(tr("DLC already installed:") + "\n" + addonDirPath + - "\n\n" + tr("Would you like to overwrite?"))); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::No); - int result = msgBox.exec(); - if (result == QMessageBox::Yes) { - game_update_path = addon_extract_path; - } else { - return; - } - } - } else { - msgBox.setText(QString(tr("Game already installed") + "\n" + gameDirPath + "\n" + - tr("Would you like to overwrite?"))); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::No); - int result = msgBox.exec(); - if (result == QMessageBox::Yes) { - // Do nothing. - } else { - return; - } - } - } else { - // Do nothing; - if (pkgType.contains("PATCH") || category == "ac") { - QMessageBox::information( - this, tr("PKG Extraction"), - tr("PKG is a patch or DLC, please install the game first!")); - return; - } - // what else? - } - if (!pkg.Extract(file, game_update_path, failreason)) { - QMessageBox::critical(this, tr("PKG ERROR"), QString::fromStdString(failreason)); - } else { - int nfiles = pkg.GetNumberOfFiles(); - - if (nfiles > 0) { - QVector indices; - for (int i = 0; i < nfiles; i++) { - indices.append(i); - } - - QProgressDialog dialog; - dialog.setWindowTitle(tr("PKG Extraction")); - dialog.setWindowModality(Qt::WindowModal); - QString extractmsg = QString(tr("Extracting PKG %1/%2")).arg(pkgNum).arg(nPkg); - dialog.setLabelText(extractmsg); - dialog.setAutoClose(true); - dialog.setRange(0, nfiles); - - dialog.setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, - dialog.size(), this->geometry())); - - QFutureWatcher futureWatcher; - connect(&futureWatcher, &QFutureWatcher::finished, this, [=, this]() { - if (pkgNum == nPkg) { - QString path; - - // We want to show the parent path instead of the full path - Common::FS::PathToQString(path, game_folder_path.parent_path()); - QIcon windowIcon( - Common::FS::PathToUTF8String(game_folder_path / "sce_sys/icon0.png") - .c_str()); - - QMessageBox extractMsgBox(this); - extractMsgBox.setWindowTitle(tr("Extraction Finished")); - if (!windowIcon.isNull()) { - extractMsgBox.setWindowIcon(windowIcon); - } - extractMsgBox.setText( - QString(tr("Game successfully installed at %1")).arg(path)); - extractMsgBox.addButton(QMessageBox::Ok); - extractMsgBox.setDefaultButton(QMessageBox::Ok); - connect(&extractMsgBox, &QMessageBox::buttonClicked, this, - [&](QAbstractButton* button) { - if (extractMsgBox.button(QMessageBox::Ok) == button) { - extractMsgBox.close(); - emit ExtractionFinished(); - } - }); - extractMsgBox.exec(); - } - if (delete_file_on_install) { - std::filesystem::remove(file); - } - }); - connect(&dialog, &QProgressDialog::canceled, [&]() { futureWatcher.cancel(); }); - connect(&futureWatcher, &QFutureWatcher::progressValueChanged, &dialog, - &QProgressDialog::setValue); - futureWatcher.setFuture( - QtConcurrent::map(indices, [&](int index) { pkg.ExtractFiles(index); })); - dialog.exec(); - } - } - } else { - QMessageBox::critical(this, tr("PKG ERROR"), - tr("File doesn't appear to be a valid PKG file")); - } -} - void MainWindow::InstallDirectory() { GameInstallDialog dlg; dlg.exec(); @@ -1118,19 +1042,37 @@ void MainWindow::SetLastUsedTheme() { void MainWindow::SetLastIconSizeBullet() { // set QAction bullet point if applicable int lastSize = Config::getIconSize(); - switch (lastSize) { - case 36: - ui->setIconSizeTinyAct->setChecked(true); - break; - case 64: - ui->setIconSizeSmallAct->setChecked(true); - break; - case 128: - ui->setIconSizeMediumAct->setChecked(true); - break; - case 256: - ui->setIconSizeLargeAct->setChecked(true); - break; + int lastSizeGrid = Config::getIconSizeGrid(); + if (isTableList) { + switch (lastSize) { + case 36: + ui->setIconSizeTinyAct->setChecked(true); + break; + case 64: + ui->setIconSizeSmallAct->setChecked(true); + break; + case 128: + ui->setIconSizeMediumAct->setChecked(true); + break; + case 256: + ui->setIconSizeLargeAct->setChecked(true); + break; + } + } else { + switch (lastSizeGrid) { + case 69: + ui->setIconSizeTinyAct->setChecked(true); + break; + case 97: + ui->setIconSizeSmallAct->setChecked(true); + break; + case 161: + ui->setIconSizeMediumAct->setChecked(true); + break; + case 256: + ui->setIconSizeLargeAct->setChecked(true); + break; + } } } @@ -1144,7 +1086,6 @@ QIcon MainWindow::RecolorIcon(const QIcon& icon, bool isWhite) { } void MainWindow::SetUiIcons(bool isWhite) { - ui->bootInstallPkgAct->setIcon(RecolorIcon(ui->bootInstallPkgAct->icon(), isWhite)); ui->bootGameAct->setIcon(RecolorIcon(ui->bootGameAct->icon(), isWhite)); ui->shadFolderAct->setIcon(RecolorIcon(ui->shadFolderAct->icon(), isWhite)); ui->exitAct->setIcon(RecolorIcon(ui->exitAct->icon(), isWhite)); @@ -1165,12 +1106,14 @@ void MainWindow::SetUiIcons(bool isWhite) { ui->pauseButton->setIcon(RecolorIcon(ui->pauseButton->icon(), isWhite)); ui->stopButton->setIcon(RecolorIcon(ui->stopButton->icon(), isWhite)); ui->refreshButton->setIcon(RecolorIcon(ui->refreshButton->icon(), isWhite)); + ui->restartButton->setIcon(RecolorIcon(ui->restartButton->icon(), isWhite)); ui->settingsButton->setIcon(RecolorIcon(ui->settingsButton->icon(), isWhite)); + ui->fullscreenButton->setIcon(RecolorIcon(ui->fullscreenButton->icon(), isWhite)); ui->controllerButton->setIcon(RecolorIcon(ui->controllerButton->icon(), isWhite)); ui->keyboardButton->setIcon(RecolorIcon(ui->keyboardButton->icon(), isWhite)); ui->refreshGameListAct->setIcon(RecolorIcon(ui->refreshGameListAct->icon(), isWhite)); ui->menuGame_List_Mode->setIcon(RecolorIcon(ui->menuGame_List_Mode->icon(), isWhite)); - ui->pkgViewerAct->setIcon(RecolorIcon(ui->pkgViewerAct->icon(), isWhite)); + ui->trophyViewerAct->setIcon(RecolorIcon(ui->trophyViewerAct->icon(), isWhite)); ui->configureAct->setIcon(RecolorIcon(ui->configureAct->icon(), isWhite)); ui->addElfFolderAct->setIcon(RecolorIcon(ui->addElfFolderAct->icon(), isWhite)); } diff --git a/src/qt_gui/main_window.h b/src/qt_gui/main_window.h index 5ac56e44c..5d05bfca4 100644 --- a/src/qt_gui/main_window.h +++ b/src/qt_gui/main_window.h @@ -5,6 +5,7 @@ #include #include +#include #include #include "background_music_player.h" @@ -21,7 +22,6 @@ #include "game_list_utils.h" #include "main_window_themes.h" #include "main_window_ui.h" -#include "pkg_viewer.h" class GameListFrame; @@ -35,9 +35,10 @@ public: explicit MainWindow(QWidget* parent = nullptr); ~MainWindow(); bool Init(); - void InstallDragDropPkg(std::filesystem::path file, int pkgNum, int nPkg); void InstallDirectory(); void StartGame(); + void PauseGame(); + bool showLabels; private Q_SLOTS: void ConfigureGuiFromSettings(); @@ -47,15 +48,21 @@ private Q_SLOTS: void RefreshGameTable(); void HandleResize(QResizeEvent* event); void OnLanguageChanged(const std::string& locale); + void toggleLabelsUnderIcons(); private: Ui_MainWindow* ui; void AddUiWidgets(); + void UpdateToolbarLabels(); + void UpdateToolbarButtons(); + QWidget* createButtonWithLabel(QPushButton* button, const QString& labelText, bool showLabel); void CreateActions(); + void toggleFullscreen(); void CreateRecentGameActions(); void CreateDockWindows(); void GetPhysicalDevices(); void LoadGameLists(); + #ifdef ENABLE_UPDATER void CheckUpdateMain(bool checkSave); #endif @@ -63,7 +70,6 @@ private: void SetLastUsedTheme(); void SetLastIconSizeBullet(); void SetUiIcons(bool isWhite); - void InstallPkg(); void BootGame(); void AddRecentFiles(QString filePath); void LoadTranslation(); @@ -73,11 +79,13 @@ private: bool isIconBlack = false; bool isTableList = true; bool isGameRunning = false; + bool isWhite = false; + bool is_paused = false; + QActionGroup* m_icon_size_act_group = nullptr; QActionGroup* m_list_mode_act_group = nullptr; QActionGroup* m_theme_act_group = nullptr; QActionGroup* m_recent_files_group = nullptr; - PKG pkg; // Dockable widget frames WindowThemes m_window_themes; GameListUtils m_game_list_utils; @@ -108,20 +116,6 @@ protected: } } - void dropEvent(QDropEvent* event1) override { - const QMimeData* mimeData = event1->mimeData(); - if (mimeData->hasUrls()) { - QList urlList = mimeData->urls(); - int pkgNum = 0; - int nPkg = urlList.size(); - for (const QUrl& url : urlList) { - pkgNum++; - std::filesystem::path path = Common::FS::PathFromQString(url.toLocalFile()); - InstallDragDropPkg(path, pkgNum, nPkg); - } - } - } - void resizeEvent(QResizeEvent* event) override; std::filesystem::path last_install_dir = ""; diff --git a/src/qt_gui/main_window_themes.cpp b/src/qt_gui/main_window_themes.cpp index c5574fca9..624673cba 100644 --- a/src/qt_gui/main_window_themes.cpp +++ b/src/qt_gui/main_window_themes.cpp @@ -19,7 +19,7 @@ void WindowThemes::SetWindowTheme(Theme theme, QLineEdit* mw_searchbar) { themePalette.setColor(QPalette::WindowText, Qt::white); themePalette.setColor(QPalette::Base, QColor(20, 20, 20)); themePalette.setColor(QPalette::AlternateBase, QColor(53, 53, 53)); - themePalette.setColor(QPalette::ToolTipBase, Qt::white); + themePalette.setColor(QPalette::ToolTipBase, QColor(20, 20, 20)); themePalette.setColor(QPalette::ToolTipText, Qt::white); themePalette.setColor(QPalette::Text, Qt::white); themePalette.setColor(QPalette::Button, QColor(53, 53, 53)); @@ -37,18 +37,18 @@ void WindowThemes::SetWindowTheme(Theme theme, QLineEdit* mw_searchbar) { "border-radius: 4px; padding: 5px; }" "QLineEdit:focus {" "border: 1px solid #2A82DA; }"); - themePalette.setColor(QPalette::Window, QColor(240, 240, 240)); // Light gray - themePalette.setColor(QPalette::WindowText, Qt::black); // Black - themePalette.setColor(QPalette::Base, QColor(230, 230, 230, 80)); // Grayish - themePalette.setColor(QPalette::ToolTipBase, Qt::black); // Black - themePalette.setColor(QPalette::ToolTipText, Qt::black); // Black - themePalette.setColor(QPalette::Text, Qt::black); // Black - themePalette.setColor(QPalette::Button, QColor(240, 240, 240)); // Light gray - themePalette.setColor(QPalette::ButtonText, Qt::black); // Black - themePalette.setColor(QPalette::BrightText, Qt::red); // Red - themePalette.setColor(QPalette::Link, QColor(42, 130, 218)); // Blue - themePalette.setColor(QPalette::Highlight, QColor(42, 130, 218)); // Blue - themePalette.setColor(QPalette::HighlightedText, Qt::white); // White + themePalette.setColor(QPalette::Window, QColor(240, 240, 240)); // Light gray + themePalette.setColor(QPalette::WindowText, Qt::black); // Black + themePalette.setColor(QPalette::Base, QColor(230, 230, 230, 80)); // Grayish + themePalette.setColor(QPalette::ToolTipBase, QColor(230, 230, 230, 80)); // Grayish + themePalette.setColor(QPalette::ToolTipText, Qt::black); // Black + themePalette.setColor(QPalette::Text, Qt::black); // Black + themePalette.setColor(QPalette::Button, QColor(240, 240, 240)); // Light gray + themePalette.setColor(QPalette::ButtonText, Qt::black); // Black + themePalette.setColor(QPalette::BrightText, Qt::red); // Red + themePalette.setColor(QPalette::Link, QColor(42, 130, 218)); // Blue + themePalette.setColor(QPalette::Highlight, QColor(42, 130, 218)); // Blue + themePalette.setColor(QPalette::HighlightedText, Qt::white); // White qApp->setPalette(themePalette); break; case Theme::Green: @@ -62,8 +62,9 @@ void WindowThemes::SetWindowTheme(Theme theme, QLineEdit* mw_searchbar) { themePalette.setColor(QPalette::WindowText, Qt::white); // White text themePalette.setColor(QPalette::Base, QColor(25, 40, 25)); // Darker green base themePalette.setColor(QPalette::AlternateBase, - QColor(53, 69, 53)); // Dark green alternate base - themePalette.setColor(QPalette::ToolTipBase, Qt::white); // White tooltip background + QColor(53, 69, 53)); // Dark green alternate base + themePalette.setColor(QPalette::ToolTipBase, + QColor(25, 40, 25)); // White tooltip background themePalette.setColor(QPalette::ToolTipText, Qt::white); // White tooltip text themePalette.setColor(QPalette::Text, Qt::white); // White text themePalette.setColor(QPalette::Button, QColor(53, 69, 53)); // Dark green button @@ -85,8 +86,9 @@ void WindowThemes::SetWindowTheme(Theme theme, QLineEdit* mw_searchbar) { themePalette.setColor(QPalette::WindowText, Qt::white); // White text themePalette.setColor(QPalette::Base, QColor(20, 40, 60)); // Darker blue base themePalette.setColor(QPalette::AlternateBase, - QColor(40, 60, 90)); // Dark blue alternate base - themePalette.setColor(QPalette::ToolTipBase, Qt::white); // White tooltip background + QColor(40, 60, 90)); // Dark blue alternate base + themePalette.setColor(QPalette::ToolTipBase, + QColor(20, 40, 60)); // White tooltip background themePalette.setColor(QPalette::ToolTipText, Qt::white); // White tooltip text themePalette.setColor(QPalette::Text, Qt::white); // White text themePalette.setColor(QPalette::Button, QColor(40, 60, 90)); // Dark blue button @@ -109,8 +111,9 @@ void WindowThemes::SetWindowTheme(Theme theme, QLineEdit* mw_searchbar) { themePalette.setColor(QPalette::WindowText, Qt::white); // White text themePalette.setColor(QPalette::Base, QColor(80, 30, 90)); // Darker violet base themePalette.setColor(QPalette::AlternateBase, - QColor(100, 50, 120)); // Violet alternate base - themePalette.setColor(QPalette::ToolTipBase, Qt::white); // White tooltip background + QColor(100, 50, 120)); // Violet alternate base + themePalette.setColor(QPalette::ToolTipBase, + QColor(80, 30, 90)); // White tooltip background themePalette.setColor(QPalette::ToolTipText, Qt::white); // White tooltip text themePalette.setColor(QPalette::Text, Qt::white); // White text themePalette.setColor(QPalette::Button, QColor(100, 50, 120)); // Violet button @@ -133,7 +136,7 @@ void WindowThemes::SetWindowTheme(Theme theme, QLineEdit* mw_searchbar) { themePalette.setColor(QPalette::WindowText, QColor(249, 245, 215)); themePalette.setColor(QPalette::Base, QColor(29, 32, 33)); themePalette.setColor(QPalette::AlternateBase, QColor(50, 48, 47)); - themePalette.setColor(QPalette::ToolTipBase, QColor(249, 245, 215)); + themePalette.setColor(QPalette::ToolTipBase, QColor(29, 32, 33)); themePalette.setColor(QPalette::ToolTipText, QColor(249, 245, 215)); themePalette.setColor(QPalette::Text, QColor(249, 245, 215)); themePalette.setColor(QPalette::Button, QColor(40, 40, 40)); @@ -155,7 +158,7 @@ void WindowThemes::SetWindowTheme(Theme theme, QLineEdit* mw_searchbar) { themePalette.setColor(QPalette::WindowText, QColor(192, 202, 245)); themePalette.setColor(QPalette::Base, QColor(25, 28, 39)); themePalette.setColor(QPalette::AlternateBase, QColor(36, 40, 59)); - themePalette.setColor(QPalette::ToolTipBase, QColor(192, 202, 245)); + themePalette.setColor(QPalette::ToolTipBase, QColor(25, 28, 39)); themePalette.setColor(QPalette::ToolTipText, QColor(192, 202, 245)); themePalette.setColor(QPalette::Text, QColor(192, 202, 245)); themePalette.setColor(QPalette::Button, QColor(30, 30, 41)); diff --git a/src/qt_gui/main_window_ui.h b/src/qt_gui/main_window_ui.h index 3ebfcee9e..4d3481c07 100644 --- a/src/qt_gui/main_window_ui.h +++ b/src/qt_gui/main_window_ui.h @@ -9,7 +9,6 @@ class Ui_MainWindow { public: - QAction* bootInstallPkgAct; QAction* bootGameAct; QAction* addElfFolderAct; QAction* shadFolderAct; @@ -20,13 +19,14 @@ public: QAction* setIconSizeSmallAct; QAction* setIconSizeMediumAct; QAction* setIconSizeLargeAct; + QAction* toggleLabelsAct; QAction* setlistModeListAct; QAction* setlistModeGridAct; QAction* setlistElfAct; QAction* gameInstallPathAct; QAction* downloadCheatsPatchesAct; QAction* dumpGameListAct; - QAction* pkgViewerAct; + QAction* trophyViewerAct; #ifdef ENABLE_UPDATER QAction* updaterAct; #endif @@ -49,6 +49,8 @@ public: QPushButton* settingsButton; QPushButton* controllerButton; QPushButton* keyboardButton; + QPushButton* fullscreenButton; + QPushButton* restartButton; QWidget* sizeSliderContainer; QHBoxLayout* sizeSliderContainer_layout; @@ -83,9 +85,6 @@ public: MainWindow->setDockNestingEnabled(true); MainWindow->setDockOptions(QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks | QMainWindow::AnimatedDocks | QMainWindow::GroupedDragging); - bootInstallPkgAct = new QAction(MainWindow); - bootInstallPkgAct->setObjectName("bootInstallPkgAct"); - bootInstallPkgAct->setIcon(QIcon(":images/file_icon.png")); bootGameAct = new QAction(MainWindow); bootGameAct->setObjectName("bootGameAct"); bootGameAct->setIcon(QIcon(":images/play_icon.png")); @@ -103,7 +102,13 @@ public: showGameListAct->setCheckable(true); refreshGameListAct = new QAction(MainWindow); refreshGameListAct->setObjectName("refreshGameListAct"); - refreshGameListAct->setIcon(QIcon(":images/refresh_icon.png")); + refreshGameListAct->setIcon(QIcon(":images/refreshlist_icon.png")); + + toggleLabelsAct = new QAction(MainWindow); + toggleLabelsAct->setObjectName("toggleLabelsAct"); + toggleLabelsAct->setCheckable(true); + toggleLabelsAct->setChecked(Config::getShowLabelsUnderIcons()); + setIconSizeTinyAct = new QAction(MainWindow); setIconSizeTinyAct->setObjectName("setIconSizeTinyAct"); setIconSizeTinyAct->setCheckable(true); @@ -136,9 +141,10 @@ public: dumpGameListAct = new QAction(MainWindow); dumpGameListAct->setObjectName("dumpGameList"); dumpGameListAct->setIcon(QIcon(":images/dump_icon.png")); - pkgViewerAct = new QAction(MainWindow); - pkgViewerAct->setObjectName("pkgViewer"); - pkgViewerAct->setIcon(QIcon(":images/file_icon.png")); + trophyViewerAct = new QAction(MainWindow); + trophyViewerAct->setObjectName("trophyViewer"); + trophyViewerAct->setIcon(QIcon(":images/trophy_icon.png")); + #ifdef ENABLE_UPDATER updaterAct = new QAction(MainWindow); updaterAct->setObjectName("updaterAct"); @@ -205,20 +211,28 @@ public: stopButton->setIconSize(QSize(40, 40)); refreshButton = new QPushButton(centralWidget); refreshButton->setFlat(true); - refreshButton->setIcon(QIcon(":images/refresh_icon.png")); - refreshButton->setIconSize(QSize(32, 32)); + refreshButton->setIcon(QIcon(":images/refreshlist_icon.png")); + refreshButton->setIconSize(QSize(40, 40)); + fullscreenButton = new QPushButton(centralWidget); + fullscreenButton->setFlat(true); + fullscreenButton->setIcon(QIcon(":images/fullscreen_icon.png")); + fullscreenButton->setIconSize(QSize(38, 38)); settingsButton = new QPushButton(centralWidget); settingsButton->setFlat(true); settingsButton->setIcon(QIcon(":images/settings_icon.png")); - settingsButton->setIconSize(QSize(44, 44)); + settingsButton->setIconSize(QSize(40, 40)); controllerButton = new QPushButton(centralWidget); controllerButton->setFlat(true); controllerButton->setIcon(QIcon(":images/controller_icon.png")); - controllerButton->setIconSize(QSize(40, 40)); + controllerButton->setIconSize(QSize(55, 48)); keyboardButton = new QPushButton(centralWidget); keyboardButton->setFlat(true); keyboardButton->setIcon(QIcon(":images/keyboard_icon.png")); - keyboardButton->setIconSize(QSize(48, 44)); + keyboardButton->setIconSize(QSize(50, 50)); + restartButton = new QPushButton(centralWidget); + restartButton->setFlat(true); + restartButton->setIcon(QIcon(":images/restart_game_icon.png")); + restartButton->setIconSize(QSize(40, 40)); sizeSliderContainer = new QWidget(centralWidget); sizeSliderContainer->setObjectName("sizeSliderContainer"); @@ -285,7 +299,6 @@ public: menuBar->addAction(menuView->menuAction()); menuBar->addAction(menuSettings->menuAction()); menuBar->addAction(menuHelp->menuAction()); - menuFile->addAction(bootInstallPkgAct); menuFile->addAction(bootGameAct); menuFile->addSeparator(); menuFile->addAction(addElfFolderAct); @@ -299,6 +312,7 @@ public: menuView->addAction(refreshGameListAct); menuView->addAction(menuGame_List_Mode->menuAction()); menuView->addAction(menuGame_List_Icons->menuAction()); + menuView->addAction(toggleLabelsAct); menuView->addAction(menuThemes->menuAction()); menuThemes->addAction(setThemeDark); menuThemes->addAction(setThemeLight); @@ -320,7 +334,7 @@ public: menuSettings->addAction(menuUtils->menuAction()); menuUtils->addAction(downloadCheatsPatchesAct); menuUtils->addAction(dumpGameListAct); - menuUtils->addAction(pkgViewerAct); + menuUtils->addAction(trophyViewerAct); #ifdef ENABLE_UPDATER menuHelp->addAction(updaterAct); #endif @@ -335,8 +349,6 @@ public: MainWindow->setWindowTitle(QCoreApplication::translate("MainWindow", "shadPS4", nullptr)); addElfFolderAct->setText( QCoreApplication::translate("MainWindow", "Open/Add Elf Folder", nullptr)); - bootInstallPkgAct->setText( - QCoreApplication::translate("MainWindow", "Install Packages (PKG)", nullptr)); bootGameAct->setText(QCoreApplication::translate("MainWindow", "Boot Game", nullptr)); #ifdef ENABLE_UPDATER updaterAct->setText( @@ -345,8 +357,6 @@ public: aboutAct->setText(QCoreApplication::translate("MainWindow", "About shadPS4", nullptr)); configureAct->setText(QCoreApplication::translate("MainWindow", "Configure...", nullptr)); #if QT_CONFIG(tooltip) - bootInstallPkgAct->setToolTip(QCoreApplication::translate( - "MainWindow", "Install application from a .pkg file", nullptr)); #endif // QT_CONFIG(tooltip) menuRecent->setTitle(QCoreApplication::translate("MainWindow", "Recent Games", nullptr)); shadFolderAct->setText( @@ -378,7 +388,8 @@ public: QCoreApplication::translate("MainWindow", "Download Cheats/Patches", nullptr)); dumpGameListAct->setText( QCoreApplication::translate("MainWindow", "Dump Game List", nullptr)); - pkgViewerAct->setText(QCoreApplication::translate("MainWindow", "PKG Viewer", nullptr)); + trophyViewerAct->setText( + QCoreApplication::translate("MainWindow", "Trophy Viewer", nullptr)); mw_searchbar->setPlaceholderText( QCoreApplication::translate("MainWindow", "Search...", nullptr)); menuFile->setTitle(QCoreApplication::translate("MainWindow", "File", nullptr)); @@ -400,9 +411,11 @@ public: setThemeTokyoNight->setText("Tokyo Night"); setThemeOled->setText("OLED"); toolBar->setWindowTitle(QCoreApplication::translate("MainWindow", "toolBar", nullptr)); + toggleLabelsAct->setText( + QCoreApplication::translate("MainWindow", "Show Labels Under Icons")); } // retranslateUi }; namespace Ui { class MainWindow : public Ui_MainWindow {}; -} // namespace Ui \ No newline at end of file +} // namespace Ui diff --git a/src/qt_gui/pkg_viewer.cpp b/src/qt_gui/pkg_viewer.cpp deleted file mode 100644 index ecbc6312d..000000000 --- a/src/qt_gui/pkg_viewer.cpp +++ /dev/null @@ -1,217 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "pkg_viewer.h" - -PKGViewer::PKGViewer(std::shared_ptr game_info_get, QWidget* parent, - std::function InstallDragDropPkg) - : QMainWindow(), m_game_info(game_info_get) { - this->resize(1280, 720); - this->setAttribute(Qt::WA_DeleteOnClose); - dir_list_std = Config::getPkgViewer(); - dir_list.clear(); - for (const auto& str : dir_list_std) { - dir_list.append(QString::fromStdString(str)); - } - statusBar = new QStatusBar(treeWidget); - this->setStatusBar(statusBar); - treeWidget = new QTreeWidget(this); - treeWidget->setColumnCount(9); - QStringList headers; - headers << tr("Name") << tr("Serial") << tr("Installed") << tr("Size") << tr("Category") - << tr("Type") << tr("App Ver") << tr("FW") << tr("Region") << tr("Flags") << tr("Path"); - treeWidget->setHeaderLabels(headers); - treeWidget->header()->setDefaultAlignment(Qt::AlignCenter); - treeWidget->setContextMenuPolicy(Qt::CustomContextMenu); - treeWidget->setColumnWidth(8, 170); - this->setCentralWidget(treeWidget); - QMenuBar* menuBar = new QMenuBar(this); - menuBar->setContextMenuPolicy(Qt::PreventContextMenu); - QMenu* fileMenu = menuBar->addMenu(tr("File")); - QAction* openFolderAct = new QAction(tr("Open Folder"), this); - fileMenu->addAction(openFolderAct); - this->setMenuBar(menuBar); - CheckPKGFolders(); // Check for new PKG files in existing folders. - ProcessPKGInfo(); - - connect(openFolderAct, &QAction::triggered, this, &PKGViewer::OpenPKGFolder); - - connect(treeWidget, &QTreeWidget::customContextMenuRequested, this, - [=, this](const QPoint& pos) { - if (treeWidget->selectedItems().isEmpty()) { - return; - } - m_gui_context_menus.RequestGameMenuPKGViewer(pos, m_full_pkg_list, treeWidget, - InstallDragDropPkg); - }); - - connect(parent, &QWidget::destroyed, this, [this]() { this->deleteLater(); }); -} - -PKGViewer::~PKGViewer() {} - -void PKGViewer::OpenPKGFolder() { - QString folderPath = - QFileDialog::getExistingDirectory(this, tr("Open Folder"), QDir::homePath()); - if (!dir_list.contains(folderPath)) { - dir_list.append(folderPath); - QDir directory(folderPath); - QFileInfoList fileInfoList = directory.entryInfoList(QDir::Files); - for (const QFileInfo& fileInfo : fileInfoList) { - QString file_ext = fileInfo.suffix(); - if (fileInfo.isFile() && file_ext == "pkg") { - m_pkg_list.append(fileInfo.absoluteFilePath()); - } - } - std::sort(m_pkg_list.begin(), m_pkg_list.end()); - ProcessPKGInfo(); - dir_list_std.clear(); - for (auto dir : dir_list) { - dir_list_std.push_back(dir.toStdString()); - } - Config::setPkgViewer(dir_list_std); - } else { - // qDebug() << "Folder selection canceled."; - } -} - -void PKGViewer::CheckPKGFolders() { // Check for new PKG file additions. - m_pkg_list.clear(); - for (const QString& dir : dir_list) { - QDir directory(dir); - QFileInfoList fileInfoList = directory.entryInfoList(QDir::Files); - for (const QFileInfo& fileInfo : fileInfoList) { - QString file_ext = fileInfo.suffix(); - if (fileInfo.isFile() && file_ext == "pkg") { - m_pkg_list.append(fileInfo.absoluteFilePath()); - } - } - } - std::sort(m_pkg_list.begin(), m_pkg_list.end()); -} - -void PKGViewer::ProcessPKGInfo() { - treeWidget->clear(); - map_strings.clear(); - map_integers.clear(); - m_pkg_app_list.clear(); - m_pkg_patch_list.clear(); - m_full_pkg_list.clear(); - for (int i = 0; i < m_pkg_list.size(); i++) { - std::filesystem::path path = Common::FS::PathFromQString(m_pkg_list[i]); - std::string failreason; - if (!package.Open(path, failreason)) { - QMessageBox::critical(this, tr("PKG ERROR"), QString::fromStdString(failreason)); - return; - } - psf.Open(package.sfo); - QString title_name = QString::fromStdString( - std::string{psf.GetString("TITLE").value_or(std::string{tr("Unknown").toStdString()})}); - QString title_id = QString::fromStdString(std::string{ - psf.GetString("TITLE_ID").value_or(std::string{tr("Unknown").toStdString()})}); - QString app_type = GameListUtils::GetAppType(psf.GetInteger("APP_TYPE").value_or(0)); - QString app_version = QString::fromStdString(std::string{ - psf.GetString("APP_VER").value_or(std::string{tr("Unknown").toStdString()})}); - QString title_category = QString::fromStdString(std::string{ - psf.GetString("CATEGORY").value_or(std::string{tr("Unknown").toStdString()})}); - QString pkg_size = GameListUtils::FormatSize(package.GetPkgHeader().pkg_size); - pkg_content_flag = package.GetPkgHeader().pkg_content_flags; - QString flagss = ""; - for (const auto& flag : package.flagNames) { - if (package.isFlagSet(pkg_content_flag, flag.first)) { - if (!flagss.isEmpty()) - flagss += (", "); - flagss += QString::fromStdString(flag.second.data()); - } - } - - QString fw_ = tr("Unknown"); - if (const auto fw_int_opt = psf.GetInteger("SYSTEM_VER"); fw_int_opt.has_value()) { - const u32 fw_int = *fw_int_opt; - if (fw_int == 0) { - fw_ = "0.00"; - } else { - QString fw = QString::number(fw_int, 16); - fw_ = fw.length() > 7 ? QString::number(fw_int, 16).left(3).insert(2, '.') - : fw.left(3).insert(1, '.'); - } - } - char region = package.GetPkgHeader().pkg_content_id[0]; - QString pkg_info = ""; - if (title_category == "gd" && !flagss.contains("PATCH")) { - title_category = "App"; - pkg_info = title_name + ";;" + title_id + ";;" + pkg_size + ";;" + title_category + - ";;" + app_type + ";;" + app_version + ";;" + fw_ + ";;" + - game_list_util.GetRegion(region) + ";;" + flagss + ";;" + m_pkg_list[i]; - m_pkg_app_list.append(pkg_info); - } else { - title_category = "Patch"; - pkg_info = title_name + ";;" + title_id + ";;" + pkg_size + ";;" + title_category + - ";;" + app_type + ";;" + app_version + ";;" + fw_ + ";;" + - game_list_util.GetRegion(region) + ";;" + flagss + ";;" + m_pkg_list[i]; - m_pkg_patch_list.append(pkg_info); - } - } - std::sort(m_pkg_app_list.begin(), m_pkg_app_list.end()); - for (int i = 0; i < m_pkg_app_list.size(); i++) { - QTreeWidgetItem* treeItem = new QTreeWidgetItem(treeWidget); - QStringList pkg_app_ = m_pkg_app_list[i].split(";;"); - m_full_pkg_list.append(m_pkg_app_list[i]); - treeItem->setExpanded(true); - treeItem->setText(0, pkg_app_[0]); - treeItem->setText(1, pkg_app_[1]); - treeItem->setText(3, pkg_app_[2]); - treeItem->setTextAlignment(3, Qt::AlignCenter); - treeItem->setText(4, pkg_app_[3]); - treeItem->setTextAlignment(4, Qt::AlignCenter); - treeItem->setText(5, pkg_app_[4]); - treeItem->setTextAlignment(5, Qt::AlignCenter); - treeItem->setText(6, pkg_app_[5]); - treeItem->setTextAlignment(6, Qt::AlignCenter); - treeItem->setText(7, pkg_app_[6]); - treeItem->setTextAlignment(7, Qt::AlignCenter); - treeItem->setText(8, pkg_app_[7]); - treeItem->setTextAlignment(8, Qt::AlignCenter); - treeItem->setText(9, pkg_app_[8]); - treeItem->setText(10, pkg_app_[9]); - for (const GameInfo& info : m_game_info->m_games) { // Check if game is installed. - if (info.serial == pkg_app_[1].toStdString()) { - treeItem->setText(2, QChar(0x2713)); - treeItem->setTextAlignment(2, Qt::AlignCenter); - } - } - for (const QString& item : m_pkg_patch_list) { - QStringList pkg_patch_ = item.split(";;"); - if (pkg_patch_[1] == pkg_app_[1]) { // check patches with serial. - m_full_pkg_list.append(item); - QTreeWidgetItem* childItem = new QTreeWidgetItem(treeItem); - childItem->setText(0, pkg_patch_[0]); - childItem->setText(1, pkg_patch_[1]); - childItem->setText(3, pkg_patch_[2]); - childItem->setTextAlignment(3, Qt::AlignCenter); - childItem->setText(4, pkg_patch_[3]); - childItem->setTextAlignment(4, Qt::AlignCenter); - childItem->setText(5, pkg_patch_[4]); - childItem->setTextAlignment(5, Qt::AlignCenter); - childItem->setText(6, pkg_patch_[5]); - childItem->setTextAlignment(6, Qt::AlignCenter); - childItem->setText(7, pkg_patch_[6]); - childItem->setTextAlignment(7, Qt::AlignCenter); - childItem->setText(8, pkg_patch_[7]); - childItem->setTextAlignment(8, Qt::AlignCenter); - childItem->setText(9, pkg_patch_[8]); - childItem->setText(10, pkg_patch_[9]); - } - } - } - - for (int column = 0; column < treeWidget->columnCount() - 2; ++column) { - // Resize the column to fit its contents - treeWidget->resizeColumnToContents(column); - } - // Update status bar. - statusBar->clearMessage(); - int numPkgs = m_pkg_list.size(); - QString statusMessage = QString::number(numPkgs) + " " + tr("Package"); - statusBar->showMessage(statusMessage); -} \ No newline at end of file diff --git a/src/qt_gui/pkg_viewer.h b/src/qt_gui/pkg_viewer.h deleted file mode 100644 index 265a03b92..000000000 --- a/src/qt_gui/pkg_viewer.h +++ /dev/null @@ -1,62 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include -#include -#include - -#include "common/io_file.h" -#include "core/file_format/pkg.h" -#include "core/file_format/pkg_type.h" -#include "core/file_format/psf.h" -#include "game_info.h" -#include "game_list_utils.h" -#include "gui_context_menus.h" - -class PKGViewer : public QMainWindow { - Q_OBJECT -public: - explicit PKGViewer( - std::shared_ptr game_info_get, QWidget* parent, - std::function InstallDragDropPkg = nullptr); - ~PKGViewer(); - void OpenPKGFolder(); - void CheckPKGFolders(); - void ProcessPKGInfo(); - -private: - GuiContextMenus m_gui_context_menus; - PKG package; - PSF psf; - PKGHeader pkgheader; - PKGEntry entry; - PSFHeader header; - char pkgTitleID[9]; - std::vector pkg; - u64 pkgSize = 0; - std::unordered_map map_strings; - std::unordered_map map_integers; - - u32_be pkg_content_flag; - std::shared_ptr m_game_info; - GameListUtils game_list_util; - // Status bar - QStatusBar* statusBar; - - std::vector> appTypes = { - {0, "FULL APP"}, - {1, "UPGRADABLE"}, - {2, "DEMO"}, - {3, "FREEMIUM"}, - }; - - QStringList m_full_pkg_list; - QStringList m_pkg_app_list; - QStringList m_pkg_patch_list; - QStringList m_pkg_list; - QStringList dir_list; - std::vector dir_list_std; - QTreeWidget* treeWidget = nullptr; -}; \ No newline at end of file diff --git a/src/qt_gui/settings_dialog.cpp b/src/qt_gui/settings_dialog.cpp index bde104828..5ee802b0c 100644 --- a/src/qt_gui/settings_dialog.cpp +++ b/src/qt_gui/settings_dialog.cpp @@ -5,10 +5,11 @@ #include #include #include +#include #include #include "common/config.h" -#include "common/version.h" +#include "common/scm_rev.h" #include "qt_gui/compatibility_info.h" #ifdef ENABLE_DISCORD_RPC #include "common/discord_rpc_handler.h" @@ -245,12 +246,13 @@ SettingsDialog::SettingsDialog(std::span physical_devices, // PATH TAB { connect(ui->addFolderButton, &QPushButton::clicked, this, [this]() { - const auto config_dir = Config::getGameInstallDirs(); QString file_path_string = QFileDialog::getExistingDirectory(this, tr("Directory to install games")); auto file_path = Common::FS::PathFromQString(file_path_string); - if (!file_path.empty() && Config::addGameInstallDir(file_path)) { + if (!file_path.empty() && Config::addGameInstallDir(file_path, true)) { QListWidgetItem* item = new QListWidgetItem(file_path_string); + item->setFlags(item->flags() | Qt::ItemIsUserCheckable); + item->setCheckState(Qt::Checked); ui->gameFoldersListWidget->addItem(item); } }); @@ -284,6 +286,21 @@ SettingsDialog::SettingsDialog(std::span physical_devices, ui->currentSaveDataPath->setText(save_data_path_string); } }); + + connect(ui->PortableUserButton, &QPushButton::clicked, this, []() { + QString userDir; + Common::FS::PathToQString(userDir, std::filesystem::current_path() / "user"); + if (std::filesystem::exists(std::filesystem::current_path() / "user")) { + QMessageBox::information(NULL, tr("Cannot create portable user folder"), + tr("%1 already exists").arg(userDir)); + } else { + std::filesystem::copy(Common::FS::GetUserPath(Common::FS::PathType::UserDir), + std::filesystem::current_path() / "user", + std::filesystem::copy_options::recursive); + QMessageBox::information(NULL, tr("Portable user folder created"), + tr("%1 successfully created.").arg(userDir)); + } + }); } // DEBUG TAB @@ -301,7 +318,6 @@ SettingsDialog::SettingsDialog(std::span physical_devices, // General ui->consoleLanguageGroupBox->installEventFilter(this); ui->emulatorLanguageGroupBox->installEventFilter(this); - ui->separateUpdatesCheckBox->installEventFilter(this); ui->showSplashCheckBox->installEventFilter(this); ui->discordRPCCheckbox->installEventFilter(this); ui->userName->installEventFilter(this); @@ -344,6 +360,7 @@ SettingsDialog::SettingsDialog(std::span physical_devices, ui->saveDataGroupBox->installEventFilter(this); ui->currentSaveDataPath->installEventFilter(this); ui->browseButton->installEventFilter(this); + ui->PortableUserFolderGroupBox->installEventFilter(this); // Debug ui->debugDump->installEventFilter(this); @@ -413,21 +430,25 @@ void SettingsDialog::LoadValuesFromConfig() { ui->vblankSpinBox->setValue(toml::find_or(data, "GPU", "vblankDivider", 1)); ui->dumpShadersCheckBox->setChecked(toml::find_or(data, "GPU", "dumpShaders", false)); ui->nullGpuCheckBox->setChecked(toml::find_or(data, "GPU", "nullGpu", false)); - ui->enableHDRCheckBox->setChecked(toml::find_or(data, "General", "allowHDR", false)); + ui->enableHDRCheckBox->setChecked(toml::find_or(data, "GPU", "allowHDR", false)); ui->playBGMCheckBox->setChecked(toml::find_or(data, "General", "playBGM", false)); ui->disableTrophycheckBox->setChecked( toml::find_or(data, "General", "isTrophyPopupDisabled", false)); ui->popUpDurationSpinBox->setValue(Config::getTrophyNotificationDuration()); - ui->radioButton_Left->setChecked(Config::leftSideTrophy()); - ui->radioButton_Right->setChecked(!ui->radioButton_Left->isChecked()); + + QString side = QString::fromStdString(Config::sideTrophy()); + + ui->radioButton_Left->setChecked(side == "left"); + ui->radioButton_Right->setChecked(side == "right"); + ui->radioButton_Top->setChecked(side == "top"); + ui->radioButton_Bottom->setChecked(side == "bottom"); + ui->BGMVolumeSlider->setValue(toml::find_or(data, "General", "BGMvolume", 50)); ui->discordRPCCheckbox->setChecked( toml::find_or(data, "General", "enableDiscordRPC", true)); QString translatedText_FullscreenMode = screenModeMap.key(QString::fromStdString(Config::getFullscreenMode())); ui->displayModeComboBox->setCurrentText(translatedText_FullscreenMode); - ui->separateUpdatesCheckBox->setChecked( - toml::find_or(data, "General", "separateUpdateEnabled", false)); ui->gameSizeCheckBox->setChecked(toml::find_or(data, "GUI", "loadGameSizeEnabled", true)); ui->showSplashCheckBox->setChecked(toml::find_or(data, "General", "showSplash", false)); QString translatedText_logType = logTypeMap.key(QString::fromStdString(Config::getLogType())); @@ -470,7 +491,7 @@ void SettingsDialog::LoadValuesFromConfig() { QString updateChannel = QString::fromStdString(Config::getUpdateChannel()); ui->updateComboBox->setCurrentText( channelMap.key(updateChannel != "Release" && updateChannel != "Nightly" - ? (Common::isRelease ? "Release" : "Nightly") + ? (Common::g_is_release ? "Release" : "Nightly") : updateChannel)); #endif @@ -576,8 +597,6 @@ void SettingsDialog::updateNoteTextEdit(const QString& elementName) { text = tr("Console Language:\\nSets the language that the PS4 game uses.\\nIt's recommended to set this to a language the game supports, which will vary by region."); } else if (elementName == "emulatorLanguageGroupBox") { text = tr("Emulator Language:\\nSets the language of the emulator's user interface."); - } else if (elementName == "separateUpdatesCheckBox") { - text = tr("Enable Separate Update Folder:\\nEnables installing game updates into a separate folder for easy management.\\nThis can be manually created by adding the extracted update to the game folder with the name \"CUSA00000-UPDATE\" where the CUSA ID matches the game's ID."); } else if (elementName == "showSplashCheckBox") { text = tr("Show Splash Screen:\\nShows the game's splash screen (a special image) while the game is starting."); } else if (elementName == "discordRPCCheckbox") { @@ -612,7 +631,7 @@ void SettingsDialog::updateNoteTextEdit(const QString& elementName) { //User if (elementName == "OpenCustomTrophyLocationButton") { - text = tr("Open the custom trophy images/sounds folder:\\nYou can add custom images to the trophies and an audio.\\nAdd the files to custom_trophy with the following names:\\nthophy.mp3, bronze.png, gold.png, platinum.png, silver.png"); + text = tr("Open the custom trophy images/sounds folder:\\nYou can add custom images to the trophies and an audio.\\nAdd the files to custom_trophy with the following names:\\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\\nNote: The sound will only work in QT versions."); } // Input @@ -644,6 +663,8 @@ void SettingsDialog::updateNoteTextEdit(const QString& elementName) { text = tr("Add:\\nAdd a folder to the list."); } else if (elementName == "removeFolderButton") { text = tr("Remove:\\nRemove a folder from the list."); + } else if (elementName == "PortableUserFolderGroupBox") { + text = tr("Portable user folder:\\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it."); } // Save Data @@ -706,7 +727,17 @@ void SettingsDialog::UpdateSettings() { Config::setIsMotionControlsEnabled(ui->motionControlsCheckBox->isChecked()); Config::setisTrophyPopupDisabled(ui->disableTrophycheckBox->isChecked()); Config::setTrophyNotificationDuration(ui->popUpDurationSpinBox->value()); - Config::setLeftSideTrophy(ui->radioButton_Left->isChecked()); + + if (ui->radioButton_Top->isChecked()) { + Config::setSideTrophy("top"); + } else if (ui->radioButton_Left->isChecked()) { + Config::setSideTrophy("left"); + } else if (ui->radioButton_Right->isChecked()) { + Config::setSideTrophy("right"); + } else if (ui->radioButton_Bottom->isChecked()) { + Config::setSideTrophy("bottom"); + } + Config::setPlayBGM(ui->playBGMCheckBox->isChecked()); Config::setAllowHDR(ui->enableHDRCheckBox->isChecked()); Config::setLogType(logTypeMap.value(ui->logTypeComboBox->currentText()).toStdString()); @@ -724,7 +755,6 @@ void SettingsDialog::UpdateSettings() { Config::setVblankDiv(ui->vblankSpinBox->value()); Config::setDumpShaders(ui->dumpShadersCheckBox->isChecked()); Config::setNullGpu(ui->nullGpuCheckBox->isChecked()); - Config::setSeparateUpdateEnabled(ui->separateUpdatesCheckBox->isChecked()); Config::setLoadGameSizeEnabled(ui->gameSizeCheckBox->isChecked()); Config::setShowSplash(ui->showSplashCheckBox->isChecked()); Config::setDebugDump(ui->debugDump->isChecked()); @@ -748,6 +778,17 @@ void SettingsDialog::UpdateSettings() { emit BackgroundOpacityChanged(ui->backgroundImageOpacitySlider->value()); Config::setShowBackgroundImage(ui->showBackgroundImageCheckBox->isChecked()); + std::vector dirs_with_states; + for (int i = 0; i < ui->gameFoldersListWidget->count(); i++) { + QListWidgetItem* item = ui->gameFoldersListWidget->item(i); + QString path_string = item->text(); + auto path = Common::FS::PathFromQString(path_string); + bool enabled = (item->checkState() == Qt::Checked); + + dirs_with_states.push_back({path, enabled}); + } + Config::setAllGameInstallDirs(dirs_with_states); + #ifdef ENABLE_DISCORD_RPC auto* rpc = Common::Singleton::Instance(); if (Config::getEnableDiscordRPC()) { @@ -762,6 +803,7 @@ void SettingsDialog::UpdateSettings() { } void SettingsDialog::ResetInstallFolders() { + ui->gameFoldersListWidget->clear(); std::filesystem::path userdir = Common::FS::GetUserPath(Common::FS::PathType::UserDir); const toml::value data = toml::parse(userdir / "config.toml"); @@ -769,22 +811,37 @@ void SettingsDialog::ResetInstallFolders() { if (data.contains("GUI")) { const toml::value& gui = data.at("GUI"); const auto install_dir_array = - toml::find_or>(gui, "installDirs", {}); - std::vector settings_install_dirs_config = {}; + toml::find_or>(gui, "installDirs", {}); - for (const auto& dir : install_dir_array) { - if (std::find(settings_install_dirs_config.begin(), settings_install_dirs_config.end(), - dir) == settings_install_dirs_config.end()) { - settings_install_dirs_config.push_back(dir); - } + std::vector install_dirs_enabled; + try { + install_dirs_enabled = Config::getGameInstallDirsEnabled(); + } catch (...) { + // If it does not exist, assume that all are enabled. + install_dirs_enabled.resize(install_dir_array.size(), true); } - for (const auto& dir : settings_install_dirs_config) { + if (install_dirs_enabled.size() < install_dir_array.size()) { + install_dirs_enabled.resize(install_dir_array.size(), true); + } + + std::vector settings_install_dirs_config; + + for (size_t i = 0; i < install_dir_array.size(); i++) { + std::filesystem::path dir = install_dir_array[i]; + bool enabled = install_dirs_enabled[i]; + + settings_install_dirs_config.push_back({dir, enabled}); + QString path_string; Common::FS::PathToQString(path_string, dir); + QListWidgetItem* item = new QListWidgetItem(path_string); + item->setFlags(item->flags() | Qt::ItemIsUserCheckable); + item->setCheckState(enabled ? Qt::Checked : Qt::Unchecked); ui->gameFoldersListWidget->addItem(item); } - Config::setGameInstallDirs(settings_install_dirs_config); + + Config::setAllGameInstallDirs(settings_install_dirs_config); } } diff --git a/src/qt_gui/settings_dialog.ui b/src/qt_gui/settings_dialog.ui index c793aced5..20e26775d 100644 --- a/src/qt_gui/settings_dialog.ui +++ b/src/qt_gui/settings_dialog.ui @@ -31,7 +31,7 @@ Settings
- + :/images/shadps4.ico:/images/shadps4.ico @@ -59,7 +59,7 @@ - 0 + 5 @@ -74,7 +74,7 @@ 0 0 946 - 545 + 536 @@ -130,21 +130,11 @@ 9 - - Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop - 10 - - - - Enable Separate Update Folder - - - @@ -455,7 +445,7 @@ 0 0 946 - 545 + 536 @@ -904,7 +894,7 @@ 0 0 946 - 545 + 536 @@ -1199,7 +1189,7 @@ 0 0 946 - 545 + 536 @@ -1295,17 +1285,25 @@ - - - 0 - 0 - - Right + + + + Top + + + + + + + Bottom + + + @@ -1327,8 +1325,7 @@ - - + @@ -1434,7 +1431,7 @@ 0 0 946 - 545 + 536 @@ -1718,7 +1715,7 @@ 0 0 946 - 545 + 536 @@ -1792,6 +1789,58 @@ + + + + Portable User Folder + + + + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + Create Portable User Folder from Common User Folder + + + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + + @@ -1808,7 +1857,7 @@ 0 0 946 - 545 + 536 @@ -2060,6 +2109,8 @@ - + + + diff --git a/src/qt_gui/translations/ar_SA.ts b/src/qt_gui/translations/ar_SA.ts index f1b16d4b0..e434b3259 100644 --- a/src/qt_gui/translations/ar_SA.ts +++ b/src/qt_gui/translations/ar_SA.ts @@ -7,34 +7,34 @@ AboutDialog About shadPS4 - حول shadPS4 + حول محاكي الظل PS4 shadPS4 is an experimental open-source emulator for the PlayStation 4. - shadPS4 هو محاكي تجريبي مفتوح المصدر لجهاز PlayStation 4. + محاكي الظل هو محاكي تجريبي مفتوح المصدر مخصص لـ PS4 This software should not be used to play games you have not legally obtained. - يجب عدم استخدام هذا البرنامج لتشغيل الألعاب التي لم تحصل عليها بشكل قانوني. + لا تستخدم هذا البرنامج لتشغيل الألعاب بطريقة غير قانونية. CheatsPatches Cheats / Patches for - Cheats / Patches for + شفرات / إصلاحات لـ Cheats/Patches are experimental.\nUse with caution.\n\nDownload cheats individually by selecting the repository and clicking the download button.\nIn the Patches tab, you can download all patches at once, choose which ones you want to use, and save your selection.\n\nSince we do not develop the Cheats/Patches,\nplease report issues to the cheat author.\n\nCreated a new cheat? Visit:\n - الغش والتصحيحات هي ميزات تجريبية.\nاستخدمها بحذر.\n\nقم بتنزيل الغش بشكل فردي عن طريق اختيار المستودع والنقر على زر التنزيل.\nفي علامة تبويب التصحيحات، يمكنك تنزيل جميع التصحيحات دفعة واحدة، واختيار ما تريد استخدامه، وحفظ اختياراتك.\n\nنظرًا لأننا لا نقوم بتطوير الغش/التصحيحات،\nيرجى الإبلاغ عن أي مشاكل إلى مؤلف الغش.\n\nهل قمت بإنشاء غش جديد؟ قم بزيارة:\n + الشفرات والإصلاحات هي ميزات تجريبية.\nاستخدمها بحذر.\n\nقم بتنزيل الشفرات بشكل فردي عن طريق اختيار المستودع والضغط على تنزيل.\nفي علامة تبويب الإصلاحات، يمكنك تنزيل جميع الإصلاحات دفعة واحدة، واختيار ما تريد استخدامه، وحفظ اختياراتك.\n\nنظرًا لأننا لا نقوم بتطوير الشفرات والإصلاحات ،\nيرجى الإبلاغ عن أي مشاكل إلى مؤلف الشفرات.\n\nهل قمت بإنشاء شفرة جديد؟ قم بزيارة:\n No Image Available - لا تتوفر صورة + الصورة غير موجودة Serial: - الرقم التسلسلي: + الرَّقَم التسلسلي: Version: @@ -46,7 +46,7 @@ Select Cheat File: - اختر ملف الغش: + حدد مِلَفّ الشفرات: Repository: @@ -54,7 +54,7 @@ Download Cheats - تنزيل الغش + تحميل الشفرات Delete File @@ -66,19 +66,19 @@ You can delete the cheats you don't want after downloading them. - يمكنك حذف الغش الذي لا تريده بعد تنزيله. + يمكنك حذف الشفرات التي لا 'تريدها بعد تنزيلها. Do you want to delete the selected file?\n%1 - هل تريد حذف الملف المحدد؟\n%1 + هل ترغب في حذف الملف المحدد؟\n%1 Select Patch File: - اختر ملف التصحيح: + اختر مِلَف التصحيح: Download Patches - تنزيل التصحيحات + تحميل ملفات التصحيح Save @@ -86,7 +86,7 @@ Cheats - الغش + الشفرات Patches @@ -98,15 +98,15 @@ No patch selected. - لم يتم اختيار أي تصحيح. + لم يتم تحديد أي مِلَف تصحيح. Unable to open files.json for reading. - تعذر فتح files.json للقراءة. + تعذّر فتح مِلَف files.json للقراءة. No patch file found for the current serial. - لم يتم العثور على ملف تصحيح للرقم التسلسلي الحالي. + لم يتم العثور على مِلَف تصحيح للسيريال الحالي. Unable to open the file for reading. @@ -126,11 +126,11 @@ Options saved successfully. - تم حفظ الخيارات بنجاح. + تم حفظ الإعدادات. Invalid Source - مصدر غير صالح + المصدر غير صالح The selected source is invalid. @@ -138,11 +138,11 @@ File Exists - الملف موجود + المِلَف موجود مسبقًا File already exists. Do you want to replace it? - الملف موجود بالفعل. هل تريد استبداله؟ + المِلَف موجود مسبقًا. هل ترغب في استبداله؟ Failed to save file: @@ -154,19 +154,19 @@ Cheats Not Found - لم يتم العثور على الغش + لم يتم العثور على أي شفرات No Cheats found for this game in this version of the selected repository,try another repository or a different version of the game. - لم يتم العثور على غش لهذه اللعبة في هذا الإصدار من المستودع المحدد. حاول استخدام مستودع آخر أو إصدار آخر من اللعبة. + لم يتم العثور على شفرات لهذه اللعبة في هذا الإصدار من المستودع المحدد. جرّب مستودعًا آخر أو إصدارًا مختلفًا من اللعبة. Cheats Downloaded Successfully - تم تنزيل الغش بنجاح + تم تحميل الشفرات بنجاح You have successfully downloaded the cheats for this version of the game from the selected repository. You can try downloading from another repository, if it is available it will also be possible to use it by selecting the file from the list. - لقد نجحت في تنزيل الغش لهذا الإصدار من اللعبة من المستودع المحدد. يمكنك محاولة التنزيل من مستودع آخر. إذا كان متاحًا، يمكنك اختياره عن طريق تحديد الملف من القائمة. + تم تحميل الشفرات بنجاح لهذه النسخة من اللعبة من المستودع الذي اخترته. إذا أردت، يمكنك تجربة مستودع آخر، وإذا كان متاحًا، يمكنك استخدام الشفرات عن طريق اختيار الملف من القائمة. Failed to save: @@ -182,7 +182,7 @@ Patches Downloaded Successfully! All Patches available for all games have been downloaded, there is no need to download them individually for each game as happens in Cheats. If the patch does not appear, it may be that it does not exist for the specific serial and version of the game. - تم تنزيل التصحيحات بنجاح! تم تنزيل جميع التصحيحات لجميع الألعاب، ولا داعي لتنزيلها بشكل فردي لكل لعبة كما هو الحال مع الغش. إذا لم يظهر التحديث، قد يكون السبب أنه غير متوفر للإصدار وسيريال اللعبة المحدد. + تم تنزيل التصحيحات بنجاح! تم تنزيل جميع التصحيحات المتوفرة لجميع الألعاب، ولا حاجة إلى تنزيلها بشكل فردي لكل لعبة كما هو الحال مع الشفرات. إذا لم يظهر التصحيح، فقد لا يكون متوفرًا للسيريال أو الإصدار المحدد من اللعبة. Failed to parse JSON data from HTML. @@ -190,15 +190,15 @@ Failed to retrieve HTML page. - .HTML فشل في استرجاع صفحة + فشل في جلب صفحة HTML. The game is in version: %1 - اللعبة في الإصدار: %1 + إصدار اللعبة الحالي: %1 The downloaded patch only works on version: %1 - الباتش الذي تم تنزيله يعمل فقط على الإصدار: %1 + التصحيح الذي تم تنزيله يعمل فقط مع الإصدار:%1 You may need to update your game. @@ -206,7 +206,7 @@ Incompatibility Notice - إشعار عدم التوافق + إشعار بعدم التوافق Failed to open file: @@ -238,7 +238,7 @@ Can't apply cheats before the game is started - لا يمكن تطبيق الغش قبل بدء اللعبة. + لا 'يمكن تطبيق الشفرات قبل بَدْء اللعبة Close @@ -249,7 +249,7 @@ CheckUpdate Auto Updater - محدث تلقائي + التحديثات التلقائية Error @@ -261,7 +261,7 @@ The Auto Updater allows up to 60 update checks per hour.\nYou have reached this limit. Please try again later. - يتيح التحديث التلقائي ما يصل إلى 60 عملية تحقق من التحديث في الساعة.\nلقد وصلت إلى هذا الحد. الرجاء المحاولة مرة أخرى لاحقًا. + تسمح التحديثات التلقائية بـ 60 عملية تحقق من التحديث في الساعة.\nلقد وصلت إلى الحد المسموح به. الرجاء المحاولة لاحقًا. Failed to parse update information. @@ -329,7 +329,7 @@ Network error occurred while trying to access the URL - حدث خطأ في الشبكة أثناء محاولة الوصول إلى عنوان URL + حدث خطأ في الشبكة عند محاولة الوصول إلى الموقع Download Complete @@ -388,11 +388,11 @@ Boots - أحذية + إقلاع Menus - قوائم + القائمة Ingame @@ -407,146 +407,217 @@ ControlSettings Configure Controls - Configure Controls + إعدادات التحكم D-Pad - D-Pad + الأسهم+عصا التحكم Up - Up + فوق Left - Left + يسار Right - Right + يمين Down - Down + تحت Left Stick Deadzone (def:2 max:127) - Left Stick Deadzone (def:2 max:127) + النقطة العمياء للعصا اليسرى (الافتراضي: 2، الحد الأقصى: 127) Left Deadzone - Left Deadzone + النقطة العمياء لليسار Left Stick - Left Stick + عصا التحكم اليسرى Config Selection - Config Selection + تحديد الإعدادات Common Config - Common Config + إعدادات عامة Use per-game configs - Use per-game configs + استخدام إعدادات كل لُعْبَة L1 / LB - L1 / LB + L1 / LB L2 / LT - L2 / LT + L2 / LT Back - Back + رجوع R1 / RB - R1 / RB + R1 / RB R2 / RT - R2 / RT + R2 / RT L3 - L3 + L3 Options / Start - Options / Start + الخيارات / البَدْء R3 - R3 + R3 Face Buttons - Face Buttons + الأزرار Triangle / Y - Triangle / Y + مثلث / Y Square / X - Square / X + مربع / X Circle / B - Circle / B + دائرة / B Cross / A - Cross / A + إكس / A Right Stick Deadzone (def:2, max:127) - Right Stick Deadzone (def:2, max:127) + النقطة العمياء للعصا اليمنى (الافتراضي: 2، الحد الأقصى: 127) Right Deadzone - Right Deadzone + النقطة العمياء اليمنى Right Stick - Right Stick + عصا التحكم اليمنى Color Adjustment - Color Adjustment + تعديل الألوان R: - R: + أحمر: G: - G: + أخضر: B: - B: + أزرق: Override Lightbar Color - Override Lightbar Color + تجاوز لون شريط الإضاءة Override Color - Override Color + تجاوز اللون + + + Unable to Save + غير قادر على الحفظ + + + Cannot bind axis values more than once + لا يمكن ربط قيم المحور أكثر من مرة + + + Save + حفظ + + + Apply + تطبيق + + + Restore Defaults + استعادة الإعدادات الافتراضية + + + Cancel + إلغاء + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + تحرير أزرار الإدخال للوحة المفاتيح و الفأرة ووحدة التحكم + + + Use Per-Game configs + استخدام إعدادات كل لُعْبَة + + + Error + خطأ + + + Could not open the file for reading + تعذر فتح المِلَفّ للقراءة + + + Could not open the file for writing + تعذر فتح المِلَفّ للكتابة + + + Save Changes + حفظ التغييرات + + + Do you want to save changes? + هل تريد حفظ التغييرات؟ + + + Help + المساعدة + + + Do you want to reset your custom default config to the original default config? + هل تريد إعادة تعيين الإعدادات الافتراضية المخصصة الخاصة بك إلى الإعدادات الافتراضية الأصلية؟ + + + Do you want to reset this config to your custom default config? + هل تريد إعادة تعيين هذا الإعداد إلى الإعداد الافتراضي المخصص لك؟ + + + Reset to Default + إعادة تعيين إلى الافتراضي ElfViewer Open Folder - فتح المجلد + افتح مجلد @@ -576,7 +647,7 @@ Browse - تصفح + استعراض Error @@ -584,7 +655,7 @@ Directory to install DLC - Directory to install DLC + مكان تثبيت حزمات DLC @@ -603,7 +674,7 @@ Compatibility - Compatibility + التوافق Region @@ -631,47 +702,47 @@ Never Played - Never Played + لم تلعب أبداً h - h + ا m - m + ة s - s + ثانية/ثواني Compatibility is untested - Compatibility is untested + لم يتم اختبار التوافق Game does not initialize properly / crashes the emulator - Game does not initialize properly / crashes the emulator + اللعبة لا تبدأ بشكل صحيح / تتسبب في انهيار المحاكي Game boots, but only displays a blank screen - Game boots, but only displays a blank screen + اللعبة تبدأ بالإقلاع، لكنها تعرض شاشة فارغة فقط Game displays an image but does not go past the menu - Game displays an image but does not go past the menu + اللعبة تعرض صورة ولكن لا تتجاوز القائمة Game has game-breaking glitches or unplayable performance - Game has game-breaking glitches or unplayable performance + اللعبة بها أخطاء جسيمة أو أداء يجعلها غير قابلة للعب Game can be completed with playable performance and no major glitches - Game can be completed with playable performance and no major glitches + يمكن إنهاء اللعبة بأداء جيد وبدون أعطال رئيسية Click to see details on github - انقر لرؤية التفاصيل على GitHub + اضغط لعرض التفاصيل على GitHub Last updated @@ -682,23 +753,23 @@ GameListUtils B - B + بايت KB - KB + كيلو بايت MB - MB + ميغابايت GB - GB + جيجابايت TB - TB + تيرابايت @@ -709,15 +780,15 @@ Cheats / Patches - الغش / التصحيحات + الشفرات / التصحيحات SFO Viewer - عارض SFO + عارض معلومات اللعبة (SFO) Trophy Viewer - عارض الجوائز + عارض الكؤوس Open Folder... @@ -749,11 +820,11 @@ Copy Version - Copy Version + نسخ الإصدار Copy Size - Copy Size + نسخ حجم Copy All @@ -761,35 +832,39 @@ Delete... - Delete... + حذف... Delete Game - Delete Game + حذف اللعبة Delete Update - Delete Update + حذف التحديث Delete DLC - Delete DLC + حذف DLC + + + Delete Trophy + حذف الكؤوس Compatibility... - Compatibility... + التوافق... Update database - Update database + تحديث قاعدة البيانات View report - View report + عرض التقرير Submit a report - Submit a report + إرسال تقرير Shortcut creation @@ -807,95 +882,314 @@ Error creating shortcut! خطأ في إنشاء الاختصار - - Install PKG - PKG تثبيت - Game - Game + اللعبة This game has no update to delete! - This game has no update to delete! + لا يوجد تحديث لهذه اللعبة لحذفه! Update - Update + تحديث This game has no DLC to delete! - This game has no DLC to delete! + لا توجد محتويات إضافية (DLC) لهذه اللعبة لحذفها! DLC - DLC + DLC Delete %1 - Delete %1 + حذف %1 Are you sure you want to delete %1's %2 directory? - Are you sure you want to delete %1's %2 directory? + هل أنت متأكد من أنك تريد حذف دليل %1's %2؟ Open Update Folder - Open Update Folder + فتح مجلد التحديث Delete Save Data - Delete Save Data + حذف بيانات الحفظ This game has no update folder to open! - This game has no update folder to open! + لا يوجد مجلد تحديث لهذه اللعبة لفتحه! + + + No log file found for this game! + لم يتم العثور على ملف سجل لهذه اللعبة! Failed to convert icon. - Failed to convert icon. + فشل تحويل الأيقونة. This game has no save data to delete! - This game has no save data to delete! + لا توجد بيانات حفظ لهذه اللعبة لحذفها! + + + This game has no saved trophies to delete! + لا توجد كؤوس محفوظة لهذه اللعبة لحذفها! Save Data - Save Data + بيانات الحفظ + + + Trophy + الكؤوس SFO Viewer for - SFO Viewer for + عارض SFO لـ - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - shadPS4 - اختر المجلد + Quickstart + البدء السريع - Select which directory you want to install to. - Select which directory you want to install to. + FAQ + الأسئلة الأكثر شيوعاً - Install All Queued to Selected Folder - Install All Queued to Selected Folder + Syntax + البنية - Delete PKG File on Install - Delete PKG File on Install + Special Bindings + الارتباطات الخاصة + + + Keybindings + تعيين الأزرار + + + + KBMSettings + + Configure Controls + إعدادات جهاز التحكم + + + D-Pad + الأسهم+عصا التحكم + + + Up + أعلى + + + unmapped + غير معين + + + Left + يسار + + + Right + يمين + + + Down + أسفل + + + Left Analog Halfmode + تقليل سرعة عصا التحكم اليسرى للنصف + + + hold to move left stick at half-speed + الاستمرار للتحرك إلى اليسار بنصف السرعة + + + Left Stick + عصا التحكم اليسرى + + + Config Selection + تحديد الإعدادات + + + Common Config + إعدادات عامة + + + Use per-game configs + استخدام إعدادات خاصة لكل لعبه + + + L1 + L1 + + + L2 + L2 + + + Text Editor + محرّر النصوص + + + Help + المساعدة + + + R1 + R1 + + + R2 + R2 + + + L3 + L3 + + + Touchpad Click + زر لوحة اللمس + + + Mouse to Joystick + تحويل الماوس إلى عصا التحكم + + + *press F7 ingame to activate + * اضغط F7 داخل اللعبة للتفعيل + + + R3 + R3 + + + Options + الخيارات + + + Mouse Movement Parameters + إعدادات حركة الماوس + + + note: click Help Button/Special Keybindings for more information + ملاحظة: لمزيد من المعلومات عن التعيينات الخاصة، اضغط على زر المساعدة + + + Face Buttons + الأزرار الأمامية + + + Triangle + مثلث + + + Square + مربع + + + Circle + دائرة + + + Cross + اكس + + + Right Analog Halfmode + وضع النصف للعصا اليمنى (نصف الحساسية أو نصف الحركة) + + + hold to move right stick at half-speed + اضغط مع الاستمرار لتحريك العصا اليمنى بسرعة منخفضة + + + Right Stick + عصا التحكم اليمنى + + + Speed Offset (def 0.125): + تعويض السرعة (الافتراضي 0.125): + + + Copy from Common Config + نسخ من الإعدادات العامة + + + Deadzone Offset (def 0.50): + تعويض منطقة الخمول (الافتراضي 0.50): + + + Speed Multiplier (def 1.0): + معدل مضاعفة السرعة (التلقائي 1.0): + + + Common Config Selected + تم اختيار الإعدادات العامة + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + يقوم هذا الزر بنسخ التعيينات من الإعدادات العامة إلى الملف الشخصي المحدد حاليًا، ولا يمكن استخدامه إذا كانت الإعدادات العامة هي الملف المحدد. + + + Copy values from Common Config + نسخ القيم من الإعدادات العامة + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + هل تريد استبدال التعيينات الحالية بالتعيينات من الإعدادات العامة؟ + + + Unable to Save + تعذّر الحفظ + + + Cannot bind any unique input more than once + لا يمكن تعيين نفس الزر لأكثر من وظيفة + + + Press a key + اضغط زرًا + + + Cannot set mapping + تعذّر تعيين الزر + + + Mousewheel cannot be mapped to stick outputs + لا يمكن تعيين عجلة الفأرة لمخرجات العصا + + + Save + حفظ + + + Apply + تطبيق + + + Restore Defaults + استعادة الإعدادات الافتراضية + + + Cancel + إلغاء MainWindow Open/Add Elf Folder - Elf فتح/إضافة مجلد - - - Install Packages (PKG) - (PKG) تثبيت الحزم + فتح / إضافة مجلد Elf Boot Game @@ -913,17 +1207,13 @@ Configure... ...تكوين - - Install application from a .pkg file - .pkg تثبيت التطبيق من ملف - Recent Games الألعاب الأخيرة Open shadPS4 Folder - Open shadPS4 Folder + فتح مجلد shadPS4 Exit @@ -935,11 +1225,11 @@ Exit the application. - الخروج من التطبيق. + إغلاق التطبيق Show Game List - إظهار قائمة الألعاب + عرض قائمة الألعاب Game List Refresh @@ -986,8 +1276,12 @@ تفريغ قائمة الألعاب - PKG Viewer - عارض PKG + Trophy Viewer + عارض الجوائز + + + No games found. Please add your games to your library first. + لم يتم العثور على ألعاب. يرجى إضافة ألعابك إلى المكتبة أولاً. Search... @@ -1051,7 +1345,7 @@ Game List - ققائمة الألعاب + قائمة الألعاب * Unsupported Vulkan Version @@ -1059,7 +1353,7 @@ Download Cheats For All Installed Games - تنزيل الغش لجميع الألعاب المثبتة + تحميل الشفرات لجميع الألعاب المثبتة Download Patches For All Games @@ -1071,7 +1365,7 @@ You have downloaded cheats for all the games you have installed. - لقد قمت بتنزيل الغش لجميع الألعاب التي قمت بتثبيتها. + تم تحميل الشفرات لجميع الألعاب المثبتة. Patches Downloaded Successfully! @@ -1097,160 +1391,61 @@ Only one file can be selected! !يمكن تحديد ملف واحد فقط - - PKG Extraction - PKG استخراج - - - Patch detected! - تم اكتشاف تصحيح! - - - PKG and Game versions match: - :واللعبة تتطابق إصدارات PKG - - - Would you like to overwrite? - هل ترغب في الكتابة فوق الملف الموجود؟ - - - PKG Version %1 is older than installed version: - :أقدم من الإصدار المثبت PKG Version %1 - - - Game is installed: - :اللعبة مثبتة - - - Would you like to install Patch: - :هل ترغب في تثبيت التصحيح - - - DLC Installation - تثبيت المحتوى القابل للتنزيل - - - Would you like to install DLC: %1? - هل ترغب في تثبيت المحتوى القابل للتنزيل: 1%؟ - - - DLC already installed: - :المحتوى القابل للتنزيل مثبت بالفعل - - - Game already installed - اللعبة مثبتة بالفعل - - - PKG ERROR - PKG خطأ في - - - Extracting PKG %1/%2 - PKG %1/%2 جاري استخراج - - - Extraction Finished - اكتمل الاستخراج - - - Game successfully installed at %1 - تم تثبيت اللعبة بنجاح في %1 - - - File doesn't appear to be a valid PKG file - يبدو أن الملف ليس ملف PKG صالحًا - Run Game - Run Game + تشغيل اللعبة Eboot.bin file not found - Eboot.bin file not found - - - PKG File (*.PKG *.pkg) - PKG File (*.PKG *.pkg) - - - PKG is a patch or DLC, please install the game first! - PKG is a patch or DLC, please install the game first! + لم يتم العثور على ملف Eboot.bin Game is already running! - Game is already running! + اللعبة قيد التشغيل بالفعل! shadPS4 - shadPS4 - - - - PKGViewer - - Open Folder - فتح المجلد + shadPS4 - PKG ERROR - PKG خطأ في + Play + تشغيل - Name - اسم + Pause + إيقاف مؤقت - Serial - سيريال + Stop + إيقاف - Installed - Installed + Restart + إعادة تشغيل - Size - حجم + Full Screen + الشاشة الكاملة - Category - Category + Controllers + وحدات التحكم - Type - Type + Keyboard + لوحة المفاتيح - App Ver - App Ver + Refresh List + تحديث القائمة - FW - FW + Resume + استئناف - Region - منطقة - - - Flags - Flags - - - Path - مسار - - - File - ملف - - - Unknown - غير معروف - - - Package - Package + Show Labels Under Icons + إظهار التسميات تحت الأيقونات @@ -1269,7 +1464,7 @@ Console Language - لغة وحدة التحكم + لغة النظام Emulator Language @@ -1279,17 +1474,13 @@ Emulator المحاكي - - Enable Separate Update Folder - Enable Separate Update Folder - Default tab when opening settings - علامة التبويب الافتراضية عند فتح الإعدادات + التبويب الافتراضي عند فتح الإعدادات Show Game Size In List - عرض حجم اللعبة في القائمة + إظهار حجم اللعبة في القائمة Show Splash @@ -1305,15 +1496,19 @@ Trophy Key - Trophy Key + مفتاح الكأس Trophy - Trophy + الكؤوس + + + Open the custom trophy images/sounds folder + فتح مجلد الصور/الأصوات المخصصة للكؤوس Logger - المسجل + سجل الأحداث Log Type @@ -1325,27 +1520,27 @@ Open Log Location - افتح موقع السجل + فتح موقع السجل Input - إدخال + إعدادات المدخلات Cursor - مؤشر + مؤشر الماوس Hide Cursor - إخفاء المؤشر + إخفاء مؤشر الماوس Hide Cursor Idle Timeout - مهلة إخفاء المؤشر عند الخمول + إخفاء المؤشر بعد فترة الخمول s - s + س Controller @@ -1357,7 +1552,7 @@ Graphics - الرسومات + الرسوميات GUI @@ -1369,7 +1564,7 @@ Graphics Device - جهاز الرسومات + جهاز الرسوميات Vblank Divider @@ -1377,19 +1572,19 @@ Advanced - متقدم + الإعدادات المتقدمة Enable Shaders Dumping - تمكين تفريغ الشيدرات + تمكين تصدير الشيدرات Enable NULL GPU - تمكين وحدة معالجة الرسومات الفارغة + تمكين GPU فارغ Enable HDR - Enable HDR + تشغيل HDR Paths @@ -1409,43 +1604,43 @@ Debug - تصحيح الأخطاء + التصحيح Enable Debug Dumping - تمكين تفريغ التصحيح + تمكين تصدير بيانات التصحيح Enable Vulkan Validation Layers - Vulkan تمكين طبقات التحقق من + تمكين طبقات التحقق لـ Vulkan Enable Vulkan Synchronization Validation - Vulkan تمكين التحقق من تزامن + تمكين التحقق من تزامن Vulkan Enable RenderDoc Debugging - RenderDoc تمكين تصحيح أخطاء + تمكين التصحيح باستخدام RenderDoc Enable Crash Diagnostics - Enable Crash Diagnostics + تشغيل تشخيص الأعطال Collect Shaders - Collect Shaders + جمع الشيدرات Copy GPU Buffers - Copy GPU Buffers + نسخ مخازن الرسوميات Host Debug Markers - Host Debug Markers + علامات التصحيح على المضيف Guest Debug Markers - Guest Debug Markers + علامات التصحيح على الضيف Update @@ -1453,11 +1648,11 @@ Check for Updates at Startup - تحقق من التحديثات عند بدء التشغيل + التحقق من التحديثات عند بدء التشغيل Always Show Changelog - Always Show Changelog + عرض سجل التغييرات دائمًا Update Channel @@ -1473,23 +1668,23 @@ Title Music - Title Music + موسيقى الشاشة الرئيسية - Disable Trophy Pop-ups - Disable Trophy Pop-ups + Disable Trophy Notification + تعطيل إشعار التروفي Background Image - Background Image + صورة الخلفية Show Background Image - Show Background Image + إظهار صورة الخلفية Opacity - Opacity + الشفافية Play title music @@ -1497,19 +1692,19 @@ Update Compatibility Database On Startup - Update Compatibility Database On Startup + تحديث بيانات التوافق تلقائيًا عند التشغيل Game Compatibility - Game Compatibility + توافق الألعاب Display Compatibility Data - Display Compatibility Data + عرض بيانات التوافق Update Compatibility Database - Update Compatibility Database + تحديث قاعدة بيانات التوافق Volume @@ -1533,7 +1728,7 @@ Point your mouse at an option to display its description. - وجّه الماوس نحو خيار لعرض وصفه. + ✅ مرّر مؤشر الماوس على أي خِيار لعرض وصفه. Console Language:\nSets the language that the PS4 game uses.\nIt's recommended to set this to a language the game supports, which will vary by region. @@ -1541,15 +1736,11 @@ Emulator Language:\nSets the language of the emulator's user interface. - لغة المحاكي:\nتحدد لغة واجهة المستخدم الخاصة بالمحاكي. - - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management. + لغة المحاكي:\nتحدد اللغة المستخدمة في واجهة المحاكي. Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. - إظهار شاشة البداية:\nيعرض شاشة البداية الخاصة باللعبة (صورة خاصة) أثناء بدء التشغيل. + عرض شاشة البداية:\nيعرض شاشة البداية الخاصة باللعبة (صورة مميزة) أثناء بدء التشغيل. Enable Discord Rich Presence:\nDisplays the emulator icon and relevant information on your Discord profile. @@ -1557,59 +1748,60 @@ Username:\nSets the PS4's account username, which may be displayed by some games. - اسم المستخدم:\nيضبط اسم حساب PS4، الذي قد يتم عرضه في بعض الألعاب. + اسم المستخدم:\nيحدد اسم حساب'PS4، وقد يظهر في بعض الألعاب. Trophy Key:\nKey used to decrypt trophies. Must be obtained from your jailbroken console.\nMust contain only hex characters. - Trophy Key:\nKey used to decrypt trophies. Must be obtained from your jailbroken console.\nMust contain only hex characters. + مفتاح الكؤوس:\nيُستخدم لفك تشفير الجوائز داخل الألعاب. يُستخرج من جهاز معدل.\nيجب أن يُكتب باستخدام رموز ست عشرية فقط. Log Type:\nSets whether to synchronize the output of the log window for performance. May have adverse effects on emulation. - نوع السجل:\nيضبط ما إذا كان سيتم مزامنة مخرجات نافذة السجل للأداء. قد يؤثر سلبًا على المحاكاة. + نوع السجل:\nييحدد ما إذا كان سيتم مزامنة مخرجات نافذة السجل لتحسين الأداء. قد يؤدي ذلك إلى تأثيرات سلبية على المحاكاة. Log Filter:\nFilters the log to only print specific information.\nExamples: "Core:Trace" "Lib.Pad:Debug Common.Filesystem:Error" "*:Critical"\nLevels: Trace, Debug, Info, Warning, Error, Critical - in this order, a specific level silences all levels preceding it in the list and logs every level after it. - فلتر السجل:\nيقوم بتصفية السجل لطباعة معلومات محددة فقط.\nأمثلة: "Core:Trace" "Lib.Pad:Debug Common.Filesystem:Error" "*:Critical" المستويات: Trace, Debug, Info, Warning, Error, Critical - بالترتيب، مستوى محدد يخفي جميع المستويات التي تسبقه ويعرض جميع المستويات بعده. + تصفية السجل:\nيمكنك تحديد نوع المعلومات التي سيتم عرضها في السجل فقط.\nأمثلة: "Core:Trace" "Lib.Pad:Debug Common.Filesystem:Error" "*:Critical" االمستويات حسب الترتيب:: Trace, Debug, Info, Warning, Error, Critical - عند اختيار مستوى معين، يتم تجاهل كل ما قبله، وتسجيل كل ما بعده. Update:\nRelease: Official versions released every month that may be very outdated, but are more reliable and tested.\nNightly: Development versions that have all the latest features and fixes, but may contain bugs and are less stable. - تحديث: Release: إصدارات رسمية تصدر شهريًا، قد تكون قديمة بعض الشيء، لكنها أكثر استقرارًا واختبارًا. Nightly: إصدارات تطوير تحتوي على أحدث الميزات والإصلاحات، لكنها قد تحتوي على أخطاء وأقل استقرارًا. + تحديث: Release: نُسخ شهرية مستقرة وخضعت للاختبار، لكنها قد تكون قديمة. +Nightly: نُسخ تحتوي على أحدث الميزات، لكنها أقل استقرارًا وقد تحتوي على أخطاء. Background Image:\nControl the opacity of the game background image. - Background Image:\nControl the opacity of the game background image. + صورة الخلفية:\nتحكم في شفافية صورة خلفية اللعبة. Play Title Music:\nIf a game supports it, enable playing special music when selecting the game in the GUI. - تشغيل موسيقى العنوان:\nإذا كانت اللعبة تدعم ذلك، قم بتمكين تشغيل موسيقى خاصة عند اختيار اللعبة في واجهة المستخدم. + تشغيل موسيقى العنوان:\nفي حال كانت اللعبة تدعم ذلك، يتم تشغيل موسيقى خاصة عند تحديدها في الواجهة. Disable Trophy Pop-ups:\nDisable in-game trophy notifications. Trophy progress can still be tracked using the Trophy Viewer (right-click the game in the main window). - Disable Trophy Pop-ups:\nDisable in-game trophy notifications. Trophy progress can still be tracked using the Trophy Viewer (right-click the game in the main window). + تعطيل إشعارات التروفي:\nيمنع ظهور إشعارات الجوائز أثناء اللعب، بينما يظل بإمكانك متابعة التقدم من خلال "عارض التروفي" (انقر بزر الفأرة الأيمن على اللعبة في النافذة الرئيسية). Hide Cursor:\nChoose when the cursor will disappear:\nNever: You will always see the mouse.\nidle: Set a time for it to disappear after being idle.\nAlways: you will never see the mouse. - إخفاء المؤشر:\nاختر متى سيختفي المؤشر:\nأبداً: سترى الفأرة دائماً.\nعاطل: حدد وقتاً لاختفائه بعد أن يكون غير مستخدم.\nدائماً: لن ترى الفأرة أبداً. + إخفاء المؤشر:\nاختر متى يتم إخفاء مؤشر الماوس:\nأبدًا: يظهر دائمًا.\nعند الخمول: يختفي بعد فترة من عدم الحركة.\nدائمًا: لا يظهر إطلاقًا. Hide Idle Cursor Timeout:\nThe duration (seconds) after which the cursor that has been idle hides itself. - حدد وقتاً لاختفاء الفأرة بعد أن تكون غير مستخدم. + مدة إخفاء المؤشر عند الخمول:\nالوقت (بالثواني) الذي ينتظره المؤشر قبل أن يختفي تلقائيًا عند عدم استخدامه. Back Button Behavior:\nSets the controller's back button to emulate tapping the specified position on the PS4 touchpad. - سلوك زر العودة:\nيضبط زر العودة في وحدة التحكم ليحاكي الضغط على الموضع المحدد على لوحة اللمس في PS4. + سلوك زر الرجوع:\nيحدد وظيفة زر' الرجوع في وحدة التحكم لمحاكاة اللمس في موقع معيّن على لوحة اللمس الخاصة بـ PS4. Display Compatibility Data:\nDisplays game compatibility information in table view. Enable "Update Compatibility On Startup" to get up-to-date information. - Display Compatibility Data:\nDisplays game compatibility information in table view. Enable "Update Compatibility On Startup" to get up-to-date information. + عرض بيانات التوافق:\nيعرض معلومات توافق الألعاب في عرض جدولي. فعّل ""تحديث التوافق عند بدء التشغيل"" للحصول على أحدث المعلومات. Update Compatibility On Startup:\nAutomatically update the compatibility database when shadPS4 starts. - Update Compatibility On Startup:\nAutomatically update the compatibility database when shadPS4 starts. + تحديث التوافق عند بدء التشغيل:\nيتم تحديث قاعدة بيانات التوافق تلقائيًا عند بدء تشغيل shadPS4. Update Compatibility Database:\nImmediately update the compatibility database. - Update Compatibility Database:\nImmediately update the compatibility database. + تحديث قاعدة بيانات التوافق:\nتحديث فوري لقاعدة بيانات التوافق. Never @@ -1625,15 +1817,15 @@ Touchpad Left - لوحة اللمس اليسرى + الجانب الأيسر من لوحة اللمس Touchpad Right - لوحة اللمس اليمنى + الجانب الأيمن من لوحة اللمس Touchpad Center - وسط لوحة اللمس + مركز لوحة اللمس None @@ -1641,11 +1833,11 @@ Graphics Device:\nOn multiple GPU systems, select the GPU the emulator will use from the drop down list,\nor select "Auto Select" to automatically determine it. - جهاز الرسومات:\nعلى الأنظمة متعددة وحدات معالجة الرسومات، اختر وحدة معالجة الرسومات التي سيستخدمها المحاكي من قائمة منسدلة،\nأو اختر "Auto Select" لتحديدها تلقائيًا. + جهاز الرسوميات:\nفي الأنظمة التي تحتوي على أكثر من معالج رسومي، اختر وحدة المعالجة الرسومية GPU التي سيستخدمها المحاكي من القائمة المنسدلة،\nأو اختر ""تحديد تلقائي"" ليتم اختيارها تلقائيًا. Width/Height:\nSets the size of the emulator window at launch, which can be resized during gameplay.\nThis is different from the in-game resolution. - العرض / الارتفاع:\nيضبط حجم نافذة المحاكي عند التشغيل، والذي يمكن تغيير حجمه أثناء اللعب.\nهذا يختلف عن دقة اللعبة نفسها. + العرض/الارتفاع:\nتحدد حجم نافذة المحاكي عند التشغيل، ويمكن تغيير حجمها أثناء اللعب.\nيختلف هذا عن دقة اللعبة داخل اللعبة. Vblank Divider:\nThe frame rate at which the emulator refreshes at is multiplied by this number. Changing this may have adverse effects, such as increasing the game speed, or breaking critical game functionality that does not expect this to change! @@ -1653,19 +1845,19 @@ Enable Shaders Dumping:\nFor the sake of technical debugging, saves the games shaders to a folder as they render. - تمكين تفريغ الـ Shaders:\nلأغراض تصحيح الأخطاء التقنية، يحفظ الـ Shaders الخاصة باللعبة في مجلد أثناء التشغيل. + تمكين تفريغ الشيدرات:\nلأغراض تصحيح الأخطاء التقنية، يقوم بحفظ شيدرات اللعبة في مجلد أثناء عرضها. Enable Null GPU:\nFor the sake of technical debugging, disables game rendering as if there were no graphics card. - تمكين GPU الافتراضية:\nلأغراض تصحيح الأخطاء التقنية، يقوم بتعطيل عرض اللعبة كما لو لم يكن هناك بطاقة رسومات. + تمكين GPU فارغ:\nلأغراض تصحيح الأخطاء التقنية، يتم تعطيل عرض اللعبة كما لو لم يكن هناك كرت شاشة. Enable HDR:\nEnables HDR in games that support it.\nYour monitor must have support for the BT2020 PQ color space and the RGB10A2 swapchain format. - Enable HDR:\nEnables HDR in games that support it.\nYour monitor must have support for the BT2020 PQ color space and the RGB10A2 swapchain format. + تشغيل HDR:\n يقوم بتشغيل HDR في الألعاب المدعومة.\nيجب أن تدعم شاشتك أطياف ألوان BT2020 PQ و صيغة تنسيق المبادلة RGB10A2. Game Folders:\nThe list of folders to check for installed games. - مجلدات اللعبة:\nقائمة بالمجلدات للتحقق من الألعاب المثبتة. + مجلدات اللعبة:\nقائمة المجلدات التي يتم فحصها للبحث عن الألعاب المثبتة. Add:\nAdd a folder to the list. @@ -1677,7 +1869,7 @@ Enable Debug Dumping:\nSaves the import and export symbols and file header information of the currently running PS4 program to a directory. - تمكين تفريغ التصحيح:\nيحفظ رموز الاستيراد والتصدير ومعلومات رأس الملف للبرنامج الحالي لجهاز PS4 إلى دليل. + تمكين تفريغ التصحيح:\nيقوم بحفظ الرموز المستوردة والمصدرة، بالإضافة إلى معلومات رأس الملف للبرنامج الجاري تشغيله على PS4 في مجلد. Enable Vulkan Validation Layers:\nEnables a system that validates the state of the Vulkan renderer and logs information about its internal state.\nThis will reduce performance and likely change the behavior of emulation. @@ -1693,51 +1885,51 @@ Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). - Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + تجميع برامج التظليل:\n يجب أن تقوم بتشغيل هذا لتعديل برامج التظليل باستخدام قائمة تصحيح الأخطاء (Ctrl + F10). Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. - Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + تشخيص الأعطال:\nيقوم بإنشاء ملف بصيغة .yaml يحتوي على معلومات عن حالة Vulkan في وقت حدوث العطل.\nمفيد لتصحيح أخطاء 'فصل الجهاز'. إذا قمت بتشغيل هذا من الأفضل أن تقوم بتشغيل "استضافة علامات تصحيح الأخطاء" و "ضيف علامات تصحيح الأخطاء".\nلا يعمل على وحدة معالجة رسوم إنتل.\nتحتاج لتشغيل التحقق من طبقات Vulkan و مجموعة تطوير البرامج الخاصة بـVulkan من أجل أن يعمل هذا. Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. - Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + نسخ مخازن الذاكرة الخاصة بالـ GPU:\nيتجاوز مشكلة التزامن المتعلقة بتقديمات GPU.\n قد يساعد أو لا يساعد في حل أعطال PM4 من النوع 0. Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. - Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + علامات تصحيح الأخطاء للمضيف:\nقوم بإدراج معلومات في المحاكي مثل علامات للأوامر AMDGPU المرتبطة بأوامر فولكن، إضافةً إلى تخصيص أسماء لتصحيح الأخطاء للموارد.\nمن الأفضل تفعيل تشخيص الأعطال عند تفعيل هذه الخاصية.\nمفيد لبرامج مثل أداة تصحيح الأخطاء الرسومية. Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. - Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + علامات تصحيح الضيف:\nيُدخل أي علامات تصحيح أضافتها اللعبة بنفسها إلى ذاكرة أوامر الرسوميات.\nإذا تم التفعيل الأفضل تمكين "تشخيص الأعطال".\nمفيد لبرامج مثل دوك. Save Data Path:\nThe folder where game save data will be saved. - Save Data Path:\nThe folder where game save data will be saved. + مسار حفظ البيانات:\nالمجلد الذي سيتم فيه حفظ بيانات تخزين اللعبة. Browse:\nBrowse for a folder to set as the save data path. - Browse:\nBrowse for a folder to set as the save data path. + تصفح:\nاختر مجلدًا لتحديده كمكان لحفظ بيانات التخزين. Release - Release + إصدار Nightly - Nightly + إصدار ليلي Set the volume of the background music. - Set the volume of the background music. + ضبط صوت الموسيقى في الخلفية. Enable Motion Controls - Enable Motion Controls + تفعيل التحكم بالحركة Save Data Path - Save Data Path + مسار بيانات الحفظ Browse @@ -1745,15 +1937,15 @@ async - async + غير متزامن sync - sync + متزامن Auto Select - Auto Select + تلقائي Directory to install games @@ -1761,54 +1953,130 @@ Directory to save data - Directory to save data + مسار الحفظ لبيانات الألعاب Video - Video + الفيديو Display Mode - Display Mode + طريقة العرض Windowed - Windowed + نافذة Fullscreen - Fullscreen + شاشة كاملة Fullscreen (Borderless) - Fullscreen (Borderless) + شاشة كاملة (دون حدود) Window Size - Window Size + حجم النافذة W: - W: + العرض: H: - H: + الارتفاع: Separate Log Files - Separate Log Files + ملفات السجل المنفصل Separate Log Files:\nWrites a separate logfile for each game. - Separate Log Files:\nWrites a separate logfile for each game. + ملفات السجل المنفصلة:\nيتم كتابة سجل منفصل لكل لعبه. + + + Trophy Notification Position + موقع إشعار الكأس + + + Left + يسار + + + Right + يمين + + + Top + في الأعلى + + + Bottom + الأسفل + + + Notification Duration + مدة الإشعار + + + Portable User Folder + مجلد المستخدم المتنقل + + + Create Portable User Folder from Common User Folder + إنشاء مجلد مستخدم المتنقل من مجلد المستخدم الشائع + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + مجلد المستخدم القابل للنقل:\nتخزين إعدادات وبيانات المحاكي التي ستُطبق فقط على هذا الإصدار في المجلد الحالي. بعد إنشاء مجلد المستخدم القابل للنقل، يجب إعادة تشغيل التطبيق للبدء في استخدامه. + + + Cannot create portable user folder + لا يمكن إنشاء مجلد المستخدم المتنقل + + + %1 already exists + %1 موجود مسبقاً + + + Portable user folder created + تم إنشاء مجلد مستخدم محمول + + + %1 successfully created. + تم إنشاء %1 بنجاح. + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + افتح مجلد الصور/الأصوات الخاصة بالجوائز المخصصة:\nيمكنك إضافة صور مخصصة للجوائز وصوت مرفق.\nأضف الملفات إلى مجلد custom_trophy بالأسماء التالية:\ntrophy.wav أو trophy.mp3، bronze.png، gold.png، platinum.png، silver.png\nملاحظة: الصوت سيعمل فقط في الإصدارات التي تستخدم QT. TrophyViewer Trophy Viewer - عارض الجوائز + عارض التروفي + + + Select Game: + اختر الُعْبَه: + + + Progress + مقدار التقدُّم + + + Show Earned Trophies + عرض الكؤوس المكتسبة + + + Show Not Earned Trophies + عرض الكؤوس غير المكتسبة + + + Show Hidden Trophies + عرض الكؤوس المخفية diff --git a/src/qt_gui/translations/da_DK.ts b/src/qt_gui/translations/da_DK.ts index e6af07e74..131a989e1 100644 --- a/src/qt_gui/translations/da_DK.ts +++ b/src/qt_gui/translations/da_DK.ts @@ -541,6 +541,77 @@ Override Color Override Color + + Unable to Save + Unable to Save + + + Cannot bind axis values more than once + Cannot bind axis values more than once + + + Save + Save + + + Apply + Apply + + + Restore Defaults + Restore Defaults + + + Cancel + Cancel + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + Edit Keyboard + Mouse and Controller input bindings + + + Use Per-Game configs + Use Per-Game configs + + + Error + Error + + + Could not open the file for reading + Could not open the file for reading + + + Could not open the file for writing + Could not open the file for writing + + + Save Changes + Save Changes + + + Do you want to save changes? + Do you want to save changes? + + + Help + Help + + + Do you want to reset your custom default config to the original default config? + Do you want to reset your custom default config to the original default config? + + + Do you want to reset this config to your custom default config? + Do you want to reset this config to your custom default config? + + + Reset to Default + Reset to Default + ElfViewer @@ -775,6 +846,10 @@ Delete DLC Delete DLC + + Delete Trophy + Delete Trophy + Compatibility... Compatibility... @@ -807,10 +882,6 @@ Error creating shortcut! Error creating shortcut! - - Install PKG - Install PKG - Game Game @@ -851,6 +922,10 @@ This game has no update folder to open! This game has no update folder to open! + + No log file found for this game! + No log file found for this game! + Failed to convert icon. Failed to convert icon. @@ -859,32 +934,255 @@ This game has no save data to delete! This game has no save data to delete! + + This game has no saved trophies to delete! + This game has no saved trophies to delete! + Save Data Save Data + + Trophy + Trophy + SFO Viewer for SFO Viewer for - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - shadPS4 - Choose directory + Quickstart + Quickstart - Select which directory you want to install to. - Select which directory you want to install to. + FAQ + FAQ - Install All Queued to Selected Folder - Install All Queued to Selected Folder + Syntax + Syntax - Delete PKG File on Install - Delete PKG File on Install + Special Bindings + Special Bindings + + + Keybindings + Keybindings + + + + KBMSettings + + Configure Controls + Configure Controls + + + D-Pad + D-Pad + + + Up + Up + + + unmapped + unmapped + + + Left + Left + + + Right + Right + + + Down + Down + + + Left Analog Halfmode + Left Analog Halfmode + + + hold to move left stick at half-speed + hold to move left stick at half-speed + + + Left Stick + Left Stick + + + Config Selection + Config Selection + + + Common Config + Common Config + + + Use per-game configs + Use per-game configs + + + L1 + L1 + + + L2 + L2 + + + Text Editor + Text Editor + + + Help + Help + + + R1 + R1 + + + R2 + R2 + + + L3 + L3 + + + Touchpad Click + Touchpad Click + + + Mouse to Joystick + Mouse to Joystick + + + *press F7 ingame to activate + *press F7 ingame to activate + + + R3 + R3 + + + Options + Options + + + Mouse Movement Parameters + Mouse Movement Parameters + + + note: click Help Button/Special Keybindings for more information + note: click Help Button/Special Keybindings for more information + + + Face Buttons + Face Buttons + + + Triangle + Triangle + + + Square + Square + + + Circle + Circle + + + Cross + Cross + + + Right Analog Halfmode + Right Analog Halfmode + + + hold to move right stick at half-speed + hold to move right stick at half-speed + + + Right Stick + Right Stick + + + Speed Offset (def 0.125): + Speed Offset (def 0.125): + + + Copy from Common Config + Copy from Common Config + + + Deadzone Offset (def 0.50): + Deadzone Offset (def 0.50): + + + Speed Multiplier (def 1.0): + Speed Multiplier (def 1.0): + + + Common Config Selected + Common Config Selected + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + + + Copy values from Common Config + Copy values from Common Config + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + Do you want to overwrite existing mappings with the mappings from the Common Config? + + + Unable to Save + Unable to Save + + + Cannot bind any unique input more than once + Cannot bind any unique input more than once + + + Press a key + Press a key + + + Cannot set mapping + Cannot set mapping + + + Mousewheel cannot be mapped to stick outputs + Mousewheel cannot be mapped to stick outputs + + + Save + Save + + + Apply + Apply + + + Restore Defaults + Restore Defaults + + + Cancel + Cancel @@ -893,10 +1191,6 @@ Open/Add Elf Folder Open/Add Elf Folder - - Install Packages (PKG) - Install Packages (PKG) - Boot Game Boot Game @@ -913,10 +1207,6 @@ Configure... Configure... - - Install application from a .pkg file - Install application from a .pkg file - Recent Games Recent Games @@ -986,8 +1276,12 @@ Dump Game List - PKG Viewer - PKG Viewer + Trophy Viewer + Trophy Viewer + + + No games found. Please add your games to your library first. + No games found. Please add your games to your library first. Search... @@ -1097,70 +1391,6 @@ Only one file can be selected! Kun én fil kan vælges! - - PKG Extraction - PKG-udtrækning - - - Patch detected! - Opdatering detekteret! - - - PKG and Game versions match: - PKG og spilversioner matcher: - - - Would you like to overwrite? - Vil du overskrive? - - - PKG Version %1 is older than installed version: - PKG Version %1 er ældre end den installerede version: - - - Game is installed: - Spillet er installeret: - - - Would you like to install Patch: - Vil du installere opdateringen: - - - DLC Installation - DLC Installation - - - Would you like to install DLC: %1? - Vil du installere DLC: %1? - - - DLC already installed: - DLC allerede installeret: - - - Game already installed - Spillet er allerede installeret - - - PKG ERROR - PKG FEJL - - - Extracting PKG %1/%2 - Udvinding af PKG %1/%2 - - - Extraction Finished - Udvinding afsluttet - - - Game successfully installed at %1 - Spillet blev installeret succesfuldt på %1 - - - File doesn't appear to be a valid PKG file - Filen ser ikke ud til at være en gyldig PKG-fil - Run Game Run Game @@ -1169,14 +1399,6 @@ Eboot.bin file not found Eboot.bin file not found - - PKG File (*.PKG *.pkg) - PKG File (*.PKG *.pkg) - - - PKG is a patch or DLC, please install the game first! - PKG is a patch or DLC, please install the game first! - Game is already running! Game is already running! @@ -1185,72 +1407,45 @@ shadPS4 shadPS4 - - - PKGViewer - Open Folder - Open Folder + Play + Play - PKG ERROR - PKG FEJL + Pause + Pause - Name - Navn + Stop + Stop - Serial - Seriel + Restart + Restart - Installed - Installed + Full Screen + Full Screen - Size - Størrelse + Controllers + Controllers - Category - Category + Keyboard + Keyboard - Type - Type + Refresh List + Refresh List - App Ver - App Ver + Resume + Resume - FW - FW - - - Region - Region - - - Flags - Flags - - - Path - Sti - - - File - File - - - Unknown - Ukendt - - - Package - Package + Show Labels Under Icons + Show Labels Under Icons @@ -1279,10 +1474,6 @@ Emulator Emulator - - Enable Separate Update Folder - Enable Separate Update Folder - Default tab when opening settings Standardfaneblad ved åbning af indstillinger @@ -1311,6 +1502,10 @@ Trophy Trophy + + Open the custom trophy images/sounds folder + Open the custom trophy images/sounds folder + Logger Logger @@ -1476,8 +1671,8 @@ Title Music - Disable Trophy Pop-ups - Disable Trophy Pop-ups + Disable Trophy Notification + Disable Trophy Notification Background Image @@ -1543,10 +1738,6 @@ Emulator Language:\nSets the language of the emulator's user interface. Emulatorsprog:\nIndstiller sproget i emulatorens brugergrænseflade. - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management. - Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. Vis startskærm:\nViser en startskærm (speciel grafik) under opstarten. @@ -1803,6 +1994,62 @@ Separate Log Files:\nWrites a separate logfile for each game. Separate Log Files:\nWrites a separate logfile for each game. + + Trophy Notification Position + Trophy Notification Position + + + Left + Left + + + Right + Right + + + Top + Top + + + Bottom + Bottom + + + Notification Duration + Notification Duration + + + Portable User Folder + Portable User Folder + + + Create Portable User Folder from Common User Folder + Create Portable User Folder from Common User Folder + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + + + Cannot create portable user folder + Cannot create portable user folder + + + %1 already exists + %1 already exists + + + Portable user folder created + Portable user folder created + + + %1 successfully created. + %1 successfully created. + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + TrophyViewer @@ -1810,5 +2057,25 @@ Trophy Viewer Trophy Viewer + + Select Game: + Select Game: + + + Progress + Progress + + + Show Earned Trophies + Show Earned Trophies + + + Show Not Earned Trophies + Show Not Earned Trophies + + + Show Hidden Trophies + Show Hidden Trophies + diff --git a/src/qt_gui/translations/de_DE.ts b/src/qt_gui/translations/de_DE.ts index 5d57b6361..c7a18dd99 100644 --- a/src/qt_gui/translations/de_DE.ts +++ b/src/qt_gui/translations/de_DE.ts @@ -38,7 +38,7 @@ Version: - Version: + Version: Size: @@ -50,7 +50,7 @@ Repository: - Repository: + Quellen: Download Cheats @@ -86,11 +86,11 @@ Cheats - Cheats + Cheats Patches - Patches + Patches Error @@ -234,7 +234,7 @@ Name: - Name: + Name: Can't apply cheats before the game is started @@ -407,139 +407,210 @@ ControlSettings Configure Controls - Configure Controls + Steuerung einrichten D-Pad - D-Pad + Steuerkreuz Up - Up + Oben Left - Left + Links Right - Right + Rechts Down - Down + Runter Left Stick Deadzone (def:2 max:127) - Left Stick Deadzone (def:2 max:127) + Linker Stick tote Zone (def:2 max:127) Left Deadzone - Left Deadzone + Linke Deadzone Left Stick - Left Stick + Linker Analogstick Config Selection - Config Selection + Konfigurationsauswahl Common Config - Common Config + Standard Konfiguration Use per-game configs - Use per-game configs + Benutze Per-Game Einstellungen L1 / LB - L1 / LB + L1 / LB L2 / LT - L2 / LT + L2 / LT Back - Back + Zurück R1 / RB - R1 / RB + R1 / RB R2 / RT - R2 / RT + R2 / RT L3 - L3 + L3 Options / Start - Options / Start + Options / Start R3 - R3 + R3 Face Buttons - Face Buttons + Aktionstasten Triangle / Y - Triangle / Y + Dreieck / Y Square / X - Square / X + Quadrat / X Circle / B - Circle / B + Kreis / B Cross / A - Cross / A + Kreuz / A Right Stick Deadzone (def:2, max:127) - Right Stick Deadzone (def:2, max:127) + Rechter Stick tote Zone (def:2, max:127) Right Deadzone - Right Deadzone + Rechte tote Zone Right Stick - Right Stick + Rechter Analogstick Color Adjustment - Color Adjustment + Farbanpassung R: - R: + R: G: - G: + G: B: - B: + B: Override Lightbar Color - Override Lightbar Color + Farbe der Leuchtleiste überschreiben Override Color - Override Color + Farbe überschreiben + + + Unable to Save + Speichern nicht möglich + + + Cannot bind axis values more than once + Achsenwerte können nicht mehr als einmal gebunden werden + + + Save + Speichern + + + Apply + Übernehmen + + + Restore Defaults + Werkseinstellungen wiederherstellen + + + Cancel + Abbrechen + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + Tastatur + Maus und Controller Eingabezuordnungen bearbeiten + + + Use Per-Game configs + Benutze Per-Game Einstellungen + + + Error + Fehler + + + Could not open the file for reading + Datei konnte nicht zum Lesen geöffnet werden + + + Could not open the file for writing + Datei konnte nicht zum Schreiben geöffnet werden + + + Save Changes + Änderungen Speichern + + + Do you want to save changes? + Sollen die Änderungen gespeichert werden? + + + Help + Hilfe + + + Do you want to reset your custom default config to the original default config? + Möchten Sie Ihre eigene Standardkonfiguration auf die ursprüngliche Standardkonfiguration zurücksetzen? + + + Do you want to reset this config to your custom default config? + Möchten Sie diese Konfiguration auf Ihre eigene Standardkonfiguration zurücksetzen? + + + Reset to Default + Auf Standard zurücksetzen @@ -584,7 +655,7 @@ Directory to install DLC - Directory to install DLC + Verzeichnis zum Installieren von DLC @@ -595,7 +666,7 @@ Name - Name + Name Serial @@ -607,11 +678,11 @@ Region - Region + Region Firmware - Firmware + Firmware Size @@ -619,7 +690,7 @@ Version - Version + Version Path @@ -635,15 +706,15 @@ h - h + h m - m + m s - s + s Compatibility is untested @@ -682,23 +753,23 @@ GameListUtils B - B + B KB - KB + KB MB - MB + MB GB - GB + GB TB - TB + TB @@ -709,7 +780,7 @@ Cheats / Patches - Cheats / Patches + Cheats / Patches SFO Viewer @@ -775,6 +846,10 @@ Delete DLC Lösche DLC + + Delete Trophy + Trophäe löschen + Compatibility... Kompatibilität... @@ -807,10 +882,6 @@ Error creating shortcut! Fehler beim Erstellen der Verknüpfung! - - Install PKG - PKG installieren - Game Spiel @@ -829,7 +900,7 @@ DLC - DLC + DLC Delete %1 @@ -849,42 +920,269 @@ This game has no update folder to open! - This game has no update folder to open! + Dieses Spiel hat keinen Update-Ordner zum öffnen! + + + No log file found for this game! + Keine Protokolldatei für dieses Spiel gefunden! Failed to convert icon. - Failed to convert icon. + Fehler beim Konvertieren des Symbols. This game has no save data to delete! - This game has no save data to delete! + Dieses Spiel hat keine Speicherdaten zum Löschen! + + + This game has no saved trophies to delete! + Dieses Spiel hat keine gespeicherten Trophäen zum Löschen! Save Data - Save Data + Gespeicherte Daten + + + Trophy + Trophäe SFO Viewer for - SFO Viewer for + SFO-Betrachter für - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - shadPS4 - Wähle Ordner + Quickstart + Schnellstart - Select which directory you want to install to. - Wählen Sie das Verzeichnis aus, in das Sie installieren möchten. + FAQ + Häufig gestellte Fragen - Install All Queued to Selected Folder - Install All Queued to Selected Folder + Syntax + Syntax - Delete PKG File on Install - Delete PKG File on Install + Special Bindings + Spezielle Zuordnungen + + + Keybindings + Tastenbelegung + + + + KBMSettings + + Configure Controls + Steuerung konfigurieren + + + D-Pad + Steuerkreuz + + + Up + Oben + + + unmapped + nicht zugeordnet + + + Left + Links + + + Right + Rechts + + + Down + Runter + + + Left Analog Halfmode + Linker Analog-Halbmodus + + + hold to move left stick at half-speed + Halten um den linken Analogstick mit Halbgeschwindigkeit zu bewegen + + + Left Stick + Linker Analogstick + + + Config Selection + Konfigurationsauswahl + + + Common Config + Allgemeine Konfiguration + + + Use per-game configs + Benutze Per-Game Einstellungen + + + L1 + L1 + + + L2 + L2 + + + Text Editor + Textbearbeiter + + + Help + Hilfe + + + R1 + R1 + + + R2 + R2 + + + L3 + L3 + + + Touchpad Click + Touchpad-Klick + + + Mouse to Joystick + Maus zu Joystick + + + *press F7 ingame to activate + *Zum Aktivieren F7 ingame drücken + + + R3 + R3 + + + Options + Options + + + Mouse Movement Parameters + Mausbewegungsparameter + + + note: click Help Button/Special Keybindings for more information + Hinweis: Klicken Sie auf Hilfe-Button/Special Tastaturbelegungen für weitere Informationen + + + Face Buttons + Aktionstasten + + + Triangle + Dreieck + + + Square + Quadrat + + + Circle + Kreis + + + Cross + Kreuz + + + Right Analog Halfmode + Rechter Analog-Halbmodus + + + hold to move right stick at half-speed + Halten um den rechten Analogstick mit Halbgeschwindigkeit zu bewegen + + + Right Stick + Rechter Analogstick + + + Speed Offset (def 0.125): + Geschwindigkeitsversatz (Def 0.125): + + + Copy from Common Config + Von allgemeiner Konfiguration kopieren + + + Deadzone Offset (def 0.50): + Tote Zone Versatz (Def 0.50): + + + Speed Multiplier (def 1.0): + Geschwindigkeit Multiplikator (def 1.0): + + + Common Config Selected + Allgemeine Konfiguration ausgewählt + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + Diese Schaltfläche kopiert Zuordnungen aus der allgemeinen Konfiguration in das aktuell ausgewählte Profil, und kann nicht verwendet werden, wenn das aktuell ausgewählte Profil die allgemeine Konfiguration ist. + + + Copy values from Common Config + Werte von allgemeiner Konfiguration kopieren + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + Möchten Sie die vorhandenen Zuordnungen mit den Zuordnungen der allgemeinen Konfigurationen überschreiben? + + + Unable to Save + Speichern nicht möglich + + + Cannot bind any unique input more than once + Kann keine eindeutige Eingabe mehr als einmal zuordnen + + + Press a key + Drücken Sie eine Taste + + + Cannot set mapping + Kann Zuordnung nicht festlegen + + + Mousewheel cannot be mapped to stick outputs + Mausrad kann nicht zu Analogstick Ausgabe zugeordnet werden + + + Save + Speichern + + + Apply + Übernehmen + + + Restore Defaults + Werkseinstellungen wiederherstellen + + + Cancel + Abbrechen @@ -893,10 +1191,6 @@ Open/Add Elf Folder Elf-Ordner öffnen/hinzufügen - - Install Packages (PKG) - Pakete installieren (PKG) - Boot Game Spiel starten @@ -913,10 +1207,6 @@ Configure... Konfigurieren... - - Install application from a .pkg file - Installiere Anwendung aus .pkg-Datei - Recent Games Zuletzt gespielt @@ -986,8 +1276,12 @@ Spielliste ausgeben - PKG Viewer - PKG-Anschauer + Trophy Viewer + Trophäenansicht + + + No games found. Please add your games to your library first. + Keine Spiele gefunden. Bitte fügen Sie zuerst Ihre Spiele zu Ihrer Bibliothek hinzu. Search... @@ -1097,160 +1391,61 @@ Only one file can be selected! Es kann nur eine Datei ausgewählt werden! - - PKG Extraction - PKG-Extraktion - - - Patch detected! - Patch erkannt! - - - PKG and Game versions match: - PKG- und Spielversionen stimmen überein: - - - Would you like to overwrite? - Willst du überschreiben? - - - PKG Version %1 is older than installed version: - PKG-Version %1 ist älter als die installierte Version: - - - Game is installed: - Spiel ist installiert: - - - Would you like to install Patch: - Willst du den Patch installieren: - - - DLC Installation - DLC-Installation - - - Would you like to install DLC: %1? - Willst du das DLC installieren: %1? - - - DLC already installed: - DLC bereits installiert: - - - Game already installed - Spiel bereits installiert - - - PKG ERROR - PKG-FEHLER - - - Extracting PKG %1/%2 - Extrahiere PKG %1/%2 - - - Extraction Finished - Extraktion abgeschlossen - - - Game successfully installed at %1 - Spiel erfolgreich installiert auf %1 - - - File doesn't appear to be a valid PKG file - Die Datei scheint keine gültige PKG-Datei zu sein - Run Game - Run Game + Spiel ausführen Eboot.bin file not found - Eboot.bin file not found - - - PKG File (*.PKG *.pkg) - PKG File (*.PKG *.pkg) - - - PKG is a patch or DLC, please install the game first! - PKG is a patch or DLC, please install the game first! + Eboot.bin Datei nicht gefunden Game is already running! - Game is already running! + Spiel läuft bereits! shadPS4 - shadPS4 - - - - PKGViewer - - Open Folder - Ordner öffnen + shadPS4 - PKG ERROR - PKG-FEHLER + Play + Spielen - Name - Name + Pause + Pause - Serial - Seriennummer + Stop + Stopp - Installed - Installed + Restart + Neustarten - Size - Größe + Full Screen + Vollbild - Category - Category + Controllers + Controller - Type - Type + Keyboard + Tastatur - App Ver - App Ver + Refresh List + Liste aktualisieren - FW - FW + Resume + Fortsetzen - Region - Region - - - Flags - Flags - - - Path - Pfad - - - File - Datei - - - Unknown - Unbekannt - - - Package - Package + Show Labels Under Icons + Etiketten unter Symbolen anzeigen @@ -1265,7 +1460,7 @@ System - System + System Console Language @@ -1277,11 +1472,7 @@ Emulator - Emulator - - - Enable Separate Update Folder - Separaten Update-Ordner aktivieren + Emulator Default tab when opening settings @@ -1311,9 +1502,13 @@ Trophy Trophäe + + Open the custom trophy images/sounds folder + Öffne den benutzerdefinierten Ordner für Trophäenbilder/Sounds + Logger - Logger + Protokollführer Log Type @@ -1333,7 +1528,7 @@ Cursor - Cursor + Mauszeiger Hide Cursor @@ -1345,11 +1540,11 @@ s - s + s Controller - Controller + Kontroller Back Button Behavior @@ -1389,7 +1584,7 @@ Enable HDR - Enable HDR + HDR aktivieren Paths @@ -1409,7 +1604,7 @@ Debug - Debug + Debug Enable Debug Dumping @@ -1476,20 +1671,20 @@ Titelmusik - Disable Trophy Pop-ups - Deaktiviere Trophäen Pop-ups + Disable Trophy Notification + Trophäen-Benachrichtigung deaktivieren Background Image - Background Image + Hintergrundbild Show Background Image - Show Background Image + Hintergrundbild anzeigen Opacity - Opacity + Transparenz Play title music @@ -1543,10 +1738,6 @@ Emulator Language:\nSets the language of the emulator's user interface. Emulatorsprache:\nLegt die Sprache der Emulator-Benutzeroberfläche fest. - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Separaten Update-Ordner aktivieren:\nErmöglicht die Installation von Spielaktualiserungen in einem separaten Ordner zur einfachen Verwaltung. - Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. Startbildschirm anzeigen:\nZeigt beim Start einen speziellen Bildschirm (Splash) des Spiels an. @@ -1577,7 +1768,7 @@ Background Image:\nControl the opacity of the game background image. - Background Image:\nControl the opacity of the game background image. + Hintergrundbild:\nSteuere die Deckkraft des Spiel-Hintergrundbilds. Play Title Music:\nIf a game supports it, enable playing special music when selecting the game in the GUI. @@ -1661,7 +1852,7 @@ Enable HDR:\nEnables HDR in games that support it.\nYour monitor must have support for the BT2020 PQ color space and the RGB10A2 swapchain format. - Enable HDR:\nEnables HDR in games that support it.\nYour monitor must have support for the BT2020 PQ color space and the RGB10A2 swapchain format. + HDR:\nAktiviert HDR in Spielen, die es unterstützen.\nIhr Monitor muss Unterstützung für den BT2020 PQ Farbraum und das RGB10A2 Swapchain Format haben. Game Folders:\nThe list of folders to check for installed games. @@ -1713,23 +1904,23 @@ Save Data Path:\nThe folder where game save data will be saved. - Save Data Path:\nThe folder where game save data will be saved. + Datenpfad speichern:\nDer Ordner, in dem Spieldaten gespeichert werden. Browse:\nBrowse for a folder to set as the save data path. - Browse:\nBrowse for a folder to set as the save data path. + Durchsuchen:\nDurchsuchen eines Ordners, um den Speicherdatenpfad festzulegen. Release - Release + Veröffentlichung Nightly - Nightly + Nightly Set the volume of the background music. - Set the volume of the background music. + Legen Sie die Lautstärke der Hintergrundmusik fest. Enable Motion Controls @@ -1745,15 +1936,15 @@ async - async + asynchron sync - sync + syncron Auto Select - Auto Select + Auto-Wählen Directory to install games @@ -1761,47 +1952,107 @@ Directory to save data - Directory to save data + Verzeichnis um Daten zu speichern Video - Video + Video Display Mode - Display Mode + Anzeigemodus Windowed - Windowed + Fenster Fullscreen - Fullscreen + Vollbild Fullscreen (Borderless) - Fullscreen (Borderless) + Vollbild (randlos) Window Size - Window Size + Fenstergröße W: - W: + W: H: - H: + H: Separate Log Files - Separate Log Files + Separate Protokolldateien Separate Log Files:\nWrites a separate logfile for each game. - Separate Log Files:\nWrites a separate logfile for each game. + Separate Protokolldateien:\nSchreibt für jedes Spiel eine separate Logdatei. + + + Trophy Notification Position + Trophäen-Benachrichtigungsposition + + + Left + Links + + + Right + Rechts + + + Top + Zuoberst + + + Bottom + Zuunterst + + + Notification Duration + Benachrichtigungsdauer + + + Portable User Folder + Portable Benutzerordner + + + Create Portable User Folder from Common User Folder + Erstellen eines portablen Benutzerordners aus dem allgemeinen Benutzer Ordner + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + Portablen Benutzerordner:\nspeichert ShadPS4 Einstellungen und Daten, die nur auf den ShadPS4 Build im aktuellen Ordner angewendet werden. Starten Sie die App nach dem Erstellen des tragbaren Benutzerordners neu, um sie zu verwenden. + + + Cannot create portable user folder + Kann keinen portablen Benutzerordner erstellen + + + %1 already exists + %1 existiert bereits + + + Portable user folder created + Portablen Benutzerordner erstellt + + + %1 successfully created. + %1 erfolgreich erstellt. + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + Öffnen Sie den Ordner für benutzerdefinierte Trophäenbilder/-sounds:\n +Sie können benutzerdefinierte Bilder zu den Trophäen hinzufügen und einen Ton hinzufügen.\n +Fügen Sie die Dateien dem Ordner custom_trophy mit folgenden Namen hinzu:\n +trophy.wav ODER trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\n +Hinweis: Der Sound funktioniert nur in Qt-Versionen. @@ -1810,5 +2061,25 @@ Trophy Viewer Trophäenansicht + + Select Game: + Spiel auswählen: + + + Progress + Fortschritt + + + Show Earned Trophies + Verdiente Trophäen anzeigen + + + Show Not Earned Trophies + Nicht verdiente Trophäen anzeigen + + + Show Hidden Trophies + Verborgene Trophäen anzeigen + diff --git a/src/qt_gui/translations/el_GR.ts b/src/qt_gui/translations/el_GR.ts index 3d2763409..c91e0c731 100644 --- a/src/qt_gui/translations/el_GR.ts +++ b/src/qt_gui/translations/el_GR.ts @@ -541,6 +541,77 @@ Override Color Override Color + + Unable to Save + Unable to Save + + + Cannot bind axis values more than once + Cannot bind axis values more than once + + + Save + Save + + + Apply + Apply + + + Restore Defaults + Restore Defaults + + + Cancel + Cancel + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + Edit Keyboard + Mouse and Controller input bindings + + + Use Per-Game configs + Use Per-Game configs + + + Error + Error + + + Could not open the file for reading + Could not open the file for reading + + + Could not open the file for writing + Could not open the file for writing + + + Save Changes + Save Changes + + + Do you want to save changes? + Do you want to save changes? + + + Help + Help + + + Do you want to reset your custom default config to the original default config? + Do you want to reset your custom default config to the original default config? + + + Do you want to reset this config to your custom default config? + Do you want to reset this config to your custom default config? + + + Reset to Default + Reset to Default + ElfViewer @@ -775,6 +846,10 @@ Delete DLC Delete DLC + + Delete Trophy + Delete Trophy + Compatibility... Compatibility... @@ -807,10 +882,6 @@ Error creating shortcut! Error creating shortcut! - - Install PKG - Install PKG - Game Game @@ -851,6 +922,10 @@ This game has no update folder to open! This game has no update folder to open! + + No log file found for this game! + No log file found for this game! + Failed to convert icon. Failed to convert icon. @@ -859,32 +934,255 @@ This game has no save data to delete! This game has no save data to delete! + + This game has no saved trophies to delete! + This game has no saved trophies to delete! + Save Data Save Data + + Trophy + Trophy + SFO Viewer for SFO Viewer for - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - shadPS4 - Choose directory + Quickstart + Quickstart - Select which directory you want to install to. - Select which directory you want to install to. + FAQ + FAQ - Install All Queued to Selected Folder - Install All Queued to Selected Folder + Syntax + Syntax - Delete PKG File on Install - Delete PKG File on Install + Special Bindings + Special Bindings + + + Keybindings + Keybindings + + + + KBMSettings + + Configure Controls + Configure Controls + + + D-Pad + D-Pad + + + Up + Up + + + unmapped + unmapped + + + Left + Left + + + Right + Right + + + Down + Down + + + Left Analog Halfmode + Left Analog Halfmode + + + hold to move left stick at half-speed + hold to move left stick at half-speed + + + Left Stick + Left Stick + + + Config Selection + Config Selection + + + Common Config + Common Config + + + Use per-game configs + Use per-game configs + + + L1 + L1 + + + L2 + L2 + + + Text Editor + Text Editor + + + Help + Help + + + R1 + R1 + + + R2 + R2 + + + L3 + L3 + + + Touchpad Click + Touchpad Click + + + Mouse to Joystick + Mouse to Joystick + + + *press F7 ingame to activate + *press F7 ingame to activate + + + R3 + R3 + + + Options + Options + + + Mouse Movement Parameters + Mouse Movement Parameters + + + note: click Help Button/Special Keybindings for more information + note: click Help Button/Special Keybindings for more information + + + Face Buttons + Face Buttons + + + Triangle + Triangle + + + Square + Square + + + Circle + Circle + + + Cross + Cross + + + Right Analog Halfmode + Right Analog Halfmode + + + hold to move right stick at half-speed + hold to move right stick at half-speed + + + Right Stick + Right Stick + + + Speed Offset (def 0.125): + Speed Offset (def 0.125): + + + Copy from Common Config + Copy from Common Config + + + Deadzone Offset (def 0.50): + Deadzone Offset (def 0.50): + + + Speed Multiplier (def 1.0): + Speed Multiplier (def 1.0): + + + Common Config Selected + Common Config Selected + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + + + Copy values from Common Config + Copy values from Common Config + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + Do you want to overwrite existing mappings with the mappings from the Common Config? + + + Unable to Save + Unable to Save + + + Cannot bind any unique input more than once + Cannot bind any unique input more than once + + + Press a key + Press a key + + + Cannot set mapping + Cannot set mapping + + + Mousewheel cannot be mapped to stick outputs + Mousewheel cannot be mapped to stick outputs + + + Save + Save + + + Apply + Apply + + + Restore Defaults + Restore Defaults + + + Cancel + Cancel @@ -893,10 +1191,6 @@ Open/Add Elf Folder Open/Add Elf Folder - - Install Packages (PKG) - Install Packages (PKG) - Boot Game Boot Game @@ -913,10 +1207,6 @@ Configure... Configure... - - Install application from a .pkg file - Install application from a .pkg file - Recent Games Recent Games @@ -986,8 +1276,12 @@ Dump Game List - PKG Viewer - PKG Viewer + Trophy Viewer + Trophy Viewer + + + No games found. Please add your games to your library first. + No games found. Please add your games to your library first. Search... @@ -1097,70 +1391,6 @@ Only one file can be selected! Μπορεί να επιλεγεί μόνο ένα αρχείο! - - PKG Extraction - Εξαγωγή PKG - - - Patch detected! - Αναγνώριση ενημέρωσης! - - - PKG and Game versions match: - Οι εκδόσεις PKG και παιχνιδιού ταιριάζουν: - - - Would you like to overwrite? - Θέλετε να αντικαταστήσετε; - - - PKG Version %1 is older than installed version: - Η έκδοση PKG %1 είναι παλαιότερη από την εγκατεστημένη έκδοση: - - - Game is installed: - Το παιχνίδι είναι εγκατεστημένο: - - - Would you like to install Patch: - Θέλετε να εγκαταστήσετε την ενημέρωση: - - - DLC Installation - Εγκατάσταση DLC - - - Would you like to install DLC: %1? - Θέλετε να εγκαταστήσετε το DLC: %1; - - - DLC already installed: - DLC ήδη εγκατεστημένο: - - - Game already installed - Παιχνίδι ήδη εγκατεστημένο - - - PKG ERROR - ΣΦΑΛΜΑ PKG - - - Extracting PKG %1/%2 - Εξαγωγή PKG %1/%2 - - - Extraction Finished - Η εξαγωγή ολοκληρώθηκε - - - Game successfully installed at %1 - Το παιχνίδι εγκαταστάθηκε επιτυχώς στο %1 - - - File doesn't appear to be a valid PKG file - Η αρχείο δεν φαίνεται να είναι έγκυρο αρχείο PKG - Run Game Run Game @@ -1169,14 +1399,6 @@ Eboot.bin file not found Eboot.bin file not found - - PKG File (*.PKG *.pkg) - PKG File (*.PKG *.pkg) - - - PKG is a patch or DLC, please install the game first! - PKG is a patch or DLC, please install the game first! - Game is already running! Game is already running! @@ -1185,72 +1407,45 @@ shadPS4 shadPS4 - - - PKGViewer - Open Folder - Open Folder + Play + Play - PKG ERROR - ΣΦΑΛΜΑ PKG + Pause + Pause - Name - Όνομα + Stop + Stop - Serial - Σειριακός αριθμός + Restart + Restart - Installed - Installed + Full Screen + Full Screen - Size - Μέγεθος + Controllers + Controllers - Category - Category + Keyboard + Keyboard - Type - Type + Refresh List + Refresh List - App Ver - App Ver + Resume + Resume - FW - FW - - - Region - Περιοχή - - - Flags - Flags - - - Path - Διαδρομή - - - File - File - - - Unknown - Άγνωστο - - - Package - Package + Show Labels Under Icons + Show Labels Under Icons @@ -1279,10 +1474,6 @@ Emulator Emulator - - Enable Separate Update Folder - Enable Separate Update Folder - Default tab when opening settings Προεπιλεγμένη καρτέλα κατά την ανοίγμα των ρυθμίσεων @@ -1311,6 +1502,10 @@ Trophy Trophy + + Open the custom trophy images/sounds folder + Open the custom trophy images/sounds folder + Logger Logger @@ -1476,8 +1671,8 @@ Title Music - Disable Trophy Pop-ups - Disable Trophy Pop-ups + Disable Trophy Notification + Disable Trophy Notification Background Image @@ -1543,10 +1738,6 @@ Emulator Language:\nSets the language of the emulator's user interface. Γλώσσα Εξομοιωτή:\nΡυθμίζει τη γλώσσα του γραφικού περιβάλλοντος του εξομοιωτή. - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. Εμφάνιση Splash Screen:\nΕμφανίζει ειδική γραφική οθόνη κατά την εκκίνηση. @@ -1803,6 +1994,62 @@ Separate Log Files:\nWrites a separate logfile for each game. Separate Log Files:\nWrites a separate logfile for each game. + + Trophy Notification Position + Trophy Notification Position + + + Left + Left + + + Right + Right + + + Top + Top + + + Bottom + Bottom + + + Notification Duration + Notification Duration + + + Portable User Folder + Portable User Folder + + + Create Portable User Folder from Common User Folder + Create Portable User Folder from Common User Folder + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + + + Cannot create portable user folder + Cannot create portable user folder + + + %1 already exists + %1 already exists + + + Portable user folder created + Portable user folder created + + + %1 successfully created. + %1 successfully created. + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + TrophyViewer @@ -1810,5 +2057,25 @@ Trophy Viewer Trophy Viewer + + Select Game: + Select Game: + + + Progress + Progress + + + Show Earned Trophies + Show Earned Trophies + + + Show Not Earned Trophies + Show Not Earned Trophies + + + Show Hidden Trophies + Show Hidden Trophies + diff --git a/src/qt_gui/translations/en_US.ts b/src/qt_gui/translations/en_US.ts index 92fb59a02..780f089e8 100644 --- a/src/qt_gui/translations/en_US.ts +++ b/src/qt_gui/translations/en_US.ts @@ -541,6 +541,77 @@ Override Color + + Unable to Save + + + + Cannot bind axis values more than once + + + + Save + Save + + + Apply + Apply + + + Restore Defaults + Restore Defaults + + + Cancel + Cancel + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + + + + Use Per-Game configs + + + + Error + Error + + + Could not open the file for reading + + + + Could not open the file for writing + + + + Save Changes + + + + Do you want to save changes? + + + + Help + Help + + + Do you want to reset your custom default config to the original default config? + + + + Do you want to reset this config to your custom default config? + + + + Reset to Default + + ElfViewer @@ -811,10 +882,6 @@ Error creating shortcut! Error creating shortcut! - - Install PKG - Install PKG - Game Game @@ -885,23 +952,238 @@ - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - shadPS4 - Choose directory - - - Select which directory you want to install to. - Select which directory you want to install to. - - - Install All Queued to Selected Folder + Quickstart - Delete PKG File on Install + FAQ + + Syntax + + + + Special Bindings + + + + Keybindings + + + + + KBMSettings + + Configure Controls + + + + D-Pad + + + + Up + + + + unmapped + + + + Left + Left + + + Right + Right + + + Down + + + + Left Analog Halfmode + + + + hold to move left stick at half-speed + + + + Left Stick + + + + Config Selection + + + + Common Config + + + + Use per-game configs + + + + L1 + + + + L2 + + + + Text Editor + + + + Help + Help + + + R1 + + + + R2 + + + + L3 + + + + Touchpad Click + + + + Mouse to Joystick + + + + *press F7 ingame to activate + + + + R3 + + + + Options + + + + Mouse Movement Parameters + + + + note: click Help Button/Special Keybindings for more information + + + + Face Buttons + + + + Triangle + + + + Square + + + + Circle + + + + Cross + + + + Right Analog Halfmode + + + + hold to move right stick at half-speed + + + + Right Stick + + + + Speed Offset (def 0.125): + + + + Copy from Common Config + + + + Deadzone Offset (def 0.50): + + + + Speed Multiplier (def 1.0): + + + + Common Config Selected + + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + + + + Copy values from Common Config + + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + + + + Unable to Save + + + + Cannot bind any unique input more than once + + + + Press a key + + + + Cannot set mapping + + + + Mousewheel cannot be mapped to stick outputs + + + + Save + Save + + + Apply + Apply + + + Restore Defaults + Restore Defaults + + + Cancel + Cancel + MainWindow @@ -909,10 +1191,6 @@ Open/Add Elf Folder Open/Add Elf Folder - - Install Packages (PKG) - Install Packages (PKG) - Boot Game Boot Game @@ -929,10 +1207,6 @@ Configure... Configure... - - Install application from a .pkg file - Install application from a .pkg file - Recent Games Recent Games @@ -1002,8 +1276,12 @@ Dump Game List - PKG Viewer - PKG Viewer + Trophy Viewer + Trophy Viewer + + + No games found. Please add your games to your library first. + No games found. Please add your games to your library first. Search... @@ -1113,70 +1391,6 @@ Only one file can be selected! Only one file can be selected! - - PKG Extraction - PKG Extraction - - - Patch detected! - Patch detected! - - - PKG and Game versions match: - PKG and Game versions match: - - - Would you like to overwrite? - Would you like to overwrite? - - - PKG Version %1 is older than installed version: - PKG Version %1 is older than installed version: - - - Game is installed: - Game is installed: - - - Would you like to install Patch: - Would you like to install Patch: - - - DLC Installation - DLC Installation - - - Would you like to install DLC: %1? - Would you like to install DLC: %1? - - - DLC already installed: - DLC already installed: - - - Game already installed - Game already installed - - - PKG ERROR - PKG ERROR - - - Extracting PKG %1/%2 - Extracting PKG %1/%2 - - - Extraction Finished - Extraction Finished - - - Game successfully installed at %1 - Game successfully installed at %1 - - - File doesn't appear to be a valid PKG file - File doesn't appear to be a valid PKG file - Run Game @@ -1185,14 +1399,6 @@ Eboot.bin file not found - - PKG File (*.PKG *.pkg) - - - - PKG is a patch or DLC, please install the game first! - - Game is already running! @@ -1201,71 +1407,44 @@ shadPS4 shadPS4 - - - PKGViewer - Open Folder - Open Folder - - - PKG ERROR - PKG ERROR - - - Name - Name - - - Serial - Serial - - - Installed + Play - Size - Size - - - Category + Pause - Type + Stop - App Ver + Restart - FW + Full Screen - Region - Region - - - Flags + Controllers - Path - Path + Keyboard + - File - File + Refresh List + - Unknown - Unknown + Resume + - Package + Show Labels Under Icons @@ -1295,10 +1474,6 @@ Emulator Emulator - - Enable Separate Update Folder - Enable Separate Update Folder - Default tab when opening settings Default tab when opening settings @@ -1563,10 +1738,6 @@ Emulator Language:\nSets the language of the emulator's user interface. Emulator Language:\nSets the language of the emulator's user interface. - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. @@ -1631,10 +1802,6 @@ Update Compatibility Database:\nImmediately update the compatibility database. Update Compatibility Database:\nImmediately update the compatibility database. - - Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\nthophy.mp3, bronze.png, gold.png, platinum.png, silver.png - Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\nthophy.mp3, bronze.png, gold.png, platinum.png, silver.png - Never Never @@ -1839,10 +2006,50 @@ Right Right + + Top + Top + + + Bottom + Bottom + Notification Duration Notification Duration + + Portable User Folder + + + + Create Portable User Folder from Common User Folder + + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + + + + Cannot create portable user folder + + + + %1 already exists + + + + Portable user folder created + + + + %1 successfully created. + + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + + TrophyViewer @@ -1850,6 +2057,10 @@ Trophy Viewer Trophy Viewer + + Select Game: + + Progress diff --git a/src/qt_gui/translations/es_ES.ts b/src/qt_gui/translations/es_ES.ts index 148613422..035aac6a3 100644 --- a/src/qt_gui/translations/es_ES.ts +++ b/src/qt_gui/translations/es_ES.ts @@ -443,15 +443,15 @@ Config Selection - Config Selection + Selección de Configuraciones Common Config - Common Config + Configuración Estándar Use per-game configs - Use per-game configs + Usar configuraciones por juego L1 / LB @@ -535,11 +535,82 @@ Override Lightbar Color - Override Lightbar Color + Reemplazar el Color de la Barra de Luz Override Color - Override Color + Reemplazar Color + + + Unable to Save + No se Pudo Guardar + + + Cannot bind axis values more than once + No se pueden vincular valores del eje más de una vez + + + Save + Guardar + + + Apply + Aplicar + + + Restore Defaults + Restaurar Valores Por Defecto + + + Cancel + Cancelar + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + Editar Asignaciones de Teclado + Ratón y Mando + + + Use Per-Game configs + Usar Configuraciones por Juego + + + Error + Error + + + Could not open the file for reading + No se pudo abrir el archivo para la lectura + + + Could not open the file for writing + No se pudo abrir el archivo para escritura + + + Save Changes + Guardar Cambios + + + Do you want to save changes? + ¿Quieres guardar los cambios? + + + Help + Ayuda + + + Do you want to reset your custom default config to the original default config? + ¿Desea restablecer su configuración predeterminada personalizada a la configuración por defecto original? + + + Do you want to reset this config to your custom default config? + ¿Quieres restablecer esta configuración a tu configuración por defecto personalizada? + + + Reset to Default + Resetear A Valores Originales @@ -631,7 +702,7 @@ Never Played - Never Played + Nunca Jugado h @@ -717,7 +788,7 @@ Trophy Viewer - Ver trofeos + Expositor de Trofeos Open Folder... @@ -775,6 +846,10 @@ Delete DLC Eliminar DLC + + Delete Trophy + Eliminar Trofeo + Compatibility... Compatibilidad... @@ -807,10 +882,6 @@ Error creating shortcut! ¡Error al crear el acceso directo! - - Install PKG - Instalar PKG - Game Juego @@ -851,6 +922,10 @@ This game has no update folder to open! ¡Este juego no tiene carpeta de actualizaciones! + + No log file found for this game! + ¡No se encontró un archivo de registro para este juego! + Failed to convert icon. Error al convertir el icono. @@ -859,32 +934,255 @@ This game has no save data to delete! ¡Este juego no tiene datos guardados! + + This game has no saved trophies to delete! + ¡Este juego no tiene trofeos guardados para eliminar! + Save Data Datos guardados + + Trophy + Trofeo + SFO Viewer for Visualizador de SFO para - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - shadPS4 - Elegir carpeta + Quickstart + Inicio Rápido - Select which directory you want to install to. - Selecciona el directorio de instalación. + FAQ + Preguntas Frecuentes (FAQ) - Install All Queued to Selected Folder - Instalar toda la cola en la carpeta seleccionada + Syntax + Sintaxis - Delete PKG File on Install - Eliminar archivo PKG tras la instalación + Special Bindings + Asignación de Teclas Especiales + + + Keybindings + Asignación de Teclas + + + + KBMSettings + + Configure Controls + Configurar Controles + + + D-Pad + Cruceta + + + Up + Arriba + + + unmapped + sin vincular + + + Left + Izquierda + + + Right + Derecha + + + Down + Abajo + + + Left Analog Halfmode + Modo Reducido del Stick Izquierdo + + + hold to move left stick at half-speed + manten para mover el stick izquierdo a la mitad de la velocidad + + + Left Stick + Stick Izquierdo + + + Config Selection + Selección de Configuraciones + + + Common Config + Configuración Estándar + + + Use per-game configs + Usar configuraciones por juego + + + L1 + L1 + + + L2 + L2 + + + Text Editor + Editor de Texto + + + Help + Ayuda + + + R1 + R1 + + + R2 + R2 + + + L3 + L3 + + + Touchpad Click + Clic de pantalla táctil + + + Mouse to Joystick + Ratón a Joystick + + + *press F7 ingame to activate + * presiona F7 en el juego para activar + + + R3 + R3 + + + Options + Opciones + + + Mouse Movement Parameters + Parámetros Movimiento del Ratón + + + note: click Help Button/Special Keybindings for more information + nota: haga clic en Botón de ayuda/Asignación de Teclas Especiales para más información + + + Face Buttons + Botones de Acción + + + Triangle + Triángulo + + + Square + Cuadrado + + + Circle + Círculo + + + Cross + Equis + + + Right Analog Halfmode + Modo Reducido del Stick Derecho + + + hold to move right stick at half-speed + manten para mover el stick derecho a la mitad de la velocidad + + + Right Stick + Stick Derecho + + + Speed Offset (def 0.125): + Compensación de Velocidad (def 0.125): + + + Copy from Common Config + Copiar desde la Configuración Estándar + + + Deadzone Offset (def 0.50): + Zona Muerta (def 0.50): + + + Speed Multiplier (def 1.0): + Multiplicador de Velocidad (def 1.0): + + + Common Config Selected + Configuración Estándar Seleccionada + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + Este botón copia mapeos de la Configuración Estándar al perfil seleccionado actualmente, y no se puede utilizar cuando el perfil seleccionado es la Configuración Estándar. + + + Copy values from Common Config + Copiar valores de la Configuración Estándar + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + ¿Quiere sobrescribir los mapeos existentes con los mapeos de la Configuración Estándar? + + + Unable to Save + No se Pudo Guardar + + + Cannot bind any unique input more than once + No se puede vincular ninguna entrada única más de una vez + + + Press a key + Pulsa una tecla + + + Cannot set mapping + No se pudo asignar el mapeo + + + Mousewheel cannot be mapped to stick outputs + La rueda del ratón no puede ser mapeada al stick + + + Save + Guardar + + + Apply + Aplicar + + + Restore Defaults + Restaurar Valores Por Defecto + + + Cancel + Cancelar @@ -893,10 +1191,6 @@ Open/Add Elf Folder Abrir/Agregar carpeta Elf - - Install Packages (PKG) - Instalar paquetes (PKG) - Boot Game Iniciar juego @@ -913,10 +1207,6 @@ Configure... Configurar... - - Install application from a .pkg file - Instalar aplicación desde un archivo .pkg - Recent Games Juegos recientes @@ -963,11 +1253,11 @@ List View - Vista de lista + Vista de Lista Grid View - Vista de cuadrícula + Vista de Cuadrícula Elf Viewer @@ -975,7 +1265,7 @@ Game Install Directory - Carpeta de instalación de los juegos + Carpeta de Instalación de Juegos Download Cheats/Patches @@ -983,11 +1273,15 @@ Dump Game List - Volcar lista de juegos + Volcar Lista de Juegos - PKG Viewer - Vista PKG + Trophy Viewer + Expositor de Trofeos + + + No games found. Please add your games to your library first. + No se encontraron juegos. Por favor, añade tus juegos a tu biblioteca primero. Search... @@ -1003,11 +1297,11 @@ Game List Icons - Iconos de los juegos + Iconos de Juegos Game List Mode - Tipo de lista + Tipo de Lista Settings @@ -1051,7 +1345,7 @@ Game List - Lista de juegos + Lista de Juegos * Unsupported Vulkan Version @@ -1097,70 +1391,6 @@ Only one file can be selected! ¡Solo se puede seleccionar un archivo! - - PKG Extraction - Extracción de PKG - - - Patch detected! - ¡Actualización detectada! - - - PKG and Game versions match: - Las versiones de PKG y del juego coinciden: - - - Would you like to overwrite? - ¿Desea sobrescribir? - - - PKG Version %1 is older than installed version: - La versión de PKG %1 es más antigua que la versión instalada: - - - Game is installed: - El juego está instalado: - - - Would you like to install Patch: - ¿Desea instalar la actualización: - - - DLC Installation - Instalación de DLC - - - Would you like to install DLC: %1? - ¿Desea instalar el DLC: %1? - - - DLC already installed: - DLC ya instalado: - - - Game already installed - Juego ya instalado - - - PKG ERROR - ERROR PKG - - - Extracting PKG %1/%2 - Extrayendo PKG %1/%2 - - - Extraction Finished - Extracción terminada - - - Game successfully installed at %1 - Juego instalado exitosamente en %1 - - - File doesn't appear to be a valid PKG file - El archivo parece no ser un archivo PKG válido - Run Game Ejecutar juego @@ -1169,14 +1399,6 @@ Eboot.bin file not found Archivo Eboot.bin no encontrado - - PKG File (*.PKG *.pkg) - Archivo PKG (*.PKG *.pkg) - - - PKG is a patch or DLC, please install the game first! - El archivo PKG es un parche o un DLC, ¡debes instalar el juego primero! - Game is already running! ¡El juego ya se está ejecutando! @@ -1185,72 +1407,45 @@ shadPS4 shadPS4 - - - PKGViewer - Open Folder - Abrir carpeta + Play + Jugar - PKG ERROR - ERROR PKG + Pause + Pausar - Name - Nombre + Stop + Detener - Serial - Numero de serie + Restart + Reiniciar - Installed - Instalado + Full Screen + Pantalla completa - Size - Tamaño + Controllers + Controles - Category - Categoría + Keyboard + Teclado - Type - Tipo + Refresh List + Actualizar lista - App Ver - Versión de aplicación + Resume + Reanudar - FW - FW - - - Region - Región - - - Flags - Etiquetas - - - Path - Ruta - - - File - Archivo - - - Unknown - Desconocido - - - Package - Paquete + Show Labels Under Icons + Mostrar etiquetas debajo de los iconos @@ -1269,7 +1464,7 @@ Console Language - Idioma de la consola + Idioma de la Consola Emulator Language @@ -1279,10 +1474,6 @@ Emulator Emulador - - Enable Separate Update Folder - Habilitar carpeta independiente de actualizaciones - Default tab when opening settings Pestaña predeterminada al abrir la configuración @@ -1293,7 +1484,7 @@ Show Splash - Mostrar splash + Mostrar Pantalla de Bienvenida Enable Discord Rich Presence @@ -1301,31 +1492,35 @@ Username - Nombre de usuario + Nombre de Usuario Trophy Key - Clave de trofeos + Clave de Trofeos Trophy Trofeo + + Open the custom trophy images/sounds folder + Abrir la carpeta de trofeos/sonidos personalizados + Logger Registro Log Type - Tipo de registro + Tipo de Registro Log Filter - Filtro de registro + Filtro de Registro Open Log Location - Abrir ubicación del registro + Abrir Ubicación del registro Input @@ -1337,11 +1532,11 @@ Hide Cursor - Ocultar cursor + Ocultar Cursor Hide Cursor Idle Timeout - Tiempo de espera para ocultar cursor inactivo + Tiempo de Espera para Ocultar Cursor Inactivo s @@ -1353,7 +1548,7 @@ Back Button Behavior - Comportamiento del botón de retroceso + Comportamiento del Botón de Retroceso Graphics @@ -1369,7 +1564,7 @@ Graphics Device - Dispositivo gráfico + Dispositivo Gráfico Vblank Divider @@ -1381,7 +1576,7 @@ Enable Shaders Dumping - Habilitar volcado de shaders + Habilitar volcado de Shaders Enable NULL GPU @@ -1397,7 +1592,7 @@ Game Folders - Carpetas de juego + Carpetas de Juegos Add... @@ -1413,27 +1608,27 @@ Enable Debug Dumping - Habilitar volcado de depuración + Habilitar Volcado de Depuración Enable Vulkan Validation Layers - Habilitar capas de validación de Vulkan + Habilitar Capas de Validación de Vulkan Enable Vulkan Synchronization Validation - Habilitar validación de sincronización de Vulkan + Habilitar Validación de Sincronización de Vulkan Enable RenderDoc Debugging - Habilitar depuración de RenderDoc + Habilitar Depuración de RenderDoc Enable Crash Diagnostics - Habilitar diagnóstico de fallos + Habilitar Diagnóstico de Fallos Collect Shaders - Recopilar shaders + Recopilar Shaders Copy GPU Buffers @@ -1441,11 +1636,11 @@ Host Debug Markers - Host Debug Markers + Marcadores de Depuración del Host Guest Debug Markers - Guest Debug Markers + Marcadores de Depuración del Invitado Update @@ -1453,11 +1648,11 @@ Check for Updates at Startup - Buscar actualizaciones al iniciar + Buscar Actualizaciones al Iniciar Always Show Changelog - Mostrar siempre el registro de cambios + Mostrar Siempre el Registro de Cambios Update Channel @@ -1465,7 +1660,7 @@ Check for Updates - Verificar actualizaciones + Buscar Actualizaciones GUI Settings @@ -1476,12 +1671,12 @@ Música de título - Disable Trophy Pop-ups - Deshabilitar mensajes de trofeos + Disable Trophy Notification + Desactivar Notificaciones de Trofeos Background Image - Imagen de fondo + Imagen de Fondo Show Background Image @@ -1501,7 +1696,7 @@ Game Compatibility - Game Compatibility + Compatibilidad Display Compatibility Data @@ -1533,7 +1728,7 @@ Point your mouse at an option to display its description. - Coloque el mouse sobre una opción para mostrar su descripción. + Coloque el ratón sobre una opción para mostrar su descripción. Console Language:\nSets the language that the PS4 game uses.\nIt's recommended to set this to a language the game supports, which will vary by region. @@ -1543,10 +1738,6 @@ Emulator Language:\nSets the language of the emulator's user interface. Idioma del Emulador:\nConfigura el idioma de la interfaz de usuario del emulador. - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. Mostrar Pantalla de Inicio:\nMuestra la pantalla de inicio del juego (una imagen especial) mientras el juego se está iniciando. @@ -1561,7 +1752,7 @@ Trophy Key:\nKey used to decrypt trophies. Must be obtained from your jailbroken console.\nMust contain only hex characters. - Trophy Key:\nKey used to decrypt trophies. Must be obtained from your jailbroken console.\nMust contain only hex characters. + Clave de Trofeos:\nClave utilizada para descifrar trofeos. Debe obtenerse de tu consola desbloqueada.\nSolo debe contener caracteres hexadecimales. Log Type:\nSets whether to synchronize the output of the log window for performance. May have adverse effects on emulation. @@ -1585,15 +1776,15 @@ Disable Trophy Pop-ups:\nDisable in-game trophy notifications. Trophy progress can still be tracked using the Trophy Viewer (right-click the game in the main window). - Disable Trophy Pop-ups:\nDisable in-game trophy notifications. Trophy progress can still be tracked using the Trophy Viewer (right-click the game in the main window). + Desactivar Notificaciones de trofeos:\nDesactiva las notificaciones de trofeos en el juego. El progreso de trofeos todavía puede ser rastreado usando el Expositor de Trofeos (haz clic derecho en el juego en la ventana principal). Hide Cursor:\nChoose when the cursor will disappear:\nNever: You will always see the mouse.\nidle: Set a time for it to disappear after being idle.\nAlways: you will never see the mouse. - Ocultar Cursor:\nElija cuándo desaparecerá el cursor:\nNunca: Siempre verá el mouse.\nInactivo: Establezca un tiempo para que desaparezca después de estar inactivo.\nSiempre: nunca verá el mouse. + Ocultar Cursor:\nElija cuándo desaparecerá el cursor:\nNunca: Siempre verá el ratón.\nInactivo: Establezca un tiempo para que desaparezca después de estar inactivo.\nSiempre: nunca verá el ratón. Hide Idle Cursor Timeout:\nThe duration (seconds) after which the cursor that has been idle hides itself. - Establezca un tiempo para que el mouse desaparezca después de estar inactivo. + Establezca un tiempo para que el ratón desaparezca después de estar inactivo. Back Button Behavior:\nSets the controller's back button to emulate tapping the specified position on the PS4 touchpad. @@ -1601,15 +1792,15 @@ Display Compatibility Data:\nDisplays game compatibility information in table view. Enable "Update Compatibility On Startup" to get up-to-date information. - Display Compatibility Data:\nDisplays game compatibility information in table view. Enable "Update Compatibility On Startup" to get up-to-date information. + Mostrar Datos de Compatibilidad:\nMuestra información de compatibilidad de juegos en vista de tabla. Habilite "Actualizar Compatibilidad al Iniciar" para obtener información actualizada. Update Compatibility On Startup:\nAutomatically update the compatibility database when shadPS4 starts. - Update Compatibility On Startup:\nAutomatically update the compatibility database when shadPS4 starts. + Actualizar Compatibilidad al Iniciar:\nActualiza automáticamente la base de datos de compatibilidad cuando shadPS4 se inicia. Update Compatibility Database:\nImmediately update the compatibility database. - Update Compatibility Database:\nImmediately update the compatibility database. + Actualizar Base de Datos de Compatibilidad:\nActualizar inmediatamente la base de datos de compatibilidad. Never @@ -1653,7 +1844,7 @@ Enable Shaders Dumping:\nFor the sake of technical debugging, saves the games shaders to a folder as they render. - Habilitar la Volcadura de Sombras:\nPor el bien de la depuración técnica, guarda las sombras del juego en una carpeta mientras se renderizan. + Habilitar la Volcadura de Shaders:\nPor el bien de la depuración técnica, guarda las sombras del juego en una carpeta mientras se renderizan. Enable Null GPU:\nFor the sake of technical debugging, disables game rendering as if there were no graphics card. @@ -1661,7 +1852,7 @@ Enable HDR:\nEnables HDR in games that support it.\nYour monitor must have support for the BT2020 PQ color space and the RGB10A2 swapchain format. - Enable HDR:\nEnables HDR in games that support it.\nYour monitor must have support for the BT2020 PQ color space and the RGB10A2 swapchain format. + Habilitar HDR:\nHabilita HDR en juegos que lo soporten.\nTu monitor debe tener soporte para el espacio de color PQ BT2020 y el formato RGB10A2 de cadena de intercambio. Game Folders:\nThe list of folders to check for installed games. @@ -1693,31 +1884,31 @@ Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). - Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + Recopilar Shaders:\nNecesitas esto habilitado para editar shaders con el menú de depuración (Ctrl + F10). Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. - Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + Diagnóstico de cuelgues:\nCrea un archivo .yaml con información sobre el estado de Vulkan en el momento del cuelgue.\nÚtil para depurar errores de tipo 'Dispositivo perdido' . Con esto activado, deberías habilitar los marcadores de depuración de Host E Invitado.\nNo funciona en GPUs de Intel.\nNecesitas activar las Capas de Validación de Vulkan y el SDK de Vulkan para que funcione. Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. - Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + Copiar Búferes de GPU:\nSortea condiciones de carrera que implican envíos de GPU.\nPuede o no ayudar con cuelgues del tipo 0 de PM4. Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. - Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + Marcadores de Depuración del Host:\n Inserta información del emulador como marcadores para comandos AMDGPU específicos, además de proporcionar nombres de depuración.\nCon esto activado, deberías habilitar el diagnóstico de fallos.\nUtil para programas como RenderDoc. Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. - Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + Marcadores de Depuración del Invitado:\n Inserta cualquier marcador que el propio juego ha añadido al búfer de comandos.\nCon esto activado, deberías habilitar el diagnóstico de fallos.\nUtil para programas como RenderDoc. Save Data Path:\nThe folder where game save data will be saved. - Save Data Path:\nThe folder where game save data will be saved. + Ruta de Guardado de Datos:\nLa carpeta donde se guardarán los datos del juego. Browse:\nBrowse for a folder to set as the save data path. - Browse:\nBrowse for a folder to set as the save data path. + Buscar:\nBusque una carpeta para establecer como ruta de datos guardados. Release @@ -1729,11 +1920,11 @@ Set the volume of the background music. - Set the volume of the background music. + Establece el volumen de la música de fondo. Enable Motion Controls - Habilitar controles de movimiento + Habilitar Controles de Movimiento Save Data Path @@ -1745,15 +1936,15 @@ async - async + asíncrono sync - sync + síncrono Auto Select - Selección automática + Selección Automática Directory to install games @@ -1769,7 +1960,7 @@ Display Mode - Modo de imagen + Modo de Imagen Windowed @@ -1777,15 +1968,15 @@ Fullscreen - Pantalla completa + Pantalla Completa Fullscreen (Borderless) - Pantalla completa (sin bordes) + Pantalla Completa (sin bordes) Window Size - Tamaño de ventana + Tamaño de Ventana W: @@ -1797,18 +1988,94 @@ Separate Log Files - Separate Log Files + Archivos de Registro Independientes Separate Log Files:\nWrites a separate logfile for each game. - Separate Log Files:\nWrites a separate logfile for each game. + Archivos de Registro Independientes:\nEscribe un archivo de registro separado para cada juego. + + + Trophy Notification Position + Posición de Notificación de Trofeos + + + Left + Izquierda + + + Right + Derecha + + + Top + Arriba + + + Bottom + Abajo + + + Notification Duration + Duración de Notificaciones + + + Portable User Folder + Carpeta Portable de Usuario + + + Create Portable User Folder from Common User Folder + Crear Carpeta Portable de Usuario a partir de la Carpeta de Usuario Estándar + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + Carpeta portable de usuario:\nAlmacena la configuración de shadPS4 y los datos que se aplicarán sólo a la compilación shadPS4 ubicada en la carpeta actual. Reinicia la aplicación después de crear la carpeta portable de usuario para empezar a usarla. + + + Cannot create portable user folder + No se pudo crear la carpeta portable de usuario + + + %1 already exists + %1 ya existe + + + Portable user folder created + Carpeta Portable de Usuario Creada + + + %1 successfully created. + %1 creado correctamente. + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + Abre la carpeta de trofeos/sonidos personalizados:\nPuedes añadir imágenes y un audio personalizados a los trofeos.\nAñade los archivos a custom_trophy con los siguientes nombres:\ntrophy.wav o trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNota: El sonido sólo funcionará en versiones QT. TrophyViewer Trophy Viewer - Vista de trofeos + Expositor de Trofeos + + + Select Game: + Selecciona un Juego: + + + Progress + Progreso + + + Show Earned Trophies + Mostrar Trofeos Obtenidos + + + Show Not Earned Trophies + Mostrar Trofeos No Obtenidos + + + Show Hidden Trophies + Mostrar Trofeos Ocultos diff --git a/src/qt_gui/translations/fa_IR.ts b/src/qt_gui/translations/fa_IR.ts index a173dc9d4..552a0ff23 100644 --- a/src/qt_gui/translations/fa_IR.ts +++ b/src/qt_gui/translations/fa_IR.ts @@ -541,6 +541,77 @@ Override Color Override Color + + Unable to Save + Unable to Save + + + Cannot bind axis values more than once + Cannot bind axis values more than once + + + Save + Save + + + Apply + Apply + + + Restore Defaults + Restore Defaults + + + Cancel + Cancel + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + Edit Keyboard + Mouse and Controller input bindings + + + Use Per-Game configs + Use Per-Game configs + + + Error + Error + + + Could not open the file for reading + Could not open the file for reading + + + Could not open the file for writing + Could not open the file for writing + + + Save Changes + Save Changes + + + Do you want to save changes? + Do you want to save changes? + + + Help + Help + + + Do you want to reset your custom default config to the original default config? + Do you want to reset your custom default config to the original default config? + + + Do you want to reset this config to your custom default config? + Do you want to reset this config to your custom default config? + + + Reset to Default + Reset to Default + ElfViewer @@ -775,6 +846,10 @@ Delete DLC حذف محتوای اضافی (DLC) + + Delete Trophy + Delete Trophy + Compatibility... Compatibility... @@ -807,10 +882,6 @@ Error creating shortcut! مشکلی در هنگام ساخت میانبر بوجود آمد! - - Install PKG - نصب PKG - Game بازی @@ -851,6 +922,10 @@ This game has no update folder to open! This game has no update folder to open! + + No log file found for this game! + No log file found for this game! + Failed to convert icon. Failed to convert icon. @@ -859,32 +934,255 @@ This game has no save data to delete! This game has no save data to delete! + + This game has no saved trophies to delete! + This game has no saved trophies to delete! + Save Data Save Data + + Trophy + Trophy + SFO Viewer for SFO Viewer for - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - ShadPS4 - انتخاب محل نصب بازی + Quickstart + Quickstart - Select which directory you want to install to. - محلی را که می‌خواهید در آن نصب شود، انتخاب کنید. + FAQ + FAQ - Install All Queued to Selected Folder - Install All Queued to Selected Folder + Syntax + Syntax - Delete PKG File on Install - Delete PKG File on Install + Special Bindings + Special Bindings + + + Keybindings + Keybindings + + + + KBMSettings + + Configure Controls + Configure Controls + + + D-Pad + D-Pad + + + Up + Up + + + unmapped + unmapped + + + Left + Left + + + Right + Right + + + Down + Down + + + Left Analog Halfmode + Left Analog Halfmode + + + hold to move left stick at half-speed + hold to move left stick at half-speed + + + Left Stick + Left Stick + + + Config Selection + Config Selection + + + Common Config + Common Config + + + Use per-game configs + Use per-game configs + + + L1 + L1 + + + L2 + L2 + + + Text Editor + Text Editor + + + Help + Help + + + R1 + R1 + + + R2 + R2 + + + L3 + L3 + + + Touchpad Click + Touchpad Click + + + Mouse to Joystick + Mouse to Joystick + + + *press F7 ingame to activate + *press F7 ingame to activate + + + R3 + R3 + + + Options + Options + + + Mouse Movement Parameters + Mouse Movement Parameters + + + note: click Help Button/Special Keybindings for more information + note: click Help Button/Special Keybindings for more information + + + Face Buttons + Face Buttons + + + Triangle + Triangle + + + Square + Square + + + Circle + Circle + + + Cross + Cross + + + Right Analog Halfmode + Right Analog Halfmode + + + hold to move right stick at half-speed + hold to move right stick at half-speed + + + Right Stick + Right Stick + + + Speed Offset (def 0.125): + Speed Offset (def 0.125): + + + Copy from Common Config + Copy from Common Config + + + Deadzone Offset (def 0.50): + Deadzone Offset (def 0.50): + + + Speed Multiplier (def 1.0): + Speed Multiplier (def 1.0): + + + Common Config Selected + Common Config Selected + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + + + Copy values from Common Config + Copy values from Common Config + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + Do you want to overwrite existing mappings with the mappings from the Common Config? + + + Unable to Save + Unable to Save + + + Cannot bind any unique input more than once + Cannot bind any unique input more than once + + + Press a key + Press a key + + + Cannot set mapping + Cannot set mapping + + + Mousewheel cannot be mapped to stick outputs + Mousewheel cannot be mapped to stick outputs + + + Save + Save + + + Apply + Apply + + + Restore Defaults + Restore Defaults + + + Cancel + Cancel @@ -893,10 +1191,6 @@ Open/Add Elf Folder ELF بازکردن/ساختن پوشه - - Install Packages (PKG) - نصب بسته (PKG) - Boot Game اجرای بازی @@ -913,10 +1207,6 @@ Configure... ...تنظیمات - - Install application from a .pkg file - .PKG نصب بازی از فایل - Recent Games بازی های اخیر @@ -986,8 +1276,12 @@ استخراج لیست بازی ها - PKG Viewer - PKG مشاهده گر + Trophy Viewer + Trophy Viewer + + + No games found. Please add your games to your library first. + No games found. Please add your games to your library first. Search... @@ -1097,70 +1391,6 @@ Only one file can be selected! فقط یک فایل انتخاب کنید! - - PKG Extraction - PKG استخراج فایل - - - Patch detected! - پچ شناسایی شد! - - - PKG and Game versions match: - و نسخه بازی همخوانی دارد PKG فایل: - - - Would you like to overwrite? - آیا مایل به جایگزینی فایل هستید؟ - - - PKG Version %1 is older than installed version: - نسخه فایل PKG %1 قدیمی تر از نسخه نصب شده است: - - - Game is installed: - بازی نصب شد: - - - Would you like to install Patch: - آیا مایل به نصب پچ هستید: - - - DLC Installation - نصب DLC - - - Would you like to install DLC: %1? - آیا مایل به نصب DLC هستید: %1 - - - DLC already installed: - قبلا نصب شده DLC این: - - - Game already installed - این بازی قبلا نصب شده - - - PKG ERROR - PKG ارور فایل - - - Extracting PKG %1/%2 - درحال استخراج PKG %1/%2 - - - Extraction Finished - استخراج به پایان رسید - - - Game successfully installed at %1 - بازی با موفقیت در %1 نصب شد - - - File doesn't appear to be a valid PKG file - این فایل یک PKG درست به نظر نمی آید - Run Game Run Game @@ -1169,14 +1399,6 @@ Eboot.bin file not found Eboot.bin file not found - - PKG File (*.PKG *.pkg) - PKG File (*.PKG *.pkg) - - - PKG is a patch or DLC, please install the game first! - PKG is a patch or DLC, please install the game first! - Game is already running! Game is already running! @@ -1185,72 +1407,45 @@ shadPS4 ShadPS4 - - - PKGViewer - Open Folder - بازکردن پوشه + Play + Play - PKG ERROR - PKG ارور فایل + Pause + Pause - Name - نام + Stop + Stop - Serial - سریال + Restart + Restart - Installed - Installed + Full Screen + Full Screen - Size - اندازه + Controllers + Controllers - Category - Category + Keyboard + Keyboard - Type - Type + Refresh List + Refresh List - App Ver - App Ver + Resume + Resume - FW - FW - - - Region - منطقه - - - Flags - Flags - - - Path - مسیر - - - File - فایل - - - Unknown - ناشناخته - - - Package - Package + Show Labels Under Icons + Show Labels Under Icons @@ -1279,10 +1474,6 @@ Emulator شبیه ساز - - Enable Separate Update Folder - فعال‌سازی پوشه جداگانه برای به‌روزرسانی - Default tab when opening settings زبان پیش‌فرض هنگام باز کردن تنظیمات @@ -1311,6 +1502,10 @@ Trophy Trophy + + Open the custom trophy images/sounds folder + Open the custom trophy images/sounds folder + Logger Logger @@ -1476,8 +1671,8 @@ Title Music - Disable Trophy Pop-ups - غیرفعال کردن نمایش جوایز + Disable Trophy Notification + Disable Trophy Notification Background Image @@ -1543,10 +1738,6 @@ Emulator Language:\nSets the language of the emulator's user interface. زبان شبیه‌ساز:\nزبان رابط کاربری شبیه‌ساز را انتخاب می‌کند. - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - فعال‌سازی پوشه جداگانه برای به‌روزرسانی:\nامکان نصب به‌روزرسانی‌های بازی در یک پوشه جداگانه برای مدیریت راحت‌تر را فراهم می‌کند. - Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. نمایش صفحه شروع:\nصفحه شروع بازی (تصویری ویژه) را هنگام بارگذاری بازی نمایش می‌دهد. @@ -1803,6 +1994,62 @@ Separate Log Files:\nWrites a separate logfile for each game. Separate Log Files:\nWrites a separate logfile for each game. + + Trophy Notification Position + Trophy Notification Position + + + Left + Left + + + Right + Right + + + Top + Top + + + Bottom + Bottom + + + Notification Duration + Notification Duration + + + Portable User Folder + Portable User Folder + + + Create Portable User Folder from Common User Folder + Create Portable User Folder from Common User Folder + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + + + Cannot create portable user folder + Cannot create portable user folder + + + %1 already exists + %1 already exists + + + Portable user folder created + Portable user folder created + + + %1 successfully created. + %1 successfully created. + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + TrophyViewer @@ -1810,5 +2057,25 @@ Trophy Viewer مشاهده جوایز + + Select Game: + Select Game: + + + Progress + Progress + + + Show Earned Trophies + Show Earned Trophies + + + Show Not Earned Trophies + Show Not Earned Trophies + + + Show Hidden Trophies + Show Hidden Trophies + diff --git a/src/qt_gui/translations/fi_FI.ts b/src/qt_gui/translations/fi_FI.ts index bcbbd07f6..44c668560 100644 --- a/src/qt_gui/translations/fi_FI.ts +++ b/src/qt_gui/translations/fi_FI.ts @@ -407,139 +407,210 @@ ControlSettings Configure Controls - Configure Controls + Määritä Kontrollit D-Pad - D-Pad + D-Pad Up - Up + Ylös Left - Left + Vasen Right - Right + Oikea Down - Down + Alas Left Stick Deadzone (def:2 max:127) - Left Stick Deadzone (def:2 max:127) + Vasemman Analogin Deadzone (oletus:2 max:127) Left Deadzone - Left Deadzone + Vasen Deadzone Left Stick - Left Stick + Vasen Analogi Config Selection - Config Selection + Asetusten Valinta Common Config - Common Config + Yleinen Asetus Use per-game configs - Use per-game configs + Käytä pelikohtaisia asetuksia L1 / LB - L1 / LB + L1 / LB L2 / LT - L2 / LT + L2 / LT Back - Back + Back R1 / RB - R1 / RB + R1 / RB R2 / RT - R2 / RT + R2 / RT L3 - L3 + L3 Options / Start - Options / Start + Options / Start R3 - R3 + R3 Face Buttons - Face Buttons + Etunäppäimet Triangle / Y - Triangle / Y + Kolmio / Y Square / X - Square / X + Neliö / X Circle / B - Circle / B + Ympyrä / B Cross / A - Cross / A + Rasti / A Right Stick Deadzone (def:2, max:127) - Right Stick Deadzone (def:2, max:127) + Oikean Analogin Deadzone (oletus:2 max:127) Right Deadzone - Right Deadzone + Oikea Deadzone Right Stick - Right Stick + Oikea Analogi Color Adjustment - Color Adjustment + Värinhallinta R: - R: + R: G: - G: + G: B: - B: + B: Override Lightbar Color - Override Lightbar Color + Pakota Ohjaimen Valopalkin Väri Override Color - Override Color + Pakotettava Väri + + + Unable to Save + Tallentaminen Epäonnistui + + + Cannot bind axis values more than once + Akseliarvoja ei voi määrittää kertaa useammin + + + Save + Tallenna + + + Apply + Ota Käyttöön + + + Restore Defaults + Palauta Oletukset + + + Cancel + Peruuta + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + Muokkaa Näppäimistön + Hiiren ja Ohjaimen näppäinasetuksia + + + Use Per-Game configs + Käytä Pelikohtaisia Asetuksia + + + Error + Virhe + + + Could not open the file for reading + Tiedostoa ei voitu avata luettavaksi + + + Could not open the file for writing + Tiedostoa ei voitu avata kirjoitettavaksi + + + Save Changes + Tallenna Muutokset + + + Do you want to save changes? + Haluatko tallentaa muutokset? + + + Help + Tietoa + + + Do you want to reset your custom default config to the original default config? + Haluatko nollata oletusasetuksiin tekemäsi muutokset? + + + Do you want to reset this config to your custom default config? + Haluato palauttaa nämä asetukset takaisin määrittämiisi oletuksiin? + + + Reset to Default + Reset to Default @@ -775,6 +846,10 @@ Delete DLC Poista Lisäsisältö + + Delete Trophy + Delete Trophy + Compatibility... Yhteensopivuus... @@ -807,10 +882,6 @@ Error creating shortcut! Virhe pikakuvakkeen luonnissa! - - Install PKG - Asenna PKG - Game Peli @@ -851,6 +922,10 @@ This game has no update folder to open! This game has no update folder to open! + + No log file found for this game! + No log file found for this game! + Failed to convert icon. Failed to convert icon. @@ -859,32 +934,255 @@ This game has no save data to delete! This game has no save data to delete! + + This game has no saved trophies to delete! + This game has no saved trophies to delete! + Save Data Save Data + + Trophy + Trophy + SFO Viewer for SFO Viewer for - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - shadPS4 - Valitse hakemisto + Quickstart + Quickstart - Select which directory you want to install to. - Valitse, mihin hakemistoon haluat asentaa. + FAQ + FAQ - Install All Queued to Selected Folder - Install All Queued to Selected Folder + Syntax + Syntax - Delete PKG File on Install - Delete PKG File on Install + Special Bindings + Special Bindings + + + Keybindings + Keybindings + + + + KBMSettings + + Configure Controls + Configure Controls + + + D-Pad + D-Pad + + + Up + Up + + + unmapped + unmapped + + + Left + Left + + + Right + Right + + + Down + Down + + + Left Analog Halfmode + Left Analog Halfmode + + + hold to move left stick at half-speed + hold to move left stick at half-speed + + + Left Stick + Left Stick + + + Config Selection + Config Selection + + + Common Config + Common Config + + + Use per-game configs + Use per-game configs + + + L1 + L1 + + + L2 + L2 + + + Text Editor + Text Editor + + + Help + Help + + + R1 + R1 + + + R2 + R2 + + + L3 + L3 + + + Touchpad Click + Kosketuslevyn Klikkaus + + + Mouse to Joystick + Hiiri Joystickinä + + + *press F7 ingame to activate + *paina F7 pelissä aktivoidaksesi + + + R3 + R3 + + + Options + Options + + + Mouse Movement Parameters + Hiiren Liikkeen Parametrit + + + note: click Help Button/Special Keybindings for more information + huomio: klikkaa apunappia/näppäintä saadaksesi lisää tietoa + + + Face Buttons + Face Buttons + + + Triangle + Triangle + + + Square + Square + + + Circle + Circle + + + Cross + Cross + + + Right Analog Halfmode + Right Analog Halfmode + + + hold to move right stick at half-speed + hold to move right stick at half-speed + + + Right Stick + Right Stick + + + Speed Offset (def 0.125): + Speed Offset (def 0.125): + + + Copy from Common Config + Copy from Common Config + + + Deadzone Offset (def 0.50): + Deadzone Offset (def 0.50): + + + Speed Multiplier (def 1.0): + Speed Multiplier (def 1.0): + + + Common Config Selected + Common Config Selected + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + + + Copy values from Common Config + Copy values from Common Config + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + Do you want to overwrite existing mappings with the mappings from the Common Config? + + + Unable to Save + Unable to Save + + + Cannot bind any unique input more than once + Cannot bind any unique input more than once + + + Press a key + Press a key + + + Cannot set mapping + Cannot set mapping + + + Mousewheel cannot be mapped to stick outputs + Mousewheel cannot be mapped to stick outputs + + + Save + Save + + + Apply + Apply + + + Restore Defaults + Restore Defaults + + + Cancel + Cancel @@ -893,10 +1191,6 @@ Open/Add Elf Folder Avaa/Lisää Elf Hakemisto - - Install Packages (PKG) - Asenna Paketteja (PKG) - Boot Game Käynnistä Peli @@ -913,10 +1207,6 @@ Configure... Asetukset... - - Install application from a .pkg file - Asenna sovellus .pkg tiedostosta - Recent Games Viimeisimmät Pelit @@ -986,8 +1276,12 @@ Kirjoita Pelilista Tiedostoon - PKG Viewer - PKG Selain + Trophy Viewer + Trophy Viewer + + + No games found. Please add your games to your library first. + No games found. Please add your games to your library first. Search... @@ -1097,70 +1391,6 @@ Only one file can be selected! Vain yksi tiedosto voi olla valittuna! - - PKG Extraction - PKG:n purku - - - Patch detected! - Päivitys havaittu! - - - PKG and Game versions match: - PKG- ja peliversiot vastaavat: - - - Would you like to overwrite? - Haluatko korvata? - - - PKG Version %1 is older than installed version: - PKG-versio %1 on vanhempi kuin asennettu versio: - - - Game is installed: - Peli on asennettu: - - - Would you like to install Patch: - Haluatko asentaa päivityksen: - - - DLC Installation - Lisäsisällön asennus - - - Would you like to install DLC: %1? - Haluatko asentaa lisäsisällön: %1? - - - DLC already installed: - Lisäsisältö on jo asennettu: - - - Game already installed - Peli on jo asennettu - - - PKG ERROR - PKG VIRHE - - - Extracting PKG %1/%2 - Purkaminen PKG %1/%2 - - - Extraction Finished - Purku valmis - - - Game successfully installed at %1 - Peli asennettu onnistuneesti kohtaan %1 - - - File doesn't appear to be a valid PKG file - Tiedosto ei vaikuta olevan kelvollinen PKG-tiedosto - Run Game Run Game @@ -1169,14 +1399,6 @@ Eboot.bin file not found Eboot.bin file not found - - PKG File (*.PKG *.pkg) - PKG File (*.PKG *.pkg) - - - PKG is a patch or DLC, please install the game first! - PKG is a patch or DLC, please install the game first! - Game is already running! Game is already running! @@ -1185,72 +1407,45 @@ shadPS4 shadPS4 - - - PKGViewer - Open Folder - Avaa Hakemisto + Play + Play - PKG ERROR - PKG VIRHE + Pause + Pause - Name - Nimi + Stop + Stop - Serial - Sarjanumero + Restart + Restart - Installed - Installed + Full Screen + Full Screen - Size - Koko + Controllers + Controllers - Category - Category + Keyboard + Keyboard - Type - Type + Refresh List + Refresh List - App Ver - App Ver + Resume + Resume - FW - FW - - - Region - Alue - - - Flags - Flags - - - Path - Polku - - - File - Tiedosto - - - Unknown - Tuntematon - - - Package - Package + Show Labels Under Icons + Show Labels Under Icons @@ -1279,10 +1474,6 @@ Emulator Emulaattori - - Enable Separate Update Folder - Ota Käyttöön Erillinen Päivityshakemisto - Default tab when opening settings Oletusvälilehti avattaessa asetuksia @@ -1311,6 +1502,10 @@ Trophy Trophy + + Open the custom trophy images/sounds folder + Open the custom trophy images/sounds folder + Logger Lokinkerääjä @@ -1476,8 +1671,8 @@ Title Music - Disable Trophy Pop-ups - Poista Trophy Pop-upit Käytöstä + Disable Trophy Notification + Disable Trophy Notification Background Image @@ -1543,10 +1738,6 @@ Emulator Language:\nSets the language of the emulator's user interface. Emulaattorin Kieli:\nAsettaa emulaattorin käyttöliittymän kielen. - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Ota Käyttöön Erillinen Päivityskansio:\nOttaa käyttöön päivitysten asennuksen erilliseen kansioon helpottamaan niiden hallintaa.\nTämä on tehtävissä manuaalisesti lisäämällä puretun päivityksen pelikansioon "CUSA00000-UPDATE" nimellä, missä CUSA ID vastaa pelin ID:tä. - Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. Näytä Aloitusnäyttö:\nNäyttää pelin aloitusnäytön (erityinen kuva) pelin käynnistyessä. @@ -1803,6 +1994,62 @@ Separate Log Files:\nWrites a separate logfile for each game. Separate Log Files:\nWrites a separate logfile for each game. + + Trophy Notification Position + Trophy Notification Position + + + Left + Left + + + Right + Right + + + Top + Top + + + Bottom + Bottom + + + Notification Duration + Notification Duration + + + Portable User Folder + Portable User Folder + + + Create Portable User Folder from Common User Folder + Create Portable User Folder from Common User Folder + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + + + Cannot create portable user folder + Cannot create portable user folder + + + %1 already exists + %1 already exists + + + Portable user folder created + Portable user folder created + + + %1 successfully created. + %1 successfully created. + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + TrophyViewer @@ -1810,5 +2057,25 @@ Trophy Viewer Trophy Selain + + Select Game: + Select Game: + + + Progress + Progress + + + Show Earned Trophies + Show Earned Trophies + + + Show Not Earned Trophies + Show Not Earned Trophies + + + Show Hidden Trophies + Show Hidden Trophies + diff --git a/src/qt_gui/translations/fr_FR.ts b/src/qt_gui/translations/fr_FR.ts index a812631f5..13e1be9f5 100644 --- a/src/qt_gui/translations/fr_FR.ts +++ b/src/qt_gui/translations/fr_FR.ts @@ -487,7 +487,7 @@ Face Buttons - Face Buttons + Touches d'action Triangle / Y @@ -535,12 +535,83 @@ Override Lightbar Color - Override Lightbar Color + Remplacer la couleur de la barre de lumière Override Color Remplacer la couleur + + Unable to Save + Impossible de sauvegarder + + + Cannot bind axis values more than once + Impossible de lier les valeurs de l'axe plusieurs fois + + + Save + Enregistrer + + + Apply + Appliquer + + + Restore Defaults + Réinitialiser par défaut + + + Cancel + Annuler + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + Modifier les raccourcis d'entrée clavier + souris et contrôleur + + + Use Per-Game configs + Utiliser les configurations pour chaque jeu + + + Error + Erreur + + + Could not open the file for reading + Impossible d'ouvrir le fichier pour la lecture + + + Could not open the file for writing + Impossible d'ouvrir le fichier pour l'écriture + + + Save Changes + Enregistrer les Modifications + + + Do you want to save changes? + Voulez-vous sauvegarder les modifications? + + + Help + Aide + + + Do you want to reset your custom default config to the original default config? + Voulez-vous réinitialiser votre configuration par défaut personnalisée à la configuration par défaut d'origine ? + + + Do you want to reset this config to your custom default config? + Voulez-vous réinitialiser cette configuration à votre configuration personnalisée par défaut ? + + + Reset to Default + Rétablir par défaut + ElfViewer @@ -775,6 +846,10 @@ Delete DLC Supprimer DLC + + Delete Trophy + Supprimer Trophée + Compatibility... Compatibilité... @@ -807,10 +882,6 @@ Error creating shortcut! Erreur lors de la création du raccourci ! - - Install PKG - Installer un PKG - Game Jeu @@ -851,6 +922,10 @@ This game has no update folder to open! Ce jeu n'a pas de dossier de mise à jour à ouvrir! + + No log file found for this game! + Aucun fichier journal trouvé pour ce jeu! + Failed to convert icon. Échec de la conversion de l'icône. @@ -859,32 +934,255 @@ This game has no save data to delete! Ce jeu n'a pas de mise à jour à supprimer! + + This game has no saved trophies to delete! + Ce jeu n'a aucun trophée sauvegardé à supprimer! + Save Data Enregistrer les Données + + Trophy + Trophée + SFO Viewer for Visionneuse SFO pour - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - shadPS4 - Choisir un répertoire + Quickstart + Démarrage rapide - Select which directory you want to install to. - Sélectionnez le répertoire où vous souhaitez effectuer l'installation. + FAQ + FAQ - Install All Queued to Selected Folder - Installer toute la file d’attente dans le dossier sélectionné + Syntax + Syntaxe - Delete PKG File on Install - Supprimer le fichier PKG à l'installation + Special Bindings + Special bindings + + + Keybindings + Raccourcis + + + + KBMSettings + + Configure Controls + Configurer les Commandes + + + D-Pad + Croix directionnelle + + + Up + Haut + + + unmapped + non mappé + + + Left + Gauche + + + Right + Droite + + + Down + Bas + + + Left Analog Halfmode + Demi-mode analogique gauche + + + hold to move left stick at half-speed + maintenez pour déplacer le joystick gauche à mi-vitesse + + + Left Stick + Joystick gauche + + + Config Selection + Sélection de la Configuration + + + Common Config + Configuration Commune + + + Use per-game configs + Utiliser les configurations par jeu + + + L1 + L1 + + + L2 + L2 + + + Text Editor + Éditeur de Texte + + + Help + Aide + + + R1 + R1 + + + R2 + R2 + + + L3 + L3 + + + Touchpad Click + Clic tactile + + + Mouse to Joystick + Souris vers Joystick + + + *press F7 ingame to activate + *Appuyez sur F7 en jeu pour activer + + + R3 + R3 + + + Options + Options + + + Mouse Movement Parameters + Paramètres du mouvement de la souris + + + note: click Help Button/Special Keybindings for more information + remarque: cliquez sur le bouton Aide / Raccourcis spéciaux pour plus d'informations + + + Face Buttons + Touches d'action + + + Triangle + Triangle + + + Square + Carré + + + Circle + Rond + + + Cross + Croix + + + Right Analog Halfmode + Demi-mode analogique droit + + + hold to move right stick at half-speed + maintenez pour déplacer le joystick droit à mi-vitesse + + + Right Stick + Joystick Droit + + + Speed Offset (def 0.125): + Décalage de vitesse (def 0,125) : + + + Copy from Common Config + Copier à partir de la configuration commune + + + Deadzone Offset (def 0.50): + Deadzone Offset (def 0,50): + + + Speed Multiplier (def 1.0): + Multiplicateur de vitesse (def 1,0) : + + + Common Config Selected + Configuration courante sélectionnée + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + Ce bouton copie les mappings de la configuration commune vers le profil actuellement sélectionné, et ne peut pas être utilisé lorsque le profil actuellement sélectionné est la configuration commune. + + + Copy values from Common Config + Copier à partir de la configuration commune + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + Voulez-vous remplacer les mappings existants par les mappings de la configuration commune ? + + + Unable to Save + Impossible de sauvegarder + + + Cannot bind any unique input more than once + Impossible de lier une entrée unique plus d'une fois + + + Press a key + Appuyez sur un bouton + + + Cannot set mapping + Impossible de définir le mapping + + + Mousewheel cannot be mapped to stick outputs + La molette de la souris ne peut pas être affectée aux sorties de la manette + + + Save + Enregistrer + + + Apply + Appliquer + + + Restore Defaults + Réinitialiser par défaut + + + Cancel + Annuler @@ -893,10 +1191,6 @@ Open/Add Elf Folder Ouvrir/Ajouter un dossier ELF - - Install Packages (PKG) - Installer des packages (PKG) - Boot Game Démarrer un jeu @@ -913,10 +1207,6 @@ Configure... Configurer... - - Install application from a .pkg file - Installer une application depuis un fichier .pkg - Recent Games Jeux récents @@ -986,8 +1276,12 @@ Dumper la liste des jeux - PKG Viewer - Visionneuse PKG + Trophy Viewer + Visionneuse de trophées + + + No games found. Please add your games to your library first. + Aucun jeu trouvé. Veuillez d'abord ajouter vos jeux à votre bibliothèque. Search... @@ -1097,70 +1391,6 @@ Only one file can be selected! Un seul fichier peut être sélectionné ! - - PKG Extraction - Extraction du PKG - - - Patch detected! - Patch détecté ! - - - PKG and Game versions match: - Les versions PKG et jeu correspondent: - - - Would you like to overwrite? - Souhaitez-vous remplacer ? - - - PKG Version %1 is older than installed version: - La version PKG %1 est plus ancienne que la version installée: - - - Game is installed: - Jeu installé: - - - Would you like to install Patch: - Souhaitez-vous installer le patch: - - - DLC Installation - Installation du DLC - - - Would you like to install DLC: %1? - Souhaitez-vous installer le DLC: %1 ? - - - DLC already installed: - DLC déjà installé: - - - Game already installed - Jeu déjà installé - - - PKG ERROR - Erreur PKG - - - Extracting PKG %1/%2 - Extraction PKG %1/%2 - - - Extraction Finished - Extraction terminée - - - Game successfully installed at %1 - Jeu installé avec succès dans %1 - - - File doesn't appear to be a valid PKG file - Le fichier ne semble pas être un PKG valide - Run Game Lancer le jeu @@ -1169,14 +1399,6 @@ Eboot.bin file not found Fichier Eboot.bin introuvable - - PKG File (*.PKG *.pkg) - Fichier PKG (*.PKG *.pkg) - - - PKG is a patch or DLC, please install the game first! - PKG est un patch ou DLC, veuillez d'abord installer le jeu ! - Game is already running! Le jeu est déjà en cours ! @@ -1185,72 +1407,45 @@ shadPS4 shadPS4 - - - PKGViewer - Open Folder - Ouvrir un dossier + Play + Jouer - PKG ERROR - Erreur PKG + Pause + Pause - Name - Nom + Stop + Stop - Serial - Numéro de série + Restart + Redémarrer - Installed - Installé + Full Screen + Plein écran - Size - Taille + Controllers + Contrôleurs - Category - Catégorie + Keyboard + Clavier - Type - Type + Refresh List + Rafraîchir la liste - App Ver - App Ver + Resume + Reprendre - FW - FW - - - Region - Région - - - Flags - Les indicateurs - - - Path - Répertoire - - - File - Fichier - - - Unknown - Inconnu - - - Package - Package + Show Labels Under Icons + Afficher les libellés sous les icônes @@ -1279,10 +1474,6 @@ Emulator Émulateur - - Enable Separate Update Folder - Dossier séparé pour les mises à jour - Default tab when opening settings Onglet par défaut lors de l'ouverture des paramètres @@ -1311,6 +1502,10 @@ Trophy Trophée + + Open the custom trophy images/sounds folder + Ouvrir le dossier des images/sons de trophée personnalisé + Logger Journalisation @@ -1476,8 +1671,8 @@ Musique du titre - Disable Trophy Pop-ups - Désactiver les notifications de trophées + Disable Trophy Notification + Désactiver la notification de trophée Background Image @@ -1543,10 +1738,6 @@ Emulator Language:\nSets the language of the emulator's user interface. Langue de l'émulateur:\nDéfinit la langue de l'interface utilisateur de l'émulateur. - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Dossier séparé pour les mises à jour:\nInstalle les mises à jours des jeux dans un dossier séparé pour une gestion plus facile. - Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. Afficher l'écran de démarrage:\nAffiche l'écran de démarrage du jeu (une image spéciale) lors du démarrage du jeu. @@ -1717,7 +1908,7 @@ Browse:\nBrowse for a folder to set as the save data path. - Browse:\nBrowse for a folder to set as the save data path. + Parcourir:\nNaviguez pour trouver un dossier pour définir le chemin des données de sauvegarde. Release @@ -1797,11 +1988,67 @@ Separate Log Files - Separate Log Files + Séparer les fichiers de log Separate Log Files:\nWrites a separate logfile for each game. - Separate Log Files:\nWrites a separate logfile for each game. + Fichiers journaux séparés :\nÉcrit un fichier journal séparé pour chaque jeu. + + + Trophy Notification Position + Position de notification du trophée + + + Left + Gauche + + + Right + Droite + + + Top + Haut + + + Bottom + Bas + + + Notification Duration + Durée de la notification + + + Portable User Folder + Dossier d'utilisateur portable + + + Create Portable User Folder from Common User Folder + Créer un dossier utilisateur portable à partir du dossier utilisateur commun + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + Dossier utilisateur portable :\nStocke les paramètres et données shadPS4 qui seront appliqués uniquement à la version shadPS4 située dans le dossier actuel. Redémarrez l'application après avoir créé le dossier utilisateur portable pour commencer à l'utiliser. + + + Cannot create portable user folder + Impossible de créer le dossier utilisateur portable + + + %1 already exists + %1 existe déjà + + + Portable user folder created + Dossier utilisateur portable créé + + + %1 successfully created. + %1 a été créé avec succès. + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + Ouvrez le dossier des images/sons des trophées personnalisés:\nVous pouvez ajouter des images personnalisées aux trophées et aux sons.\nAjoutez les fichiers à custom_trophy avec les noms suivants:\ntrophy.wav OU trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote : Le son ne fonctionnera que dans les versions QT. @@ -1810,5 +2057,25 @@ Trophy Viewer Visionneuse de trophées + + Select Game: + Sélectionnez un jeu: + + + Progress + Progression + + + Show Earned Trophies + Afficher les trophées gagnés + + + Show Not Earned Trophies + Afficher les trophées non gagnés + + + Show Hidden Trophies + Afficher les trophées cachés + diff --git a/src/qt_gui/translations/hu_HU.ts b/src/qt_gui/translations/hu_HU.ts index 93e266f2c..58857d0d7 100644 --- a/src/qt_gui/translations/hu_HU.ts +++ b/src/qt_gui/translations/hu_HU.ts @@ -541,6 +541,77 @@ Override Color Override Color + + Unable to Save + Unable to Save + + + Cannot bind axis values more than once + Cannot bind axis values more than once + + + Save + Save + + + Apply + Apply + + + Restore Defaults + Restore Defaults + + + Cancel + Cancel + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + Edit Keyboard + Mouse and Controller input bindings + + + Use Per-Game configs + Use Per-Game configs + + + Error + Error + + + Could not open the file for reading + Could not open the file for reading + + + Could not open the file for writing + Could not open the file for writing + + + Save Changes + Save Changes + + + Do you want to save changes? + Do you want to save changes? + + + Help + Help + + + Do you want to reset your custom default config to the original default config? + Do you want to reset your custom default config to the original default config? + + + Do you want to reset this config to your custom default config? + Do you want to reset this config to your custom default config? + + + Reset to Default + Reset to Default + ElfViewer @@ -775,6 +846,10 @@ Delete DLC DLC-k törlése + + Delete Trophy + Delete Trophy + Compatibility... Compatibility... @@ -807,10 +882,6 @@ Error creating shortcut! Hiba a parancsikon létrehozásával! - - Install PKG - PKG telepítése - Game Játék @@ -851,6 +922,10 @@ This game has no update folder to open! This game has no update folder to open! + + No log file found for this game! + No log file found for this game! + Failed to convert icon. Failed to convert icon. @@ -859,32 +934,255 @@ This game has no save data to delete! This game has no save data to delete! + + This game has no saved trophies to delete! + This game has no saved trophies to delete! + Save Data Save Data + + Trophy + Trophy + SFO Viewer for SFO Viewer for - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - shadPS4 - Mappa kiválasztása + Quickstart + Quickstart - Select which directory you want to install to. - Válassza ki a mappát a játékok telepítésére. + FAQ + FAQ - Install All Queued to Selected Folder - Install All Queued to Selected Folder + Syntax + Syntax - Delete PKG File on Install - Delete PKG File on Install + Special Bindings + Special Bindings + + + Keybindings + Keybindings + + + + KBMSettings + + Configure Controls + Configure Controls + + + D-Pad + D-Pad + + + Up + Up + + + unmapped + unmapped + + + Left + Left + + + Right + Right + + + Down + Down + + + Left Analog Halfmode + Left Analog Halfmode + + + hold to move left stick at half-speed + hold to move left stick at half-speed + + + Left Stick + Left Stick + + + Config Selection + Config Selection + + + Common Config + Common Config + + + Use per-game configs + Use per-game configs + + + L1 + L1 + + + L2 + L2 + + + Text Editor + Text Editor + + + Help + Help + + + R1 + R1 + + + R2 + R2 + + + L3 + L3 + + + Touchpad Click + Touchpad Click + + + Mouse to Joystick + Mouse to Joystick + + + *press F7 ingame to activate + *press F7 ingame to activate + + + R3 + R3 + + + Options + Options + + + Mouse Movement Parameters + Mouse Movement Parameters + + + note: click Help Button/Special Keybindings for more information + note: click Help Button/Special Keybindings for more information + + + Face Buttons + Face Buttons + + + Triangle + Triangle + + + Square + Square + + + Circle + Circle + + + Cross + Cross + + + Right Analog Halfmode + Right Analog Halfmode + + + hold to move right stick at half-speed + hold to move right stick at half-speed + + + Right Stick + Right Stick + + + Speed Offset (def 0.125): + Speed Offset (def 0.125): + + + Copy from Common Config + Copy from Common Config + + + Deadzone Offset (def 0.50): + Deadzone Offset (def 0.50): + + + Speed Multiplier (def 1.0): + Speed Multiplier (def 1.0): + + + Common Config Selected + Common Config Selected + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + + + Copy values from Common Config + Copy values from Common Config + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + Do you want to overwrite existing mappings with the mappings from the Common Config? + + + Unable to Save + Unable to Save + + + Cannot bind any unique input more than once + Cannot bind any unique input more than once + + + Press a key + Press a key + + + Cannot set mapping + Cannot set mapping + + + Mousewheel cannot be mapped to stick outputs + Mousewheel cannot be mapped to stick outputs + + + Save + Save + + + Apply + Apply + + + Restore Defaults + Restore Defaults + + + Cancel + Cancel @@ -893,10 +1191,6 @@ Open/Add Elf Folder ELF Mappa Megnyitása/Hozzáadása - - Install Packages (PKG) - PKG-k Telepítése (PKG) - Boot Game Játék Indítása @@ -913,10 +1207,6 @@ Configure... Konfigurálás... - - Install application from a .pkg file - Program telepítése egy .pkg fájlból - Recent Games Legutóbbi Játékok @@ -986,8 +1276,12 @@ Játéklista Dumpolása - PKG Viewer - PKG Nézegető + Trophy Viewer + Trophy Viewer + + + No games found. Please add your games to your library first. + No games found. Please add your games to your library first. Search... @@ -1097,70 +1391,6 @@ Only one file can be selected! Csak egy fájl választható ki! - - PKG Extraction - PKG kicsomagolás - - - Patch detected! - Frissítés észlelve! - - - PKG and Game versions match: - A PKG és a játék verziói egyeznek: - - - Would you like to overwrite? - Szeretné felülírni? - - - PKG Version %1 is older than installed version: - A(z) %1-es PKG verzió régebbi, mint a telepített verzió: - - - Game is installed: - A játék telepítve van: - - - Would you like to install Patch: - Szeretné telepíteni a frissítést: - - - DLC Installation - DLC Telepítés - - - Would you like to install DLC: %1? - Szeretné telepíteni a %1 DLC-t? - - - DLC already installed: - DLC már telepítve: - - - Game already installed - A játék már telepítve van - - - PKG ERROR - PKG HIBA - - - Extracting PKG %1/%2 - PKG kicsomagolása %1/%2 - - - Extraction Finished - Kicsomagolás befejezve - - - Game successfully installed at %1 - A játék sikeresen telepítve itt: %1 - - - File doesn't appear to be a valid PKG file - A fájl nem tűnik érvényes PKG fájlnak - Run Game Run Game @@ -1169,14 +1399,6 @@ Eboot.bin file not found Eboot.bin file not found - - PKG File (*.PKG *.pkg) - PKG File (*.PKG *.pkg) - - - PKG is a patch or DLC, please install the game first! - PKG is a patch or DLC, please install the game first! - Game is already running! Game is already running! @@ -1185,72 +1407,45 @@ shadPS4 shadPS4 - - - PKGViewer - Open Folder - Mappa Megnyitása + Play + Play - PKG ERROR - PKG HIBA + Pause + Pause - Name - Név + Stop + Stop - Serial - Sorozatszám + Restart + Restart - Installed - Installed + Full Screen + Full Screen - Size - Méret + Controllers + Controllers - Category - Category + Keyboard + Keyboard - Type - Type + Refresh List + Refresh List - App Ver - App Ver + Resume + Resume - FW - FW - - - Region - Régió - - - Flags - Flags - - - Path - Útvonal - - - File - Fájl - - - Unknown - Ismeretlen - - - Package - Package + Show Labels Under Icons + Show Labels Under Icons @@ -1279,10 +1474,6 @@ Emulator Emulátor - - Enable Separate Update Folder - Külön Frissítési Mappa Engedélyezése - Default tab when opening settings Alapértelmezett fül a beállítások megnyitásakor @@ -1311,6 +1502,10 @@ Trophy Trophy + + Open the custom trophy images/sounds folder + Open the custom trophy images/sounds folder + Logger Naplózó @@ -1476,8 +1671,8 @@ Title Music - Disable Trophy Pop-ups - Disable Trophy Pop-ups + Disable Trophy Notification + Disable Trophy Notification Background Image @@ -1543,10 +1738,6 @@ Emulator Language:\nSets the language of the emulator's user interface. Emulátor nyelve:\nBeállítja az emulátor felhasználói felületének nyelvét. - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Külön Frissítéi Mappa Engedélyezése:\nEngedélyezi a frissítések külön mappába helyezését, a könnyű kezelésük érdekében. - Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. Indítóképernyő megjelenítése:\nMegjeleníti a játék indítóképernyőjét (különleges képet) a játék elindításakor. @@ -1803,6 +1994,62 @@ Separate Log Files:\nWrites a separate logfile for each game. Separate Log Files:\nWrites a separate logfile for each game. + + Trophy Notification Position + Trophy Notification Position + + + Left + Left + + + Right + Right + + + Top + Top + + + Bottom + Bottom + + + Notification Duration + Notification Duration + + + Portable User Folder + Portable User Folder + + + Create Portable User Folder from Common User Folder + Create Portable User Folder from Common User Folder + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + + + Cannot create portable user folder + Cannot create portable user folder + + + %1 already exists + %1 already exists + + + Portable user folder created + Portable user folder created + + + %1 successfully created. + %1 successfully created. + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + TrophyViewer @@ -1810,5 +2057,25 @@ Trophy Viewer Trófeák Megtekintése + + Select Game: + Select Game: + + + Progress + Progress + + + Show Earned Trophies + Show Earned Trophies + + + Show Not Earned Trophies + Show Not Earned Trophies + + + Show Hidden Trophies + Show Hidden Trophies + diff --git a/src/qt_gui/translations/id_ID.ts b/src/qt_gui/translations/id_ID.ts index 335450ca2..de19824f7 100644 --- a/src/qt_gui/translations/id_ID.ts +++ b/src/qt_gui/translations/id_ID.ts @@ -7,22 +7,22 @@ AboutDialog About shadPS4 - About shadPS4 + Tentang shadPS4 shadPS4 is an experimental open-source emulator for the PlayStation 4. - shadPS4 is an experimental open-source emulator for the PlayStation 4. + shadPS4 adalah emulator sumber terbuka eksperimental untuk PlayStation 4. This software should not be used to play games you have not legally obtained. - This software should not be used to play games you have not legally obtained. + Perangkat lunak ini tidak boleh digunakan untuk memainkan permainan yang tidak Anda peroleh secara legal. CheatsPatches Cheats / Patches for - Cheats / Patches for + Kecurangan / Tambalan untuk Cheats/Patches are experimental.\nUse with caution.\n\nDownload cheats individually by selecting the repository and clicking the download button.\nIn the Patches tab, you can download all patches at once, choose which ones you want to use, and save your selection.\n\nSince we do not develop the Cheats/Patches,\nplease report issues to the cheat author.\n\nCreated a new cheat? Visit:\n @@ -34,7 +34,7 @@ Serial: - Serial: + Seri: Version: @@ -400,38 +400,38 @@ Playable - Playable + Dapat dimainkan ControlSettings Configure Controls - Configure Controls + Konfigurasi Kontrol D-Pad - D-Pad + Tombol arah Up - Up + Atas Left - Left + Kiri Right - Right + Kanan Down - Down + Bawah Left Stick Deadzone (def:2 max:127) - Left Stick Deadzone (def:2 max:127) + Zona Mati Stik Kiri (standar: 2, maksimum: 127) Left Deadzone @@ -541,6 +541,77 @@ Override Color Override Color + + Unable to Save + Unable to Save + + + Cannot bind axis values more than once + Cannot bind axis values more than once + + + Save + Save + + + Apply + Apply + + + Restore Defaults + Restore Defaults + + + Cancel + Cancel + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + Edit Keyboard + Mouse and Controller input bindings + + + Use Per-Game configs + Use Per-Game configs + + + Error + Error + + + Could not open the file for reading + Could not open the file for reading + + + Could not open the file for writing + Could not open the file for writing + + + Save Changes + Save Changes + + + Do you want to save changes? + Do you want to save changes? + + + Help + Help + + + Do you want to reset your custom default config to the original default config? + Do you want to reset your custom default config to the original default config? + + + Do you want to reset this config to your custom default config? + Do you want to reset this config to your custom default config? + + + Reset to Default + Reset to Default + ElfViewer @@ -775,6 +846,10 @@ Delete DLC Delete DLC + + Delete Trophy + Delete Trophy + Compatibility... Compatibility... @@ -807,10 +882,6 @@ Error creating shortcut! Error creating shortcut! - - Install PKG - Install PKG - Game Game @@ -851,6 +922,10 @@ This game has no update folder to open! This game has no update folder to open! + + No log file found for this game! + No log file found for this game! + Failed to convert icon. Failed to convert icon. @@ -859,32 +934,255 @@ This game has no save data to delete! This game has no save data to delete! + + This game has no saved trophies to delete! + This game has no saved trophies to delete! + Save Data Save Data + + Trophy + Trophy + SFO Viewer for SFO Viewer for - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - shadPS4 - Choose directory + Quickstart + Quickstart - Select which directory you want to install to. - Select which directory you want to install to. + FAQ + FAQ - Install All Queued to Selected Folder - Install All Queued to Selected Folder + Syntax + Syntax - Delete PKG File on Install - Delete PKG File on Install + Special Bindings + Special Bindings + + + Keybindings + Keybindings + + + + KBMSettings + + Configure Controls + Configure Controls + + + D-Pad + D-Pad + + + Up + Up + + + unmapped + unmapped + + + Left + Left + + + Right + Right + + + Down + Down + + + Left Analog Halfmode + Left Analog Halfmode + + + hold to move left stick at half-speed + hold to move left stick at half-speed + + + Left Stick + Left Stick + + + Config Selection + Config Selection + + + Common Config + Common Config + + + Use per-game configs + Use per-game configs + + + L1 + L1 + + + L2 + L2 + + + Text Editor + Text Editor + + + Help + Help + + + R1 + R1 + + + R2 + R2 + + + L3 + L3 + + + Touchpad Click + Touchpad Click + + + Mouse to Joystick + Mouse to Joystick + + + *press F7 ingame to activate + *press F7 ingame to activate + + + R3 + R3 + + + Options + Options + + + Mouse Movement Parameters + Mouse Movement Parameters + + + note: click Help Button/Special Keybindings for more information + note: click Help Button/Special Keybindings for more information + + + Face Buttons + Face Buttons + + + Triangle + Triangle + + + Square + Square + + + Circle + Circle + + + Cross + Cross + + + Right Analog Halfmode + Right Analog Halfmode + + + hold to move right stick at half-speed + hold to move right stick at half-speed + + + Right Stick + Right Stick + + + Speed Offset (def 0.125): + Speed Offset (def 0.125): + + + Copy from Common Config + Copy from Common Config + + + Deadzone Offset (def 0.50): + Deadzone Offset (def 0.50): + + + Speed Multiplier (def 1.0): + Speed Multiplier (def 1.0): + + + Common Config Selected + Common Config Selected + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + + + Copy values from Common Config + Copy values from Common Config + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + Do you want to overwrite existing mappings with the mappings from the Common Config? + + + Unable to Save + Unable to Save + + + Cannot bind any unique input more than once + Cannot bind any unique input more than once + + + Press a key + Press a key + + + Cannot set mapping + Cannot set mapping + + + Mousewheel cannot be mapped to stick outputs + Mousewheel cannot be mapped to stick outputs + + + Save + Save + + + Apply + Apply + + + Restore Defaults + Restore Defaults + + + Cancel + Cancel @@ -893,10 +1191,6 @@ Open/Add Elf Folder Open/Add Elf Folder - - Install Packages (PKG) - Install Packages (PKG) - Boot Game Boot Game @@ -913,10 +1207,6 @@ Configure... Configure... - - Install application from a .pkg file - Install application from a .pkg file - Recent Games Recent Games @@ -986,8 +1276,12 @@ Dump Game List - PKG Viewer - PKG Viewer + Trophy Viewer + Trophy Viewer + + + No games found. Please add your games to your library first. + No games found. Please add your games to your library first. Search... @@ -1097,70 +1391,6 @@ Only one file can be selected! Hanya satu file yang bisa dipilih! - - PKG Extraction - Ekstraksi PKG - - - Patch detected! - Patch terdeteksi! - - - PKG and Game versions match: - Versi PKG dan Game cocok: - - - Would you like to overwrite? - Apakah Anda ingin menimpa? - - - PKG Version %1 is older than installed version: - Versi PKG %1 lebih lama dari versi yang terpasang: - - - Game is installed: - Game telah terpasang: - - - Would you like to install Patch: - Apakah Anda ingin menginstal patch: - - - DLC Installation - Instalasi DLC - - - Would you like to install DLC: %1? - Apakah Anda ingin menginstal DLC: %1? - - - DLC already installed: - DLC sudah terpasang: - - - Game already installed - Game sudah terpasang - - - PKG ERROR - KESALAHAN PKG - - - Extracting PKG %1/%2 - Mengekstrak PKG %1/%2 - - - Extraction Finished - Ekstraksi Selesai - - - Game successfully installed at %1 - Game berhasil dipasang di %1 - - - File doesn't appear to be a valid PKG file - File tampaknya bukan file PKG yang valid - Run Game Run Game @@ -1169,14 +1399,6 @@ Eboot.bin file not found Eboot.bin file not found - - PKG File (*.PKG *.pkg) - PKG File (*.PKG *.pkg) - - - PKG is a patch or DLC, please install the game first! - PKG is a patch or DLC, please install the game first! - Game is already running! Game is already running! @@ -1185,72 +1407,45 @@ shadPS4 shadPS4 - - - PKGViewer - Open Folder - Open Folder + Play + Play - PKG ERROR - KESALAHAN PKG + Pause + Pause - Name - Nama + Stop + Stop - Serial - Serial + Restart + Restart - Installed - Installed + Full Screen + Full Screen - Size - Ukuran + Controllers + Controllers - Category - Category + Keyboard + Keyboard - Type - Type + Refresh List + Refresh List - App Ver - App Ver + Resume + Resume - FW - FW - - - Region - Wilayah - - - Flags - Flags - - - Path - Jalur - - - File - File - - - Unknown - Tidak Dikenal - - - Package - Package + Show Labels Under Icons + Show Labels Under Icons @@ -1279,10 +1474,6 @@ Emulator Emulator - - Enable Separate Update Folder - Enable Separate Update Folder - Default tab when opening settings Tab default saat membuka pengaturan @@ -1311,6 +1502,10 @@ Trophy Trophy + + Open the custom trophy images/sounds folder + Open the custom trophy images/sounds folder + Logger Logger @@ -1476,8 +1671,8 @@ Title Music - Disable Trophy Pop-ups - Disable Trophy Pop-ups + Disable Trophy Notification + Disable Trophy Notification Background Image @@ -1543,10 +1738,6 @@ Emulator Language:\nSets the language of the emulator's user interface. Bahasa Emulator:\nMenetapkan bahasa antarmuka pengguna emulator. - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management. - Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. Tampilkan Layar Pembuka:\nMenampilkan layar pembuka permainan (gambar khusus) saat permainan dimulai. @@ -1803,6 +1994,62 @@ Separate Log Files:\nWrites a separate logfile for each game. Separate Log Files:\nWrites a separate logfile for each game. + + Trophy Notification Position + Trophy Notification Position + + + Left + Left + + + Right + Right + + + Top + Top + + + Bottom + Bottom + + + Notification Duration + Notification Duration + + + Portable User Folder + Portable User Folder + + + Create Portable User Folder from Common User Folder + Create Portable User Folder from Common User Folder + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + + + Cannot create portable user folder + Cannot create portable user folder + + + %1 already exists + %1 already exists + + + Portable user folder created + Portable user folder created + + + %1 successfully created. + %1 successfully created. + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + TrophyViewer @@ -1810,5 +2057,25 @@ Trophy Viewer Trophy Viewer + + Select Game: + Select Game: + + + Progress + Progress + + + Show Earned Trophies + Show Earned Trophies + + + Show Not Earned Trophies + Show Not Earned Trophies + + + Show Hidden Trophies + Show Hidden Trophies + diff --git a/src/qt_gui/translations/it_IT.ts b/src/qt_gui/translations/it_IT.ts index fd1f4d521..8c9e53611 100644 --- a/src/qt_gui/translations/it_IT.ts +++ b/src/qt_gui/translations/it_IT.ts @@ -138,7 +138,7 @@ File Exists - Il file è presente + Il file esiste già File already exists. Do you want to replace it? @@ -541,6 +541,77 @@ Override Color Sostituisci Colore + + Unable to Save + Impossibile Salvare + + + Cannot bind axis values more than once + Impossibile associare i valori degli assi più di una volta + + + Save + Salva + + + Apply + Applica + + + Restore Defaults + Ripristina Impostazioni Predefinite + + + Cancel + Annulla + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + Modifica le associazioni di input di tastiera + mouse e controller + + + Use Per-Game configs + Usa Configurazioni Per Gioco + + + Error + Errore + + + Could not open the file for reading + Impossibile aprire il file per la lettura + + + Could not open the file for writing + Impossibile aprire il file per la scrittura + + + Save Changes + Salva Modifiche + + + Do you want to save changes? + Vuoi salvare le modifiche? + + + Help + Aiuto + + + Do you want to reset your custom default config to the original default config? + Vuoi reimpostare la configurazione predefinita personalizzata alla configurazione predefinita originale? + + + Do you want to reset this config to your custom default config? + Vuoi reimpostare questa configurazione alla configurazione predefinita personalizzata? + + + Reset to Default + Ripristina a Predefinito + ElfViewer @@ -775,6 +846,10 @@ Delete DLC Elimina DLC + + Delete Trophy + Elimina Trofei + Compatibility... Compatibilità... @@ -807,10 +882,6 @@ Error creating shortcut! Errore nella creazione della scorciatoia! - - Install PKG - Installa PKG - Game Gioco @@ -851,6 +922,10 @@ This game has no update folder to open! Questo gioco non ha nessuna cartella di aggiornamento da aprire! + + No log file found for this game! + Nessun file di log trovato per questo gioco! + Failed to convert icon. Impossibile convertire l'icona. @@ -859,32 +934,255 @@ This game has no save data to delete! Questo gioco non ha alcun salvataggio dati da eliminare! + + This game has no saved trophies to delete! + Questo gioco non ha nessun trofeo salvato da eliminare! + Save Data Dati Salvataggio + + Trophy + Trofei + SFO Viewer for Visualizzatore SFO per - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - shadPS4 - Scegli cartella + Quickstart + Avvio rapido - Select which directory you want to install to. - Seleziona in quale cartella vuoi effettuare l'installazione. + FAQ + FAQ - Install All Queued to Selected Folder - Installa tutto in coda nella Cartella Selezionata + Syntax + Sintassi - Delete PKG File on Install - Elimina file PKG dopo Installazione + Special Bindings + Associazioni Speciali + + + Keybindings + Associazioni dei pulsanti + + + + KBMSettings + + Configure Controls + Configura Comandi + + + D-Pad + Croce direzionale + + + Up + Su + + + unmapped + non mappato + + + Left + Sinistra + + + Right + Destra + + + Down + Giù + + + Left Analog Halfmode + Mezza Modalità Analogico Sinistra + + + hold to move left stick at half-speed + tieni premuto per muovere la levetta analogica sinistra a metà velocità + + + Left Stick + Levetta Sinistra + + + Config Selection + Selezione Configurazione + + + Common Config + Configurazione Comune + + + Use per-game configs + Usa configurazioni per gioco + + + L1 + L1 + + + L2 + L2 + + + Text Editor + Editor Testuale + + + Help + Aiuto + + + R1 + R1 + + + R2 + R2 + + + L3 + L3 + + + Touchpad Click + Click Touchpad + + + Mouse to Joystick + Mouse a Joystick + + + *press F7 ingame to activate + *premere F7 in gioco per attivare + + + R3 + R3 + + + Options + Opzioni + + + Mouse Movement Parameters + Parametri Movimento Del Mouse + + + note: click Help Button/Special Keybindings for more information + nota: cliccare sul Pulsante Aiuto/Associazioni Speciali dei Tasti per maggiori informazioni + + + Face Buttons + Pulsanti Frontali + + + Triangle + Triangolo + + + Square + Quadrato + + + Circle + Cerchio + + + Cross + Croce + + + Right Analog Halfmode + Mezza Modalità Analogico Destra + + + hold to move right stick at half-speed + tieni premuto per muovere la levetta analogica destra a metà velocità + + + Right Stick + Levetta Destra + + + Speed Offset (def 0.125): + Scostamento Velocità (def 0,125): + + + Copy from Common Config + Copia da Configurazione Comune + + + Deadzone Offset (def 0.50): + Scostamento Zona Morta (def 0,50): + + + Speed Multiplier (def 1.0): + Moltiplicatore Di Velocità (def 1,0): + + + Common Config Selected + Configurazione Comune Selezionata + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + Questo pulsante copia le mappature dalla Configurazione Comune al profilo attualmente selezionato, e non può essere usato quando il profilo attualmente selezionato è Configurazione Comune. + + + Copy values from Common Config + Copia valori da Configurazione Comune + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + Vuoi sovrascrivere le mappature esistenti con le mappature dalla Configurazione Comune? + + + Unable to Save + Impossibile Salvare + + + Cannot bind any unique input more than once + Non è possibile associare qualsiasi input univoco più di una volta + + + Press a key + Premi un tasto + + + Cannot set mapping + Impossibile impostare la mappatura + + + Mousewheel cannot be mapped to stick outputs + La rotella del mouse non può essere associata ai comandi della levetta analogica + + + Save + Salva + + + Apply + Applica + + + Restore Defaults + Ripristina Impostazioni Predefinite + + + Cancel + Annulla @@ -893,10 +1191,6 @@ Open/Add Elf Folder Apri/Aggiungi cartella Elf - - Install Packages (PKG) - Installa Pacchetti (PKG) - Boot Game Avvia Gioco @@ -913,10 +1207,6 @@ Configure... Configura... - - Install application from a .pkg file - Installa applicazione da un file .pkg - Recent Games Giochi Recenti @@ -986,8 +1276,12 @@ Scarica Lista Giochi - PKG Viewer - Visualizzatore PKG + Trophy Viewer + Visualizzatore Trofei + + + No games found. Please add your games to your library first. + Nessun gioco trovato. Aggiungi prima i tuoi giochi alla tua libreria. Search... @@ -1097,70 +1391,6 @@ Only one file can be selected! Si può selezionare solo un file! - - PKG Extraction - Estrazione file PKG - - - Patch detected! - Patch rilevata! - - - PKG and Game versions match: - Le versioni di PKG e del Gioco corrispondono: - - - Would you like to overwrite? - Vuoi sovrascrivere? - - - PKG Version %1 is older than installed version: - La versione PKG %1 è più vecchia rispetto alla versione installata: - - - Game is installed: - Gioco installato: - - - Would you like to install Patch: - Vuoi installare la patch: - - - DLC Installation - Installazione DLC - - - Would you like to install DLC: %1? - Vuoi installare il DLC: %1? - - - DLC already installed: - DLC già installato: - - - Game already installed - Gioco già installato - - - PKG ERROR - ERRORE PKG - - - Extracting PKG %1/%2 - Estrazione file PKG %1/%2 - - - Extraction Finished - Estrazione Completata - - - Game successfully installed at %1 - Gioco installato correttamente in %1 - - - File doesn't appear to be a valid PKG file - Il file sembra non essere un file PKG valido - Run Game Esegui Gioco @@ -1169,14 +1399,6 @@ Eboot.bin file not found File Eboot.bin non trovato - - PKG File (*.PKG *.pkg) - File PKG (*.PKG *.pkg) - - - PKG is a patch or DLC, please install the game first! - Il file PKG è una patch o DLC, si prega di installare prima il gioco! - Game is already running! Il gioco è già in esecuzione! @@ -1185,72 +1407,45 @@ shadPS4 shadPS4 - - - PKGViewer - Open Folder - Apri Cartella + Play + Riproduci - PKG ERROR - ERRORE PKG + Pause + Pausa - Name - Nome + Stop + Arresta - Serial - Seriale + Restart + Riavvia - Installed - Installato + Full Screen + Schermo Intero - Size - Dimensione + Controllers + Controller - Category - Categoria + Keyboard + Tastiera - Type - Tipo + Refresh List + Aggiorna Lista - App Ver - Vers. App. + Resume + Riprendi - FW - FW - - - Region - Regione - - - Flags - Segnalazioni - - - Path - Percorso - - - File - File - - - Unknown - Sconosciuto - - - Package - Pacchetto + Show Labels Under Icons + Mostra Etichette Sotto Icone @@ -1279,10 +1474,6 @@ Emulator Emulatore - - Enable Separate Update Folder - Abilita Cartella Aggiornamenti Separata - Default tab when opening settings Scheda predefinita all'apertura delle impostazioni @@ -1311,6 +1502,10 @@ Trophy Trofei + + Open the custom trophy images/sounds folder + Apri la cartella personalizzata delle immagini/suoni dei trofei + Logger Registro @@ -1476,8 +1671,8 @@ Musica del Titolo - Disable Trophy Pop-ups - Disabilita Notifica Trofei + Disable Trophy Notification + Disabilita Notifiche Trofei Background Image @@ -1543,10 +1738,6 @@ Emulator Language:\nSets the language of the emulator's user interface. Lingua dell'Emulatore:\nImposta la lingua dell'interfaccia utente dell'emulatore. - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Abilita Cartella Aggiornamenti Separata:\nAbilita l'installazione degli aggiornamenti in una cartella separata per una più facile gestione. - Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. Mostra Schermata di Avvio:\nMostra la schermata di avvio del gioco (un'immagine speciale) mentre il gioco si sta avviando. @@ -1803,6 +1994,62 @@ Separate Log Files:\nWrites a separate logfile for each game. File di registro separati:\nScrive un file di registro separato per ogni gioco. + + Trophy Notification Position + Posizione Notifica Trofei + + + Left + Sinistra + + + Right + Destra + + + Top + In alto + + + Bottom + In basso + + + Notification Duration + Durata Notifica + + + Portable User Folder + Cartella Utente Portatile + + + Create Portable User Folder from Common User Folder + Crea una Cartella Utente Portatile dalla Cartella Comune Utente + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + Cartella utente portatile:\nMemorizza le impostazioni e i dati shadPS4 che saranno applicati solo alla build shadPS4 situata nella cartella attuale. Riavviare l'applicazione dopo aver creato la cartella utente portatile per iniziare a usarla. + + + Cannot create portable user folder + Impossibile creare la cartella utente portatile + + + %1 already exists + %1: esiste già + + + Portable user folder created + Cartella utente portatile creata + + + %1 successfully created. + %1 creato con successo. + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + Apri la cartella personalizzata delle immagini/suoni trofei:\nÈ possibile aggiungere immagini personalizzate ai trofei e un audio.\nAggiungi i file a custom_trophy con i seguenti nomi:\ntrophy.wav OPPURE trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNota: Il suono funzionerà solo nelle versioni QT. + TrophyViewer @@ -1810,5 +2057,25 @@ Trophy Viewer Visualizzatore Trofei + + Select Game: + Seleziona Gioco: + + + Progress + Progresso + + + Show Earned Trophies + Mostra Trofei Guadagnati + + + Show Not Earned Trophies + Mostra Trofei Non Guadagnati + + + Show Hidden Trophies + Mostra Trofei Nascosti + diff --git a/src/qt_gui/translations/ja_JP.ts b/src/qt_gui/translations/ja_JP.ts index 6e11dfe0c..146caa515 100644 --- a/src/qt_gui/translations/ja_JP.ts +++ b/src/qt_gui/translations/ja_JP.ts @@ -541,6 +541,77 @@ Override Color Override Color + + Unable to Save + Unable to Save + + + Cannot bind axis values more than once + Cannot bind axis values more than once + + + Save + Save + + + Apply + Apply + + + Restore Defaults + Restore Defaults + + + Cancel + Cancel + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + Edit Keyboard + Mouse and Controller input bindings + + + Use Per-Game configs + Use Per-Game configs + + + Error + Error + + + Could not open the file for reading + Could not open the file for reading + + + Could not open the file for writing + Could not open the file for writing + + + Save Changes + Save Changes + + + Do you want to save changes? + Do you want to save changes? + + + Help + Help + + + Do you want to reset your custom default config to the original default config? + Do you want to reset your custom default config to the original default config? + + + Do you want to reset this config to your custom default config? + Do you want to reset this config to your custom default config? + + + Reset to Default + Reset to Default + ElfViewer @@ -775,6 +846,10 @@ Delete DLC DLCを削除 + + Delete Trophy + Delete Trophy + Compatibility... 互換性... @@ -807,10 +882,6 @@ Error creating shortcut! ショートカットの作成に失敗しました! - - Install PKG - PKGをインストール - Game ゲーム @@ -851,6 +922,10 @@ This game has no update folder to open! このゲームにはアップデートフォルダがありません! + + No log file found for this game! + No log file found for this game! + Failed to convert icon. アイコンの変換に失敗しました。 @@ -859,32 +934,255 @@ This game has no save data to delete! このゲームには削除するセーブデータがありません! + + This game has no saved trophies to delete! + This game has no saved trophies to delete! + Save Data Save Data + + Trophy + Trophy + SFO Viewer for SFO Viewer for - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - shadPS4 - ディレクトリを選択 + Quickstart + Quickstart - Select which directory you want to install to. - インストール先のディレクトリを選択してください。 + FAQ + FAQ - Install All Queued to Selected Folder - Install All Queued to Selected Folder + Syntax + Syntax - Delete PKG File on Install - インストール時にPKGファイルを削除 + Special Bindings + Special Bindings + + + Keybindings + Keybindings + + + + KBMSettings + + Configure Controls + Configure Controls + + + D-Pad + D-Pad + + + Up + Up + + + unmapped + unmapped + + + Left + Left + + + Right + Right + + + Down + Down + + + Left Analog Halfmode + Left Analog Halfmode + + + hold to move left stick at half-speed + hold to move left stick at half-speed + + + Left Stick + Left Stick + + + Config Selection + Config Selection + + + Common Config + Common Config + + + Use per-game configs + Use per-game configs + + + L1 + L1 + + + L2 + L2 + + + Text Editor + Text Editor + + + Help + Help + + + R1 + R1 + + + R2 + R2 + + + L3 + L3 + + + Touchpad Click + Touchpad Click + + + Mouse to Joystick + Mouse to Joystick + + + *press F7 ingame to activate + *press F7 ingame to activate + + + R3 + R3 + + + Options + Options + + + Mouse Movement Parameters + Mouse Movement Parameters + + + note: click Help Button/Special Keybindings for more information + note: click Help Button/Special Keybindings for more information + + + Face Buttons + Face Buttons + + + Triangle + Triangle + + + Square + Square + + + Circle + Circle + + + Cross + Cross + + + Right Analog Halfmode + Right Analog Halfmode + + + hold to move right stick at half-speed + hold to move right stick at half-speed + + + Right Stick + Right Stick + + + Speed Offset (def 0.125): + Speed Offset (def 0.125): + + + Copy from Common Config + Copy from Common Config + + + Deadzone Offset (def 0.50): + Deadzone Offset (def 0.50): + + + Speed Multiplier (def 1.0): + Speed Multiplier (def 1.0): + + + Common Config Selected + Common Config Selected + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + + + Copy values from Common Config + Copy values from Common Config + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + Do you want to overwrite existing mappings with the mappings from the Common Config? + + + Unable to Save + Unable to Save + + + Cannot bind any unique input more than once + Cannot bind any unique input more than once + + + Press a key + Press a key + + + Cannot set mapping + Cannot set mapping + + + Mousewheel cannot be mapped to stick outputs + Mousewheel cannot be mapped to stick outputs + + + Save + Save + + + Apply + Apply + + + Restore Defaults + Restore Defaults + + + Cancel + Cancel @@ -893,10 +1191,6 @@ Open/Add Elf Folder Elfフォルダを開く/追加する - - Install Packages (PKG) - パッケージをインストール (PKG) - Boot Game ゲームを起動 @@ -913,10 +1207,6 @@ Configure... 設定... - - Install application from a .pkg file - .pkgファイルからアプリケーションをインストール - Recent Games 最近プレイしたゲーム @@ -986,8 +1276,12 @@ ゲームリストをダンプ - PKG Viewer - PKGビューアー + Trophy Viewer + Trophy Viewer + + + No games found. Please add your games to your library first. + No games found. Please add your games to your library first. Search... @@ -1097,70 +1391,6 @@ Only one file can be selected! 1つのファイルしか選択できません! - - PKG Extraction - PKGの抽出 - - - Patch detected! - パッチが検出されました! - - - PKG and Game versions match: - PKGとゲームのバージョンが一致しています: - - - Would you like to overwrite? - 上書きしてもよろしいですか? - - - PKG Version %1 is older than installed version: - PKGバージョン %1 はインストールされているバージョンよりも古いです: - - - Game is installed: - ゲームはインストール済みです: - - - Would you like to install Patch: - パッチをインストールしてもよろしいですか: - - - DLC Installation - DLCのインストール - - - Would you like to install DLC: %1? - DLCをインストールしてもよろしいですか: %1? - - - DLC already installed: - DLCはすでにインストールされています: - - - Game already installed - ゲームはすでにインストールされています - - - PKG ERROR - PKGエラー - - - Extracting PKG %1/%2 - PKGを抽出中 %1/%2 - - - Extraction Finished - 抽出完了 - - - Game successfully installed at %1 - ゲームが %1 に正常にインストールされました - - - File doesn't appear to be a valid PKG file - ファイルが有効なPKGファイルでないようです - Run Game ゲームを実行 @@ -1169,14 +1399,6 @@ Eboot.bin file not found Eboot.bin ファイルが見つかりません - - PKG File (*.PKG *.pkg) - PKGファイル (*.PKG *.pkg) - - - PKG is a patch or DLC, please install the game first! - PKG is a patch or DLC, please install the game first! - Game is already running! ゲームは既に実行されています! @@ -1185,72 +1407,45 @@ shadPS4 shadPS4 - - - PKGViewer - Open Folder - フォルダーを開く + Play + Play - PKG ERROR - PKGエラー + Pause + Pause - Name - 名前 + Stop + Stop - Serial - シリアル + Restart + Restart - Installed - Installed + Full Screen + Full Screen - Size - サイズ + Controllers + Controllers - Category - Category + Keyboard + Keyboard - Type - Type + Refresh List + Refresh List - App Ver - App Ver + Resume + Resume - FW - FW - - - Region - 地域 - - - Flags - Flags - - - Path - パス - - - File - ファイル - - - Unknown - 不明 - - - Package - パッケージ + Show Labels Under Icons + Show Labels Under Icons @@ -1279,10 +1474,6 @@ Emulator エミュレーター - - Enable Separate Update Folder - アップデートフォルダの分離を有効化 - Default tab when opening settings 設定を開くときのデフォルトタブ @@ -1311,6 +1502,10 @@ Trophy トロフィー + + Open the custom trophy images/sounds folder + Open the custom trophy images/sounds folder + Logger ロガー @@ -1476,8 +1671,8 @@ Title Music - Disable Trophy Pop-ups - トロフィーのポップアップを無効化 + Disable Trophy Notification + Disable Trophy Notification Background Image @@ -1543,10 +1738,6 @@ Emulator Language:\nSets the language of the emulator's user interface. エミュレーターの言語:\nエミュレーターのユーザーインターフェースの言語を設定します。 - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Enable Separate Update Folder:\nゲームのアップデートを別のフォルダにインストールすることで、管理が容易になります。 - Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. スプラッシュスクリーンを表示:\nゲーム起動中にゲームのスプラッシュスクリーン(特別な画像)を表示します。 @@ -1803,6 +1994,62 @@ Separate Log Files:\nWrites a separate logfile for each game. Separate Log Files:\nWrites a separate logfile for each game. + + Trophy Notification Position + Trophy Notification Position + + + Left + Left + + + Right + Right + + + Top + Top + + + Bottom + Bottom + + + Notification Duration + Notification Duration + + + Portable User Folder + Portable User Folder + + + Create Portable User Folder from Common User Folder + Create Portable User Folder from Common User Folder + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + + + Cannot create portable user folder + Cannot create portable user folder + + + %1 already exists + %1 already exists + + + Portable user folder created + Portable user folder created + + + %1 successfully created. + %1 successfully created. + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + TrophyViewer @@ -1810,5 +2057,25 @@ Trophy Viewer トロフィービューアー + + Select Game: + Select Game: + + + Progress + Progress + + + Show Earned Trophies + Show Earned Trophies + + + Show Not Earned Trophies + Show Not Earned Trophies + + + Show Hidden Trophies + Show Hidden Trophies + diff --git a/src/qt_gui/translations/ko_KR.ts b/src/qt_gui/translations/ko_KR.ts index ad24f6f54..b79959d38 100644 --- a/src/qt_gui/translations/ko_KR.ts +++ b/src/qt_gui/translations/ko_KR.ts @@ -541,6 +541,77 @@ Override Color Override Color + + Unable to Save + Unable to Save + + + Cannot bind axis values more than once + Cannot bind axis values more than once + + + Save + Save + + + Apply + Apply + + + Restore Defaults + Restore Defaults + + + Cancel + Cancel + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + Edit Keyboard + Mouse and Controller input bindings + + + Use Per-Game configs + Use Per-Game configs + + + Error + Error + + + Could not open the file for reading + Could not open the file for reading + + + Could not open the file for writing + Could not open the file for writing + + + Save Changes + Save Changes + + + Do you want to save changes? + Do you want to save changes? + + + Help + Help + + + Do you want to reset your custom default config to the original default config? + Do you want to reset your custom default config to the original default config? + + + Do you want to reset this config to your custom default config? + Do you want to reset this config to your custom default config? + + + Reset to Default + Reset to Default + ElfViewer @@ -775,6 +846,10 @@ Delete DLC Delete DLC + + Delete Trophy + Delete Trophy + Compatibility... Compatibility... @@ -807,10 +882,6 @@ Error creating shortcut! Error creating shortcut! - - Install PKG - Install PKG - Game Game @@ -851,6 +922,10 @@ This game has no update folder to open! This game has no update folder to open! + + No log file found for this game! + No log file found for this game! + Failed to convert icon. Failed to convert icon. @@ -859,32 +934,255 @@ This game has no save data to delete! This game has no save data to delete! + + This game has no saved trophies to delete! + This game has no saved trophies to delete! + Save Data Save Data + + Trophy + Trophy + SFO Viewer for SFO Viewer for - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - shadPS4 - Choose directory + Quickstart + Quickstart - Select which directory you want to install to. - Select which directory you want to install to. + FAQ + FAQ - Install All Queued to Selected Folder - Install All Queued to Selected Folder + Syntax + Syntax - Delete PKG File on Install - Delete PKG File on Install + Special Bindings + Special Bindings + + + Keybindings + Keybindings + + + + KBMSettings + + Configure Controls + Configure Controls + + + D-Pad + D-Pad + + + Up + Up + + + unmapped + unmapped + + + Left + Left + + + Right + Right + + + Down + Down + + + Left Analog Halfmode + Left Analog Halfmode + + + hold to move left stick at half-speed + hold to move left stick at half-speed + + + Left Stick + Left Stick + + + Config Selection + Config Selection + + + Common Config + Common Config + + + Use per-game configs + Use per-game configs + + + L1 + L1 + + + L2 + L2 + + + Text Editor + Text Editor + + + Help + Help + + + R1 + R1 + + + R2 + R2 + + + L3 + L3 + + + Touchpad Click + Touchpad Click + + + Mouse to Joystick + Mouse to Joystick + + + *press F7 ingame to activate + *press F7 ingame to activate + + + R3 + R3 + + + Options + Options + + + Mouse Movement Parameters + Mouse Movement Parameters + + + note: click Help Button/Special Keybindings for more information + note: click Help Button/Special Keybindings for more information + + + Face Buttons + Face Buttons + + + Triangle + Triangle + + + Square + Square + + + Circle + Circle + + + Cross + Cross + + + Right Analog Halfmode + Right Analog Halfmode + + + hold to move right stick at half-speed + hold to move right stick at half-speed + + + Right Stick + Right Stick + + + Speed Offset (def 0.125): + Speed Offset (def 0.125): + + + Copy from Common Config + Copy from Common Config + + + Deadzone Offset (def 0.50): + Deadzone Offset (def 0.50): + + + Speed Multiplier (def 1.0): + Speed Multiplier (def 1.0): + + + Common Config Selected + Common Config Selected + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + + + Copy values from Common Config + Copy values from Common Config + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + Do you want to overwrite existing mappings with the mappings from the Common Config? + + + Unable to Save + Unable to Save + + + Cannot bind any unique input more than once + Cannot bind any unique input more than once + + + Press a key + Press a key + + + Cannot set mapping + Cannot set mapping + + + Mousewheel cannot be mapped to stick outputs + Mousewheel cannot be mapped to stick outputs + + + Save + Save + + + Apply + Apply + + + Restore Defaults + Restore Defaults + + + Cancel + Cancel @@ -893,10 +1191,6 @@ Open/Add Elf Folder Open/Add Elf Folder - - Install Packages (PKG) - Install Packages (PKG) - Boot Game Boot Game @@ -913,10 +1207,6 @@ Configure... Configure... - - Install application from a .pkg file - Install application from a .pkg file - Recent Games Recent Games @@ -986,8 +1276,12 @@ Dump Game List - PKG Viewer - PKG Viewer + Trophy Viewer + Trophy Viewer + + + No games found. Please add your games to your library first. + No games found. Please add your games to your library first. Search... @@ -1097,70 +1391,6 @@ Only one file can be selected! Only one file can be selected! - - PKG Extraction - PKG Extraction - - - Patch detected! - Patch detected! - - - PKG and Game versions match: - PKG and Game versions match: - - - Would you like to overwrite? - Would you like to overwrite? - - - PKG Version %1 is older than installed version: - PKG Version %1 is older than installed version: - - - Game is installed: - Game is installed: - - - Would you like to install Patch: - Would you like to install Patch: - - - DLC Installation - DLC Installation - - - Would you like to install DLC: %1? - Would you like to install DLC: %1? - - - DLC already installed: - DLC already installed: - - - Game already installed - Game already installed - - - PKG ERROR - PKG ERROR - - - Extracting PKG %1/%2 - Extracting PKG %1/%2 - - - Extraction Finished - Extraction Finished - - - Game successfully installed at %1 - Game successfully installed at %1 - - - File doesn't appear to be a valid PKG file - File doesn't appear to be a valid PKG file - Run Game Run Game @@ -1169,14 +1399,6 @@ Eboot.bin file not found Eboot.bin file not found - - PKG File (*.PKG *.pkg) - PKG File (*.PKG *.pkg) - - - PKG is a patch or DLC, please install the game first! - PKG is a patch or DLC, please install the game first! - Game is already running! Game is already running! @@ -1185,72 +1407,45 @@ shadPS4 shadPS4 - - - PKGViewer - Open Folder - Open Folder + Play + Play - PKG ERROR - PKG ERROR + Pause + Pause - Name - Name + Stop + Stop - Serial - Serial + Restart + Restart - Installed - Installed + Full Screen + Full Screen - Size - Size + Controllers + Controllers - Category - Category + Keyboard + Keyboard - Type - Type + Refresh List + Refresh List - App Ver - App Ver + Resume + Resume - FW - FW - - - Region - Region - - - Flags - Flags - - - Path - Path - - - File - File - - - Unknown - 알 수 없음 - - - Package - Package + Show Labels Under Icons + Show Labels Under Icons @@ -1279,10 +1474,6 @@ Emulator Emulator - - Enable Separate Update Folder - Enable Separate Update Folder - Default tab when opening settings 설정 열기 시 기본 탭 @@ -1311,6 +1502,10 @@ Trophy Trophy + + Open the custom trophy images/sounds folder + Open the custom trophy images/sounds folder + Logger Logger @@ -1476,8 +1671,8 @@ Title Music - Disable Trophy Pop-ups - Disable Trophy Pop-ups + Disable Trophy Notification + Disable Trophy Notification Background Image @@ -1543,10 +1738,6 @@ Emulator Language:\nSets the language of the emulator's user interface. Emulator Language:\nSets the language of the emulator's user interface. - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. @@ -1803,6 +1994,62 @@ Separate Log Files:\nWrites a separate logfile for each game. Separate Log Files:\nWrites a separate logfile for each game. + + Trophy Notification Position + Trophy Notification Position + + + Left + Left + + + Right + Right + + + Top + Top + + + Bottom + Bottom + + + Notification Duration + Notification Duration + + + Portable User Folder + Portable User Folder + + + Create Portable User Folder from Common User Folder + Create Portable User Folder from Common User Folder + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + + + Cannot create portable user folder + Cannot create portable user folder + + + %1 already exists + %1 already exists + + + Portable user folder created + Portable user folder created + + + %1 successfully created. + %1 successfully created. + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + TrophyViewer @@ -1810,5 +2057,25 @@ Trophy Viewer Trophy Viewer + + Select Game: + Select Game: + + + Progress + Progress + + + Show Earned Trophies + Show Earned Trophies + + + Show Not Earned Trophies + Show Not Earned Trophies + + + Show Hidden Trophies + Show Hidden Trophies + diff --git a/src/qt_gui/translations/lt_LT.ts b/src/qt_gui/translations/lt_LT.ts index c1886a4fa..03ff5a003 100644 --- a/src/qt_gui/translations/lt_LT.ts +++ b/src/qt_gui/translations/lt_LT.ts @@ -7,7 +7,7 @@ AboutDialog About shadPS4 - About shadPS4 + Apie shadPS4 shadPS4 is an experimental open-source emulator for the PlayStation 4. @@ -15,7 +15,7 @@ This software should not be used to play games you have not legally obtained. - This software should not be used to play games you have not legally obtained. + Ši programa neturėtų būti naudojama žaidimams kurių neturite legaliai įsigiję. @@ -463,7 +463,7 @@ Back - Back + Atgal R1 / RB @@ -519,7 +519,7 @@ Color Adjustment - Color Adjustment + Spalvų Reguliavimas R: @@ -541,6 +541,77 @@ Override Color Override Color + + Unable to Save + Nepavyko Išsaugoti + + + Cannot bind axis values more than once + Cannot bind axis values more than once + + + Save + Save + + + Apply + Apply + + + Restore Defaults + Restore Defaults + + + Cancel + Atšaukti + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + Edit Keyboard + Mouse and Controller input bindings + + + Use Per-Game configs + Use Per-Game configs + + + Error + Error + + + Could not open the file for reading + Could not open the file for reading + + + Could not open the file for writing + Could not open the file for writing + + + Save Changes + Išsaugoti Pakeitimus + + + Do you want to save changes? + Ar norite išsaugoti pakeitimus? + + + Help + Pagalba + + + Do you want to reset your custom default config to the original default config? + Do you want to reset your custom default config to the original default config? + + + Do you want to reset this config to your custom default config? + Do you want to reset this config to your custom default config? + + + Reset to Default + Reset to Default + ElfViewer @@ -775,6 +846,10 @@ Delete DLC Delete DLC + + Delete Trophy + Delete Trophy + Compatibility... Compatibility... @@ -801,19 +876,15 @@ Error - Error + Klaida Error creating shortcut! Error creating shortcut! - - Install PKG - Install PKG - Game - Game + Žaidimas This game has no update to delete! @@ -851,6 +922,10 @@ This game has no update folder to open! This game has no update folder to open! + + No log file found for this game! + No log file found for this game! + Failed to convert icon. Failed to convert icon. @@ -859,32 +934,255 @@ This game has no save data to delete! This game has no save data to delete! + + This game has no saved trophies to delete! + This game has no saved trophies to delete! + Save Data Save Data + + Trophy + Trophy + SFO Viewer for SFO Viewer for - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - shadPS4 - Choose directory + Quickstart + Quickstart - Select which directory you want to install to. - Select which directory you want to install to. + FAQ + FAQ - Install All Queued to Selected Folder - Install All Queued to Selected Folder + Syntax + Syntax - Delete PKG File on Install - Delete PKG File on Install + Special Bindings + Special Bindings + + + Keybindings + Keybindings + + + + KBMSettings + + Configure Controls + Configure Controls + + + D-Pad + D-Pad + + + Up + Up + + + unmapped + unmapped + + + Left + Left + + + Right + Right + + + Down + Down + + + Left Analog Halfmode + Left Analog Halfmode + + + hold to move left stick at half-speed + hold to move left stick at half-speed + + + Left Stick + Left Stick + + + Config Selection + Config Selection + + + Common Config + Common Config + + + Use per-game configs + Use per-game configs + + + L1 + L1 + + + L2 + L2 + + + Text Editor + Text Editor + + + Help + Help + + + R1 + R1 + + + R2 + R2 + + + L3 + L3 + + + Touchpad Click + Touchpad Click + + + Mouse to Joystick + Mouse to Joystick + + + *press F7 ingame to activate + *press F7 ingame to activate + + + R3 + R3 + + + Options + Options + + + Mouse Movement Parameters + Mouse Movement Parameters + + + note: click Help Button/Special Keybindings for more information + note: click Help Button/Special Keybindings for more information + + + Face Buttons + Face Buttons + + + Triangle + Triangle + + + Square + Square + + + Circle + Circle + + + Cross + Cross + + + Right Analog Halfmode + Right Analog Halfmode + + + hold to move right stick at half-speed + hold to move right stick at half-speed + + + Right Stick + Right Stick + + + Speed Offset (def 0.125): + Speed Offset (def 0.125): + + + Copy from Common Config + Copy from Common Config + + + Deadzone Offset (def 0.50): + Deadzone Offset (def 0.50): + + + Speed Multiplier (def 1.0): + Speed Multiplier (def 1.0): + + + Common Config Selected + Common Config Selected + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + + + Copy values from Common Config + Copy values from Common Config + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + Do you want to overwrite existing mappings with the mappings from the Common Config? + + + Unable to Save + Unable to Save + + + Cannot bind any unique input more than once + Cannot bind any unique input more than once + + + Press a key + Press a key + + + Cannot set mapping + Cannot set mapping + + + Mousewheel cannot be mapped to stick outputs + Mousewheel cannot be mapped to stick outputs + + + Save + Save + + + Apply + Apply + + + Restore Defaults + Restore Defaults + + + Cancel + Cancel @@ -893,10 +1191,6 @@ Open/Add Elf Folder Open/Add Elf Folder - - Install Packages (PKG) - Install Packages (PKG) - Boot Game Boot Game @@ -913,10 +1207,6 @@ Configure... Configure... - - Install application from a .pkg file - Install application from a .pkg file - Recent Games Recent Games @@ -986,8 +1276,12 @@ Dump Game List - PKG Viewer - PKG Viewer + Trophy Viewer + Trophy Viewer + + + No games found. Please add your games to your library first. + No games found. Please add your games to your library first. Search... @@ -1097,70 +1391,6 @@ Only one file can be selected! Galite pasirinkti tik vieną failą! - - PKG Extraction - PKG ištraukimas - - - Patch detected! - Rasta atnaujinimą! - - - PKG and Game versions match: - PKG ir žaidimo versijos sutampa: - - - Would you like to overwrite? - Ar norite perrašyti? - - - PKG Version %1 is older than installed version: - PKG versija %1 yra senesnė nei įdiegta versija: - - - Game is installed: - Žaidimas įdiegtas: - - - Would you like to install Patch: - Ar norite įdiegti atnaujinimą: - - - DLC Installation - DLC diegimas - - - Would you like to install DLC: %1? - Ar norite įdiegti DLC: %1? - - - DLC already installed: - DLC jau įdiegtas: - - - Game already installed - Žaidimas jau įdiegtas - - - PKG ERROR - PKG KLAIDA - - - Extracting PKG %1/%2 - Ekstrakcinis PKG %1/%2 - - - Extraction Finished - Ekstrakcija baigta - - - Game successfully installed at %1 - Žaidimas sėkmingai įdiegtas %1 - - - File doesn't appear to be a valid PKG file - Failas atrodo, kad nėra galiojantis PKG failas - Run Game Run Game @@ -1169,14 +1399,6 @@ Eboot.bin file not found Eboot.bin file not found - - PKG File (*.PKG *.pkg) - PKG File (*.PKG *.pkg) - - - PKG is a patch or DLC, please install the game first! - PKG is a patch or DLC, please install the game first! - Game is already running! Game is already running! @@ -1185,72 +1407,45 @@ shadPS4 shadPS4 - - - PKGViewer - Open Folder - Open Folder + Play + Play - PKG ERROR - PKG KLAIDA + Pause + Pause - Name - Vardas + Stop + Stop - Serial - Serijinis numeris + Restart + Restart - Installed - Installed + Full Screen + Full Screen - Size - Dydis + Controllers + Controllers - Category - Category + Keyboard + Keyboard - Type - Type + Refresh List + Refresh List - App Ver - App Ver + Resume + Resume - FW - FW - - - Region - Regionas - - - Flags - Flags - - - Path - Kelias - - - File - File - - - Unknown - Nežinoma - - - Package - Package + Show Labels Under Icons + Show Labels Under Icons @@ -1279,10 +1474,6 @@ Emulator Emulator - - Enable Separate Update Folder - Enable Separate Update Folder - Default tab when opening settings Numatytoji kortelė atidarius nustatymus @@ -1311,6 +1502,10 @@ Trophy Trophy + + Open the custom trophy images/sounds folder + Open the custom trophy images/sounds folder + Logger Logger @@ -1476,8 +1671,8 @@ Title Music - Disable Trophy Pop-ups - Disable Trophy Pop-ups + Disable Trophy Notification + Disable Trophy Notification Background Image @@ -1543,10 +1738,6 @@ Emulator Language:\nSets the language of the emulator's user interface. Emuliatoriaus kalba:\nNustato emuliatoriaus vartotojo sąsajos kalbą. - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. Rodyti paleidimo ekraną:\nPaleidimo metu rodo žaidimo paleidimo ekraną (ypatingą vaizdą). @@ -1803,6 +1994,62 @@ Separate Log Files:\nWrites a separate logfile for each game. Separate Log Files:\nWrites a separate logfile for each game. + + Trophy Notification Position + Trophy Notification Position + + + Left + Left + + + Right + Right + + + Top + Top + + + Bottom + Bottom + + + Notification Duration + Notification Duration + + + Portable User Folder + Portable User Folder + + + Create Portable User Folder from Common User Folder + Create Portable User Folder from Common User Folder + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + + + Cannot create portable user folder + Cannot create portable user folder + + + %1 already exists + %1 already exists + + + Portable user folder created + Portable user folder created + + + %1 successfully created. + %1 successfully created. + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + TrophyViewer @@ -1810,5 +2057,25 @@ Trophy Viewer Trophy Viewer + + Select Game: + Select Game: + + + Progress + Progress + + + Show Earned Trophies + Show Earned Trophies + + + Show Not Earned Trophies + Show Not Earned Trophies + + + Show Hidden Trophies + Show Hidden Trophies + diff --git a/src/qt_gui/translations/nb_NO.ts b/src/qt_gui/translations/nb_NO.ts index daf44c3bb..e937287fd 100644 --- a/src/qt_gui/translations/nb_NO.ts +++ b/src/qt_gui/translations/nb_NO.ts @@ -22,11 +22,11 @@ CheatsPatches Cheats / Patches for - Juks / Programrettelser for + Juks og programrettelser for Cheats/Patches are experimental.\nUse with caution.\n\nDownload cheats individually by selecting the repository and clicking the download button.\nIn the Patches tab, you can download all patches at once, choose which ones you want to use, and save your selection.\n\nSince we do not develop the Cheats/Patches,\nplease report issues to the cheat author.\n\nCreated a new cheat? Visit:\n - Juks/programrettelse er eksperimentelle.\nBruk med forsiktighet.\n\nLast ned juks individuelt ved å velge pakkebrønn og klikke på nedlastingsknappen.\nPå fanen programrettelse kan du laste ned alle programrettelser samtidig, velge hvilke du ønsker å bruke, og lagre valget ditt.\n\nSiden vi ikke utvikler Juks/Programrettelse,\nvær vennlig å rapportere problemer til juks/programrettelse utvikleren.\n\nHar du laget en ny juks? Besøk:\n + Juks og programrettelser er eksperimentelle.\nBruk med forsiktighet.\n\nLast ned juks individuelt ved å velge pakkebrønn og trykke på nedlastingsknappen.\nPå fanen programrettelser kan du laste ned alle programrettelser samtidig, velg hvilke du ønsker å bruke, og lagre valget ditt.\n\nSiden vi ikke utvikler juks eller programrettelser,\nmeld fra om feil til jukse eller programrettelse utvikleren.\n\nHar du utviklet en ny juks? Besøk:\n No Image Available @@ -90,7 +90,7 @@ Patches - Programrettelse + Programrettelser Error @@ -102,7 +102,7 @@ Unable to open files.json for reading. - Kan ikke åpne files.json for lesing. + Klarte ikke åpne files.json for lesing. No patch file found for the current serial. @@ -110,11 +110,11 @@ Unable to open the file for reading. - Kan ikke åpne fila for lesing. + Klarte ikke åpne fila for lesing. Unable to open the file for writing. - Kan ikke åpne fila for skriving. + Klarte ikke åpne fila for skriving. Failed to parse XML: @@ -146,11 +146,11 @@ Failed to save file: - Kunne ikke lagre fila: + Klarte ikke lagre fila: Failed to download file: - Kunne ikke laste ned fila: + Klarte ikke laste ned fila: Cheats Not Found @@ -170,11 +170,11 @@ Failed to save: - Kunne ikke lagre: + Klarte ikke lagre: Failed to download: - Kunne ikke laste ned: + Klarte ikke laste ned: Download Complete @@ -186,11 +186,11 @@ Failed to parse JSON data from HTML. - Kunne ikke analysere JSON-data fra HTML. + Klarte ikke analysere JSON-data fra HTML. Failed to retrieve HTML page. - Kunne ikke hente HTML-side. + Klarte ikke hente HTML-siden. The game is in version: %1 @@ -210,7 +210,7 @@ Failed to open file: - Kunne ikke åpne fila: + Klarte ikke åpne fila: XML ERROR: @@ -230,7 +230,7 @@ Failed to open files.json for reading. - Kunne ikke åpne files.json for lesing. + Klarte ikke åpne files.json for lesing. Name: @@ -265,7 +265,7 @@ Failed to parse update information. - Kunne ikke analysere oppdaterings-informasjonen. + Klarte ikke analysere oppdateringsinformasjon. No pre-releases found. @@ -337,26 +337,26 @@ The update has been downloaded, press OK to install. - Oppdateringen har blitt lastet ned, trykk OK for å installere. + Oppdateringen ble lastet ned, trykk OK for å installere. Failed to save the update file at - Kunne ikke lagre oppdateringsfila på + Klarte ikke lagre oppdateringsfila på Starting Update... - Starter oppdatering... + Starter oppdatering … Failed to create the update script file - Kunne ikke opprette oppdateringsskriptfila + Klarte ikke opprette oppdateringsskriptfila CompatibilityInfoClass Fetching compatibility data, please wait - Henter kompatibilitetsdata, vennligst vent + Henter kompatibilitetsdata, vent litt. Cancel @@ -364,7 +364,7 @@ Loading... - Laster... + Laster … Error @@ -372,11 +372,11 @@ Unable to update compatibility data! Try again later. - Kan ikke oppdatere kompatibilitetsdata! Prøv igjen senere. + Klarte ikke oppdatere kompatibilitetsdata! Prøv igjen senere. Unable to open compatibility_data.json for writing. - Kan ikke åpne compatibility_data.json for skriving. + Klarte ikke åpne compatibility_data.json for skriving. Unknown @@ -407,11 +407,11 @@ ControlSettings Configure Controls - Sett opp kontroller + Kontrolleroppsett D-Pad - D-Pad + Navigasjonsknapper Up @@ -443,7 +443,7 @@ Config Selection - Utvalg av oppsett + Valg av oppsett Common Config @@ -541,6 +541,77 @@ Override Color Overstyr farge + + Unable to Save + Klarte ikke lagre + + + Cannot bind axis values more than once + Kan ikke tildele akseverdier mer enn en gang + + + Save + Lagre + + + Apply + Bruk + + + Restore Defaults + Gjenopprett standardinnstillinger + + + Cancel + Avbryt + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + Rediger oppsett for tastatur, mus og kontroller + + + Use Per-Game configs + Bruk oppsett per spill + + + Error + Feil + + + Could not open the file for reading + Klarte ikke åpne fila for lesing + + + Could not open the file for writing + Klarte ikke åpne fila for skriving + + + Save Changes + Lagre endringer + + + Do you want to save changes? + Vil du lagre endringene? + + + Help + Hjelp + + + Do you want to reset your custom default config to the original default config? + Vil du tilbakestille alle dine tilpassede innstillinger til standarden? + + + Do you want to reset this config to your custom default config? + Vil du tilbakestille dette oppsettet til standard oppsett? + + + Reset to Default + Tilbakestill + ElfViewer @@ -553,7 +624,7 @@ GameInfoClass Loading game list, please wait :3 - Laster spilliste, vennligst vent :3 + Laster spilliste, vent litt :3 Cancel @@ -561,7 +632,7 @@ Loading... - Laster... + Laster … @@ -651,7 +722,7 @@ Game does not initialize properly / crashes the emulator - Spillet initialiseres ikke riktig / krasjer emulatoren + Spillet initialiseres ikke riktig eller krasjer emulatoren Game boots, but only displays a blank screen @@ -671,7 +742,7 @@ Click to see details on github - Klikk for å se detaljer på GitHub + Trykk for å se detaljer på GitHub Last updated @@ -709,11 +780,11 @@ Cheats / Patches - Juks / Programrettelse + Juks og programrettelser SFO Viewer - SFO viser + SFO-viser Trophy Viewer @@ -721,7 +792,7 @@ Open Folder... - Åpne mappe... + Åpne mappe … Open Game Folder @@ -737,7 +808,7 @@ Copy info... - Kopier info... + Kopier info … Copy Name @@ -761,7 +832,7 @@ Delete... - Slett... + Slett … Delete Game @@ -775,9 +846,13 @@ Delete DLC Slett DLC + + Delete Trophy + Slett trofé + Compatibility... - Kompatibilitet... + Kompatibilitet … Update database @@ -807,10 +882,6 @@ Error creating shortcut! Feil ved opprettelse av snarvei! - - Install PKG - Installer PKG - Game Spill @@ -837,7 +908,7 @@ Are you sure you want to delete %1's %2 directory? - Er du sikker på at du vil slette %1's %2 directory? + Er du sikker på at du vil slette %1's %2 mappa? Open Update Folder @@ -851,6 +922,10 @@ This game has no update folder to open! Dette spillet har ingen oppdateringsmappe å åpne! + + No log file found for this game! + Fant ingen loggfil for dette spillet! + Failed to convert icon. Klarte ikke konvertere ikon. @@ -859,43 +934,262 @@ This game has no save data to delete! Dette spillet har ingen lagret data å slette! + + This game has no saved trophies to delete! + Dette spillet har ingen lagrede trofeer å slette! + Save Data Lagret data + + Trophy + Trofé + SFO Viewer for SFO-viser for - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - shadPS4 - Velg mappe + Quickstart + Hurtigstart - Select which directory you want to install to. - Velg hvilken mappe du vil installere til. + FAQ + Ofte stilte spørsmål - Install All Queued to Selected Folder - Installer alle i kø til den valgte mappa + Syntax + Syntaks - Delete PKG File on Install - Slett PKG-fila ved installering + Special Bindings + Spesielle hurtigtaster + + + Keybindings + Hurtigtast + + + + KBMSettings + + Configure Controls + Tastaturoppsett + + + D-Pad + Navigasjonsknapper + + + Up + Opp + + + unmapped + Ikke satt opp + + + Left + Venstre + + + Right + Høyre + + + Down + Ned + + + Left Analog Halfmode + Venstre analog halvmodus + + + hold to move left stick at half-speed + Hold for å bevege venstre analog med halv hastighet + + + Left Stick + Venstre analog + + + Config Selection + Valg av oppsett + + + Common Config + Felles oppsett + + + Use per-game configs + Bruk oppsett per spill + + + L1 + L1 + + + L2 + L2 + + + Text Editor + Skriveprogram + + + Help + Hjelp + + + R1 + R1 + + + R2 + R2 + + + L3 + L3 + + + Touchpad Click + Berøringsplateknapp + + + Mouse to Joystick + Mus til styrespak + + + *press F7 ingame to activate + Trykk F7 i spillet for å bruke + + + R3 + R3 + + + Options + Options + + + Mouse Movement Parameters + Oppsett av musebevegelse + + + note: click Help Button/Special Keybindings for more information + Merk: Trykk på hjelpeknappen for mer informasjon + + + Face Buttons + Handlingsknapper + + + Triangle + Triangel + + + Square + Firkant + + + Circle + Sirkel + + + Cross + Kryss + + + Right Analog Halfmode + Høyre analog halvmodus + + + hold to move right stick at half-speed + Hold for å bevege høyre analog med halv hastighet + + + Right Stick + Høyre analog + + + Speed Offset (def 0.125): + Hastighetsforskyvning (def 0.125): + + + Copy from Common Config + Kopier fra felles oppsettet + + + Deadzone Offset (def 0.50): + Dødsoneforskyvning (def 0.50): + + + Speed Multiplier (def 1.0): + Hastighetsmultiplikator (def 1.0): + + + Common Config Selected + Felles oppsett valgt + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + Denne knappen kopierer oppsettet fra felles oppsettet til den valgte profilen, og kan ikke brukes når den gjeldende brukte profilen er felles oppsettet. + + + Copy values from Common Config + Kopier verdier fra felles oppsettet + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + Vil du overskrive eksisterende valg av oppsett med felles oppsettet? + + + Unable to Save + Klarte ikke lagre + + + Cannot bind any unique input more than once + Kan ikke tildele unike oppsett mer enn en gang + + + Press a key + Trykk på en tast + + + Cannot set mapping + Klarte ikke tildele + + + Mousewheel cannot be mapped to stick outputs + Musehjulet kan ikke tildeles analogstikkene + + + Save + Lagre + + + Apply + Bruk + + + Restore Defaults + Gjenopprett standardinnstillinger + + + Cancel + Avbryt MainWindow Open/Add Elf Folder - Åpne/Legg til Elf-mappe - - - Install Packages (PKG) - Installer pakker (PKG) + Åpne eller legg til Elf-mappe Boot Game @@ -911,11 +1205,7 @@ Configure... - Sett opp... - - - Install application from a .pkg file - Installer fra en .pkg fil + Sett opp … Recent Games @@ -979,19 +1269,23 @@ Download Cheats/Patches - Last ned juks/programrettelse + Last ned juks og programrettelser Dump Game List Dump spilliste - PKG Viewer - PKG-viser + Trophy Viewer + Troféviser + + + No games found. Please add your games to your library first. + Fant ingen spill. Legg til spillene dine i biblioteket først. Search... - Søk... + Søk … File @@ -1097,70 +1391,6 @@ Only one file can be selected! Kun én fil kan velges! - - PKG Extraction - PKG-utpakking - - - Patch detected! - Programrettelse oppdaget! - - - PKG and Game versions match: - PKG og spillversjoner stemmer overens: - - - Would you like to overwrite? - Ønsker du å overskrive? - - - PKG Version %1 is older than installed version: - PKG-versjon %1 er eldre enn installert versjon: - - - Game is installed: - Spillet er installert: - - - Would you like to install Patch: - Ønsker du å installere programrettelsen: - - - DLC Installation - DLC installasjon - - - Would you like to install DLC: %1? - Ønsker du å installere DLC: %1? - - - DLC already installed: - DLC allerede installert: - - - Game already installed - Spillet er allerede installert - - - PKG ERROR - PKG FEIL - - - Extracting PKG %1/%2 - Pakker ut PKG %1/%2 - - - Extraction Finished - Utpakking fullført - - - Game successfully installed at %1 - Spillet ble installert i %1 - - - File doesn't appear to be a valid PKG file - Fila ser ikke ut til å være en gyldig PKG-fil - Run Game Kjør spill @@ -1169,14 +1399,6 @@ Eboot.bin file not found Klarte ikke finne Eboot.bin-fila - - PKG File (*.PKG *.pkg) - PKG-fil (*.PKG *.pkg) - - - PKG is a patch or DLC, please install the game first! - PKG er en programrettelse eller DLC. Installer spillet først! - Game is already running! Spillet kjører allerede! @@ -1185,72 +1407,45 @@ shadPS4 shadPS4 - - - PKGViewer - Open Folder - Åpne mappe + Play + Spill - PKG ERROR - PKG FEIL + Pause + Pause - Name - Navn + Stop + Stopp - Serial - Serienummer + Restart + Start på nytt - Installed - Installert + Full Screen + Fullskjerm - Size - Størrelse + Controllers + Kontroller - Category - Kategori + Keyboard + Tastatur - Type - Type + Refresh List + Oppdater lista - App Ver - Programversjon + Resume + Gjenoppta - FW - FV - - - Region - Region - - - Flags - Flagg - - - Path - Adresse - - - File - Fil - - - Unknown - Ukjent - - - Package - Pakke + Show Labels Under Icons + Vis merkelapp under ikoner @@ -1261,7 +1456,7 @@ General - Generell + Generelt System @@ -1279,10 +1474,6 @@ Emulator Emulator - - Enable Separate Update Folder - Bruk seperat oppdateringsmappe - Default tab when opening settings Standardfanen når innstillingene åpnes @@ -1311,6 +1502,10 @@ Trophy Trofé + + Open the custom trophy images/sounds folder + Åpne mappa med tilpassede bilder og lyder for trofé + Logger Loggføring @@ -1401,7 +1596,7 @@ Add... - Legg til... + Legg til … Remove @@ -1409,11 +1604,11 @@ Debug - Feilretting + Feilsøking Enable Debug Dumping - Bruk feilrettingsdumping + Bruk feilsøkingsdumping Enable Vulkan Validation Layers @@ -1476,8 +1671,8 @@ Tittelmusikk - Disable Trophy Pop-ups - Deaktiver trofé hurtigmeny + Disable Trophy Notification + Slå av trofévarsler Background Image @@ -1493,7 +1688,7 @@ Play title music - Spill tittelmusikk + Spill av tittelmusikk Update Compatibility Database On Startup @@ -1543,10 +1738,6 @@ Emulator Language:\nSets the language of the emulator's user interface. Emulatorspråket:\nAngir språket for emulatorens brukergrensesnitt. - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Bruk separat oppdateringsmappe:\n Gjør det mulig å installere spilloppdateringer i en egen mappe for enkel administrasjon.\nDette kan gjøres manuelt ved å legge til den utpakkede oppdateringen, til spillmappa med navnet "CUSA00000-UPDATE" der CUSA-ID-en samsvarer med spillets-ID. - Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. Vis velkomstbilde:\nViser spillets velkomstbilde (et spesialbilde) når spillet starter. @@ -1585,7 +1776,7 @@ Disable Trophy Pop-ups:\nDisable in-game trophy notifications. Trophy progress can still be tracked using the Trophy Viewer (right-click the game in the main window). - Deaktiver trofé hurtigmeny:\nDeaktiver trofévarsler i spillet. Trofé-fremgang kan fortsatt ved help av troféviseren (høyreklikk på spillet i hovedvinduet). + Slå av trofévarsler:\nFjerner trofévarsler i spillet. Troféfremgang kan fortsatt vises ved hjelp av troféviseren (høyreklikk på spillet i hovedvinduet). Hide Cursor:\nChoose when the cursor will disappear:\nNever: You will always see the mouse.\nidle: Set a time for it to disappear after being idle.\nAlways: you will never see the mouse. @@ -1625,15 +1816,15 @@ Touchpad Left - Berøringsplate Venstre + Berøringsplate venstre Touchpad Right - Berøringsplate Høyre + Berøringsplate høyre Touchpad Center - Berøringsplate Midt + Berøringsplate midten None @@ -1641,11 +1832,11 @@ Graphics Device:\nOn multiple GPU systems, select the GPU the emulator will use from the drop down list,\nor select "Auto Select" to automatically determine it. - Grafikkenhet:\nI systemer med flere GPU-er, velg GPU-en emulatoren skal bruke fra rullegardinlista,\neller "Velg automatisk&quot. + Grafikkenhet:\nSystemer med flere GPU-er, kan emulatoren velge hvilken enhet som skal brukes fra rullegardinlista,\neller velg "Velg automatisk". Width/Height:\nSets the size of the emulator window at launch, which can be resized during gameplay.\nThis is different from the in-game resolution. - Bredde/Høyde:\nAngir størrelsen på emulatorvinduet ved oppstart, som kan endres under spillingen.\nDette er forskjellig fra oppløsningen i spillet. + Bredde / Høyde:\nAngir størrelsen på emulatorvinduet ved oppstart, som kan endres under spillingen.\nDette er annerledes fra oppløsningen i spillet. Vblank Divider:\nThe frame rate at which the emulator refreshes at is multiplied by this number. Changing this may have adverse effects, such as increasing the game speed, or breaking critical game functionality that does not expect this to change! @@ -1677,7 +1868,7 @@ Enable Debug Dumping:\nSaves the import and export symbols and file header information of the currently running PS4 program to a directory. - Bruk feilrettingsdumping:\nLagrer import- og eksport-symbolene og filoverskrifts-informasjonen til det nåværende kjørende PS4-programmet i en mappe. + Bruk feilsøkingsdumping:\nLagrer import- og eksport-symbolene og filoverskrifts-informasjonen til det nåværende kjørende PS4-programmet i en mappe. Enable Vulkan Validation Layers:\nEnables a system that validates the state of the Vulkan renderer and logs information about its internal state.\nThis will reduce performance and likely change the behavior of emulation. @@ -1733,7 +1924,7 @@ Enable Motion Controls - Bruk bevegelseskontroller + Bruk bevegelsesstyring Save Data Path @@ -1757,7 +1948,7 @@ Directory to install games - Mappe for å installere spill + Mappe for installering av spill Directory to save data @@ -1803,6 +1994,62 @@ Separate Log Files:\nWrites a separate logfile for each game. Separate loggfiler:\nOppretter en separat loggfil for hvert spill. + + Trophy Notification Position + Trofévarsel plassering + + + Left + Venstre + + + Right + Høyre + + + Top + Øverst + + + Bottom + Nederst + + + Notification Duration + Varslingsvarighet + + + Portable User Folder + Separat brukermappe + + + Create Portable User Folder from Common User Folder + Lag ny separat brukermappe fra fellesbrukermappa + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + Separat brukermappe:\n Lagrer shadPS4-innstillinger og data som kun brukes til shadPS4 programmet i gjeldende mappe. Start programmet på nytt etter opprettelsen av mappa for å ta den i bruk. + + + Cannot create portable user folder + Klarte ikke opprette separat brukermappe + + + %1 already exists + %1 finnes allerede + + + Portable user folder created + Separat brukermappe opprettet + + + %1 successfully created. + %1 opprettet. + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + Åpne mappa med tilpassede bilder og lyder for trofé:\nDu kan legge til tilpassede bilder til trofeer og en lyd.\nLegg filene til custom_trophy med følgende navn:\ntrophy.wav ELLER trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nMerk: Lyden avspilles kun i Qt-versjonen. + TrophyViewer @@ -1810,5 +2057,25 @@ Trophy Viewer Troféviser + + Select Game: + Velg spill: + + + Progress + Fremdrift + + + Show Earned Trophies + Vis opptjente trofeer + + + Show Not Earned Trophies + Vis ikke opptjente trofeer + + + Show Hidden Trophies + Vis skjulte trofeer + diff --git a/src/qt_gui/translations/nl_NL.ts b/src/qt_gui/translations/nl_NL.ts index 762254a6e..2d75b74eb 100644 --- a/src/qt_gui/translations/nl_NL.ts +++ b/src/qt_gui/translations/nl_NL.ts @@ -7,7 +7,7 @@ AboutDialog About shadPS4 - About shadPS4 + Over shadPS4 shadPS4 is an experimental open-source emulator for the PlayStation 4. @@ -541,6 +541,77 @@ Override Color Override Color + + Unable to Save + Unable to Save + + + Cannot bind axis values more than once + Cannot bind axis values more than once + + + Save + Save + + + Apply + Apply + + + Restore Defaults + Restore Defaults + + + Cancel + Cancel + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + Edit Keyboard + Mouse and Controller input bindings + + + Use Per-Game configs + Use Per-Game configs + + + Error + Error + + + Could not open the file for reading + + + + Could not open the file for writing + Could not open the file for writing + + + Save Changes + Save Changes + + + Do you want to save changes? + Do you want to save changes? + + + Help + Help + + + Do you want to reset your custom default config to the original default config? + Do you want to reset your custom default config to the original default config? + + + Do you want to reset this config to your custom default config? + Do you want to reset this config to your custom default config? + + + Reset to Default + Reset to Default + ElfViewer @@ -775,6 +846,10 @@ Delete DLC Delete DLC + + Delete Trophy + Delete Trophy + Compatibility... Compatibility... @@ -807,10 +882,6 @@ Error creating shortcut! Error creating shortcut! - - Install PKG - Install PKG - Game Game @@ -851,6 +922,10 @@ This game has no update folder to open! This game has no update folder to open! + + No log file found for this game! + No log file found for this game! + Failed to convert icon. Failed to convert icon. @@ -859,32 +934,255 @@ This game has no save data to delete! This game has no save data to delete! + + This game has no saved trophies to delete! + This game has no saved trophies to delete! + Save Data Save Data + + Trophy + Trophy + SFO Viewer for SFO Viewer for - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - shadPS4 - Choose directory + Quickstart + Quickstart - Select which directory you want to install to. - Select which directory you want to install to. + FAQ + FAQ - Install All Queued to Selected Folder - Install All Queued to Selected Folder + Syntax + Syntax - Delete PKG File on Install - Delete PKG File on Install + Special Bindings + Special Bindings + + + Keybindings + Keybindings + + + + KBMSettings + + Configure Controls + Configure Controls + + + D-Pad + D-Pad + + + Up + Up + + + unmapped + unmapped + + + Left + Left + + + Right + Right + + + Down + Down + + + Left Analog Halfmode + Left Analog Halfmode + + + hold to move left stick at half-speed + hold to move left stick at half-speed + + + Left Stick + Left Stick + + + Config Selection + Config Selection + + + Common Config + Common Config + + + Use per-game configs + Use per-game configs + + + L1 + L1 + + + L2 + L2 + + + Text Editor + Text Editor + + + Help + Help + + + R1 + R1 + + + R2 + R2 + + + L3 + L3 + + + Touchpad Click + Touchpad Click + + + Mouse to Joystick + Mouse to Joystick + + + *press F7 ingame to activate + *press F7 ingame to activate + + + R3 + R3 + + + Options + Options + + + Mouse Movement Parameters + Mouse Movement Parameters + + + note: click Help Button/Special Keybindings for more information + note: click Help Button/Special Keybindings for more information + + + Face Buttons + Face Buttons + + + Triangle + Triangle + + + Square + Square + + + Circle + Circle + + + Cross + Cross + + + Right Analog Halfmode + Right Analog Halfmode + + + hold to move right stick at half-speed + hold to move right stick at half-speed + + + Right Stick + Right Stick + + + Speed Offset (def 0.125): + Speed Offset (def 0.125): + + + Copy from Common Config + Copy from Common Config + + + Deadzone Offset (def 0.50): + Deadzone Offset (def 0.50): + + + Speed Multiplier (def 1.0): + Speed Multiplier (def 1.0): + + + Common Config Selected + Common Config Selected + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + + + Copy values from Common Config + Copy values from Common Config + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + Do you want to overwrite existing mappings with the mappings from the Common Config? + + + Unable to Save + Unable to Save + + + Cannot bind any unique input more than once + Cannot bind any unique input more than once + + + Press a key + Press a key + + + Cannot set mapping + Cannot set mapping + + + Mousewheel cannot be mapped to stick outputs + Mousewheel cannot be mapped to stick outputs + + + Save + Save + + + Apply + Apply + + + Restore Defaults + Restore Defaults + + + Cancel + Cancel @@ -893,10 +1191,6 @@ Open/Add Elf Folder Open/Add Elf Folder - - Install Packages (PKG) - Install Packages (PKG) - Boot Game Boot Game @@ -913,10 +1207,6 @@ Configure... Configure... - - Install application from a .pkg file - Install application from a .pkg file - Recent Games Recent Games @@ -986,8 +1276,12 @@ Dump Game List - PKG Viewer - PKG Viewer + Trophy Viewer + Trophy Viewer + + + No games found. Please add your games to your library first. + No games found. Please add your games to your library first. Search... @@ -1097,70 +1391,6 @@ Only one file can be selected! Je kunt slechts één bestand selecteren! - - PKG Extraction - PKG-extractie - - - Patch detected! - Patch gedetecteerd! - - - PKG and Game versions match: - PKG- en gameversies komen overeen: - - - Would you like to overwrite? - Wilt u overschrijven? - - - PKG Version %1 is older than installed version: - PKG-versie %1 is ouder dan de geïnstalleerde versie: - - - Game is installed: - Game is geïnstalleerd: - - - Would you like to install Patch: - Wilt u de patch installeren: - - - DLC Installation - DLC-installatie - - - Would you like to install DLC: %1? - Wilt u DLC installeren: %1? - - - DLC already installed: - DLC al geïnstalleerd: - - - Game already installed - Game al geïnstalleerd - - - PKG ERROR - PKG FOUT - - - Extracting PKG %1/%2 - PKG %1/%2 aan het extraheren - - - Extraction Finished - Extractie voltooid - - - Game successfully installed at %1 - Spel succesvol geïnstalleerd op %1 - - - File doesn't appear to be a valid PKG file - Het bestand lijkt geen geldig PKG-bestand te zijn - Run Game Run Game @@ -1169,14 +1399,6 @@ Eboot.bin file not found Eboot.bin file not found - - PKG File (*.PKG *.pkg) - PKG File (*.PKG *.pkg) - - - PKG is a patch or DLC, please install the game first! - PKG is a patch or DLC, please install the game first! - Game is already running! Game is already running! @@ -1185,72 +1407,45 @@ shadPS4 shadPS4 - - - PKGViewer - Open Folder - Open Folder + Play + Play - PKG ERROR - PKG FOUT + Pause + Pause - Name - Naam + Stop + Stop - Serial - Serienummer + Restart + Restart - Installed - Installed + Full Screen + Full Screen - Size - Grootte + Controllers + Controllers - Category - Category + Keyboard + Keyboard - Type - Type + Refresh List + Refresh List - App Ver - App Ver + Resume + Resume - FW - FW - - - Region - Regio - - - Flags - Flags - - - Path - Pad - - - File - File - - - Unknown - Onbekend - - - Package - Package + Show Labels Under Icons + Show Labels Under Icons @@ -1279,10 +1474,6 @@ Emulator Emulator - - Enable Separate Update Folder - Enable Separate Update Folder - Default tab when opening settings Standaardtabblad bij het openen van instellingen @@ -1311,6 +1502,10 @@ Trophy Trophy + + Open the custom trophy images/sounds folder + Open the custom trophy images/sounds folder + Logger Logger @@ -1476,8 +1671,8 @@ Title Music - Disable Trophy Pop-ups - Disable Trophy Pop-ups + Disable Trophy Notification + Disable Trophy Notification Background Image @@ -1543,10 +1738,6 @@ Emulator Language:\nSets the language of the emulator's user interface. Emulator Taal:\nStelt de taal van de gebruikersinterface van de emulator in. - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management. - Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. Opstartscherm weergeven:\nToont het opstartscherm van het spel (een speciale afbeelding) tijdens het starten van het spel. @@ -1803,6 +1994,62 @@ Separate Log Files:\nWrites a separate logfile for each game. Separate Log Files:\nWrites a separate logfile for each game. + + Trophy Notification Position + Trophy Notification Position + + + Left + Left + + + Right + Right + + + Top + Top + + + Bottom + Bottom + + + Notification Duration + Notification Duration + + + Portable User Folder + Portable User Folder + + + Create Portable User Folder from Common User Folder + Create Portable User Folder from Common User Folder + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + + + Cannot create portable user folder + Cannot create portable user folder + + + %1 already exists + %1 already exists + + + Portable user folder created + Portable user folder created + + + %1 successfully created. + %1 successfully created. + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + TrophyViewer @@ -1810,5 +2057,25 @@ Trophy Viewer Trophy Viewer + + Select Game: + Select Game: + + + Progress + Progress + + + Show Earned Trophies + Show Earned Trophies + + + Show Not Earned Trophies + Show Not Earned Trophies + + + Show Hidden Trophies + Show Hidden Trophies + diff --git a/src/qt_gui/translations/pl_PL.ts b/src/qt_gui/translations/pl_PL.ts index 407948fae..bd59a1894 100644 --- a/src/qt_gui/translations/pl_PL.ts +++ b/src/qt_gui/translations/pl_PL.ts @@ -541,6 +541,77 @@ Override Color Zastąp kolor + + Unable to Save + Zapisywanie nie powiodło się + + + Cannot bind axis values more than once + Nie można powiązać wartości osi więcej niż raz + + + Save + Zapisz + + + Apply + Zastosuj + + + Restore Defaults + Przywróć ustawienia domyślne + + + Cancel + Anuluj + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + Edytuj przypisanie klawiszy klawiatury + myszy oraz kontrolera + + + Use Per-Game configs + Użyj osobnej konfiguracji dla każdej gry + + + Error + Błąd + + + Could not open the file for reading + Nie można otworzyć pliku do odczytu + + + Could not open the file for writing + Nie można otworzyć pliku do zapisu + + + Save Changes + Zapisać zmiany + + + Do you want to save changes? + Czy chcesz zapisać zmiany? + + + Help + Pomóc + + + Do you want to reset your custom default config to the original default config? + Czy chcesz zresetować Twoją domyślną konfigurację do oryginalnej domyślnej konfiguracji? + + + Do you want to reset this config to your custom default config? + Czy chcesz zresetować tę konfigurację do Twojej domyślnej konfiguracji? + + + Reset to Default + Zresetować do domyślnych + ElfViewer @@ -775,6 +846,10 @@ Delete DLC Usuń dodatkową zawartość (DLC) + + Delete Trophy + Usuń trofeum + Compatibility... Kompatybilność... @@ -807,10 +882,6 @@ Error creating shortcut! Utworzenie skrótu zakończone niepowodzeniem! - - Install PKG - Zainstaluj PKG - Game Gra @@ -851,6 +922,10 @@ This game has no update folder to open! Ta gra nie ma folderu aktualizacji do otwarcia! + + No log file found for this game! + Nie znaleziono pliku dziennika dla tej gry! + Failed to convert icon. Nie udało się przekonwertować ikony. @@ -859,32 +934,255 @@ This game has no save data to delete! Ta gra nie ma zapisów do usunięcia! + + This game has no saved trophies to delete! + Ta gra nie ma zapisanych trofeuów do usunięcia! + Save Data Zapisane dane + + Trophy + Trofeum + SFO Viewer for Menedżer plików SFO dla - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - shadPS4 - Wybierz katalog + Quickstart + Szybki start - Select which directory you want to install to. - Wybierz katalog, do którego chcesz zainstalować. + FAQ + Najczęściej zadawane pytania - Install All Queued to Selected Folder - Zainstaluj wszystkie oczekujące do wybranego folderu + Syntax + Składnia - Delete PKG File on Install - Usuń plik PKG po instalacji + Special Bindings + Specjalne wiązania + + + Keybindings + Przypisanie klawiszy + + + + KBMSettings + + Configure Controls + Skonfiguruj sterowanie + + + D-Pad + Krzyżak + + + Up + Strzałka w górę + + + unmapped + nieprzypisane + + + Left + Strzałka w lewo + + + Right + Strzałka w prawo + + + Down + Strzałka w dół + + + Left Analog Halfmode + Połowiczny tryb lewego drążka + + + hold to move left stick at half-speed + przytrzymaj, aby przesuwać lewy drążek dwa razy wolniej + + + Left Stick + Lewy drążek + + + Config Selection + Wybór konfiguracji + + + Common Config + Typowa konfiguracja + + + Use per-game configs + Użyj osobnej konfiguracji dla każdej gry + + + L1 + L1 + + + L2 + L2 + + + Text Editor + Edytor tekstu + + + Help + Pomoc + + + R1 + R1 + + + R2 + R2 + + + L3 + L3 + + + Touchpad Click + Kliknięcie Touchpada + + + Mouse to Joystick + Mysz na Joystick + + + *press F7 ingame to activate + *naciśnij F7 w grze aby aktywować + + + R3 + R3 + + + Options + Opcje + + + Mouse Movement Parameters + Parametry ruchu myszy + + + note: click Help Button/Special Keybindings for more information + uwaga: kliknij przycisk Pomoc/Specjalne skróty klawiszowe, aby uzyskać więcej informacji + + + Face Buttons + Przednie przyciski + + + Triangle + Trójkąt + + + Square + Kwadrat + + + Circle + Kółko + + + Cross + Krzyżyk + + + Right Analog Halfmode + Połowiczny tryb prawego drążka + + + hold to move right stick at half-speed + przytrzymaj, aby przesuwać prawy drążek dwa razy wolniej + + + Right Stick + Prawy drążek + + + Speed Offset (def 0.125): + Offset prędkości (def 0,125): + + + Copy from Common Config + Kopiuj z typowej konfiguracji + + + Deadzone Offset (def 0.50): + Offset martwych stref (def 0,50): + + + Speed Multiplier (def 1.0): + Mnożnik prędkości (def1.0): + + + Common Config Selected + Wybrano typową konfigurację + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + Przycisk ten kopiuje mapowanie z typowej konfiguracji do aktualnie wybranego profilu, i nie może być użyty, gdy aktualnie wybranym profilem jest typowa konfiguracja. + + + Copy values from Common Config + Kopiuj z typowej konfiguracji + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + Czy chcesz nadpisać istniejące mapowania mapowaniem z typowej konfiguracji? + + + Unable to Save + Zapisywanie nie powiodło się + + + Cannot bind any unique input more than once + Nie można powiązać żadnych unikalnych danych wejściowych więcej niż raz + + + Press a key + Naciśnij klawisz + + + Cannot set mapping + Nie można ustawić mapowania + + + Mousewheel cannot be mapped to stick outputs + Kółko myszy nie może być przypisane do sterowania drążkiem + + + Save + Zapisz + + + Apply + Zastosuj + + + Restore Defaults + Przywróć ustawienia domyślne + + + Cancel + Anuluj @@ -893,10 +1191,6 @@ Open/Add Elf Folder Otwórz/Dodaj folder Elf - - Install Packages (PKG) - Zainstaluj paczkę (PKG) - Boot Game Uruchom grę @@ -913,10 +1207,6 @@ Configure... Konfiguruj... - - Install application from a .pkg file - Zainstaluj aplikacje z pliku .pkg - Recent Games Ostatnie gry @@ -986,8 +1276,12 @@ Zgraj listę gier - PKG Viewer - Menedżer plików PKG + Trophy Viewer + Menedżer trofeów + + + No games found. Please add your games to your library first. + Nie znaleziono gier. Najpierw dodaj swoje gry do swojej biblioteki. Search... @@ -1097,70 +1391,6 @@ Only one file can be selected! Można wybrać tylko jeden plik! - - PKG Extraction - Wypakowywanie PKG - - - Patch detected! - Wykryto łatkę! - - - PKG and Game versions match: - Wersje PKG i gry są zgodne: - - - Would you like to overwrite? - Czy chcesz nadpisać? - - - PKG Version %1 is older than installed version: - Wersja PKG %1 jest starsza niż zainstalowana wersja: - - - Game is installed: - Gra jest zainstalowana: - - - Would you like to install Patch: - Czy chcesz zainstalować łatkę: - - - DLC Installation - Instalacja dodatkowej zawartości (DLC) - - - Would you like to install DLC: %1? - Czy chcesz zainstalować dodatkową zawartość (DLC): %1? - - - DLC already installed: - Dodatkowa zawartość (DLC) już zainstalowana: - - - Game already installed - Gra już zainstalowana - - - PKG ERROR - BŁĄD PKG - - - Extracting PKG %1/%2 - Wypakowywanie PKG %1/%2 - - - Extraction Finished - Wypakowywanie zakończone - - - Game successfully installed at %1 - Gra pomyślnie zainstalowana w %1 - - - File doesn't appear to be a valid PKG file - Plik nie wydaje się być prawidłowym plikiem PKG - Run Game Uruchom grę @@ -1169,14 +1399,6 @@ Eboot.bin file not found Nie znaleziono pliku EBOOT.BIN - - PKG File (*.PKG *.pkg) - Plik PKG (*.PKG *.pkg) - - - PKG is a patch or DLC, please install the game first! - PKG jest aktualizacją lub dodatkową zawartością (DLC), najpierw zainstaluj grę! - Game is already running! Gra jest już uruchomiona! @@ -1185,72 +1407,45 @@ shadPS4 shadPS4 - - - PKGViewer - Open Folder - Otwórz folder + Play + Play - PKG ERROR - BŁĄD PKG + Pause + Pause - Name - Nazwa + Stop + Stop - Serial - Numer seryjny + Restart + Restart - Installed - Zainstalowano + Full Screen + Full Screen - Size - Rozmiar + Controllers + Controllers - Category - Kategoria + Keyboard + Keyboard - Type - Typ + Refresh List + Refresh List - App Ver - Wersja aplikacji + Resume + Resume - FW - Oprogramowanie - - - Region - Region - - - Flags - Flagi - - - Path - Ścieżka - - - File - Plik - - - Unknown - Nieznany - - - Package - Paczka + Show Labels Under Icons + Show Labels Under Icons @@ -1279,10 +1474,6 @@ Emulator Emulator - - Enable Separate Update Folder - Włącz oddzielny folder aktualizacji - Default tab when opening settings Domyślna zakładka podczas otwierania ustawień @@ -1309,7 +1500,11 @@ Trophy - Trofeum + Trofea + + + Open the custom trophy images/sounds folder + Otwórz niestandardowy folder obrazów/dźwięków trofeów Logger @@ -1476,8 +1671,8 @@ Muzyka tytułowa - Disable Trophy Pop-ups - Wyłącz wyskakujące okienka trofeów + Disable Trophy Notification + Wyłącz powiadomienia o trofeach Background Image @@ -1543,10 +1738,6 @@ Emulator Language:\nSets the language of the emulator's user interface. Język emulatora:\nUstala język interfejsu użytkownika emulatora. - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Włącz oddzielny folder aktualizacji:\nUmożliwia instalowanie aktualizacji gier w oddzielnym folderze w celu łatwego zarządzania. - Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. Wyświetl ekran powitalny:\nPodczas uruchamiania gry wyświetla ekran powitalny (specjalny obraz). @@ -1803,6 +1994,62 @@ Separate Log Files:\nWrites a separate logfile for each game. Oddzielne pliki dziennika:\nZapisuje oddzielny plik dziennika dla każdej gry. + + Trophy Notification Position + Pozycja powiadomień trofeów + + + Left + Z lewej + + + Right + Z prawej + + + Top + Z góry + + + Bottom + Z dołu + + + Notification Duration + Czas trwania powiadomienia + + + Portable User Folder + Przenośny folder użytkownika + + + Create Portable User Folder from Common User Folder + Utwórz przenośny folder użytkownika ze zwykłego folderu użytkownika + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + Przenośny folder użytkownika:\nPrzechowuje ustawienia shadPS4 i dane, które zostaną zastosowane tylko do kompilacji shadPS4 znajdującej się w bieżącym folderze. Uruchom ponownie aplikację po utworzeniu przenośnego folderu użytkownika, aby zacząć z niego korzystać. + + + Cannot create portable user folder + Nie można utworzyć przenośnego folderu użytkownika + + + %1 already exists + %1 już istnieje + + + Portable user folder created + Utworzono przenośny folder użytkownika + + + %1 successfully created. + %1 prawidłowo utworzony. + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + Otwórz niestandardowy folder obrazów/dźwięków:\nMożesz dodać własne obrazy dla trofeów i ich dźwięki.\nDodaj pliki do custom_trophy o następujących nazwach:\ntrophy.wav LUB trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nUwaga: Dźwięki działają tylko w wersji QT. + TrophyViewer @@ -1810,5 +2057,25 @@ Trophy Viewer Menedżer trofeów + + Select Game: + Wybierz grę: + + + Progress + Postęp + + + Show Earned Trophies + Pokaż zdobyte trofea + + + Show Not Earned Trophies + Pokaż niezdobyte trofea + + + Show Hidden Trophies + Pokaż ukryte trofea + diff --git a/src/qt_gui/translations/pt_BR.ts b/src/qt_gui/translations/pt_BR.ts index 406109150..584d6dc19 100644 --- a/src/qt_gui/translations/pt_BR.ts +++ b/src/qt_gui/translations/pt_BR.ts @@ -22,11 +22,11 @@ CheatsPatches Cheats / Patches for - Trapaças / Patches para + Trapaças / Modificações para Cheats/Patches are experimental.\nUse with caution.\n\nDownload cheats individually by selecting the repository and clicking the download button.\nIn the Patches tab, you can download all patches at once, choose which ones you want to use, and save your selection.\n\nSince we do not develop the Cheats/Patches,\nplease report issues to the cheat author.\n\nCreated a new cheat? Visit:\n - As Trapaças/Patches são experimentais.\nUse com cautela.\n\nBaixe as trapaças individualmente selecionando o repositório e clicando no botão de baixar.\nNa aba Patches, você pode baixar todos os patches de uma vez, escolha qual deseja usar e salve a opção.\n\nComo não desenvolvemos as Trapaças/Patches,\npor favor, reporte os problemas relacionados ao autor da trapaça.\n\nCriou uma nova trapaça? Visite:\n + As Trapaças/Modificações são experimentais.\nUse com cautela.\n\nBaixe as trapaças individualmente selecionando o repositório e clicando no botão de baixar.\nNa aba Modificações, você pode baixar todas as modificações de uma vez, escolha qual deseja usar e salve a opção.\n\nComo não desenvolvemos as Trapaças/Modificações,\npor favor, reporte os problemas relacionados ao autor da trapaça.\n\nCriou uma nova trapaça? Visite:\n No Image Available @@ -78,7 +78,7 @@ Download Patches - Baixar Patches + Baixar Modificações Save @@ -90,7 +90,7 @@ Patches - Patches + Modificações Error @@ -182,7 +182,7 @@ Patches Downloaded Successfully! All Patches available for all games have been downloaded, there is no need to download them individually for each game as happens in Cheats. If the patch does not appear, it may be that it does not exist for the specific serial and version of the game. - Patches Baixados com Sucesso! Todos os patches disponíveis para todos os jogos foram baixados, não é necessário baixá-los individualmente para cada jogo como acontece em Trapaças. Se o patch não aparecer, pode ser que ele não exista para o serial e versão específicas do jogo. + Modificações Baixados com Sucesso! Todos as modificações disponíveis para todos os jogos foram baixados, não é necessário baixá-los individualmente para cada jogo como acontece em trapaças. Se a modificação não aparecer, pode ser que ela não exista para o serial e versão específicas do jogo. Failed to parse JSON data from HTML. @@ -541,6 +541,77 @@ Override Color Substituir a Cor + + Unable to Save + Não foi possível salvar + + + Cannot bind axis values more than once + Não é possível vincular os valores do eixo mais de uma vez + + + Save + Salvar + + + Apply + Aplicar + + + Restore Defaults + Restaurar Padrões + + + Cancel + Cancelar + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + Editar atalhos de entrada do Teclado + Mouse e do Controle + + + Use Per-Game configs + Usar configurações por jogo + + + Error + Erro + + + Could not open the file for reading + Não foi possível abrir o arquivo para leitura + + + Could not open the file for writing + Não foi possível abrir o arquivo para gravação + + + Save Changes + Salvar Alterações + + + Do you want to save changes? + Gostaria de salvar as alterações? + + + Help + Ajuda + + + Do you want to reset your custom default config to the original default config? + Você gostaria de redefinir sua configuração padrão personalizada de volta para a configuração padrão original? + + + Do you want to reset this config to your custom default config? + Você gostaria de redefinir esta configuração para a sua configuração padrão personalizada? + + + Reset to Default + Redefinir ao Padrão + ElfViewer @@ -627,7 +698,7 @@ Play Time - Tempo Jogado + Tempo de Jogo Never Played @@ -651,7 +722,7 @@ Game does not initialize properly / crashes the emulator - Jogo não inicializa corretamente / trava o emulador + O jogo não inicializa corretamente ou trava o emulador Game boots, but only displays a blank screen @@ -659,7 +730,7 @@ Game displays an image but does not go past the menu - Jogo exibe imagem mas não passa do menu + O jogo exibe imagem mas não passa do menu Game has game-breaking glitches or unplayable performance @@ -709,7 +780,7 @@ Cheats / Patches - Trapaças / Patches + Trapaças / Modificações SFO Viewer @@ -775,6 +846,10 @@ Delete DLC Excluir DLC + + Delete Trophy + Excluir Troféu + Compatibility... Compatibilidade... @@ -807,10 +882,6 @@ Error creating shortcut! Erro ao criar atalho! - - Install PKG - Instalar PKG - Game Jogo @@ -837,7 +908,7 @@ Are you sure you want to delete %1's %2 directory? - Tem certeza de que deseja excluir o diretório %2 de %1? + Tem certeza de que deseja excluir o diretório do %2 %1? Open Update Folder @@ -851,6 +922,10 @@ This game has no update folder to open! Este jogo não possui pasta de atualização para abrir! + + No log file found for this game! + Nenhum arquivo de registro foi encontrado para este jogo! + Failed to convert icon. Falha ao converter o ícone. @@ -859,32 +934,255 @@ This game has no save data to delete! Este jogo não tem dados salvos para excluir! + + This game has no saved trophies to delete! + Este jogo não tem troféus salvos para excluir! + Save Data Dados Salvos + + Trophy + Troféus + SFO Viewer for Visualizador de SFO para - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - shadPS4 - Escolha o diretório + Quickstart + Introdução - Select which directory you want to install to. - Selecione o diretório em que você deseja instalar. + FAQ + Perguntas frequentes - Install All Queued to Selected Folder - Instalar Tudo da Fila para a Pasta Selecionada + Syntax + Sintaxe - Delete PKG File on Install - Excluir o PKG após a Instalação + Special Bindings + Atalhos Especiais + + + Keybindings + Teclas de atalho + + + + KBMSettings + + Configure Controls + Configurar Controles + + + D-Pad + Direcional + + + Up + Cima + + + unmapped + não mapeado + + + Left + Esquerda + + + Right + Direita + + + Down + Baixo + + + Left Analog Halfmode + Meio Analógico Esquerdo + + + hold to move left stick at half-speed + Segure para mover o analógico esquerdo pela metade da velocidade + + + Left Stick + Analógico Esquerdo + + + Config Selection + Seleção de Configuração + + + Common Config + Configuração Comum + + + Use per-game configs + Usar configurações por jogo + + + L1 + L1 + + + L2 + L2 + + + Text Editor + Editor de Texto + + + Help + Ajuda + + + R1 + R1 + + + R2 + R2 + + + L3 + L3 + + + Touchpad Click + Clique do Touchpad + + + Mouse to Joystick + Mouse para Analógico + + + *press F7 ingame to activate + *Pressione F7 no jogo para ativar + + + R3 + R3 + + + Options + Opções + + + Mouse Movement Parameters + Parâmetros de Movimento do Mouse + + + note: click Help Button/Special Keybindings for more information + Nota: clique no botão de Ajuda e Atalhos Especiais para obter mais informações + + + Face Buttons + Botões de Ação + + + Triangle + Triângulo + + + Square + Quadrado + + + Circle + Círculo + + + Cross + Cruz + + + Right Analog Halfmode + Meio Analógico Direito + + + hold to move right stick at half-speed + Segure para mover o analógico direito pela metade da velocidade + + + Right Stick + Analógico Direito + + + Speed Offset (def 0.125): + Deslocamento de Velocidade (Pad 0,125): + + + Copy from Common Config + Copiar da Configuração Comum + + + Deadzone Offset (def 0.50): + Deslocamento da Zona Morta (Pad 0,50): + + + Speed Multiplier (def 1.0): + Multiplicador de Velocidade (Pad 1,0): + + + Common Config Selected + Configuração Comum Selecionada + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + Este botão copia os mapeamentos da Configuração Comum para o perfil atualmente selecionado, e não pode ser usado quando o perfil atualmente selecionado é a Configuração Comum. + + + Copy values from Common Config + Copiar valores da Configuração Comum + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + Você deseja substituir os mapeamentos existentes com os mapeamentos da Configuração Comum? + + + Unable to Save + Não foi possível salvar + + + Cannot bind any unique input more than once + Não é possível vincular qualquer entrada única mais de uma vez + + + Press a key + Aperte uma tecla + + + Cannot set mapping + Não é possível definir o mapeamento + + + Mousewheel cannot be mapped to stick outputs + A rolagem do mouse não pode ser mapeada para saídas do analógico + + + Save + Salvar + + + Apply + Aplicar + + + Restore Defaults + Restaurar Padrões + + + Cancel + Cancelar @@ -893,10 +1191,6 @@ Open/Add Elf Folder Abrir/Adicionar pasta Elf - - Install Packages (PKG) - Instalar Pacotes (PKG) - Boot Game Iniciar Jogo @@ -913,10 +1207,6 @@ Configure... Configurar... - - Install application from a .pkg file - Instalar aplicação de um arquivo .pkg - Recent Games Jogos Recentes @@ -935,7 +1225,7 @@ Exit the application. - Sair da aplicação. + Sair do aplicativo. Show Game List @@ -963,11 +1253,11 @@ List View - Visualizar em Lista + Visualização em Lista Grid View - Visualizar em Grade + Visualização em Grade Elf Viewer @@ -979,15 +1269,19 @@ Download Cheats/Patches - Baixar Trapaças/Patches + Baixar Trapaças/Modificações Dump Game List Exportar Lista de Jogos - PKG Viewer - Visualizador de PKG + Trophy Viewer + Visualizador de Troféus + + + No games found. Please add your games to your library first. + Nenhum jogo encontrado. Adicione seus jogos à sua biblioteca primeiro. Search... @@ -1063,7 +1357,7 @@ Download Patches For All Games - Baixar Patches para Todos os Jogos + Baixar Modificações para Todos os Jogos Download Complete @@ -1075,11 +1369,11 @@ Patches Downloaded Successfully! - Patches Baixados com Sucesso! + Modificações Baixadas com Sucesso! All Patches available for all games have been downloaded. - Todos os patches disponíveis para todos os jogos foram baixados. + Todos as modificações disponíveis para todos os jogos foram baixadas. Games: @@ -1097,70 +1391,6 @@ Only one file can be selected! Apenas um arquivo pode ser selecionado! - - PKG Extraction - Extração de PKG - - - Patch detected! - Atualização detectada! - - - PKG and Game versions match: - As versões do PKG e do Jogo são iguais: - - - Would you like to overwrite? - Você gostaria de sobrescrever? - - - PKG Version %1 is older than installed version: - A Versão do PKG %1 é mais antiga do que a versão instalada: - - - Game is installed: - Jogo instalado: - - - Would you like to install Patch: - Você gostaria de instalar a atualização: - - - DLC Installation - Instalação de DLC - - - Would you like to install DLC: %1? - Você gostaria de instalar o DLC: %1? - - - DLC already installed: - DLC já está instalado: - - - Game already installed - O jogo já está instalado: - - - PKG ERROR - ERRO DE PKG - - - Extracting PKG %1/%2 - Extraindo PKG %1/%2 - - - Extraction Finished - Extração Concluída - - - Game successfully installed at %1 - Jogo instalado com sucesso em %1 - - - File doesn't appear to be a valid PKG file - O arquivo não parece ser um arquivo PKG válido - Run Game Executar Jogo @@ -1169,14 +1399,6 @@ Eboot.bin file not found Arquivo Eboot.bin não encontrado - - PKG File (*.PKG *.pkg) - Arquivo PKG (*.PKG *.pkg) - - - PKG is a patch or DLC, please install the game first! - O PKG é um patch ou DLC, por favor instale o jogo primeiro! - Game is already running! O jogo já está executando! @@ -1185,72 +1407,45 @@ shadPS4 shadPS4 - - - PKGViewer - Open Folder - Abrir Pasta + Play + Jogar - PKG ERROR - ERRO DE PKG + Pause + Pausar - Name - Nome + Stop + Parar - Serial - Serial + Restart + Reiniciar - Installed - Instalado + Full Screen + Tela Cheia - Size - Tamanho + Controllers + Controles - Category - Categoria + Keyboard + Teclado - Type - Tipo + Refresh List + Atualizar Lista - App Ver - Versão do App + Resume + Continuar - FW - FW - - - Region - Região - - - Flags - Flags - - - Path - Caminho - - - File - Arquivo - - - Unknown - Desconhecido - - - Package - Pacote + Show Labels Under Icons + Mostrar Rótulos Sob Ícones @@ -1279,10 +1474,6 @@ Emulator Emulador - - Enable Separate Update Folder - Ativar Pasta de Atualização Separada - Default tab when opening settings Aba padrão ao abrir as configurações @@ -1309,11 +1500,15 @@ Trophy - Troféus + Troféu + + + Open the custom trophy images/sounds folder + Abrir a pasta de imagens e sons de troféus personalizados Logger - Registros de Log + Log/Registro Log Type @@ -1476,8 +1671,8 @@ Música no Menu - Disable Trophy Pop-ups - Desabilitar Pop-ups dos Troféus + Disable Trophy Notification + Desativar Notificações de Troféu Background Image @@ -1497,7 +1692,7 @@ Update Compatibility Database On Startup - Atualizar Base de Dados de Compatibilidade ao Inicializar + Atualizar Banco de Dados de Compatibilidade ao Inicializar Game Compatibility @@ -1543,10 +1738,6 @@ Emulator Language:\nSets the language of the emulator's user interface. Idioma do Emulador:\nDefine o idioma da interface do emulador. - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Ativar Pasta de Atualização Separada:\nPermite instalar atualizações de jogos em uma pasta separada para fácil gerenciamento.\nIsso pode ser manualmente criado adicionando a atualização extraída à pasta do jogo com o nome "CUSA00000-UPDATE" onde o ID do CUSA corresponde ao ID do jogo. - Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. Mostrar Splash Inicial:\nExibe a tela inicial do jogo (imagem especial) ao iniciar o jogo. @@ -1565,11 +1756,11 @@ Log Type:\nSets whether to synchronize the output of the log window for performance. May have adverse effects on emulation. - Tipo de Registro:\nDetermina se a saída da janela de log deve ser sincronizada por motivos de desempenho. Pode impactar negativamente na emulação. + Tipo de Registro:\nDetermina se a saída da janela de registro deve ser sincronizada por motivos de desempenho. Pode impactar negativamente na emulação. Log Filter:\nFilters the log to only print specific information.\nExamples: "Core:Trace" "Lib.Pad:Debug Common.Filesystem:Error" "*:Critical"\nLevels: Trace, Debug, Info, Warning, Error, Critical - in this order, a specific level silences all levels preceding it in the list and logs every level after it. - Filtro de Registro:\nFiltra o registro para exibir apenas informações específicas.\nExemplos: "Core:Trace" "Lib.Pad:Debug Common.Filesystem:Error" "*:Critical"\nNíveis: Trace, Debug, Info, Warning, Error, Critical - nesta ordem, um nível específico silencia todos os níveis anteriores na lista e registra todos os níveis após ele. + Filtro do Registro:\nFiltra o registro para exibir apenas informações específicas.\nExemplos: "Core:Trace" "Lib.Pad:Debug Common.Filesystem:Error" "*:Critical"\nNíveis: Trace, Debug, Info, Warning, Error, Critical - nesta ordem, um nível específico silencia todos os níveis anteriores na lista e registra todos os níveis após este. Update:\nRelease: Official versions released every month that may be very outdated, but are more reliable and tested.\nNightly: Development versions that have all the latest features and fixes, but may contain bugs and are less stable. @@ -1705,11 +1896,11 @@ Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. - Marcadores de Depuração de Host:\nInsere informações vindo do emulador como marcadores para comandos AMDGPU específicos em torno de comandos Vulkan, além de fornecer nomes de depuração aos recursos.\nSe isso estiver habilitado, ative os Diagnósticos de Falha.\nÚtil para programas como o RenderDoc. + Marcadores de Depuração do Host:\nInsere informações vindo do emulador como marcadores para comandos AMDGPU específicos em torno de comandos Vulkan, além de fornecer nomes de depuração aos recursos.\nSe isso estiver habilitado, ative os Diagnósticos de Falhas.\nÚtil para programas como o RenderDoc. Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. - Marcadores de Depuração de Convidado:\nInsere quaisquer marcadores de depuração que o próprio jogo adicionou ao buffer de comando.\nSe isso estiver habilitado, ative os Diagnósticos de Falha.\nÚtil para programas como o RenderDoc. + Marcadores de Depuração do Convidado:\nInsere quaisquer marcadores de depuração que o próprio jogo adicionou ao buffer de comando.\nSe isso estiver habilitado, ative os Diagnósticos de Falhas.\nÚtil para programas como o RenderDoc. Save Data Path:\nThe folder where game save data will be saved. @@ -1797,11 +1988,67 @@ Separate Log Files - Separar Arquivos de Log + Separar Arquivos de Registro Separate Log Files:\nWrites a separate logfile for each game. - Separar Arquivos de Log:\nGrava um arquivo de log para cada jogo. + Separar Arquivos de Registro:\nGrava um arquivo de registro para cada jogo. + + + Trophy Notification Position + Posição da Notificação do Troféu + + + Left + Esquerda + + + Right + Direita + + + Top + Acima + + + Bottom + Abaixo + + + Notification Duration + Duração da Notificação + + + Portable User Folder + Pasta Portátil do Usuário + + + Create Portable User Folder from Common User Folder + Criar Pasta Portátil do Usuário a partir da Pasta Comum do Usuário + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + Pasta Portátil do Usuário:\nArmazena as configurações e dados do shadPS4 que serão aplicados apenas à compilação do shadPS4 localizada na pasta atual. Reinicie o aplicativo após criar a pasta portátil do usuário para começar a usá-la. + + + Cannot create portable user folder + Não é possível criar a pasta portátil do usuário + + + %1 already exists + %1 já existe + + + Portable user folder created + Pasta portátil do usuário criada + + + %1 successfully created. + %1 criado com sucesso. + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + Abrir a pasta de imagens e sons de troféus personalizados:\nVocê pode adicionar imagens personalizadas aos troféus e um áudio.\nAdicione os arquivos na pasta custom_trophy com os seguintes nomes:\ntrophy.wav OU trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nObservação: O som funcionará apenas em versões Qt. @@ -1810,5 +2057,25 @@ Trophy Viewer Visualizador de Troféus + + Select Game: + Selecionar Jogo: + + + Progress + Progresso + + + Show Earned Trophies + Mostrar Troféus Conquistados + + + Show Not Earned Trophies + Mostrar Troféus Não Conquistados + + + Show Hidden Trophies + Mostrar Troféus Ocultos + diff --git a/src/qt_gui/translations/pt_PT.ts b/src/qt_gui/translations/pt_PT.ts index e5cbedb96..70a73afe7 100644 --- a/src/qt_gui/translations/pt_PT.ts +++ b/src/qt_gui/translations/pt_PT.ts @@ -541,6 +541,77 @@ Override Color Substituir Cor + + Unable to Save + Não é possível salvar + + + Cannot bind axis values more than once + Não foi possível atribuir os valores do eixo X ou Y mais de uma vez + + + Save + Salvar + + + Apply + Aplicar + + + Restore Defaults + Restaurar o Padrão + + + Cancel + Cancelar + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + Editar comandos do Teclado + Mouse e do Controle + + + Use Per-Game configs + Use uma configuração para cada jogo + + + Error + Erro + + + Could not open the file for reading + Não foi possível abrir o arquivo para ler + + + Could not open the file for writing + Não foi possível abrir o arquivo para escrever + + + Save Changes + Salvar mudanças + + + Do you want to save changes? + Salvar as mudanças? + + + Help + Ajuda + + + Do you want to reset your custom default config to the original default config? + Restaurar a configuração customizada padrão para a configuração original padrão? + + + Do you want to reset this config to your custom default config? + Deseja redefinir esta configuração para a configuração padrão personalizada? + + + Reset to Default + Resetar ao Padrão + ElfViewer @@ -775,6 +846,10 @@ Delete DLC Eliminar DLC + + Delete Trophy + Eliminar Troféu + Compatibility... Compatibilidade... @@ -807,10 +882,6 @@ Error creating shortcut! Erro ao criar atalho! - - Install PKG - Instalar PKG - Game Jogo @@ -851,6 +922,10 @@ This game has no update folder to open! Este jogo não tem nenhuma pasta de atualização para abrir! + + No log file found for this game! + Não foi encontrado nenhum ficheiro de registo para este jogo! + Failed to convert icon. Falha ao converter ícone. @@ -859,32 +934,255 @@ This game has no save data to delete! Este jogo não tem dados guardados para eliminar! + + This game has no saved trophies to delete! + Este jogo não tem troféus guardados para eliminar! + Save Data Dados Guardados + + Trophy + Troféus + SFO Viewer for Visualizador SFO para - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - shadPS4 - Escolher diretório + Quickstart + Início Rápido - Select which directory you want to install to. - Selecione o diretório em que deseja instalar. + FAQ + Perguntas Frequentes - Install All Queued to Selected Folder - Instalar Todos os Pendentes para a Pasta Selecionada + Syntax + Sintaxe - Delete PKG File on Install - Eliminar Ficheiro PKG após Instalação + Special Bindings + Atalhos Especiais + + + Keybindings + Combinações de Teclas + + + + KBMSettings + + Configure Controls + Configurar Comandos + + + D-Pad + Botões de Direção + + + Up + Cima + + + unmapped + não mapeado + + + Left + Esquerda + + + Right + Direita + + + Down + Baixo + + + Left Analog Halfmode + Meio Modo do Manípulo Esquerdo + + + hold to move left stick at half-speed + mantenha pressionado para mover o manípulo esquerdo à metade da velocidade + + + Left Stick + Manípulo Esquerdo + + + Config Selection + Seleção de Configuração + + + Common Config + Configuração Comum + + + Use per-game configs + Utilizar configurações por jogo + + + L1 + L1 + + + L2 + L2 + + + Text Editor + Editor de Texto + + + Help + Ajuda + + + R1 + R1 + + + R2 + R2 + + + L3 + L3 + + + Touchpad Click + Clique do Touchpad + + + Mouse to Joystick + Rato para Manípulo + + + *press F7 ingame to activate + *pressione F7 em jogo para ativar + + + R3 + R3 + + + Options + Opções + + + Mouse Movement Parameters + Parâmetros de Movimento do Rato + + + note: click Help Button/Special Keybindings for more information + nota: clique no Botão de Ajuda/Special Keybindings para obter mais informações + + + Face Buttons + Botões Frontais + + + Triangle + Triângulo + + + Square + Quadrado + + + Circle + Círculo + + + Cross + Cruz + + + Right Analog Halfmode + Meio Modo do Manípulo Direito + + + hold to move right stick at half-speed + mantenha pressionado para mover o manípulo direito à metade da velocidade + + + Right Stick + Manípulo Direito + + + Speed Offset (def 0.125): + Deslocamento de Velocidade (def 0,125): + + + Copy from Common Config + Copiar da Configuração Comum + + + Deadzone Offset (def 0.50): + Deslocamento da Zona Morta (def 0,50): + + + Speed Multiplier (def 1.0): + Multiplicador de Velocidade (def 1,0): + + + Common Config Selected + Configuração Comum Selecionada + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + Este botão copia mapeamentos da Configuração Comum para o perfil atualmente selecionado, e não pode ser usado quando o perfil atualmente selecionado é a Configuração Comum. + + + Copy values from Common Config + Copiar valores da Configuração Comum + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + Substituir mapeamentos existentes com os mapeamentos da Configuração Comum? + + + Unable to Save + Não é possível salvar + + + Cannot bind any unique input more than once + Não é possível vincular qualquer entrada única mais de uma vez + + + Press a key + Pressione uma tecla + + + Cannot set mapping + Não é possível definir o mapeamento + + + Mousewheel cannot be mapped to stick outputs + Roda do rato não pode ser mapeada para saídas empates + + + Save + Salvar + + + Apply + Aplicar + + + Restore Defaults + Restaurar Definições + + + Cancel + Cancelar @@ -893,10 +1191,6 @@ Open/Add Elf Folder Abrir/Adicionar pasta Elf - - Install Packages (PKG) - Instalar Pacotes (PKG) - Boot Game Iniciar Jogo @@ -913,10 +1207,6 @@ Configure... Configurar... - - Install application from a .pkg file - Instalar aplicação através de um ficheiro .pkg - Recent Games Jogos Recentes @@ -986,8 +1276,12 @@ Exportar Lista de Jogos - PKG Viewer - Visualizador PKG + Trophy Viewer + Visualizador de Troféus + + + No games found. Please add your games to your library first. + Nenhum jogo encontrado. Por favor, adicione os seus jogos à sua biblioteca primeiro. Search... @@ -1097,70 +1391,6 @@ Only one file can be selected! Apenas um ficheiro pode ser selecionado! - - PKG Extraction - Extração de PKG - - - Patch detected! - Patch detetado! - - - PKG and Game versions match: - As versões do PKG e do Jogo coincidem: - - - Would you like to overwrite? - Gostaria de substituir? - - - PKG Version %1 is older than installed version: - A versão do PKG %1 é mais antiga do que a versão instalada: - - - Game is installed: - O jogo está instalado: - - - Would you like to install Patch: - Gostaria de instalar o Patch: - - - DLC Installation - Instalação de DLC - - - Would you like to install DLC: %1? - Deseja instalar o DLC: %1? - - - DLC already installed: - DLC já está instalado: - - - Game already installed - O jogo já está instalado - - - PKG ERROR - ERRO PKG - - - Extracting PKG %1/%2 - A extrair PKG %1/%2 - - - Extraction Finished - Extração Finalizada - - - Game successfully installed at %1 - Jogo instalado com sucesso em %1 - - - File doesn't appear to be a valid PKG file - O ficheiro não aparenta ser um ficheiro PKG válido - Run Game Executar Jogo @@ -1169,14 +1399,6 @@ Eboot.bin file not found Ficheiro eboot.bin não encontrado - - PKG File (*.PKG *.pkg) - Ficheiro PKG (*.PKG *.pkg) - - - PKG is a patch or DLC, please install the game first! - Este PKG é um patch ou DLC, por favor instale o respetivo jogo primeiro! - Game is already running! O jogo já está a ser executado! @@ -1185,72 +1407,45 @@ shadPS4 shadPS4 - - - PKGViewer - Open Folder - Abrir Pasta + Play + Play - PKG ERROR - ERRO PKG + Pause + Pause - Name - Nome + Stop + Stop - Serial - Número de Série + Restart + Restart - Installed - Instalado + Full Screen + Full Screen - Size - Tamanho + Controllers + Controllers - Category - Categoria + Keyboard + Keyboard - Type - Tipo + Refresh List + Refresh List - App Ver - App Ver + Resume + Resume - FW - FW - - - Region - Região - - - Flags - Flags - - - Path - Caminho - - - File - Ficheiro - - - Unknown - Desconhecido - - - Package - Pacote + Show Labels Under Icons + Show Labels Under Icons @@ -1279,10 +1474,6 @@ Emulator Emulador - - Enable Separate Update Folder - Ativar Pasta de Atualizações Separada - Default tab when opening settings Aba padrão ao abrir as definições @@ -1311,6 +1502,10 @@ Trophy Troféus + + Open the custom trophy images/sounds folder + Abrir a pasta de imagens/sons de troféus personalizados + Logger Registos @@ -1476,8 +1671,8 @@ Música de Título - Disable Trophy Pop-ups - Desativar Pop-ups dos Troféus + Disable Trophy Notification + Desativar Notificações de Troféus Background Image @@ -1543,10 +1738,6 @@ Emulator Language:\nSets the language of the emulator's user interface. Idioma do Emulador:\nDefine o idioma da interface gráfica do emulador. - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Ativar Pasta de Atualização Separada:\nPermite instalar as atualizações dos jogos numa pasta separada para uma fácil gestão.\nIsto pode ser manualmente criado adicionando a atualização extraída à pasta do jogo com o nome "CUSA00000-UPDATE" onde o ID do CUSA corresponde ao ID do jogo. - Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. Mostrar Splash Inicial:\nExibe o ecrã inicial do jogo (uma imagem especial) enquanto o jogo inicia. @@ -1803,6 +1994,62 @@ Separate Log Files:\nWrites a separate logfile for each game. Separar Ficheiros de Registo:\nEscreve um ficheiro de registo para cada jogo. + + Trophy Notification Position + Posição da Notificação do Troféu + + + Left + Esquerda + + + Right + Direita + + + Top + Acima + + + Bottom + Abaixo + + + Notification Duration + Duração da Notificação + + + Portable User Folder + Pasta de Utilizador Portátil + + + Create Portable User Folder from Common User Folder + Criar Pasta de Utilizador Portátil a partir da Pasta de Utilizador Comum + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + Pasta de utilizador portátil:\nArmazena as definições e dados do shadPS4 que serão aplicados apenas na compilação do shadPS4 localizada na pasta atual. Reinicie a aplicação após criar a pasta de utilizador portátil para começar a usá-la. + + + Cannot create portable user folder + Não é possível criar pasta de utilizador portátil + + + %1 already exists + %1 já existe + + + Portable user folder created + Pasta de utilizador portátil criada + + + %1 successfully created. + %1 criado com sucesso. + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + Abra a pasta de imagens/sons de troféus personalizados:\nPoderá adicionar imagens personalizadas aos troféus e um áudio.\nAdicione os arquivos na pasta custom_trophy com os seguintes nomes:\ntrophy.mp3 ou trophy.wav, bronze.png, gold.png, platinum.png, silver.png\nObservação: O som funcionará apenas nas versões Qt. + TrophyViewer @@ -1810,5 +2057,25 @@ Trophy Viewer Visualizador de Troféus + + Select Game: + Escolha o Jogo: + + + Progress + Progresso + + + Show Earned Trophies + Mostrar Troféus Conquistados + + + Show Not Earned Trophies + Mostrar Troféus Não Conquistados + + + Show Hidden Trophies + Mostrar Troféus Ocultos + diff --git a/src/qt_gui/translations/ro_RO.ts b/src/qt_gui/translations/ro_RO.ts index 7083e6d49..78dd79c53 100644 --- a/src/qt_gui/translations/ro_RO.ts +++ b/src/qt_gui/translations/ro_RO.ts @@ -541,6 +541,77 @@ Override Color Override Color + + Unable to Save + Unable to Save + + + Cannot bind axis values more than once + Cannot bind axis values more than once + + + Save + Save + + + Apply + Apply + + + Restore Defaults + Restore Defaults + + + Cancel + Cancel + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + Edit Keyboard + Mouse and Controller input bindings + + + Use Per-Game configs + Use Per-Game configs + + + Error + Error + + + Could not open the file for reading + Could not open the file for reading + + + Could not open the file for writing + Could not open the file for writing + + + Save Changes + Save Changes + + + Do you want to save changes? + Do you want to save changes? + + + Help + Help + + + Do you want to reset your custom default config to the original default config? + Do you want to reset your custom default config to the original default config? + + + Do you want to reset this config to your custom default config? + Do you want to reset this config to your custom default config? + + + Reset to Default + Reset to Default + ElfViewer @@ -775,6 +846,10 @@ Delete DLC Delete DLC + + Delete Trophy + Delete Trophy + Compatibility... Compatibility... @@ -807,10 +882,6 @@ Error creating shortcut! Error creating shortcut! - - Install PKG - Install PKG - Game Game @@ -851,6 +922,10 @@ This game has no update folder to open! Acest joc nu are folderul de actualizări pentru a fi deschis! + + No log file found for this game! + No log file found for this game! + Failed to convert icon. Failed to convert icon. @@ -859,32 +934,255 @@ This game has no save data to delete! This game has no save data to delete! + + This game has no saved trophies to delete! + This game has no saved trophies to delete! + Save Data Save Data + + Trophy + Trophy + SFO Viewer for SFO Viewer for - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - shadPS4 - Choose directory + Quickstart + Quickstart - Select which directory you want to install to. - Select which directory you want to install to. + FAQ + FAQ - Install All Queued to Selected Folder - Install All Queued to Selected Folder + Syntax + Syntax - Delete PKG File on Install - Delete PKG File on Install + Special Bindings + Special Bindings + + + Keybindings + Keybindings + + + + KBMSettings + + Configure Controls + Configure Controls + + + D-Pad + D-Pad + + + Up + Up + + + unmapped + unmapped + + + Left + Left + + + Right + Right + + + Down + Down + + + Left Analog Halfmode + Left Analog Halfmode + + + hold to move left stick at half-speed + hold to move left stick at half-speed + + + Left Stick + Left Stick + + + Config Selection + Config Selection + + + Common Config + Common Config + + + Use per-game configs + Use per-game configs + + + L1 + L1 + + + L2 + L2 + + + Text Editor + Text Editor + + + Help + Help + + + R1 + R1 + + + R2 + R2 + + + L3 + L3 + + + Touchpad Click + Touchpad Click + + + Mouse to Joystick + Mouse to Joystick + + + *press F7 ingame to activate + *press F7 ingame to activate + + + R3 + R3 + + + Options + Options + + + Mouse Movement Parameters + Mouse Movement Parameters + + + note: click Help Button/Special Keybindings for more information + note: click Help Button/Special Keybindings for more information + + + Face Buttons + Face Buttons + + + Triangle + Triangle + + + Square + Square + + + Circle + Circle + + + Cross + Cross + + + Right Analog Halfmode + Right Analog Halfmode + + + hold to move right stick at half-speed + hold to move right stick at half-speed + + + Right Stick + Right Stick + + + Speed Offset (def 0.125): + Speed Offset (def 0.125): + + + Copy from Common Config + Copy from Common Config + + + Deadzone Offset (def 0.50): + Deadzone Offset (def 0.50): + + + Speed Multiplier (def 1.0): + Speed Multiplier (def 1.0): + + + Common Config Selected + Common Config Selected + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + + + Copy values from Common Config + Copy values from Common Config + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + Do you want to overwrite existing mappings with the mappings from the Common Config? + + + Unable to Save + Unable to Save + + + Cannot bind any unique input more than once + Cannot bind any unique input more than once + + + Press a key + Press a key + + + Cannot set mapping + Cannot set mapping + + + Mousewheel cannot be mapped to stick outputs + Mousewheel cannot be mapped to stick outputs + + + Save + Save + + + Apply + Apply + + + Restore Defaults + Restore Defaults + + + Cancel + Cancel @@ -893,10 +1191,6 @@ Open/Add Elf Folder Open/Add Elf Folder - - Install Packages (PKG) - Install Packages (PKG) - Boot Game Boot Game @@ -913,10 +1207,6 @@ Configure... Configure... - - Install application from a .pkg file - Install application from a .pkg file - Recent Games Recent Games @@ -986,8 +1276,12 @@ Dump Game List - PKG Viewer - PKG Viewer + Trophy Viewer + Trophy Viewer + + + No games found. Please add your games to your library first. + No games found. Please add your games to your library first. Search... @@ -1097,70 +1391,6 @@ Only one file can be selected! Numai un fișier poate fi selectat! - - PKG Extraction - Extracție PKG - - - Patch detected! - Patch detectat! - - - PKG and Game versions match: - Versiunile PKG și ale jocului sunt compatibile: - - - Would you like to overwrite? - Doriți să suprascrieți? - - - PKG Version %1 is older than installed version: - Versiunea PKG %1 este mai veche decât versiunea instalată: - - - Game is installed: - Jocul este instalat: - - - Would you like to install Patch: - Doriți să instalați patch-ul: - - - DLC Installation - Instalare DLC - - - Would you like to install DLC: %1? - Doriți să instalați DLC-ul: %1? - - - DLC already installed: - DLC deja instalat: - - - Game already installed - Jocul deja instalat - - - PKG ERROR - EROARE PKG - - - Extracting PKG %1/%2 - Extracție PKG %1/%2 - - - Extraction Finished - Extracție terminată - - - Game successfully installed at %1 - Jocul a fost instalat cu succes la %1 - - - File doesn't appear to be a valid PKG file - Fișierul nu pare să fie un fișier PKG valid - Run Game Run Game @@ -1169,14 +1399,6 @@ Eboot.bin file not found Eboot.bin file not found - - PKG File (*.PKG *.pkg) - PKG File (*.PKG *.pkg) - - - PKG is a patch or DLC, please install the game first! - PKG is a patch or DLC, please install the game first! - Game is already running! Game is already running! @@ -1185,72 +1407,45 @@ shadPS4 shadPS4 - - - PKGViewer - Open Folder - Deschide Folder + Play + Play - PKG ERROR - EROARE PKG + Pause + Pause - Name - Nume + Stop + Stop - Serial - Serie + Restart + Restart - Installed - Installed + Full Screen + Full Screen - Size - Dimensiune + Controllers + Controllers - Category - Category + Keyboard + Keyboard - Type - Type + Refresh List + Refresh List - App Ver - App Ver + Resume + Resume - FW - FW - - - Region - Regiune - - - Flags - Flags - - - Path - Drum - - - File - File - - - Unknown - Necunoscut - - - Package - Package + Show Labels Under Icons + Show Labels Under Icons @@ -1279,10 +1474,6 @@ Emulator Emulator - - Enable Separate Update Folder - Enable Separate Update Folder - Default tab when opening settings Tab-ul implicit la deschiderea setărilor @@ -1311,6 +1502,10 @@ Trophy Trophy + + Open the custom trophy images/sounds folder + Open the custom trophy images/sounds folder + Logger Logger @@ -1476,8 +1671,8 @@ Title Music - Disable Trophy Pop-ups - Disable Trophy Pop-ups + Disable Trophy Notification + Disable Trophy Notification Background Image @@ -1543,10 +1738,6 @@ Emulator Language:\nSets the language of the emulator's user interface. Limba emulatorului:\nSetează limba interfeței utilizatorului a emulatorului. - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. Afișează ecranul de încărcare:\nAfișează ecranul de încărcare al jocului (o imagine specială) în timp ce jocul pornește. @@ -1803,6 +1994,62 @@ Separate Log Files:\nWrites a separate logfile for each game. Separate Log Files:\nWrites a separate logfile for each game. + + Trophy Notification Position + Trophy Notification Position + + + Left + Left + + + Right + Right + + + Top + Top + + + Bottom + Bottom + + + Notification Duration + Notification Duration + + + Portable User Folder + Portable User Folder + + + Create Portable User Folder from Common User Folder + Create Portable User Folder from Common User Folder + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + + + Cannot create portable user folder + Cannot create portable user folder + + + %1 already exists + %1 already exists + + + Portable user folder created + Portable user folder created + + + %1 successfully created. + %1 successfully created. + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + TrophyViewer @@ -1810,5 +2057,25 @@ Trophy Viewer Trophy Viewer + + Select Game: + Select Game: + + + Progress + Progress + + + Show Earned Trophies + Show Earned Trophies + + + Show Not Earned Trophies + Show Not Earned Trophies + + + Show Hidden Trophies + Show Hidden Trophies + diff --git a/src/qt_gui/translations/ru_RU.ts b/src/qt_gui/translations/ru_RU.ts index d9e90d1a2..0f16efc2c 100644 --- a/src/qt_gui/translations/ru_RU.ts +++ b/src/qt_gui/translations/ru_RU.ts @@ -541,6 +541,77 @@ Override Color Заменить цвет + + Unable to Save + Не удаётся сохранить + + + Cannot bind axis values more than once + Невозможно привязать значения оси более одного раза + + + Save + Сохранить + + + Apply + Применить + + + Restore Defaults + По умолчанию + + + Cancel + Отмена + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + Редактировать бинды клавиатуры + мыши и контроллера + + + Use Per-Game configs + Использовать настройки для каждой игры + + + Error + Ошибка + + + Could not open the file for reading + Не удалось открыть файл для чтения + + + Could not open the file for writing + Не удалось открыть файл для записи + + + Save Changes + Сохранить изменения + + + Do you want to save changes? + Хотите сохранить изменения? + + + Help + Помощь + + + Do you want to reset your custom default config to the original default config? + Хотите ли вы сбросить ваш пользовательский конфиг по умолчанию к первоначальному конфигу по умолчанию? + + + Do you want to reset this config to your custom default config? + Хотите ли вы сбросить этот конфиг к вашему пользовательскому конфигу по умолчанию? + + + Reset to Default + Сбросить по умолчанию + ElfViewer @@ -775,6 +846,10 @@ Delete DLC Удалить DLC + + Delete Trophy + Удалить трофей + Compatibility... Совместимость... @@ -807,10 +882,6 @@ Error creating shortcut! Ошибка создания ярлыка! - - Install PKG - Установить PKG - Game Игры @@ -851,6 +922,10 @@ This game has no update folder to open! У этой игры нет папки обновлений, которую можно открыть! + + No log file found for this game! + Не найден файл логов для этой игры! + Failed to convert icon. Не удалось преобразовать иконку. @@ -859,32 +934,255 @@ This game has no save data to delete! У этой игры нет сохранений, которые можно удалить! + + This game has no saved trophies to delete! + У этой игры нет сохраненных трофеев для удаления! + Save Data Сохранения + + Trophy + Трофей + SFO Viewer for Просмотр SFO для - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - shadPS4 - Выберите папку + Quickstart + Быстрый старт - Select which directory you want to install to. - Выберите папку, в которую вы хотите установить. + FAQ + ЧАВО - Install All Queued to Selected Folder - Установить все из очереди в выбранную папку + Syntax + Синтаксис - Delete PKG File on Install - Удалить файл PKG при установке + Special Bindings + Специальные бинды + + + Keybindings + Бинды клавиш + + + + KBMSettings + + Configure Controls + Настроить управление + + + D-Pad + Крестовина + + + Up + Вверх + + + unmapped + не назначено + + + Left + Влево + + + Right + Вправо + + + Down + Вниз + + + Left Analog Halfmode + Левый стик вполовину + + + hold to move left stick at half-speed + удерживайте для перемещения левого стика вполовину меньше + + + Left Stick + Левый стик + + + Config Selection + Выбор конфига + + + Common Config + Общий конфиг + + + Use per-game configs + Использовать настройки для каждой игры + + + L1 + L1 + + + L2 + L2 + + + Text Editor + Текстовый редактор + + + Help + Помощь + + + R1 + R1 + + + R2 + R2 + + + L3 + L3 + + + Touchpad Click + Нажатие на тачпад + + + Mouse to Joystick + Мышь в джойстик + + + *press F7 ingame to activate + *нажмите F7 в игре для активации + + + R3 + R3 + + + Options + Options + + + Mouse Movement Parameters + Параметры движения мыши + + + note: click Help Button/Special Keybindings for more information + примечание: нажмите кнопку Помощь/Специальные бинды для получения дополнительной информации + + + Face Buttons + Кнопки действий + + + Triangle + Треугольник + + + Square + Квадрат + + + Circle + Круг + + + Cross + Крест + + + Right Analog Halfmode + Правый стик вполовину + + + hold to move right stick at half-speed + удерживайте для перемещения правого стика вполовину меньше + + + Right Stick + Правый стик + + + Speed Offset (def 0.125): + Смещение скорости (по умолч 0.125): + + + Copy from Common Config + Копировать из общего конфига + + + Deadzone Offset (def 0.50): + Смещение мёртвой зоны (по умолч 0.50) + + + Speed Multiplier (def 1.0): + Множитель скорости (по умолч 1.0) + + + Common Config Selected + Выбран общий конфиг + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + Эта кнопка копирует настройки из общего конфига в текущий выбранный профиль, и не может быть использован, когда выбранный профиль это общий конфиг. + + + Copy values from Common Config + Копировать значения из общего конфига + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + Вы хотите перезаписать существующие настройки настройками из общего конфига? + + + Unable to Save + Не удаётся сохранить + + + Cannot bind any unique input more than once + Невозможно привязать уникальный ввод более одного раза + + + Press a key + Нажмите кнопку + + + Cannot set mapping + Не удаётся задать настройки + + + Mousewheel cannot be mapped to stick outputs + Колесо не может быть назначено для вывода стиков + + + Save + Сохранить + + + Apply + Применить + + + Restore Defaults + По умолчанию + + + Cancel + Отмена @@ -893,10 +1191,6 @@ Open/Add Elf Folder Открыть/Добавить папку Elf - - Install Packages (PKG) - Установить пакеты (PKG) - Boot Game Запустить игру @@ -913,10 +1207,6 @@ Configure... Настроить... - - Install application from a .pkg file - Установить приложение из файла .pkg - Recent Games Недавние игры @@ -986,8 +1276,12 @@ Дамп списка игр - PKG Viewer - Просмотр PKG + Trophy Viewer + Просмотр трофеев + + + No games found. Please add your games to your library first. + Не найдено ни одной игры. Пожалуйста, сначала добавьте игры в библиотеку. Search... @@ -1097,70 +1391,6 @@ Only one file can be selected! Можно выбрать только один файл! - - PKG Extraction - Извлечение PKG - - - Patch detected! - Обнаружен патч! - - - PKG and Game versions match: - Версии PKG и игры совпадают: - - - Would you like to overwrite? - Хотите перезаписать? - - - PKG Version %1 is older than installed version: - Версия PKG %1 старше установленной версии: - - - Game is installed: - Игра установлена: - - - Would you like to install Patch: - Хотите установить патч: - - - DLC Installation - Установка DLC - - - Would you like to install DLC: %1? - Вы хотите установить DLC: %1? - - - DLC already installed: - DLC уже установлен: - - - Game already installed - Игра уже установлена - - - PKG ERROR - ОШИБКА PKG - - - Extracting PKG %1/%2 - Извлечение PKG %1/%2 - - - Extraction Finished - Извлечение завершено - - - Game successfully installed at %1 - Игра успешно установлена в %1 - - - File doesn't appear to be a valid PKG file - Файл не является допустимым файлом PKG - Run Game Запустить игру @@ -1169,14 +1399,6 @@ Eboot.bin file not found Файл eboot.bin не найден - - PKG File (*.PKG *.pkg) - Файл PKG (*.PKG *.pkg) - - - PKG is a patch or DLC, please install the game first! - Выбранный PKG является патчем или DLC, пожалуйста, сначала установите игру! - Game is already running! Игра уже запущена! @@ -1185,72 +1407,45 @@ shadPS4 shadPS4 - - - PKGViewer - Open Folder - Открыть папку + Play + Играть - PKG ERROR - ОШИБКА PKG + Pause + Пауза - Name - Название + Stop + Остановить - Serial - Серийный номер + Restart + Перезапустить - Installed - Установлено + Full Screen + Полный экран - Size - Размер + Controllers + Контроллеры - Category - Категория + Keyboard + Клавиатура - Type - Тип + Refresh List + Обновить список - App Ver - Версия приложения + Resume + Продолжить - FW - Прошивка - - - Region - Регион - - - Flags - Флаги - - - Path - Путь - - - File - Файл - - - Unknown - Неизвестно - - - Package - Пакет + Show Labels Under Icons + Показывать метки под значками @@ -1279,10 +1474,6 @@ Emulator Эмулятор - - Enable Separate Update Folder - Отдельная папка обновлений - Default tab when opening settings Вкладка по умолчанию при открытии настроек @@ -1311,6 +1502,10 @@ Trophy Трофеи + + Open the custom trophy images/sounds folder + Открыть папку с пользовательскими изображениями/звуками трофеев + Logger Логирование @@ -1476,8 +1671,8 @@ Заглавная музыка - Disable Trophy Pop-ups - Отключить уведомления о трофеях + Disable Trophy Notification + Отключить уведомления о трофее Background Image @@ -1543,10 +1738,6 @@ Emulator Language:\nSets the language of the emulator's user interface. Язык эмулятора:\nУстанавливает язык пользовательского интерфейса эмулятора. - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Отдельная папка обновлений:\nПозволяет устанавливать обновления игры в отдельную папку для удобства.\nМожно создать вручную, добавив извлеченное обновление в папку с игрой с именем "CUSA00000-UPDATE", где идентификатор CUSA совпадает с идентификатором игры. - Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. Показывать заставку:\nОтображает заставку игры (специальное изображение) во время запуска. @@ -1803,6 +1994,62 @@ Separate Log Files:\nWrites a separate logfile for each game. Отдельные файлы логов:\nПишет отдельный файл логов для каждой игры. + + Trophy Notification Position + Местоположение уведомления о трофее + + + Left + Слева + + + Right + Справа + + + Top + Сверху + + + Bottom + Снизу + + + Notification Duration + Продолжительность уведомления + + + Portable User Folder + Портативная папка пользователя + + + Create Portable User Folder from Common User Folder + Создать портативную папку пользователя из общей папки пользователя + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + Портативная папка пользователя:\nХранит настройки и данные shadPS4, которые будут применяться только к билду shadPS4, расположенному в этой папке. Перезагрузите приложение после создания портативной папки пользователя чтобы начать использовать её. + + + Cannot create portable user folder + Невозможно создать папку для портативной папки пользователя + + + %1 already exists + %1 уже существует + + + Portable user folder created + Портативная папка пользователя создана + + + %1 successfully created. + %1 успешно создано. + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + Открыть папку с пользовательскими изображениями/звуками трофеев:\nВы можете добавить пользовательские изображения к трофеям и аудио.\nДобавьте файлы в custom_trophy со следующими именами:\ntrophy.wav ИЛИ trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nПримечание: звук будет работать только в QT-версии. + TrophyViewer @@ -1810,5 +2057,25 @@ Trophy Viewer Просмотр трофеев + + Select Game: + Выберите игру: + + + Progress + Прогресс + + + Show Earned Trophies + Показать заработанные трофеи + + + Show Not Earned Trophies + Показать не заработанные трофеи + + + Show Hidden Trophies + Показать скрытые трофеи + diff --git a/src/qt_gui/translations/sl_SI.ts b/src/qt_gui/translations/sl_SI.ts new file mode 100644 index 000000000..ab61a5d3a --- /dev/null +++ b/src/qt_gui/translations/sl_SI.ts @@ -0,0 +1,2081 @@ + + + + + + AboutDialog + + About shadPS4 + About shadPS4 + + + shadPS4 is an experimental open-source emulator for the PlayStation 4. + shadPS4 is an experimental open-source emulator for the PlayStation 4. + + + This software should not be used to play games you have not legally obtained. + This software should not be used to play games you have not legally obtained. + + + + CheatsPatches + + Cheats / Patches for + Cheats / Patches for + + + Cheats/Patches are experimental.\nUse with caution.\n\nDownload cheats individually by selecting the repository and clicking the download button.\nIn the Patches tab, you can download all patches at once, choose which ones you want to use, and save your selection.\n\nSince we do not develop the Cheats/Patches,\nplease report issues to the cheat author.\n\nCreated a new cheat? Visit:\n + Cheats/Patches are experimental.\nUse with caution.\n\nDownload cheats individually by selecting the repository and clicking the download button.\nIn the Patches tab, you can download all patches at once, choose which ones you want to use, and save your selection.\n\nSince we do not develop the Cheats/Patches,\nplease report issues to the cheat author.\n\nCreated a new cheat? Visit:\n + + + No Image Available + No Image Available + + + Serial: + Serial: + + + Version: + Version: + + + Size: + Size: + + + Select Cheat File: + Select Cheat File: + + + Repository: + Repository: + + + Download Cheats + Download Cheats + + + Delete File + Delete File + + + No files selected. + No files selected. + + + You can delete the cheats you don't want after downloading them. + You can delete the cheats you don't want after downloading them. + + + Do you want to delete the selected file?\n%1 + Do you want to delete the selected file?\n%1 + + + Select Patch File: + Select Patch File: + + + Download Patches + Download Patches + + + Save + Save + + + Cheats + Cheats + + + Patches + Patches + + + Error + Error + + + No patch selected. + No patch selected. + + + Unable to open files.json for reading. + Unable to open files.json for reading. + + + No patch file found for the current serial. + No patch file found for the current serial. + + + Unable to open the file for reading. + Unable to open the file for reading. + + + Unable to open the file for writing. + Unable to open the file for writing. + + + Failed to parse XML: + Failed to parse XML: + + + Success + Success + + + Options saved successfully. + Options saved successfully. + + + Invalid Source + Invalid Source + + + The selected source is invalid. + The selected source is invalid. + + + File Exists + File Exists + + + File already exists. Do you want to replace it? + File already exists. Do you want to replace it? + + + Failed to save file: + Failed to save file: + + + Failed to download file: + Failed to download file: + + + Cheats Not Found + Cheats Not Found + + + No Cheats found for this game in this version of the selected repository,try another repository or a different version of the game. + No Cheats found for this game in this version of the selected repository,try another repository or a different version of the game. + + + Cheats Downloaded Successfully + Cheats Downloaded Successfully + + + You have successfully downloaded the cheats for this version of the game from the selected repository. You can try downloading from another repository, if it is available it will also be possible to use it by selecting the file from the list. + You have successfully downloaded the cheats for this version of the game from the selected repository. You can try downloading from another repository, if it is available it will also be possible to use it by selecting the file from the list. + + + Failed to save: + Failed to save: + + + Failed to download: + Failed to download: + + + Download Complete + Download Complete + + + Patches Downloaded Successfully! All Patches available for all games have been downloaded, there is no need to download them individually for each game as happens in Cheats. If the patch does not appear, it may be that it does not exist for the specific serial and version of the game. + Patches Downloaded Successfully! All Patches available for all games have been downloaded, there is no need to download them individually for each game as happens in Cheats. If the patch does not appear, it may be that it does not exist for the specific serial and version of the game. + + + Failed to parse JSON data from HTML. + Failed to parse JSON data from HTML. + + + Failed to retrieve HTML page. + Failed to retrieve HTML page. + + + The game is in version: %1 + The game is in version: %1 + + + The downloaded patch only works on version: %1 + The downloaded patch only works on version: %1 + + + You may need to update your game. + You may need to update your game. + + + Incompatibility Notice + Incompatibility Notice + + + Failed to open file: + Failed to open file: + + + XML ERROR: + XML ERROR: + + + Failed to open files.json for writing + Failed to open files.json for writing + + + Author: + Author: + + + Directory does not exist: + Directory does not exist: + + + Failed to open files.json for reading. + Failed to open files.json for reading. + + + Name: + Name: + + + Can't apply cheats before the game is started + Can't apply cheats before the game is started + + + Close + Close + + + + CheckUpdate + + Auto Updater + Auto Updater + + + Error + Error + + + Network error: + Network error: + + + The Auto Updater allows up to 60 update checks per hour.\nYou have reached this limit. Please try again later. + The Auto Updater allows up to 60 update checks per hour.\nYou have reached this limit. Please try again later. + + + Failed to parse update information. + Failed to parse update information. + + + No pre-releases found. + No pre-releases found. + + + Invalid release data. + Invalid release data. + + + No download URL found for the specified asset. + No download URL found for the specified asset. + + + Your version is already up to date! + Your version is already up to date! + + + Update Available + Update Available + + + Update Channel + Update Channel + + + Current Version + Current Version + + + Latest Version + Latest Version + + + Do you want to update? + Do you want to update? + + + Show Changelog + Show Changelog + + + Check for Updates at Startup + Check for Updates at Startup + + + Update + Update + + + No + No + + + Hide Changelog + Hide Changelog + + + Changes + Changes + + + Network error occurred while trying to access the URL + Network error occurred while trying to access the URL + + + Download Complete + Download Complete + + + The update has been downloaded, press OK to install. + The update has been downloaded, press OK to install. + + + Failed to save the update file at + Failed to save the update file at + + + Starting Update... + Starting Update... + + + Failed to create the update script file + Failed to create the update script file + + + + CompatibilityInfoClass + + Fetching compatibility data, please wait + Fetching compatibility data, please wait + + + Cancel + Cancel + + + Loading... + Loading... + + + Error + Error + + + Unable to update compatibility data! Try again later. + Unable to update compatibility data! Try again later. + + + Unable to open compatibility_data.json for writing. + Unable to open compatibility_data.json for writing. + + + Unknown + Unknown + + + Nothing + Nothing + + + Boots + Boots + + + Menus + Menus + + + Ingame + Ingame + + + Playable + Playable + + + + ControlSettings + + Configure Controls + Configure Controls + + + D-Pad + D-Pad + + + Up + Up + + + Left + Left + + + Right + Right + + + Down + Down + + + Left Stick Deadzone (def:2 max:127) + Left Stick Deadzone (def:2 max:127) + + + Left Deadzone + Left Deadzone + + + Left Stick + Left Stick + + + Config Selection + Config Selection + + + Common Config + Common Config + + + Use per-game configs + Use per-game configs + + + L1 / LB + L1 / LB + + + L2 / LT + L2 / LT + + + Back + Back + + + R1 / RB + R1 / RB + + + R2 / RT + R2 / RT + + + L3 + L3 + + + Options / Start + Options / Start + + + R3 + R3 + + + Face Buttons + Face Buttons + + + Triangle / Y + Triangle / Y + + + Square / X + Square / X + + + Circle / B + Circle / B + + + Cross / A + Cross / A + + + Right Stick Deadzone (def:2, max:127) + Right Stick Deadzone (def:2, max:127) + + + Right Deadzone + Right Deadzone + + + Right Stick + Right Stick + + + Color Adjustment + Color Adjustment + + + R: + R: + + + G: + G: + + + B: + B: + + + Override Lightbar Color + Override Lightbar Color + + + Override Color + Override Color + + + Unable to Save + Unable to Save + + + Cannot bind axis values more than once + Cannot bind axis values more than once + + + Save + Save + + + Apply + Apply + + + Restore Defaults + Restore Defaults + + + Cancel + Cancel + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + Edit Keyboard + Mouse and Controller input bindings + + + Use Per-Game configs + Use Per-Game configs + + + Error + Error + + + Could not open the file for reading + Could not open the file for reading + + + Could not open the file for writing + Could not open the file for writing + + + Save Changes + Save Changes + + + Do you want to save changes? + Do you want to save changes? + + + Help + Help + + + Do you want to reset your custom default config to the original default config? + Do you want to reset your custom default config to the original default config? + + + Do you want to reset this config to your custom default config? + Do you want to reset this config to your custom default config? + + + Reset to Default + Reset to Default + + + + ElfViewer + + Open Folder + Open Folder + + + + GameInfoClass + + Loading game list, please wait :3 + Loading game list, please wait :3 + + + Cancel + Cancel + + + Loading... + Loading... + + + + GameInstallDialog + + shadPS4 - Choose directory + shadPS4 - Choose directory + + + Directory to install games + Directory to install games + + + Browse + Browse + + + Error + Error + + + Directory to install DLC + Directory to install DLC + + + + GameListFrame + + Icon + Icon + + + Name + Name + + + Serial + Serial + + + Compatibility + Compatibility + + + Region + Region + + + Firmware + Firmware + + + Size + Size + + + Version + Version + + + Path + Path + + + Play Time + Play Time + + + Never Played + Never Played + + + h + h + + + m + m + + + s + s + + + Compatibility is untested + Compatibility is untested + + + Game does not initialize properly / crashes the emulator + Game does not initialize properly / crashes the emulator + + + Game boots, but only displays a blank screen + Game boots, but only displays a blank screen + + + Game displays an image but does not go past the menu + Game displays an image but does not go past the menu + + + Game has game-breaking glitches or unplayable performance + Game has game-breaking glitches or unplayable performance + + + Game can be completed with playable performance and no major glitches + Game can be completed with playable performance and no major glitches + + + Click to see details on github + Click to see details on github + + + Last updated + Last updated + + + + GameListUtils + + B + B + + + KB + KB + + + MB + MB + + + GB + GB + + + TB + TB + + + + GuiContextMenus + + Create Shortcut + Create Shortcut + + + Cheats / Patches + Cheats / Patches + + + SFO Viewer + SFO Viewer + + + Trophy Viewer + Trophy Viewer + + + Open Folder... + Open Folder... + + + Open Game Folder + Open Game Folder + + + Open Save Data Folder + Open Save Data Folder + + + Open Log Folder + Open Log Folder + + + Copy info... + Copy info... + + + Copy Name + Copy Name + + + Copy Serial + Copy Serial + + + Copy Version + Copy Version + + + Copy Size + Copy Size + + + Copy All + Copy All + + + Delete... + Delete... + + + Delete Game + Delete Game + + + Delete Update + Delete Update + + + Delete DLC + Delete DLC + + + Delete Trophy + Delete Trophy + + + Compatibility... + Compatibility... + + + Update database + Update database + + + View report + View report + + + Submit a report + Submit a report + + + Shortcut creation + Shortcut creation + + + Shortcut created successfully! + Shortcut created successfully! + + + Error + Error + + + Error creating shortcut! + Error creating shortcut! + + + Game + Game + + + This game has no update to delete! + This game has no update to delete! + + + Update + Update + + + This game has no DLC to delete! + This game has no DLC to delete! + + + DLC + DLC + + + Delete %1 + Delete %1 + + + Are you sure you want to delete %1's %2 directory? + Are you sure you want to delete %1's %2 directory? + + + Open Update Folder + Open Update Folder + + + Delete Save Data + Delete Save Data + + + This game has no update folder to open! + This game has no update folder to open! + + + No log file found for this game! + No log file found for this game! + + + Failed to convert icon. + Failed to convert icon. + + + This game has no save data to delete! + This game has no save data to delete! + + + This game has no saved trophies to delete! + This game has no saved trophies to delete! + + + Save Data + Save Data + + + Trophy + Trophy + + + SFO Viewer for + SFO Viewer for + + + + HelpDialog + + Quickstart + Quickstart + + + FAQ + FAQ + + + Syntax + Syntax + + + Special Bindings + Special Bindings + + + Keybindings + Keybindings + + + + KBMSettings + + Configure Controls + Configure Controls + + + D-Pad + D-Pad + + + Up + Up + + + unmapped + unmapped + + + Left + Left + + + Right + Right + + + Down + Down + + + Left Analog Halfmode + Left Analog Halfmode + + + hold to move left stick at half-speed + hold to move left stick at half-speed + + + Left Stick + Left Stick + + + Config Selection + Config Selection + + + Common Config + Common Config + + + Use per-game configs + Use per-game configs + + + L1 + L1 + + + L2 + L2 + + + Text Editor + Text Editor + + + Help + Help + + + R1 + R1 + + + R2 + R2 + + + L3 + L3 + + + Touchpad Click + Touchpad Click + + + Mouse to Joystick + Mouse to Joystick + + + *press F7 ingame to activate + *press F7 ingame to activate + + + R3 + R3 + + + Options + Options + + + Mouse Movement Parameters + Mouse Movement Parameters + + + note: click Help Button/Special Keybindings for more information + note: click Help Button/Special Keybindings for more information + + + Face Buttons + Face Buttons + + + Triangle + Triangle + + + Square + Square + + + Circle + Circle + + + Cross + Cross + + + Right Analog Halfmode + Right Analog Halfmode + + + hold to move right stick at half-speed + hold to move right stick at half-speed + + + Right Stick + Right Stick + + + Speed Offset (def 0.125): + Speed Offset (def 0.125): + + + Copy from Common Config + Copy from Common Config + + + Deadzone Offset (def 0.50): + Deadzone Offset (def 0.50): + + + Speed Multiplier (def 1.0): + Speed Multiplier (def 1.0): + + + Common Config Selected + Common Config Selected + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + + + Copy values from Common Config + Copy values from Common Config + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + Do you want to overwrite existing mappings with the mappings from the Common Config? + + + Unable to Save + Unable to Save + + + Cannot bind any unique input more than once + Cannot bind any unique input more than once + + + Press a key + Press a key + + + Cannot set mapping + Cannot set mapping + + + Mousewheel cannot be mapped to stick outputs + Mousewheel cannot be mapped to stick outputs + + + Save + Save + + + Apply + Apply + + + Restore Defaults + Restore Defaults + + + Cancel + Cancel + + + + MainWindow + + Open/Add Elf Folder + Open/Add Elf Folder + + + Boot Game + Boot Game + + + Check for Updates + Check for Updates + + + About shadPS4 + About shadPS4 + + + Configure... + Configure... + + + Recent Games + Recent Games + + + Open shadPS4 Folder + Open shadPS4 Folder + + + Exit + Exit + + + Exit shadPS4 + Exit shadPS4 + + + Exit the application. + Exit the application. + + + Show Game List + Show Game List + + + Game List Refresh + Game List Refresh + + + Tiny + Tiny + + + Small + Small + + + Medium + Medium + + + Large + Large + + + List View + List View + + + Grid View + Grid View + + + Elf Viewer + Elf Viewer + + + Game Install Directory + Game Install Directory + + + Download Cheats/Patches + Download Cheats/Patches + + + Dump Game List + Dump Game List + + + Trophy Viewer + Trophy Viewer + + + No games found. Please add your games to your library first. + No games found. Please add your games to your library first. + + + Search... + Search... + + + File + File + + + View + View + + + Game List Icons + Game List Icons + + + Game List Mode + Game List Mode + + + Settings + Settings + + + Utils + Utils + + + Themes + Themes + + + Help + Help + + + Dark + Dark + + + Light + Light + + + Green + Green + + + Blue + Blue + + + Violet + Violet + + + toolBar + toolBar + + + Game List + Game List + + + * Unsupported Vulkan Version + * Unsupported Vulkan Version + + + Download Cheats For All Installed Games + Download Cheats For All Installed Games + + + Download Patches For All Games + Download Patches For All Games + + + Download Complete + Download Complete + + + You have downloaded cheats for all the games you have installed. + You have downloaded cheats for all the games you have installed. + + + Patches Downloaded Successfully! + Patches Downloaded Successfully! + + + All Patches available for all games have been downloaded. + All Patches available for all games have been downloaded. + + + Games: + Games: + + + ELF files (*.bin *.elf *.oelf) + ELF files (*.bin *.elf *.oelf) + + + Game Boot + Game Boot + + + Only one file can be selected! + Only one file can be selected! + + + Run Game + Run Game + + + Eboot.bin file not found + Eboot.bin file not found + + + Game is already running! + Game is already running! + + + shadPS4 + shadPS4 + + + Play + Play + + + Pause + Pause + + + Stop + Stop + + + Restart + Restart + + + Full Screen + Full Screen + + + Controllers + Controllers + + + Keyboard + Keyboard + + + Refresh List + Refresh List + + + Resume + Resume + + + Show Labels Under Icons + Show Labels Under Icons + + + + SettingsDialog + + Settings + Settings + + + General + General + + + System + System + + + Console Language + Console Language + + + Emulator Language + Emulator Language + + + Emulator + Emulator + + + Default tab when opening settings + Default tab when opening settings + + + Show Game Size In List + Show Game Size In List + + + Show Splash + Show Splash + + + Enable Discord Rich Presence + Enable Discord Rich Presence + + + Username + Username + + + Trophy Key + Trophy Key + + + Trophy + Trophy + + + Open the custom trophy images/sounds folder + Open the custom trophy images/sounds folder + + + Logger + Logger + + + Log Type + Log Type + + + Log Filter + Log Filter + + + Open Log Location + Open Log Location + + + Input + Input + + + Cursor + Cursor + + + Hide Cursor + Hide Cursor + + + Hide Cursor Idle Timeout + Hide Cursor Idle Timeout + + + s + s + + + Controller + Controller + + + Back Button Behavior + Back Button Behavior + + + Graphics + Graphics + + + GUI + GUI + + + User + User + + + Graphics Device + Graphics Device + + + Vblank Divider + Vblank Divider + + + Advanced + Advanced + + + Enable Shaders Dumping + Enable Shaders Dumping + + + Enable NULL GPU + Enable NULL GPU + + + Enable HDR + Enable HDR + + + Paths + Paths + + + Game Folders + Game Folders + + + Add... + Add... + + + Remove + Remove + + + Debug + Debug + + + Enable Debug Dumping + Enable Debug Dumping + + + Enable Vulkan Validation Layers + Enable Vulkan Validation Layers + + + Enable Vulkan Synchronization Validation + Enable Vulkan Synchronization Validation + + + Enable RenderDoc Debugging + Enable RenderDoc Debugging + + + Enable Crash Diagnostics + Enable Crash Diagnostics + + + Collect Shaders + Collect Shaders + + + Copy GPU Buffers + Copy GPU Buffers + + + Host Debug Markers + Host Debug Markers + + + Guest Debug Markers + Guest Debug Markers + + + Update + Update + + + Check for Updates at Startup + Check for Updates at Startup + + + Always Show Changelog + Always Show Changelog + + + Update Channel + Update Channel + + + Check for Updates + Check for Updates + + + GUI Settings + GUI Settings + + + Title Music + Title Music + + + Disable Trophy Notification + Disable Trophy Notification + + + Background Image + Background Image + + + Show Background Image + Show Background Image + + + Opacity + Opacity + + + Play title music + Play title music + + + Update Compatibility Database On Startup + Update Compatibility Database On Startup + + + Game Compatibility + Game Compatibility + + + Display Compatibility Data + Display Compatibility Data + + + Update Compatibility Database + Update Compatibility Database + + + Volume + Volume + + + Save + Save + + + Apply + Apply + + + Restore Defaults + Restore Defaults + + + Close + Close + + + Point your mouse at an option to display its description. + Point your mouse at an option to display its description. + + + Console Language:\nSets the language that the PS4 game uses.\nIt's recommended to set this to a language the game supports, which will vary by region. + Console Language:\nSets the language that the PS4 game uses.\nIt's recommended to set this to a language the game supports, which will vary by region. + + + Emulator Language:\nSets the language of the emulator's user interface. + Emulator Language:\nSets the language of the emulator's user interface. + + + Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. + Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. + + + Enable Discord Rich Presence:\nDisplays the emulator icon and relevant information on your Discord profile. + Enable Discord Rich Presence:\nDisplays the emulator icon and relevant information on your Discord profile. + + + Username:\nSets the PS4's account username, which may be displayed by some games. + Username:\nSets the PS4's account username, which may be displayed by some games. + + + Trophy Key:\nKey used to decrypt trophies. Must be obtained from your jailbroken console.\nMust contain only hex characters. + Trophy Key:\nKey used to decrypt trophies. Must be obtained from your jailbroken console.\nMust contain only hex characters. + + + Log Type:\nSets whether to synchronize the output of the log window for performance. May have adverse effects on emulation. + Log Type:\nSets whether to synchronize the output of the log window for performance. May have adverse effects on emulation. + + + Log Filter:\nFilters the log to only print specific information.\nExamples: "Core:Trace" "Lib.Pad:Debug Common.Filesystem:Error" "*:Critical"\nLevels: Trace, Debug, Info, Warning, Error, Critical - in this order, a specific level silences all levels preceding it in the list and logs every level after it. + Log Filter:\nFilters the log to only print specific information.\nExamples: "Core:Trace" "Lib.Pad:Debug Common.Filesystem:Error" "*:Critical"\nLevels: Trace, Debug, Info, Warning, Error, Critical - in this order, a specific level silences all levels preceding it in the list and logs every level after it. + + + Update:\nRelease: Official versions released every month that may be very outdated, but are more reliable and tested.\nNightly: Development versions that have all the latest features and fixes, but may contain bugs and are less stable. + Update:\nRelease: Official versions released every month that may be very outdated, but are more reliable and tested.\nNightly: Development versions that have all the latest features and fixes, but may contain bugs and are less stable. + + + Background Image:\nControl the opacity of the game background image. + Background Image:\nControl the opacity of the game background image. + + + Play Title Music:\nIf a game supports it, enable playing special music when selecting the game in the GUI. + Play Title Music:\nIf a game supports it, enable playing special music when selecting the game in the GUI. + + + Disable Trophy Pop-ups:\nDisable in-game trophy notifications. Trophy progress can still be tracked using the Trophy Viewer (right-click the game in the main window). + Disable Trophy Pop-ups:\nDisable in-game trophy notifications. Trophy progress can still be tracked using the Trophy Viewer (right-click the game in the main window). + + + Hide Cursor:\nChoose when the cursor will disappear:\nNever: You will always see the mouse.\nidle: Set a time for it to disappear after being idle.\nAlways: you will never see the mouse. + Hide Cursor:\nChoose when the cursor will disappear:\nNever: You will always see the mouse.\nidle: Set a time for it to disappear after being idle.\nAlways: you will never see the mouse. + + + Hide Idle Cursor Timeout:\nThe duration (seconds) after which the cursor that has been idle hides itself. + Hide Idle Cursor Timeout:\nThe duration (seconds) after which the cursor that has been idle hides itself. + + + Back Button Behavior:\nSets the controller's back button to emulate tapping the specified position on the PS4 touchpad. + Back Button Behavior:\nSets the controller's back button to emulate tapping the specified position on the PS4 touchpad. + + + Display Compatibility Data:\nDisplays game compatibility information in table view. Enable "Update Compatibility On Startup" to get up-to-date information. + Display Compatibility Data:\nDisplays game compatibility information in table view. Enable "Update Compatibility On Startup" to get up-to-date information. + + + Update Compatibility On Startup:\nAutomatically update the compatibility database when shadPS4 starts. + Update Compatibility On Startup:\nAutomatically update the compatibility database when shadPS4 starts. + + + Update Compatibility Database:\nImmediately update the compatibility database. + Update Compatibility Database:\nImmediately update the compatibility database. + + + Never + Never + + + Idle + Idle + + + Always + Always + + + Touchpad Left + Touchpad Left + + + Touchpad Right + Touchpad Right + + + Touchpad Center + Touchpad Center + + + None + None + + + Graphics Device:\nOn multiple GPU systems, select the GPU the emulator will use from the drop down list,\nor select "Auto Select" to automatically determine it. + Graphics Device:\nOn multiple GPU systems, select the GPU the emulator will use from the drop down list,\nor select "Auto Select" to automatically determine it. + + + Width/Height:\nSets the size of the emulator window at launch, which can be resized during gameplay.\nThis is different from the in-game resolution. + Width/Height:\nSets the size of the emulator window at launch, which can be resized during gameplay.\nThis is different from the in-game resolution. + + + Vblank Divider:\nThe frame rate at which the emulator refreshes at is multiplied by this number. Changing this may have adverse effects, such as increasing the game speed, or breaking critical game functionality that does not expect this to change! + Vblank Divider:\nThe frame rate at which the emulator refreshes at is multiplied by this number. Changing this may have adverse effects, such as increasing the game speed, or breaking critical game functionality that does not expect this to change! + + + Enable Shaders Dumping:\nFor the sake of technical debugging, saves the games shaders to a folder as they render. + Enable Shaders Dumping:\nFor the sake of technical debugging, saves the games shaders to a folder as they render. + + + Enable Null GPU:\nFor the sake of technical debugging, disables game rendering as if there were no graphics card. + Enable Null GPU:\nFor the sake of technical debugging, disables game rendering as if there were no graphics card. + + + Enable HDR:\nEnables HDR in games that support it.\nYour monitor must have support for the BT2020 PQ color space and the RGB10A2 swapchain format. + Enable HDR:\nEnables HDR in games that support it.\nYour monitor must have support for the BT2020 PQ color space and the RGB10A2 swapchain format. + + + Game Folders:\nThe list of folders to check for installed games. + Game Folders:\nThe list of folders to check for installed games. + + + Add:\nAdd a folder to the list. + Add:\nAdd a folder to the list. + + + Remove:\nRemove a folder from the list. + Remove:\nRemove a folder from the list. + + + Enable Debug Dumping:\nSaves the import and export symbols and file header information of the currently running PS4 program to a directory. + Enable Debug Dumping:\nSaves the import and export symbols and file header information of the currently running PS4 program to a directory. + + + Enable Vulkan Validation Layers:\nEnables a system that validates the state of the Vulkan renderer and logs information about its internal state.\nThis will reduce performance and likely change the behavior of emulation. + Enable Vulkan Validation Layers:\nEnables a system that validates the state of the Vulkan renderer and logs information about its internal state.\nThis will reduce performance and likely change the behavior of emulation. + + + Enable Vulkan Synchronization Validation:\nEnables a system that validates the timing of Vulkan rendering tasks.\nThis will reduce performance and likely change the behavior of emulation. + Enable Vulkan Synchronization Validation:\nEnables a system that validates the timing of Vulkan rendering tasks.\nThis will reduce performance and likely change the behavior of emulation. + + + Enable RenderDoc Debugging:\nIf enabled, the emulator will provide compatibility with Renderdoc to allow capture and analysis of the currently rendered frame. + Enable RenderDoc Debugging:\nIf enabled, the emulator will provide compatibility with Renderdoc to allow capture and analysis of the currently rendered frame. + + + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + + + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + + + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + + + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + + + Save Data Path:\nThe folder where game save data will be saved. + Save Data Path:\nThe folder where game save data will be saved. + + + Browse:\nBrowse for a folder to set as the save data path. + Browse:\nBrowse for a folder to set as the save data path. + + + Release + Release + + + Nightly + Nightly + + + Set the volume of the background music. + Set the volume of the background music. + + + Enable Motion Controls + Enable Motion Controls + + + Save Data Path + Save Data Path + + + Browse + Browse + + + async + async + + + sync + sync + + + Auto Select + Auto Select + + + Directory to install games + Directory to install games + + + Directory to save data + Directory to save data + + + Video + Video + + + Display Mode + Display Mode + + + Windowed + Windowed + + + Fullscreen + Fullscreen + + + Fullscreen (Borderless) + Fullscreen (Borderless) + + + Window Size + Window Size + + + W: + W: + + + H: + H: + + + Separate Log Files + Separate Log Files + + + Separate Log Files:\nWrites a separate logfile for each game. + Separate Log Files:\nWrites a separate logfile for each game. + + + Trophy Notification Position + Trophy Notification Position + + + Left + Left + + + Right + Right + + + Top + Top + + + Bottom + Bottom + + + Notification Duration + Notification Duration + + + Portable User Folder + Portable User Folder + + + Create Portable User Folder from Common User Folder + Create Portable User Folder from Common User Folder + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + + + Cannot create portable user folder + Cannot create portable user folder + + + %1 already exists + %1 already exists + + + Portable user folder created + Portable user folder created + + + %1 successfully created. + %1 successfully created. + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + + + + TrophyViewer + + Trophy Viewer + Trophy Viewer + + + Select Game: + Select Game: + + + Progress + Progress + + + Show Earned Trophies + Show Earned Trophies + + + Show Not Earned Trophies + Show Not Earned Trophies + + + Show Hidden Trophies + Show Hidden Trophies + + + diff --git a/src/qt_gui/translations/sq_AL.ts b/src/qt_gui/translations/sq_AL.ts index 0a90bcd10..50314a9b2 100644 --- a/src/qt_gui/translations/sq_AL.ts +++ b/src/qt_gui/translations/sq_AL.ts @@ -74,7 +74,7 @@ Select Patch File: - Përzgjidh Skedarin e Arnës: + Përzgjidh skedarin e arnës: Download Patches @@ -138,7 +138,7 @@ File Exists - Skedari Ekziston + Skedari ekziston File already exists. Do you want to replace it? @@ -411,7 +411,7 @@ D-Pad - D-Pad + Shigjetat Up @@ -451,7 +451,7 @@ Use per-game configs - Përdor konfigurime për secilën lojë + Përdor konfigurime të veçanta për secilën lojë L1 / LB @@ -541,6 +541,77 @@ Override Color Zëvendëso Ngjyrën + + Unable to Save + Ruajtja Dështoi + + + Cannot bind axis values more than once + Nuk mund të caktohen vlerat e boshtit më shumë se një herë + + + Save + Ruaj + + + Apply + Zbato + + + Restore Defaults + Rikthe Paracaktimet + + + Cancel + Anulo + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + Redakto caktimet e hyrjeve për Tastierën + Miun dhe Dorezën + + + Use Per-Game configs + Përdor konfigurime për secilën lojë + + + Error + Gabim + + + Could not open the file for reading + Skedari nuk mund të hapet për lexim + + + Could not open the file for writing + Skedari nuk mund të hapet për shkrim + + + Save Changes + Ruaj Ndryshimet + + + Do you want to save changes? + Do të ruash ndryshimet? + + + Help + Ndihmë + + + Do you want to reset your custom default config to the original default config? + A do ta rivendosësh konfigurimin tënd të paracaktuar të personalizuar te konfigurimi i paracaktuar origjinal? + + + Do you want to reset this config to your custom default config? + A do ta rivendosësh këtë konfigurim në konfigurimin tënd të paracaktuar të personalizuar? + + + Reset to Default + Rivendos në të Paracaktuarit + ElfViewer @@ -775,6 +846,10 @@ Delete DLC Fshi DLC-në + + Delete Trophy + Fshi Trofeun + Compatibility... Përputhshmëria... @@ -807,10 +882,6 @@ Error creating shortcut! Gabim në krijimin e shkurtores! - - Install PKG - Instalo PKG - Game Loja @@ -851,6 +922,10 @@ This game has no update folder to open! Kjo lojë nuk ka dosje përditësimi për të hapur! + + No log file found for this game! + Nuk u gjet asnjë skedar ditari për këtë lojë! + Failed to convert icon. Konvertimi i ikonës dështoi. @@ -859,32 +934,255 @@ This game has no save data to delete! Kjo lojë nuk ka të dhëna ruajtje për të fshirë! + + This game has no saved trophies to delete! + Kjo lojë nuk ka trofe të ruajtur për të fshirë! + Save Data Të dhënat e ruajtjes + + Trophy + Trofeu + SFO Viewer for Shikuesi SFO për - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - shadPS4 - Përzgjidh dosjen + Quickstart + Nisje e shpejtë - Select which directory you want to install to. - Përzgjidh në cilën dosje do që të instalosh. + FAQ + Pyetje të Shpeshta - Install All Queued to Selected Folder - Instalo të gjitha të radhiturat në dosjen e zgjedhur + Syntax + Sintaksa - Delete PKG File on Install - Fshi skedarin PKG pas instalimit + Special Bindings + Caktimet e Veçantë + + + Keybindings + Caktimet e Tasteve + + + + KBMSettings + + Configure Controls + Konfiguro Kontrollet + + + D-Pad + Shigjetat + + + Up + Lartë + + + unmapped + pacaktuar + + + Left + Majtas + + + Right + Djathtas + + + Down + Poshtë + + + Left Analog Halfmode + Mënyra e gjysmuar për levën e majtë + + + hold to move left stick at half-speed + mbaj shtypur për të lëvizur levën e majtë me gjysmën e shpejtësisë + + + Left Stick + Leva e Majtë + + + Config Selection + Zgjedhja e Konfigurimit + + + Common Config + Konfigurim i Përbashkët + + + Use per-game configs + Përdor konfigurime për secilën lojë + + + L1 + L1 + + + L2 + L2 + + + Text Editor + Redaktuesi i Tekstit + + + Help + Ndihmë + + + R1 + R1 + + + R2 + R2 + + + L3 + L3 + + + Touchpad Click + Klikim i Panelit me Prekje + + + Mouse to Joystick + Miu në Levë + + + *press F7 ingame to activate + *shtyp F7 gjatë lojës për ta aktivizuar + + + R3 + R3 + + + Options + Rregullime + + + Mouse Movement Parameters + Parametrat e Lëvizjes së Miut + + + note: click Help Button/Special Keybindings for more information + shënim: kliko Butonin e Ndihmës/Caktimet e Tasteve të Veçantë për më shumë informacion + + + Face Buttons + Butonat Kryesore + + + Triangle + Trekëndësh + + + Square + Katror + + + Circle + Rreth + + + Cross + Kryq + + + Right Analog Halfmode + Mënyra e gjysmuar për levën e djathtë + + + hold to move right stick at half-speed + mbaj shtypur për të lëvizur levën e djathtë me gjysmën e shpejtësisë + + + Right Stick + Leva e Djathtë + + + Speed Offset (def 0.125): + Ofset i Shpejtësisë (paracaktuar 0.125): + + + Copy from Common Config + Kopjo nga Konfigurimi i Përbashkët + + + Deadzone Offset (def 0.50): + Ofseti i Zonës së Vdekur (paracaktuar 0.50): + + + Speed Multiplier (def 1.0): + Shumëzuesi i Shpejtësisë (paracaktuar 1.0): + + + Common Config Selected + Konfigurimi i Përbashkët i Zgjedhur + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + Ky buton kopjon caktimet nga Konfigurimi i Përbashkët në profilin e zgjedhur aktualisht, dhe nuk mund të përdoret kur profili i zgjedhur aktualisht është Konfigurimi i Përbashkët. + + + Copy values from Common Config + Kopjo vlerat nga Konfigurimi i Përbashkët + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + A dëshiron të mbishkruash caktimet ekzistuese me ato nga Konfigurimi i Përbashkët? + + + Unable to Save + Ruajtja Dështoi + + + Cannot bind any unique input more than once + Asnjë hyrje unike nuk mund të caktohet më shumë se një herë + + + Press a key + Shtyp një tast + + + Cannot set mapping + Caktimi nuk u vendos dot + + + Mousewheel cannot be mapped to stick outputs + Rrota e miut nuk mund të caktohet për daljet e levës + + + Save + Ruaj + + + Apply + Zbato + + + Restore Defaults + Rikthe Paracaktimet + + + Cancel + Anulo @@ -893,10 +1191,6 @@ Open/Add Elf Folder Hap/Shto Dosje ELF - - Install Packages (PKG) - Instalo Paketat (PKG) - Boot Game Nis Lojën @@ -913,10 +1207,6 @@ Configure... Konfiguro... - - Install application from a .pkg file - Instalo aplikacionin nga një skedar .pkg - Recent Games Lojërat e fundit @@ -986,8 +1276,12 @@ Zbraz Listën e Lojërave - PKG Viewer - Shikuesi i PKG + Trophy Viewer + Shikuesi i Trofeve + + + No games found. Please add your games to your library first. + Nuk u gjetën lojëra. Shto lojërat në librarinë tënde fillimisht. Search... @@ -1097,70 +1391,6 @@ Only one file can be selected! Mund të përzgjidhet vetëm një skedar! - - PKG Extraction - Nxjerrja e PKG-së - - - Patch detected! - U zbulua një arnë! - - - PKG and Game versions match: - PKG-ja dhe versioni i Lojës përputhen: - - - Would you like to overwrite? - Dëshiron të mbishkruash? - - - PKG Version %1 is older than installed version: - Versioni %1 i PKG-së është më i vjetër se versioni i instaluar: - - - Game is installed: - Loja është instaluar: - - - Would you like to install Patch: - Dëshiron të instalosh Arnën: - - - DLC Installation - Instalimi i DLC-ve - - - Would you like to install DLC: %1? - Dëshiron të instalosh DLC-në: %1? - - - DLC already installed: - DLC-ja është instaluar tashmë: - - - Game already installed - Loja është instaluar tashmë - - - PKG ERROR - GABIM PKG - - - Extracting PKG %1/%2 - Po nxirret PKG-ja %1/%2 - - - Extraction Finished - Nxjerrja Përfundoi - - - Game successfully installed at %1 - Loja u instalua me sukses në %1 - - - File doesn't appear to be a valid PKG file - Skedari nuk duket si skedar PKG i vlefshëm - Run Game Ekzekuto lojën @@ -1169,14 +1399,6 @@ Eboot.bin file not found Skedari Eboot.bin nuk u gjet - - PKG File (*.PKG *.pkg) - Skedar PKG (*.PKG *.pkg) - - - PKG is a patch or DLC, please install the game first! - PKG-ja është një arnë ose DLC, të lutem instalo lojën fillimisht! - Game is already running! Loja tashmë është duke u ekzekutuar! @@ -1185,72 +1407,45 @@ shadPS4 shadPS4 - - - PKGViewer - Open Folder - Hap Dosjen + Play + Luaj - PKG ERROR - GABIM PKG + Pause + Pezullo - Name - Emri + Stop + Ndalo - Serial - Seriku + Restart + Rinis - Installed - Instaluar + Full Screen + Ekran i Plotë - Size - Madhësia + Controllers + Dorezat - Category - Kategoria + Keyboard + Tastiera - Type - Lloji + Refresh List + Rifresko Listën - App Ver - Versioni i aplikacionit + Resume + Rifillo - FW - Firmueri - - - Region - Rajoni - - - Flags - Flamurët - - - Path - Shtegu - - - File - Skedari - - - Unknown - E panjohur - - - Package - Paketa + Show Labels Under Icons + Shfaq Etiketat Poshtë Ikonave @@ -1279,13 +1474,9 @@ Emulator Emulatori - - Enable Separate Update Folder - Aktivizo dosjen e ndarë të përditësimit - Default tab when opening settings - Skeda e parazgjedhur kur hapen cilësimet + Skeda e paracaktuar kur hapen cilësimet Show Game Size In List @@ -1311,6 +1502,10 @@ Trophy Trofeu + + Open the custom trophy images/sounds folder + Hap dosjen e imazheve/tingujve të trofeve të personalizuar + Logger Regjistruesi i ditarit @@ -1381,7 +1576,7 @@ Enable Shaders Dumping - Aktivizo Zbrazjen e Shaders-ave + Aktivizo Zbrazjen e Shader-ave Enable NULL GPU @@ -1457,7 +1652,7 @@ Always Show Changelog - Shfaq gjithmonë regjistrin e ndryshimeve + Shfaq gjithmonë ditarin e ndryshimeve Update Channel @@ -1476,8 +1671,8 @@ Muzika e titullit - Disable Trophy Pop-ups - Çaktivizo njoftimet për Trofetë + Disable Trophy Notification + Çaktivizo Njoftimin e Trofeut Background Image @@ -1525,7 +1720,7 @@ Restore Defaults - Rikthe paracaktimet + Rikthe Paracaktimet Close @@ -1543,10 +1738,6 @@ Emulator Language:\nSets the language of the emulator's user interface. Gjuha e emulatorit:\nPërcakton gjuhën e ndërfaqes së përdoruesit të emulatorit. - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Aktivizo dosjen e ndarë të përditësimit:\nAktivizon instalimin e përditësimeve të lojërave në dosje të veçanta për menaxhim më të lehtë.\nKjo mund të krijohet manualisht duke shtuar përditësimin e shpaketuar në dosjen e lojës me emrin "CUSA00000-UPDATE" ku ID-ja CUSA përputhet me ID-në e lojës. - Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. Shfaq ekranin e ngarkesës:\nShfaq ekranin e ngarkesës së lojës (një pamje e veçantë) gjatë fillimit të lojës. @@ -1597,7 +1788,7 @@ Back Button Behavior:\nSets the controller's back button to emulate tapping the specified position on the PS4 touchpad. - Sjellja e butonit mbrapa:\nLejon të përcaktohet se në cilën pjesë të tastierës prekëse do të imitojë një prekje butoni mbrapa. + Sjellja e butonit mbrapa:\nLejon të përcaktohet se në cilën pjesë të panelit me prekje të dorezës do të imitojë një prekje butoni mbrapa. Display Compatibility Data:\nDisplays game compatibility information in table view. Enable "Update Compatibility On Startup" to get up-to-date information. @@ -1625,15 +1816,15 @@ Touchpad Left - Tastiera prekëse majtas + Paneli me Prekje Majtas Touchpad Right - Tastiera prekëse djathtas + Paneli me Prekje Djathtas Touchpad Center - Tastiera prekëse në qendër + Paneli me Prekje në Qendër None @@ -1803,6 +1994,62 @@ Separate Log Files:\nWrites a separate logfile for each game. Skedarë të Ditarit të Ndarë:\nShkruan një skedar të ditarit të veçuar për secilën lojë. + + Trophy Notification Position + Pozicioni i Njoftimit të Trofeve + + + Left + Majtas + + + Right + Djathtas + + + Top + Sipër + + + Bottom + Poshtë + + + Notification Duration + Kohëzgjatja e Njoftimit + + + Portable User Folder + Dosja Portative e Përdoruesit + + + Create Portable User Folder from Common User Folder + Krijo Dosje Portative të Përdoruesit nga Dosja e Përbashkët e Përdoruesit + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + Dosja portative e përdoruesit:\nRuan cilësimet dhe të dhënat të shadPS4 që do të zbatohen vetëm për konstruktin e shadPS4 të vendosur në dosjen aktuale. Rinis aplikacionin pasi të krijosh dosjen portative te përdoruesit për ta përdorur. + + + Cannot create portable user folder + Dosja portative e përdoruesit nuk u krijua dot + + + %1 already exists + %1 tashmë ekziston + + + Portable user folder created + Dosja portative e përdoruesit u krijua + + + %1 successfully created. + %1 u krijua me sukses. + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + Hap dosjen e imazheve/tingujve të trofeve të personalizuar:\nMund të shtosh imazhe të personalizuara për trofetë dhe një audio.\nShto skedarët në dosjen custom_trophy me emrat që vijojnë:\ntrophy.wav ose trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nShënim: Tingulli do të punojë vetëm në versionet QT. + TrophyViewer @@ -1810,5 +2057,25 @@ Trophy Viewer Shikuesi i Trofeve + + Select Game: + Zgjidh Lojën: + + + Progress + Ecuria + + + Show Earned Trophies + Shfaq Trofetë që janë fituar + + + Show Not Earned Trophies + Shfaq Trofetë që nuk janë fituar + + + Show Hidden Trophies + Shfaq Trofetë e Fshehur + diff --git a/src/qt_gui/translations/sv_SE.ts b/src/qt_gui/translations/sv_SE.ts index e9ea2f20a..ce0da785c 100644 --- a/src/qt_gui/translations/sv_SE.ts +++ b/src/qt_gui/translations/sv_SE.ts @@ -541,6 +541,77 @@ Override Color Åsidosätt färg + + Unable to Save + Kunde inte spara + + + Cannot bind axis values more than once + Kan inte binda axelvärden fler än en gång + + + Save + Spara + + + Apply + Tillämpa + + + Restore Defaults + Återställ till standard + + + Cancel + Avbryt + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + Redigera inmatningsbindningar för tangentbord + mus och kontroller + + + Use Per-Game configs + Använd konfigurationer per-spel + + + Error + Fel + + + Could not open the file for reading + Kunde inte öppna filen för läsning + + + Could not open the file for writing + Kunde inte öppna filen för skrivning + + + Save Changes + Spara ändringar + + + Do you want to save changes? + Vill du spara ändringarna? + + + Help + Hjälp + + + Do you want to reset your custom default config to the original default config? + Vill du återställa din anpassade standardkonfiguration till ursprungliga standardkonfigurationen? + + + Do you want to reset this config to your custom default config? + Vill du återställa denna konfiguration till din anpassade standardkonfiguration? + + + Reset to Default + Återställ till standard + ElfViewer @@ -775,6 +846,10 @@ Delete DLC Ta bort DLC + + Delete Trophy + Ta bort trofé + Compatibility... Kompatibilitet... @@ -807,10 +882,6 @@ Error creating shortcut! Fel vid skapandet av genväg! - - Install PKG - Installera PKG - Game Spel @@ -851,6 +922,10 @@ This game has no update folder to open! Detta spel har ingen uppdateringsmapp att öppna! + + No log file found for this game! + Ingen loggfil hittades för detta spel! + Failed to convert icon. Misslyckades med att konvertera ikon. @@ -859,32 +934,255 @@ This game has no save data to delete! Detta spel har inget sparat data att ta bort! + + This game has no saved trophies to delete! + Detta spel har inga sparade troféer att ta bort! + Save Data Sparat data + + Trophy + Trofé + SFO Viewer for SFO-visare för - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - shadPS4 - Välj katalog + Quickstart + Snabbstart - Select which directory you want to install to. - Välj vilken katalog som du vill installera till. + FAQ + Frågor och svar - Install All Queued to Selected Folder - Installera alla köade till markerad mapp + Syntax + Syntax - Delete PKG File on Install - Ta bort PKG-fil efter installation + Special Bindings + Speciella bindningar + + + Keybindings + Tangentbindningar + + + + KBMSettings + + Configure Controls + Konfigurera kontroller + + + D-Pad + Riktningsknappar + + + Up + Upp + + + unmapped + inte mappad + + + Left + Vänster + + + Right + Höger + + + Down + Ner + + + Left Analog Halfmode + Halvläge för vänster analog + + + hold to move left stick at half-speed + håll ner för att flytta vänster spak i halvfart + + + Left Stick + Vänster spak + + + Config Selection + Konfigurationsval + + + Common Config + Gemensam konfiguration + + + Use per-game configs + Använd konfiguration per-spel + + + L1 + L1 + + + L2 + L2 + + + Text Editor + Textredigerare + + + Help + Hjälp + + + R1 + R1 + + + R2 + R2 + + + L3 + L3 + + + Touchpad Click + Klick på styrplatta + + + Mouse to Joystick + Mus till styrspak + + + *press F7 ingame to activate + *tryck F7 i spelet för att aktivera + + + R3 + R3 + + + Options + Alternativ + + + Mouse Movement Parameters + Parametrar för musrörelse + + + note: click Help Button/Special Keybindings for more information + observera: klicka på Hjälp-knapp/Speciella tangentbindningar för mer information + + + Face Buttons + Handlingsknappar + + + Triangle + Triangel + + + Square + Fyrkant + + + Circle + Cirkel + + + Cross + Kryss + + + Right Analog Halfmode + Halvläge för höger analog + + + hold to move right stick at half-speed + håll ner för att flytta höger spak i halvfart + + + Right Stick + Höger spak + + + Speed Offset (def 0.125): + Offset för hastighet (standard 0.125): + + + Copy from Common Config + Kopiera från gemensam konfiguration + + + Deadzone Offset (def 0.50): + Offset för dödläge (standard 0.50): + + + Speed Multiplier (def 1.0): + Hastighetsmultiplikator (standard 1.0): + + + Common Config Selected + Gemensam konfiguration valdes + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + Den här knappen kopierar mappningar från gemensam konfiguration till den aktuella valda profilen och kan inte användas när den aktuella valda profilen är gemensam konfiguration. + + + Copy values from Common Config + Kopiera värden från gemensam konfiguration + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + Vill du skriva över befintliga mappningar med mappningarna från gemensam konfiguration? + + + Unable to Save + Kunde inte spara + + + Cannot bind any unique input more than once + Kan inte binda någon unik inmatning fler än en gång + + + Press a key + Tryck på en tangent + + + Cannot set mapping + Kan inte ställa in mappning + + + Mousewheel cannot be mapped to stick outputs + Mushjulet kan inte mappas till spakutmatningar + + + Save + Spara + + + Apply + Tillämpa + + + Restore Defaults + Återställ till standard + + + Cancel + Avbryt @@ -893,10 +1191,6 @@ Open/Add Elf Folder Öppna/Lägg till Elf-mapp - - Install Packages (PKG) - Installera paket (PKG) - Boot Game Starta spel @@ -913,10 +1207,6 @@ Configure... Konfigurera... - - Install application from a .pkg file - Installera program från en .pkg-fil - Recent Games Senaste spel @@ -986,8 +1276,12 @@ Dumpa spellista - PKG Viewer - PKG-visare + Trophy Viewer + Trofévisare + + + No games found. Please add your games to your library first. + Inga spel hittades. Lägg till dina spel till biblioteket först. Search... @@ -1097,70 +1391,6 @@ Only one file can be selected! Endast en fil kan väljas! - - PKG Extraction - PKG-extrahering - - - Patch detected! - Patch upptäcktes! - - - PKG and Game versions match: - PKG och spelversioner matchar: - - - Would you like to overwrite? - Vill du skriva över? - - - PKG Version %1 is older than installed version: - PKG-versionen %1 är äldre än installerad version: - - - Game is installed: - Spelet är installerat: - - - Would you like to install Patch: - Vill du installera patch: - - - DLC Installation - DLC-installation - - - Would you like to install DLC: %1? - Vill du installera DLC: %1? - - - DLC already installed: - DLC redan installerat: - - - Game already installed - Spelet redan installerat - - - PKG ERROR - PKG-FEL - - - Extracting PKG %1/%2 - Extraherar PKG %1/%2 - - - Extraction Finished - Extrahering färdig - - - Game successfully installed at %1 - Spelet installerades i %1 - - - File doesn't appear to be a valid PKG file - Filen verkar inte vara en giltig PKG-fil - Run Game Kör spel @@ -1169,14 +1399,6 @@ Eboot.bin file not found Filen eboot.bin hittades inte - - PKG File (*.PKG *.pkg) - PKG-fil (*.PKG *.pkg) - - - PKG is a patch or DLC, please install the game first! - PKG är en patch eller DLC. Installera spelet först! - Game is already running! Spelet är redan igång! @@ -1185,72 +1407,45 @@ shadPS4 shadPS4 - - - PKGViewer - Open Folder - Öppna mapp + Play + Spela - PKG ERROR - PKG-FEL + Pause + Paus - Name - Namn + Stop + Stoppa - Serial - Serienummer + Restart + Starta om - Installed - Installerat + Full Screen + Helskärm - Size - Storlek + Controllers + Kontroller - Category - Kategori + Keyboard + Tangentbord - Type - Typ + Refresh List + Uppdatera lista - App Ver - Appver + Resume + Återuppta - FW - FW - - - Region - Region - - - Flags - Flaggor - - - Path - Sökväg - - - File - Arkiv - - - Unknown - Okänt - - - Package - Paket + Show Labels Under Icons + Visa etiketter under ikoner @@ -1279,10 +1474,6 @@ Emulator Emulator - - Enable Separate Update Folder - Aktivera separat uppdateringsmapp - Default tab when opening settings Standardflik när inställningar öppnas @@ -1311,6 +1502,10 @@ Trophy Troféer + + Open the custom trophy images/sounds folder + Öppna mappen för anpassade trofébilder/ljud + Logger Loggning @@ -1476,8 +1671,8 @@ Titelmusik - Disable Trophy Pop-ups - Inaktivera popup för troféer + Disable Trophy Notification + Inaktivera troféaviseringar Background Image @@ -1543,10 +1738,6 @@ Emulator Language:\nSets the language of the emulator's user interface. Emulatorspråk:\nStäller in språket för emulatorns användargränssnitt - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Aktivera separat uppdateringsmapp:\nAktiverar installation av speluppdateringar i en separat mapp för enkel hantering.\nDetta kan skapas manuellt genom att lägga till uppackad uppdatering till spelmappen med namnet "CUSA00000-UPDATE" där CUSA ID matchar spelets id - Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. Visa startskärm:\nVisar spelets startskärm (en speciell bild) när spelet startas @@ -1803,6 +1994,62 @@ Separate Log Files:\nWrites a separate logfile for each game. Separata loggfiler:\nSkriver en separat loggfil för varje spel. + + Trophy Notification Position + Aviseringsposition för trofé + + + Left + Vänster + + + Right + Höger + + + Top + Överst + + + Bottom + Nederst + + + Notification Duration + Varaktighet för avisering + + + Portable User Folder + Portabel användarmapp + + + Create Portable User Folder from Common User Folder + Skapa portabel användarmapp från gemensam användarmapp + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + Portabel användarmapp:\nLagrar shadPS4-inställningar och data som endast tillämpas på den shadPS4-version som finns i den aktuella mappen. Starta om appen efter att du har skapat den portabla användarmappen för att börja använda den. + + + Cannot create portable user folder + Kan inte skapa portabel användarmapp + + + %1 already exists + %1 finns redan + + + Portable user folder created + Portabel användarmapp skapad + + + %1 successfully created. + %1 skapades. + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + Öppna mappen för anpassade trofébilder/ljud:\nDu kan lägga till egna bilder till troféerna och ett ljud.\nLägg till filerna i custom_trophy med följande namn:\ntrophy.wav ELLER trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nObservera: Ljudet fungerar endast i QT-versioner. + TrophyViewer @@ -1810,5 +2057,25 @@ Trophy Viewer Trofé-visare + + Select Game: + Välj spel: + + + Progress + Förlopp + + + Show Earned Trophies + Visa förtjänade troféer + + + Show Not Earned Trophies + Visa icke-förtjänade troféer + + + Show Hidden Trophies + Visa dolda troféer + diff --git a/src/qt_gui/translations/tr_TR.ts b/src/qt_gui/translations/tr_TR.ts index ac7dee9a4..f5f7b65e5 100644 --- a/src/qt_gui/translations/tr_TR.ts +++ b/src/qt_gui/translations/tr_TR.ts @@ -26,11 +26,11 @@ Cheats/Patches are experimental.\nUse with caution.\n\nDownload cheats individually by selecting the repository and clicking the download button.\nIn the Patches tab, you can download all patches at once, choose which ones you want to use, and save your selection.\n\nSince we do not develop the Cheats/Patches,\nplease report issues to the cheat author.\n\nCreated a new cheat? Visit:\n - Cheats/Patches deneysel niteliktedir.\nDikkatli kullanın.\n\nCheat'leri ayrı ayrı indirerek, depo seçerek ve indirme düğmesine tıklayarak indirin.\nPatches sekmesinde tüm patch'leri bir kerede indirebilir, hangi patch'leri kullanmak istediğinizi seçebilir ve seçiminizi kaydedebilirsiniz.\n\nCheats/Patches'i geliştirmediğimiz için,\nproblemleri cheat yazarına bildirin.\n\nYeni bir cheat mi oluşturduğunuz? Şu adresi ziyaret edin:\n + Hileler/Yamalar deneysel özelliklerdir.\nDikkatli kullanın.\n\nHileleri depo seçerek ve indirme düğmesine tıklayarak ayrı ayrı indirin.\nYamalar sekmesinde tüm yamaları tek seferde indirebilir, hangi yamaları kullanmak istediğinizi seçebilir ve seçiminizi kaydedebilirsiniz.\n\nHileleri ve yamaları biz geliştirmediğimiz için\nsorunlarınızı hile geliştiricisine bildirin.\n\nYeni bir hile oluşturduysanız şu adresi ziyaret edin:\n No Image Available - Görüntü Mevcut Değil + Kaynak Mevcut Değil Serial: @@ -70,7 +70,7 @@ Do you want to delete the selected file?\n%1 - Seçilen dosyayı silmek istiyor musunuz?\n%1 + Seçili dosyayı silmek istiyor musunuz?\n%1 Select Patch File: @@ -122,7 +122,7 @@ Success - Başarı + Başarılı Options saved successfully. @@ -138,11 +138,11 @@ File Exists - Dosya Var + Dosya mevcut File already exists. Do you want to replace it? - Dosya zaten var. Üzerine yazmak ister misiniz? + Dosya zaten mevcut. Var olan dosyayı değiştirmek istiyor musunuz? Failed to save file: @@ -431,7 +431,7 @@ Left Stick Deadzone (def:2 max:127) - Sol Analog Ölü Bölgesi (şu an:2, en çok:127) + Sol Analog Ölü Bölgesi (varsayılan: 2, en çok: 127) Left Deadzone @@ -447,11 +447,11 @@ Common Config - Genel Yapılandırma + Ortak Yapılandırma Use per-game configs - Oyuna özel yapılandırmaları kullan + Oyuna özel yapılandırma kullan L1 / LB @@ -507,7 +507,7 @@ Right Stick Deadzone (def:2, max:127) - Sağ Analog Ölü Bölgesi (şu an:2, en çok:127) + Sağ Analog Ölü Bölgesi (varsayılan: 2, en çok: 127) Right Deadzone @@ -541,6 +541,77 @@ Override Color Rengi Geçersiz Kıl + + Unable to Save + Kaydedilemedi + + + Cannot bind axis values more than once + Eksen değerleri birden fazla kez bağlanamaz + + + Save + Kaydet + + + Apply + Uygula + + + Restore Defaults + Varsayılanlara Sıfırla + + + Cancel + İptal + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + Klavye + Fare ve Kontrolcü tuş atamalarını düzenle + + + Use Per-Game configs + Oyuna özel yapılandırma kullan + + + Error + Hata + + + Could not open the file for reading + Dosya okumak için açılamadı + + + Could not open the file for writing + Dosya yazmak için açılamadı + + + Save Changes + Değişiklikleri Kaydet + + + Do you want to save changes? + Değişiklikleri kaydetmek istiyor musunuz? + + + Help + Yardım + + + Do you want to reset your custom default config to the original default config? + Özel varsayılan yapılandırmanızı, orijinal varsayılan yapılandırmaya sıfırlamak istiyor musunuz? + + + Do you want to reset this config to your custom default config? + Bu yapılandırmayı özel varsayılan yapılandırmanıza sıfırlamak istiyor musunuz? + + + Reset to Default + Varsayılanlara Sıfırla + ElfViewer @@ -584,7 +655,7 @@ Directory to install DLC - İndirilebilir içeriğin yükleneceği dizin + DLC'lerin yükleneceği dizin @@ -773,7 +844,11 @@ Delete DLC - İndirilebilir İçeriği Sil + DLC'yi Sil + + + Delete Trophy + Kupayı Sil Compatibility... @@ -807,10 +882,6 @@ Error creating shortcut! Kısayol oluşturulurken hata oluştu! - - Install PKG - PKG Yükle - Game Oyun @@ -825,11 +896,11 @@ This game has no DLC to delete! - Bu oyunun silinecek indirilebilir içeriği yok! + Bu oyunun silinecek DLC'si yok! DLC - İndirilebilir İçerik + DLC Delete %1 @@ -851,6 +922,10 @@ This game has no update folder to open! Bu oyunun açılacak güncelleme klasörü yok! + + No log file found for this game! + Bu oyun için günlük dosyası bulunamadı! + Failed to convert icon. Simge dönüştürülemedi. @@ -859,43 +934,262 @@ This game has no save data to delete! Bu oyunun silinecek kayıt verisi yok! + + This game has no saved trophies to delete! + Bu oyunun silinecek kupası yok! + Save Data Kayıt Verisi + + Trophy + Kupa + SFO Viewer for SFO Görüntüleyici: - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - shadPS4 - Klasörü Seç + Quickstart + Hızlı Başlangıç - Select which directory you want to install to. - Hangi dizine yüklemek istediğinizi seçin. + FAQ + SSS - Install All Queued to Selected Folder - Tüm Kuyruktakileri Seçili Klasöre Yükle + Syntax + Sözdizimi - Delete PKG File on Install - Yüklemede PKG Dosyasını Sil + Special Bindings + Özel Atamalar + + + Keybindings + Tuş Atamaları + + + + KBMSettings + + Configure Controls + Kontrolleri Yapılandır + + + D-Pad + Yön Düğmeleri + + + Up + Yukarı + + + unmapped + atanmamış + + + Left + Sol + + + Right + Sağ + + + Down + Aşağı + + + Left Analog Halfmode + Sol Analog Yarı Modu + + + hold to move left stick at half-speed + sol analogu yarı hızda hareket ettirmek için basılı tutun + + + Left Stick + Sol Analog + + + Config Selection + Yapılandırma Seçimi + + + Common Config + Ortak Yapılandırma + + + Use per-game configs + Oyuna özel yapılandırma kullan + + + L1 + L1 + + + L2 + L2 + + + Text Editor + Metin Düzenleyici + + + Help + Yardım + + + R1 + R1 + + + R2 + R2 + + + L3 + L3 + + + Touchpad Click + Dokunmatik Yüzey Tıklaması + + + Mouse to Joystick + Mouse'dan Kontrolcü + + + *press F7 ingame to activate + *Etkinleştirmek için oyundayken F7'ye basın + + + R3 + R3 + + + Options + Seçenekler + + + Mouse Movement Parameters + Mouse Hızı Değişkenleri + + + note: click Help Button/Special Keybindings for more information + Not: Daha fazla bilgi için Yardım ya da Özel Atamalar'a tıklayın + + + Face Buttons + Eylem Düğmeleri + + + Triangle + Üçgen + + + Square + Kare + + + Circle + Daire + + + Cross + Çarpı + + + Right Analog Halfmode + Sağ Analog Yarı Modu + + + hold to move right stick at half-speed + sağ analogu yarı hızda hareket ettirmek için basılı tutun + + + Right Stick + Sağ Analog + + + Speed Offset (def 0.125): + Hız Sapması (varsayılan 0.125): + + + Copy from Common Config + Ortak Yapılandırmadan Kopyala + + + Deadzone Offset (def 0.50): + Ölü Bölge Sapması (varsayılan 0.50): + + + Speed Multiplier (def 1.0): + Hız Çarpanı (varsayılan 1.0): + + + Common Config Selected + Ortak Yapılandırma Seçildi + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + Bu tuş, Ortak Yapılandırma'daki atamaları seçili profile kopyalar ve seçili profil Ortak Yapılandırma ise kullanılamaz. + + + Copy values from Common Config + Ortak Yapılandırmadan Değerleri Kopyala + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + Mevcut atamaların üzerine ortak yapılandırmadaki atamaları yazmak istiyor musunuz? + + + Unable to Save + Kaydedilemedi + + + Cannot bind any unique input more than once + Herhangi bir benzersiz girdi birden fazla kez bağlanamaz + + + Press a key + Bir tuşa basın + + + Cannot set mapping + Atama ayarlanamıyor + + + Mousewheel cannot be mapped to stick outputs + Mouse tekerleği analog çıkışlarına atanamaz + + + Save + Kaydet + + + Apply + Uygula + + + Restore Defaults + Varsayılanlara Sıfırla + + + Cancel + İptal MainWindow Open/Add Elf Folder - Elf Klasörünü Aç/Ekle - - - Install Packages (PKG) - Paketleri Kur (PKG) + Elf Klasörü Aç/Ekle Boot Game @@ -913,10 +1207,6 @@ Configure... Yapılandır... - - Install application from a .pkg file - .pkg dosyasından uygulama yükle - Recent Games Son Oyunlar @@ -947,11 +1237,11 @@ Tiny - Küçük + Minik Small - Ufak + Küçük Medium @@ -986,8 +1276,12 @@ Oyun Listesini Kaydet - PKG Viewer - PKG Görüntüleyici + Trophy Viewer + Kupa Görüntüleyici + + + No games found. Please add your games to your library first. + Oyun bulunamadı. Oyunlarınızı lütfen önce kütüphanenize ekleyin. Search... @@ -1097,70 +1391,6 @@ Only one file can be selected! Sadece bir dosya seçilebilir! - - PKG Extraction - PKG Çıkartma - - - Patch detected! - Yama tespit edildi! - - - PKG and Game versions match: - PKG ve oyun sürümleri uyumlu: - - - Would you like to overwrite? - Üzerine yazmak ister misiniz? - - - PKG Version %1 is older than installed version: - PKG Sürümü %1, kurulu sürümden daha eski: - - - Game is installed: - Oyun yüklendi: - - - Would you like to install Patch: - Yamanın yüklenmesini ister misiniz: - - - DLC Installation - DLC Yükleme - - - Would you like to install DLC: %1? - DLC'yi yüklemek ister misiniz: %1? - - - DLC already installed: - DLC zaten yüklü: - - - Game already installed - Oyun zaten yüklü - - - PKG ERROR - PKG HATASI - - - Extracting PKG %1/%2 - PKG Çıkarılıyor %1/%2 - - - Extraction Finished - Çıkarma Tamamlandı - - - Game successfully installed at %1 - Oyun başarıyla %1 konumuna yüklendi - - - File doesn't appear to be a valid PKG file - Dosya geçerli bir PKG dosyası gibi görünmüyor - Run Game Oyunu Çalıştır @@ -1169,14 +1399,6 @@ Eboot.bin file not found Eboot.bin dosyası bulunamadı - - PKG File (*.PKG *.pkg) - PKG Dosyası (*.PKG *.pkg) - - - PKG is a patch or DLC, please install the game first! - PKG bir yama ya da indirilebilir içerik, lütfen önce oyunu yükleyin! - Game is already running! Oyun zaten çalışıyor! @@ -1185,72 +1407,45 @@ shadPS4 shadPS4 - - - PKGViewer - Open Folder - Klasörü Aç + Play + Başlat - PKG ERROR - PKG HATASI + Pause + Duraklat - Name - Ad + Stop + Durdur - Serial - Seri Numarası + Restart + Yeniden Başlat - Installed - Yüklü + Full Screen + Tam Ekran - Size - Boyut + Controllers + Kontrolcüler - Category - Kategori + Keyboard + Klavye - Type - Tür + Refresh List + Listeyi Yenile - App Ver - Uygulama Sürümü + Resume + Devam Et - FW - Sistem Yazılımı - - - Region - Bölge - - - Flags - Bayraklar - - - Path - Yol - - - File - Dosya - - - Unknown - Bilinmeyen - - - Package - Paket + Show Labels Under Icons + Simgelerin Altında Etiketleri Göster @@ -1279,10 +1474,6 @@ Emulator Emülatör - - Enable Separate Update Folder - Ayrı Güncelleme Klasörünü Etkinleştir - Default tab when opening settings Ayarlar açıldığında varsayılan sekme @@ -1311,6 +1502,10 @@ Trophy Kupa + + Open the custom trophy images/sounds folder + Özel kupa görüntüleri/sesleri klasörünü aç + Logger Kayıt Tutucu @@ -1385,11 +1580,11 @@ Enable NULL GPU - NULL GPU'yu Etkinleştir + NULL GPU'yu Etkinleştir Enable HDR - HDR'yi Etkinleştir + HDR Paths @@ -1476,8 +1671,8 @@ Oyun Müziği - Disable Trophy Pop-ups - Kupa Açılır Pencerelerini Devre Dışı Bırak + Disable Trophy Notification + Kupa Bildirimini Devre Dışı Bırak Background Image @@ -1533,7 +1728,7 @@ Point your mouse at an option to display its description. - Seçenek üzerinde farenizi tutarak açıklamasını görüntüleyin. + Açıklamasını görüntülemek için mouse'unuzu bir seçeneğin üzerine getirin. Console Language:\nSets the language that the PS4 game uses.\nIt's recommended to set this to a language the game supports, which will vary by region. @@ -1543,10 +1738,6 @@ Emulator Language:\nSets the language of the emulator's user interface. Emülatör Dili:\nEmülatörün kullanıcı arayüzünün dilini ayarlar. - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management. - Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. Açılış Ekranını Göster:\nOyun açılırken (özel bir görüntü) açılış ekranını gösterir. @@ -1593,7 +1784,7 @@ Hide Idle Cursor Timeout:\nThe duration (seconds) after which the cursor that has been idle hides itself. - Hareket etmeden sonra imlecin kaybolacağı süreyi ayarlayın. + İmleç İçin Hareketsizlik Zaman Aşımı:\nBoşta kalan imlecin kendini kaç saniye sonra gizleyeceğidir. Back Button Behavior:\nSets the controller's back button to emulate tapping the specified position on the PS4 touchpad. @@ -1661,7 +1852,7 @@ Enable HDR:\nEnables HDR in games that support it.\nYour monitor must have support for the BT2020 PQ color space and the RGB10A2 swapchain format. - Enable HDR:\nEnables HDR in games that support it.\nYour monitor must have support for the BT2020 PQ color space and the RGB10A2 swapchain format. + HDR'yi Etkinleştir:\nDestekleyen oyunlarda HDR'yi etkinleştirir.\nMonitörünüz, BT2020 PQ renk alanını ve RGB10A2 takas zinciri biçimini desteklemelidir. Game Folders:\nThe list of folders to check for installed games. @@ -1697,7 +1888,7 @@ Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. - Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + Çökme Tanılamaları:\nÇökme anındaki Vulkan durumu hakkında bilgi içeren bir .yaml dosyası oluşturur.\n'Cihaz kayıp' hatalarını ayıklamak için kullanışlıdır. Bunu etkinleştirdiyseniz, Ana Bilgisayar ve Konuk Hata Ayıklama İşaretleyicileri'ni etkinleştirmelisiniz.\nIntel GPU'lar üzerinde çalışmaz.\nÇalışabilmesi için Vulkan Doğrulama Katmanları'nın etkinleştirilmesine ve Vulkan SDK'sine ihtiyacınız vardır. Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. @@ -1705,7 +1896,7 @@ Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. - Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + Ana Bilgisayar Hata Ayıklama Göstergeleri:\nVulkan komutlarının etrafına belirli AMDGPU komutları için göstergeler gibi emülatör tarafı bilgileri ekler ve kaynaklara hata ayıklama adları verir.\nBunu etkinleştirdiyseniz, Çökme Tanılamaları'nı etkinleştirmelisiniz.\nRenderDoc gibi programlar için faydalıdır. Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. @@ -1765,15 +1956,15 @@ Video - Video + Görüntü Display Mode - Display Mode + Görüntü Modu Windowed - Windowed + Pencereli Fullscreen @@ -1803,6 +1994,62 @@ Separate Log Files:\nWrites a separate logfile for each game. Ayrı Günlük Dosyaları:\nHer oyun için ayrı bir günlük dosyası yazar. + + Trophy Notification Position + Kupa Bildirim Konumu + + + Left + Sol + + + Right + Sağ + + + Top + Üst + + + Bottom + Alt + + + Notification Duration + Bildirim Süresi + + + Portable User Folder + Taşınabilir Kullanıcı Klasörü + + + Create Portable User Folder from Common User Folder + Ortak Kullanıcı Klasöründen Taşınabilir Kullanıcı Klasörü Oluştur + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + Taşınabilir kullanıcı klasörü:\nYalnızca geçerli klasörde bulunan shadPS4 derlemesine uygulanacak shadPS4 ayarlarını ve verilerini depolar. Kullanmaya başlamak için taşınabilir kullanıcı klasörünü oluşturduktan sonra uygulamayı yeniden başlatın. + + + Cannot create portable user folder + Taşınabilir kullanıcı klasörü oluşturulamıyor + + + %1 already exists + %1 zaten mevcut + + + Portable user folder created + Taşınabilir kullanıcı klasörü oluşturuldu + + + %1 successfully created. + %1 başarıyla oluşturuldu. + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + Özel kupa görüntüleri/sesleri klasörünü aç:\nKupalara özel görüntüler ve sesler ekleyebilirsiniz.\nDosyaları aşağıdaki adlarla custom_trophy'ye ekleyin:\ntrophy.wav ya da trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNot: Ses yalnızca QT sürümlerinde çalışacaktır. + TrophyViewer @@ -1810,5 +2057,25 @@ Trophy Viewer Kupa Görüntüleyici + + Select Game: + Oyun Seç: + + + Progress + İlerleme + + + Show Earned Trophies + Kazanılmış Kupaları Göster + + + Show Not Earned Trophies + Kazanılmamış Kupaları Göster + + + Show Hidden Trophies + Gizli Kupaları Göster + diff --git a/src/qt_gui/translations/uk_UA.ts b/src/qt_gui/translations/uk_UA.ts index 0a3865d49..3eb88bcab 100644 --- a/src/qt_gui/translations/uk_UA.ts +++ b/src/qt_gui/translations/uk_UA.ts @@ -407,139 +407,210 @@ ControlSettings Configure Controls - Configure Controls + Налаштування елементів керування D-Pad - D-Pad + Хрестовина Up - Up + Вгору Left - Left + Ліворуч Right - Right + Праворуч Down - Down + Вниз Left Stick Deadzone (def:2 max:127) - Left Stick Deadzone (def:2 max:127) + Мертва зона лівого стику (за замов.: 2, максимум: 127) Left Deadzone - Left Deadzone + Ліва мертва зона Left Stick - Left Stick + Лівий стік Config Selection - Config Selection + Вибір конфігурації Common Config - Common Config + Загальна конфігурація Use per-game configs - Use per-game configs + Використовувати ігрові конфігурації L1 / LB - L1 / LB + L1 / Лівий Бампер L2 / LT - L2 / LT + L2 / Лівий Тригер Back - Back + Назад R1 / RB - R1 / RB + R1 / Правий Бампер R2 / RT - R2 / RT + R2 / Правий Тригер L3 - L3 + Кнопка лівого стику Options / Start - Options / Start + Опції / Старт R3 - R3 + Кнопка правого стику Face Buttons - Face Buttons + Лицьові кнопки Triangle / Y - Triangle / Y + Трикутник / Y Square / X - Square / X + Квадрат / X Circle / B - Circle / B + Коло / B Cross / A - Cross / A + Хрест / A Right Stick Deadzone (def:2, max:127) - Right Stick Deadzone (def:2, max:127) + Мертва зона правого стику (за замов.: 2, максимум: 127) Right Deadzone - Right Deadzone + Права мертва зона Right Stick - Right Stick + Правий стик Color Adjustment - Color Adjustment + Налаштування Кольору R: - R: + R: G: - G: + G: B: - B: + B: Override Lightbar Color - Override Lightbar Color + Змінити колір підсвітки Override Color - Override Color + Змінити колір + + + Unable to Save + Не вдалося зберегти + + + Cannot bind axis values more than once + Неможливо пере назначити кнопку більше одного разу + + + Save + Зберегти + + + Apply + Застосувати + + + Restore Defaults + За замовчуванням + + + Cancel + Відмінити + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + Налаштування клавіатури, миші та перевизначення кнопок контролеру + + + Use Per-Game configs + Використовувати ігрові конфігурації + + + Error + Помилка + + + Could not open the file for reading + Не вдалося відкрити файл для читання + + + Could not open the file for writing + Не вдалось відкрити файл для запису + + + Save Changes + Зберегти зміни + + + Do you want to save changes? + Бажаєте зберегти зміни? + + + Help + Допомога + + + Do you want to reset your custom default config to the original default config? + Ви бажаєте скинути ваші налаштування за замовчуванням до початкової конфігурації? + + + Do you want to reset this config to your custom default config? + Ви бажаєте скинути ці налаштування до вашої конфігурації за замовчуванням? + + + Reset to Default + Відновити налаштування за замовчанням @@ -584,7 +655,7 @@ Directory to install DLC - Directory to install DLC + Папка для встановлення DLC @@ -775,6 +846,10 @@ Delete DLC Видалити DLC + + Delete Trophy + Видалити трофей + Compatibility... Сумісність... @@ -807,10 +882,6 @@ Error creating shortcut! Помилка при створенні ярлика! - - Install PKG - Встановити PKG - Game гри @@ -829,7 +900,7 @@ DLC - DLC + DLC Delete %1 @@ -851,40 +922,267 @@ This game has no update folder to open! Ця гра не має папки оновленнь, щоб відкрити її! + + No log file found for this game! + Файл звіту для цієї гри не знайдено! + Failed to convert icon. - Failed to convert icon. + Не вдалося конвертувати значок. This game has no save data to delete! Ця гра не містить збережень, які можна видалити! + + This game has no saved trophies to delete! + Ця гра немає збережених трофеїв для видалення! + Save Data Збереження + + Trophy + Трофеї + SFO Viewer for - SFO Viewer for + Перегляд SFO - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - shadPS4 - Виберіть папку + Quickstart + Швидкий старт - Select which directory you want to install to. - Виберіть папку, до якої ви хочете встановити. + FAQ + ЧаПи - Install All Queued to Selected Folder - Встановити все з черги до вибраної папки + Syntax + Синтаксис - Delete PKG File on Install - Видалити файл PKG під час встановлення + Special Bindings + Спеціальні прив'язки + + + Keybindings + Призначення клавіш + + + + KBMSettings + + Configure Controls + Налаштування елементів керування + + + D-Pad + Хрестовина + + + Up + Вгору + + + unmapped + не назначено + + + Left + Ліворуч + + + Right + Праворуч + + + Down + Вниз + + + Left Analog Halfmode + Напіврежим лівого аналогового стику + + + hold to move left stick at half-speed + утримуйте щоб рухати лівий стик в половину швидкості + + + Left Stick + Лівий стик + + + Config Selection + Вибір конфігурації + + + Common Config + Загальна конфігурація + + + Use per-game configs + Використовувати ігрові конфігурації + + + L1 + L1 / Лівий Бампер + + + L2 + L2 / Лівий Тригер + + + Text Editor + Текстовий редактор + + + Help + Довідка + + + R1 + R1 / Правий Бампер + + + R2 + R2 / Правий Тригер + + + L3 + Кнопка лівого стику + + + Touchpad Click + Натискання на сенсорну панель + + + Mouse to Joystick + Миша в джойстик + + + *press F7 ingame to activate + *натисніть F7 у грі для увімкнення + + + R3 + Кнопка правого стику + + + Options + Опції + + + Mouse Movement Parameters + Параметри руху миші + + + note: click Help Button/Special Keybindings for more information + замітка: натисніть кнопку Довідки/Спеціального Призначення клавіш для отримання додаткової інформації + + + Face Buttons + Лицьові кнопки + + + Triangle + Трикутник + + + Square + Квадрат + + + Circle + Коло + + + Cross + Хрест + + + Right Analog Halfmode + Напіврежим правого аналогового стику + + + hold to move right stick at half-speed + утримуйте щоб рухати правий стик в половину швидкості + + + Right Stick + Правий стик + + + Speed Offset (def 0.125): + Зміщення швидкості (замовч 0,125): + + + Copy from Common Config + Копіювати з Загальної конфігурації + + + Deadzone Offset (def 0.50): + Зміщення мертвої зони (замовч 0,50): + + + Speed Multiplier (def 1.0): + Модифікатор швидкості (замовч 1,0): + + + Common Config Selected + Вибрані Загальні налаштування + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + Ця кнопка копіює перепризначення кнопок із Загальної конфігурації до поточного вибраного профілю, і не може бути використана, якщо поточний вибраний профіль є загальною конфігурацією. + + + Copy values from Common Config + Копіювати значення з Загальної конфігурації + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + Ви бажаєте перезаписати наявні перепризначення кнопок з загальної конфігурації? + + + Unable to Save + Не вдалося зберегти + + + Cannot bind any unique input more than once + Не можна прив'язати кнопку вводу більш ніж один раз + + + Press a key + Натисніть клавішу + + + Cannot set mapping + Не вдалося встановити прив'язку + + + Mousewheel cannot be mapped to stick outputs + Коліщатко миші не можна прив'язати зі значенням стиків + + + Save + Зберегти + + + Apply + Застосувати + + + Restore Defaults + За замовчуванням + + + Cancel + Відмінити @@ -893,10 +1191,6 @@ Open/Add Elf Folder Відкрити/Додати папку Elf - - Install Packages (PKG) - Встановити пакети (PKG) - Boot Game Запустити гру @@ -913,10 +1207,6 @@ Configure... Налаштувати... - - Install application from a .pkg file - Встановити додаток з файлу .pkg - Recent Games Нещодавні ігри @@ -986,8 +1276,12 @@ Дамп списку ігор - PKG Viewer - Перегляд PKG + Trophy Viewer + Переглядач трофеїв + + + No games found. Please add your games to your library first. + Не знайдено жодної гри. Будь ласка, спочатку додайте свої ігри до бібліотеки. Search... @@ -1097,160 +1391,61 @@ Only one file can be selected! Можна вибрати лише один файл! - - PKG Extraction - Розпакування PKG - - - Patch detected! - Виявлено патч! - - - PKG and Game versions match: - Версії PKG та гри збігаються: - - - Would you like to overwrite? - Бажаєте перезаписати? - - - PKG Version %1 is older than installed version: - Версія PKG %1 старіша за встановлену версію: - - - Game is installed: - Встановлена гра: - - - Would you like to install Patch: - Бажаєте встановити патч: - - - DLC Installation - Встановлення DLC - - - Would you like to install DLC: %1? - Ви бажаєте встановити DLC: %1? - - - DLC already installed: - DLC вже встановлено: - - - Game already installed - Гра вже встановлена - - - PKG ERROR - ПОМИЛКА PKG - - - Extracting PKG %1/%2 - Витягування PKG %1/%2 - - - Extraction Finished - Розпакування завершено - - - Game successfully installed at %1 - Гру успішно встановлено у %1 - - - File doesn't appear to be a valid PKG file - Файл не є дійсним PKG-файлом - Run Game - Run Game + Запустити гру Eboot.bin file not found - Eboot.bin file not found - - - PKG File (*.PKG *.pkg) - PKG File (*.PKG *.pkg) - - - PKG is a patch or DLC, please install the game first! - PKG is a patch or DLC, please install the game first! + Файл Boot.bin не знайдено Game is already running! - Game is already running! + Гра вже запущена! shadPS4 - shadPS4 - - - - PKGViewer - - Open Folder - Відкрити папку + shadPS4 - PKG ERROR - ПОМИЛКА PKG + Play + Грати - Name - Назва + Pause + Пауза - Serial - Серійний номер + Stop + Стоп - Installed - Installed + Restart + Перезапуск - Size - Розмір + Full Screen + На повний екран - Category - Category + Controllers + Контролери - Type - Type + Keyboard + Клавіатура - App Ver - App Ver + Refresh List + Оновити список - FW - FW + Resume + Продовжити - Region - Регіон - - - Flags - Flags - - - Path - Шлях - - - File - Файл - - - Unknown - Невідомо - - - Package - Package + Show Labels Under Icons + Показати найменування під іконками @@ -1279,10 +1474,6 @@ Emulator Емулятор - - Enable Separate Update Folder - Увімкнути окрему папку оновлень - Default tab when opening settings Вкладка за замовчуванням при відкритті налаштувань @@ -1311,6 +1502,10 @@ Trophy Трофеї + + Open the custom trophy images/sounds folder + Відкрити папку користувацьких зображень трофеїв/звуків + Logger Логування @@ -1389,7 +1584,7 @@ Enable HDR - Enable HDR + Увімкнути HDR Paths @@ -1476,8 +1671,8 @@ Титульна музика - Disable Trophy Pop-ups - Вимкнути спливаючі вікна трофеїв + Disable Trophy Notification + Вимкнути сповіщення про отримання трофею Background Image @@ -1543,10 +1738,6 @@ Emulator Language:\nSets the language of the emulator's user interface. Мова емулятора:\nВстановіть мову користувацького інтерфейсу емулятора. - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Окрема папка для оновлень:\nДає змогу встановлювати оновлення гри в окрему папку для зручності. - Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. Показувати заставку:\nВідображає заставку гри (спеціальне зображення) під час запуску гри. @@ -1661,7 +1852,7 @@ Enable HDR:\nEnables HDR in games that support it.\nYour monitor must have support for the BT2020 PQ color space and the RGB10A2 swapchain format. - Enable HDR:\nEnables HDR in games that support it.\nYour monitor must have support for the BT2020 PQ color space and the RGB10A2 swapchain format. + Увімкнути HDR:\nУвімкнути HDR в іграх, які його підтримують.\nВаш монітор повинен мати колірний простір BT2020 PQ та формат swapchain RGB10A2. Game Folders:\nThe list of folders to check for installed games. @@ -1729,7 +1920,7 @@ Set the volume of the background music. - Set the volume of the background music. + Налаштування гучності фонової музики. Enable Motion Controls @@ -1761,47 +1952,103 @@ Directory to save data - Directory to save data + Папка для збереження даних Video - Video + Відео Display Mode - Display Mode + Режим відображення Windowed - Windowed + У вікні Fullscreen - Fullscreen + Повноекранний Fullscreen (Borderless) - Fullscreen (Borderless) + Повний екран (без рамок) Window Size - Window Size + Розмір вікна W: - W: + Висота: H: - H: + Ширина: Separate Log Files - Separate Log Files + Окремі файли журналу Separate Log Files:\nWrites a separate logfile for each game. - Separate Log Files:\nWrites a separate logfile for each game. + Окремі файли журналу:\nЗаписує окремий файл журналу для кожної гри. + + + Trophy Notification Position + Розміщення сповіщень про трофеї + + + Left + Ліворуч + + + Right + Праворуч + + + Top + Вгорі + + + Bottom + Внизу + + + Notification Duration + Тривалість сповіщення + + + Portable User Folder + Портативна папка користувача + + + Create Portable User Folder from Common User Folder + Створити портативну папку користувача з загальної папки + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + Портативна папка користувача:\nЗберігає налаштування та дані shadPS4, які будуть застосовані лише до збірки shadPS4, розташованої у поточній теці. Перезапустіть програму після створення портативної теки користувача, щоб почати користуватися нею. + + + Cannot create portable user folder + Не вдалося створити портативну папку користувача + + + %1 already exists + %1 вже існує + + + Portable user folder created + Портативна папка користувача створена + + + %1 successfully created. + %1 успішно створено. + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + Відкрити папку користувацьких зображень трофеїв/звуків:\nВи можете додати користувацькі зображення до трофеїв та звук.\nДодайте файли до теки custom_trophy з такими назвами:\ntrophy.wav АБО trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nПримітка: Звук буде працювати лише у версіях ShadPS4 з графічним інтерфейсом. @@ -1810,5 +2057,25 @@ Trophy Viewer Трофеї + + Select Game: + Виберіть гру: + + + Progress + Прогрес + + + Show Earned Trophies + Показати отримані трофеї + + + Show Not Earned Trophies + Показати не отримані трофеї + + + Show Hidden Trophies + Показати приховані трофеї + diff --git a/src/qt_gui/translations/vi_VN.ts b/src/qt_gui/translations/vi_VN.ts index 50a34ad7a..e0bc7e4fe 100644 --- a/src/qt_gui/translations/vi_VN.ts +++ b/src/qt_gui/translations/vi_VN.ts @@ -541,6 +541,77 @@ Override Color Override Color + + Unable to Save + Unable to Save + + + Cannot bind axis values more than once + Cannot bind axis values more than once + + + Save + Save + + + Apply + Apply + + + Restore Defaults + Restore Defaults + + + Cancel + Cancel + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + Edit Keyboard + Mouse and Controller input bindings + + + Use Per-Game configs + Use Per-Game configs + + + Error + Error + + + Could not open the file for reading + Could not open the file for reading + + + Could not open the file for writing + Could not open the file for writing + + + Save Changes + Save Changes + + + Do you want to save changes? + Do you want to save changes? + + + Help + Help + + + Do you want to reset your custom default config to the original default config? + Do you want to reset your custom default config to the original default config? + + + Do you want to reset this config to your custom default config? + Do you want to reset this config to your custom default config? + + + Reset to Default + Reset to Default + ElfViewer @@ -775,6 +846,10 @@ Delete DLC Delete DLC + + Delete Trophy + Delete Trophy + Compatibility... Compatibility... @@ -807,10 +882,6 @@ Error creating shortcut! Error creating shortcut! - - Install PKG - Install PKG - Game Game @@ -851,6 +922,10 @@ This game has no update folder to open! This game has no update folder to open! + + No log file found for this game! + No log file found for this game! + Failed to convert icon. Failed to convert icon. @@ -859,32 +934,255 @@ This game has no save data to delete! This game has no save data to delete! + + This game has no saved trophies to delete! + This game has no saved trophies to delete! + Save Data Save Data + + Trophy + Trophy + SFO Viewer for SFO Viewer for - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - shadPS4 - Choose directory + Quickstart + Quickstart - Select which directory you want to install to. - Select which directory you want to install to. + FAQ + FAQ - Install All Queued to Selected Folder - Install All Queued to Selected Folder + Syntax + Syntax - Delete PKG File on Install - Delete PKG File on Install + Special Bindings + Special Bindings + + + Keybindings + Keybindings + + + + KBMSettings + + Configure Controls + Configure Controls + + + D-Pad + D-Pad + + + Up + Up + + + unmapped + unmapped + + + Left + Left + + + Right + Right + + + Down + Down + + + Left Analog Halfmode + Left Analog Halfmode + + + hold to move left stick at half-speed + hold to move left stick at half-speed + + + Left Stick + Left Stick + + + Config Selection + Config Selection + + + Common Config + Common Config + + + Use per-game configs + Use per-game configs + + + L1 + L1 + + + L2 + L2 + + + Text Editor + Text Editor + + + Help + Help + + + R1 + R1 + + + R2 + R2 + + + L3 + L3 + + + Touchpad Click + Touchpad Click + + + Mouse to Joystick + Mouse to Joystick + + + *press F7 ingame to activate + *press F7 ingame to activate + + + R3 + R3 + + + Options + Options + + + Mouse Movement Parameters + Mouse Movement Parameters + + + note: click Help Button/Special Keybindings for more information + note: click Help Button/Special Keybindings for more information + + + Face Buttons + Face Buttons + + + Triangle + Triangle + + + Square + Square + + + Circle + Circle + + + Cross + Cross + + + Right Analog Halfmode + Right Analog Halfmode + + + hold to move right stick at half-speed + hold to move right stick at half-speed + + + Right Stick + Right Stick + + + Speed Offset (def 0.125): + Speed Offset (def 0.125): + + + Copy from Common Config + Copy from Common Config + + + Deadzone Offset (def 0.50): + Deadzone Offset (def 0.50): + + + Speed Multiplier (def 1.0): + Speed Multiplier (def 1.0): + + + Common Config Selected + Common Config Selected + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + + + Copy values from Common Config + Copy values from Common Config + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + Do you want to overwrite existing mappings with the mappings from the Common Config? + + + Unable to Save + Unable to Save + + + Cannot bind any unique input more than once + Cannot bind any unique input more than once + + + Press a key + Press a key + + + Cannot set mapping + Cannot set mapping + + + Mousewheel cannot be mapped to stick outputs + Mousewheel cannot be mapped to stick outputs + + + Save + Save + + + Apply + Apply + + + Restore Defaults + Restore Defaults + + + Cancel + Cancel @@ -893,10 +1191,6 @@ Open/Add Elf Folder Open/Add Elf Folder - - Install Packages (PKG) - Install Packages (PKG) - Boot Game Boot Game @@ -913,10 +1207,6 @@ Configure... Configure... - - Install application from a .pkg file - Install application from a .pkg file - Recent Games Recent Games @@ -986,8 +1276,12 @@ Dump Game List - PKG Viewer - PKG Viewer + Trophy Viewer + Trophy Viewer + + + No games found. Please add your games to your library first. + No games found. Please add your games to your library first. Search... @@ -1097,70 +1391,6 @@ Only one file can be selected! Chỉ có thể chọn một tệp duy nhất! - - PKG Extraction - Giải nén PKG - - - Patch detected! - Đã phát hiện bản vá! - - - PKG and Game versions match: - Các phiên bản PKG và trò chơi khớp nhau: - - - Would you like to overwrite? - Bạn có muốn ghi đè không? - - - PKG Version %1 is older than installed version: - Phiên bản PKG %1 cũ hơn phiên bản đã cài đặt: - - - Game is installed: - Trò chơi đã được cài đặt: - - - Would you like to install Patch: - Bạn có muốn cài đặt bản vá: - - - DLC Installation - Cài đặt DLC - - - Would you like to install DLC: %1? - Bạn có muốn cài đặt DLC: %1? - - - DLC already installed: - DLC đã được cài đặt: - - - Game already installed - Trò chơi đã được cài đặt - - - PKG ERROR - LOI PKG - - - Extracting PKG %1/%2 - Đang giải nén PKG %1/%2 - - - Extraction Finished - Giải nén hoàn tất - - - Game successfully installed at %1 - Trò chơi đã được cài đặt thành công tại %1 - - - File doesn't appear to be a valid PKG file - Tệp không có vẻ là tệp PKG hợp lệ - Run Game Run Game @@ -1169,14 +1399,6 @@ Eboot.bin file not found Eboot.bin file not found - - PKG File (*.PKG *.pkg) - PKG File (*.PKG *.pkg) - - - PKG is a patch or DLC, please install the game first! - PKG is a patch or DLC, please install the game first! - Game is already running! Game is already running! @@ -1185,72 +1407,45 @@ shadPS4 shadPS4 - - - PKGViewer - Open Folder - Open Folder + Play + Play - PKG ERROR - LOI PKG + Pause + Pause - Name - Tên + Stop + Stop - Serial - Số seri + Restart + Restart - Installed - Installed + Full Screen + Full Screen - Size - Kích thước + Controllers + Controllers - Category - Category + Keyboard + Keyboard - Type - Type + Refresh List + Refresh List - App Ver - App Ver + Resume + Resume - FW - FW - - - Region - Khu vực - - - Flags - Flags - - - Path - Đường dẫn - - - File - File - - - Unknown - Không xác định - - - Package - Package + Show Labels Under Icons + Show Labels Under Icons @@ -1279,10 +1474,6 @@ Emulator Trình giả lập - - Enable Separate Update Folder - Bật thư mục cập nhật riêng - Default tab when opening settings Tab mặc định khi mở cài đặt @@ -1311,6 +1502,10 @@ Trophy Trophy + + Open the custom trophy images/sounds folder + Open the custom trophy images/sounds folder + Logger Logger @@ -1476,8 +1671,8 @@ Title Music - Disable Trophy Pop-ups - Disable Trophy Pop-ups + Disable Trophy Notification + Disable Trophy Notification Background Image @@ -1543,10 +1738,6 @@ Emulator Language:\nSets the language of the emulator's user interface. Ngôn ngữ của trình giả lập:\nChọn ngôn ngữ của giao diện người dùng của trình giả lập. - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management. - Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. Hiển thị màn hình khởi động:\nHiển thị màn hình khởi động của trò chơi (một hình ảnh đặc biệt) trong khi trò chơi khởi động. @@ -1803,6 +1994,62 @@ Separate Log Files:\nWrites a separate logfile for each game. Separate Log Files:\nWrites a separate logfile for each game. + + Trophy Notification Position + Trophy Notification Position + + + Left + Left + + + Right + Right + + + Top + Top + + + Bottom + Bottom + + + Notification Duration + Notification Duration + + + Portable User Folder + Portable User Folder + + + Create Portable User Folder from Common User Folder + Create Portable User Folder from Common User Folder + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + + + Cannot create portable user folder + Cannot create portable user folder + + + %1 already exists + %1 already exists + + + Portable user folder created + Portable user folder created + + + %1 successfully created. + %1 successfully created. + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + TrophyViewer @@ -1810,5 +2057,25 @@ Trophy Viewer Trình xem chiến tích + + Select Game: + Select Game: + + + Progress + Progress + + + Show Earned Trophies + Show Earned Trophies + + + Show Not Earned Trophies + Show Not Earned Trophies + + + Show Hidden Trophies + Show Hidden Trophies + diff --git a/src/qt_gui/translations/zh_CN.ts b/src/qt_gui/translations/zh_CN.ts index b855f2dcd..120310810 100644 --- a/src/qt_gui/translations/zh_CN.ts +++ b/src/qt_gui/translations/zh_CN.ts @@ -411,7 +411,7 @@ D-Pad - D-Pad + 十字键 Up @@ -487,23 +487,23 @@ Face Buttons - 正面按钮 + 功能键(动作键) Triangle / Y - Triangle / Y + 三角 / Y Square / X - Square / X + 方框 / X Circle / B - Circle / B + 圈 / B Cross / A - Cross / A + 叉 / A Right Stick Deadzone (def:2, max:127) @@ -541,6 +541,77 @@ Override Color 覆盖颜色 + + Unable to Save + 无法保存 + + + Cannot bind axis values more than once + 摇杆 X/Y 轴的操作绑定不在同一直线 + + + Save + 保存 + + + Apply + 应用 + + + Restore Defaults + 恢复默认设置 + + + Cancel + 取消 + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + 编辑键盘鼠标和手柄按键绑定 + + + Use Per-Game configs + 每个游戏使用单独的配置 + + + Error + 错误 + + + Could not open the file for reading + 无法打开文件进行读取 + + + Could not open the file for writing + 无法打开文件进行读取 + + + Save Changes + 保存更改 + + + Do you want to save changes? + 您要保存更改吗? + + + Help + 帮助 + + + Do you want to reset your custom default config to the original default config? + 您要将自定义默认配置重置为默认配置吗? + + + Do you want to reset this config to your custom default config? + 您想要将此配置重置为自定义默认配置吗? + + + Reset to Default + 重置为默认 + ElfViewer @@ -775,6 +846,10 @@ Delete DLC 删除 DLC + + Delete Trophy + 删除奖杯 + Compatibility... 兼容性... @@ -807,10 +882,6 @@ Error creating shortcut! 创建快捷方式出错! - - Install PKG - 安装 PKG - Game 游戏 @@ -851,6 +922,10 @@ This game has no update folder to open! 这个游戏没有可打开的更新文件夹! + + No log file found for this game! + 没有找到这个游戏的日志文件! + Failed to convert icon. 转换图标失败。 @@ -859,32 +934,255 @@ This game has no save data to delete! 这个游戏没有更新可以删除! + + This game has no saved trophies to delete! + 这个游戏没有保存的奖杯可删除! + Save Data 存档数据 + + Trophy + 奖杯 + SFO Viewer for SFO 查看器 - - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - shadPS4 - 选择文件目录 + Quickstart + 快速入门 - Select which directory you want to install to. - 选择您想要安装到的目录。 + FAQ + 常见问题 - Install All Queued to Selected Folder - 安装所有 PKG 到选定的文件夹 + Syntax + 语法 - Delete PKG File on Install - 安装后删除 PKG 文件 + Special Bindings + 特殊绑定 + + + Keybindings + 按键绑定 + + + + KBMSettings + + Configure Controls + 配置键鼠 + + + D-Pad + 十字键 + + + Up + + + + unmapped + 未映射 + + + Left + + + + Right + + + + Down + + + + Left Analog Halfmode + 左摇杆半速模式 + + + hold to move left stick at half-speed + 按住以半速移动左摇杆 + + + Left Stick + 左摇杆 + + + Config Selection + 配置选择 + + + Common Config + 通用配置 + + + Use per-game configs + 每个游戏使用单独的配置 + + + L1 + L1 + + + L2 + L2 + + + Text Editor + 文本编辑器 + + + Help + 帮助 + + + R1 + R1 + + + R2 + R2 + + + L3 + L3 + + + Touchpad Click + 触摸板点击 + + + Mouse to Joystick + 鼠标控制摇杆 + + + *press F7 ingame to activate + * 按 F7 键激活 + + + R3 + R3 + + + Options + 选项设置 + + + Mouse Movement Parameters + 鼠标移动参数 + + + note: click Help Button/Special Keybindings for more information + 注意:点击帮助按钮 -> 获取更多关于映射特殊键位的信息 + + + Face Buttons + 功能键(动作键) + + + Triangle + 三角 + + + Square + 方框 + + + Circle + + + + Cross + + + + Right Analog Halfmode + 右摇杆半速模式 + + + hold to move right stick at half-speed + 按住以半速移动右摇杆 + + + Right Stick + 右摇杆 + + + Speed Offset (def 0.125): + 速度偏移量(默认 0.125): + + + Copy from Common Config + 从通用配置中复制 + + + Deadzone Offset (def 0.50): + 死区偏移量(默认 0.50): + + + Speed Multiplier (def 1.0): + 速度系数(默认 1.0): + + + Common Config Selected + 已选中通用配置 + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + 此按钮用于将通用配置中的映射复制到当前选定的配置文件,当前选定的配置文件为通用配置时无法使用。 + + + Copy values from Common Config + 从通用配置中复制配置 + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + 您想要用通用配置的映射覆盖现有映射吗? + + + Unable to Save + 无法保存 + + + Cannot bind any unique input more than once + 不能绑定重复的按键 + + + Press a key + 按下按键 + + + Cannot set mapping + 无法设置映射 + + + Mousewheel cannot be mapped to stick outputs + 鼠标滚轮无法映射到摇杆 + + + Save + 保存 + + + Apply + 应用 + + + Restore Defaults + 恢复默认设置 + + + Cancel + 取消 @@ -893,10 +1191,6 @@ Open/Add Elf Folder 打开/添加 Elf 文件夹 - - Install Packages (PKG) - 安装 Packages (PKG) - Boot Game 启动游戏 @@ -913,10 +1207,6 @@ Configure... 设置... - - Install application from a .pkg file - 从 .pkg 文件安装应用程序 - Recent Games 最近启动的游戏 @@ -986,8 +1276,12 @@ 导出游戏列表 - PKG Viewer - PKG 查看器 + Trophy Viewer + 奖杯查看器 + + + No games found. Please add your games to your library first. + 未找到游戏。请先将您的游戏添加到您的资料库。 Search... @@ -1097,70 +1391,6 @@ Only one file can be selected! 只能选择一个文件! - - PKG Extraction - PKG 解压 - - - Patch detected! - 检测到补丁! - - - PKG and Game versions match: - PKG 和游戏版本匹配: - - - Would you like to overwrite? - 您想要覆盖吗? - - - PKG Version %1 is older than installed version: - PKG 版本 %1 比已安装版本更旧: - - - Game is installed: - 游戏已安装: - - - Would you like to install Patch: - 您想安装补丁吗: - - - DLC Installation - DLC 安装 - - - Would you like to install DLC: %1? - 您想安装 DLC:%1 吗? - - - DLC already installed: - DLC 已经安装: - - - Game already installed - 游戏已经安装 - - - PKG ERROR - PKG 错误 - - - Extracting PKG %1/%2 - 正在解压 PKG %1/%2 - - - Extraction Finished - 解压完成 - - - Game successfully installed at %1 - 游戏成功安装在 %1 - - - File doesn't appear to be a valid PKG file - 文件似乎不是有效的 PKG 文件 - Run Game 运行游戏 @@ -1169,14 +1399,6 @@ Eboot.bin file not found 找不到 Eboot.bin 文件 - - PKG File (*.PKG *.pkg) - PKG 文件(*.PKG *.pkg) - - - PKG is a patch or DLC, please install the game first! - PKG是一个补丁或 DLC,请先安装游戏! - Game is already running! 游戏已经在运行中! @@ -1185,72 +1407,45 @@ shadPS4 shadPS4 - - - PKGViewer - Open Folder - 打开文件夹 + Play + 开始游戏 - PKG ERROR - PKG 错误 + Pause + 暂停 - Name - 名称 + Stop + 关闭 - Serial - 序列号 + Restart + 重新启动 - Installed - 已安装 + Full Screen + 全屏 - Size - 大小 + Controllers + 控制器 - Category - 分类 + Keyboard + 键盘 - Type - 类型 + Refresh List + 刷新列表 - App Ver - 版本 + Resume + 继续游戏 - FW - 固件 - - - Region - 区域 - - - Flags - 标志 - - - Path - 路径 - - - File - 文件 - - - Unknown - 未知 - - - Package - Package + Show Labels Under Icons + 显示图标下的标签 @@ -1279,10 +1474,6 @@ Emulator 模拟器 - - Enable Separate Update Folder - 启用单独的更新目录 - Default tab when opening settings 打开设置时的默认选项卡 @@ -1311,6 +1502,10 @@ Trophy 奖杯 + + Open the custom trophy images/sounds folder + 打开自定义奖杯图像/声音文件夹 + Logger 日志 @@ -1476,8 +1671,8 @@ 标题音乐 - Disable Trophy Pop-ups - 禁止弹出奖杯 + Disable Trophy Notification + 禁用奖杯通知 Background Image @@ -1543,10 +1738,6 @@ Emulator Language:\nSets the language of the emulator's user interface. 模拟器语言:\n设置模拟器用户界面的语言。 - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - 启用单独的更新目录:\n启用安装游戏更新到一个单独的目录中以更便于管理。 - Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. 显示启动画面:\n在游戏启动时显示游戏的启动画面(特殊图像)。 @@ -1803,6 +1994,62 @@ Separate Log Files:\nWrites a separate logfile for each game. 独立日志文件:\n每个游戏使用单独的日志文件。 + + Trophy Notification Position + 奖杯通知位置 + + + Left + 左边 + + + Right + 右边 + + + Top + 顶部 + + + Bottom + 底部 + + + Notification Duration + 通知显示持续时间 + + + Portable User Folder + 本地用户文件夹 + + + Create Portable User Folder from Common User Folder + 从公共用户文件夹创建本地用户文件夹 + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + 本地用户文件夹:\n存储 shadPS4 设置和数据,这些设置和数据仅应用于当前运行的 shadPS4。创建本地用户文件夹后,重启应用即可开始使用。 + + + Cannot create portable user folder + 无法创建本地用户文件夹 + + + %1 already exists + %1 已存在 + + + Portable user folder created + 本地用户文件夹已创建 + + + %1 successfully created. + %1 创建成功。 + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + 打开自定义奖杯图像/声音文件夹:\n您可以自定义奖杯图像和声音。\n将文件添加到 custom_trophy 文件夹中,文件名如下:\ntrophy.wav 或 trophy.mp3、bronze.png、gold.png、platinum.png、silver.png。\n注意:自定义声音只能在 QT 版本中生效。 + TrophyViewer @@ -1810,5 +2057,25 @@ Trophy Viewer 奖杯查看器 + + Select Game: + 选择游戏: + + + Progress + 进度 + + + Show Earned Trophies + 显示获得的奖杯 + + + Show Not Earned Trophies + 显示未获得的奖杯 + + + Show Hidden Trophies + 显示隐藏奖杯 + diff --git a/src/qt_gui/translations/zh_TW.ts b/src/qt_gui/translations/zh_TW.ts index 15c921d15..bd051651d 100644 --- a/src/qt_gui/translations/zh_TW.ts +++ b/src/qt_gui/translations/zh_TW.ts @@ -7,26 +7,26 @@ AboutDialog About shadPS4 - About shadPS4 + 關於 shadPS4 shadPS4 is an experimental open-source emulator for the PlayStation 4. - shadPS4 is an experimental open-source emulator for the PlayStation 4. + shadPS4 是一款試驗性質的 PlayStation 4 開源模擬器軟體。 This software should not be used to play games you have not legally obtained. - This software should not be used to play games you have not legally obtained. + 不得用此軟體來遊玩你未曾合法獲取的遊戲。 CheatsPatches Cheats / Patches for - Cheats / Patches for + 金手指/修補程式: Cheats/Patches are experimental.\nUse with caution.\n\nDownload cheats individually by selecting the repository and clicking the download button.\nIn the Patches tab, you can download all patches at once, choose which ones you want to use, and save your selection.\n\nSince we do not develop the Cheats/Patches,\nplease report issues to the cheat author.\n\nCreated a new cheat? Visit:\n - 作弊/補丁為實驗性功能。\n請小心使用。\n\n透過選擇儲存庫並點擊下載按鈕來單獨下載作弊程式。\n在“補丁”標籤頁中,您可以一次下載所有補丁,選擇要使用的補丁並保存您的選擇。\n\n由於我們不開發作弊/補丁,\n請將問題報告給作弊程式的作者。\n\n創建了新的作弊程式?請訪問:\n + 金手指/修補檔屬於試驗性質功能。\n請小心使用。\n\n透過選取儲存庫並點擊下載按鈕來單獨下載作弊程式。\n在“修補檔”標籤頁中,你可以一次下載所有修補檔,選擇要使用的補丁並保存您的選擇。\n\n由於我們不負責開發金手指/修補檔,\n請將問題匯報給作弊程式的作者。\n\n建立了新的作弊程式?請瀏覽:\n No Image Available @@ -34,27 +34,27 @@ Serial: - 序號: + 序號: Version: - 版本: + 版本: Size: - 大小: + 大小: Select Cheat File: - 選擇作弊檔案: + 選取金手指檔案: Repository: - 儲存庫: + 儲存庫: Download Cheats - 下載作弊碼 + 下載金手指 Delete File @@ -62,19 +62,19 @@ No files selected. - 沒有選擇檔案。 + 未選取檔案。 You can delete the cheats you don't want after downloading them. - 您可以在下載後刪除不需要的作弊碼。 + 下載後可以刪除不需要的金手指。 Do you want to delete the selected file?\n%1 - 您是否要刪除選定的檔案?\n%1 + 確定要刪除選取的檔案?\n%1 Select Patch File: - 選擇修補檔案: + 選取修補檔案: Download Patches @@ -86,7 +86,7 @@ Cheats - 作弊碼 + 金手指 Patches @@ -98,27 +98,27 @@ No patch selected. - 未選擇修補檔。 + 未選取修補檔。 Unable to open files.json for reading. - 無法打開 files.json 進行讀取。 + 無法開啟 files.json 進行讀取。 No patch file found for the current serial. - 找不到當前序號的修補檔。 + 找不到目前序號的修補檔。 Unable to open the file for reading. - 無法打開檔案進行讀取。 + 無法開啟檔案進行讀取。 Unable to open the file for writing. - 無法打開檔案進行寫入。 + 無法開啟檔案進行寫入。 Failed to parse XML: - 解析 XML 失敗: + 解析 XML 失敗: Success @@ -126,7 +126,7 @@ Options saved successfully. - 選項已成功儲存。 + 已成功儲存選項。 Invalid Source @@ -134,7 +134,7 @@ The selected source is invalid. - 選擇的來源無效。 + 選取的來源無效。 File Exists @@ -142,39 +142,39 @@ File already exists. Do you want to replace it? - 檔案已存在。您是否希望替換它? + 檔案已存在,您要取代嗎? Failed to save file: - 無法儲存檔案: + 無法儲存檔案: Failed to download file: - 無法下載檔案: + 無法下載檔案: Cheats Not Found - 未找到作弊碼 + 找不到金手指 No Cheats found for this game in this version of the selected repository,try another repository or a different version of the game. - 在此版本的儲存庫中未找到該遊戲的作弊碼,請嘗試另一個儲存庫或不同版本的遊戲。 + 在此版本的儲存庫中未找到該遊戲的金手指,請嘗試另一個儲存庫或不同版本的遊戲。 Cheats Downloaded Successfully - 作弊碼下載成功 + 全手指下載成功 You have successfully downloaded the cheats for this version of the game from the selected repository. You can try downloading from another repository, if it is available it will also be possible to use it by selecting the file from the list. - 您已成功下載該遊戲版本的作弊碼 從選定的儲存庫中。 您可以嘗試從其他儲存庫下載,如果可用,您也可以選擇從列表中選擇檔案來使用它。 + 你已成功從選取的儲存庫中下載該遊戲版本的金手指。 可用的話,你可以嘗試從其他儲存庫下載,你也可以從列表中選取檔案來使用它。 Failed to save: - 儲存失敗: + 儲存失敗: Failed to download: - 下載失敗: + 下載失敗: Download Complete @@ -182,15 +182,15 @@ Patches Downloaded Successfully! All Patches available for all games have been downloaded, there is no need to download them individually for each game as happens in Cheats. If the patch does not appear, it may be that it does not exist for the specific serial and version of the game. - 修補檔下載成功!所有遊戲的修補檔已下載完成,無需像作弊碼那樣為每個遊戲單獨下載。如果補丁未顯示,可能是該補丁不適用於特定的序號和遊戲版本。 + 修補檔下載成功!所有遊戲的修補檔已下載完成,無需像金手指那樣為每個遊戲單獨下載。如果修補檔仍未顯示,可能該修補檔是不適用於特定的序號和遊戲版本。 Failed to parse JSON data from HTML. - 無法從 HTML 解析 JSON 數據。 + 無法從 HTML 分析 JSON 資料。 Failed to retrieve HTML page. - 無法檢索 HTML 頁面。 + 無法接收 HTML 頁面。 The game is in version: %1 @@ -198,11 +198,11 @@ The downloaded patch only works on version: %1 - 下載的補丁僅適用於版本: %1 + 下載的修補檔僅適用於版本: %1 You may need to update your game. - 您可能需要更新遊戲。 + 你可能需要更新你的遊戲。 Incompatibility Notice @@ -210,35 +210,35 @@ Failed to open file: - 無法打開檔案: + 無法開啟檔案: XML ERROR: - XML 錯誤: + XML 錯誤: Failed to open files.json for writing - 無法打開 files.json 進行寫入 + 無法開啟 files.json 進行寫入 Author: - 作者: + 作者: Directory does not exist: - 目錄不存在: + 目錄不存在: Failed to open files.json for reading. - 無法打開 files.json 進行讀取。 + 無法開啟 files.json 進行讀取。 Name: - 名稱: + 名稱: Can't apply cheats before the game is started - 在遊戲開始之前無法應用作弊。 + 在遊戲'開始之前無法套用金手指 Close @@ -265,19 +265,19 @@ Failed to parse update information. - 無法解析更新資訊。 + 無法分析更新資訊。 No pre-releases found. - 未找到預發布版本。 + 未找到預發佈版本。 Invalid release data. - 無效的發行數據。 + 無效的發佈資料。 No download URL found for the specified asset. - 未找到指定資產的下載 URL。 + 未找到指定資源的下載 URL。 Your version is already up to date! @@ -293,7 +293,7 @@ Current Version - 當前版本 + 目前版本 Latest Version @@ -301,7 +301,7 @@ Do you want to update? - 您想要更新嗎? + 你要更新嗎? Show Changelog @@ -321,7 +321,7 @@ Hide Changelog - 隱藏變更日誌 + 隱藏變更日誌紀錄 Changes @@ -329,7 +329,7 @@ Network error occurred while trying to access the URL - 嘗試訪問 URL 時發生網路錯誤 + 嘗試存取 URL 時發生了網路錯誤 Download Complete @@ -337,11 +337,11 @@ The update has been downloaded, press OK to install. - 更新已下載,按 OK 安裝。 + 已下載更新,按 OK 安裝。 Failed to save the update file at - 無法將更新文件保存到 + 無法將更新檔案儲存到 Starting Update... @@ -349,7 +349,7 @@ Failed to create the update script file - 無法創建更新腳本文件 + 無法建立更新程式碼檔案 @@ -364,7 +364,7 @@ Loading... - 載入中... + 正在載入… Error @@ -388,203 +388,274 @@ Boots - 靴子 + 可啟動 Menus - 選單 + 可顯示標題畫面 Ingame - 遊戲內 + 可進入遊戲 Playable - 可玩 + 可如常遊玩 ControlSettings Configure Controls - Configure Controls + 操控組態 D-Pad - D-Pad + 十字方向鍵 Up - Up + Left - Left + Right - Right + Down - Down + Left Stick Deadzone (def:2 max:127) - Left Stick Deadzone (def:2 max:127) + 左搖桿無效區域(預設:2 最大:127) Left Deadzone - Left Deadzone + 左無效區域 Left Stick - Left Stick + 左搖桿 Config Selection - Config Selection + 選取組態 Common Config - Common Config + 通用組態 Use per-game configs - Use per-game configs + 使用個別遊戲組態 L1 / LB - L1 / LB + L1 / LB L2 / LT - L2 / LT + L2 / LT Back - Back + Back R1 / RB - R1 / RB + R1 / RB R2 / RT - R2 / RT + R2 / RT L3 - L3 + L3 Options / Start - Options / Start + Options / Start R3 - R3 + R3 Face Buttons - Face Buttons + 功能鍵(動作按鈕) Triangle / Y - Triangle / Y + 三角 / Y Square / X - Square / X + 正方 / X Circle / B - Circle / B + 圖形 / B Cross / A - Cross / A + 交叉 / A Right Stick Deadzone (def:2, max:127) - Right Stick Deadzone (def:2, max:127) + 右搖桿無效區域(預設:2 最大:127) Right Deadzone - Right Deadzone + 右無效區域 Right Stick - Right Stick + 右搖桿 Color Adjustment - Color Adjustment + 色彩調整 R: - R: + 紅: G: - G: + 綠: B: - B: + 藍: Override Lightbar Color - Override Lightbar Color + 覆寫燈條顏色 Override Color - Override Color + 覆寫顏色 + + + Unable to Save + 無法儲存 + + + Cannot bind axis values more than once + 不能同時連結多個方向軸設定值 + + + Save + 儲存 + + + Apply + 套用 + + + Restore Defaults + 還原成預設值 + + + Cancel + 取消 + + + + EditorDialog + + Edit Keyboard + Mouse and Controller input bindings + 編輯鍵盤滑鼠和控制器按鈕連結 + + + Use Per-Game configs + 使用個別遊戲組態 + + + Error + 錯誤 + + + Could not open the file for reading + 無法開啟檔案進行讀取 + + + Could not open the file for writing + 無法開啟檔案進行寫入 + + + Save Changes + 儲存變更 + + + Do you want to save changes? + 你要儲存變更嗎? + + + Help + 幫助 + + + Do you want to reset your custom default config to the original default config? + 你要將自訂預設組態還原成原始預設組態嗎? + + + Do you want to reset this config to your custom default config? + 你要將此組態還原成自訂預設組態嗎? + + + Reset to Default + 還原成預設值 ElfViewer Open Folder - Open Folder + 開啟資料夾 GameInfoClass Loading game list, please wait :3 - Loading game list, please wait :3 + 正在載入遊戲列表,請稍候 :3 Cancel - Cancel + 取消 Loading... - Loading... + 正在載入… GameInstallDialog shadPS4 - Choose directory - shadPS4 - Choose directory + shadPS4 - 選取檔案目錄 Directory to install games - Directory to install games + 要安裝遊戲的目錄 Browse - Browse + 瀏覽 Error - Error + 錯誤 Directory to install DLC - Directory to install DLC + 要安裝DLC的目錄 @@ -603,7 +674,7 @@ Compatibility - Compatibility + 相容性 Region @@ -611,7 +682,7 @@ Firmware - 固件 + 韌體 Size @@ -631,43 +702,43 @@ Never Played - Never Played + 從未玩過 h - h + 小時 m - m + 分鐘 s - s + Compatibility is untested - Compatibility is untested + 未曾測試相容性 Game does not initialize properly / crashes the emulator - Game does not initialize properly / crashes the emulator + 無法正確初始化遊戲/模擬器當機 Game boots, but only displays a blank screen - Game boots, but only displays a blank screen + 遊戲可啟動,但只會顯示空白畫面 Game displays an image but does not go past the menu - Game displays an image but does not go past the menu + 可以顯示遊戲畫面,但是在標題畫面無法繼續 Game has game-breaking glitches or unplayable performance - Game has game-breaking glitches or unplayable performance + 遊戲有嚴重的BUG或者效能過低而無法遊玩 Game can be completed with playable performance and no major glitches - Game can be completed with playable performance and no major glitches + 遊戲能在可以合理遊玩的效能下破關也沒有重大BUG Click to see details on github @@ -682,224 +753,447 @@ GameListUtils B - B + B KB - KB + KB MB - MB + MB GB - GB + GB TB - TB + TB GuiContextMenus Create Shortcut - Create Shortcut + 建立捷徑 Cheats / Patches - Zuòbì / Xiūbǔ chéngshì + 金手指/修補程式 SFO Viewer - SFO Viewer + SFO 檢視器 Trophy Viewer - Trophy Viewer + 獎盃檢視器 Open Folder... - 打開資料夾... + 開啟資料夾… Open Game Folder - 打開遊戲資料夾 + 開啟遊戲資料夾 Open Save Data Folder - 打開存檔資料夾 + 開啟遊戲存檔資料夾 Open Log Folder - 打開日誌資料夾 + 開啟日誌紀錄資料夾 Copy info... - Copy info... + 複製資訊... Copy Name - Copy Name + 複製名稱 Copy Serial - Copy Serial + 複製序號 Copy Version - Copy Version + 複製版本資訊 Copy Size - Copy Size + 複製大小 Copy All - Copy All + 全部複製 Delete... - Delete... + 刪除… Delete Game - Delete Game + 刪除遊戲 Delete Update - Delete Update + 刪除更新 Delete DLC - Delete DLC + 刪除DLC + + + Delete Trophy + 刪除獎盃 Compatibility... - Compatibility... + 相容性… Update database - Update database + 更新資料庫 View report - View report + 檢視報告 Submit a report - Submit a report + 提交報告 Shortcut creation - Shortcut creation + 建立捷徑 Shortcut created successfully! - Shortcut created successfully! + 成功建立捷徑! Error - Error + 錯誤 Error creating shortcut! - Error creating shortcut! - - - Install PKG - Install PKG + 建立捷徑出錯! Game - Game + 遊戲 This game has no update to delete! - This game has no update to delete! + 此遊戲沒有可刪除的更新! Update - Update + 更新 This game has no DLC to delete! - This game has no DLC to delete! + 此遊戲沒有可刪除的DLC! DLC - DLC + DLC Delete %1 - Delete %1 + 刪除 %1 Are you sure you want to delete %1's %2 directory? - Are you sure you want to delete %1's %2 directory? + 確定要刪除 %1' 的%2目錄? Open Update Folder - Open Update Folder + 開啟更新資料夾 Delete Save Data - Delete Save Data + 刪除遊戲存檔 This game has no update folder to open! - This game has no update folder to open! + 此遊戲沒有可開啟的更新資料夾! + + + No log file found for this game! + 找不到此遊戲的日誌紀錄檔! Failed to convert icon. - Failed to convert icon. + 轉換圖示失敗。 This game has no save data to delete! - This game has no save data to delete! + 此遊戲沒有可刪除的遊戲存檔! + + + This game has no saved trophies to delete! + 此遊戲沒有可刪除的已儲存獎盃! Save Data - Save Data + 遊戲存檔 + + + Trophy + 獎盃 SFO Viewer for - SFO Viewer for + SFO 檢視器: - InstallDirSelect + HelpDialog - shadPS4 - Choose directory - shadPS4 - Choose directory + Quickstart + 快速入門 - Select which directory you want to install to. - Select which directory you want to install to. + FAQ + 常見問答 - Install All Queued to Selected Folder - Install All Queued to Selected Folder + Syntax + 語法 - Delete PKG File on Install - Delete PKG File on Install + Special Bindings + 特殊連結 + + + Keybindings + 按鍵連結 + + + + KBMSettings + + Configure Controls + 操控組態 + + + D-Pad + 十字方向鍵 + + + Up + + + + unmapped + 鍵位未有對應 + + + Left + + + + Right + + + + Down + + + + Left Analog Halfmode + 左類比搖桿半速模式 + + + hold to move left stick at half-speed + 按住可半速移動左搖桿 + + + Left Stick + 左搖桿 + + + Config Selection + 選取組態 + + + Common Config + 通用組態 + + + Use per-game configs + 使用個別遊戲組態 + + + L1 + L1 + + + L2 + L2 + + + Text Editor + 文字編輯器 + + + Help + 幫助 + + + R1 + R1 + + + R2 + R2 + + + L3 + L3 + + + Touchpad Click + 觸控板點擊 + + + Mouse to Joystick + 滑鼠操控操縱桿 + + + *press F7 ingame to activate + *在遊戲中按F7啟動 + + + R3 + R3 + + + Options + Options + + + Mouse Movement Parameters + 滑鼠指標移動參數 + + + note: click Help Button/Special Keybindings for more information + 注意:點擊 幫助 按鈕/特殊按鍵連結以取得更多資訊 + + + Face Buttons + 功能鍵(動作按鈕) + + + Triangle + 三角 + + + Square + 正方 + + + Circle + 圓形 + + + Cross + 交叉 + + + Right Analog Halfmode + 右類比搖桿半速模式 + + + hold to move right stick at half-speed + 按住可半速移動右搖桿 + + + Right Stick + 右搖桿 + + + Speed Offset (def 0.125): + 速度偏移量(預設為 0.125): + + + Copy from Common Config + 從通用組態中複製設定值 + + + Deadzone Offset (def 0.50): + 無效區偏移量(預設為 0.50): + + + Speed Multiplier (def 1.0): + 速度倍數(預設為 1.0): + + + Common Config Selected + 已選取通用組態 + + + This button copies mappings from the Common Config to the currently selected profile, and cannot be used when the currently selected profile is the Common Config. + 此按鈕會將通用組態中的鍵位對應複製到目前選取的組態檔案,選取通用組態時無法使用此按鈕。 + + + Copy values from Common Config + 從通用組態中複製設定值 + + + Do you want to overwrite existing mappings with the mappings from the Common Config? + 你要將通用組態中的鍵位對應覆寫到現有的鍵位對應嗎? + + + Unable to Save + 無法儲存 + + + Cannot bind any unique input more than once + 任何唯一的鍵位都不能重複連結 + + + Press a key + 按下按鍵 + + + Cannot set mapping + 無法設定鍵位對應 + + + Mousewheel cannot be mapped to stick outputs + 滑鼠滾輪無法對應到搖桿輸出 + + + Save + 儲存 + + + Apply + 套用 + + + Restore Defaults + 還原成預設值 + + + Cancel + 取消 MainWindow Open/Add Elf Folder - Open/Add Elf Folder - - - Install Packages (PKG) - Install Packages (PKG) + 開啟/新增 Elf 資料夾 Boot Game - Boot Game + 啟動遊戲 Check for Updates @@ -907,119 +1201,119 @@ About shadPS4 - About shadPS4 + 關於 shadPS4 Configure... - Configure... - - - Install application from a .pkg file - Install application from a .pkg file + 組態… Recent Games - Recent Games + 最近遊玩的遊戲 Open shadPS4 Folder - Open shadPS4 Folder + 開啟 shadPS4 資料夾 Exit - Exit + 退出 Exit shadPS4 - Exit shadPS4 + 退出 shadPS4 Exit the application. - Exit the application. + 退出應用程式。 Show Game List - Show Game List + 顯示遊戲列表 Game List Refresh - Game List Refresh + 重新整理遊戲列表 Tiny - Tiny + 微小 Small - Small + Medium - Medium + Large - Large + List View - List View + 以列表顯示 Grid View - Grid View + 以網格顯視 Elf Viewer - Elf Viewer + Elf 檢視器 Game Install Directory - Game Install Directory + 遊戲安裝目錄 Download Cheats/Patches - Xiàzài Zuòbì / Xiūbǔ chéngshì + 下載金手指/修補檔 Dump Game List - Dump Game List + 偵印遊戲列表 - PKG Viewer - PKG Viewer + Trophy Viewer + 獎盃檢視器 + + + No games found. Please add your games to your library first. + 找不到遊戲,請先將你的遊戲加入遊戲庫中。 Search... - Search... + 搜尋… File - File + 檔案 View - View + 檢視 Game List Icons - Game List Icons + 遊戲列表圖示 Game List Mode - Game List Mode + 遊戲列表模式 Settings - Settings + 設定 Utils - Utils + 工具 Themes - Themes + 主題 Help @@ -1027,27 +1321,27 @@ Dark - Dark + 深色 Light - Light + 淺色 Green - Green + 綠色 Blue - Blue + 藍色 Violet - Violet + 紫羅蘭色 toolBar - toolBar + 工具列 Game List @@ -1059,7 +1353,7 @@ Download Cheats For All Installed Games - 下載所有已安裝遊戲的作弊碼 + 下載所有已安裝遊戲的金手指 Download Patches For All Games @@ -1071,7 +1365,7 @@ You have downloaded cheats for all the games you have installed. - 您已經下載了所有已安裝遊戲的作弊碼。 + 你已下載所有已安裝遊戲的金手指。 Patches Downloaded Successfully! @@ -1083,7 +1377,7 @@ Games: - 遊戲: + 遊戲: ELF files (*.bin *.elf *.oelf) @@ -1095,205 +1389,102 @@ Only one file can be selected! - 只能選擇一個檔案! - - - PKG Extraction - PKG 解壓縮 - - - Patch detected! - 檢測到補丁! - - - PKG and Game versions match: - PKG 和遊戲版本匹配: - - - Would you like to overwrite? - 您想要覆蓋嗎? - - - PKG Version %1 is older than installed version: - PKG 版本 %1 比已安裝版本更舊: - - - Game is installed: - 遊戲已安裝: - - - Would you like to install Patch: - 您想要安裝補丁嗎: - - - DLC Installation - DLC 安裝 - - - Would you like to install DLC: %1? - 您想要安裝 DLC: %1 嗎? - - - DLC already installed: - DLC 已經安裝: - - - Game already installed - 遊戲已經安裝 - - - PKG ERROR - PKG 錯誤 - - - Extracting PKG %1/%2 - 正在解壓縮 PKG %1/%2 - - - Extraction Finished - 解壓縮完成 - - - Game successfully installed at %1 - 遊戲成功安裝於 %1 - - - File doesn't appear to be a valid PKG file - 檔案似乎不是有效的 PKG 檔案 + 只能選取一個檔案! Run Game - Run Game + 執行遊戲 Eboot.bin file not found - Eboot.bin file not found - - - PKG File (*.PKG *.pkg) - PKG File (*.PKG *.pkg) - - - PKG is a patch or DLC, please install the game first! - PKG is a patch or DLC, please install the game first! + 找不到 Eboot.bin 檔案 Game is already running! - Game is already running! + 已在執行遊戲! shadPS4 - shadPS4 - - - - PKGViewer - - Open Folder - Open Folder + shadPS4 - PKG ERROR - PKG 錯誤 + Play + 遊玩 - Name - 名稱 + Pause + 暫停 - Serial - 序號 + Stop + 停止 - Installed - Installed + Restart + 重新啟動 - Size - 大小 + Full Screen + 全螢幕 - Category - Category + Controllers + 控制器 - Type - Type + Keyboard + 鍵盤 - App Ver - App Ver + Refresh List + 重新整理列表 - FW - FW + Resume + 繼續 - Region - 區域 - - - Flags - Flags - - - Path - 路徑 - - - File - File - - - Unknown - 未知 - - - Package - Package + Show Labels Under Icons + 在圖示下方顯示標籤 SettingsDialog Settings - Settings + 設定 General - General + 一般 System - System + 系統 Console Language - Console Language + 主機語言 Emulator Language - Emulator Language + 模擬器語言 Emulator - Emulator - - - Enable Separate Update Folder - Enable Separate Update Folder + 模擬器 Default tab when opening settings - 打開設置時的默認選項卡 + 開啟設定時的預設選項頁面 Show Game Size In List - 顯示遊戲大小在列表中 + 在列表中顯示遊戲大小 Show Splash - Show Splash + 顯示啟動畫面 Enable Discord Rich Presence @@ -1301,31 +1492,35 @@ Username - Username + 使用者名稱 Trophy Key - Trophy Key + 獎盃金鑰 Trophy - Trophy + 獎盃 + + + Open the custom trophy images/sounds folder + 開啟自訂獎盃圖像/音效資料夾 Logger - Logger + 日誌紀錄器 Log Type - Log Type + 日誌記錄類型 Log Filter - Log Filter + 日誌紀錄過濾器 Open Log Location - 開啟日誌位置 + 開啟日誌記錄位置 Input @@ -1333,19 +1528,19 @@ Cursor - 游標 + 滑鼠遊標 Hide Cursor - 隱藏游標 + 隱藏滑鼠指標 Hide Cursor Idle Timeout - 游標空閒超時隱藏 + 空閒滑鼠指標逾時隱藏 s - s + Controller @@ -1357,7 +1552,7 @@ Graphics - Graphics + 圖形 GUI @@ -1369,27 +1564,27 @@ Graphics Device - Graphics Device + 圖形裝置 Vblank Divider - Vblank Divider + Vblank 分隔符 Advanced - Advanced + 進階 Enable Shaders Dumping - Enable Shaders Dumping + 啟用著色器傾印 Enable NULL GPU - Enable NULL GPU + 啟用空值GPU Enable HDR - Enable HDR + 啟用 HDR Paths @@ -1401,7 +1596,7 @@ Add... - 添加... + 新增… Remove @@ -1409,43 +1604,43 @@ Debug - Debug + 偵錯 Enable Debug Dumping - Enable Debug Dumping + 啟用偵錯傾印 Enable Vulkan Validation Layers - Enable Vulkan Validation Layers + 啟用 Vulkan 驗證層 Enable Vulkan Synchronization Validation - Enable Vulkan Synchronization Validation + 啟用 Vulkan 同步驗證 Enable RenderDoc Debugging - Enable RenderDoc Debugging + 啟用 RenderDoc 偵錯 Enable Crash Diagnostics - Enable Crash Diagnostics + 啟用當機診斷 Collect Shaders - Collect Shaders + 收集著色器 Copy GPU Buffers - Copy GPU Buffers + 複製 GPU 緩衝區 Host Debug Markers - Host Debug Markers + Host 偵錯標記 Guest Debug Markers - Guest Debug Markers + Guest 偵錯標記 Update @@ -1469,27 +1664,27 @@ GUI Settings - 介面設置 + 介面設定 Title Music - Title Music + 標題音樂 - Disable Trophy Pop-ups - Disable Trophy Pop-ups + Disable Trophy Notification + 停用獎盃通知 Background Image - Background Image + 背景圖像 Show Background Image - Show Background Image + 顯示背景影像 Opacity - Opacity + 透明度 Play title music @@ -1497,19 +1692,19 @@ Update Compatibility Database On Startup - Update Compatibility Database On Startup + 啟動時更新相容性資料庫 Game Compatibility - Game Compatibility + 遊戲相容性 Display Compatibility Data - Display Compatibility Data + 顯示相容性資料 Update Compatibility Database - Update Compatibility Database + 更新相容性資料庫 Volume @@ -1525,7 +1720,7 @@ Restore Defaults - 還原預設值 + 還原成預設值 Close @@ -1533,83 +1728,79 @@ Point your mouse at an option to display its description. - 將鼠標指向選項以顯示其描述。 + 將滑鼠指標指向選項就會顯示其描述。 Console Language:\nSets the language that the PS4 game uses.\nIt's recommended to set this to a language the game supports, which will vary by region. - 主機語言:\n設定PS4遊戲使用的語言。\n建議將其設置為遊戲支持的語言,這會因地區而異。 + 主機語言:\n設定 PS4 遊戲使用的語言。 \n建議將其設定為遊戲'支援的語言,該語言因地區而異。 Emulator Language:\nSets the language of the emulator's user interface. - 模擬器語言:\n設定模擬器的用戶介面的語言。 - - - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management.\nThis can be manually created by adding the extracted update to the game folder with the name "CUSA00000-UPDATE" where the CUSA ID matches the game's ID. - Enable Separate Update Folder:\nEnables installing game updates into a separate folder for easy management. + 模擬器語言:\n設定模擬器'的使用者介面語言。 Show Splash Screen:\nShows the game's splash screen (a special image) while the game is starting. - 顯示啟動畫面:\n在遊戲啟動時顯示遊戲的啟動畫面(特殊圖片)。 + 顯示啟動畫面:\n遊戲'開始時顯示遊戲的啟動畫面(特殊圖像)。 Enable Discord Rich Presence:\nDisplays the emulator icon and relevant information on your Discord profile. - 啟用 Discord Rich Presence:\n在您的 Discord 個人檔案上顯示模擬器圖標和相關信息。 + 啟用 Discord Rich Presence:\n在你的 Discord 個人檔案上顯示模擬器圖示和相關資訊。 Username:\nSets the PS4's account username, which may be displayed by some games. - 用戶名:\n設定PS4帳號的用戶名,某些遊戲中可能會顯示。 + 使用者名稱:\n設定 PS4 '的帳號使用者名稱,某些遊戲可能會顯示該使用者名稱。 Trophy Key:\nKey used to decrypt trophies. Must be obtained from your jailbroken console.\nMust contain only hex characters. - Trophy Key:\nKey used to decrypt trophies. Must be obtained from your jailbroken console.\nMust contain only hex characters. + 獎盃金鑰:\n用於解密獎盃的金鑰,必須從你的越獄主機中獲取。 \n僅包含十六進制字元。 Log Type:\nSets whether to synchronize the output of the log window for performance. May have adverse effects on emulation. - 日誌類型:\n設定是否同步日誌窗口的輸出以提高性能。可能對模擬產生不良影響。 + 日誌記錄類型:\n設定是否同步日誌記錄視窗的輸出以提高效能。可能會對模擬產生負面影響。 Log Filter:\nFilters the log to only print specific information.\nExamples: "Core:Trace" "Lib.Pad:Debug Common.Filesystem:Error" "*:Critical"\nLevels: Trace, Debug, Info, Warning, Error, Critical - in this order, a specific level silences all levels preceding it in the list and logs every level after it. - 日誌過濾器:\n過濾日誌以僅打印特定信息。\n範例:"Core:Trace" "Lib.Pad:Debug Common.Filesystem:Error" "*:Critical" 等級: Trace, Debug, Info, Warning, Error, Critical - 以此順序,特定級別靜音所有前面的級別,並記錄其後的每個級別。 + 日誌記錄過濾器:\n過濾日誌記錄以僅列出特定資訊。 \n範例:{[="-=]}Core:Trace{[="-=]} {[="-=]}Lib.Pad:Debug Common.Filesystem:Error{[="-=]} {[="-=]}*:Critical{[="-=]}\n等級:Trace、Debug、Info、Warning、Error、Critical - 按照此順序,指定等級之後會不列出列表中等級低於其的所有資訊,並記錄列出等級高於其/同級的資訊。 Update:\nRelease: Official versions released every month that may be very outdated, but are more reliable and tested.\nNightly: Development versions that have all the latest features and fixes, but may contain bugs and are less stable. - 更新:\nRelease: 每月發布的官方版本,可能非常舊,但更可靠且經過測試。\nNightly: 開發版本,擁有所有最新的功能和修復,但可能包含錯誤,穩定性較差。 + 更新:\n正式版:每月發布的正式版本可能會過時,但更可靠而且有經過測試。 \n預覽版:具有所有最新功能和修復的開發版本,但可能含有一些錯誤而且不太穩定。 Background Image:\nControl the opacity of the game background image. - Background Image:\nControl the opacity of the game background image. + 背景圖像:\n控制遊戲背​​景圖像的能見度。 Play Title Music:\nIf a game supports it, enable playing special music when selecting the game in the GUI. - 播放標題音樂:\n如果遊戲支持,啟用在GUI中選擇遊戲時播放特殊音樂。 + 播放標題音樂:\n如果遊戲支援的話,則啟用在 GUI 中選取遊戲時播放特殊音樂。 Disable Trophy Pop-ups:\nDisable in-game trophy notifications. Trophy progress can still be tracked using the Trophy Viewer (right-click the game in the main window). - Disable Trophy Pop-ups:\nDisable in-game trophy notifications. Trophy progress can still be tracked using the Trophy Viewer (right-click the game in the main window). + 停用獎盃彈出視窗:\n停用遊戲內獎盃通知,仍然可以使用獎盃檢視器(在主視窗中右鍵單擊遊戲)追蹤獎盃進度。 Hide Cursor:\nChoose when the cursor will disappear:\nNever: You will always see the mouse.\nidle: Set a time for it to disappear after being idle.\nAlways: you will never see the mouse. - 隱藏游標:\n選擇游標何時消失:\n從不: 您將始終看到滑鼠。\n閒置: 設定在閒置後消失的時間。\n始終: 您將永遠看不到滑鼠。 + 隱藏滑鼠指標:\n選擇滑鼠指標何時消失:\n從不:你始終會看到滑鼠指標。 \n閒置:設定滑鼠指標空閒多久後消失的時間。 \n始終:你始終看不到滑鼠指標。 Hide Idle Cursor Timeout:\nThe duration (seconds) after which the cursor that has been idle hides itself. - 設定滑鼠在閒置後消失的時間。 + 空閒滑鼠指標隱藏逾時:\n閒置滑鼠指標隱藏自身之前的持續顯示時間(秒)。 Back Button Behavior:\nSets the controller's back button to emulate tapping the specified position on the PS4 touchpad. - 返回按鈕行為:\n設定控制器的返回按鈕模擬在 PS4 觸控板上指定位置的觸碰。 + 返回按鈕行為:\n設定控制器'的返回按鈕以模擬點擊 PS4 控制器觸控板上的指定位置。 Display Compatibility Data:\nDisplays game compatibility information in table view. Enable "Update Compatibility On Startup" to get up-to-date information. - Display Compatibility Data:\nDisplays game compatibility information in table view. Enable "Update Compatibility On Startup" to get up-to-date information. + 顯示相容性資料:\n在表格顯視模式中顯示遊戲相容性資訊。啟用「啟動"時更新相容性」以取得"最新資訊。 Update Compatibility On Startup:\nAutomatically update the compatibility database when shadPS4 starts. - Update Compatibility On Startup:\nAutomatically update the compatibility database when shadPS4 starts. + 啟動時更新相容性:\n在 shadPS4 啟動時自動更新相容性資料庫。 Update Compatibility Database:\nImmediately update the compatibility database. - Update Compatibility Database:\nImmediately update the compatibility database. + 更新相容性資料庫:\n立即更新相容性資料庫。 Never @@ -1641,174 +1832,250 @@ Graphics Device:\nOn multiple GPU systems, select the GPU the emulator will use from the drop down list,\nor select "Auto Select" to automatically determine it. - 圖形設備:\n在多GPU系統中,從下拉列表中選擇模擬器將使用的GPU,\n或選擇「自動選擇」以自動確定。 + 圖形裝置:\n在多GPU系統中,從下拉列表中選取模擬器將使用的GPU,\n或選取「自動選取」以自動選用適合的GPU。 Width/Height:\nSets the size of the emulator window at launch, which can be resized during gameplay.\nThis is different from the in-game resolution. - 寬度/高度:\n設定模擬器啟動時的窗口大小,可以在遊戲過程中調整。\n這與遊戲內解析度不同。 + 寬度/高度:\n設定模擬器啟動時的視窗大小,可以在遊戲過程中調整。\n這與遊戲內部解析度不同。 Vblank Divider:\nThe frame rate at which the emulator refreshes at is multiplied by this number. Changing this may have adverse effects, such as increasing the game speed, or breaking critical game functionality that does not expect this to change! - Vblank分隔符:\n模擬器的幀速率將乘以這個數字。更改此數字可能會有不良影響,例如增加遊戲速度,或破壞不預期此變化的關鍵遊戲功能! + Vblank分隔符:\n模擬器的畫格速率將乘以這個數字。變更此數字可能會有不良影響,例如增加遊戲速度,或可能會不似預期地破壞關鍵的遊戲功能! Enable Shaders Dumping:\nFor the sake of technical debugging, saves the games shaders to a folder as they render. - 啟用著色器轉儲:\n為了技術調試,將遊戲的著色器在渲染時保存到文件夾中。 + 啟用著色器傾印:\n作為技術偵錯用途,將遊戲的著色器在渲染時儲存到資料夾中。 Enable Null GPU:\nFor the sake of technical debugging, disables game rendering as if there were no graphics card. - 啟用空GPU:\n為了技術調試,禁用遊戲渲染,彷彿沒有顯示卡。 + 啟用空值GPU:\n作為技術偵錯用途,停用遊戲渲染,彷如沒有顯示卡。 Enable HDR:\nEnables HDR in games that support it.\nYour monitor must have support for the BT2020 PQ color space and the RGB10A2 swapchain format. - Enable HDR:\nEnables HDR in games that support it.\nYour monitor must have support for the BT2020 PQ color space and the RGB10A2 swapchain format. + 啟用 HDR:\n在支援 HDR 的遊戲中啟用 HDR。 \n您的顯示器必須支援 BT2020 PQ 色彩空間和 RGB10A2 交換鏈格式。 Game Folders:\nThe list of folders to check for installed games. - 遊戲資料夾:\n檢查已安裝遊戲的資料夾列表。 + 遊戲資料夾:\n檢查已安裝遊戲的資料夾列表。 Add:\nAdd a folder to the list. - 添加:\n將資料夾添加到列表。 + 新增:\n將資料夾新增到列表中。 Remove:\nRemove a folder from the list. - 移除:\n從列表中移除資料夾。 + 移除:\n從列表中移除資料夾。 Enable Debug Dumping:\nSaves the import and export symbols and file header information of the currently running PS4 program to a directory. - 啟用調試轉儲:\n將當前運行的PS4程序的輸入和輸出符號及文件頭信息保存到目錄中。 + 啟用偵錯傾印:\n將目前執行的PS4程式的輸入和輸出符號以及檔案頭資訊儲存到目錄中。 Enable Vulkan Validation Layers:\nEnables a system that validates the state of the Vulkan renderer and logs information about its internal state.\nThis will reduce performance and likely change the behavior of emulation. - 啟用Vulkan驗證層:\n啟用一個系統來驗證Vulkan渲染器的狀態並記錄其內部狀態的信息。這將降低性能並可能改變模擬行為。 + 啟用Vulkan驗證層:\n啟用一個系統來驗證Vulkan渲染器的狀態並記錄其內部狀態的資訊。這樣將會降低效能並可能改變模擬行為。 Enable Vulkan Synchronization Validation:\nEnables a system that validates the timing of Vulkan rendering tasks.\nThis will reduce performance and likely change the behavior of emulation. - 啟用Vulkan同步驗證:\n啟用一個系統來驗證Vulkan渲染任務的時間。這將降低性能並可能改變模擬行為。 + 啟用Vulkan同步驗證:\n啟用一個系統來驗證Vulkan渲染工作的時間。\n這樣將會降低效能並可能改變模擬行為。 Enable RenderDoc Debugging:\nIf enabled, the emulator will provide compatibility with Renderdoc to allow capture and analysis of the currently rendered frame. - 啟用RenderDoc調試:\n如果啟用,模擬器將提供與Renderdoc的兼容性,以允許捕獲和分析當前渲染的幀。 + 啟用RenderDoc偵錯:\n如果啟用的話,模擬器將會提供與Renderdoc的相容性,以便允許擷取和分析目前渲染的畫格。 Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). - Collect Shaders:\nYou need this enabled to edit shaders with the debug menu (Ctrl + F10). + 收集著色器:\n您需要啟用此功能才能使用偵錯功能表 (Ctrl + F10) 編輯著色器。 Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. - Crash Diagnostics:\nCreates a .yaml file with info about the Vulkan state at the time of crashing.\nUseful for debugging 'Device lost' errors. If you have this enabled, you should enable Host AND Guest Debug Markers.\nDoes not work on Intel GPUs.\nYou need Vulkan Validation Layers enabled and the Vulkan SDK for this to work. + 當機診斷:\n會建立一個 .yaml 檔案,其中包含有關當機時 Vulkan 狀態的資訊。 \n對於偵錯「'裝置遺失」的'錯誤很有用。如果啟用了此功能,則應啟用主機和來賓偵錯標記。 \n不適用於 Intel GPU。 \n你需要啟用 Vulkan 驗證層和 Vulkan SDK 才能使此功能如常運作。 Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. - Copy GPU Buffers:\nGets around race conditions involving GPU submits.\nMay or may not help with PM4 type 0 crashes. + 複製 GPU 緩衝區:\n解決涉及 GPU 提交的競爭條件。 \n說不定能幫助解決 PM4 類型 0 的當機。 Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. - Host Debug Markers:\nInserts emulator-side information like markers for specific AMDGPU commands around Vulkan commands, as well as giving resources debug names.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + Host 偵錯標記:\n插入模擬器端資訊,例如圍繞 Vulkan 指令的特定 AMDGPU 指令的標記,以及提供資源偵錯名稱。 \n如果啟用此功能,則應啟用當機診斷。 \n對於 RenderDoc 等程式很有用。 Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. - Guest Debug Markers:\nInserts any debug markers the game itself has added to the command buffer.\nIf you have this enabled, you should enable Crash Diagnostics.\nUseful for programs like RenderDoc. + Guest 偵錯標記:\n插入遊戲本身已新增至指令緩衝區的任何偵錯標記。 \n如果啟用此功能,則應啟用當機診斷。 \n對於 RenderDoc 等程式很有用。 Save Data Path:\nThe folder where game save data will be saved. - Save Data Path:\nThe folder where game save data will be saved. + 遊戲存檔路徑:\n存放遊戲存檔資料的資料夾。 Browse:\nBrowse for a folder to set as the save data path. - Browse:\nBrowse for a folder to set as the save data path. + 瀏覽:\n選取要設定為存放遊戲存檔路徑的資料夾。 Release - Release + 正式版 Nightly - Nightly + 預覽版 Set the volume of the background music. - Set the volume of the background music. + 設定背景音樂的音量。 Enable Motion Controls - Enable Motion Controls + 啟用動態感應控制 Save Data Path - Save Data Path + 遊戲存檔路徑 Browse - Browse + 瀏覽 async - async + 異步 sync - sync + 同步 Auto Select - Auto Select + 自動選取 Directory to install games - Directory to install games + 要安裝遊戲的目錄 Directory to save data - Directory to save data + 遊戲存檔的目錄 Video - Video + 影像 Display Mode - Display Mode + 顯示模式 Windowed - Windowed + 視窗 Fullscreen - Fullscreen + 全螢幕 Fullscreen (Borderless) - Fullscreen (Borderless) + 全螢幕(無邊框) Window Size - Window Size + 視窗大小 W: - W: + 寬: H: - H: + 高: Separate Log Files - Separate Log Files + 單獨的日誌紀錄檔 Separate Log Files:\nWrites a separate logfile for each game. - Separate Log Files:\nWrites a separate logfile for each game. + 單獨的日誌紀錄檔:\n為個別遊戲寫入單獨的日誌記錄檔。 + + + Trophy Notification Position + 獎盃通知位置 + + + Left + 左側 + + + Right + 右側 + + + Top + 頂部 + + + Bottom + 底部 + + + Notification Duration + 通知顯示持續時間 + + + Portable User Folder + 可移植的使用者資料夾 + + + Create Portable User Folder from Common User Folder + 從通用使用者資料夾建立可移植的使用者資料夾 + + + Portable user folder:\nStores shadPS4 settings and data that will be applied only to the shadPS4 build located in the current folder. Restart the app after creating the portable user folder to begin using it. + 可移植的使用者資料夾:\n儲存僅套用於目前資料夾中的 shadPS4 版本的 shadPS4 設定和資料。建立可移植的使用者資料夾後重新啟動應用程式以便開始使用它。 + + + Cannot create portable user folder + 無法建立可移植的使用者資料夾 + + + %1 already exists + %1 已存在 + + + Portable user folder created + 已建立可移植的使用者資料夾 + + + %1 successfully created. + 已成功建立 %1。 + + + Open the custom trophy images/sounds folder:\nYou can add custom images to the trophies and an audio.\nAdd the files to custom_trophy with the following names:\ntrophy.wav OR trophy.mp3, bronze.png, gold.png, platinum.png, silver.png\nNote: The sound will only work in QT versions. + 開啟自訂獎盃影像/聲音資料夾:\n您可以將自訂影像新增至獎盃和音訊。 \n將檔案加入 custom_tropy,名稱如下:\ntropy.wav OR trophy.mp3、bronze.png、gold.png、platinum.png、silver.png\n注意:聲音僅在 QT 版本中有效。 TrophyViewer Trophy Viewer - Trophy Viewer + 獎盃檢視器 + + + Select Game: + 選取遊戲: + + + Progress + 進度 + + + Show Earned Trophies + 顯示已獲得的獎盃 + + + Show Not Earned Trophies + 顯示未獲得的獎盃 + + + Show Hidden Trophies + 顯示隱藏的獎盃 diff --git a/src/qt_gui/trophy_viewer.cpp b/src/qt_gui/trophy_viewer.cpp index 148cbee06..bed487605 100644 --- a/src/qt_gui/trophy_viewer.cpp +++ b/src/qt_gui/trophy_viewer.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include "common/path_util.h" @@ -103,8 +104,10 @@ void TrophyViewer::updateTableFilters() { } } -TrophyViewer::TrophyViewer(QString trophyPath, QString gameTrpPath) : QMainWindow() { - this->setWindowTitle(tr("Trophy Viewer")); +TrophyViewer::TrophyViewer(QString trophyPath, QString gameTrpPath, QString gameName, + const QVector& allTrophyGames) + : QMainWindow(), allTrophyGames_(allTrophyGames), currentGameName_(gameName) { + this->setWindowTitle(tr("Trophy Viewer") + " - " + currentGameName_); this->setAttribute(Qt::WA_DeleteOnClose); tabWidget = new QTabWidget(this); @@ -126,11 +129,40 @@ TrophyViewer::TrophyViewer(QString trophyPath, QString gameTrpPath) : QMainWindo << "PID"; PopulateTrophyWidget(trophyPath); - QDockWidget* trophyInfoDock = new QDockWidget("", this); + trophyInfoDock = new QDockWidget("", this); QWidget* dockWidget = new QWidget(trophyInfoDock); QVBoxLayout* dockLayout = new QVBoxLayout(dockWidget); dockLayout->setAlignment(Qt::AlignTop); + // ComboBox for game selection + if (!allTrophyGames_.isEmpty()) { + QLabel* gameSelectionLabel = new QLabel(tr("Select Game:"), dockWidget); + dockLayout->addWidget(gameSelectionLabel); + + gameSelectionComboBox = new QComboBox(dockWidget); + for (const auto& game : allTrophyGames_) { + gameSelectionComboBox->addItem(game.name); + } + + // Select current game in ComboBox + if (!currentGameName_.isEmpty()) { + int index = gameSelectionComboBox->findText(currentGameName_); + if (index >= 0) { + gameSelectionComboBox->setCurrentIndex(index); + } + } + + dockLayout->addWidget(gameSelectionComboBox); + + connect(gameSelectionComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, + &TrophyViewer::onGameSelectionChanged); + + QFrame* line = new QFrame(dockWidget); + line->setFrameShape(QFrame::HLine); + line->setFrameShadow(QFrame::Sunken); + dockLayout->addWidget(line); + } + trophyInfoLabel = new QLabel(tr("Progress") + ": 0% (0/0)", dockWidget); trophyInfoLabel->setStyleSheet( "font-weight: bold; font-size: 16px; color: white; background: #333; padding: 5px;"); @@ -157,6 +189,15 @@ TrophyViewer::TrophyViewer(QString trophyPath, QString gameTrpPath) : QMainWindo // Adds the dock to the left area this->addDockWidget(Qt::LeftDockWidgetArea, trophyInfoDock); + expandButton = new QPushButton(">>", this); + expandButton->setGeometry(80, 0, 27, 27); + expandButton->hide(); + + connect(expandButton, &QPushButton::clicked, this, [this] { + trophyInfoDock->setVisible(true); + expandButton->hide(); + }); + // Connects checkbox signals to update trophy display #if (QT_VERSION < QT_VERSION_CHECK(6, 7, 0)) connect(showEarnedCheck, &QCheckBox::stateChanged, this, &TrophyViewer::updateTableFilters); @@ -173,6 +214,54 @@ TrophyViewer::TrophyViewer(QString trophyPath, QString gameTrpPath) : QMainWindo updateTrophyInfo(); updateTableFilters(); + + connect(trophyInfoDock, &QDockWidget::topLevelChanged, this, [this] { + if (!trophyInfoDock->isVisible()) { + expandButton->show(); + } + }); + + connect(trophyInfoDock, &QDockWidget::visibilityChanged, this, [this] { + if (!trophyInfoDock->isVisible()) { + expandButton->show(); + } else { + expandButton->hide(); + } + }); +} + +void TrophyViewer::onGameSelectionChanged(int index) { + if (index < 0 || index >= allTrophyGames_.size()) { + return; + } + + while (tabWidget->count() > 0) { + QWidget* widget = tabWidget->widget(0); + tabWidget->removeTab(0); + delete widget; + } + + const TrophyGameInfo& selectedGame = allTrophyGames_[index]; + currentGameName_ = selectedGame.name; + gameTrpPath_ = selectedGame.gameTrpPath; + + this->setWindowTitle(tr("Trophy Viewer") + " - " + currentGameName_); + + PopulateTrophyWidget(selectedGame.trophyPath); + + updateTrophyInfo(); + updateTableFilters(); +} + +void TrophyViewer::onDockClosed() { + if (!trophyInfoDock->isVisible()) { + reopenButton->setVisible(true); + } +} + +void TrophyViewer::reopenLeftDock() { + trophyInfoDock->show(); + reopenButton->setVisible(false); } void TrophyViewer::PopulateTrophyWidget(QString title) { @@ -354,10 +443,15 @@ void TrophyViewer::PopulateTrophyWidget(QString title) { tabWidget->addTab(tableWidget, tabName.insert(6, " ").replace(0, 1, tabName.at(0).toUpper())); - this->showMaximized(); + if (!this->isMaximized()) { + this->resize(width + 400, 720); + QSize mainWindowSize = QApplication::activeWindow()->size(); + this->resize(mainWindowSize.width() * 0.8, mainWindowSize.height() * 0.8); + } + this->show(); tableWidget->horizontalHeader()->setSectionResizeMode(3, QHeaderView::Fixed); - tableWidget->setColumnWidth(3, 650); + tableWidget->setColumnWidth(3, 500); } this->setCentralWidget(tabWidget); } diff --git a/src/qt_gui/trophy_viewer.h b/src/qt_gui/trophy_viewer.h index bd99e1a8c..c63171774 100644 --- a/src/qt_gui/trophy_viewer.h +++ b/src/qt_gui/trophy_viewer.h @@ -4,28 +4,46 @@ #pragma once #include +#include +#include #include +#include #include #include #include #include #include +#include +#include #include #include #include +#include #include #include "common/types.h" #include "core/file_format/trp.h" +struct TrophyGameInfo { + QString name; + QString trophyPath; + QString gameTrpPath; +}; + class TrophyViewer : public QMainWindow { Q_OBJECT public: - explicit TrophyViewer(QString trophyPath, QString gameTrpPath); + explicit TrophyViewer( + QString trophyPath, QString gameTrpPath, QString gameName = "", + const QVector& allTrophyGames = QVector()); void updateTrophyInfo(); - void updateTableFilters(); + void onDockClosed(); + void reopenLeftDock(); + +private slots: + void onGameSelectionChanged(int index); private: void PopulateTrophyWidget(QString title); @@ -34,11 +52,17 @@ private: QTabWidget* tabWidget = nullptr; QStringList headers; QString gameTrpPath_; + QString currentGameName_; TRP trp; QLabel* trophyInfoLabel; QCheckBox* showEarnedCheck; QCheckBox* showNotEarnedCheck; QCheckBox* showHiddenCheck; + QComboBox* gameSelectionComboBox; + QPushButton* expandButton; + QDockWidget* trophyInfoDock; + QPushButton* reopenButton; + QVector allTrophyGames_; std::string GetTrpType(const QChar trp_) { switch (trp_.toLatin1()) { diff --git a/src/sdl_window.cpp b/src/sdl_window.cpp index 80d196147..e369240c6 100644 --- a/src/sdl_window.cpp +++ b/src/sdl_window.cpp @@ -10,7 +10,7 @@ #include "common/assert.h" #include "common/config.h" #include "common/elf_info.h" -#include "common/version.h" +#include "core/debug_state.h" #include "core/libraries/kernel/time.h" #include "core/libraries/pad/pad.h" #include "imgui/renderer/imgui_core.h" @@ -396,6 +396,25 @@ void WindowSDL::WaitEvent() { case SDL_EVENT_QUIT: is_open = false; break; + case SDL_EVENT_TOGGLE_FULLSCREEN: { + if (SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN) { + SDL_SetWindowFullscreen(window, 0); + } else { + SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN); + } + break; + } + case SDL_EVENT_TOGGLE_PAUSE: + SDL_Log("Received SDL_EVENT_TOGGLE_PAUSE"); + + if (DebugState.IsGuestThreadsPaused()) { + SDL_Log("Game Resumed"); + DebugState.ResumeGuestThreads(); + } else { + SDL_Log("Game Paused"); + DebugState.PauseGuestThreads(); + } + break; default: break; } diff --git a/src/sdl_window.h b/src/sdl_window.h index 03ba0797b..48a9be58c 100644 --- a/src/sdl_window.h +++ b/src/sdl_window.h @@ -7,6 +7,8 @@ #include "core/libraries/pad/pad.h" #include "input/controller.h" #include "string" +#define SDL_EVENT_TOGGLE_FULLSCREEN (SDL_EVENT_USER + 1) +#define SDL_EVENT_TOGGLE_PAUSE (SDL_EVENT_USER + 2) struct SDL_Window; struct SDL_Gamepad; diff --git a/src/shader_recompiler/backend/spirv/emit_spirv.cpp b/src/shader_recompiler/backend/spirv/emit_spirv.cpp index 6b0d7228b..936f82cd6 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv.cpp @@ -32,6 +32,8 @@ static constexpr spv::ExecutionMode GetInputPrimitiveType(AmdGpu::PrimitiveType return spv::ExecutionMode::Triangles; case AmdGpu::PrimitiveType::AdjTriangleList: return spv::ExecutionMode::InputTrianglesAdjacency; + case AmdGpu::PrimitiveType::AdjLineList: + return spv::ExecutionMode::InputLinesAdjacency; default: UNREACHABLE_MSG("Unknown input primitive type {}", u32(type)); } @@ -333,8 +335,7 @@ void DefineEntryPoint(const Info& info, EmitContext& ctx, Id main) { ctx.AddExecutionMode(main, spv::ExecutionMode::OriginUpperLeft); } if (info.has_discard) { - ctx.AddExtension("SPV_EXT_demote_to_helper_invocation"); - ctx.AddCapability(spv::Capability::DemoteToHelperInvocationEXT); + ctx.AddCapability(spv::Capability::DemoteToHelperInvocation); } if (info.stores.GetAny(IR::Attribute::Depth)) { ctx.AddExecutionMode(main, spv::ExecutionMode::DepthReplacing); diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_atomic.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_atomic.cpp index 4faa99fe8..211899714 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_atomic.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_atomic.cpp @@ -21,6 +21,15 @@ Id SharedAtomicU32(EmitContext& ctx, Id offset, Id value, return (ctx.*atomic_func)(ctx.U32[1], pointer, scope, semantics, value); } +Id SharedAtomicU32_IncDec(EmitContext& ctx, Id offset, + Id (Sirit::Module::*atomic_func)(Id, Id, Id, Id)) { + const Id shift_id{ctx.ConstU32(2U)}; + const Id index{ctx.OpShiftRightArithmetic(ctx.U32[1], offset, shift_id)}; + const Id pointer{ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, index)}; + const auto [scope, semantics]{AtomicArgs(ctx)}; + return (ctx.*atomic_func)(ctx.U32[1], pointer, scope, semantics); +} + Id BufferAtomicU32BoundsCheck(EmitContext& ctx, Id index, Id buffer_size, auto emit_func) { if (Sirit::ValidId(buffer_size)) { // Bounds checking enabled, wrap in a conditional branch to make sure that @@ -29,6 +38,7 @@ Id BufferAtomicU32BoundsCheck(EmitContext& ctx, Id index, Id buffer_size, auto e const Id ib_label = ctx.OpLabel(); const Id oob_label = ctx.OpLabel(); const Id end_label = ctx.OpLabel(); + ctx.OpSelectionMerge(end_label, spv::SelectionControlMask::MaskNone); ctx.OpBranchConditional(in_bounds, ib_label, oob_label); ctx.AddLabel(ib_label); const Id ib_result = emit_func(); @@ -99,6 +109,18 @@ Id EmitSharedAtomicXor32(EmitContext& ctx, Id offset, Id value) { return SharedAtomicU32(ctx, offset, value, &Sirit::Module::OpAtomicXor); } +Id EmitSharedAtomicISub32(EmitContext& ctx, Id offset, Id value) { + return SharedAtomicU32(ctx, offset, value, &Sirit::Module::OpAtomicISub); +} + +Id EmitSharedAtomicIIncrement32(EmitContext& ctx, Id offset) { + return SharedAtomicU32_IncDec(ctx, offset, &Sirit::Module::OpAtomicIIncrement); +} + +Id EmitSharedAtomicIDecrement32(EmitContext& ctx, Id offset) { + return SharedAtomicU32_IncDec(ctx, offset, &Sirit::Module::OpAtomicIDecrement); +} + Id EmitBufferAtomicIAdd32(EmitContext& ctx, IR::Inst* inst, u32 handle, Id address, Id value) { return BufferAtomicU32(ctx, inst, handle, address, value, &Sirit::Module::OpAtomicIAdd); } diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_bitwise_conversion.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_bitwise_conversion.cpp index 56a6abc05..43655ba3f 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_bitwise_conversion.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_bitwise_conversion.cpp @@ -64,10 +64,6 @@ Id EmitBitCastU32F32(EmitContext& ctx, Id value) { return ctx.OpBitcast(ctx.U32[1], value); } -Id EmitBitCastU64F64(EmitContext& ctx, Id value) { - return ctx.OpBitcast(ctx.U64, value); -} - Id EmitBitCastF16U16(EmitContext& ctx, Id value) { return ctx.OpBitcast(ctx.F16[1], value); } @@ -76,10 +72,6 @@ Id EmitBitCastF32U32(EmitContext& ctx, Id value) { return ctx.OpBitcast(ctx.F32[1], value); } -void EmitBitCastF64U64(EmitContext&) { - UNREACHABLE_MSG("SPIR-V Instruction"); -} - Id EmitPackUint2x32(EmitContext& ctx, Id value) { return ctx.OpBitcast(ctx.U64, value); } @@ -88,10 +80,14 @@ Id EmitUnpackUint2x32(EmitContext& ctx, Id value) { return ctx.OpBitcast(ctx.U32[2], value); } -Id EmitPackFloat2x32(EmitContext& ctx, Id value) { +Id EmitPackDouble2x32(EmitContext& ctx, Id value) { return ctx.OpBitcast(ctx.F64[1], value); } +Id EmitUnpackDouble2x32(EmitContext& ctx, Id value) { + return ctx.OpBitcast(ctx.U32[2], value); +} + Id EmitPackUnorm2x16(EmitContext& ctx, Id value) { return ctx.OpPackUnorm2x16(ctx.U32[1], value); } diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_floating_point.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_floating_point.cpp index a63be87e2..347c4cb0a 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_floating_point.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_floating_point.cpp @@ -75,6 +75,28 @@ Id EmitFPMin64(EmitContext& ctx, Id a, Id b) { return ctx.OpFMin(ctx.F64[1], a, b); } +Id EmitFPMinTri32(EmitContext& ctx, Id a, Id b, Id c) { + if (ctx.profile.supports_trinary_minmax) { + return ctx.OpFMin3AMD(ctx.F32[1], a, b, c); + } + return ctx.OpFMin(ctx.F32[1], a, ctx.OpFMin(ctx.F32[1], b, c)); +} + +Id EmitFPMaxTri32(EmitContext& ctx, Id a, Id b, Id c) { + if (ctx.profile.supports_trinary_minmax) { + return ctx.OpFMax3AMD(ctx.F32[1], a, b, c); + } + return ctx.OpFMax(ctx.F32[1], a, ctx.OpFMax(ctx.F32[1], b, c)); +} + +Id EmitFPMedTri32(EmitContext& ctx, Id a, Id b, Id c) { + if (ctx.profile.supports_trinary_minmax) { + return ctx.OpFMid3AMD(ctx.F32[1], a, b, c); + } + const Id mmx{ctx.OpFMin(ctx.F32[1], ctx.OpFMax(ctx.F32[1], a, b), c)}; + return ctx.OpFMax(ctx.F32[1], ctx.OpFMin(ctx.F32[1], a, b), mmx); +} + Id EmitFPMul16(EmitContext& ctx, IR::Inst* inst, Id a, Id b) { return Decorate(ctx, inst, ctx.OpFMul(ctx.F16[1], a, b)); } @@ -245,12 +267,12 @@ Id EmitFPFrexpSig64(EmitContext& ctx, Id value) { Id EmitFPFrexpExp32(EmitContext& ctx, Id value) { const auto frexp = ctx.OpFrexpStruct(ctx.frexp_result_f32, value); - return ctx.OpCompositeExtract(ctx.U32[1], frexp, 1); + return ctx.OpBitcast(ctx.U32[1], ctx.OpCompositeExtract(ctx.S32[1], frexp, 1)); } Id EmitFPFrexpExp64(EmitContext& ctx, Id value) { const auto frexp = ctx.OpFrexpStruct(ctx.frexp_result_f64, value); - return ctx.OpCompositeExtract(ctx.U32[1], frexp, 1); + return ctx.OpBitcast(ctx.U32[1], ctx.OpCompositeExtract(ctx.S32[1], frexp, 1)); } Id EmitFPOrdEqual16(EmitContext& ctx, Id lhs, Id rhs) { diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h index aaa2bb526..079f1005d 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h +++ b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h @@ -130,6 +130,10 @@ Id EmitSharedAtomicSMin32(EmitContext& ctx, Id offset, Id value); Id EmitSharedAtomicAnd32(EmitContext& ctx, Id offset, Id value); Id EmitSharedAtomicOr32(EmitContext& ctx, Id offset, Id value); Id EmitSharedAtomicXor32(EmitContext& ctx, Id offset, Id value); +Id EmitSharedAtomicIIncrement32(EmitContext& ctx, Id offset); +Id EmitSharedAtomicIDecrement32(EmitContext& ctx, Id offset); +Id EmitSharedAtomicISub32(EmitContext& ctx, Id offset, Id value); + Id EmitCompositeConstructU32x2(EmitContext& ctx, IR::Inst* inst, Id e1, Id e2); Id EmitCompositeConstructU32x3(EmitContext& ctx, IR::Inst* inst, Id e1, Id e2, Id e3); Id EmitCompositeConstructU32x4(EmitContext& ctx, IR::Inst* inst, Id e1, Id e2, Id e3, Id e4); @@ -198,13 +202,12 @@ Id EmitSelectF32(EmitContext& ctx, Id cond, Id true_value, Id false_value); Id EmitSelectF64(EmitContext& ctx, Id cond, Id true_value, Id false_value); Id EmitBitCastU16F16(EmitContext& ctx, Id value); Id EmitBitCastU32F32(EmitContext& ctx, Id value); -Id EmitBitCastU64F64(EmitContext& ctx, Id value); Id EmitBitCastF16U16(EmitContext& ctx, Id value); Id EmitBitCastF32U32(EmitContext& ctx, Id value); -void EmitBitCastF64U64(EmitContext& ctx); Id EmitPackUint2x32(EmitContext& ctx, Id value); Id EmitUnpackUint2x32(EmitContext& ctx, Id value); -Id EmitPackFloat2x32(EmitContext& ctx, Id value); +Id EmitPackDouble2x32(EmitContext& ctx, Id value); +Id EmitUnpackDouble2x32(EmitContext& ctx, Id value); Id EmitPackUnorm2x16(EmitContext& ctx, Id value); Id EmitUnpackUnorm2x16(EmitContext& ctx, Id value); Id EmitPackSnorm2x16(EmitContext& ctx, Id value); @@ -247,6 +250,9 @@ Id EmitFPMax32(EmitContext& ctx, Id a, Id b, bool is_legacy = false); Id EmitFPMax64(EmitContext& ctx, Id a, Id b); Id EmitFPMin32(EmitContext& ctx, Id a, Id b, bool is_legacy = false); Id EmitFPMin64(EmitContext& ctx, Id a, Id b); +Id EmitFPMinTri32(EmitContext& ctx, Id a, Id b, Id c); +Id EmitFPMaxTri32(EmitContext& ctx, Id a, Id b, Id c); +Id EmitFPMedTri32(EmitContext& ctx, Id a, Id b, Id c); Id EmitFPMul16(EmitContext& ctx, IR::Inst* inst, Id a, Id b); Id EmitFPMul32(EmitContext& ctx, IR::Inst* inst, Id a, Id b); Id EmitFPMul64(EmitContext& ctx, IR::Inst* inst, Id a, Id b); @@ -335,8 +341,8 @@ Id EmitIAdd64(EmitContext& ctx, Id a, Id b); Id EmitIAddCary32(EmitContext& ctx, Id a, Id b); Id EmitISub32(EmitContext& ctx, Id a, Id b); Id EmitISub64(EmitContext& ctx, Id a, Id b); -Id EmitSMulExt(EmitContext& ctx, Id a, Id b); -Id EmitUMulExt(EmitContext& ctx, Id a, Id b); +Id EmitSMulHi(EmitContext& ctx, Id a, Id b); +Id EmitUMulHi(EmitContext& ctx, Id a, Id b); Id EmitIMul32(EmitContext& ctx, Id a, Id b); Id EmitIMul64(EmitContext& ctx, Id a, Id b); Id EmitSDiv32(EmitContext& ctx, Id a, Id b); @@ -372,6 +378,12 @@ Id EmitSMin32(EmitContext& ctx, Id a, Id b); Id EmitUMin32(EmitContext& ctx, Id a, Id b); Id EmitSMax32(EmitContext& ctx, Id a, Id b); Id EmitUMax32(EmitContext& ctx, Id a, Id b); +Id EmitSMinTri32(EmitContext& ctx, Id a, Id b, Id c); +Id EmitUMinTri32(EmitContext& ctx, Id a, Id b, Id c); +Id EmitSMaxTri32(EmitContext& ctx, Id a, Id b, Id c); +Id EmitUMaxTri32(EmitContext& ctx, Id a, Id b, Id c); +Id EmitSMedTri32(EmitContext& ctx, Id a, Id b, Id c); +Id EmitUMedTri32(EmitContext& ctx, Id a, Id b, Id c); Id EmitSClamp32(EmitContext& ctx, IR::Inst* inst, Id value, Id min, Id max); Id EmitUClamp32(EmitContext& ctx, IR::Inst* inst, Id value, Id min, Id max); Id EmitSLessThan32(EmitContext& ctx, Id lhs, Id rhs); diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_integer.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_integer.cpp index e2d702389..10bfbb2ab 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_integer.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_integer.cpp @@ -72,12 +72,17 @@ Id EmitISub64(EmitContext& ctx, Id a, Id b) { return ctx.OpISub(ctx.U64, a, b); } -Id EmitSMulExt(EmitContext& ctx, Id a, Id b) { - return ctx.OpSMulExtended(ctx.full_result_i32x2, a, b); +Id EmitSMulHi(EmitContext& ctx, Id a, Id b) { + const auto signed_a{ctx.OpBitcast(ctx.S32[1], a)}; + const auto signed_b{ctx.OpBitcast(ctx.S32[1], b)}; + const auto mul_ext{ctx.OpSMulExtended(ctx.full_result_i32x2, signed_a, signed_b)}; + const auto signed_hi{ctx.OpCompositeExtract(ctx.S32[1], mul_ext, 1)}; + return ctx.OpBitcast(ctx.U32[1], signed_hi); } -Id EmitUMulExt(EmitContext& ctx, Id a, Id b) { - return ctx.OpUMulExtended(ctx.full_result_u32x2, a, b); +Id EmitUMulHi(EmitContext& ctx, Id a, Id b) { + const auto mul_ext{ctx.OpUMulExtended(ctx.full_result_u32x2, a, b)}; + return ctx.OpCompositeExtract(ctx.U32[1], mul_ext, 1); } Id EmitIMul32(EmitContext& ctx, Id a, Id b) { @@ -236,7 +241,7 @@ Id EmitFindILsb64(EmitContext& ctx, Id value) { const Id hi{ctx.OpCompositeExtract(ctx.U32[1], unpacked, 1U)}; const Id lo_lsb{ctx.OpFindILsb(ctx.U32[1], lo)}; const Id hi_lsb{ctx.OpFindILsb(ctx.U32[1], hi)}; - const Id found_lo{ctx.OpINotEqual(ctx.U32[1], lo_lsb, ctx.ConstU32(u32(-1)))}; + const Id found_lo{ctx.OpINotEqual(ctx.U1[1], lo_lsb, ctx.ConstU32(u32(-1)))}; return ctx.OpSelect(ctx.U32[1], found_lo, lo_lsb, hi_lsb); } @@ -256,6 +261,50 @@ Id EmitUMax32(EmitContext& ctx, Id a, Id b) { return ctx.OpUMax(ctx.U32[1], a, b); } +Id EmitSMinTri32(EmitContext& ctx, Id a, Id b, Id c) { + if (ctx.profile.supports_trinary_minmax) { + return ctx.OpSMin3AMD(ctx.U32[1], a, b, c); + } + return ctx.OpSMin(ctx.U32[1], a, ctx.OpSMin(ctx.U32[1], b, c)); +} + +Id EmitUMinTri32(EmitContext& ctx, Id a, Id b, Id c) { + if (ctx.profile.supports_trinary_minmax) { + return ctx.OpUMin3AMD(ctx.U32[1], a, b, c); + } + return ctx.OpUMin(ctx.U32[1], a, ctx.OpUMin(ctx.U32[1], b, c)); +} + +Id EmitSMaxTri32(EmitContext& ctx, Id a, Id b, Id c) { + if (ctx.profile.supports_trinary_minmax) { + return ctx.OpSMax3AMD(ctx.U32[1], a, b, c); + } + return ctx.OpSMax(ctx.U32[1], a, ctx.OpSMax(ctx.U32[1], b, c)); +} + +Id EmitUMaxTri32(EmitContext& ctx, Id a, Id b, Id c) { + if (ctx.profile.supports_trinary_minmax) { + return ctx.OpUMax3AMD(ctx.U32[1], a, b, c); + } + return ctx.OpUMax(ctx.U32[1], a, ctx.OpUMax(ctx.U32[1], b, c)); +} + +Id EmitSMedTri32(EmitContext& ctx, Id a, Id b, Id c) { + if (ctx.profile.supports_trinary_minmax) { + return ctx.OpSMid3AMD(ctx.U32[1], a, b, c); + } + const Id mmx{ctx.OpSMin(ctx.U32[1], ctx.OpSMax(ctx.U32[1], a, b), c)}; + return ctx.OpSMax(ctx.U32[1], ctx.OpSMin(ctx.U32[1], a, b), mmx); +} + +Id EmitUMedTri32(EmitContext& ctx, Id a, Id b, Id c) { + if (ctx.profile.supports_trinary_minmax) { + return ctx.OpUMid3AMD(ctx.U32[1], a, b, c); + } + const Id mmx{ctx.OpUMin(ctx.U32[1], ctx.OpUMax(ctx.U32[1], a, b), c)}; + return ctx.OpUMax(ctx.U32[1], ctx.OpUMin(ctx.U32[1], a, b), mmx); +} + Id EmitSClamp32(EmitContext& ctx, IR::Inst* inst, Id value, Id min, Id max) { Id result{}; if (ctx.profile.has_broken_spirv_clamp) { diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp index 7c25d1477..8433251ff 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp @@ -50,6 +50,8 @@ static constexpr u32 NumVertices(AmdGpu::PrimitiveType type) { return 3u; case AmdGpu::PrimitiveType::AdjTriangleList: return 6u; + case AmdGpu::PrimitiveType::AdjLineList: + return 4u; default: UNREACHABLE(); } @@ -151,9 +153,9 @@ void EmitContext::DefineArithmeticTypes() { full_result_i32x2 = Name(TypeStruct(S32[1], S32[1]), "full_result_i32x2"); full_result_u32x2 = Name(TypeStruct(U32[1], U32[1]), "full_result_u32x2"); - frexp_result_f32 = Name(TypeStruct(F32[1], U32[1]), "frexp_result_f32"); + frexp_result_f32 = Name(TypeStruct(F32[1], S32[1]), "frexp_result_f32"); if (info.uses_fp64) { - frexp_result_f64 = Name(TypeStruct(F64[1], U32[1]), "frexp_result_f64"); + frexp_result_f64 = Name(TypeStruct(F64[1], S32[1]), "frexp_result_f64"); } } diff --git a/src/shader_recompiler/frontend/control_flow_graph.cpp b/src/shader_recompiler/frontend/control_flow_graph.cpp index 126cb4eb6..b53db9e94 100644 --- a/src/shader_recompiler/frontend/control_flow_graph.cpp +++ b/src/shader_recompiler/frontend/control_flow_graph.cpp @@ -2,7 +2,9 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include +#include #include "common/assert.h" +#include "common/logging/log.h" #include "shader_recompiler/frontend/control_flow_graph.h" namespace Shader::Gcn { @@ -39,9 +41,6 @@ static IR::Condition MakeCondition(const GcnInst& inst) { return IR::Condition::Execz; case Opcode::S_CBRANCH_EXECNZ: return IR::Condition::Execnz; - case Opcode::S_AND_SAVEEXEC_B64: - case Opcode::S_ANDN2_B64: - return IR::Condition::Execnz; default: return IR::Condition::True; } @@ -69,6 +68,39 @@ static bool IgnoresExecMask(const GcnInst& inst) { return false; } +static std::optional ResolveSetPcTarget(std::span list, u32 setpc_index, + std::span pc_map) { + if (setpc_index < 3) { + return std::nullopt; + } + + const auto& getpc = list[setpc_index - 3]; + const auto& arith = list[setpc_index - 2]; + const auto& setpc = list[setpc_index]; + + if (getpc.opcode != Opcode::S_GETPC_B64 || + !(arith.opcode == Opcode::S_ADD_U32 || arith.opcode == Opcode::S_SUB_U32) || + setpc.opcode != Opcode::S_SETPC_B64) + return std::nullopt; + + if (getpc.dst[0].code != setpc.src[0].code || arith.dst[0].code != setpc.src[0].code) + return std::nullopt; + + if (arith.src_count < 2 || arith.src[1].field != OperandField::LiteralConst) + return std::nullopt; + + const u32 imm = arith.src[1].code; + + const s32 signed_offset = + (arith.opcode == Opcode::S_ADD_U32) ? static_cast(imm) : -static_cast(imm); + + const u32 base_pc = pc_map[setpc_index - 3] + getpc.length; + + const u32 result_pc = static_cast(static_cast(base_pc) + signed_offset); + LOG_DEBUG(Render_Recompiler, "SetPC target: {} + {} = {}", base_pc, signed_offset, result_pc); + return result_pc & ~0x3u; +} + static constexpr size_t LabelReserveSize = 32; CFG::CFG(Common::ObjectPool& block_pool_, std::span inst_list_) @@ -76,9 +108,9 @@ CFG::CFG(Common::ObjectPool& block_pool_, std::span inst_l index_to_pc.resize(inst_list.size() + 1); labels.reserve(LabelReserveSize); EmitLabels(); - EmitDivergenceLabels(); EmitBlocks(); LinkBlocks(); + SplitDivergenceScopes(); } void CFG::EmitLabels() { @@ -91,9 +123,20 @@ void CFG::EmitLabels() { index_to_pc[i] = pc; const GcnInst inst = inst_list[i]; if (inst.IsUnconditionalBranch()) { - const u32 target = inst.BranchTarget(pc); + u32 target = inst.BranchTarget(pc); + if (inst.opcode == Opcode::S_SETPC_B64) { + if (auto t = ResolveSetPcTarget(inst_list, i, index_to_pc)) { + target = *t; + } else { + ASSERT_MSG( + false, + "S_SETPC_B64 without a resolvable offset at PC {:#x} (Index {}): Involved " + "instructions not recognized or invalid pattern", + pc, i); + } + } AddLabel(target); - // Emit this label so that the block ends with s_branch instruction + // Emit this label so that the block ends with the branching instruction AddLabel(pc + inst.length); } else if (inst.IsConditionalBranch()) { const u32 true_label = inst.BranchTarget(pc); @@ -104,6 +147,7 @@ void CFG::EmitLabels() { const u32 next_label = pc + inst.length; AddLabel(next_label); } + pc += inst.length; } index_to_pc[inst_list.size()] = pc; @@ -112,7 +156,7 @@ void CFG::EmitLabels() { std::ranges::sort(labels); } -void CFG::EmitDivergenceLabels() { +void CFG::SplitDivergenceScopes() { const auto is_open_scope = [](const GcnInst& inst) { // An open scope instruction is an instruction that modifies EXEC // but also saves the previous value to restore later. This indicates @@ -136,64 +180,97 @@ void CFG::EmitDivergenceLabels() { (inst.opcode == Opcode::S_ANDN2_B64 && inst.dst[0].field == OperandField::ExecLo); }; - // Since we will be adding new labels, avoid iterating those as well. - const size_t end_size = labels.size(); - for (u32 l = 0; l < end_size; l++) { - const Label start = labels[l]; - // Stop if we reached end of existing labels. - if (l == end_size - 1) { - break; - } - const Label end = labels[l + 1]; - const size_t end_index = GetIndex(end); - + for (auto blk = blocks.begin(); blk != blocks.end(); blk++) { + auto next_blk = std::next(blk); s32 curr_begin = -1; - s32 last_exec_idx = -1; - for (size_t index = GetIndex(start); index < end_index; index++) { + for (size_t index = blk->begin_index; index <= blk->end_index; index++) { const auto& inst = inst_list[index]; - if (curr_begin != -1) { - // Keep note of the last instruction that does not ignore exec, so we know where - // to end the divergence block without impacting trailing instructions that do. - if (!IgnoresExecMask(inst)) { - last_exec_idx = index; - } - // Consider a close scope on certain instruction types or at the last instruction - // before the next label. - if (is_close_scope(inst) || index == end_index - 1) { - // Only insert a scope if, since the open-scope instruction, there is at least - // one instruction that does not ignore exec. - if (index - curr_begin > 1 && last_exec_idx != -1) { - // Add a label to the instruction right after the open scope call. - // It is the start of a new basic block. - const auto& save_inst = inst_list[curr_begin]; - AddLabel(index_to_pc[curr_begin] + save_inst.length); - // Add a label to the close scope instruction. - // There are 3 cases where we need to close a scope. - // * Close scope instruction inside the block - // * Close scope instruction at the end of the block (cbranch or endpgm) - // * Normal instruction at the end of the block - // If the instruction we want to close the scope at is at the end of the - // block, we do not need to insert a new label. - if (last_exec_idx != end_index - 1) { - // Add the label after the last instruction affected by exec. - const auto& last_exec_inst = inst_list[last_exec_idx]; - AddLabel(index_to_pc[last_exec_idx] + last_exec_inst.length); - } - } - // Reset scope begin. + const bool is_close = is_close_scope(inst); + if ((is_close || index == blk->end_index) && curr_begin != -1) { + // If there are no instructions inside scope don't do anything. + if (index - curr_begin == 1) { curr_begin = -1; + continue; } + // If all instructions in the scope ignore exec masking, we shouldn't insert a + // scope. + const auto start = inst_list.begin() + curr_begin + 1; + if (!std::ranges::all_of(start, inst_list.begin() + index, IgnoresExecMask)) { + // Determine the first instruction affected by the exec mask. + do { + ++curr_begin; + } while (IgnoresExecMask(inst_list[curr_begin])); + + // Determine the last instruction affected by the exec mask. + s32 curr_end = index; + while (IgnoresExecMask(inst_list[curr_end])) { + --curr_end; + } + + // Create a new block for the divergence scope. + Block* block = block_pool.Create(); + block->begin = index_to_pc[curr_begin]; + block->end = index_to_pc[curr_end]; + block->begin_index = curr_begin; + block->end_index = curr_end; + block->end_inst = inst_list[curr_end]; + blocks.insert_before(next_blk, *block); + + // If we are inside the parent block, make an epilogue block and jump to it. + if (curr_end != blk->end_index) { + Block* epi_block = block_pool.Create(); + epi_block->begin = index_to_pc[curr_end + 1]; + epi_block->end = blk->end; + epi_block->begin_index = curr_end + 1; + epi_block->end_index = blk->end_index; + epi_block->end_inst = blk->end_inst; + epi_block->cond = blk->cond; + epi_block->end_class = blk->end_class; + epi_block->branch_true = blk->branch_true; + epi_block->branch_false = blk->branch_false; + blocks.insert_before(next_blk, *epi_block); + + // Have divergence block always jump to epilogue block. + block->cond = IR::Condition::True; + block->branch_true = epi_block; + block->branch_false = nullptr; + + // If the parent block fails to enter divergence block make it jump to + // epilogue too + blk->branch_false = epi_block; + } else { + // No epilogue block is needed since the divergence block + // also ends the parent block. Inherit the end condition. + auto& parent_blk = *blk; + ASSERT(blk->cond == IR::Condition::True && blk->branch_true); + block->cond = IR::Condition::True; + block->branch_true = blk->branch_true; + block->branch_false = nullptr; + + // If the parent block didn't enter the divergence scope + // have it jump directly to the next one + blk->branch_false = blk->branch_true; + } + + // Shrink parent block to end right before curr_begin + // and make it jump to divergence block + --curr_begin; + blk->end = index_to_pc[curr_begin]; + blk->end_index = curr_begin; + blk->end_inst = inst_list[curr_begin]; + blk->cond = IR::Condition::Execnz; + blk->end_class = EndClass::Branch; + blk->branch_true = block; + } + // Reset scope begin. + curr_begin = -1; } // Mark a potential start of an exec scope. if (is_open_scope(inst)) { curr_begin = index; - last_exec_idx = -1; } } } - - // Sort labels to make sure block insertion is correct. - std::ranges::sort(labels); } void CFG::EmitBlocks() { @@ -234,22 +311,6 @@ void CFG::LinkBlocks() { for (auto it = blocks.begin(); it != blocks.end(); it++) { auto& block = *it; const auto end_inst{block.end_inst}; - // Handle divergence block inserted here. - if (end_inst.opcode == Opcode::S_AND_SAVEEXEC_B64 || - end_inst.opcode == Opcode::S_ANDN2_B64 || end_inst.IsCmpx()) { - // Blocks are stored ordered by address in the set - auto next_it = std::next(it); - auto* target_block = &(*next_it); - ++target_block->num_predecessors; - block.branch_true = target_block; - - auto merge_it = std::next(next_it); - auto* merge_block = &(*merge_it); - ++merge_block->num_predecessors; - block.branch_false = merge_block; - block.end_class = EndClass::Branch; - continue; - } // If the block doesn't end with a branch we simply // need to link with the next block. @@ -265,7 +326,18 @@ void CFG::LinkBlocks() { // Find the branch targets from the instruction and link the blocks. // Note: Block end address is one instruction after end_inst. const u32 branch_pc = block.end - end_inst.length; - const u32 target_pc = end_inst.BranchTarget(branch_pc); + u32 target_pc = 0; + if (end_inst.opcode == Opcode::S_SETPC_B64) { + auto tgt = ResolveSetPcTarget(inst_list, block.end_index, index_to_pc); + ASSERT_MSG(tgt, + "S_SETPC_B64 without a resolvable offset at PC {:#x} (Index {}): Involved " + "instructions not recognized or invalid pattern", + branch_pc, block.end_index); + target_pc = *tgt; + } else { + target_pc = end_inst.BranchTarget(branch_pc); + } + if (end_inst.IsUnconditionalBranch()) { auto* target_block = get_block(target_pc); ++target_block->num_predecessors; diff --git a/src/shader_recompiler/frontend/control_flow_graph.h b/src/shader_recompiler/frontend/control_flow_graph.h index d98d4b05d..0acce3306 100644 --- a/src/shader_recompiler/frontend/control_flow_graph.h +++ b/src/shader_recompiler/frontend/control_flow_graph.h @@ -57,9 +57,9 @@ public: private: void EmitLabels(); - void EmitDivergenceLabels(); void EmitBlocks(); void LinkBlocks(); + void SplitDivergenceScopes(); void AddLabel(Label address) { const auto it = std::ranges::find(labels, address); diff --git a/src/shader_recompiler/frontend/format.cpp b/src/shader_recompiler/frontend/format.cpp index 76b1cc818..52c8c733e 100644 --- a/src/shader_recompiler/frontend/format.cpp +++ b/src/shader_recompiler/frontend/format.cpp @@ -2784,8 +2784,7 @@ constexpr std::array InstructionFormatDS = {{ // 62 = DS_APPEND {InstClass::DsAppendCon, InstCategory::DataShare, 3, 1, ScalarType::Uint32, ScalarType::Uint32}, // 63 = DS_ORDERED_COUNT - {InstClass::GdsOrdCnt, InstCategory::DataShare, 3, 1, ScalarType::Undefined, - ScalarType::Undefined}, + {InstClass::GdsOrdCnt, InstCategory::DataShare, 3, 1, ScalarType::Uint32, ScalarType::Uint32}, // 64 = DS_ADD_U64 {InstClass::DsAtomicArith64, InstCategory::DataShare, 3, 1, ScalarType::Uint64, ScalarType::Uint64}, @@ -3570,19 +3569,19 @@ constexpr std::array InstructionFormatMIMG = {{ {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Uint32, ScalarType::Float32}, // 65 = IMAGE_GATHER4_CL - {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Undefined, - ScalarType::Undefined}, + {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Uint32, + ScalarType::Float32}, {}, {}, // 68 = IMAGE_GATHER4_L - {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Undefined, - ScalarType::Undefined}, + {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Uint32, + ScalarType::Float32}, // 69 = IMAGE_GATHER4_B - {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Undefined, - ScalarType::Undefined}, + {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Uint32, + ScalarType::Float32}, // 70 = IMAGE_GATHER4_B_CL - {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Undefined, - ScalarType::Undefined}, + {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Uint32, + ScalarType::Float32}, // 71 = IMAGE_GATHER4_LZ {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Uint32, ScalarType::Float32}, @@ -3590,19 +3589,19 @@ constexpr std::array InstructionFormatMIMG = {{ {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Uint32, ScalarType::Float32}, // 73 = IMAGE_GATHER4_C_CL - {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Undefined, - ScalarType::Undefined}, + {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Uint32, + ScalarType::Float32}, {}, {}, // 76 = IMAGE_GATHER4_C_L - {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Undefined, - ScalarType::Undefined}, + {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Uint32, + ScalarType::Float32}, // 77 = IMAGE_GATHER4_C_B - {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Undefined, - ScalarType::Undefined}, + {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Uint32, + ScalarType::Float32}, // 78 = IMAGE_GATHER4_C_B_CL - {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Undefined, - ScalarType::Undefined}, + {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Uint32, + ScalarType::Float32}, // 79 = IMAGE_GATHER4_C_LZ {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Uint32, ScalarType::Float32}, @@ -3610,19 +3609,19 @@ constexpr std::array InstructionFormatMIMG = {{ {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Uint32, ScalarType::Float32}, // 81 = IMAGE_GATHER4_CL_O - {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Undefined, - ScalarType::Undefined}, + {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Uint32, + ScalarType::Float32}, {}, {}, // 84 = IMAGE_GATHER4_L_O - {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Undefined, - ScalarType::Undefined}, + {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Uint32, + ScalarType::Float32}, // 85 = IMAGE_GATHER4_B_O - {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Undefined, - ScalarType::Undefined}, + {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Uint32, + ScalarType::Float32}, // 86 = IMAGE_GATHER4_B_CL_O - {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Undefined, - ScalarType::Undefined}, + {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Uint32, + ScalarType::Float32}, // 87 = IMAGE_GATHER4_LZ_O {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Uint32, ScalarType::Float32}, @@ -3630,19 +3629,19 @@ constexpr std::array InstructionFormatMIMG = {{ {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Uint32, ScalarType::Float32}, // 89 = IMAGE_GATHER4_C_CL_O - {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Undefined, - ScalarType::Undefined}, + {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Uint32, + ScalarType::Float32}, {}, {}, // 92 = IMAGE_GATHER4_C_L_O - {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Undefined, - ScalarType::Undefined}, + {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Uint32, + ScalarType::Float32}, // 93 = IMAGE_GATHER4_C_B_O - {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Undefined, - ScalarType::Undefined}, + {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Uint32, + ScalarType::Float32}, // 94 = IMAGE_GATHER4_C_B_CL_O - {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Undefined, - ScalarType::Undefined}, + {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Uint32, + ScalarType::Float32}, // 95 = IMAGE_GATHER4_C_LZ_O {InstClass::VectorMemImgSmp, InstCategory::VectorMemory, 4, 1, ScalarType::Uint32, ScalarType::Float32}, diff --git a/src/shader_recompiler/frontend/instruction.cpp b/src/shader_recompiler/frontend/instruction.cpp index a0c132053..246c2b85a 100644 --- a/src/shader_recompiler/frontend/instruction.cpp +++ b/src/shader_recompiler/frontend/instruction.cpp @@ -18,7 +18,7 @@ bool GcnInst::IsTerminateInstruction() const { } bool GcnInst::IsUnconditionalBranch() const { - return opcode == Opcode::S_BRANCH; + return opcode == Opcode::S_BRANCH || opcode == Opcode::S_SETPC_B64; } bool GcnInst::IsFork() const { diff --git a/src/shader_recompiler/frontend/translate/data_share.cpp b/src/shader_recompiler/frontend/translate/data_share.cpp index 460f8913c..c29497ada 100644 --- a/src/shader_recompiler/frontend/translate/data_share.cpp +++ b/src/shader_recompiler/frontend/translate/data_share.cpp @@ -13,6 +13,12 @@ void Translator::EmitDataShare(const GcnInst& inst) { // DS case Opcode::DS_ADD_U32: return DS_ADD_U32(inst, false); + case Opcode::DS_SUB_U32: + return DS_SUB_U32(inst, false); + case Opcode::DS_INC_U32: + return DS_INC_U32(inst, false); + case Opcode::DS_DEC_U32: + return DS_DEC_U32(inst, false); case Opcode::DS_MIN_I32: return DS_MIN_U32(inst, true, false); case Opcode::DS_MAX_I32: @@ -35,6 +41,8 @@ void Translator::EmitDataShare(const GcnInst& inst) { return DS_WRITE(32, false, true, true, inst); case Opcode::DS_ADD_RTN_U32: return DS_ADD_U32(inst, true); + case Opcode::DS_SUB_RTN_U32: + return DS_SUB_U32(inst, true); case Opcode::DS_MIN_RTN_U32: return DS_MIN_U32(inst, false, true); case Opcode::DS_MAX_RTN_U32: @@ -61,10 +69,14 @@ void Translator::EmitDataShare(const GcnInst& inst) { return DS_WRITE(64, false, false, false, inst); case Opcode::DS_WRITE2_B64: return DS_WRITE(64, false, true, false, inst); + case Opcode::DS_WRITE2ST64_B64: + return DS_WRITE(64, false, true, true, inst); case Opcode::DS_READ_B64: return DS_READ(64, false, false, false, inst); case Opcode::DS_READ2_B64: return DS_READ(64, false, true, false, inst); + case Opcode::DS_READ2ST64_B64: + return DS_READ(64, false, true, true, inst); default: LogMissingOpcode(inst); } @@ -224,6 +236,40 @@ void Translator::DS_SWIZZLE_B32(const GcnInst& inst) { SetDst(inst.dst[0], ir.QuadShuffle(src, index)); } +void Translator::DS_INC_U32(const GcnInst& inst, bool rtn) { + const IR::U32 addr{GetSrc(inst.src[0])}; + const IR::U32 offset = + ir.Imm32((u32(inst.control.ds.offset1) << 8u) + u32(inst.control.ds.offset0)); + const IR::U32 addr_offset = ir.IAdd(addr, offset); + const IR::Value original_val = ir.SharedAtomicIIncrement(addr_offset); + if (rtn) { + SetDst(inst.dst[0], IR::U32{original_val}); + } +} + +void Translator::DS_DEC_U32(const GcnInst& inst, bool rtn) { + const IR::U32 addr{GetSrc(inst.src[0])}; + const IR::U32 offset = + ir.Imm32((u32(inst.control.ds.offset1) << 8u) + u32(inst.control.ds.offset0)); + const IR::U32 addr_offset = ir.IAdd(addr, offset); + const IR::Value original_val = ir.SharedAtomicIDecrement(addr_offset); + if (rtn) { + SetDst(inst.dst[0], IR::U32{original_val}); + } +} + +void Translator::DS_SUB_U32(const GcnInst& inst, bool rtn) { + const IR::U32 addr{GetSrc(inst.src[0])}; + const IR::U32 data{GetSrc(inst.src[1])}; + const IR::U32 offset = + ir.Imm32((u32(inst.control.ds.offset1) << 8u) + u32(inst.control.ds.offset0)); + const IR::U32 addr_offset = ir.IAdd(addr, offset); + const IR::Value original_val = ir.SharedAtomicISub(addr_offset, data); + if (rtn) { + SetDst(inst.dst[0], IR::U32{original_val}); + } +} + void Translator::DS_READ(int bit_size, bool is_signed, bool is_pair, bool stride64, const GcnInst& inst) { const IR::U32 addr{ir.GetVectorReg(IR::VectorReg(inst.src[0].code))}; diff --git a/src/shader_recompiler/frontend/translate/scalar_alu.cpp b/src/shader_recompiler/frontend/translate/scalar_alu.cpp index 39f972848..3a8e894ae 100644 --- a/src/shader_recompiler/frontend/translate/scalar_alu.cpp +++ b/src/shader_recompiler/frontend/translate/scalar_alu.cpp @@ -30,6 +30,8 @@ void Translator::EmitScalarAlu(const GcnInst& inst) { return S_SUB_I32(inst); case Opcode::S_ADDC_U32: return S_ADDC_U32(inst); + case Opcode::S_SUBB_U32: + return S_SUBB_U32(inst); case Opcode::S_MIN_I32: return S_MIN_U32(true, inst); case Opcode::S_MIN_U32: @@ -110,6 +112,8 @@ void Translator::EmitScalarAlu(const GcnInst& inst) { return S_FF1_I32_B32(inst); case Opcode::S_FF1_I32_B64: return S_FF1_I32_B64(inst); + case Opcode::S_FLBIT_I32_B32: + return S_FLBIT_I32_B32(inst); case Opcode::S_BITSET0_B32: return S_BITSET_B32(inst, 0); case Opcode::S_BITSET1_B32: @@ -236,6 +240,17 @@ void Translator::S_SUB_U32(const GcnInst& inst) { ir.SetScc(ir.IGreaterThan(src1, src0, false)); } +void Translator::S_SUBB_U32(const GcnInst& inst) { + const IR::U32 src0{GetSrc(inst.src[0])}; + const IR::U32 src1{GetSrc(inst.src[1])}; + const IR::U32 borrow{ir.Select(ir.GetScc(), ir.Imm32(1U), ir.Imm32(0U))}; + const IR::U32 result{ir.ISub(ir.ISub(src0, src1), borrow)}; + SetDst(inst.dst[0], result); + + const IR::U32 sum_with_borrow{ir.IAdd(src1, borrow)}; + ir.SetScc(ir.ILessThan(src0, sum_with_borrow, false)); +} + void Translator::S_ADD_I32(const GcnInst& inst) { const IR::U32 src0{GetSrc(inst.src[0])}; const IR::U32 src1{GetSrc(inst.src[1])}; @@ -660,6 +675,17 @@ void Translator::S_FF1_I32_B64(const GcnInst& inst) { SetDst(inst.dst[0], result); } +void Translator::S_FLBIT_I32_B32(const GcnInst& inst) { + const IR::U32 src0{GetSrc(inst.src[0])}; + // Gcn wants the MSB position counting from the left, but SPIR-V counts from the rightmost (LSB) + // position + const IR::U32 msb_pos = ir.FindUMsb(src0); + const IR::U32 pos_from_left = ir.ISub(ir.Imm32(31), msb_pos); + // Select 0xFFFFFFFF if src0 was 0 + const IR::U1 cond = ir.INotEqual(src0, ir.Imm32(0)); + SetDst(inst.dst[0], IR::U32{ir.Select(cond, pos_from_left, ir.Imm32(~0U))}); +} + void Translator::S_BITSET_B32(const GcnInst& inst, u32 bit_value) { const IR::U32 old_value{GetSrc(inst.dst[0])}; const IR::U32 offset{ir.BitFieldExtract(GetSrc(inst.src[0]), ir.Imm32(0U), ir.Imm32(5U))}; diff --git a/src/shader_recompiler/frontend/translate/scalar_flow.cpp b/src/shader_recompiler/frontend/translate/scalar_flow.cpp index ef8bab789..cd1cf51f0 100644 --- a/src/shader_recompiler/frontend/translate/scalar_flow.cpp +++ b/src/shader_recompiler/frontend/translate/scalar_flow.cpp @@ -13,8 +13,12 @@ void Translator::EmitFlowControl(u32 pc, const GcnInst& inst) { case Opcode::S_TTRACEDATA: LOG_WARNING(Render_Vulkan, "S_TTRACEDATA instruction!"); return; + case Opcode::S_SETPRIO: + LOG_WARNING(Render_Vulkan, "S_SETPRIO instruction!"); + return; case Opcode::S_GETPC_B64: return S_GETPC_B64(pc, inst); + case Opcode::S_SETPC_B64: case Opcode::S_WAITCNT: case Opcode::S_NOP: case Opcode::S_ENDPGM: diff --git a/src/shader_recompiler/frontend/translate/translate.cpp b/src/shader_recompiler/frontend/translate/translate.cpp index 230f3917f..c5a5814a4 100644 --- a/src/shader_recompiler/frontend/translate/translate.cpp +++ b/src/shader_recompiler/frontend/translate/translate.cpp @@ -336,7 +336,7 @@ T Translator::GetSrc64(const InstOperand& operand) { const auto value_lo = ir.GetVectorReg(IR::VectorReg(operand.code)); const auto value_hi = ir.GetVectorReg(IR::VectorReg(operand.code + 1)); if constexpr (is_float) { - value = ir.PackFloat2x32(ir.CompositeConstruct(value_lo, value_hi)); + value = ir.PackDouble2x32(ir.CompositeConstruct(value_lo, value_hi)); } else { value = ir.PackUint2x32(ir.CompositeConstruct(value_lo, value_hi)); } @@ -444,10 +444,9 @@ void Translator::SetDst64(const InstOperand& operand, const IR::U64F64& value_ra value_untyped = ir.FPSaturate(value_raw); } } - const IR::U64 value = - is_float ? ir.BitCast(IR::F64{value_untyped}) : IR::U64{value_untyped}; - const IR::Value unpacked{ir.UnpackUint2x32(value)}; + const IR::Value unpacked{is_float ? ir.UnpackDouble2x32(IR::F64{value_untyped}) + : ir.UnpackUint2x32(IR::U64{value_untyped})}; const IR::U32 lo{ir.CompositeExtract(unpacked, 0U)}; const IR::U32 hi{ir.CompositeExtract(unpacked, 1U)}; switch (operand.field) { diff --git a/src/shader_recompiler/frontend/translate/translate.h b/src/shader_recompiler/frontend/translate/translate.h index 2fd48a051..68d5e8dc8 100644 --- a/src/shader_recompiler/frontend/translate/translate.h +++ b/src/shader_recompiler/frontend/translate/translate.h @@ -80,6 +80,7 @@ public: // SOP2 void S_ADD_U32(const GcnInst& inst); void S_SUB_U32(const GcnInst& inst); + void S_SUBB_U32(const GcnInst& inst); void S_ADD_I32(const GcnInst& inst); void S_SUB_I32(const GcnInst& inst); void S_ADDC_U32(const GcnInst& inst); @@ -119,6 +120,7 @@ public: void S_BCNT1_I32_B64(const GcnInst& inst); void S_FF1_I32_B32(const GcnInst& inst); void S_FF1_I32_B64(const GcnInst& inst); + void S_FLBIT_I32_B32(const GcnInst& inst); void S_BITSET_B32(const GcnInst& inst, u32 bit_value); void S_GETPC_B64(u32 pc, const GcnInst& inst); void S_SAVEEXEC_B64(NegateMode negate, bool is_or, const GcnInst& inst); @@ -238,13 +240,11 @@ public: void V_FMA_F32(const GcnInst& inst); void V_FMA_F64(const GcnInst& inst); void V_MIN3_F32(const GcnInst& inst); - void V_MIN3_I32(const GcnInst& inst); - void V_MIN3_U32(const GcnInst& inst); + void V_MIN3_U32(bool is_signed, const GcnInst& inst); void V_MAX3_F32(const GcnInst& inst); void V_MAX3_U32(bool is_signed, const GcnInst& inst); void V_MED3_F32(const GcnInst& inst); - void V_MED3_I32(const GcnInst& inst); - void V_MED3_U32(const GcnInst& inst); + void V_MED3_U32(bool is_signed, const GcnInst& inst); void V_SAD(const GcnInst& inst); void V_SAD_U32(const GcnInst& inst); void V_CVT_PK_U16_U32(const GcnInst& inst); @@ -275,6 +275,9 @@ public: void DS_READ(int bit_size, bool is_signed, bool is_pair, bool stride64, const GcnInst& inst); void DS_APPEND(const GcnInst& inst); void DS_CONSUME(const GcnInst& inst); + void DS_SUB_U32(const GcnInst& inst, bool rtn); + void DS_INC_U32(const GcnInst& inst, bool rtn); + void DS_DEC_U32(const GcnInst& inst, bool rtn); // Buffer Memory // MUBUF / MTBUF diff --git a/src/shader_recompiler/frontend/translate/vector_alu.cpp b/src/shader_recompiler/frontend/translate/vector_alu.cpp index 56e903052..3ce86c131 100644 --- a/src/shader_recompiler/frontend/translate/vector_alu.cpp +++ b/src/shader_recompiler/frontend/translate/vector_alu.cpp @@ -359,9 +359,9 @@ void Translator::EmitVectorAlu(const GcnInst& inst) { case Opcode::V_MIN3_F32: return V_MIN3_F32(inst); case Opcode::V_MIN3_I32: - return V_MIN3_I32(inst); + return V_MIN3_U32(true, inst); case Opcode::V_MIN3_U32: - return V_MIN3_U32(inst); + return V_MIN3_U32(false, inst); case Opcode::V_MAX3_F32: return V_MAX3_F32(inst); case Opcode::V_MAX3_I32: @@ -371,9 +371,9 @@ void Translator::EmitVectorAlu(const GcnInst& inst) { case Opcode::V_MED3_F32: return V_MED3_F32(inst); case Opcode::V_MED3_I32: - return V_MED3_I32(inst); + return V_MED3_U32(true, inst); case Opcode::V_MED3_U32: - return V_MED3_U32(inst); + return V_MED3_U32(false, inst); case Opcode::V_SAD_U32: return V_SAD_U32(inst); case Opcode::V_CVT_PK_U16_U32: @@ -394,6 +394,8 @@ void Translator::EmitVectorAlu(const GcnInst& inst) { return V_MUL_HI_U32(false, inst); case Opcode::V_MUL_LO_I32: return V_MUL_LO_U32(inst); + case Opcode::V_MUL_HI_I32: + return V_MUL_HI_U32(true, inst); case Opcode::V_MAD_U64_U32: return V_MAD_U64_U32(inst); case Opcode::V_NOP: @@ -511,13 +513,13 @@ void Translator::V_LSHLREV_B32(const GcnInst& inst) { void Translator::V_AND_B32(const GcnInst& inst) { const IR::U32 src0{GetSrc(inst.src[0])}; - const IR::U32 src1{ir.GetVectorReg(IR::VectorReg(inst.src[1].code))}; + const IR::U32 src1{GetSrc(inst.src[1])}; SetDst(inst.dst[0], ir.BitwiseAnd(src0, src1)); } void Translator::V_OR_B32(bool is_xor, const GcnInst& inst) { const IR::U32 src0{GetSrc(inst.src[0])}; - const IR::U32 src1{ir.GetVectorReg(IR::VectorReg(inst.src[1].code))}; + const IR::U32 src1{GetSrc(inst.src[1])}; SetDst(inst.dst[0], is_xor ? ir.BitwiseXor(src0, src1) : IR::U32(ir.BitwiseOr(src0, src1))); } @@ -577,7 +579,7 @@ void Translator::V_MBCNT_U32_B32(bool is_low, const GcnInst& inst) { void Translator::V_ADD_I32(const GcnInst& inst) { // Signed or unsigned components const IR::U32 src0{GetSrc(inst.src[0])}; - const IR::U32 src1{ir.GetVectorReg(IR::VectorReg(inst.src[1].code))}; + const IR::U32 src1{GetSrc(inst.src[1])}; const IR::U32 result{ir.IAdd(src0, src1)}; SetDst(inst.dst[0], result); @@ -1010,8 +1012,10 @@ void Translator::V_CMP_CLASS_F32(const GcnInst& inst) { value = ir.FPIsNan(src0); } else if ((class_mask & IR::FloatClassFunc::Infinity) == IR::FloatClassFunc::Infinity) { value = ir.FPIsInf(src0); + } else if ((class_mask & IR::FloatClassFunc::Negative) == IR::FloatClassFunc::Negative) { + value = ir.FPLessThanEqual(src0, ir.Imm32(-0.f)); } else { - UNREACHABLE(); + UNREACHABLE_MSG("Unsupported float class mask: {:#x}", static_cast(class_mask)); } } else { // We don't know the type yet, delay its resolution. @@ -1166,59 +1170,42 @@ void Translator::V_MIN3_F32(const GcnInst& inst) { const IR::F32 src0{GetSrc(inst.src[0])}; const IR::F32 src1{GetSrc(inst.src[1])}; const IR::F32 src2{GetSrc(inst.src[2])}; - SetDst(inst.dst[0], ir.FPMin(src0, ir.FPMin(src1, src2))); + SetDst(inst.dst[0], ir.FPMinTri(src0, src1, src2)); } -void Translator::V_MIN3_I32(const GcnInst& inst) { +void Translator::V_MIN3_U32(bool is_signed, const GcnInst& inst) { const IR::U32 src0{GetSrc(inst.src[0])}; const IR::U32 src1{GetSrc(inst.src[1])}; const IR::U32 src2{GetSrc(inst.src[2])}; - SetDst(inst.dst[0], ir.SMin(src0, ir.SMin(src1, src2))); -} - -void Translator::V_MIN3_U32(const GcnInst& inst) { - const IR::U32 src0{GetSrc(inst.src[0])}; - const IR::U32 src1{GetSrc(inst.src[1])}; - const IR::U32 src2{GetSrc(inst.src[2])}; - SetDst(inst.dst[0], ir.UMin(src0, ir.UMin(src1, src2))); + SetDst(inst.dst[0], ir.IMinTri(src0, src1, src2, is_signed)); } void Translator::V_MAX3_F32(const GcnInst& inst) { const IR::F32 src0{GetSrc(inst.src[0])}; const IR::F32 src1{GetSrc(inst.src[1])}; const IR::F32 src2{GetSrc(inst.src[2])}; - SetDst(inst.dst[0], ir.FPMax(src0, ir.FPMax(src1, src2))); + SetDst(inst.dst[0], ir.FPMaxTri(src0, src1, src2)); } void Translator::V_MAX3_U32(bool is_signed, const GcnInst& inst) { const IR::U32 src0{GetSrc(inst.src[0])}; const IR::U32 src1{GetSrc(inst.src[1])}; const IR::U32 src2{GetSrc(inst.src[2])}; - SetDst(inst.dst[0], ir.IMax(src0, ir.IMax(src1, src2, is_signed), is_signed)); + SetDst(inst.dst[0], ir.IMaxTri(src0, src1, src2, is_signed)); } void Translator::V_MED3_F32(const GcnInst& inst) { const IR::F32 src0{GetSrc(inst.src[0])}; const IR::F32 src1{GetSrc(inst.src[1])}; const IR::F32 src2{GetSrc(inst.src[2])}; - const IR::F32 mmx = ir.FPMin(ir.FPMax(src0, src1), src2); - SetDst(inst.dst[0], ir.FPMax(ir.FPMin(src0, src1), mmx)); + SetDst(inst.dst[0], ir.FPMedTri(src0, src1, src2)); } -void Translator::V_MED3_I32(const GcnInst& inst) { +void Translator::V_MED3_U32(bool is_signed, const GcnInst& inst) { const IR::U32 src0{GetSrc(inst.src[0])}; const IR::U32 src1{GetSrc(inst.src[1])}; const IR::U32 src2{GetSrc(inst.src[2])}; - const IR::U32 mmx = ir.SMin(ir.SMax(src0, src1), src2); - SetDst(inst.dst[0], ir.SMax(ir.SMin(src0, src1), mmx)); -} - -void Translator::V_MED3_U32(const GcnInst& inst) { - const IR::U32 src0{GetSrc(inst.src[0])}; - const IR::U32 src1{GetSrc(inst.src[1])}; - const IR::U32 src2{GetSrc(inst.src[2])}; - const IR::U32 mmx = ir.UMin(ir.UMax(src0, src1), src2); - SetDst(inst.dst[0], ir.UMax(ir.UMin(src0, src1), mmx)); + SetDst(inst.dst[0], ir.IMedTri(src0, src1, src2, is_signed)); } void Translator::V_SAD(const GcnInst& inst) { @@ -1294,7 +1281,7 @@ void Translator::V_MUL_LO_U32(const GcnInst& inst) { void Translator::V_MUL_HI_U32(bool is_signed, const GcnInst& inst) { const IR::U32 src0{GetSrc(inst.src[0])}; const IR::U32 src1{GetSrc(inst.src[1])}; - const IR::U32 hi{ir.CompositeExtract(ir.IMulExt(src0, src1, is_signed), 1)}; + const IR::U32 hi{ir.IMulHi(src0, src1, is_signed)}; SetDst(inst.dst[0], hi); } diff --git a/src/shader_recompiler/ir/ir_emitter.cpp b/src/shader_recompiler/ir/ir_emitter.cpp index 3615e8cbb..e1ebf2206 100644 --- a/src/shader_recompiler/ir/ir_emitter.cpp +++ b/src/shader_recompiler/ir/ir_emitter.cpp @@ -84,16 +84,6 @@ IR::F16 IREmitter::BitCast(const IR::U16& value) { return Inst(Opcode::BitCastF16U16, value); } -template <> -IR::U64 IREmitter::BitCast(const IR::F64& value) { - return Inst(Opcode::BitCastU64F64, value); -} - -template <> -IR::F64 IREmitter::BitCast(const IR::U64& value) { - return Inst(Opcode::BitCastF64U64, value); -} - U1 IREmitter::ConditionRef(const U1& value) { return Inst(Opcode::ConditionRef, value); } @@ -357,6 +347,18 @@ U32 IREmitter::SharedAtomicXor(const U32& address, const U32& data) { return Inst(Opcode::SharedAtomicXor32, address, data); } +U32 IREmitter::SharedAtomicIIncrement(const U32& address) { + return Inst(Opcode::SharedAtomicIIncrement32, address); +} + +U32 IREmitter::SharedAtomicIDecrement(const U32& address) { + return Inst(Opcode::SharedAtomicIDecrement32, address); +} + +U32 IREmitter::SharedAtomicISub(const U32& address, const U32& data) { + return Inst(Opcode::SharedAtomicISub32, address, data); +} + U32 IREmitter::ReadConst(const Value& base, const U32& offset) { return Inst(Opcode::ReadConst, base, offset); } @@ -829,8 +831,12 @@ Value IREmitter::UnpackUint2x32(const U64& value) { return Inst(Opcode::UnpackUint2x32, value); } -F64 IREmitter::PackFloat2x32(const Value& vector) { - return Inst(Opcode::PackFloat2x32, vector); +F64 IREmitter::PackDouble2x32(const Value& vector) { + return Inst(Opcode::PackDouble2x32, vector); +} + +Value IREmitter::UnpackDouble2x32(const F64& value) { + return Inst(Opcode::UnpackDouble2x32, value); } U32 IREmitter::Pack2x16(const AmdGpu::NumberFormat number_format, const Value& vector) { @@ -1336,6 +1342,18 @@ F32F64 IREmitter::FPMin(const F32F64& lhs, const F32F64& rhs, bool is_legacy) { } } +F32F64 IREmitter::FPMinTri(const F32F64& a, const F32F64& b, const F32F64& c) { + return Inst(Opcode::FPMinTri32, a, b, c); +} + +F32F64 IREmitter::FPMaxTri(const F32F64& a, const F32F64& b, const F32F64& c) { + return Inst(Opcode::FPMaxTri32, a, b, c); +} + +F32F64 IREmitter::FPMedTri(const F32F64& a, const F32F64& b, const F32F64& c) { + return Inst(Opcode::FPMedTri32, a, b, c); +} + U32U64 IREmitter::IAdd(const U32U64& a, const U32U64& b) { if (a.Type() != b.Type()) { UNREACHABLE_MSG("Mismatching types {} and {}", a.Type(), b.Type()); @@ -1376,8 +1394,8 @@ U32U64 IREmitter::ISub(const U32U64& a, const U32U64& b) { } } -IR::Value IREmitter::IMulExt(const U32& a, const U32& b, bool is_signed) { - return Inst(is_signed ? Opcode::SMulExt : Opcode::UMulExt, a, b); +U32 IREmitter::IMulHi(const U32& a, const U32& b, bool is_signed) { + return Inst(is_signed ? Opcode::SMulHi : Opcode::UMulHi, a, b); } U32U64 IREmitter::IMul(const U32U64& a, const U32U64& b) { @@ -1567,6 +1585,42 @@ U32 IREmitter::IMax(const U32& a, const U32& b, bool is_signed) { return is_signed ? SMax(a, b) : UMax(a, b); } +U32 IREmitter::SMinTri(const U32& a, const U32& b, const U32& c) { + return Inst(Opcode::SMinTri32, a, b, c); +} + +U32 IREmitter::UMinTri(const U32& a, const U32& b, const U32& c) { + return Inst(Opcode::UMinTri32, a, b, c); +} + +U32 IREmitter::IMinTri(const U32& a, const U32& b, const U32& c, bool is_signed) { + return is_signed ? SMinTri(a, b, c) : UMinTri(a, b, c); +} + +U32 IREmitter::SMaxTri(const U32& a, const U32& b, const U32& c) { + return Inst(Opcode::SMaxTri32, a, b, c); +} + +U32 IREmitter::UMaxTri(const U32& a, const U32& b, const U32& c) { + return Inst(Opcode::UMaxTri32, a, b, c); +} + +U32 IREmitter::IMaxTri(const U32& a, const U32& b, const U32& c, bool is_signed) { + return is_signed ? SMaxTri(a, b, c) : UMaxTri(a, b, c); +} + +U32 IREmitter::SMedTri(const U32& a, const U32& b, const U32& c) { + return Inst(Opcode::SMedTri32, a, b, c); +} + +U32 IREmitter::UMedTri(const U32& a, const U32& b, const U32& c) { + return Inst(Opcode::UMedTri32, a, b, c); +} + +U32 IREmitter::IMedTri(const U32& a, const U32& b, const U32& c, bool is_signed) { + return is_signed ? SMedTri(a, b, c) : UMedTri(a, b, c); +} + U32 IREmitter::SClamp(const U32& value, const U32& min, const U32& max) { return Inst(Opcode::SClamp32, value, min, max); } diff --git a/src/shader_recompiler/ir/ir_emitter.h b/src/shader_recompiler/ir/ir_emitter.h index 7ac75bf70..d978b3b4f 100644 --- a/src/shader_recompiler/ir/ir_emitter.h +++ b/src/shader_recompiler/ir/ir_emitter.h @@ -106,6 +106,10 @@ public: [[nodiscard]] U32 SharedAtomicOr(const U32& address, const U32& data); [[nodiscard]] U32 SharedAtomicXor(const U32& address, const U32& data); + [[nodiscard]] U32 SharedAtomicIIncrement(const U32& address); + [[nodiscard]] U32 SharedAtomicIDecrement(const U32& address); + [[nodiscard]] U32 SharedAtomicISub(const U32& address, const U32& data); + [[nodiscard]] U32 ReadConst(const Value& base, const U32& offset); [[nodiscard]] U32 ReadConstBuffer(const Value& handle, const U32& index); @@ -177,7 +181,8 @@ public: [[nodiscard]] U64 PackUint2x32(const Value& vector); [[nodiscard]] Value UnpackUint2x32(const U64& value); - [[nodiscard]] F64 PackFloat2x32(const Value& vector); + [[nodiscard]] F64 PackDouble2x32(const Value& vector); + [[nodiscard]] Value UnpackDouble2x32(const F64& value); [[nodiscard]] U32 Pack2x16(AmdGpu::NumberFormat number_format, const Value& vector); [[nodiscard]] Value Unpack2x16(AmdGpu::NumberFormat number_format, const U32& value); @@ -233,11 +238,14 @@ public: [[nodiscard]] U1 FPUnordered(const F32F64& lhs, const F32F64& rhs); [[nodiscard]] F32F64 FPMax(const F32F64& lhs, const F32F64& rhs, bool is_legacy = false); [[nodiscard]] F32F64 FPMin(const F32F64& lhs, const F32F64& rhs, bool is_legacy = false); + [[nodiscard]] F32F64 FPMinTri(const F32F64& a, const F32F64& b, const F32F64& c); + [[nodiscard]] F32F64 FPMaxTri(const F32F64& a, const F32F64& b, const F32F64& c); + [[nodiscard]] F32F64 FPMedTri(const F32F64& a, const F32F64& b, const F32F64& c); [[nodiscard]] U32U64 IAdd(const U32U64& a, const U32U64& b); [[nodiscard]] Value IAddCary(const U32& a, const U32& b); [[nodiscard]] U32U64 ISub(const U32U64& a, const U32U64& b); - [[nodiscard]] Value IMulExt(const U32& a, const U32& b, bool is_signed = false); + [[nodiscard]] U32 IMulHi(const U32& a, const U32& b, bool is_signed = false); [[nodiscard]] U32U64 IMul(const U32U64& a, const U32U64& b); [[nodiscard]] U32 IDiv(const U32& a, const U32& b, bool is_signed = false); [[nodiscard]] U32 IMod(const U32& a, const U32& b, bool is_signed = false); @@ -266,6 +274,15 @@ public: [[nodiscard]] U32 SMax(const U32& a, const U32& b); [[nodiscard]] U32 UMax(const U32& a, const U32& b); [[nodiscard]] U32 IMax(const U32& a, const U32& b, bool is_signed); + [[nodiscard]] U32 SMinTri(const U32& a, const U32& b, const U32& c); + [[nodiscard]] U32 UMinTri(const U32& a, const U32& b, const U32& c); + [[nodiscard]] U32 IMinTri(const U32& a, const U32& b, const U32& c, bool is_signed); + [[nodiscard]] U32 SMaxTri(const U32& a, const U32& b, const U32& c); + [[nodiscard]] U32 UMaxTri(const U32& a, const U32& b, const U32& c); + [[nodiscard]] U32 IMaxTri(const U32& a, const U32& b, const U32& c, bool is_signed); + [[nodiscard]] U32 SMedTri(const U32& a, const U32& b, const U32& c); + [[nodiscard]] U32 UMedTri(const U32& a, const U32& b, const U32& c); + [[nodiscard]] U32 IMedTri(const U32& a, const U32& b, const U32& c, bool is_signed); [[nodiscard]] U32 SClamp(const U32& value, const U32& min, const U32& max); [[nodiscard]] U32 UClamp(const U32& value, const U32& min, const U32& max); diff --git a/src/shader_recompiler/ir/opcodes.inc b/src/shader_recompiler/ir/opcodes.inc index d5e17631b..6f186808c 100644 --- a/src/shader_recompiler/ir/opcodes.inc +++ b/src/shader_recompiler/ir/opcodes.inc @@ -44,6 +44,9 @@ OPCODE(SharedAtomicUMax32, U32, U32, OPCODE(SharedAtomicAnd32, U32, U32, U32, ) OPCODE(SharedAtomicOr32, U32, U32, U32, ) OPCODE(SharedAtomicXor32, U32, U32, U32, ) +OPCODE(SharedAtomicISub32, U32, U32, U32, ) +OPCODE(SharedAtomicIIncrement32, U32, U32, ) +OPCODE(SharedAtomicIDecrement32, U32, U32, ) // Context getters/setters OPCODE(GetUserData, U32, ScalarReg, ) @@ -188,14 +191,13 @@ OPCODE(SelectF64, F64, U1, // Bitwise conversions OPCODE(BitCastU16F16, U16, F16, ) OPCODE(BitCastU32F32, U32, F32, ) -OPCODE(BitCastU64F64, U64, F64, ) OPCODE(BitCastF16U16, F16, U16, ) OPCODE(BitCastF32U32, F32, U32, ) -OPCODE(BitCastF64U64, F64, U64, ) OPCODE(PackUint2x32, U64, U32x2, ) OPCODE(UnpackUint2x32, U32x2, U64, ) -OPCODE(PackFloat2x32, F64, F32x2, ) +OPCODE(PackDouble2x32, F64, U32x2, ) +OPCODE(UnpackDouble2x32, U32x2, F64, ) OPCODE(PackUnorm2x16, U32, F32x2, ) OPCODE(UnpackUnorm2x16, F32x2, U32, ) @@ -241,6 +243,9 @@ OPCODE(FPMax32, F32, F32, OPCODE(FPMax64, F64, F64, F64, ) OPCODE(FPMin32, F32, F32, F32, U1, ) OPCODE(FPMin64, F64, F64, F64, ) +OPCODE(FPMinTri32, F32, F32, F32, F32, ) +OPCODE(FPMaxTri32, F32, F32, F32, F32, ) +OPCODE(FPMedTri32, F32, F32, F32, F32, ) OPCODE(FPMul32, F32, F32, F32, ) OPCODE(FPMul64, F64, F64, F64, ) OPCODE(FPDiv32, F32, F32, F32, ) @@ -314,8 +319,8 @@ OPCODE(ISub32, U32, U32, OPCODE(ISub64, U64, U64, U64, ) OPCODE(IMul32, U32, U32, U32, ) OPCODE(IMul64, U64, U64, U64, ) -OPCODE(SMulExt, U32x2, U32, U32, ) -OPCODE(UMulExt, U32x2, U32, U32, ) +OPCODE(SMulHi, U32, U32, U32, ) +OPCODE(UMulHi, U32, U32, U32, ) OPCODE(SDiv32, U32, U32, U32, ) OPCODE(UDiv32, U32, U32, U32, ) OPCODE(SMod32, U32, U32, U32, ) @@ -350,6 +355,12 @@ OPCODE(SMin32, U32, U32, OPCODE(UMin32, U32, U32, U32, ) OPCODE(SMax32, U32, U32, U32, ) OPCODE(UMax32, U32, U32, U32, ) +OPCODE(SMinTri32, U32, U32, U32, U32, ) +OPCODE(UMinTri32, U32, U32, U32, U32, ) +OPCODE(SMaxTri32, U32, U32, U32, U32, ) +OPCODE(UMaxTri32, U32, U32, U32, U32, ) +OPCODE(SMedTri32, U32, U32, U32, U32, ) +OPCODE(UMedTri32, U32, U32, U32, U32, ) OPCODE(SClamp32, U32, U32, U32, U32, ) OPCODE(UClamp32, U32, U32, U32, U32, ) OPCODE(SLessThan32, U1, U32, U32, ) diff --git a/src/shader_recompiler/ir/passes/constant_propagation_pass.cpp b/src/shader_recompiler/ir/passes/constant_propagation_pass.cpp index c8a4b13cb..5c66b1115 100644 --- a/src/shader_recompiler/ir/passes/constant_propagation_pass.cpp +++ b/src/shader_recompiler/ir/passes/constant_propagation_pass.cpp @@ -251,54 +251,6 @@ void FoldCmpClass(IR::Block& block, IR::Inst& inst) { } } -void FoldReadLane(IR::Block& block, IR::Inst& inst) { - const u32 lane = inst.Arg(1).U32(); - IR::Inst* prod = inst.Arg(0).InstRecursive(); - - const auto search_chain = [lane](const IR::Inst* prod) -> IR::Value { - while (prod->GetOpcode() == IR::Opcode::WriteLane) { - if (prod->Arg(2).U32() == lane) { - return prod->Arg(1); - } - prod = prod->Arg(0).InstRecursive(); - } - return {}; - }; - - if (prod->GetOpcode() == IR::Opcode::WriteLane) { - if (const IR::Value value = search_chain(prod); !value.IsEmpty()) { - inst.ReplaceUsesWith(value); - } - return; - } - - if (prod->GetOpcode() == IR::Opcode::Phi) { - boost::container::small_vector phi_args; - for (size_t arg_index = 0; arg_index < prod->NumArgs(); ++arg_index) { - const IR::Inst* arg{prod->Arg(arg_index).InstRecursive()}; - if (arg->GetOpcode() != IR::Opcode::WriteLane) { - return; - } - const IR::Value value = search_chain(arg); - if (value.IsEmpty()) { - continue; - } - phi_args.emplace_back(value); - } - if (std::ranges::all_of(phi_args, [&](IR::Value value) { return value == phi_args[0]; })) { - inst.ReplaceUsesWith(phi_args[0]); - return; - } - const auto insert_point = IR::Block::InstructionList::s_iterator_to(*prod); - IR::Inst* const new_phi{&*block.PrependNewInst(insert_point, IR::Opcode::Phi)}; - new_phi->SetFlags(IR::Type::U32); - for (size_t arg_index = 0; arg_index < phi_args.size(); arg_index++) { - new_phi->AddPhiOperand(prod->PhiBlock(arg_index), phi_args[arg_index]); - } - inst.ReplaceUsesWith(IR::Value{new_phi}); - } -} - void ConstantPropagation(IR::Block& block, IR::Inst& inst) { switch (inst.GetOpcode()) { case IR::Opcode::IAdd32: @@ -408,8 +360,6 @@ void ConstantPropagation(IR::Block& block, IR::Inst& inst) { case IR::Opcode::SelectF32: case IR::Opcode::SelectF64: return FoldSelect(inst); - case IR::Opcode::ReadLane: - return FoldReadLane(block, inst); case IR::Opcode::FPNeg32: FoldWhenAllImmediates(inst, [](f32 a) { return -a; }); return; diff --git a/src/shader_recompiler/ir/passes/hull_shader_transform.cpp b/src/shader_recompiler/ir/passes/hull_shader_transform.cpp index fced4b362..5cf8a1525 100644 --- a/src/shader_recompiler/ir/passes/hull_shader_transform.cpp +++ b/src/shader_recompiler/ir/passes/hull_shader_transform.cpp @@ -1,11 +1,13 @@ // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later + #include "common/assert.h" #include "shader_recompiler/info.h" #include "shader_recompiler/ir/attribute.h" #include "shader_recompiler/ir/breadth_first_search.h" #include "shader_recompiler/ir/ir_emitter.h" #include "shader_recompiler/ir/opcodes.h" +#include "shader_recompiler/ir/passes/ir_passes.h" #include "shader_recompiler/ir/pattern_matching.h" #include "shader_recompiler/ir/program.h" #include "shader_recompiler/runtime_info.h" @@ -75,10 +77,12 @@ namespace Shader::Optimization { * * output_patch_stride and output_cp_stride are usually compile time constants in the gcn * - * Hull shaders can probably also read output control points corresponding to other threads, like - * shared memory (but we havent seen this yet). - * ^ This is an UNREACHABLE for now. We may need to insert additional barriers if this happens. - * They should also be able to read PatchConst values, + * Hull shaders can also read output control points corresponding to other threads. + * In HLSL style, this should only be possible in the Patch Constant function. + * TODO we may need to insert additional barriers if sync is free/more permissive + * on AMD LDS HW + + * They should also be able to read output PatchConst values, * although not sure if this happens in practice. * * To determine which type of attribute (input, output, patchconst) we the check the users of @@ -101,22 +105,22 @@ namespace Shader::Optimization { * layout (location = 0) in vec4 in_attrs[][NUM_INPUT_ATTRIBUTES]; * * Here the NUM_INPUT_ATTRIBUTES is derived from the ls_stride member of the TessConstants V#. - * We divide ls_stride (in bytes) by 16 to get the number of vec4 attributes. - * For TES, the number of attributes comes from hs_cp_stride / 16. + * We take ALIGN_UP(ls_stride, 16) / 16 to get the number of vec4 attributes. + * For TES, NUM_INPUT_ATTRIBUTES is ALIGN_UP(hs_cp_stride, 16) / 16. * The first (outer) dimension is unsized but corresponds to the number of vertices in the hs input * patch (for Hull) or the hs output patch (for Domain). * * For input reads in TCS or TES, we emit SPIR-V like: - * float value = in_attrs[addr / ls_stride][(addr % ls_stride) >> 4][(addr & 0xF) >> 2]; + * float value = in_attrs[addr / ls_stride][(addr % ls_stride) >> 4][(addr % ls_stride) >> 2]; * * For output writes, we assume the control point index is InvocationId, since high level languages * impose that restriction (although maybe it's technically possible on hardware). So SPIR-V looks * like this: * layout (location = 0) in vec4 in_attrs[][NUM_OUTPUT_ATTRIBUTES]; - * out_attrs[InvocationId][(addr % hs_cp_stride) >> 4][(addr & 0xF) >> 2] = value; + * out_attrs[InvocationId][(addr % hs_cp_stride) >> 4][(addr % hs_cp_stride) >> 2] = value; * - * NUM_OUTPUT_ATTRIBUTES is derived by hs_cp_stride / 16, so it can link with the TES in_attrs - * variable. + * NUM_OUTPUT_ATTRIBUTES is derived by ALIGN_UP(hs_cp_stride, 16) / 16, so it matches + * NUM_INPUT_ATTRIBUTES of the TES. * * Another challenge is the fact that the GCN shader needs to address attributes from LDS as a whole * which contains the attributes from many patches. On the other hand, higher level shading @@ -235,12 +239,11 @@ private: case IR::Opcode::Phi: { struct PhiCounter { u16 seq_num; - u8 unique_edge; - u8 counter; + u16 unique_edge; }; PhiCounter count = inst->Flags(); - ASSERT_MSG(count.counter == 0 || count.unique_edge == use.operand); + ASSERT_MSG(count.seq_num == 0 || count.unique_edge == use.operand); // the point of seq_num is to tell us if we've already traversed this // phi on the current walk. Alternatively we could keep a set of phi's // seen on the current walk. This is to handle phi cycles @@ -249,13 +252,11 @@ private: count.seq_num = seq_num; // Mark the phi as having been traversed originally through this edge count.unique_edge = use.operand; - count.counter = inc; } else if (count.seq_num < seq_num) { count.seq_num = seq_num; // For now, assume we are visiting this phi via the same edge // as on other walks. If not, some dataflow analysis might be necessary ASSERT(count.unique_edge == use.operand); - count.counter += inc; } else { // count.seq_num == seq_num // there's a cycle, and we've already been here on this walk @@ -735,6 +736,8 @@ void TessellationPreprocess(IR::Program& program, RuntimeInfo& runtime_info) { } } } + + ConstantPropagationPass(program.post_order_blocks); } } // namespace Shader::Optimization diff --git a/src/shader_recompiler/ir/passes/ir_passes.h b/src/shader_recompiler/ir/passes/ir_passes.h index 69628dbfd..06e4ac850 100644 --- a/src/shader_recompiler/ir/passes/ir_passes.h +++ b/src/shader_recompiler/ir/passes/ir_passes.h @@ -17,11 +17,12 @@ void IdentityRemovalPass(IR::BlockList& program); void DeadCodeEliminationPass(IR::Program& program); void ConstantPropagationPass(IR::BlockList& program); void FlattenExtendedUserdataPass(IR::Program& program); +void ReadLaneEliminationPass(IR::Program& program); void ResourceTrackingPass(IR::Program& program); void CollectShaderInfoPass(IR::Program& program); void LowerBufferFormatToRaw(IR::Program& program); -void RingAccessElimination(const IR::Program& program, const RuntimeInfo& runtime_info, - Stage stage); +void LowerFp64ToFp32(IR::Program& program); +void RingAccessElimination(const IR::Program& program, const RuntimeInfo& runtime_info); void TessellationPreprocess(IR::Program& program, RuntimeInfo& runtime_info); void HullShaderTransform(IR::Program& program, RuntimeInfo& runtime_info); void DomainShaderTransform(IR::Program& program, RuntimeInfo& runtime_info); diff --git a/src/shader_recompiler/ir/passes/lower_buffer_format_to_raw.cpp b/src/shader_recompiler/ir/passes/lower_buffer_format_to_raw.cpp index 3fdc6f0cd..658a495bc 100644 --- a/src/shader_recompiler/ir/passes/lower_buffer_format_to_raw.cpp +++ b/src/shader_recompiler/ir/passes/lower_buffer_format_to_raw.cpp @@ -196,13 +196,18 @@ static void LowerBufferFormatInst(IR::Block& block, IR::Inst& inst, Info& info) const auto buffer{desc.GetSharp(info)}; const auto is_inst_typed = flags.inst_data_fmt != AmdGpu::DataFormat::FormatInvalid; - const auto data_format = is_inst_typed ? flags.inst_data_fmt.Value() : buffer.GetDataFmt(); - const auto num_format = is_inst_typed ? flags.inst_num_fmt.Value() : buffer.GetNumberFmt(); + const auto data_format = + is_inst_typed ? AmdGpu::RemapDataFormat(flags.inst_data_fmt.Value()) : buffer.GetDataFmt(); const auto format_info = FormatInfo{ .data_format = data_format, - .num_format = num_format, - .swizzle = is_inst_typed ? AmdGpu::IdentityMapping : buffer.DstSelect(), - .num_conversion = AmdGpu::MapNumberConversion(num_format), + .num_format = is_inst_typed + ? AmdGpu::RemapNumberFormat(flags.inst_num_fmt.Value(), data_format) + : buffer.GetNumberFmt(), + .swizzle = is_inst_typed + ? AmdGpu::RemapSwizzle(flags.inst_data_fmt.Value(), AmdGpu::IdentityMapping) + : buffer.DstSelect(), + .num_conversion = is_inst_typed ? AmdGpu::MapNumberConversion(flags.inst_num_fmt.Value()) + : buffer.GetNumberConversion(), .num_components = AmdGpu::NumComponents(data_format), }; diff --git a/src/shader_recompiler/ir/passes/lower_fp64_to_fp32.cpp b/src/shader_recompiler/ir/passes/lower_fp64_to_fp32.cpp new file mode 100644 index 000000000..3c30e75b4 --- /dev/null +++ b/src/shader_recompiler/ir/passes/lower_fp64_to_fp32.cpp @@ -0,0 +1,186 @@ +// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "shader_recompiler/info.h" +#include "shader_recompiler/ir/basic_block.h" +#include "shader_recompiler/ir/ir_emitter.h" +#include "shader_recompiler/ir/program.h" + +namespace Shader::Optimization { + +constexpr s32 F64ToF32Exp = +1023 - 127; +constexpr s32 F32ToF64Exp = +127 - 1023; + +static IR::F32 PackedF64ToF32(IR::IREmitter& ir, const IR::Value& packed) { + const IR::U32 lo{ir.CompositeExtract(packed, 0)}; + const IR::U32 hi{ir.CompositeExtract(packed, 1)}; + const IR::U32 sign{ir.BitFieldExtract(hi, ir.Imm32(31), ir.Imm32(1))}; + const IR::U32 exp{ir.BitFieldExtract(hi, ir.Imm32(20), ir.Imm32(11))}; + const IR::U32 mantissa_hi{ir.BitFieldExtract(hi, ir.Imm32(0), ir.Imm32(20))}; + const IR::U32 mantissa_lo{ir.BitFieldExtract(lo, ir.Imm32(29), ir.Imm32(3))}; + const IR::U32 mantissa{ + ir.BitwiseOr(ir.ShiftLeftLogical(mantissa_hi, ir.Imm32(3)), mantissa_lo)}; + const IR::U32 exp_if_subnorm{ + ir.Select(ir.IEqual(exp, ir.Imm32(0)), ir.Imm32(0), ir.IAdd(exp, ir.Imm32(F64ToF32Exp)))}; + const IR::U32 exp_if_infnan{ + ir.Select(ir.IEqual(exp, ir.Imm32(0x7ff)), ir.Imm32(0xff), exp_if_subnorm)}; + const IR::U32 result{ + ir.BitwiseOr(ir.ShiftLeftLogical(sign, ir.Imm32(31)), + ir.BitwiseOr(ir.ShiftLeftLogical(exp_if_infnan, ir.Imm32(23)), mantissa))}; + return ir.BitCast(result); +} + +IR::Value F32ToPackedF64(IR::IREmitter& ir, const IR::Value& raw) { + const IR::U32 value{ir.BitCast(IR::F32(raw))}; + const IR::U32 sign{ir.BitFieldExtract(value, ir.Imm32(31), ir.Imm32(1))}; + const IR::U32 exp{ir.BitFieldExtract(value, ir.Imm32(23), ir.Imm32(8))}; + const IR::U32 mantissa{ir.BitFieldExtract(value, ir.Imm32(0), ir.Imm32(23))}; + const IR::U32 mantissa_hi{ir.BitFieldExtract(mantissa, ir.Imm32(3), ir.Imm32(20))}; + const IR::U32 mantissa_lo{ir.BitFieldExtract(mantissa, ir.Imm32(0), ir.Imm32(3))}; + const IR::U32 exp_if_subnorm{ + ir.Select(ir.IEqual(exp, ir.Imm32(0)), ir.Imm32(0), ir.IAdd(exp, ir.Imm32(F32ToF64Exp)))}; + const IR::U32 exp_if_infnan{ + ir.Select(ir.IEqual(exp, ir.Imm32(0xff)), ir.Imm32(0x7ff), exp_if_subnorm)}; + const IR::U32 lo{ir.ShiftLeftLogical(mantissa_lo, ir.Imm32(29))}; + const IR::U32 hi{ + ir.BitwiseOr(ir.ShiftLeftLogical(sign, ir.Imm32(31)), + ir.BitwiseOr(ir.ShiftLeftLogical(exp_if_infnan, ir.Imm32(20)), mantissa_hi))}; + return ir.CompositeConstruct(lo, hi); +} + +static IR::Opcode Replace(IR::Opcode op) { + switch (op) { + case IR::Opcode::CompositeConstructF64x2: + return IR::Opcode::CompositeConstructF32x2; + case IR::Opcode::CompositeConstructF64x3: + return IR::Opcode::CompositeConstructF32x3; + case IR::Opcode::CompositeConstructF64x4: + return IR::Opcode::CompositeConstructF32x4; + case IR::Opcode::CompositeExtractF64x2: + return IR::Opcode::CompositeExtractF32x2; + case IR::Opcode::CompositeExtractF64x3: + return IR::Opcode::CompositeExtractF32x3; + case IR::Opcode::CompositeExtractF64x4: + return IR::Opcode::CompositeExtractF32x4; + case IR::Opcode::CompositeInsertF64x2: + return IR::Opcode::CompositeInsertF32x2; + case IR::Opcode::CompositeInsertF64x3: + return IR::Opcode::CompositeInsertF32x3; + case IR::Opcode::CompositeInsertF64x4: + return IR::Opcode::CompositeInsertF32x4; + case IR::Opcode::CompositeShuffleF64x2: + return IR::Opcode::CompositeShuffleF32x2; + case IR::Opcode::CompositeShuffleF64x3: + return IR::Opcode::CompositeShuffleF32x3; + case IR::Opcode::CompositeShuffleF64x4: + return IR::Opcode::CompositeShuffleF32x4; + case IR::Opcode::SelectF64: + return IR::Opcode::SelectF64; + case IR::Opcode::FPAbs64: + return IR::Opcode::FPAbs32; + case IR::Opcode::FPAdd64: + return IR::Opcode::FPAdd32; + case IR::Opcode::FPFma64: + return IR::Opcode::FPFma32; + case IR::Opcode::FPMax64: + return IR::Opcode::FPMax32; + case IR::Opcode::FPMin64: + return IR::Opcode::FPMin32; + case IR::Opcode::FPMul64: + return IR::Opcode::FPMul32; + case IR::Opcode::FPDiv64: + return IR::Opcode::FPDiv32; + case IR::Opcode::FPNeg64: + return IR::Opcode::FPNeg32; + case IR::Opcode::FPRecip64: + return IR::Opcode::FPRecip32; + case IR::Opcode::FPRecipSqrt64: + return IR::Opcode::FPRecipSqrt32; + case IR::Opcode::FPSaturate64: + return IR::Opcode::FPSaturate32; + case IR::Opcode::FPClamp64: + return IR::Opcode::FPClamp32; + case IR::Opcode::FPRoundEven64: + return IR::Opcode::FPRoundEven32; + case IR::Opcode::FPFloor64: + return IR::Opcode::FPFloor32; + case IR::Opcode::FPCeil64: + return IR::Opcode::FPCeil32; + case IR::Opcode::FPTrunc64: + return IR::Opcode::FPTrunc32; + case IR::Opcode::FPFract64: + return IR::Opcode::FPFract32; + case IR::Opcode::FPFrexpSig64: + return IR::Opcode::FPFrexpSig32; + case IR::Opcode::FPFrexpExp64: + return IR::Opcode::FPFrexpExp32; + case IR::Opcode::FPOrdEqual64: + return IR::Opcode::FPOrdEqual32; + case IR::Opcode::FPUnordEqual64: + return IR::Opcode::FPUnordEqual32; + case IR::Opcode::FPOrdNotEqual64: + return IR::Opcode::FPOrdNotEqual32; + case IR::Opcode::FPUnordNotEqual64: + return IR::Opcode::FPUnordNotEqual32; + case IR::Opcode::FPOrdLessThan64: + return IR::Opcode::FPOrdLessThan32; + case IR::Opcode::FPUnordLessThan64: + return IR::Opcode::FPUnordLessThan32; + case IR::Opcode::FPOrdGreaterThan64: + return IR::Opcode::FPOrdGreaterThan32; + case IR::Opcode::FPUnordGreaterThan64: + return IR::Opcode::FPUnordGreaterThan32; + case IR::Opcode::FPOrdLessThanEqual64: + return IR::Opcode::FPOrdLessThanEqual32; + case IR::Opcode::FPUnordLessThanEqual64: + return IR::Opcode::FPUnordLessThanEqual32; + case IR::Opcode::FPOrdGreaterThanEqual64: + return IR::Opcode::FPOrdGreaterThanEqual32; + case IR::Opcode::FPUnordGreaterThanEqual64: + return IR::Opcode::FPUnordGreaterThanEqual32; + case IR::Opcode::FPIsNan64: + return IR::Opcode::FPIsNan32; + case IR::Opcode::FPIsInf64: + return IR::Opcode::FPIsInf32; + case IR::Opcode::ConvertS32F64: + return IR::Opcode::ConvertS32F32; + case IR::Opcode::ConvertF32F64: + return IR::Opcode::Identity; + case IR::Opcode::ConvertF64F32: + return IR::Opcode::Identity; + case IR::Opcode::ConvertF64S32: + return IR::Opcode::ConvertF32S32; + case IR::Opcode::ConvertF64U32: + return IR::Opcode::ConvertF32U32; + default: + return op; + } +} + +static void Lower(IR::Block& block, IR::Inst& inst) { + switch (inst.GetOpcode()) { + case IR::Opcode::PackDouble2x32: { + IR::IREmitter ir(block, IR::Block::InstructionList::s_iterator_to(inst)); + inst.ReplaceUsesWith(PackedF64ToF32(ir, inst.Arg(0))); + break; + } + case IR::Opcode::UnpackDouble2x32: { + IR::IREmitter ir(block, IR::Block::InstructionList::s_iterator_to(inst)); + inst.ReplaceUsesWith(F32ToPackedF64(ir, inst.Arg(0))); + break; + } + default: + inst.ReplaceOpcode(Replace(inst.GetOpcode())); + break; + } +} + +void LowerFp64ToFp32(IR::Program& program) { + for (IR::Block* const block : program.blocks) { + for (IR::Inst& inst : block->Instructions()) { + Lower(*block, inst); + } + } +} + +} // namespace Shader::Optimization diff --git a/src/shader_recompiler/ir/passes/readlane_elimination_pass.cpp b/src/shader_recompiler/ir/passes/readlane_elimination_pass.cpp new file mode 100644 index 000000000..fbe382d41 --- /dev/null +++ b/src/shader_recompiler/ir/passes/readlane_elimination_pass.cpp @@ -0,0 +1,115 @@ +// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "shader_recompiler/ir/program.h" + +namespace Shader::Optimization { + +static IR::Inst* SearchChain(IR::Inst* inst, u32 lane) { + while (inst->GetOpcode() == IR::Opcode::WriteLane) { + if (inst->Arg(2).U32() == lane) { + // We found a possible write lane source, return it. + return inst; + } + inst = inst->Arg(0).InstRecursive(); + } + return inst; +} + +static bool IsPossibleToEliminate(IR::Inst* inst, u32 lane) { + // Breadth-first search visiting the right most arguments first + boost::container::small_vector visited; + std::queue queue; + queue.push(inst); + + while (!queue.empty()) { + // Pop one instruction from the queue + IR::Inst* inst{queue.front()}; + queue.pop(); + + // If it's a WriteLane search for possible candidates + if (inst = SearchChain(inst, lane); inst->GetOpcode() == IR::Opcode::WriteLane) { + // We found a possible write lane source, stop looking here. + continue; + } + // If there are other instructions in-between that use the value we can't eliminate. + if (inst->GetOpcode() != IR::Opcode::ReadLane && inst->GetOpcode() != IR::Opcode::Phi) { + return false; + } + // Visit the right most arguments first + for (size_t arg = inst->NumArgs(); arg--;) { + auto arg_value{inst->Arg(arg)}; + if (arg_value.IsImmediate()) { + continue; + } + // Queue instruction if it hasn't been visited + IR::Inst* arg_inst{arg_value.InstRecursive()}; + if (std::ranges::find(visited, arg_inst) == visited.end()) { + visited.push_back(arg_inst); + queue.push(arg_inst); + } + } + } + return true; +} + +using PhiMap = std::unordered_map; + +static IR::Value GetRealValue(PhiMap& phi_map, IR::Inst* inst, u32 lane) { + // If this is a WriteLane op search the chain for a possible candidate. + if (inst = SearchChain(inst, lane); inst->GetOpcode() == IR::Opcode::WriteLane) { + return inst->Arg(1); + } + + // If this is a phi, duplicate it and populate its arguments with real values. + if (inst->GetOpcode() == IR::Opcode::Phi) { + // We are in a phi cycle, use the already duplicated phi. + const auto [it, is_new_phi] = phi_map.try_emplace(inst); + if (!is_new_phi) { + return IR::Value{it->second}; + } + + // Create new phi and insert it right before the old one. + const auto insert_point = IR::Block::InstructionList::s_iterator_to(*inst); + IR::Block* block = inst->GetParent(); + IR::Inst* new_phi{&*block->PrependNewInst(insert_point, IR::Opcode::Phi)}; + new_phi->SetFlags(IR::Type::U32); + it->second = new_phi; + + // Gather all arguments. + for (size_t arg_index = 0; arg_index < inst->NumArgs(); arg_index++) { + IR::Inst* arg_prod = inst->Arg(arg_index).InstRecursive(); + const IR::Value arg = GetRealValue(phi_map, arg_prod, lane); + new_phi->AddPhiOperand(inst->PhiBlock(arg_index), arg); + } + return IR::Value{new_phi}; + } + UNREACHABLE(); +} + +void ReadLaneEliminationPass(IR::Program& program) { + PhiMap phi_map; + for (IR::Block* const block : program.blocks) { + for (IR::Inst& inst : block->Instructions()) { + if (inst.GetOpcode() != IR::Opcode::ReadLane) { + continue; + } + const u32 lane = inst.Arg(1).U32(); + IR::Inst* prod = inst.Arg(0).InstRecursive(); + + // Check simple case of no control flow and phis + if (prod = SearchChain(prod, lane); prod->GetOpcode() == IR::Opcode::WriteLane) { + inst.ReplaceUsesWith(prod->Arg(1)); + continue; + } + + // Traverse the phi tree to see if it's possible to eliminate + if (prod->GetOpcode() == IR::Opcode::Phi && IsPossibleToEliminate(prod, lane)) { + inst.ReplaceUsesWith(GetRealValue(phi_map, prod, lane)); + phi_map.clear(); + } + } + } +} + +} // namespace Shader::Optimization diff --git a/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp b/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp index c5bfe5796..778da149f 100644 --- a/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp +++ b/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp @@ -235,9 +235,12 @@ std::pair TryDisableAnisoLod0(const IR::Inst* inst) { return {prod2, true}; } -SharpLocation TrackSharp(const IR::Inst* inst, const Shader::Info& info) { +SharpLocation AttemptTrackSharp(const IR::Inst* inst, auto& visited_insts) { // Search until we find a potential sharp source. - const auto pred = [](const IR::Inst* inst) -> std::optional { + const auto pred = [&visited_insts](const IR::Inst* inst) -> std::optional { + if (std::ranges::find(visited_insts, inst) != visited_insts.end()) { + return std::nullopt; + } if (inst->GetOpcode() == IR::Opcode::GetUserData || inst->GetOpcode() == IR::Opcode::ReadConst) { return inst; @@ -247,6 +250,7 @@ SharpLocation TrackSharp(const IR::Inst* inst, const Shader::Info& info) { const auto result = IR::BreadthFirstSearch(inst, pred); ASSERT_MSG(result, "Unable to track sharp source"); inst = result.value(); + visited_insts.emplace_back(inst); if (inst->GetOpcode() == IR::Opcode::GetUserData) { return static_cast(inst->Arg(0).ScalarReg()); } else { @@ -256,6 +260,29 @@ SharpLocation TrackSharp(const IR::Inst* inst, const Shader::Info& info) { } } +/// Tracks a sharp with validation of the chosen data type. +template +std::pair TrackSharp(const IR::Inst* inst, const Info& info) { + boost::container::small_vector visited_insts{}; + while (true) { + const auto prev_size = visited_insts.size(); + const auto sharp = AttemptTrackSharp(inst, visited_insts); + if (const auto data = info.ReadUdSharp(sharp); data.Valid()) { + return std::make_pair(sharp, data); + } + if (prev_size == visited_insts.size()) { + // No change in visited instructions, we've run out of paths. + UNREACHABLE_MSG("Unable to find valid sharp."); + } + } +} + +/// Tracks a sharp without data validation. +SharpLocation TrackSharp(const IR::Inst* inst, const Info& info) { + boost::container::static_vector visited_insts{}; + return AttemptTrackSharp(inst, visited_insts); +} + s32 TryHandleInlineCbuf(IR::Inst& inst, Info& info, Descriptors& descriptors, AmdGpu::Buffer& cbuf) { @@ -293,8 +320,8 @@ void PatchBufferSharp(IR::Block& block, IR::Inst& inst, Info& info, Descriptors& if (binding = TryHandleInlineCbuf(inst, info, descriptors, buffer); binding == -1) { IR::Inst* handle = inst.Arg(0).InstRecursive(); IR::Inst* producer = handle->Arg(0).InstRecursive(); - const auto sharp = TrackSharp(producer, info); - buffer = info.ReadUdSharp(sharp); + SharpLocation sharp; + std::tie(sharp, buffer) = TrackSharp(producer, info); binding = descriptors.Add(BufferResource{ .sharp_idx = sharp, .used_types = BufferDataType(inst, buffer.GetNumberFmt()), diff --git a/src/shader_recompiler/ir/passes/ring_access_elimination.cpp b/src/shader_recompiler/ir/passes/ring_access_elimination.cpp index d6f1efb12..071b94ac0 100644 --- a/src/shader_recompiler/ir/passes/ring_access_elimination.cpp +++ b/src/shader_recompiler/ir/passes/ring_access_elimination.cpp @@ -11,8 +11,7 @@ namespace Shader::Optimization { -void RingAccessElimination(const IR::Program& program, const RuntimeInfo& runtime_info, - Stage stage) { +void RingAccessElimination(const IR::Program& program, const RuntimeInfo& runtime_info) { auto& info = program.info; const auto& ForEachInstruction = [&](auto func) { @@ -24,7 +23,7 @@ void RingAccessElimination(const IR::Program& program, const RuntimeInfo& runtim } }; - switch (stage) { + switch (program.info.stage) { case Stage::Local: { ForEachInstruction([=](IR::IREmitter& ir, IR::Inst& inst) { const auto opcode = inst.GetOpcode(); diff --git a/src/shader_recompiler/ir/passes/shader_info_collection_pass.cpp b/src/shader_recompiler/ir/passes/shader_info_collection_pass.cpp index 219378a6c..d739b2da5 100644 --- a/src/shader_recompiler/ir/passes/shader_info_collection_pass.cpp +++ b/src/shader_recompiler/ir/passes/shader_info_collection_pass.cpp @@ -44,7 +44,8 @@ void Visit(Info& info, const IR::Inst& inst) { case IR::Opcode::BitCastF16U16: info.uses_fp16 = true; break; - case IR::Opcode::BitCastU64F64: + case IR::Opcode::PackDouble2x32: + case IR::Opcode::UnpackDouble2x32: info.uses_fp64 = true; break; case IR::Opcode::ImageWrite: diff --git a/src/shader_recompiler/ir/reg.h b/src/shader_recompiler/ir/reg.h index 40c4b61c3..622190cf0 100644 --- a/src/shader_recompiler/ir/reg.h +++ b/src/shader_recompiler/ir/reg.h @@ -25,6 +25,7 @@ enum class FloatClassFunc : u32 { NaN = SignalingNan | QuietNan, Infinity = PositiveInfinity | NegativeInfinity, + Negative = NegativeInfinity | NegativeNormal | NegativeDenorm | NegativeZero, Finite = NegativeNormal | NegativeDenorm | NegativeZero | PositiveNormal | PositiveDenorm | PositiveZero, }; diff --git a/src/shader_recompiler/ir/srt_gvn_table.h b/src/shader_recompiler/ir/srt_gvn_table.h index 232ee6152..3baa1c7da 100644 --- a/src/shader_recompiler/ir/srt_gvn_table.h +++ b/src/shader_recompiler/ir/srt_gvn_table.h @@ -52,24 +52,16 @@ private: switch (inst->GetOpcode()) { case IR::Opcode::Phi: { - // hack to get to parity with main - // Need to fix ssa_rewrite pass to remove certain phis - std::optional source = TryRemoveTrivialPhi(inst); - if (!source) { - const auto pred = [](IR::Inst* inst) -> std::optional { - if (inst->GetOpcode() == IR::Opcode::GetUserData || - inst->GetOpcode() == IR::Opcode::CompositeConstructU32x2 || - inst->GetOpcode() == IR::Opcode::ReadConst) { - return inst; - } - return std::nullopt; - }; - source = IR::BreadthFirstSearch(inst, pred).transform([](auto inst) { - return IR::Value{inst}; - }); - ASSERT(source); - } - vn = GetValueNumber(source.value()); + const auto pred = [](IR::Inst* inst) -> std::optional { + if (inst->GetOpcode() == IR::Opcode::GetUserData || + inst->GetOpcode() == IR::Opcode::CompositeConstructU32x2 || + inst->GetOpcode() == IR::Opcode::ReadConst) { + return inst; + } + return std::nullopt; + }; + IR::Inst* source = IR::BreadthFirstSearch(inst, pred).value(); + vn = GetValueNumber(source); value_numbers[IR::Value(inst)] = vn; break; } @@ -117,30 +109,6 @@ private: return iv; } - // Temp workaround for something like this: - // [0000555558a5baf8] %297 = Phi [ %24, {Block $1} ], [ %297, {Block $5} ] (uses: 4) - // [0000555558a4e038] %305 = CompositeConstructU32x2 %297, %296 (uses: 4) - // [0000555558a4e0a8] %306 = ReadConst %305, #0 (uses: 2) - // Should probably be fixed in ssa_rewrite - std::optional TryRemoveTrivialPhi(IR::Inst* phi) { - IR::Value single_source{}; - - for (auto i = 0; i < phi->NumArgs(); i++) { - IR::Value v = phi->Arg(i).Resolve(); - if (v == IR::Value(phi)) { - continue; - } - if (!single_source.IsEmpty() && single_source != v) { - return std::nullopt; - } - single_source = v; - } - - ASSERT(!single_source.IsEmpty()); - phi->ReplaceUsesWith(single_source); - return single_source; - } - struct HashInstVector { size_t operator()(const InstVector& iv) const { u32 h = 0; diff --git a/src/shader_recompiler/profile.h b/src/shader_recompiler/profile.h index 1ceaea664..9aac6230a 100644 --- a/src/shader_recompiler/profile.h +++ b/src/shader_recompiler/profile.h @@ -15,6 +15,7 @@ struct Profile { bool support_int8{}; bool support_int16{}; bool support_int64{}; + bool support_float64{}; bool support_vertex_instance_id{}; bool support_float_controls{}; bool support_separate_denorm_behavior{}; @@ -26,6 +27,7 @@ struct Profile { bool support_legacy_vertex_attributes{}; bool supports_image_load_store_lod{}; bool supports_native_cube_calc{}; + bool supports_trinary_minmax{}; bool supports_robust_buffer_access{}; bool has_broken_spirv_clamp{}; bool lower_left_origin_mode{}; diff --git a/src/shader_recompiler/recompiler.cpp b/src/shader_recompiler/recompiler.cpp index 1c132ebbb..3e0bd98d2 100644 --- a/src/shader_recompiler/recompiler.cpp +++ b/src/shader_recompiler/recompiler.cpp @@ -1,9 +1,6 @@ // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include "common/config.h" -#include "common/io_file.h" -#include "common/path_util.h" #include "shader_recompiler/frontend/control_flow_graph.h" #include "shader_recompiler/frontend/decode.h" #include "shader_recompiler/frontend/structured_control_flow.h" @@ -63,26 +60,21 @@ IR::Program TranslateProgram(std::span code, Pools& pools, Info& info program.post_order_blocks = Shader::IR::PostOrder(program.syntax_list.front()); // Run optimization passes - const auto stage = program.info.stage; - + if (!profile.support_float64) { + Shader::Optimization::LowerFp64ToFp32(program); + } Shader::Optimization::SsaRewritePass(program.post_order_blocks); + Shader::Optimization::ConstantPropagationPass(program.post_order_blocks); Shader::Optimization::IdentityRemovalPass(program.blocks); if (info.l_stage == LogicalStage::TessellationControl) { - // Tess passes require previous const prop passes for now (for simplicity). TODO allow - // fine grained folding or opportunistic folding we set an operand to an immediate - Shader::Optimization::ConstantPropagationPass(program.post_order_blocks); Shader::Optimization::TessellationPreprocess(program, runtime_info); - Shader::Optimization::ConstantPropagationPass(program.post_order_blocks); Shader::Optimization::HullShaderTransform(program, runtime_info); } else if (info.l_stage == LogicalStage::TessellationEval) { - Shader::Optimization::ConstantPropagationPass(program.post_order_blocks); Shader::Optimization::TessellationPreprocess(program, runtime_info); - Shader::Optimization::ConstantPropagationPass(program.post_order_blocks); Shader::Optimization::DomainShaderTransform(program, runtime_info); } - Shader::Optimization::ConstantPropagationPass(program.post_order_blocks); - Shader::Optimization::RingAccessElimination(program, runtime_info, stage); - Shader::Optimization::ConstantPropagationPass(program.post_order_blocks); + Shader::Optimization::RingAccessElimination(program, runtime_info); + Shader::Optimization::ReadLaneEliminationPass(program); Shader::Optimization::FlattenExtendedUserdataPass(program); Shader::Optimization::ResourceTrackingPass(program); Shader::Optimization::LowerBufferFormatToRaw(program); diff --git a/src/shader_recompiler/specialization.h b/src/shader_recompiler/specialization.h index 1c3bfc60a..e40309aaf 100644 --- a/src/shader_recompiler/specialization.h +++ b/src/shader_recompiler/specialization.h @@ -13,7 +13,9 @@ namespace Shader { struct VsAttribSpecialization { + s32 num_components{}; AmdGpu::NumberClass num_class{}; + AmdGpu::CompMapping dst_select{}; auto operator<=>(const VsAttribSpecialization&) const = default; }; @@ -89,12 +91,17 @@ struct StageSpecialization { Backend::Bindings start_) : info{&info_}, runtime_info{runtime_info_}, start{start_} { fetch_shader_data = Gcn::ParseFetchShader(info_); - if (info_.stage == Stage::Vertex && fetch_shader_data && - !profile_.support_legacy_vertex_attributes) { + if (info_.stage == Stage::Vertex && fetch_shader_data) { // Specialize shader on VS input number types to follow spec. ForEachSharp(vs_attribs, fetch_shader_data->attributes, - [](auto& spec, const auto& desc, AmdGpu::Buffer sharp) { - spec.num_class = AmdGpu::GetNumberClass(sharp.GetNumberFmt()); + [&profile_](auto& spec, const auto& desc, AmdGpu::Buffer sharp) { + spec.num_components = desc.UsesStepRates() + ? AmdGpu::NumComponents(sharp.GetDataFmt()) + : 0; + spec.num_class = profile_.support_legacy_vertex_attributes + ? AmdGpu::NumberClass{} + : AmdGpu::GetNumberClass(sharp.GetNumberFmt()); + spec.dst_select = sharp.DstSelect(); }); } u32 binding{}; diff --git a/src/shadps4.qrc b/src/shadps4.qrc index 14b50f7a5..2aee394c8 100644 --- a/src/shadps4.qrc +++ b/src/shadps4.qrc @@ -1,36 +1,41 @@ - - images/shadps4.ico - images/about_icon.png - images/dump_icon.png - images/play_icon.png - images/pause_icon.png - images/stop_icon.png - images/utils_icon.png - images/file_icon.png - images/folder_icon.png - images/themes_icon.png - images/iconsize_icon.png - images/list_icon.png - images/grid_icon.png - images/exit_icon.png - images/settings_icon.png - images/controller_icon.png - images/refresh_icon.png - images/update_icon.png - images/list_mode_icon.png - images/flag_jp.png - images/flag_eu.png - images/flag_unk.png - images/flag_us.png - images/flag_world.png - images/flag_china.png - images/github.png - images/discord.png - images/ko-fi.png - images/youtube.png - images/website.png - images/ps4_controller.png - images/keyboard_icon.png - + + images/shadps4.ico + images/shadps4.png + images/about_icon.png + images/dump_icon.png + images/play_icon.png + images/pause_icon.png + images/stop_icon.png + images/utils_icon.png + images/file_icon.png + images/folder_icon.png + images/themes_icon.png + images/iconsize_icon.png + images/list_icon.png + images/grid_icon.png + images/exit_icon.png + images/settings_icon.png + images/controller_icon.png + images/restart_game_icon.png + images/update_icon.png + images/list_mode_icon.png + images/flag_jp.png + images/flag_eu.png + images/flag_unk.png + images/flag_us.png + images/flag_world.png + images/flag_china.png + images/github.png + images/discord.png + images/ko-fi.png + images/youtube.png + images/website.png + images/ps4_controller.png + images/keyboard_icon.png + images/KBM.png + images/fullscreen_icon.png + images/refreshlist_icon.png + images/trophy_icon.png + diff --git a/src/shadps4.rc b/src/shadps4.rc index 8c984f260..9edccfbfd 100644 --- a/src/shadps4.rc +++ b/src/shadps4.rc @@ -1 +1,43 @@ -IDI_ICON1 ICON "images/shadps4.ico" \ No newline at end of file +// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "winresrc.h" + +#define xstr(s) str(s) +#define str(s) #s + +// NEUTRAL LANG +LANGUAGE LANG_NEUTRAL, 0x8 + +// ICON +IDI_ICON1 ICON "images/shadps4.ico" + +// VERSION +VS_VERSION_INFO VERSIONINFO + FILEVERSION EMULATOR_VERSION_MAJOR, EMULATOR_VERSION_MINOR, EMULATOR_VERSION_PATCH, 0 + PRODUCTVERSION EMULATOR_VERSION_MAJOR, EMULATOR_VERSION_MINOR, EMULATOR_VERSION_PATCH, 0 + FILEFLAGSMASK 0x3fL + FILEFLAGS 0x0L + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "\0" + VALUE "FileDescription", "shadPS4 - PlayStation 4 Emulator\0" + VALUE "FileVersion", xstr(EMULATOR_VERSION_MAJOR) "." xstr(EMULATOR_VERSION_MINOR) "." xstr(EMULATOR_VERSION_PATCH) ".0\0" + VALUE "InternalName", "shadPS4\0" + VALUE "LegalCopyright", "Copyright 2025 shadPS4 Team\0" + VALUE "OriginalFilename", "shadPS4.exe\0" + VALUE "ProductName", "shadPS4\0" + VALUE "ProductVersion", xstr(EMULATOR_VERSION_MAJOR) "." xstr(EMULATOR_VERSION_MINOR) "." xstr(EMULATOR_VERSION_PATCH) ".0\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END diff --git a/src/video_core/amdgpu/liverpool.cpp b/src/video_core/amdgpu/liverpool.cpp index 246c8c947..967b952c6 100644 --- a/src/video_core/amdgpu/liverpool.cpp +++ b/src/video_core/amdgpu/liverpool.cpp @@ -602,20 +602,25 @@ Liverpool::Task Liverpool::ProcessGraphics(std::span dcb, std::spansrc_sel == DmaDataSrc::Data && dma_data->dst_sel == DmaDataDst::Gds) { rasterizer->InlineData(dma_data->dst_addr_lo, &dma_data->data, sizeof(u32), true); - } else if (dma_data->src_sel == DmaDataSrc::Memory && + } else if ((dma_data->src_sel == DmaDataSrc::Memory || + dma_data->src_sel == DmaDataSrc::MemoryUsingL2) && dma_data->dst_sel == DmaDataDst::Gds) { rasterizer->InlineData(dma_data->dst_addr_lo, dma_data->SrcAddress(), dma_data->NumBytes(), true); } else if (dma_data->src_sel == DmaDataSrc::Data && - dma_data->dst_sel == DmaDataDst::Memory) { + (dma_data->dst_sel == DmaDataDst::Memory || + dma_data->dst_sel == DmaDataDst::MemoryUsingL2)) { rasterizer->InlineData(dma_data->DstAddress(), &dma_data->data, sizeof(u32), false); } else if (dma_data->src_sel == DmaDataSrc::Gds && - dma_data->dst_sel == DmaDataDst::Memory) { + (dma_data->dst_sel == DmaDataDst::Memory || + dma_data->dst_sel == DmaDataDst::MemoryUsingL2)) { // LOG_WARNING(Render_Vulkan, "GDS memory read"); - } else if (dma_data->src_sel == DmaDataSrc::Memory && - dma_data->dst_sel == DmaDataDst::Memory) { + } else if ((dma_data->src_sel == DmaDataSrc::Memory || + dma_data->src_sel == DmaDataSrc::MemoryUsingL2) && + (dma_data->dst_sel == DmaDataDst::Memory || + dma_data->dst_sel == DmaDataDst::MemoryUsingL2)) { rasterizer->InlineData(dma_data->DstAddress(), dma_data->SrcAddress(), dma_data->NumBytes(), false); @@ -726,20 +731,39 @@ Liverpool::Task Liverpool::ProcessGraphics(std::span dcb, std::span -Liverpool::Task Liverpool::ProcessCompute(std::span acb, u32 vqid) { +Liverpool::Task Liverpool::ProcessCompute(const u32* acb, u32 acb_dwords, u32 vqid) { FIBER_ENTER(acb_task_name[vqid]); - const auto& queue = asc_queues[{vqid}]; + auto& queue = asc_queues[{vqid}]; - auto base_addr = reinterpret_cast(acb.data()); - while (!acb.empty()) { - const auto* header = reinterpret_cast(acb.data()); - const u32 type = header->type; - if (type != 3) { - // No other types of packets were spotted so far - UNREACHABLE_MSG("Invalid PM4 type {}", type); + auto base_addr = reinterpret_cast(acb); + while (acb_dwords > 0) { + auto* header = reinterpret_cast(acb); + u32 next_dw_off = header->type3.NumWords() + 1; + + // If we have a buffered packet, use it. + if (queue.tmp_dwords > 0) [[unlikely]] { + header = reinterpret_cast(queue.tmp_packet.data()); + next_dw_off = header->type3.NumWords() + 1 - queue.tmp_dwords; + std::memcpy(queue.tmp_packet.data() + queue.tmp_dwords, acb, next_dw_off * sizeof(u32)); + queue.tmp_dwords = 0; + } + + // If the packet is split across ring boundary, buffer until next submission + if (next_dw_off > acb_dwords) [[unlikely]] { + std::memcpy(queue.tmp_packet.data(), acb, acb_dwords * sizeof(u32)); + queue.tmp_dwords = acb_dwords; + if constexpr (!is_indirect) { + *queue.read_addr += acb_dwords; + *queue.read_addr %= queue.ring_size_dw; + } + break; + } + + if (header->type != 3) { + // No other types of packets were spotted so far + UNREACHABLE_MSG("Invalid PM4 type {}", header->type.Value()); } - const u32 count = header->type3.NumWords(); const PM4ItOpcode opcode = header->type3.opcode; const auto* it_body = reinterpret_cast(header) + 1; switch (opcode) { @@ -749,8 +773,8 @@ Liverpool::Task Liverpool::ProcessCompute(std::span acb, u32 vqid) { } case PM4ItOpcode::IndirectBuffer: { const auto* indirect_buffer = reinterpret_cast(header); - auto task = ProcessCompute( - {indirect_buffer->Address(), indirect_buffer->ib_size}, vqid); + auto task = ProcessCompute(indirect_buffer->Address(), + indirect_buffer->ib_size, vqid); RESUME_ASC(task, vqid); while (!task.handle.done()) { @@ -766,19 +790,24 @@ Liverpool::Task Liverpool::ProcessCompute(std::span acb, u32 vqid) { } if (dma_data->src_sel == DmaDataSrc::Data && dma_data->dst_sel == DmaDataDst::Gds) { rasterizer->InlineData(dma_data->dst_addr_lo, &dma_data->data, sizeof(u32), true); - } else if (dma_data->src_sel == DmaDataSrc::Memory && + } else if ((dma_data->src_sel == DmaDataSrc::Memory || + dma_data->src_sel == DmaDataSrc::MemoryUsingL2) && dma_data->dst_sel == DmaDataDst::Gds) { rasterizer->InlineData(dma_data->dst_addr_lo, dma_data->SrcAddress(), dma_data->NumBytes(), true); } else if (dma_data->src_sel == DmaDataSrc::Data && - dma_data->dst_sel == DmaDataDst::Memory) { + (dma_data->dst_sel == DmaDataDst::Memory || + dma_data->dst_sel == DmaDataDst::MemoryUsingL2)) { rasterizer->InlineData(dma_data->DstAddress(), &dma_data->data, sizeof(u32), false); } else if (dma_data->src_sel == DmaDataSrc::Gds && - dma_data->dst_sel == DmaDataDst::Memory) { + (dma_data->dst_sel == DmaDataDst::Memory || + dma_data->dst_sel == DmaDataDst::MemoryUsingL2)) { // LOG_WARNING(Render_Vulkan, "GDS memory read"); - } else if (dma_data->src_sel == DmaDataSrc::Memory && - dma_data->dst_sel == DmaDataDst::Memory) { + } else if ((dma_data->src_sel == DmaDataSrc::Memory || + dma_data->src_sel == DmaDataSrc::MemoryUsingL2) && + (dma_data->dst_sel == DmaDataDst::Memory || + dma_data->dst_sel == DmaDataDst::MemoryUsingL2)) { rasterizer->InlineData(dma_data->DstAddress(), dma_data->SrcAddress(), dma_data->NumBytes(), false); @@ -800,7 +829,7 @@ Liverpool::Task Liverpool::ProcessCompute(std::span acb, u32 vqid) { } case PM4ItOpcode::SetShReg: { const auto* set_data = reinterpret_cast(header); - const auto set_size = (count - 1) * sizeof(u32); + const auto set_size = (header->type3.NumWords() - 1) * sizeof(u32); if (set_data->reg_offset >= 0x200 && set_data->reg_offset <= (0x200 + sizeof(ComputeProgram) / 4)) { @@ -895,14 +924,14 @@ Liverpool::Task Liverpool::ProcessCompute(std::span acb, u32 vqid) { } default: UNREACHABLE_MSG("Unknown PM4 type 3 opcode {:#x} with count {}", - static_cast(opcode), count); + static_cast(opcode), header->type3.NumWords()); } - const auto packet_size_dw = header->type3.NumWords() + 1; - acb = NextPacket(acb, packet_size_dw); + acb += next_dw_off; + acb_dwords -= next_dw_off; if constexpr (!is_indirect) { - *queue.read_addr += packet_size_dw; + *queue.read_addr += next_dw_off; *queue.read_addr %= queue.ring_size_dw; } } @@ -969,7 +998,7 @@ void Liverpool::SubmitAsc(u32 gnm_vqid, std::span acb) { auto& queue = mapped_queues[gnm_vqid]; const auto vqid = gnm_vqid - 1; - const auto& task = ProcessCompute(acb, vqid); + const auto& task = ProcessCompute(acb.data(), acb.size(), vqid); { std::scoped_lock lock{queue.m_access}; queue.submits.emplace(task.handle); diff --git a/src/video_core/amdgpu/liverpool.h b/src/video_core/amdgpu/liverpool.h index c18bcd57b..8f9292f1c 100644 --- a/src/video_core/amdgpu/liverpool.h +++ b/src/video_core/amdgpu/liverpool.h @@ -1423,6 +1423,10 @@ struct Liverpool { return num_samples; } + bool IsClipDisabled() const { + return clipper_control.clip_disable || primitive_type == PrimitiveType::RectList; + } + void SetDefaults(); }; @@ -1496,10 +1500,13 @@ public: } struct AscQueueInfo { + static constexpr size_t Pm4BufferSize = 1024; VAddr map_addr; u32* read_addr; u32 ring_size_dw; u32 pipe_id; + std::array tmp_packet; + u32 tmp_dwords; }; Common::SlotVector asc_queues{}; @@ -1541,7 +1548,7 @@ private: Task ProcessGraphics(std::span dcb, std::span ccb); Task ProcessCeUpdate(std::span ccb); template - Task ProcessCompute(std::span acb, u32 vqid); + Task ProcessCompute(const u32* acb, u32 acb_dwords, u32 vqid); void Process(std::stop_token stoken); diff --git a/src/video_core/amdgpu/pm4_cmds.h b/src/video_core/amdgpu/pm4_cmds.h index e92ba17fa..ae1d32e00 100644 --- a/src/video_core/amdgpu/pm4_cmds.h +++ b/src/video_core/amdgpu/pm4_cmds.h @@ -377,12 +377,14 @@ struct PM4CmdAcquireMem { enum class DmaDataDst : u32 { Memory = 0, Gds = 1, + MemoryUsingL2 = 3, }; enum class DmaDataSrc : u32 { Memory = 0, Gds = 1, Data = 2, + MemoryUsingL2 = 3, }; struct PM4DmaData { diff --git a/src/video_core/host_shaders/CMakeLists.txt b/src/video_core/host_shaders/CMakeLists.txt index e60cca122..3001bf773 100644 --- a/src/video_core/host_shaders/CMakeLists.txt +++ b/src/video_core/host_shaders/CMakeLists.txt @@ -12,6 +12,7 @@ set(SHADER_FILES detilers/micro_64bpp.comp detilers/micro_8bpp.comp fs_tri.vert + fsr.comp post_process.frag ) diff --git a/src/video_core/host_shaders/StringShaderHeader.cmake b/src/video_core/host_shaders/StringShaderHeader.cmake index 9f7525535..798b43e6c 100644 --- a/src/video_core/host_shaders/StringShaderHeader.cmake +++ b/src/video_core/host_shaders/StringShaderHeader.cmake @@ -9,28 +9,31 @@ get_filename_component(CONTENTS_NAME ${SOURCE_FILE} NAME) string(REPLACE "." "_" CONTENTS_NAME ${CONTENTS_NAME}) string(TOUPPER ${CONTENTS_NAME} CONTENTS_NAME) -FILE(READ ${SOURCE_FILE} line_contents) +# Function to recursively parse #include directives and replace them with file contents +function(parse_includes file_path output_content) + file(READ ${file_path} file_content) + # This regex includes \n at the begin to (hackish) avoid including comments + string(REGEX MATCHALL "\n#include +\"[^\"]+\"" includes "${file_content}") -# Replace double quotes with single quotes, -# as double quotes will be used to wrap the lines -STRING(REGEX REPLACE "\"" "'" line_contents "${line_contents}") + set(parsed_content "${file_content}") + foreach (include_match ${includes}) + string(REGEX MATCH "\"([^\"]+)\"" _ "${include_match}") + set(include_file ${CMAKE_MATCH_1}) + get_filename_component(include_full_path "${file_path}" DIRECTORY) + set(include_full_path "${include_full_path}/${include_file}") -# CMake separates list elements with semicolons, but semicolons -# are used extensively in the shader code. -# Replace with a temporary marker, to be reverted later. -STRING(REGEX REPLACE ";" "{{SEMICOLON}}" line_contents "${line_contents}") + if (NOT EXISTS "${include_full_path}") + message(FATAL_ERROR "Included file not found: ${include_full_path} from ${file_path}") + endif () -# Make every line an individual element in the CMake list. -STRING(REGEX REPLACE "\n" ";" line_contents "${line_contents}") + parse_includes("${include_full_path}" sub_content) + string(REPLACE "${include_match}" "\n${sub_content}" parsed_content "${parsed_content}") + endforeach () + set(${output_content} "${parsed_content}" PARENT_SCOPE) +endfunction() -# Build the shader string, wrapping each line in double quotes. -foreach(line IN LISTS line_contents) - string(CONCAT CONTENTS "${CONTENTS}" \"${line}\\n\"\n) -endforeach() - -# Revert the original semicolons in the source. -STRING(REGEX REPLACE "{{SEMICOLON}}" ";" CONTENTS "${CONTENTS}") +parse_includes("${SOURCE_FILE}" CONTENTS) get_filename_component(OUTPUT_DIR ${HEADER_FILE} DIRECTORY) -make_directory(${OUTPUT_DIR}) +file(MAKE_DIRECTORY ${OUTPUT_DIR}) configure_file(${INPUT_FILE} ${HEADER_FILE} @ONLY) diff --git a/src/video_core/host_shaders/fsr.comp b/src/video_core/host_shaders/fsr.comp new file mode 100644 index 000000000..105859e35 --- /dev/null +++ b/src/video_core/host_shaders/fsr.comp @@ -0,0 +1,91 @@ +// SPDX-FileCopyrightText: Copyright (c) 2021 Advanced Micro Devices, Inc. All rights reserved. +// SPDX-License-Identifier: MIT + +#version 450 +#extension GL_ARB_separate_shader_objects: enable +#extension GL_ARB_shading_language_420pack: enable + +// FidelityFX Super Resolution Sample +// +// Copyright (c) 2021 Advanced Micro Devices, Inc. All rights reserved. +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +layout (push_constant) uniform const_buffer +{ + uvec4 Const0; + uvec4 Const1; + uvec4 Const2; + uvec4 Const3; + uvec4 Sample; +}; + +#define A_GPU 1 +#define A_GLSL 1 + +#define A_HALF +#include "fsr/ffx_a.h" + +layout (set = 0, binding = 0) uniform texture2D InputTexture; +layout (set = 0, binding = 1, rgba16f) uniform image2D OutputTexture; +layout (set = 0, binding = 2) uniform sampler InputSampler; + +#if SAMPLE_EASU +#define FSR_EASU_H 1 +AH4 FsrEasuRH(AF2 p) { AH4 res = AH4(textureGather(sampler2D(InputTexture, InputSampler), p, 0)); return res; } +AH4 FsrEasuGH(AF2 p) { AH4 res = AH4(textureGather(sampler2D(InputTexture, InputSampler), p, 1)); return res; } +AH4 FsrEasuBH(AF2 p) { AH4 res = AH4(textureGather(sampler2D(InputTexture, InputSampler), p, 2)); return res; } +#endif// SAMPLE_EASU + +#if SAMPLE_RCAS +#define FSR_RCAS_H +AH4 FsrRcasLoadH(ASW2 p) { return AH4(texelFetch(sampler2D(InputTexture, InputSampler), ASU2(p), 0)); } +void FsrRcasInputH(inout AH1 r, inout AH1 g, inout AH1 b) { } +#endif// SAMPLE_RCAS + +#include "fsr/ffx_fsr1.h" + +void CurrFilter(AU2 pos) +{ + #if SAMPLE_EASU + AH3 c; + FsrEasuH(c, pos, Const0, Const1, Const2, Const3); + if (Sample.x == 1) + c *= c; + imageStore(OutputTexture, ASU2(pos), AH4(c, 1)); + #endif// SAMPLE_EASU +#if SAMPLE_RCAS + AH3 c; + FsrRcasH(c.r, c.g, c.b, pos, Const0); + if (Sample.x == 1) + c *= c; + imageStore(OutputTexture, ASU2(pos), AH4(c, 1)); + #endif// SAMPLE_RCAS +} + +layout (local_size_x = 64) in; +void main() +{ + // Do remapping of local xy in workgroup for a more PS-like swizzle pattern. + AU2 gxy = ARmp8x8(gl_LocalInvocationID.x) + AU2(gl_WorkGroupID.x << 4u, gl_WorkGroupID.y << 4u); + CurrFilter(gxy); + gxy.x += 8u; + CurrFilter(gxy); + gxy.y += 8u; + CurrFilter(gxy); + gxy.x -= 8u; + CurrFilter(gxy); +} \ No newline at end of file diff --git a/src/video_core/host_shaders/fsr/ffx_a.h b/src/video_core/host_shaders/fsr/ffx_a.h new file mode 100644 index 000000000..882b0381c --- /dev/null +++ b/src/video_core/host_shaders/fsr/ffx_a.h @@ -0,0 +1,2657 @@ +// clang-format off +//============================================================================================================================== +// +// [A] SHADER PORTABILITY 1.20210629 +// +//============================================================================================================================== +// FidelityFX Super Resolution Sample +// +// Copyright (c) 2021 Advanced Micro Devices, Inc. All rights reserved. +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +//------------------------------------------------------------------------------------------------------------------------------ +// MIT LICENSE +// =========== +// Copyright (c) 2014 Michal Drobot (for concepts used in "FLOAT APPROXIMATIONS"). +// ----------- +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, +// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// ----------- +// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the +// Software. +// ----------- +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +//------------------------------------------------------------------------------------------------------------------------------ +// ABOUT +// ===== +// Common central point for high-level shading language and C portability for various shader headers. +//------------------------------------------------------------------------------------------------------------------------------ +// DEFINES +// ======= +// A_CPU ..... Include the CPU related code. +// A_GPU ..... Include the GPU related code. +// A_GLSL .... Using GLSL. +// A_HLSL .... Using HLSL. +// A_HLSL_6_2 Using HLSL 6.2 with new 'uint16_t' and related types (requires '-enable-16bit-types'). +// A_NO_16_BIT_CAST Don't use instructions that are not availabe in SPIR-V (needed for running A_HLSL_6_2 on Vulkan) +// A_GCC ..... Using a GCC compatible compiler (else assume MSVC compatible compiler by default). +// ======= +// A_BYTE .... Support 8-bit integer. +// A_HALF .... Support 16-bit integer and floating point. +// A_LONG .... Support 64-bit integer. +// A_DUBL .... Support 64-bit floating point. +// ======= +// A_WAVE .... Support wave-wide operations. +//------------------------------------------------------------------------------------------------------------------------------ +// To get #include "ffx_a.h" working in GLSL use '#extension GL_GOOGLE_include_directive:require'. +//------------------------------------------------------------------------------------------------------------------------------ +// SIMPLIFIED TYPE SYSTEM +// ====================== +// - All ints will be unsigned with exception of when signed is required. +// - Type naming simplified and shortened "A<#components>", +// - H = 16-bit float (half) +// - F = 32-bit float (float) +// - D = 64-bit float (double) +// - P = 1-bit integer (predicate, not using bool because 'B' is used for byte) +// - B = 8-bit integer (byte) +// - W = 16-bit integer (word) +// - U = 32-bit integer (unsigned) +// - L = 64-bit integer (long) +// - Using "AS<#components>" for signed when required. +//------------------------------------------------------------------------------------------------------------------------------ +// TODO +// ==== +// - Make sure 'ALerp*(a,b,m)' does 'b*m+(-a*m+a)' (2 ops). +//------------------------------------------------------------------------------------------------------------------------------ +// CHANGE LOG +// ========== +// 20200914 - Expanded wave ops and prx code. +// 20200713 - Added [ZOL] section, fixed serious bugs in sRGB and Rec.709 color conversion code, etc. +//============================================================================================================================== +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// COMMON +//============================================================================================================================== +#define A_2PI 6.28318530718 +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// +// +// CPU +// +// +//============================================================================================================================== +#ifdef A_CPU + // Supporting user defined overrides. + #ifndef A_RESTRICT + #define A_RESTRICT __restrict + #endif +//------------------------------------------------------------------------------------------------------------------------------ + #ifndef A_STATIC + #define A_STATIC static + #endif +//------------------------------------------------------------------------------------------------------------------------------ + // Same types across CPU and GPU. + // Predicate uses 32-bit integer (C friendly bool). + typedef uint32_t AP1; + typedef float AF1; + typedef double AD1; + typedef uint8_t AB1; + typedef uint16_t AW1; + typedef uint32_t AU1; + typedef uint64_t AL1; + typedef int8_t ASB1; + typedef int16_t ASW1; + typedef int32_t ASU1; + typedef int64_t ASL1; +//------------------------------------------------------------------------------------------------------------------------------ + #define AD1_(a) ((AD1)(a)) + #define AF1_(a) ((AF1)(a)) + #define AL1_(a) ((AL1)(a)) + #define AU1_(a) ((AU1)(a)) +//------------------------------------------------------------------------------------------------------------------------------ + #define ASL1_(a) ((ASL1)(a)) + #define ASU1_(a) ((ASU1)(a)) +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC AU1 AU1_AF1(AF1 a){union{AF1 f;AU1 u;}bits;bits.f=a;return bits.u;} +//------------------------------------------------------------------------------------------------------------------------------ + #define A_TRUE 1 + #define A_FALSE 0 +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// +// CPU/GPU PORTING +// +//------------------------------------------------------------------------------------------------------------------------------ +// Get CPU and GPU to share all setup code, without duplicate code paths. +// This uses a lower-case prefix for special vector constructs. +// - In C restrict pointers are used. +// - In the shading language, in/inout/out arguments are used. +// This depends on the ability to access a vector value in both languages via array syntax (aka color[2]). +//============================================================================================================================== +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// VECTOR ARGUMENT/RETURN/INITIALIZATION PORTABILITY +//============================================================================================================================== + #define retAD2 AD1 *A_RESTRICT + #define retAD3 AD1 *A_RESTRICT + #define retAD4 AD1 *A_RESTRICT + #define retAF2 AF1 *A_RESTRICT + #define retAF3 AF1 *A_RESTRICT + #define retAF4 AF1 *A_RESTRICT + #define retAL2 AL1 *A_RESTRICT + #define retAL3 AL1 *A_RESTRICT + #define retAL4 AL1 *A_RESTRICT + #define retAU2 AU1 *A_RESTRICT + #define retAU3 AU1 *A_RESTRICT + #define retAU4 AU1 *A_RESTRICT +//------------------------------------------------------------------------------------------------------------------------------ + #define inAD2 AD1 *A_RESTRICT + #define inAD3 AD1 *A_RESTRICT + #define inAD4 AD1 *A_RESTRICT + #define inAF2 AF1 *A_RESTRICT + #define inAF3 AF1 *A_RESTRICT + #define inAF4 AF1 *A_RESTRICT + #define inAL2 AL1 *A_RESTRICT + #define inAL3 AL1 *A_RESTRICT + #define inAL4 AL1 *A_RESTRICT + #define inAU2 AU1 *A_RESTRICT + #define inAU3 AU1 *A_RESTRICT + #define inAU4 AU1 *A_RESTRICT +//------------------------------------------------------------------------------------------------------------------------------ + #define inoutAD2 AD1 *A_RESTRICT + #define inoutAD3 AD1 *A_RESTRICT + #define inoutAD4 AD1 *A_RESTRICT + #define inoutAF2 AF1 *A_RESTRICT + #define inoutAF3 AF1 *A_RESTRICT + #define inoutAF4 AF1 *A_RESTRICT + #define inoutAL2 AL1 *A_RESTRICT + #define inoutAL3 AL1 *A_RESTRICT + #define inoutAL4 AL1 *A_RESTRICT + #define inoutAU2 AU1 *A_RESTRICT + #define inoutAU3 AU1 *A_RESTRICT + #define inoutAU4 AU1 *A_RESTRICT +//------------------------------------------------------------------------------------------------------------------------------ + #define outAD2 AD1 *A_RESTRICT + #define outAD3 AD1 *A_RESTRICT + #define outAD4 AD1 *A_RESTRICT + #define outAF2 AF1 *A_RESTRICT + #define outAF3 AF1 *A_RESTRICT + #define outAF4 AF1 *A_RESTRICT + #define outAL2 AL1 *A_RESTRICT + #define outAL3 AL1 *A_RESTRICT + #define outAL4 AL1 *A_RESTRICT + #define outAU2 AU1 *A_RESTRICT + #define outAU3 AU1 *A_RESTRICT + #define outAU4 AU1 *A_RESTRICT +//------------------------------------------------------------------------------------------------------------------------------ + #define varAD2(x) AD1 x[2] + #define varAD3(x) AD1 x[3] + #define varAD4(x) AD1 x[4] + #define varAF2(x) AF1 x[2] + #define varAF3(x) AF1 x[3] + #define varAF4(x) AF1 x[4] + #define varAL2(x) AL1 x[2] + #define varAL3(x) AL1 x[3] + #define varAL4(x) AL1 x[4] + #define varAU2(x) AU1 x[2] + #define varAU3(x) AU1 x[3] + #define varAU4(x) AU1 x[4] +//------------------------------------------------------------------------------------------------------------------------------ + #define initAD2(x,y) {x,y} + #define initAD3(x,y,z) {x,y,z} + #define initAD4(x,y,z,w) {x,y,z,w} + #define initAF2(x,y) {x,y} + #define initAF3(x,y,z) {x,y,z} + #define initAF4(x,y,z,w) {x,y,z,w} + #define initAL2(x,y) {x,y} + #define initAL3(x,y,z) {x,y,z} + #define initAL4(x,y,z,w) {x,y,z,w} + #define initAU2(x,y) {x,y} + #define initAU3(x,y,z) {x,y,z} + #define initAU4(x,y,z,w) {x,y,z,w} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// SCALAR RETURN OPS +//------------------------------------------------------------------------------------------------------------------------------ +// TODO +// ==== +// - Replace transcendentals with manual versions. +//============================================================================================================================== + #ifdef A_GCC + A_STATIC AD1 AAbsD1(AD1 a){return __builtin_fabs(a);} + A_STATIC AF1 AAbsF1(AF1 a){return __builtin_fabsf(a);} + A_STATIC AU1 AAbsSU1(AU1 a){return AU1_(__builtin_abs(ASU1_(a)));} + A_STATIC AL1 AAbsSL1(AL1 a){return AL1_(__builtin_llabs(ASL1_(a)));} + #else + A_STATIC AD1 AAbsD1(AD1 a){return fabs(a);} + A_STATIC AF1 AAbsF1(AF1 a){return fabsf(a);} + A_STATIC AU1 AAbsSU1(AU1 a){return AU1_(abs(ASU1_(a)));} + A_STATIC AL1 AAbsSL1(AL1 a){return AL1_(labs((long)ASL1_(a)));} + #endif +//------------------------------------------------------------------------------------------------------------------------------ + #ifdef A_GCC + A_STATIC AD1 ACosD1(AD1 a){return __builtin_cos(a);} + A_STATIC AF1 ACosF1(AF1 a){return __builtin_cosf(a);} + #else + A_STATIC AD1 ACosD1(AD1 a){return cos(a);} + A_STATIC AF1 ACosF1(AF1 a){return cosf(a);} + #endif +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC AD1 ADotD2(inAD2 a,inAD2 b){return a[0]*b[0]+a[1]*b[1];} + A_STATIC AD1 ADotD3(inAD3 a,inAD3 b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2];} + A_STATIC AD1 ADotD4(inAD4 a,inAD4 b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3];} + A_STATIC AF1 ADotF2(inAF2 a,inAF2 b){return a[0]*b[0]+a[1]*b[1];} + A_STATIC AF1 ADotF3(inAF3 a,inAF3 b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2];} + A_STATIC AF1 ADotF4(inAF4 a,inAF4 b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3];} +//------------------------------------------------------------------------------------------------------------------------------ + #ifdef A_GCC + A_STATIC AD1 AExp2D1(AD1 a){return __builtin_exp2(a);} + A_STATIC AF1 AExp2F1(AF1 a){return __builtin_exp2f(a);} + #else + A_STATIC AD1 AExp2D1(AD1 a){return exp2(a);} + A_STATIC AF1 AExp2F1(AF1 a){return exp2f(a);} + #endif +//------------------------------------------------------------------------------------------------------------------------------ + #ifdef A_GCC + A_STATIC AD1 AFloorD1(AD1 a){return __builtin_floor(a);} + A_STATIC AF1 AFloorF1(AF1 a){return __builtin_floorf(a);} + #else + A_STATIC AD1 AFloorD1(AD1 a){return floor(a);} + A_STATIC AF1 AFloorF1(AF1 a){return floorf(a);} + #endif +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC AD1 ALerpD1(AD1 a,AD1 b,AD1 c){return b*c+(-a*c+a);} + A_STATIC AF1 ALerpF1(AF1 a,AF1 b,AF1 c){return b*c+(-a*c+a);} +//------------------------------------------------------------------------------------------------------------------------------ + #ifdef A_GCC + A_STATIC AD1 ALog2D1(AD1 a){return __builtin_log2(a);} + A_STATIC AF1 ALog2F1(AF1 a){return __builtin_log2f(a);} + #else + A_STATIC AD1 ALog2D1(AD1 a){return log2(a);} + A_STATIC AF1 ALog2F1(AF1 a){return log2f(a);} + #endif +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC AD1 AMaxD1(AD1 a,AD1 b){return a>b?a:b;} + A_STATIC AF1 AMaxF1(AF1 a,AF1 b){return a>b?a:b;} + A_STATIC AL1 AMaxL1(AL1 a,AL1 b){return a>b?a:b;} + A_STATIC AU1 AMaxU1(AU1 a,AU1 b){return a>b?a:b;} +//------------------------------------------------------------------------------------------------------------------------------ + // These follow the convention that A integer types don't have signage, until they are operated on. + A_STATIC AL1 AMaxSL1(AL1 a,AL1 b){return (ASL1_(a)>ASL1_(b))?a:b;} + A_STATIC AU1 AMaxSU1(AU1 a,AU1 b){return (ASU1_(a)>ASU1_(b))?a:b;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC AD1 AMinD1(AD1 a,AD1 b){return a>ASL1_(b));} + A_STATIC AU1 AShrSU1(AU1 a,AU1 b){return AU1_(ASU1_(a)>>ASU1_(b));} +//------------------------------------------------------------------------------------------------------------------------------ + #ifdef A_GCC + A_STATIC AD1 ASinD1(AD1 a){return __builtin_sin(a);} + A_STATIC AF1 ASinF1(AF1 a){return __builtin_sinf(a);} + #else + A_STATIC AD1 ASinD1(AD1 a){return sin(a);} + A_STATIC AF1 ASinF1(AF1 a){return sinf(a);} + #endif +//------------------------------------------------------------------------------------------------------------------------------ + #ifdef A_GCC + A_STATIC AD1 ASqrtD1(AD1 a){return __builtin_sqrt(a);} + A_STATIC AF1 ASqrtF1(AF1 a){return __builtin_sqrtf(a);} + #else + A_STATIC AD1 ASqrtD1(AD1 a){return sqrt(a);} + A_STATIC AF1 ASqrtF1(AF1 a){return sqrtf(a);} + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// SCALAR RETURN OPS - DEPENDENT +//============================================================================================================================== + A_STATIC AD1 AClampD1(AD1 x,AD1 n,AD1 m){return AMaxD1(n,AMinD1(x,m));} + A_STATIC AF1 AClampF1(AF1 x,AF1 n,AF1 m){return AMaxF1(n,AMinF1(x,m));} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC AD1 AFractD1(AD1 a){return a-AFloorD1(a);} + A_STATIC AF1 AFractF1(AF1 a){return a-AFloorF1(a);} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC AD1 APowD1(AD1 a,AD1 b){return AExp2D1(b*ALog2D1(a));} + A_STATIC AF1 APowF1(AF1 a,AF1 b){return AExp2F1(b*ALog2F1(a));} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC AD1 ARsqD1(AD1 a){return ARcpD1(ASqrtD1(a));} + A_STATIC AF1 ARsqF1(AF1 a){return ARcpF1(ASqrtF1(a));} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC AD1 ASatD1(AD1 a){return AMinD1(1.0,AMaxD1(0.0,a));} + A_STATIC AF1 ASatF1(AF1 a){return AMinF1(1.0f,AMaxF1(0.0f,a));} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// VECTOR OPS +//------------------------------------------------------------------------------------------------------------------------------ +// These are added as needed for production or prototyping, so not necessarily a complete set. +// They follow a convention of taking in a destination and also returning the destination value to increase utility. +//============================================================================================================================== + A_STATIC retAD2 opAAbsD2(outAD2 d,inAD2 a){d[0]=AAbsD1(a[0]);d[1]=AAbsD1(a[1]);return d;} + A_STATIC retAD3 opAAbsD3(outAD3 d,inAD3 a){d[0]=AAbsD1(a[0]);d[1]=AAbsD1(a[1]);d[2]=AAbsD1(a[2]);return d;} + A_STATIC retAD4 opAAbsD4(outAD4 d,inAD4 a){d[0]=AAbsD1(a[0]);d[1]=AAbsD1(a[1]);d[2]=AAbsD1(a[2]);d[3]=AAbsD1(a[3]);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC retAF2 opAAbsF2(outAF2 d,inAF2 a){d[0]=AAbsF1(a[0]);d[1]=AAbsF1(a[1]);return d;} + A_STATIC retAF3 opAAbsF3(outAF3 d,inAF3 a){d[0]=AAbsF1(a[0]);d[1]=AAbsF1(a[1]);d[2]=AAbsF1(a[2]);return d;} + A_STATIC retAF4 opAAbsF4(outAF4 d,inAF4 a){d[0]=AAbsF1(a[0]);d[1]=AAbsF1(a[1]);d[2]=AAbsF1(a[2]);d[3]=AAbsF1(a[3]);return d;} +//============================================================================================================================== + A_STATIC retAD2 opAAddD2(outAD2 d,inAD2 a,inAD2 b){d[0]=a[0]+b[0];d[1]=a[1]+b[1];return d;} + A_STATIC retAD3 opAAddD3(outAD3 d,inAD3 a,inAD3 b){d[0]=a[0]+b[0];d[1]=a[1]+b[1];d[2]=a[2]+b[2];return d;} + A_STATIC retAD4 opAAddD4(outAD4 d,inAD4 a,inAD4 b){d[0]=a[0]+b[0];d[1]=a[1]+b[1];d[2]=a[2]+b[2];d[3]=a[3]+b[3];return d;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC retAF2 opAAddF2(outAF2 d,inAF2 a,inAF2 b){d[0]=a[0]+b[0];d[1]=a[1]+b[1];return d;} + A_STATIC retAF3 opAAddF3(outAF3 d,inAF3 a,inAF3 b){d[0]=a[0]+b[0];d[1]=a[1]+b[1];d[2]=a[2]+b[2];return d;} + A_STATIC retAF4 opAAddF4(outAF4 d,inAF4 a,inAF4 b){d[0]=a[0]+b[0];d[1]=a[1]+b[1];d[2]=a[2]+b[2];d[3]=a[3]+b[3];return d;} +//============================================================================================================================== + A_STATIC retAD2 opAAddOneD2(outAD2 d,inAD2 a,AD1 b){d[0]=a[0]+b;d[1]=a[1]+b;return d;} + A_STATIC retAD3 opAAddOneD3(outAD3 d,inAD3 a,AD1 b){d[0]=a[0]+b;d[1]=a[1]+b;d[2]=a[2]+b;return d;} + A_STATIC retAD4 opAAddOneD4(outAD4 d,inAD4 a,AD1 b){d[0]=a[0]+b;d[1]=a[1]+b;d[2]=a[2]+b;d[3]=a[3]+b;return d;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC retAF2 opAAddOneF2(outAF2 d,inAF2 a,AF1 b){d[0]=a[0]+b;d[1]=a[1]+b;return d;} + A_STATIC retAF3 opAAddOneF3(outAF3 d,inAF3 a,AF1 b){d[0]=a[0]+b;d[1]=a[1]+b;d[2]=a[2]+b;return d;} + A_STATIC retAF4 opAAddOneF4(outAF4 d,inAF4 a,AF1 b){d[0]=a[0]+b;d[1]=a[1]+b;d[2]=a[2]+b;d[3]=a[3]+b;return d;} +//============================================================================================================================== + A_STATIC retAD2 opACpyD2(outAD2 d,inAD2 a){d[0]=a[0];d[1]=a[1];return d;} + A_STATIC retAD3 opACpyD3(outAD3 d,inAD3 a){d[0]=a[0];d[1]=a[1];d[2]=a[2];return d;} + A_STATIC retAD4 opACpyD4(outAD4 d,inAD4 a){d[0]=a[0];d[1]=a[1];d[2]=a[2];d[3]=a[3];return d;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC retAF2 opACpyF2(outAF2 d,inAF2 a){d[0]=a[0];d[1]=a[1];return d;} + A_STATIC retAF3 opACpyF3(outAF3 d,inAF3 a){d[0]=a[0];d[1]=a[1];d[2]=a[2];return d;} + A_STATIC retAF4 opACpyF4(outAF4 d,inAF4 a){d[0]=a[0];d[1]=a[1];d[2]=a[2];d[3]=a[3];return d;} +//============================================================================================================================== + A_STATIC retAD2 opALerpD2(outAD2 d,inAD2 a,inAD2 b,inAD2 c){d[0]=ALerpD1(a[0],b[0],c[0]);d[1]=ALerpD1(a[1],b[1],c[1]);return d;} + A_STATIC retAD3 opALerpD3(outAD3 d,inAD3 a,inAD3 b,inAD3 c){d[0]=ALerpD1(a[0],b[0],c[0]);d[1]=ALerpD1(a[1],b[1],c[1]);d[2]=ALerpD1(a[2],b[2],c[2]);return d;} + A_STATIC retAD4 opALerpD4(outAD4 d,inAD4 a,inAD4 b,inAD4 c){d[0]=ALerpD1(a[0],b[0],c[0]);d[1]=ALerpD1(a[1],b[1],c[1]);d[2]=ALerpD1(a[2],b[2],c[2]);d[3]=ALerpD1(a[3],b[3],c[3]);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC retAF2 opALerpF2(outAF2 d,inAF2 a,inAF2 b,inAF2 c){d[0]=ALerpF1(a[0],b[0],c[0]);d[1]=ALerpF1(a[1],b[1],c[1]);return d;} + A_STATIC retAF3 opALerpF3(outAF3 d,inAF3 a,inAF3 b,inAF3 c){d[0]=ALerpF1(a[0],b[0],c[0]);d[1]=ALerpF1(a[1],b[1],c[1]);d[2]=ALerpF1(a[2],b[2],c[2]);return d;} + A_STATIC retAF4 opALerpF4(outAF4 d,inAF4 a,inAF4 b,inAF4 c){d[0]=ALerpF1(a[0],b[0],c[0]);d[1]=ALerpF1(a[1],b[1],c[1]);d[2]=ALerpF1(a[2],b[2],c[2]);d[3]=ALerpF1(a[3],b[3],c[3]);return d;} +//============================================================================================================================== + A_STATIC retAD2 opALerpOneD2(outAD2 d,inAD2 a,inAD2 b,AD1 c){d[0]=ALerpD1(a[0],b[0],c);d[1]=ALerpD1(a[1],b[1],c);return d;} + A_STATIC retAD3 opALerpOneD3(outAD3 d,inAD3 a,inAD3 b,AD1 c){d[0]=ALerpD1(a[0],b[0],c);d[1]=ALerpD1(a[1],b[1],c);d[2]=ALerpD1(a[2],b[2],c);return d;} + A_STATIC retAD4 opALerpOneD4(outAD4 d,inAD4 a,inAD4 b,AD1 c){d[0]=ALerpD1(a[0],b[0],c);d[1]=ALerpD1(a[1],b[1],c);d[2]=ALerpD1(a[2],b[2],c);d[3]=ALerpD1(a[3],b[3],c);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC retAF2 opALerpOneF2(outAF2 d,inAF2 a,inAF2 b,AF1 c){d[0]=ALerpF1(a[0],b[0],c);d[1]=ALerpF1(a[1],b[1],c);return d;} + A_STATIC retAF3 opALerpOneF3(outAF3 d,inAF3 a,inAF3 b,AF1 c){d[0]=ALerpF1(a[0],b[0],c);d[1]=ALerpF1(a[1],b[1],c);d[2]=ALerpF1(a[2],b[2],c);return d;} + A_STATIC retAF4 opALerpOneF4(outAF4 d,inAF4 a,inAF4 b,AF1 c){d[0]=ALerpF1(a[0],b[0],c);d[1]=ALerpF1(a[1],b[1],c);d[2]=ALerpF1(a[2],b[2],c);d[3]=ALerpF1(a[3],b[3],c);return d;} +//============================================================================================================================== + A_STATIC retAD2 opAMaxD2(outAD2 d,inAD2 a,inAD2 b){d[0]=AMaxD1(a[0],b[0]);d[1]=AMaxD1(a[1],b[1]);return d;} + A_STATIC retAD3 opAMaxD3(outAD3 d,inAD3 a,inAD3 b){d[0]=AMaxD1(a[0],b[0]);d[1]=AMaxD1(a[1],b[1]);d[2]=AMaxD1(a[2],b[2]);return d;} + A_STATIC retAD4 opAMaxD4(outAD4 d,inAD4 a,inAD4 b){d[0]=AMaxD1(a[0],b[0]);d[1]=AMaxD1(a[1],b[1]);d[2]=AMaxD1(a[2],b[2]);d[3]=AMaxD1(a[3],b[3]);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC retAF2 opAMaxF2(outAF2 d,inAF2 a,inAF2 b){d[0]=AMaxF1(a[0],b[0]);d[1]=AMaxF1(a[1],b[1]);return d;} + A_STATIC retAF3 opAMaxF3(outAF3 d,inAF3 a,inAF3 b){d[0]=AMaxF1(a[0],b[0]);d[1]=AMaxF1(a[1],b[1]);d[2]=AMaxF1(a[2],b[2]);return d;} + A_STATIC retAF4 opAMaxF4(outAF4 d,inAF4 a,inAF4 b){d[0]=AMaxF1(a[0],b[0]);d[1]=AMaxF1(a[1],b[1]);d[2]=AMaxF1(a[2],b[2]);d[3]=AMaxF1(a[3],b[3]);return d;} +//============================================================================================================================== + A_STATIC retAD2 opAMinD2(outAD2 d,inAD2 a,inAD2 b){d[0]=AMinD1(a[0],b[0]);d[1]=AMinD1(a[1],b[1]);return d;} + A_STATIC retAD3 opAMinD3(outAD3 d,inAD3 a,inAD3 b){d[0]=AMinD1(a[0],b[0]);d[1]=AMinD1(a[1],b[1]);d[2]=AMinD1(a[2],b[2]);return d;} + A_STATIC retAD4 opAMinD4(outAD4 d,inAD4 a,inAD4 b){d[0]=AMinD1(a[0],b[0]);d[1]=AMinD1(a[1],b[1]);d[2]=AMinD1(a[2],b[2]);d[3]=AMinD1(a[3],b[3]);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC retAF2 opAMinF2(outAF2 d,inAF2 a,inAF2 b){d[0]=AMinF1(a[0],b[0]);d[1]=AMinF1(a[1],b[1]);return d;} + A_STATIC retAF3 opAMinF3(outAF3 d,inAF3 a,inAF3 b){d[0]=AMinF1(a[0],b[0]);d[1]=AMinF1(a[1],b[1]);d[2]=AMinF1(a[2],b[2]);return d;} + A_STATIC retAF4 opAMinF4(outAF4 d,inAF4 a,inAF4 b){d[0]=AMinF1(a[0],b[0]);d[1]=AMinF1(a[1],b[1]);d[2]=AMinF1(a[2],b[2]);d[3]=AMinF1(a[3],b[3]);return d;} +//============================================================================================================================== + A_STATIC retAD2 opAMulD2(outAD2 d,inAD2 a,inAD2 b){d[0]=a[0]*b[0];d[1]=a[1]*b[1];return d;} + A_STATIC retAD3 opAMulD3(outAD3 d,inAD3 a,inAD3 b){d[0]=a[0]*b[0];d[1]=a[1]*b[1];d[2]=a[2]*b[2];return d;} + A_STATIC retAD4 opAMulD4(outAD4 d,inAD4 a,inAD4 b){d[0]=a[0]*b[0];d[1]=a[1]*b[1];d[2]=a[2]*b[2];d[3]=a[3]*b[3];return d;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC retAF2 opAMulF2(outAF2 d,inAF2 a,inAF2 b){d[0]=a[0]*b[0];d[1]=a[1]*b[1];return d;} + A_STATIC retAF3 opAMulF3(outAF3 d,inAF3 a,inAF3 b){d[0]=a[0]*b[0];d[1]=a[1]*b[1];d[2]=a[2]*b[2];return d;} + A_STATIC retAF4 opAMulF4(outAF4 d,inAF4 a,inAF4 b){d[0]=a[0]*b[0];d[1]=a[1]*b[1];d[2]=a[2]*b[2];d[3]=a[3]*b[3];return d;} +//============================================================================================================================== + A_STATIC retAD2 opAMulOneD2(outAD2 d,inAD2 a,AD1 b){d[0]=a[0]*b;d[1]=a[1]*b;return d;} + A_STATIC retAD3 opAMulOneD3(outAD3 d,inAD3 a,AD1 b){d[0]=a[0]*b;d[1]=a[1]*b;d[2]=a[2]*b;return d;} + A_STATIC retAD4 opAMulOneD4(outAD4 d,inAD4 a,AD1 b){d[0]=a[0]*b;d[1]=a[1]*b;d[2]=a[2]*b;d[3]=a[3]*b;return d;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC retAF2 opAMulOneF2(outAF2 d,inAF2 a,AF1 b){d[0]=a[0]*b;d[1]=a[1]*b;return d;} + A_STATIC retAF3 opAMulOneF3(outAF3 d,inAF3 a,AF1 b){d[0]=a[0]*b;d[1]=a[1]*b;d[2]=a[2]*b;return d;} + A_STATIC retAF4 opAMulOneF4(outAF4 d,inAF4 a,AF1 b){d[0]=a[0]*b;d[1]=a[1]*b;d[2]=a[2]*b;d[3]=a[3]*b;return d;} +//============================================================================================================================== + A_STATIC retAD2 opANegD2(outAD2 d,inAD2 a){d[0]=-a[0];d[1]=-a[1];return d;} + A_STATIC retAD3 opANegD3(outAD3 d,inAD3 a){d[0]=-a[0];d[1]=-a[1];d[2]=-a[2];return d;} + A_STATIC retAD4 opANegD4(outAD4 d,inAD4 a){d[0]=-a[0];d[1]=-a[1];d[2]=-a[2];d[3]=-a[3];return d;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC retAF2 opANegF2(outAF2 d,inAF2 a){d[0]=-a[0];d[1]=-a[1];return d;} + A_STATIC retAF3 opANegF3(outAF3 d,inAF3 a){d[0]=-a[0];d[1]=-a[1];d[2]=-a[2];return d;} + A_STATIC retAF4 opANegF4(outAF4 d,inAF4 a){d[0]=-a[0];d[1]=-a[1];d[2]=-a[2];d[3]=-a[3];return d;} +//============================================================================================================================== + A_STATIC retAD2 opARcpD2(outAD2 d,inAD2 a){d[0]=ARcpD1(a[0]);d[1]=ARcpD1(a[1]);return d;} + A_STATIC retAD3 opARcpD3(outAD3 d,inAD3 a){d[0]=ARcpD1(a[0]);d[1]=ARcpD1(a[1]);d[2]=ARcpD1(a[2]);return d;} + A_STATIC retAD4 opARcpD4(outAD4 d,inAD4 a){d[0]=ARcpD1(a[0]);d[1]=ARcpD1(a[1]);d[2]=ARcpD1(a[2]);d[3]=ARcpD1(a[3]);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC retAF2 opARcpF2(outAF2 d,inAF2 a){d[0]=ARcpF1(a[0]);d[1]=ARcpF1(a[1]);return d;} + A_STATIC retAF3 opARcpF3(outAF3 d,inAF3 a){d[0]=ARcpF1(a[0]);d[1]=ARcpF1(a[1]);d[2]=ARcpF1(a[2]);return d;} + A_STATIC retAF4 opARcpF4(outAF4 d,inAF4 a){d[0]=ARcpF1(a[0]);d[1]=ARcpF1(a[1]);d[2]=ARcpF1(a[2]);d[3]=ARcpF1(a[3]);return d;} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// HALF FLOAT PACKING +//============================================================================================================================== + // Convert float to half (in lower 16-bits of output). + // Same fast technique as documented here: ftp://ftp.fox-toolkit.org/pub/fasthalffloatconversion.pdf + // Supports denormals. + // Conversion rules are to make computations possibly "safer" on the GPU, + // -INF & -NaN -> -65504 + // +INF & +NaN -> +65504 + A_STATIC AU1 AU1_AH1_AF1(AF1 f){ + static AW1 base[512]={ + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080,0x0100, + 0x0200,0x0400,0x0800,0x0c00,0x1000,0x1400,0x1800,0x1c00,0x2000,0x2400,0x2800,0x2c00,0x3000,0x3400,0x3800,0x3c00, + 0x4000,0x4400,0x4800,0x4c00,0x5000,0x5400,0x5800,0x5c00,0x6000,0x6400,0x6800,0x6c00,0x7000,0x7400,0x7800,0x7bff, + 0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff, + 0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff, + 0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff, + 0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff, + 0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff, + 0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff, + 0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff, + 0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000, + 0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000, + 0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000, + 0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000, + 0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000, + 0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000, + 0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8001,0x8002,0x8004,0x8008,0x8010,0x8020,0x8040,0x8080,0x8100, + 0x8200,0x8400,0x8800,0x8c00,0x9000,0x9400,0x9800,0x9c00,0xa000,0xa400,0xa800,0xac00,0xb000,0xb400,0xb800,0xbc00, + 0xc000,0xc400,0xc800,0xcc00,0xd000,0xd400,0xd800,0xdc00,0xe000,0xe400,0xe800,0xec00,0xf000,0xf400,0xf800,0xfbff, + 0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff, + 0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff, + 0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff, + 0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff, + 0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff, + 0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff, + 0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff}; + static AB1 shift[512]={ + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x17,0x16,0x15,0x14,0x13,0x12,0x11,0x10,0x0f, + 0x0e,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d, + 0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x17,0x16,0x15,0x14,0x13,0x12,0x11,0x10,0x0f, + 0x0e,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d, + 0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18}; + union{AF1 f;AU1 u;}bits;bits.f=f;AU1 u=bits.u;AU1 i=u>>23;return (AU1)(base[i])+((u&0x7fffff)>>shift[i]);} +//------------------------------------------------------------------------------------------------------------------------------ + // Used to output packed constant. + A_STATIC AU1 AU1_AH2_AF2(inAF2 a){return AU1_AH1_AF1(a[0])+(AU1_AH1_AF1(a[1])<<16);} +#endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// +// +// GLSL +// +// +//============================================================================================================================== +#if defined(A_GLSL) && defined(A_GPU) + #ifndef A_SKIP_EXT + #ifdef A_HALF + #extension GL_EXT_shader_16bit_storage:require + #extension GL_EXT_shader_explicit_arithmetic_types:require + #endif +//------------------------------------------------------------------------------------------------------------------------------ + #ifdef A_LONG + #extension GL_ARB_gpu_shader_int64:require + #extension GL_NV_shader_atomic_int64:require + #endif +//------------------------------------------------------------------------------------------------------------------------------ + #ifdef A_WAVE + #extension GL_KHR_shader_subgroup_arithmetic:require + #extension GL_KHR_shader_subgroup_ballot:require + #extension GL_KHR_shader_subgroup_quad:require + #extension GL_KHR_shader_subgroup_shuffle:require + #endif + #endif +//============================================================================================================================== + #define AP1 bool + #define AP2 bvec2 + #define AP3 bvec3 + #define AP4 bvec4 +//------------------------------------------------------------------------------------------------------------------------------ + #define AF1 float + #define AF2 vec2 + #define AF3 vec3 + #define AF4 vec4 +//------------------------------------------------------------------------------------------------------------------------------ + #define AU1 uint + #define AU2 uvec2 + #define AU3 uvec3 + #define AU4 uvec4 +//------------------------------------------------------------------------------------------------------------------------------ + #define ASU1 int + #define ASU2 ivec2 + #define ASU3 ivec3 + #define ASU4 ivec4 +//============================================================================================================================== + #define AF1_AU1(x) uintBitsToFloat(AU1(x)) + #define AF2_AU2(x) uintBitsToFloat(AU2(x)) + #define AF3_AU3(x) uintBitsToFloat(AU3(x)) + #define AF4_AU4(x) uintBitsToFloat(AU4(x)) +//------------------------------------------------------------------------------------------------------------------------------ + #define AU1_AF1(x) floatBitsToUint(AF1(x)) + #define AU2_AF2(x) floatBitsToUint(AF2(x)) + #define AU3_AF3(x) floatBitsToUint(AF3(x)) + #define AU4_AF4(x) floatBitsToUint(AF4(x)) +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AU1_AH1_AF1_x(AF1 a){return packHalf2x16(AF2(a,0.0));} + #define AU1_AH1_AF1(a) AU1_AH1_AF1_x(AF1(a)) +//------------------------------------------------------------------------------------------------------------------------------ + #define AU1_AH2_AF2 packHalf2x16 + #define AU1_AW2Unorm_AF2 packUnorm2x16 + #define AU1_AB4Unorm_AF4 packUnorm4x8 +//------------------------------------------------------------------------------------------------------------------------------ + #define AF2_AH2_AU1 unpackHalf2x16 + #define AF2_AW2Unorm_AU1 unpackUnorm2x16 + #define AF4_AB4Unorm_AU1 unpackUnorm4x8 +//============================================================================================================================== + AF1 AF1_x(AF1 a){return AF1(a);} + AF2 AF2_x(AF1 a){return AF2(a,a);} + AF3 AF3_x(AF1 a){return AF3(a,a,a);} + AF4 AF4_x(AF1 a){return AF4(a,a,a,a);} + #define AF1_(a) AF1_x(AF1(a)) + #define AF2_(a) AF2_x(AF1(a)) + #define AF3_(a) AF3_x(AF1(a)) + #define AF4_(a) AF4_x(AF1(a)) +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AU1_x(AU1 a){return AU1(a);} + AU2 AU2_x(AU1 a){return AU2(a,a);} + AU3 AU3_x(AU1 a){return AU3(a,a,a);} + AU4 AU4_x(AU1 a){return AU4(a,a,a,a);} + #define AU1_(a) AU1_x(AU1(a)) + #define AU2_(a) AU2_x(AU1(a)) + #define AU3_(a) AU3_x(AU1(a)) + #define AU4_(a) AU4_x(AU1(a)) +//============================================================================================================================== + AU1 AAbsSU1(AU1 a){return AU1(abs(ASU1(a)));} + AU2 AAbsSU2(AU2 a){return AU2(abs(ASU2(a)));} + AU3 AAbsSU3(AU3 a){return AU3(abs(ASU3(a)));} + AU4 AAbsSU4(AU4 a){return AU4(abs(ASU4(a)));} +//------------------------------------------------------------------------------------------------------------------------------ + AU1 ABfe(AU1 src,AU1 off,AU1 bits){return bitfieldExtract(src,ASU1(off),ASU1(bits));} + AU1 ABfi(AU1 src,AU1 ins,AU1 mask){return (ins&mask)|(src&(~mask));} + // Proxy for V_BFI_B32 where the 'mask' is set as 'bits', 'mask=(1<>ASU1(b));} + AU2 AShrSU2(AU2 a,AU2 b){return AU2(ASU2(a)>>ASU2(b));} + AU3 AShrSU3(AU3 a,AU3 b){return AU3(ASU3(a)>>ASU3(b));} + AU4 AShrSU4(AU4 a,AU4 b){return AU4(ASU4(a)>>ASU4(b));} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// GLSL BYTE +//============================================================================================================================== + #ifdef A_BYTE + #define AB1 uint8_t + #define AB2 u8vec2 + #define AB3 u8vec3 + #define AB4 u8vec4 +//------------------------------------------------------------------------------------------------------------------------------ + #define ASB1 int8_t + #define ASB2 i8vec2 + #define ASB3 i8vec3 + #define ASB4 i8vec4 +//------------------------------------------------------------------------------------------------------------------------------ + AB1 AB1_x(AB1 a){return AB1(a);} + AB2 AB2_x(AB1 a){return AB2(a,a);} + AB3 AB3_x(AB1 a){return AB3(a,a,a);} + AB4 AB4_x(AB1 a){return AB4(a,a,a,a);} + #define AB1_(a) AB1_x(AB1(a)) + #define AB2_(a) AB2_x(AB1(a)) + #define AB3_(a) AB3_x(AB1(a)) + #define AB4_(a) AB4_x(AB1(a)) + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// GLSL HALF +//============================================================================================================================== + #ifdef A_HALF + #define AH1 float16_t + #define AH2 f16vec2 + #define AH3 f16vec3 + #define AH4 f16vec4 +//------------------------------------------------------------------------------------------------------------------------------ + #define AW1 uint16_t + #define AW2 u16vec2 + #define AW3 u16vec3 + #define AW4 u16vec4 +//------------------------------------------------------------------------------------------------------------------------------ + #define ASW1 int16_t + #define ASW2 i16vec2 + #define ASW3 i16vec3 + #define ASW4 i16vec4 +//============================================================================================================================== + #define AH2_AU1(x) unpackFloat2x16(AU1(x)) + AH4 AH4_AU2_x(AU2 x){return AH4(unpackFloat2x16(x.x),unpackFloat2x16(x.y));} + #define AH4_AU2(x) AH4_AU2_x(AU2(x)) + #define AW2_AU1(x) unpackUint2x16(AU1(x)) + #define AW4_AU2(x) unpackUint4x16(pack64(AU2(x))) +//------------------------------------------------------------------------------------------------------------------------------ + #define AU1_AH2(x) packFloat2x16(AH2(x)) + AU2 AU2_AH4_x(AH4 x){return AU2(packFloat2x16(x.xy),packFloat2x16(x.zw));} + #define AU2_AH4(x) AU2_AH4_x(AH4(x)) + #define AU1_AW2(x) packUint2x16(AW2(x)) + #define AU2_AW4(x) unpack32(packUint4x16(AW4(x))) +//============================================================================================================================== + #define AW1_AH1(x) halfBitsToUint16(AH1(x)) + #define AW2_AH2(x) halfBitsToUint16(AH2(x)) + #define AW3_AH3(x) halfBitsToUint16(AH3(x)) + #define AW4_AH4(x) halfBitsToUint16(AH4(x)) +//------------------------------------------------------------------------------------------------------------------------------ + #define AH1_AW1(x) uint16BitsToHalf(AW1(x)) + #define AH2_AW2(x) uint16BitsToHalf(AW2(x)) + #define AH3_AW3(x) uint16BitsToHalf(AW3(x)) + #define AH4_AW4(x) uint16BitsToHalf(AW4(x)) +//============================================================================================================================== + AH1 AH1_x(AH1 a){return AH1(a);} + AH2 AH2_x(AH1 a){return AH2(a,a);} + AH3 AH3_x(AH1 a){return AH3(a,a,a);} + AH4 AH4_x(AH1 a){return AH4(a,a,a,a);} + #define AH1_(a) AH1_x(AH1(a)) + #define AH2_(a) AH2_x(AH1(a)) + #define AH3_(a) AH3_x(AH1(a)) + #define AH4_(a) AH4_x(AH1(a)) +//------------------------------------------------------------------------------------------------------------------------------ + AW1 AW1_x(AW1 a){return AW1(a);} + AW2 AW2_x(AW1 a){return AW2(a,a);} + AW3 AW3_x(AW1 a){return AW3(a,a,a);} + AW4 AW4_x(AW1 a){return AW4(a,a,a,a);} + #define AW1_(a) AW1_x(AW1(a)) + #define AW2_(a) AW2_x(AW1(a)) + #define AW3_(a) AW3_x(AW1(a)) + #define AW4_(a) AW4_x(AW1(a)) +//============================================================================================================================== + AW1 AAbsSW1(AW1 a){return AW1(abs(ASW1(a)));} + AW2 AAbsSW2(AW2 a){return AW2(abs(ASW2(a)));} + AW3 AAbsSW3(AW3 a){return AW3(abs(ASW3(a)));} + AW4 AAbsSW4(AW4 a){return AW4(abs(ASW4(a)));} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AClampH1(AH1 x,AH1 n,AH1 m){return clamp(x,n,m);} + AH2 AClampH2(AH2 x,AH2 n,AH2 m){return clamp(x,n,m);} + AH3 AClampH3(AH3 x,AH3 n,AH3 m){return clamp(x,n,m);} + AH4 AClampH4(AH4 x,AH4 n,AH4 m){return clamp(x,n,m);} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AFractH1(AH1 x){return fract(x);} + AH2 AFractH2(AH2 x){return fract(x);} + AH3 AFractH3(AH3 x){return fract(x);} + AH4 AFractH4(AH4 x){return fract(x);} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 ALerpH1(AH1 x,AH1 y,AH1 a){return mix(x,y,a);} + AH2 ALerpH2(AH2 x,AH2 y,AH2 a){return mix(x,y,a);} + AH3 ALerpH3(AH3 x,AH3 y,AH3 a){return mix(x,y,a);} + AH4 ALerpH4(AH4 x,AH4 y,AH4 a){return mix(x,y,a);} +//------------------------------------------------------------------------------------------------------------------------------ + // No packed version of max3. + AH1 AMax3H1(AH1 x,AH1 y,AH1 z){return max(x,max(y,z));} + AH2 AMax3H2(AH2 x,AH2 y,AH2 z){return max(x,max(y,z));} + AH3 AMax3H3(AH3 x,AH3 y,AH3 z){return max(x,max(y,z));} + AH4 AMax3H4(AH4 x,AH4 y,AH4 z){return max(x,max(y,z));} +//------------------------------------------------------------------------------------------------------------------------------ + AW1 AMaxSW1(AW1 a,AW1 b){return AW1(max(ASU1(a),ASU1(b)));} + AW2 AMaxSW2(AW2 a,AW2 b){return AW2(max(ASU2(a),ASU2(b)));} + AW3 AMaxSW3(AW3 a,AW3 b){return AW3(max(ASU3(a),ASU3(b)));} + AW4 AMaxSW4(AW4 a,AW4 b){return AW4(max(ASU4(a),ASU4(b)));} +//------------------------------------------------------------------------------------------------------------------------------ + // No packed version of min3. + AH1 AMin3H1(AH1 x,AH1 y,AH1 z){return min(x,min(y,z));} + AH2 AMin3H2(AH2 x,AH2 y,AH2 z){return min(x,min(y,z));} + AH3 AMin3H3(AH3 x,AH3 y,AH3 z){return min(x,min(y,z));} + AH4 AMin3H4(AH4 x,AH4 y,AH4 z){return min(x,min(y,z));} +//------------------------------------------------------------------------------------------------------------------------------ + AW1 AMinSW1(AW1 a,AW1 b){return AW1(min(ASU1(a),ASU1(b)));} + AW2 AMinSW2(AW2 a,AW2 b){return AW2(min(ASU2(a),ASU2(b)));} + AW3 AMinSW3(AW3 a,AW3 b){return AW3(min(ASU3(a),ASU3(b)));} + AW4 AMinSW4(AW4 a,AW4 b){return AW4(min(ASU4(a),ASU4(b)));} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 ARcpH1(AH1 x){return AH1_(1.0)/x;} + AH2 ARcpH2(AH2 x){return AH2_(1.0)/x;} + AH3 ARcpH3(AH3 x){return AH3_(1.0)/x;} + AH4 ARcpH4(AH4 x){return AH4_(1.0)/x;} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 ARsqH1(AH1 x){return AH1_(1.0)/sqrt(x);} + AH2 ARsqH2(AH2 x){return AH2_(1.0)/sqrt(x);} + AH3 ARsqH3(AH3 x){return AH3_(1.0)/sqrt(x);} + AH4 ARsqH4(AH4 x){return AH4_(1.0)/sqrt(x);} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 ASatH1(AH1 x){return clamp(x,AH1_(0.0),AH1_(1.0));} + AH2 ASatH2(AH2 x){return clamp(x,AH2_(0.0),AH2_(1.0));} + AH3 ASatH3(AH3 x){return clamp(x,AH3_(0.0),AH3_(1.0));} + AH4 ASatH4(AH4 x){return clamp(x,AH4_(0.0),AH4_(1.0));} +//------------------------------------------------------------------------------------------------------------------------------ + AW1 AShrSW1(AW1 a,AW1 b){return AW1(ASW1(a)>>ASW1(b));} + AW2 AShrSW2(AW2 a,AW2 b){return AW2(ASW2(a)>>ASW2(b));} + AW3 AShrSW3(AW3 a,AW3 b){return AW3(ASW3(a)>>ASW3(b));} + AW4 AShrSW4(AW4 a,AW4 b){return AW4(ASW4(a)>>ASW4(b));} + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// GLSL DOUBLE +//============================================================================================================================== + #ifdef A_DUBL + #define AD1 double + #define AD2 dvec2 + #define AD3 dvec3 + #define AD4 dvec4 +//------------------------------------------------------------------------------------------------------------------------------ + AD1 AD1_x(AD1 a){return AD1(a);} + AD2 AD2_x(AD1 a){return AD2(a,a);} + AD3 AD3_x(AD1 a){return AD3(a,a,a);} + AD4 AD4_x(AD1 a){return AD4(a,a,a,a);} + #define AD1_(a) AD1_x(AD1(a)) + #define AD2_(a) AD2_x(AD1(a)) + #define AD3_(a) AD3_x(AD1(a)) + #define AD4_(a) AD4_x(AD1(a)) +//============================================================================================================================== + AD1 AFractD1(AD1 x){return fract(x);} + AD2 AFractD2(AD2 x){return fract(x);} + AD3 AFractD3(AD3 x){return fract(x);} + AD4 AFractD4(AD4 x){return fract(x);} +//------------------------------------------------------------------------------------------------------------------------------ + AD1 ALerpD1(AD1 x,AD1 y,AD1 a){return mix(x,y,a);} + AD2 ALerpD2(AD2 x,AD2 y,AD2 a){return mix(x,y,a);} + AD3 ALerpD3(AD3 x,AD3 y,AD3 a){return mix(x,y,a);} + AD4 ALerpD4(AD4 x,AD4 y,AD4 a){return mix(x,y,a);} +//------------------------------------------------------------------------------------------------------------------------------ + AD1 ARcpD1(AD1 x){return AD1_(1.0)/x;} + AD2 ARcpD2(AD2 x){return AD2_(1.0)/x;} + AD3 ARcpD3(AD3 x){return AD3_(1.0)/x;} + AD4 ARcpD4(AD4 x){return AD4_(1.0)/x;} +//------------------------------------------------------------------------------------------------------------------------------ + AD1 ARsqD1(AD1 x){return AD1_(1.0)/sqrt(x);} + AD2 ARsqD2(AD2 x){return AD2_(1.0)/sqrt(x);} + AD3 ARsqD3(AD3 x){return AD3_(1.0)/sqrt(x);} + AD4 ARsqD4(AD4 x){return AD4_(1.0)/sqrt(x);} +//------------------------------------------------------------------------------------------------------------------------------ + AD1 ASatD1(AD1 x){return clamp(x,AD1_(0.0),AD1_(1.0));} + AD2 ASatD2(AD2 x){return clamp(x,AD2_(0.0),AD2_(1.0));} + AD3 ASatD3(AD3 x){return clamp(x,AD3_(0.0),AD3_(1.0));} + AD4 ASatD4(AD4 x){return clamp(x,AD4_(0.0),AD4_(1.0));} + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// GLSL LONG +//============================================================================================================================== + #ifdef A_LONG + #define AL1 uint64_t + #define AL2 u64vec2 + #define AL3 u64vec3 + #define AL4 u64vec4 +//------------------------------------------------------------------------------------------------------------------------------ + #define ASL1 int64_t + #define ASL2 i64vec2 + #define ASL3 i64vec3 + #define ASL4 i64vec4 +//------------------------------------------------------------------------------------------------------------------------------ + #define AL1_AU2(x) packUint2x32(AU2(x)) + #define AU2_AL1(x) unpackUint2x32(AL1(x)) +//------------------------------------------------------------------------------------------------------------------------------ + AL1 AL1_x(AL1 a){return AL1(a);} + AL2 AL2_x(AL1 a){return AL2(a,a);} + AL3 AL3_x(AL1 a){return AL3(a,a,a);} + AL4 AL4_x(AL1 a){return AL4(a,a,a,a);} + #define AL1_(a) AL1_x(AL1(a)) + #define AL2_(a) AL2_x(AL1(a)) + #define AL3_(a) AL3_x(AL1(a)) + #define AL4_(a) AL4_x(AL1(a)) +//============================================================================================================================== + AL1 AAbsSL1(AL1 a){return AL1(abs(ASL1(a)));} + AL2 AAbsSL2(AL2 a){return AL2(abs(ASL2(a)));} + AL3 AAbsSL3(AL3 a){return AL3(abs(ASL3(a)));} + AL4 AAbsSL4(AL4 a){return AL4(abs(ASL4(a)));} +//------------------------------------------------------------------------------------------------------------------------------ + AL1 AMaxSL1(AL1 a,AL1 b){return AL1(max(ASU1(a),ASU1(b)));} + AL2 AMaxSL2(AL2 a,AL2 b){return AL2(max(ASU2(a),ASU2(b)));} + AL3 AMaxSL3(AL3 a,AL3 b){return AL3(max(ASU3(a),ASU3(b)));} + AL4 AMaxSL4(AL4 a,AL4 b){return AL4(max(ASU4(a),ASU4(b)));} +//------------------------------------------------------------------------------------------------------------------------------ + AL1 AMinSL1(AL1 a,AL1 b){return AL1(min(ASU1(a),ASU1(b)));} + AL2 AMinSL2(AL2 a,AL2 b){return AL2(min(ASU2(a),ASU2(b)));} + AL3 AMinSL3(AL3 a,AL3 b){return AL3(min(ASU3(a),ASU3(b)));} + AL4 AMinSL4(AL4 a,AL4 b){return AL4(min(ASU4(a),ASU4(b)));} + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// WAVE OPERATIONS +//============================================================================================================================== + #ifdef A_WAVE + // Where 'x' must be a compile time literal. + AF1 AWaveXorF1(AF1 v,AU1 x){return subgroupShuffleXor(v,x);} + AF2 AWaveXorF2(AF2 v,AU1 x){return subgroupShuffleXor(v,x);} + AF3 AWaveXorF3(AF3 v,AU1 x){return subgroupShuffleXor(v,x);} + AF4 AWaveXorF4(AF4 v,AU1 x){return subgroupShuffleXor(v,x);} + AU1 AWaveXorU1(AU1 v,AU1 x){return subgroupShuffleXor(v,x);} + AU2 AWaveXorU2(AU2 v,AU1 x){return subgroupShuffleXor(v,x);} + AU3 AWaveXorU3(AU3 v,AU1 x){return subgroupShuffleXor(v,x);} + AU4 AWaveXorU4(AU4 v,AU1 x){return subgroupShuffleXor(v,x);} +//------------------------------------------------------------------------------------------------------------------------------ + #ifdef A_HALF + AH2 AWaveXorH2(AH2 v,AU1 x){return AH2_AU1(subgroupShuffleXor(AU1_AH2(v),x));} + AH4 AWaveXorH4(AH4 v,AU1 x){return AH4_AU2(subgroupShuffleXor(AU2_AH4(v),x));} + AW2 AWaveXorW2(AW2 v,AU1 x){return AW2_AU1(subgroupShuffleXor(AU1_AW2(v),x));} + AW4 AWaveXorW4(AW4 v,AU1 x){return AW4_AU2(subgroupShuffleXor(AU2_AW4(v),x));} + #endif + #endif +//============================================================================================================================== +#endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// +// +// HLSL +// +// +//============================================================================================================================== +#if defined(A_HLSL) && defined(A_GPU) + #ifdef A_HLSL_6_2 + #define AP1 bool + #define AP2 bool2 + #define AP3 bool3 + #define AP4 bool4 +//------------------------------------------------------------------------------------------------------------------------------ + #define AF1 float32_t + #define AF2 float32_t2 + #define AF3 float32_t3 + #define AF4 float32_t4 +//------------------------------------------------------------------------------------------------------------------------------ + #define AU1 uint32_t + #define AU2 uint32_t2 + #define AU3 uint32_t3 + #define AU4 uint32_t4 +//------------------------------------------------------------------------------------------------------------------------------ + #define ASU1 int32_t + #define ASU2 int32_t2 + #define ASU3 int32_t3 + #define ASU4 int32_t4 + #else + #define AP1 bool + #define AP2 bool2 + #define AP3 bool3 + #define AP4 bool4 +//------------------------------------------------------------------------------------------------------------------------------ + #define AF1 float + #define AF2 float2 + #define AF3 float3 + #define AF4 float4 +//------------------------------------------------------------------------------------------------------------------------------ + #define AU1 uint + #define AU2 uint2 + #define AU3 uint3 + #define AU4 uint4 +//------------------------------------------------------------------------------------------------------------------------------ + #define ASU1 int + #define ASU2 int2 + #define ASU3 int3 + #define ASU4 int4 + #endif +//============================================================================================================================== + #define AF1_AU1(x) asfloat(AU1(x)) + #define AF2_AU2(x) asfloat(AU2(x)) + #define AF3_AU3(x) asfloat(AU3(x)) + #define AF4_AU4(x) asfloat(AU4(x)) +//------------------------------------------------------------------------------------------------------------------------------ + #define AU1_AF1(x) asuint(AF1(x)) + #define AU2_AF2(x) asuint(AF2(x)) + #define AU3_AF3(x) asuint(AF3(x)) + #define AU4_AF4(x) asuint(AF4(x)) +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AU1_AH1_AF1_x(AF1 a){return f32tof16(a);} + #define AU1_AH1_AF1(a) AU1_AH1_AF1_x(AF1(a)) +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AU1_AH2_AF2_x(AF2 a){return f32tof16(a.x)|(f32tof16(a.y)<<16);} + #define AU1_AH2_AF2(a) AU1_AH2_AF2_x(AF2(a)) + #define AU1_AB4Unorm_AF4(x) D3DCOLORtoUBYTE4(AF4(x)) +//------------------------------------------------------------------------------------------------------------------------------ + AF2 AF2_AH2_AU1_x(AU1 x){return AF2(f16tof32(x&0xFFFF),f16tof32(x>>16));} + #define AF2_AH2_AU1(x) AF2_AH2_AU1_x(AU1(x)) +//============================================================================================================================== + AF1 AF1_x(AF1 a){return AF1(a);} + AF2 AF2_x(AF1 a){return AF2(a,a);} + AF3 AF3_x(AF1 a){return AF3(a,a,a);} + AF4 AF4_x(AF1 a){return AF4(a,a,a,a);} + #define AF1_(a) AF1_x(AF1(a)) + #define AF2_(a) AF2_x(AF1(a)) + #define AF3_(a) AF3_x(AF1(a)) + #define AF4_(a) AF4_x(AF1(a)) +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AU1_x(AU1 a){return AU1(a);} + AU2 AU2_x(AU1 a){return AU2(a,a);} + AU3 AU3_x(AU1 a){return AU3(a,a,a);} + AU4 AU4_x(AU1 a){return AU4(a,a,a,a);} + #define AU1_(a) AU1_x(AU1(a)) + #define AU2_(a) AU2_x(AU1(a)) + #define AU3_(a) AU3_x(AU1(a)) + #define AU4_(a) AU4_x(AU1(a)) +//============================================================================================================================== + AU1 AAbsSU1(AU1 a){return AU1(abs(ASU1(a)));} + AU2 AAbsSU2(AU2 a){return AU2(abs(ASU2(a)));} + AU3 AAbsSU3(AU3 a){return AU3(abs(ASU3(a)));} + AU4 AAbsSU4(AU4 a){return AU4(abs(ASU4(a)));} +//------------------------------------------------------------------------------------------------------------------------------ + AU1 ABfe(AU1 src,AU1 off,AU1 bits){AU1 mask=(1u<>off)&mask;} + AU1 ABfi(AU1 src,AU1 ins,AU1 mask){return (ins&mask)|(src&(~mask));} + AU1 ABfiM(AU1 src,AU1 ins,AU1 bits){AU1 mask=(1u<>ASU1(b));} + AU2 AShrSU2(AU2 a,AU2 b){return AU2(ASU2(a)>>ASU2(b));} + AU3 AShrSU3(AU3 a,AU3 b){return AU3(ASU3(a)>>ASU3(b));} + AU4 AShrSU4(AU4 a,AU4 b){return AU4(ASU4(a)>>ASU4(b));} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// HLSL BYTE +//============================================================================================================================== + #ifdef A_BYTE + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// HLSL HALF +//============================================================================================================================== + #ifdef A_HALF + #ifdef A_HLSL_6_2 + #define AH1 float16_t + #define AH2 float16_t2 + #define AH3 float16_t3 + #define AH4 float16_t4 +//------------------------------------------------------------------------------------------------------------------------------ + #define AW1 uint16_t + #define AW2 uint16_t2 + #define AW3 uint16_t3 + #define AW4 uint16_t4 +//------------------------------------------------------------------------------------------------------------------------------ + #define ASW1 int16_t + #define ASW2 int16_t2 + #define ASW3 int16_t3 + #define ASW4 int16_t4 + #else + #define AH1 min16float + #define AH2 min16float2 + #define AH3 min16float3 + #define AH4 min16float4 +//------------------------------------------------------------------------------------------------------------------------------ + #define AW1 min16uint + #define AW2 min16uint2 + #define AW3 min16uint3 + #define AW4 min16uint4 +//------------------------------------------------------------------------------------------------------------------------------ + #define ASW1 min16int + #define ASW2 min16int2 + #define ASW3 min16int3 + #define ASW4 min16int4 + #endif +//============================================================================================================================== + // Need to use manual unpack to get optimal execution (don't use packed types in buffers directly). + // Unpack requires this pattern: https://gpuopen.com/first-steps-implementing-fp16/ + AH2 AH2_AU1_x(AU1 x){AF2 t=f16tof32(AU2(x&0xFFFF,x>>16));return AH2(t);} + AH4 AH4_AU2_x(AU2 x){return AH4(AH2_AU1_x(x.x),AH2_AU1_x(x.y));} + AW2 AW2_AU1_x(AU1 x){AU2 t=AU2(x&0xFFFF,x>>16);return AW2(t);} + AW4 AW4_AU2_x(AU2 x){return AW4(AW2_AU1_x(x.x),AW2_AU1_x(x.y));} + #define AH2_AU1(x) AH2_AU1_x(AU1(x)) + #define AH4_AU2(x) AH4_AU2_x(AU2(x)) + #define AW2_AU1(x) AW2_AU1_x(AU1(x)) + #define AW4_AU2(x) AW4_AU2_x(AU2(x)) +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AU1_AH2_x(AH2 x){return f32tof16(x.x)+(f32tof16(x.y)<<16);} + AU2 AU2_AH4_x(AH4 x){return AU2(AU1_AH2_x(x.xy),AU1_AH2_x(x.zw));} + AU1 AU1_AW2_x(AW2 x){return AU1(x.x)+(AU1(x.y)<<16);} + AU2 AU2_AW4_x(AW4 x){return AU2(AU1_AW2_x(x.xy),AU1_AW2_x(x.zw));} + #define AU1_AH2(x) AU1_AH2_x(AH2(x)) + #define AU2_AH4(x) AU2_AH4_x(AH4(x)) + #define AU1_AW2(x) AU1_AW2_x(AW2(x)) + #define AU2_AW4(x) AU2_AW4_x(AW4(x)) +//============================================================================================================================== + #if defined(A_HLSL_6_2) && !defined(A_NO_16_BIT_CAST) + #define AW1_AH1(x) asuint16(x) + #define AW2_AH2(x) asuint16(x) + #define AW3_AH3(x) asuint16(x) + #define AW4_AH4(x) asuint16(x) + #else + #define AW1_AH1(a) AW1(f32tof16(AF1(a))) + #define AW2_AH2(a) AW2(AW1_AH1((a).x),AW1_AH1((a).y)) + #define AW3_AH3(a) AW3(AW1_AH1((a).x),AW1_AH1((a).y),AW1_AH1((a).z)) + #define AW4_AH4(a) AW4(AW1_AH1((a).x),AW1_AH1((a).y),AW1_AH1((a).z),AW1_AH1((a).w)) + #endif +//------------------------------------------------------------------------------------------------------------------------------ + #if defined(A_HLSL_6_2) && !defined(A_NO_16_BIT_CAST) + #define AH1_AW1(x) asfloat16(x) + #define AH2_AW2(x) asfloat16(x) + #define AH3_AW3(x) asfloat16(x) + #define AH4_AW4(x) asfloat16(x) + #else + #define AH1_AW1(a) AH1(f16tof32(AU1(a))) + #define AH2_AW2(a) AH2(AH1_AW1((a).x),AH1_AW1((a).y)) + #define AH3_AW3(a) AH3(AH1_AW1((a).x),AH1_AW1((a).y),AH1_AW1((a).z)) + #define AH4_AW4(a) AH4(AH1_AW1((a).x),AH1_AW1((a).y),AH1_AW1((a).z),AH1_AW1((a).w)) + #endif +//============================================================================================================================== + AH1 AH1_x(AH1 a){return AH1(a);} + AH2 AH2_x(AH1 a){return AH2(a,a);} + AH3 AH3_x(AH1 a){return AH3(a,a,a);} + AH4 AH4_x(AH1 a){return AH4(a,a,a,a);} + #define AH1_(a) AH1_x(AH1(a)) + #define AH2_(a) AH2_x(AH1(a)) + #define AH3_(a) AH3_x(AH1(a)) + #define AH4_(a) AH4_x(AH1(a)) +//------------------------------------------------------------------------------------------------------------------------------ + AW1 AW1_x(AW1 a){return AW1(a);} + AW2 AW2_x(AW1 a){return AW2(a,a);} + AW3 AW3_x(AW1 a){return AW3(a,a,a);} + AW4 AW4_x(AW1 a){return AW4(a,a,a,a);} + #define AW1_(a) AW1_x(AW1(a)) + #define AW2_(a) AW2_x(AW1(a)) + #define AW3_(a) AW3_x(AW1(a)) + #define AW4_(a) AW4_x(AW1(a)) +//============================================================================================================================== + AW1 AAbsSW1(AW1 a){return AW1(abs(ASW1(a)));} + AW2 AAbsSW2(AW2 a){return AW2(abs(ASW2(a)));} + AW3 AAbsSW3(AW3 a){return AW3(abs(ASW3(a)));} + AW4 AAbsSW4(AW4 a){return AW4(abs(ASW4(a)));} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AClampH1(AH1 x,AH1 n,AH1 m){return max(n,min(x,m));} + AH2 AClampH2(AH2 x,AH2 n,AH2 m){return max(n,min(x,m));} + AH3 AClampH3(AH3 x,AH3 n,AH3 m){return max(n,min(x,m));} + AH4 AClampH4(AH4 x,AH4 n,AH4 m){return max(n,min(x,m));} +//------------------------------------------------------------------------------------------------------------------------------ + // V_FRACT_F16 (note DX frac() is different). + AH1 AFractH1(AH1 x){return x-floor(x);} + AH2 AFractH2(AH2 x){return x-floor(x);} + AH3 AFractH3(AH3 x){return x-floor(x);} + AH4 AFractH4(AH4 x){return x-floor(x);} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 ALerpH1(AH1 x,AH1 y,AH1 a){return lerp(x,y,a);} + AH2 ALerpH2(AH2 x,AH2 y,AH2 a){return lerp(x,y,a);} + AH3 ALerpH3(AH3 x,AH3 y,AH3 a){return lerp(x,y,a);} + AH4 ALerpH4(AH4 x,AH4 y,AH4 a){return lerp(x,y,a);} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AMax3H1(AH1 x,AH1 y,AH1 z){return max(x,max(y,z));} + AH2 AMax3H2(AH2 x,AH2 y,AH2 z){return max(x,max(y,z));} + AH3 AMax3H3(AH3 x,AH3 y,AH3 z){return max(x,max(y,z));} + AH4 AMax3H4(AH4 x,AH4 y,AH4 z){return max(x,max(y,z));} +//------------------------------------------------------------------------------------------------------------------------------ + AW1 AMaxSW1(AW1 a,AW1 b){return AW1(max(ASU1(a),ASU1(b)));} + AW2 AMaxSW2(AW2 a,AW2 b){return AW2(max(ASU2(a),ASU2(b)));} + AW3 AMaxSW3(AW3 a,AW3 b){return AW3(max(ASU3(a),ASU3(b)));} + AW4 AMaxSW4(AW4 a,AW4 b){return AW4(max(ASU4(a),ASU4(b)));} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AMin3H1(AH1 x,AH1 y,AH1 z){return min(x,min(y,z));} + AH2 AMin3H2(AH2 x,AH2 y,AH2 z){return min(x,min(y,z));} + AH3 AMin3H3(AH3 x,AH3 y,AH3 z){return min(x,min(y,z));} + AH4 AMin3H4(AH4 x,AH4 y,AH4 z){return min(x,min(y,z));} +//------------------------------------------------------------------------------------------------------------------------------ + AW1 AMinSW1(AW1 a,AW1 b){return AW1(min(ASU1(a),ASU1(b)));} + AW2 AMinSW2(AW2 a,AW2 b){return AW2(min(ASU2(a),ASU2(b)));} + AW3 AMinSW3(AW3 a,AW3 b){return AW3(min(ASU3(a),ASU3(b)));} + AW4 AMinSW4(AW4 a,AW4 b){return AW4(min(ASU4(a),ASU4(b)));} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 ARcpH1(AH1 x){return rcp(x);} + AH2 ARcpH2(AH2 x){return rcp(x);} + AH3 ARcpH3(AH3 x){return rcp(x);} + AH4 ARcpH4(AH4 x){return rcp(x);} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 ARsqH1(AH1 x){return rsqrt(x);} + AH2 ARsqH2(AH2 x){return rsqrt(x);} + AH3 ARsqH3(AH3 x){return rsqrt(x);} + AH4 ARsqH4(AH4 x){return rsqrt(x);} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 ASatH1(AH1 x){return saturate(x);} + AH2 ASatH2(AH2 x){return saturate(x);} + AH3 ASatH3(AH3 x){return saturate(x);} + AH4 ASatH4(AH4 x){return saturate(x);} +//------------------------------------------------------------------------------------------------------------------------------ + AW1 AShrSW1(AW1 a,AW1 b){return AW1(ASW1(a)>>ASW1(b));} + AW2 AShrSW2(AW2 a,AW2 b){return AW2(ASW2(a)>>ASW2(b));} + AW3 AShrSW3(AW3 a,AW3 b){return AW3(ASW3(a)>>ASW3(b));} + AW4 AShrSW4(AW4 a,AW4 b){return AW4(ASW4(a)>>ASW4(b));} + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// HLSL DOUBLE +//============================================================================================================================== + #ifdef A_DUBL + #ifdef A_HLSL_6_2 + #define AD1 float64_t + #define AD2 float64_t2 + #define AD3 float64_t3 + #define AD4 float64_t4 + #else + #define AD1 double + #define AD2 double2 + #define AD3 double3 + #define AD4 double4 + #endif +//------------------------------------------------------------------------------------------------------------------------------ + AD1 AD1_x(AD1 a){return AD1(a);} + AD2 AD2_x(AD1 a){return AD2(a,a);} + AD3 AD3_x(AD1 a){return AD3(a,a,a);} + AD4 AD4_x(AD1 a){return AD4(a,a,a,a);} + #define AD1_(a) AD1_x(AD1(a)) + #define AD2_(a) AD2_x(AD1(a)) + #define AD3_(a) AD3_x(AD1(a)) + #define AD4_(a) AD4_x(AD1(a)) +//============================================================================================================================== + AD1 AFractD1(AD1 a){return a-floor(a);} + AD2 AFractD2(AD2 a){return a-floor(a);} + AD3 AFractD3(AD3 a){return a-floor(a);} + AD4 AFractD4(AD4 a){return a-floor(a);} +//------------------------------------------------------------------------------------------------------------------------------ + AD1 ALerpD1(AD1 x,AD1 y,AD1 a){return lerp(x,y,a);} + AD2 ALerpD2(AD2 x,AD2 y,AD2 a){return lerp(x,y,a);} + AD3 ALerpD3(AD3 x,AD3 y,AD3 a){return lerp(x,y,a);} + AD4 ALerpD4(AD4 x,AD4 y,AD4 a){return lerp(x,y,a);} +//------------------------------------------------------------------------------------------------------------------------------ + AD1 ARcpD1(AD1 x){return rcp(x);} + AD2 ARcpD2(AD2 x){return rcp(x);} + AD3 ARcpD3(AD3 x){return rcp(x);} + AD4 ARcpD4(AD4 x){return rcp(x);} +//------------------------------------------------------------------------------------------------------------------------------ + AD1 ARsqD1(AD1 x){return rsqrt(x);} + AD2 ARsqD2(AD2 x){return rsqrt(x);} + AD3 ARsqD3(AD3 x){return rsqrt(x);} + AD4 ARsqD4(AD4 x){return rsqrt(x);} +//------------------------------------------------------------------------------------------------------------------------------ + AD1 ASatD1(AD1 x){return saturate(x);} + AD2 ASatD2(AD2 x){return saturate(x);} + AD3 ASatD3(AD3 x){return saturate(x);} + AD4 ASatD4(AD4 x){return saturate(x);} + #endif +//============================================================================================================================== +// HLSL WAVE +//============================================================================================================================== + #ifdef A_WAVE + // Where 'x' must be a compile time literal. + AF1 AWaveXorF1(AF1 v,AU1 x){return WaveReadLaneAt(v,WaveGetLaneIndex()^x);} + AF2 AWaveXorF2(AF2 v,AU1 x){return WaveReadLaneAt(v,WaveGetLaneIndex()^x);} + AF3 AWaveXorF3(AF3 v,AU1 x){return WaveReadLaneAt(v,WaveGetLaneIndex()^x);} + AF4 AWaveXorF4(AF4 v,AU1 x){return WaveReadLaneAt(v,WaveGetLaneIndex()^x);} + AU1 AWaveXorU1(AU1 v,AU1 x){return WaveReadLaneAt(v,WaveGetLaneIndex()^x);} + AU2 AWaveXorU1(AU2 v,AU1 x){return WaveReadLaneAt(v,WaveGetLaneIndex()^x);} + AU3 AWaveXorU1(AU3 v,AU1 x){return WaveReadLaneAt(v,WaveGetLaneIndex()^x);} + AU4 AWaveXorU1(AU4 v,AU1 x){return WaveReadLaneAt(v,WaveGetLaneIndex()^x);} +//------------------------------------------------------------------------------------------------------------------------------ + #ifdef A_HALF + AH2 AWaveXorH2(AH2 v,AU1 x){return AH2_AU1(WaveReadLaneAt(AU1_AH2(v),WaveGetLaneIndex()^x));} + AH4 AWaveXorH4(AH4 v,AU1 x){return AH4_AU2(WaveReadLaneAt(AU2_AH4(v),WaveGetLaneIndex()^x));} + AW2 AWaveXorW2(AW2 v,AU1 x){return AW2_AU1(WaveReadLaneAt(AU1_AW2(v),WaveGetLaneIndex()^x));} + AW4 AWaveXorW4(AW4 v,AU1 x){return AW4_AU1(WaveReadLaneAt(AU1_AW4(v),WaveGetLaneIndex()^x));} + #endif + #endif +//============================================================================================================================== +#endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// +// +// GPU COMMON +// +// +//============================================================================================================================== +#ifdef A_GPU + // Negative and positive infinity. + #define A_INFP_F AF1_AU1(0x7f800000u) + #define A_INFN_F AF1_AU1(0xff800000u) +//------------------------------------------------------------------------------------------------------------------------------ + // Copy sign from 's' to positive 'd'. + AF1 ACpySgnF1(AF1 d,AF1 s){return AF1_AU1(AU1_AF1(d)|(AU1_AF1(s)&AU1_(0x80000000u)));} + AF2 ACpySgnF2(AF2 d,AF2 s){return AF2_AU2(AU2_AF2(d)|(AU2_AF2(s)&AU2_(0x80000000u)));} + AF3 ACpySgnF3(AF3 d,AF3 s){return AF3_AU3(AU3_AF3(d)|(AU3_AF3(s)&AU3_(0x80000000u)));} + AF4 ACpySgnF4(AF4 d,AF4 s){return AF4_AU4(AU4_AF4(d)|(AU4_AF4(s)&AU4_(0x80000000u)));} +//------------------------------------------------------------------------------------------------------------------------------ + // Single operation to return (useful to create a mask to use in lerp for branch free logic), + // m=NaN := 0 + // m>=0 := 0 + // m<0 := 1 + // Uses the following useful floating point logic, + // saturate(+a*(-INF)==-INF) := 0 + // saturate( 0*(-INF)== NaN) := 0 + // saturate(-a*(-INF)==+INF) := 1 + AF1 ASignedF1(AF1 m){return ASatF1(m*AF1_(A_INFN_F));} + AF2 ASignedF2(AF2 m){return ASatF2(m*AF2_(A_INFN_F));} + AF3 ASignedF3(AF3 m){return ASatF3(m*AF3_(A_INFN_F));} + AF4 ASignedF4(AF4 m){return ASatF4(m*AF4_(A_INFN_F));} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AGtZeroF1(AF1 m){return ASatF1(m*AF1_(A_INFP_F));} + AF2 AGtZeroF2(AF2 m){return ASatF2(m*AF2_(A_INFP_F));} + AF3 AGtZeroF3(AF3 m){return ASatF3(m*AF3_(A_INFP_F));} + AF4 AGtZeroF4(AF4 m){return ASatF4(m*AF4_(A_INFP_F));} +//============================================================================================================================== + #ifdef A_HALF + #ifdef A_HLSL_6_2 + #define A_INFP_H AH1_AW1((uint16_t)0x7c00u) + #define A_INFN_H AH1_AW1((uint16_t)0xfc00u) + #else + #define A_INFP_H AH1_AW1(0x7c00u) + #define A_INFN_H AH1_AW1(0xfc00u) + #endif + +//------------------------------------------------------------------------------------------------------------------------------ + AH1 ACpySgnH1(AH1 d,AH1 s){return AH1_AW1(AW1_AH1(d)|(AW1_AH1(s)&AW1_(0x8000u)));} + AH2 ACpySgnH2(AH2 d,AH2 s){return AH2_AW2(AW2_AH2(d)|(AW2_AH2(s)&AW2_(0x8000u)));} + AH3 ACpySgnH3(AH3 d,AH3 s){return AH3_AW3(AW3_AH3(d)|(AW3_AH3(s)&AW3_(0x8000u)));} + AH4 ACpySgnH4(AH4 d,AH4 s){return AH4_AW4(AW4_AH4(d)|(AW4_AH4(s)&AW4_(0x8000u)));} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 ASignedH1(AH1 m){return ASatH1(m*AH1_(A_INFN_H));} + AH2 ASignedH2(AH2 m){return ASatH2(m*AH2_(A_INFN_H));} + AH3 ASignedH3(AH3 m){return ASatH3(m*AH3_(A_INFN_H));} + AH4 ASignedH4(AH4 m){return ASatH4(m*AH4_(A_INFN_H));} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AGtZeroH1(AH1 m){return ASatH1(m*AH1_(A_INFP_H));} + AH2 AGtZeroH2(AH2 m){return ASatH2(m*AH2_(A_INFP_H));} + AH3 AGtZeroH3(AH3 m){return ASatH3(m*AH3_(A_INFP_H));} + AH4 AGtZeroH4(AH4 m){return ASatH4(m*AH4_(A_INFP_H));} + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// [FIS] FLOAT INTEGER SORTABLE +//------------------------------------------------------------------------------------------------------------------------------ +// Float to integer sortable. +// - If sign bit=0, flip the sign bit (positives). +// - If sign bit=1, flip all bits (negatives). +// Integer sortable to float. +// - If sign bit=1, flip the sign bit (positives). +// - If sign bit=0, flip all bits (negatives). +// Has nice side effects. +// - Larger integers are more positive values. +// - Float zero is mapped to center of integers (so clear to integer zero is a nice default for atomic max usage). +// Burns 3 ops for conversion {shift,or,xor}. +//============================================================================================================================== + AU1 AFisToU1(AU1 x){return x^(( AShrSU1(x,AU1_(31)))|AU1_(0x80000000));} + AU1 AFisFromU1(AU1 x){return x^((~AShrSU1(x,AU1_(31)))|AU1_(0x80000000));} +//------------------------------------------------------------------------------------------------------------------------------ + // Just adjust high 16-bit value (useful when upper part of 32-bit word is a 16-bit float value). + AU1 AFisToHiU1(AU1 x){return x^(( AShrSU1(x,AU1_(15)))|AU1_(0x80000000));} + AU1 AFisFromHiU1(AU1 x){return x^((~AShrSU1(x,AU1_(15)))|AU1_(0x80000000));} +//------------------------------------------------------------------------------------------------------------------------------ + #ifdef A_HALF + AW1 AFisToW1(AW1 x){return x^(( AShrSW1(x,AW1_(15)))|AW1_(0x8000));} + AW1 AFisFromW1(AW1 x){return x^((~AShrSW1(x,AW1_(15)))|AW1_(0x8000));} +//------------------------------------------------------------------------------------------------------------------------------ + AW2 AFisToW2(AW2 x){return x^(( AShrSW2(x,AW2_(15)))|AW2_(0x8000));} + AW2 AFisFromW2(AW2 x){return x^((~AShrSW2(x,AW2_(15)))|AW2_(0x8000));} + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// [PERM] V_PERM_B32 +//------------------------------------------------------------------------------------------------------------------------------ +// Support for V_PERM_B32 started in the 3rd generation of GCN. +//------------------------------------------------------------------------------------------------------------------------------ +// yyyyxxxx - The 'i' input. +// 76543210 +// ======== +// HGFEDCBA - Naming on permutation. +//------------------------------------------------------------------------------------------------------------------------------ +// TODO +// ==== +// - Make sure compiler optimizes this. +//============================================================================================================================== + #ifdef A_HALF + AU1 APerm0E0A(AU2 i){return((i.x )&0xffu)|((i.y<<16)&0xff0000u);} + AU1 APerm0F0B(AU2 i){return((i.x>> 8)&0xffu)|((i.y<< 8)&0xff0000u);} + AU1 APerm0G0C(AU2 i){return((i.x>>16)&0xffu)|((i.y )&0xff0000u);} + AU1 APerm0H0D(AU2 i){return((i.x>>24)&0xffu)|((i.y>> 8)&0xff0000u);} +//------------------------------------------------------------------------------------------------------------------------------ + AU1 APermHGFA(AU2 i){return((i.x )&0x000000ffu)|(i.y&0xffffff00u);} + AU1 APermHGFC(AU2 i){return((i.x>>16)&0x000000ffu)|(i.y&0xffffff00u);} + AU1 APermHGAE(AU2 i){return((i.x<< 8)&0x0000ff00u)|(i.y&0xffff00ffu);} + AU1 APermHGCE(AU2 i){return((i.x>> 8)&0x0000ff00u)|(i.y&0xffff00ffu);} + AU1 APermHAFE(AU2 i){return((i.x<<16)&0x00ff0000u)|(i.y&0xff00ffffu);} + AU1 APermHCFE(AU2 i){return((i.x )&0x00ff0000u)|(i.y&0xff00ffffu);} + AU1 APermAGFE(AU2 i){return((i.x<<24)&0xff000000u)|(i.y&0x00ffffffu);} + AU1 APermCGFE(AU2 i){return((i.x<< 8)&0xff000000u)|(i.y&0x00ffffffu);} +//------------------------------------------------------------------------------------------------------------------------------ + AU1 APermGCEA(AU2 i){return((i.x)&0x00ff00ffu)|((i.y<<8)&0xff00ff00u);} + AU1 APermGECA(AU2 i){return(((i.x)&0xffu)|((i.x>>8)&0xff00u)|((i.y<<16)&0xff0000u)|((i.y<<8)&0xff000000u));} + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// [BUC] BYTE UNSIGNED CONVERSION +//------------------------------------------------------------------------------------------------------------------------------ +// Designed to use the optimal conversion, enables the scaling to possibly be factored into other computation. +// Works on a range of {0 to A_BUC_<32,16>}, for <32-bit, and 16-bit> respectively. +//------------------------------------------------------------------------------------------------------------------------------ +// OPCODE NOTES +// ============ +// GCN does not do UNORM or SNORM for bytes in opcodes. +// - V_CVT_F32_UBYTE{0,1,2,3} - Unsigned byte to float. +// - V_CVT_PKACC_U8_F32 - Float to unsigned byte (does bit-field insert into 32-bit integer). +// V_PERM_B32 does byte packing with ability to zero fill bytes as well. +// - Can pull out byte values from two sources, and zero fill upper 8-bits of packed hi and lo. +//------------------------------------------------------------------------------------------------------------------------------ +// BYTE : FLOAT - ABuc{0,1,2,3}{To,From}U1() - Designed for V_CVT_F32_UBYTE* and V_CVT_PKACCUM_U8_F32 ops. +// ==== ===== +// 0 : 0 +// 1 : 1 +// ... +// 255 : 255 +// : 256 (just outside the encoding range) +//------------------------------------------------------------------------------------------------------------------------------ +// BYTE : FLOAT - ABuc{0,1,2,3}{To,From}U2() - Designed for 16-bit denormal tricks and V_PERM_B32. +// ==== ===== +// 0 : 0 +// 1 : 1/512 +// 2 : 1/256 +// ... +// 64 : 1/8 +// 128 : 1/4 +// 255 : 255/512 +// : 1/2 (just outside the encoding range) +//------------------------------------------------------------------------------------------------------------------------------ +// OPTIMAL IMPLEMENTATIONS ON AMD ARCHITECTURES +// ============================================ +// r=ABuc0FromU1(i) +// V_CVT_F32_UBYTE0 r,i +// -------------------------------------------- +// r=ABuc0ToU1(d,i) +// V_CVT_PKACCUM_U8_F32 r,i,0,d +// -------------------------------------------- +// d=ABuc0FromU2(i) +// Where 'k0' is an SGPR with 0x0E0A +// Where 'k1' is an SGPR with {32768.0} packed into the lower 16-bits +// V_PERM_B32 d,i.x,i.y,k0 +// V_PK_FMA_F16 d,d,k1.x,0 +// -------------------------------------------- +// r=ABuc0ToU2(d,i) +// Where 'k0' is an SGPR with {1.0/32768.0} packed into the lower 16-bits +// Where 'k1' is an SGPR with 0x???? +// Where 'k2' is an SGPR with 0x???? +// V_PK_FMA_F16 i,i,k0.x,0 +// V_PERM_B32 r.x,i,i,k1 +// V_PERM_B32 r.y,i,i,k2 +//============================================================================================================================== + // Peak range for 32-bit and 16-bit operations. + #define A_BUC_32 (255.0) + #define A_BUC_16 (255.0/512.0) +//============================================================================================================================== + #if 1 + // Designed to be one V_CVT_PKACCUM_U8_F32. + // The extra min is required to pattern match to V_CVT_PKACCUM_U8_F32. + AU1 ABuc0ToU1(AU1 d,AF1 i){return (d&0xffffff00u)|((min(AU1(i),255u) )&(0x000000ffu));} + AU1 ABuc1ToU1(AU1 d,AF1 i){return (d&0xffff00ffu)|((min(AU1(i),255u)<< 8)&(0x0000ff00u));} + AU1 ABuc2ToU1(AU1 d,AF1 i){return (d&0xff00ffffu)|((min(AU1(i),255u)<<16)&(0x00ff0000u));} + AU1 ABuc3ToU1(AU1 d,AF1 i){return (d&0x00ffffffu)|((min(AU1(i),255u)<<24)&(0xff000000u));} +//------------------------------------------------------------------------------------------------------------------------------ + // Designed to be one V_CVT_F32_UBYTE*. + AF1 ABuc0FromU1(AU1 i){return AF1((i )&255u);} + AF1 ABuc1FromU1(AU1 i){return AF1((i>> 8)&255u);} + AF1 ABuc2FromU1(AU1 i){return AF1((i>>16)&255u);} + AF1 ABuc3FromU1(AU1 i){return AF1((i>>24)&255u);} + #endif +//============================================================================================================================== + #ifdef A_HALF + // Takes {x0,x1} and {y0,y1} and builds {{x0,y0},{x1,y1}}. + AW2 ABuc01ToW2(AH2 x,AH2 y){x*=AH2_(1.0/32768.0);y*=AH2_(1.0/32768.0); + return AW2_AU1(APermGCEA(AU2(AU1_AW2(AW2_AH2(x)),AU1_AW2(AW2_AH2(y)))));} +//------------------------------------------------------------------------------------------------------------------------------ + // Designed for 3 ops to do SOA to AOS and conversion. + AU2 ABuc0ToU2(AU2 d,AH2 i){AU1 b=AU1_AW2(AW2_AH2(i*AH2_(1.0/32768.0))); + return AU2(APermHGFA(AU2(d.x,b)),APermHGFC(AU2(d.y,b)));} + AU2 ABuc1ToU2(AU2 d,AH2 i){AU1 b=AU1_AW2(AW2_AH2(i*AH2_(1.0/32768.0))); + return AU2(APermHGAE(AU2(d.x,b)),APermHGCE(AU2(d.y,b)));} + AU2 ABuc2ToU2(AU2 d,AH2 i){AU1 b=AU1_AW2(AW2_AH2(i*AH2_(1.0/32768.0))); + return AU2(APermHAFE(AU2(d.x,b)),APermHCFE(AU2(d.y,b)));} + AU2 ABuc3ToU2(AU2 d,AH2 i){AU1 b=AU1_AW2(AW2_AH2(i*AH2_(1.0/32768.0))); + return AU2(APermAGFE(AU2(d.x,b)),APermCGFE(AU2(d.y,b)));} +//------------------------------------------------------------------------------------------------------------------------------ + // Designed for 2 ops to do both AOS to SOA, and conversion. + AH2 ABuc0FromU2(AU2 i){return AH2_AW2(AW2_AU1(APerm0E0A(i)))*AH2_(32768.0);} + AH2 ABuc1FromU2(AU2 i){return AH2_AW2(AW2_AU1(APerm0F0B(i)))*AH2_(32768.0);} + AH2 ABuc2FromU2(AU2 i){return AH2_AW2(AW2_AU1(APerm0G0C(i)))*AH2_(32768.0);} + AH2 ABuc3FromU2(AU2 i){return AH2_AW2(AW2_AU1(APerm0H0D(i)))*AH2_(32768.0);} + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// [BSC] BYTE SIGNED CONVERSION +//------------------------------------------------------------------------------------------------------------------------------ +// Similar to [BUC]. +// Works on a range of {-/+ A_BSC_<32,16>}, for <32-bit, and 16-bit> respectively. +//------------------------------------------------------------------------------------------------------------------------------ +// ENCODING (without zero-based encoding) +// ======== +// 0 = unused (can be used to mean something else) +// 1 = lowest value +// 128 = exact zero center (zero based encoding +// 255 = highest value +//------------------------------------------------------------------------------------------------------------------------------ +// Zero-based [Zb] flips the MSB bit of the byte (making 128 "exact zero" actually zero). +// This is useful if there is a desire for cleared values to decode as zero. +//------------------------------------------------------------------------------------------------------------------------------ +// BYTE : FLOAT - ABsc{0,1,2,3}{To,From}U2() - Designed for 16-bit denormal tricks and V_PERM_B32. +// ==== ===== +// 0 : -127/512 (unused) +// 1 : -126/512 +// 2 : -125/512 +// ... +// 128 : 0 +// ... +// 255 : 127/512 +// : 1/4 (just outside the encoding range) +//============================================================================================================================== + // Peak range for 32-bit and 16-bit operations. + #define A_BSC_32 (127.0) + #define A_BSC_16 (127.0/512.0) +//============================================================================================================================== + #if 1 + AU1 ABsc0ToU1(AU1 d,AF1 i){return (d&0xffffff00u)|((min(AU1(i+128.0),255u) )&(0x000000ffu));} + AU1 ABsc1ToU1(AU1 d,AF1 i){return (d&0xffff00ffu)|((min(AU1(i+128.0),255u)<< 8)&(0x0000ff00u));} + AU1 ABsc2ToU1(AU1 d,AF1 i){return (d&0xff00ffffu)|((min(AU1(i+128.0),255u)<<16)&(0x00ff0000u));} + AU1 ABsc3ToU1(AU1 d,AF1 i){return (d&0x00ffffffu)|((min(AU1(i+128.0),255u)<<24)&(0xff000000u));} +//------------------------------------------------------------------------------------------------------------------------------ + AU1 ABsc0ToZbU1(AU1 d,AF1 i){return ((d&0xffffff00u)|((min(AU1(trunc(i)+128.0),255u) )&(0x000000ffu)))^0x00000080u;} + AU1 ABsc1ToZbU1(AU1 d,AF1 i){return ((d&0xffff00ffu)|((min(AU1(trunc(i)+128.0),255u)<< 8)&(0x0000ff00u)))^0x00008000u;} + AU1 ABsc2ToZbU1(AU1 d,AF1 i){return ((d&0xff00ffffu)|((min(AU1(trunc(i)+128.0),255u)<<16)&(0x00ff0000u)))^0x00800000u;} + AU1 ABsc3ToZbU1(AU1 d,AF1 i){return ((d&0x00ffffffu)|((min(AU1(trunc(i)+128.0),255u)<<24)&(0xff000000u)))^0x80000000u;} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 ABsc0FromU1(AU1 i){return AF1((i )&255u)-128.0;} + AF1 ABsc1FromU1(AU1 i){return AF1((i>> 8)&255u)-128.0;} + AF1 ABsc2FromU1(AU1 i){return AF1((i>>16)&255u)-128.0;} + AF1 ABsc3FromU1(AU1 i){return AF1((i>>24)&255u)-128.0;} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 ABsc0FromZbU1(AU1 i){return AF1(((i )&255u)^0x80u)-128.0;} + AF1 ABsc1FromZbU1(AU1 i){return AF1(((i>> 8)&255u)^0x80u)-128.0;} + AF1 ABsc2FromZbU1(AU1 i){return AF1(((i>>16)&255u)^0x80u)-128.0;} + AF1 ABsc3FromZbU1(AU1 i){return AF1(((i>>24)&255u)^0x80u)-128.0;} + #endif +//============================================================================================================================== + #ifdef A_HALF + // Takes {x0,x1} and {y0,y1} and builds {{x0,y0},{x1,y1}}. + AW2 ABsc01ToW2(AH2 x,AH2 y){x=x*AH2_(1.0/32768.0)+AH2_(0.25/32768.0);y=y*AH2_(1.0/32768.0)+AH2_(0.25/32768.0); + return AW2_AU1(APermGCEA(AU2(AU1_AW2(AW2_AH2(x)),AU1_AW2(AW2_AH2(y)))));} +//------------------------------------------------------------------------------------------------------------------------------ + AU2 ABsc0ToU2(AU2 d,AH2 i){AU1 b=AU1_AW2(AW2_AH2(i*AH2_(1.0/32768.0)+AH2_(0.25/32768.0))); + return AU2(APermHGFA(AU2(d.x,b)),APermHGFC(AU2(d.y,b)));} + AU2 ABsc1ToU2(AU2 d,AH2 i){AU1 b=AU1_AW2(AW2_AH2(i*AH2_(1.0/32768.0)+AH2_(0.25/32768.0))); + return AU2(APermHGAE(AU2(d.x,b)),APermHGCE(AU2(d.y,b)));} + AU2 ABsc2ToU2(AU2 d,AH2 i){AU1 b=AU1_AW2(AW2_AH2(i*AH2_(1.0/32768.0)+AH2_(0.25/32768.0))); + return AU2(APermHAFE(AU2(d.x,b)),APermHCFE(AU2(d.y,b)));} + AU2 ABsc3ToU2(AU2 d,AH2 i){AU1 b=AU1_AW2(AW2_AH2(i*AH2_(1.0/32768.0)+AH2_(0.25/32768.0))); + return AU2(APermAGFE(AU2(d.x,b)),APermCGFE(AU2(d.y,b)));} +//------------------------------------------------------------------------------------------------------------------------------ + AU2 ABsc0ToZbU2(AU2 d,AH2 i){AU1 b=AU1_AW2(AW2_AH2(i*AH2_(1.0/32768.0)+AH2_(0.25/32768.0)))^0x00800080u; + return AU2(APermHGFA(AU2(d.x,b)),APermHGFC(AU2(d.y,b)));} + AU2 ABsc1ToZbU2(AU2 d,AH2 i){AU1 b=AU1_AW2(AW2_AH2(i*AH2_(1.0/32768.0)+AH2_(0.25/32768.0)))^0x00800080u; + return AU2(APermHGAE(AU2(d.x,b)),APermHGCE(AU2(d.y,b)));} + AU2 ABsc2ToZbU2(AU2 d,AH2 i){AU1 b=AU1_AW2(AW2_AH2(i*AH2_(1.0/32768.0)+AH2_(0.25/32768.0)))^0x00800080u; + return AU2(APermHAFE(AU2(d.x,b)),APermHCFE(AU2(d.y,b)));} + AU2 ABsc3ToZbU2(AU2 d,AH2 i){AU1 b=AU1_AW2(AW2_AH2(i*AH2_(1.0/32768.0)+AH2_(0.25/32768.0)))^0x00800080u; + return AU2(APermAGFE(AU2(d.x,b)),APermCGFE(AU2(d.y,b)));} +//------------------------------------------------------------------------------------------------------------------------------ + AH2 ABsc0FromU2(AU2 i){return AH2_AW2(AW2_AU1(APerm0E0A(i)))*AH2_(32768.0)-AH2_(0.25);} + AH2 ABsc1FromU2(AU2 i){return AH2_AW2(AW2_AU1(APerm0F0B(i)))*AH2_(32768.0)-AH2_(0.25);} + AH2 ABsc2FromU2(AU2 i){return AH2_AW2(AW2_AU1(APerm0G0C(i)))*AH2_(32768.0)-AH2_(0.25);} + AH2 ABsc3FromU2(AU2 i){return AH2_AW2(AW2_AU1(APerm0H0D(i)))*AH2_(32768.0)-AH2_(0.25);} +//------------------------------------------------------------------------------------------------------------------------------ + AH2 ABsc0FromZbU2(AU2 i){return AH2_AW2(AW2_AU1(APerm0E0A(i)^0x00800080u))*AH2_(32768.0)-AH2_(0.25);} + AH2 ABsc1FromZbU2(AU2 i){return AH2_AW2(AW2_AU1(APerm0F0B(i)^0x00800080u))*AH2_(32768.0)-AH2_(0.25);} + AH2 ABsc2FromZbU2(AU2 i){return AH2_AW2(AW2_AU1(APerm0G0C(i)^0x00800080u))*AH2_(32768.0)-AH2_(0.25);} + AH2 ABsc3FromZbU2(AU2 i){return AH2_AW2(AW2_AU1(APerm0H0D(i)^0x00800080u))*AH2_(32768.0)-AH2_(0.25);} + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// HALF APPROXIMATIONS +//------------------------------------------------------------------------------------------------------------------------------ +// These support only positive inputs. +// Did not see value yet in specialization for range. +// Using quick testing, ended up mostly getting the same "best" approximation for various ranges. +// With hardware that can co-execute transcendentals, the value in approximations could be less than expected. +// However from a latency perspective, if execution of a transcendental is 4 clk, with no packed support, -> 8 clk total. +// And co-execution would require a compiler interleaving a lot of independent work for packed usage. +//------------------------------------------------------------------------------------------------------------------------------ +// The one Newton Raphson iteration form of rsq() was skipped (requires 6 ops total). +// Same with sqrt(), as this could be x*rsq() (7 ops). +//============================================================================================================================== + #ifdef A_HALF + // Minimize squared error across full positive range, 2 ops. + // The 0x1de2 based approximation maps {0 to 1} input maps to < 1 output. + AH1 APrxLoSqrtH1(AH1 a){return AH1_AW1((AW1_AH1(a)>>AW1_(1))+AW1_(0x1de2));} + AH2 APrxLoSqrtH2(AH2 a){return AH2_AW2((AW2_AH2(a)>>AW2_(1))+AW2_(0x1de2));} + AH3 APrxLoSqrtH3(AH3 a){return AH3_AW3((AW3_AH3(a)>>AW3_(1))+AW3_(0x1de2));} + AH4 APrxLoSqrtH4(AH4 a){return AH4_AW4((AW4_AH4(a)>>AW4_(1))+AW4_(0x1de2));} +//------------------------------------------------------------------------------------------------------------------------------ + // Lower precision estimation, 1 op. + // Minimize squared error across {smallest normal to 16384.0}. + AH1 APrxLoRcpH1(AH1 a){return AH1_AW1(AW1_(0x7784)-AW1_AH1(a));} + AH2 APrxLoRcpH2(AH2 a){return AH2_AW2(AW2_(0x7784)-AW2_AH2(a));} + AH3 APrxLoRcpH3(AH3 a){return AH3_AW3(AW3_(0x7784)-AW3_AH3(a));} + AH4 APrxLoRcpH4(AH4 a){return AH4_AW4(AW4_(0x7784)-AW4_AH4(a));} +//------------------------------------------------------------------------------------------------------------------------------ + // Medium precision estimation, one Newton Raphson iteration, 3 ops. + AH1 APrxMedRcpH1(AH1 a){AH1 b=AH1_AW1(AW1_(0x778d)-AW1_AH1(a));return b*(-b*a+AH1_(2.0));} + AH2 APrxMedRcpH2(AH2 a){AH2 b=AH2_AW2(AW2_(0x778d)-AW2_AH2(a));return b*(-b*a+AH2_(2.0));} + AH3 APrxMedRcpH3(AH3 a){AH3 b=AH3_AW3(AW3_(0x778d)-AW3_AH3(a));return b*(-b*a+AH3_(2.0));} + AH4 APrxMedRcpH4(AH4 a){AH4 b=AH4_AW4(AW4_(0x778d)-AW4_AH4(a));return b*(-b*a+AH4_(2.0));} +//------------------------------------------------------------------------------------------------------------------------------ + // Minimize squared error across {smallest normal to 16384.0}, 2 ops. + AH1 APrxLoRsqH1(AH1 a){return AH1_AW1(AW1_(0x59a3)-(AW1_AH1(a)>>AW1_(1)));} + AH2 APrxLoRsqH2(AH2 a){return AH2_AW2(AW2_(0x59a3)-(AW2_AH2(a)>>AW2_(1)));} + AH3 APrxLoRsqH3(AH3 a){return AH3_AW3(AW3_(0x59a3)-(AW3_AH3(a)>>AW3_(1)));} + AH4 APrxLoRsqH4(AH4 a){return AH4_AW4(AW4_(0x59a3)-(AW4_AH4(a)>>AW4_(1)));} + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// FLOAT APPROXIMATIONS +//------------------------------------------------------------------------------------------------------------------------------ +// Michal Drobot has an excellent presentation on these: "Low Level Optimizations For GCN", +// - Idea dates back to SGI, then to Quake 3, etc. +// - https://michaldrobot.files.wordpress.com/2014/05/gcn_alu_opt_digitaldragons2014.pdf +// - sqrt(x)=rsqrt(x)*x +// - rcp(x)=rsqrt(x)*rsqrt(x) for positive x +// - https://github.com/michaldrobot/ShaderFastLibs/blob/master/ShaderFastMathLib.h +//------------------------------------------------------------------------------------------------------------------------------ +// These below are from perhaps less complete searching for optimal. +// Used FP16 normal range for testing with +4096 32-bit step size for sampling error. +// So these match up well with the half approximations. +//============================================================================================================================== + AF1 APrxLoSqrtF1(AF1 a){return AF1_AU1((AU1_AF1(a)>>AU1_(1))+AU1_(0x1fbc4639));} + AF1 APrxLoRcpF1(AF1 a){return AF1_AU1(AU1_(0x7ef07ebb)-AU1_AF1(a));} + AF1 APrxMedRcpF1(AF1 a){AF1 b=AF1_AU1(AU1_(0x7ef19fff)-AU1_AF1(a));return b*(-b*a+AF1_(2.0));} + AF1 APrxLoRsqF1(AF1 a){return AF1_AU1(AU1_(0x5f347d74)-(AU1_AF1(a)>>AU1_(1)));} +//------------------------------------------------------------------------------------------------------------------------------ + AF2 APrxLoSqrtF2(AF2 a){return AF2_AU2((AU2_AF2(a)>>AU2_(1))+AU2_(0x1fbc4639));} + AF2 APrxLoRcpF2(AF2 a){return AF2_AU2(AU2_(0x7ef07ebb)-AU2_AF2(a));} + AF2 APrxMedRcpF2(AF2 a){AF2 b=AF2_AU2(AU2_(0x7ef19fff)-AU2_AF2(a));return b*(-b*a+AF2_(2.0));} + AF2 APrxLoRsqF2(AF2 a){return AF2_AU2(AU2_(0x5f347d74)-(AU2_AF2(a)>>AU2_(1)));} +//------------------------------------------------------------------------------------------------------------------------------ + AF3 APrxLoSqrtF3(AF3 a){return AF3_AU3((AU3_AF3(a)>>AU3_(1))+AU3_(0x1fbc4639));} + AF3 APrxLoRcpF3(AF3 a){return AF3_AU3(AU3_(0x7ef07ebb)-AU3_AF3(a));} + AF3 APrxMedRcpF3(AF3 a){AF3 b=AF3_AU3(AU3_(0x7ef19fff)-AU3_AF3(a));return b*(-b*a+AF3_(2.0));} + AF3 APrxLoRsqF3(AF3 a){return AF3_AU3(AU3_(0x5f347d74)-(AU3_AF3(a)>>AU3_(1)));} +//------------------------------------------------------------------------------------------------------------------------------ + AF4 APrxLoSqrtF4(AF4 a){return AF4_AU4((AU4_AF4(a)>>AU4_(1))+AU4_(0x1fbc4639));} + AF4 APrxLoRcpF4(AF4 a){return AF4_AU4(AU4_(0x7ef07ebb)-AU4_AF4(a));} + AF4 APrxMedRcpF4(AF4 a){AF4 b=AF4_AU4(AU4_(0x7ef19fff)-AU4_AF4(a));return b*(-b*a+AF4_(2.0));} + AF4 APrxLoRsqF4(AF4 a){return AF4_AU4(AU4_(0x5f347d74)-(AU4_AF4(a)>>AU4_(1)));} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// PQ APPROXIMATIONS +//------------------------------------------------------------------------------------------------------------------------------ +// PQ is very close to x^(1/8). The functions below Use the fast float approximation method to do +// PQ<~>Gamma2 (4th power and fast 4th root) and PQ<~>Linear (8th power and fast 8th root). Maximum error is ~0.2%. +//============================================================================================================================== +// Helpers + AF1 Quart(AF1 a) { a = a * a; return a * a;} + AF1 Oct(AF1 a) { a = a * a; a = a * a; return a * a; } + AF2 Quart(AF2 a) { a = a * a; return a * a; } + AF2 Oct(AF2 a) { a = a * a; a = a * a; return a * a; } + AF3 Quart(AF3 a) { a = a * a; return a * a; } + AF3 Oct(AF3 a) { a = a * a; a = a * a; return a * a; } + AF4 Quart(AF4 a) { a = a * a; return a * a; } + AF4 Oct(AF4 a) { a = a * a; a = a * a; return a * a; } + //------------------------------------------------------------------------------------------------------------------------------ + AF1 APrxPQToGamma2(AF1 a) { return Quart(a); } + AF1 APrxPQToLinear(AF1 a) { return Oct(a); } + AF1 APrxLoGamma2ToPQ(AF1 a) { return AF1_AU1((AU1_AF1(a) >> AU1_(2)) + AU1_(0x2F9A4E46)); } + AF1 APrxMedGamma2ToPQ(AF1 a) { AF1 b = AF1_AU1((AU1_AF1(a) >> AU1_(2)) + AU1_(0x2F9A4E46)); AF1 b4 = Quart(b); return b - b * (b4 - a) / (AF1_(4.0) * b4); } + AF1 APrxHighGamma2ToPQ(AF1 a) { return sqrt(sqrt(a)); } + AF1 APrxLoLinearToPQ(AF1 a) { return AF1_AU1((AU1_AF1(a) >> AU1_(3)) + AU1_(0x378D8723)); } + AF1 APrxMedLinearToPQ(AF1 a) { AF1 b = AF1_AU1((AU1_AF1(a) >> AU1_(3)) + AU1_(0x378D8723)); AF1 b8 = Oct(b); return b - b * (b8 - a) / (AF1_(8.0) * b8); } + AF1 APrxHighLinearToPQ(AF1 a) { return sqrt(sqrt(sqrt(a))); } + //------------------------------------------------------------------------------------------------------------------------------ + AF2 APrxPQToGamma2(AF2 a) { return Quart(a); } + AF2 APrxPQToLinear(AF2 a) { return Oct(a); } + AF2 APrxLoGamma2ToPQ(AF2 a) { return AF2_AU2((AU2_AF2(a) >> AU2_(2)) + AU2_(0x2F9A4E46)); } + AF2 APrxMedGamma2ToPQ(AF2 a) { AF2 b = AF2_AU2((AU2_AF2(a) >> AU2_(2)) + AU2_(0x2F9A4E46)); AF2 b4 = Quart(b); return b - b * (b4 - a) / (AF1_(4.0) * b4); } + AF2 APrxHighGamma2ToPQ(AF2 a) { return sqrt(sqrt(a)); } + AF2 APrxLoLinearToPQ(AF2 a) { return AF2_AU2((AU2_AF2(a) >> AU2_(3)) + AU2_(0x378D8723)); } + AF2 APrxMedLinearToPQ(AF2 a) { AF2 b = AF2_AU2((AU2_AF2(a) >> AU2_(3)) + AU2_(0x378D8723)); AF2 b8 = Oct(b); return b - b * (b8 - a) / (AF1_(8.0) * b8); } + AF2 APrxHighLinearToPQ(AF2 a) { return sqrt(sqrt(sqrt(a))); } + //------------------------------------------------------------------------------------------------------------------------------ + AF3 APrxPQToGamma2(AF3 a) { return Quart(a); } + AF3 APrxPQToLinear(AF3 a) { return Oct(a); } + AF3 APrxLoGamma2ToPQ(AF3 a) { return AF3_AU3((AU3_AF3(a) >> AU3_(2)) + AU3_(0x2F9A4E46)); } + AF3 APrxMedGamma2ToPQ(AF3 a) { AF3 b = AF3_AU3((AU3_AF3(a) >> AU3_(2)) + AU3_(0x2F9A4E46)); AF3 b4 = Quart(b); return b - b * (b4 - a) / (AF1_(4.0) * b4); } + AF3 APrxHighGamma2ToPQ(AF3 a) { return sqrt(sqrt(a)); } + AF3 APrxLoLinearToPQ(AF3 a) { return AF3_AU3((AU3_AF3(a) >> AU3_(3)) + AU3_(0x378D8723)); } + AF3 APrxMedLinearToPQ(AF3 a) { AF3 b = AF3_AU3((AU3_AF3(a) >> AU3_(3)) + AU3_(0x378D8723)); AF3 b8 = Oct(b); return b - b * (b8 - a) / (AF1_(8.0) * b8); } + AF3 APrxHighLinearToPQ(AF3 a) { return sqrt(sqrt(sqrt(a))); } + //------------------------------------------------------------------------------------------------------------------------------ + AF4 APrxPQToGamma2(AF4 a) { return Quart(a); } + AF4 APrxPQToLinear(AF4 a) { return Oct(a); } + AF4 APrxLoGamma2ToPQ(AF4 a) { return AF4_AU4((AU4_AF4(a) >> AU4_(2)) + AU4_(0x2F9A4E46)); } + AF4 APrxMedGamma2ToPQ(AF4 a) { AF4 b = AF4_AU4((AU4_AF4(a) >> AU4_(2)) + AU4_(0x2F9A4E46)); AF4 b4 = Quart(b); return b - b * (b4 - a) / (AF1_(4.0) * b4); } + AF4 APrxHighGamma2ToPQ(AF4 a) { return sqrt(sqrt(a)); } + AF4 APrxLoLinearToPQ(AF4 a) { return AF4_AU4((AU4_AF4(a) >> AU4_(3)) + AU4_(0x378D8723)); } + AF4 APrxMedLinearToPQ(AF4 a) { AF4 b = AF4_AU4((AU4_AF4(a) >> AU4_(3)) + AU4_(0x378D8723)); AF4 b8 = Oct(b); return b - b * (b8 - a) / (AF1_(8.0) * b8); } + AF4 APrxHighLinearToPQ(AF4 a) { return sqrt(sqrt(sqrt(a))); } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// PARABOLIC SIN & COS +//------------------------------------------------------------------------------------------------------------------------------ +// Approximate answers to transcendental questions. +//------------------------------------------------------------------------------------------------------------------------------ +//============================================================================================================================== + #if 1 + // Valid input range is {-1 to 1} representing {0 to 2 pi}. + // Output range is {-1/4 to 1/4} representing {-1 to 1}. + AF1 APSinF1(AF1 x){return x*abs(x)-x;} // MAD. + AF2 APSinF2(AF2 x){return x*abs(x)-x;} + AF1 APCosF1(AF1 x){x=AFractF1(x*AF1_(0.5)+AF1_(0.75));x=x*AF1_(2.0)-AF1_(1.0);return APSinF1(x);} // 3x MAD, FRACT + AF2 APCosF2(AF2 x){x=AFractF2(x*AF2_(0.5)+AF2_(0.75));x=x*AF2_(2.0)-AF2_(1.0);return APSinF2(x);} + AF2 APSinCosF1(AF1 x){AF1 y=AFractF1(x*AF1_(0.5)+AF1_(0.75));y=y*AF1_(2.0)-AF1_(1.0);return APSinF2(AF2(x,y));} + #endif +//------------------------------------------------------------------------------------------------------------------------------ + #ifdef A_HALF + // For a packed {sin,cos} pair, + // - Native takes 16 clocks and 4 issue slots (no packed transcendentals). + // - Parabolic takes 8 clocks and 8 issue slots (only fract is non-packed). + AH1 APSinH1(AH1 x){return x*abs(x)-x;} + AH2 APSinH2(AH2 x){return x*abs(x)-x;} // AND,FMA + AH1 APCosH1(AH1 x){x=AFractH1(x*AH1_(0.5)+AH1_(0.75));x=x*AH1_(2.0)-AH1_(1.0);return APSinH1(x);} + AH2 APCosH2(AH2 x){x=AFractH2(x*AH2_(0.5)+AH2_(0.75));x=x*AH2_(2.0)-AH2_(1.0);return APSinH2(x);} // 3x FMA, 2xFRACT, AND + AH2 APSinCosH1(AH1 x){AH1 y=AFractH1(x*AH1_(0.5)+AH1_(0.75));y=y*AH1_(2.0)-AH1_(1.0);return APSinH2(AH2(x,y));} + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// [ZOL] ZERO ONE LOGIC +//------------------------------------------------------------------------------------------------------------------------------ +// Conditional free logic designed for easy 16-bit packing, and backwards porting to 32-bit. +//------------------------------------------------------------------------------------------------------------------------------ +// 0 := false +// 1 := true +//------------------------------------------------------------------------------------------------------------------------------ +// AndNot(x,y) -> !(x&y) .... One op. +// AndOr(x,y,z) -> (x&y)|z ... One op. +// GtZero(x) -> x>0.0 ..... One op. +// Sel(x,y,z) -> x?y:z ..... Two ops, has no precision loss. +// Signed(x) -> x<0.0 ..... One op. +// ZeroPass(x,y) -> x?0:y ..... Two ops, 'y' is a pass through safe for aliasing as integer. +//------------------------------------------------------------------------------------------------------------------------------ +// OPTIMIZATION NOTES +// ================== +// - On Vega to use 2 constants in a packed op, pass in as one AW2 or one AH2 'k.xy' and use as 'k.xx' and 'k.yy'. +// For example 'a.xy*k.xx+k.yy'. +//============================================================================================================================== + #if 1 + AU1 AZolAndU1(AU1 x,AU1 y){return min(x,y);} + AU2 AZolAndU2(AU2 x,AU2 y){return min(x,y);} + AU3 AZolAndU3(AU3 x,AU3 y){return min(x,y);} + AU4 AZolAndU4(AU4 x,AU4 y){return min(x,y);} +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AZolNotU1(AU1 x){return x^AU1_(1);} + AU2 AZolNotU2(AU2 x){return x^AU2_(1);} + AU3 AZolNotU3(AU3 x){return x^AU3_(1);} + AU4 AZolNotU4(AU4 x){return x^AU4_(1);} +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AZolOrU1(AU1 x,AU1 y){return max(x,y);} + AU2 AZolOrU2(AU2 x,AU2 y){return max(x,y);} + AU3 AZolOrU3(AU3 x,AU3 y){return max(x,y);} + AU4 AZolOrU4(AU4 x,AU4 y){return max(x,y);} +//============================================================================================================================== + AU1 AZolF1ToU1(AF1 x){return AU1(x);} + AU2 AZolF2ToU2(AF2 x){return AU2(x);} + AU3 AZolF3ToU3(AF3 x){return AU3(x);} + AU4 AZolF4ToU4(AF4 x){return AU4(x);} +//------------------------------------------------------------------------------------------------------------------------------ + // 2 ops, denormals don't work in 32-bit on PC (and if they are enabled, OMOD is disabled). + AU1 AZolNotF1ToU1(AF1 x){return AU1(AF1_(1.0)-x);} + AU2 AZolNotF2ToU2(AF2 x){return AU2(AF2_(1.0)-x);} + AU3 AZolNotF3ToU3(AF3 x){return AU3(AF3_(1.0)-x);} + AU4 AZolNotF4ToU4(AF4 x){return AU4(AF4_(1.0)-x);} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AZolU1ToF1(AU1 x){return AF1(x);} + AF2 AZolU2ToF2(AU2 x){return AF2(x);} + AF3 AZolU3ToF3(AU3 x){return AF3(x);} + AF4 AZolU4ToF4(AU4 x){return AF4(x);} +//============================================================================================================================== + AF1 AZolAndF1(AF1 x,AF1 y){return min(x,y);} + AF2 AZolAndF2(AF2 x,AF2 y){return min(x,y);} + AF3 AZolAndF3(AF3 x,AF3 y){return min(x,y);} + AF4 AZolAndF4(AF4 x,AF4 y){return min(x,y);} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 ASolAndNotF1(AF1 x,AF1 y){return (-x)*y+AF1_(1.0);} + AF2 ASolAndNotF2(AF2 x,AF2 y){return (-x)*y+AF2_(1.0);} + AF3 ASolAndNotF3(AF3 x,AF3 y){return (-x)*y+AF3_(1.0);} + AF4 ASolAndNotF4(AF4 x,AF4 y){return (-x)*y+AF4_(1.0);} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AZolAndOrF1(AF1 x,AF1 y,AF1 z){return ASatF1(x*y+z);} + AF2 AZolAndOrF2(AF2 x,AF2 y,AF2 z){return ASatF2(x*y+z);} + AF3 AZolAndOrF3(AF3 x,AF3 y,AF3 z){return ASatF3(x*y+z);} + AF4 AZolAndOrF4(AF4 x,AF4 y,AF4 z){return ASatF4(x*y+z);} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AZolGtZeroF1(AF1 x){return ASatF1(x*AF1_(A_INFP_F));} + AF2 AZolGtZeroF2(AF2 x){return ASatF2(x*AF2_(A_INFP_F));} + AF3 AZolGtZeroF3(AF3 x){return ASatF3(x*AF3_(A_INFP_F));} + AF4 AZolGtZeroF4(AF4 x){return ASatF4(x*AF4_(A_INFP_F));} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AZolNotF1(AF1 x){return AF1_(1.0)-x;} + AF2 AZolNotF2(AF2 x){return AF2_(1.0)-x;} + AF3 AZolNotF3(AF3 x){return AF3_(1.0)-x;} + AF4 AZolNotF4(AF4 x){return AF4_(1.0)-x;} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AZolOrF1(AF1 x,AF1 y){return max(x,y);} + AF2 AZolOrF2(AF2 x,AF2 y){return max(x,y);} + AF3 AZolOrF3(AF3 x,AF3 y){return max(x,y);} + AF4 AZolOrF4(AF4 x,AF4 y){return max(x,y);} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AZolSelF1(AF1 x,AF1 y,AF1 z){AF1 r=(-x)*z+z;return x*y+r;} + AF2 AZolSelF2(AF2 x,AF2 y,AF2 z){AF2 r=(-x)*z+z;return x*y+r;} + AF3 AZolSelF3(AF3 x,AF3 y,AF3 z){AF3 r=(-x)*z+z;return x*y+r;} + AF4 AZolSelF4(AF4 x,AF4 y,AF4 z){AF4 r=(-x)*z+z;return x*y+r;} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AZolSignedF1(AF1 x){return ASatF1(x*AF1_(A_INFN_F));} + AF2 AZolSignedF2(AF2 x){return ASatF2(x*AF2_(A_INFN_F));} + AF3 AZolSignedF3(AF3 x){return ASatF3(x*AF3_(A_INFN_F));} + AF4 AZolSignedF4(AF4 x){return ASatF4(x*AF4_(A_INFN_F));} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AZolZeroPassF1(AF1 x,AF1 y){return AF1_AU1((AU1_AF1(x)!=AU1_(0))?AU1_(0):AU1_AF1(y));} + AF2 AZolZeroPassF2(AF2 x,AF2 y){return AF2_AU2((AU2_AF2(x)!=AU2_(0))?AU2_(0):AU2_AF2(y));} + AF3 AZolZeroPassF3(AF3 x,AF3 y){return AF3_AU3((AU3_AF3(x)!=AU3_(0))?AU3_(0):AU3_AF3(y));} + AF4 AZolZeroPassF4(AF4 x,AF4 y){return AF4_AU4((AU4_AF4(x)!=AU4_(0))?AU4_(0):AU4_AF4(y));} + #endif +//============================================================================================================================== + #ifdef A_HALF + AW1 AZolAndW1(AW1 x,AW1 y){return min(x,y);} + AW2 AZolAndW2(AW2 x,AW2 y){return min(x,y);} + AW3 AZolAndW3(AW3 x,AW3 y){return min(x,y);} + AW4 AZolAndW4(AW4 x,AW4 y){return min(x,y);} +//------------------------------------------------------------------------------------------------------------------------------ + AW1 AZolNotW1(AW1 x){return x^AW1_(1);} + AW2 AZolNotW2(AW2 x){return x^AW2_(1);} + AW3 AZolNotW3(AW3 x){return x^AW3_(1);} + AW4 AZolNotW4(AW4 x){return x^AW4_(1);} +//------------------------------------------------------------------------------------------------------------------------------ + AW1 AZolOrW1(AW1 x,AW1 y){return max(x,y);} + AW2 AZolOrW2(AW2 x,AW2 y){return max(x,y);} + AW3 AZolOrW3(AW3 x,AW3 y){return max(x,y);} + AW4 AZolOrW4(AW4 x,AW4 y){return max(x,y);} +//============================================================================================================================== + // Uses denormal trick. + AW1 AZolH1ToW1(AH1 x){return AW1_AH1(x*AH1_AW1(AW1_(1)));} + AW2 AZolH2ToW2(AH2 x){return AW2_AH2(x*AH2_AW2(AW2_(1)));} + AW3 AZolH3ToW3(AH3 x){return AW3_AH3(x*AH3_AW3(AW3_(1)));} + AW4 AZolH4ToW4(AH4 x){return AW4_AH4(x*AH4_AW4(AW4_(1)));} +//------------------------------------------------------------------------------------------------------------------------------ + // AMD arch lacks a packed conversion opcode. + AH1 AZolW1ToH1(AW1 x){return AH1_AW1(x*AW1_AH1(AH1_(1.0)));} + AH2 AZolW2ToH2(AW2 x){return AH2_AW2(x*AW2_AH2(AH2_(1.0)));} + AH3 AZolW1ToH3(AW3 x){return AH3_AW3(x*AW3_AH3(AH3_(1.0)));} + AH4 AZolW2ToH4(AW4 x){return AH4_AW4(x*AW4_AH4(AH4_(1.0)));} +//============================================================================================================================== + AH1 AZolAndH1(AH1 x,AH1 y){return min(x,y);} + AH2 AZolAndH2(AH2 x,AH2 y){return min(x,y);} + AH3 AZolAndH3(AH3 x,AH3 y){return min(x,y);} + AH4 AZolAndH4(AH4 x,AH4 y){return min(x,y);} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 ASolAndNotH1(AH1 x,AH1 y){return (-x)*y+AH1_(1.0);} + AH2 ASolAndNotH2(AH2 x,AH2 y){return (-x)*y+AH2_(1.0);} + AH3 ASolAndNotH3(AH3 x,AH3 y){return (-x)*y+AH3_(1.0);} + AH4 ASolAndNotH4(AH4 x,AH4 y){return (-x)*y+AH4_(1.0);} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AZolAndOrH1(AH1 x,AH1 y,AH1 z){return ASatH1(x*y+z);} + AH2 AZolAndOrH2(AH2 x,AH2 y,AH2 z){return ASatH2(x*y+z);} + AH3 AZolAndOrH3(AH3 x,AH3 y,AH3 z){return ASatH3(x*y+z);} + AH4 AZolAndOrH4(AH4 x,AH4 y,AH4 z){return ASatH4(x*y+z);} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AZolGtZeroH1(AH1 x){return ASatH1(x*AH1_(A_INFP_H));} + AH2 AZolGtZeroH2(AH2 x){return ASatH2(x*AH2_(A_INFP_H));} + AH3 AZolGtZeroH3(AH3 x){return ASatH3(x*AH3_(A_INFP_H));} + AH4 AZolGtZeroH4(AH4 x){return ASatH4(x*AH4_(A_INFP_H));} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AZolNotH1(AH1 x){return AH1_(1.0)-x;} + AH2 AZolNotH2(AH2 x){return AH2_(1.0)-x;} + AH3 AZolNotH3(AH3 x){return AH3_(1.0)-x;} + AH4 AZolNotH4(AH4 x){return AH4_(1.0)-x;} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AZolOrH1(AH1 x,AH1 y){return max(x,y);} + AH2 AZolOrH2(AH2 x,AH2 y){return max(x,y);} + AH3 AZolOrH3(AH3 x,AH3 y){return max(x,y);} + AH4 AZolOrH4(AH4 x,AH4 y){return max(x,y);} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AZolSelH1(AH1 x,AH1 y,AH1 z){AH1 r=(-x)*z+z;return x*y+r;} + AH2 AZolSelH2(AH2 x,AH2 y,AH2 z){AH2 r=(-x)*z+z;return x*y+r;} + AH3 AZolSelH3(AH3 x,AH3 y,AH3 z){AH3 r=(-x)*z+z;return x*y+r;} + AH4 AZolSelH4(AH4 x,AH4 y,AH4 z){AH4 r=(-x)*z+z;return x*y+r;} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AZolSignedH1(AH1 x){return ASatH1(x*AH1_(A_INFN_H));} + AH2 AZolSignedH2(AH2 x){return ASatH2(x*AH2_(A_INFN_H));} + AH3 AZolSignedH3(AH3 x){return ASatH3(x*AH3_(A_INFN_H));} + AH4 AZolSignedH4(AH4 x){return ASatH4(x*AH4_(A_INFN_H));} + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// COLOR CONVERSIONS +//------------------------------------------------------------------------------------------------------------------------------ +// These are all linear to/from some other space (where 'linear' has been shortened out of the function name). +// So 'ToGamma' is 'LinearToGamma', and 'FromGamma' is 'LinearFromGamma'. +// These are branch free implementations. +// The AToSrgbF1() function is useful for stores for compute shaders for GPUs without hardware linear->sRGB store conversion. +//------------------------------------------------------------------------------------------------------------------------------ +// TRANSFER FUNCTIONS +// ================== +// 709 ..... Rec709 used for some HDTVs +// Gamma ... Typically 2.2 for some PC displays, or 2.4-2.5 for CRTs, or 2.2 FreeSync2 native +// Pq ...... PQ native for HDR10 +// Srgb .... The sRGB output, typical of PC displays, useful for 10-bit output, or storing to 8-bit UNORM without SRGB type +// Two ..... Gamma 2.0, fastest conversion (useful for intermediate pass approximations) +// Three ... Gamma 3.0, less fast, but good for HDR. +//------------------------------------------------------------------------------------------------------------------------------ +// KEEPING TO SPEC +// =============== +// Both Rec.709 and sRGB have a linear segment which as spec'ed would intersect the curved segment 2 times. +// (a.) For 8-bit sRGB, steps {0 to 10.3} are in the linear region (4% of the encoding range). +// (b.) For 8-bit 709, steps {0 to 20.7} are in the linear region (8% of the encoding range). +// Also there is a slight step in the transition regions. +// Precision of the coefficients in the spec being the likely cause. +// Main usage case of the sRGB code is to do the linear->sRGB converstion in a compute shader before store. +// This is to work around lack of hardware (typically only ROP does the conversion for free). +// To "correct" the linear segment, would be to introduce error, because hardware decode of sRGB->linear is fixed (and free). +// So this header keeps with the spec. +// For linear->sRGB transforms, the linear segment in some respects reduces error, because rounding in that region is linear. +// Rounding in the curved region in hardware (and fast software code) introduces error due to rounding in non-linear. +//------------------------------------------------------------------------------------------------------------------------------ +// FOR PQ +// ====== +// Both input and output is {0.0-1.0}, and where output 1.0 represents 10000.0 cd/m^2. +// All constants are only specified to FP32 precision. +// External PQ source reference, +// - https://github.com/ampas/aces-dev/blob/master/transforms/ctl/utilities/ACESlib.Utilities_Color.a1.0.1.ctl +//------------------------------------------------------------------------------------------------------------------------------ +// PACKED VERSIONS +// =============== +// These are the A*H2() functions. +// There is no PQ functions as FP16 seemed to not have enough precision for the conversion. +// The remaining functions are "good enough" for 8-bit, and maybe 10-bit if not concerned about a few 1-bit errors. +// Precision is lowest in the 709 conversion, higher in sRGB, higher still in Two and Gamma (when using 2.2 at least). +//------------------------------------------------------------------------------------------------------------------------------ +// NOTES +// ===== +// Could be faster for PQ conversions to be in ALU or a texture lookup depending on usage case. +//============================================================================================================================== + #if 1 + AF1 ATo709F1(AF1 c){AF3 j=AF3(0.018*4.5,4.5,0.45);AF2 k=AF2(1.099,-0.099); + return clamp(j.x ,c*j.y ,pow(c,j.z )*k.x +k.y );} + AF2 ATo709F2(AF2 c){AF3 j=AF3(0.018*4.5,4.5,0.45);AF2 k=AF2(1.099,-0.099); + return clamp(j.xx ,c*j.yy ,pow(c,j.zz )*k.xx +k.yy );} + AF3 ATo709F3(AF3 c){AF3 j=AF3(0.018*4.5,4.5,0.45);AF2 k=AF2(1.099,-0.099); + return clamp(j.xxx,c*j.yyy,pow(c,j.zzz)*k.xxx+k.yyy);} +//------------------------------------------------------------------------------------------------------------------------------ + // Note 'rcpX' is '1/x', where the 'x' is what would be used in AFromGamma(). + AF1 AToGammaF1(AF1 c,AF1 rcpX){return pow(c,AF1_(rcpX));} + AF2 AToGammaF2(AF2 c,AF1 rcpX){return pow(c,AF2_(rcpX));} + AF3 AToGammaF3(AF3 c,AF1 rcpX){return pow(c,AF3_(rcpX));} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AToPqF1(AF1 x){AF1 p=pow(x,AF1_(0.159302)); + return pow((AF1_(0.835938)+AF1_(18.8516)*p)/(AF1_(1.0)+AF1_(18.6875)*p),AF1_(78.8438));} + AF2 AToPqF1(AF2 x){AF2 p=pow(x,AF2_(0.159302)); + return pow((AF2_(0.835938)+AF2_(18.8516)*p)/(AF2_(1.0)+AF2_(18.6875)*p),AF2_(78.8438));} + AF3 AToPqF1(AF3 x){AF3 p=pow(x,AF3_(0.159302)); + return pow((AF3_(0.835938)+AF3_(18.8516)*p)/(AF3_(1.0)+AF3_(18.6875)*p),AF3_(78.8438));} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AToSrgbF1(AF1 c){AF3 j=AF3(0.0031308*12.92,12.92,1.0/2.4);AF2 k=AF2(1.055,-0.055); + return clamp(j.x ,c*j.y ,pow(c,j.z )*k.x +k.y );} + AF2 AToSrgbF2(AF2 c){AF3 j=AF3(0.0031308*12.92,12.92,1.0/2.4);AF2 k=AF2(1.055,-0.055); + return clamp(j.xx ,c*j.yy ,pow(c,j.zz )*k.xx +k.yy );} + AF3 AToSrgbF3(AF3 c){AF3 j=AF3(0.0031308*12.92,12.92,1.0/2.4);AF2 k=AF2(1.055,-0.055); + return clamp(j.xxx,c*j.yyy,pow(c,j.zzz)*k.xxx+k.yyy);} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AToTwoF1(AF1 c){return sqrt(c);} + AF2 AToTwoF2(AF2 c){return sqrt(c);} + AF3 AToTwoF3(AF3 c){return sqrt(c);} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AToThreeF1(AF1 c){return pow(c,AF1_(1.0/3.0));} + AF2 AToThreeF2(AF2 c){return pow(c,AF2_(1.0/3.0));} + AF3 AToThreeF3(AF3 c){return pow(c,AF3_(1.0/3.0));} + #endif +//============================================================================================================================== + #if 1 + // Unfortunately median won't work here. + AF1 AFrom709F1(AF1 c){AF3 j=AF3(0.081/4.5,1.0/4.5,1.0/0.45);AF2 k=AF2(1.0/1.099,0.099/1.099); + return AZolSelF1(AZolSignedF1(c-j.x ),c*j.y ,pow(c*k.x +k.y ,j.z ));} + AF2 AFrom709F2(AF2 c){AF3 j=AF3(0.081/4.5,1.0/4.5,1.0/0.45);AF2 k=AF2(1.0/1.099,0.099/1.099); + return AZolSelF2(AZolSignedF2(c-j.xx ),c*j.yy ,pow(c*k.xx +k.yy ,j.zz ));} + AF3 AFrom709F3(AF3 c){AF3 j=AF3(0.081/4.5,1.0/4.5,1.0/0.45);AF2 k=AF2(1.0/1.099,0.099/1.099); + return AZolSelF3(AZolSignedF3(c-j.xxx),c*j.yyy,pow(c*k.xxx+k.yyy,j.zzz));} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AFromGammaF1(AF1 c,AF1 x){return pow(c,AF1_(x));} + AF2 AFromGammaF2(AF2 c,AF1 x){return pow(c,AF2_(x));} + AF3 AFromGammaF3(AF3 c,AF1 x){return pow(c,AF3_(x));} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AFromPqF1(AF1 x){AF1 p=pow(x,AF1_(0.0126833)); + return pow(ASatF1(p-AF1_(0.835938))/(AF1_(18.8516)-AF1_(18.6875)*p),AF1_(6.27739));} + AF2 AFromPqF1(AF2 x){AF2 p=pow(x,AF2_(0.0126833)); + return pow(ASatF2(p-AF2_(0.835938))/(AF2_(18.8516)-AF2_(18.6875)*p),AF2_(6.27739));} + AF3 AFromPqF1(AF3 x){AF3 p=pow(x,AF3_(0.0126833)); + return pow(ASatF3(p-AF3_(0.835938))/(AF3_(18.8516)-AF3_(18.6875)*p),AF3_(6.27739));} +//------------------------------------------------------------------------------------------------------------------------------ + // Unfortunately median won't work here. + AF1 AFromSrgbF1(AF1 c){AF3 j=AF3(0.04045/12.92,1.0/12.92,2.4);AF2 k=AF2(1.0/1.055,0.055/1.055); + return AZolSelF1(AZolSignedF1(c-j.x ),c*j.y ,pow(c*k.x +k.y ,j.z ));} + AF2 AFromSrgbF2(AF2 c){AF3 j=AF3(0.04045/12.92,1.0/12.92,2.4);AF2 k=AF2(1.0/1.055,0.055/1.055); + return AZolSelF2(AZolSignedF2(c-j.xx ),c*j.yy ,pow(c*k.xx +k.yy ,j.zz ));} + AF3 AFromSrgbF3(AF3 c){AF3 j=AF3(0.04045/12.92,1.0/12.92,2.4);AF2 k=AF2(1.0/1.055,0.055/1.055); + return AZolSelF3(AZolSignedF3(c-j.xxx),c*j.yyy,pow(c*k.xxx+k.yyy,j.zzz));} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AFromTwoF1(AF1 c){return c*c;} + AF2 AFromTwoF2(AF2 c){return c*c;} + AF3 AFromTwoF3(AF3 c){return c*c;} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AFromThreeF1(AF1 c){return c*c*c;} + AF2 AFromThreeF2(AF2 c){return c*c*c;} + AF3 AFromThreeF3(AF3 c){return c*c*c;} + #endif +//============================================================================================================================== + #ifdef A_HALF + AH1 ATo709H1(AH1 c){AH3 j=AH3(0.018*4.5,4.5,0.45);AH2 k=AH2(1.099,-0.099); + return clamp(j.x ,c*j.y ,pow(c,j.z )*k.x +k.y );} + AH2 ATo709H2(AH2 c){AH3 j=AH3(0.018*4.5,4.5,0.45);AH2 k=AH2(1.099,-0.099); + return clamp(j.xx ,c*j.yy ,pow(c,j.zz )*k.xx +k.yy );} + AH3 ATo709H3(AH3 c){AH3 j=AH3(0.018*4.5,4.5,0.45);AH2 k=AH2(1.099,-0.099); + return clamp(j.xxx,c*j.yyy,pow(c,j.zzz)*k.xxx+k.yyy);} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AToGammaH1(AH1 c,AH1 rcpX){return pow(c,AH1_(rcpX));} + AH2 AToGammaH2(AH2 c,AH1 rcpX){return pow(c,AH2_(rcpX));} + AH3 AToGammaH3(AH3 c,AH1 rcpX){return pow(c,AH3_(rcpX));} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AToSrgbH1(AH1 c){AH3 j=AH3(0.0031308*12.92,12.92,1.0/2.4);AH2 k=AH2(1.055,-0.055); + return clamp(j.x ,c*j.y ,pow(c,j.z )*k.x +k.y );} + AH2 AToSrgbH2(AH2 c){AH3 j=AH3(0.0031308*12.92,12.92,1.0/2.4);AH2 k=AH2(1.055,-0.055); + return clamp(j.xx ,c*j.yy ,pow(c,j.zz )*k.xx +k.yy );} + AH3 AToSrgbH3(AH3 c){AH3 j=AH3(0.0031308*12.92,12.92,1.0/2.4);AH2 k=AH2(1.055,-0.055); + return clamp(j.xxx,c*j.yyy,pow(c,j.zzz)*k.xxx+k.yyy);} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AToTwoH1(AH1 c){return sqrt(c);} + AH2 AToTwoH2(AH2 c){return sqrt(c);} + AH3 AToTwoH3(AH3 c){return sqrt(c);} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AToThreeF1(AH1 c){return pow(c,AH1_(1.0/3.0));} + AH2 AToThreeF2(AH2 c){return pow(c,AH2_(1.0/3.0));} + AH3 AToThreeF3(AH3 c){return pow(c,AH3_(1.0/3.0));} + #endif +//============================================================================================================================== + #ifdef A_HALF + AH1 AFrom709H1(AH1 c){AH3 j=AH3(0.081/4.5,1.0/4.5,1.0/0.45);AH2 k=AH2(1.0/1.099,0.099/1.099); + return AZolSelH1(AZolSignedH1(c-j.x ),c*j.y ,pow(c*k.x +k.y ,j.z ));} + AH2 AFrom709H2(AH2 c){AH3 j=AH3(0.081/4.5,1.0/4.5,1.0/0.45);AH2 k=AH2(1.0/1.099,0.099/1.099); + return AZolSelH2(AZolSignedH2(c-j.xx ),c*j.yy ,pow(c*k.xx +k.yy ,j.zz ));} + AH3 AFrom709H3(AH3 c){AH3 j=AH3(0.081/4.5,1.0/4.5,1.0/0.45);AH2 k=AH2(1.0/1.099,0.099/1.099); + return AZolSelH3(AZolSignedH3(c-j.xxx),c*j.yyy,pow(c*k.xxx+k.yyy,j.zzz));} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AFromGammaH1(AH1 c,AH1 x){return pow(c,AH1_(x));} + AH2 AFromGammaH2(AH2 c,AH1 x){return pow(c,AH2_(x));} + AH3 AFromGammaH3(AH3 c,AH1 x){return pow(c,AH3_(x));} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AHromSrgbF1(AH1 c){AH3 j=AH3(0.04045/12.92,1.0/12.92,2.4);AH2 k=AH2(1.0/1.055,0.055/1.055); + return AZolSelH1(AZolSignedH1(c-j.x ),c*j.y ,pow(c*k.x +k.y ,j.z ));} + AH2 AHromSrgbF2(AH2 c){AH3 j=AH3(0.04045/12.92,1.0/12.92,2.4);AH2 k=AH2(1.0/1.055,0.055/1.055); + return AZolSelH2(AZolSignedH2(c-j.xx ),c*j.yy ,pow(c*k.xx +k.yy ,j.zz ));} + AH3 AHromSrgbF3(AH3 c){AH3 j=AH3(0.04045/12.92,1.0/12.92,2.4);AH2 k=AH2(1.0/1.055,0.055/1.055); + return AZolSelH3(AZolSignedH3(c-j.xxx),c*j.yyy,pow(c*k.xxx+k.yyy,j.zzz));} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AFromTwoH1(AH1 c){return c*c;} + AH2 AFromTwoH2(AH2 c){return c*c;} + AH3 AFromTwoH3(AH3 c){return c*c;} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AFromThreeH1(AH1 c){return c*c*c;} + AH2 AFromThreeH2(AH2 c){return c*c*c;} + AH3 AFromThreeH3(AH3 c){return c*c*c;} + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// CS REMAP +//============================================================================================================================== + // Simple remap 64x1 to 8x8 with rotated 2x2 pixel quads in quad linear. + // 543210 + // ====== + // ..xxx. + // yy...y + AU2 ARmp8x8(AU1 a){return AU2(ABfe(a,1u,3u),ABfiM(ABfe(a,3u,3u),a,1u));} +//============================================================================================================================== + // More complex remap 64x1 to 8x8 which is necessary for 2D wave reductions. + // 543210 + // ====== + // .xx..x + // y..yy. + // Details, + // LANE TO 8x8 MAPPING + // =================== + // 00 01 08 09 10 11 18 19 + // 02 03 0a 0b 12 13 1a 1b + // 04 05 0c 0d 14 15 1c 1d + // 06 07 0e 0f 16 17 1e 1f + // 20 21 28 29 30 31 38 39 + // 22 23 2a 2b 32 33 3a 3b + // 24 25 2c 2d 34 35 3c 3d + // 26 27 2e 2f 36 37 3e 3f + AU2 ARmpRed8x8(AU1 a){return AU2(ABfiM(ABfe(a,2u,3u),a,1u),ABfiM(ABfe(a,3u,3u),ABfe(a,1u,2u),2u));} +//============================================================================================================================== + #ifdef A_HALF + AW2 ARmp8x8H(AU1 a){return AW2(ABfe(a,1u,3u),ABfiM(ABfe(a,3u,3u),a,1u));} + AW2 ARmpRed8x8H(AU1 a){return AW2(ABfiM(ABfe(a,2u,3u),a,1u),ABfiM(ABfe(a,3u,3u),ABfe(a,1u,2u),2u));} + #endif +#endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// +// REFERENCE +// +//------------------------------------------------------------------------------------------------------------------------------ +// IEEE FLOAT RULES +// ================ +// - saturate(NaN)=0, saturate(-INF)=0, saturate(+INF)=1 +// - {+/-}0 * {+/-}INF = NaN +// - -INF + (+INF) = NaN +// - {+/-}0 / {+/-}0 = NaN +// - {+/-}INF / {+/-}INF = NaN +// - a<(-0) := sqrt(a) = NaN (a=-0.0 won't NaN) +// - 0 == -0 +// - 4/0 = +INF +// - 4/-0 = -INF +// - 4+INF = +INF +// - 4-INF = -INF +// - 4*(+INF) = +INF +// - 4*(-INF) = -INF +// - -4*(+INF) = -INF +// - sqrt(+INF) = +INF +//------------------------------------------------------------------------------------------------------------------------------ +// FP16 ENCODING +// ============= +// fedcba9876543210 +// ---------------- +// ......mmmmmmmmmm 10-bit mantissa (encodes 11-bit 0.5 to 1.0 except for denormals) +// .eeeee.......... 5-bit exponent +// .00000.......... denormals +// .00001.......... -14 exponent +// .11110.......... 15 exponent +// .111110000000000 infinity +// .11111nnnnnnnnnn NaN with n!=0 +// s............... sign +//------------------------------------------------------------------------------------------------------------------------------ +// FP16/INT16 ALIASING DENORMAL +// ============================ +// 11-bit unsigned integers alias with half float denormal/normal values, +// 1 = 2^(-24) = 1/16777216 ....................... first denormal value +// 2 = 2^(-23) +// ... +// 1023 = 2^(-14)*(1-2^(-10)) = 2^(-14)*(1-1/1024) ... last denormal value +// 1024 = 2^(-14) = 1/16384 .......................... first normal value that still maps to integers +// 2047 .............................................. last normal value that still maps to integers +// Scaling limits, +// 2^15 = 32768 ...................................... largest power of 2 scaling +// Largest pow2 conversion mapping is at *32768, +// 1 : 2^(-9) = 1/512 +// 2 : 1/256 +// 4 : 1/128 +// 8 : 1/64 +// 16 : 1/32 +// 32 : 1/16 +// 64 : 1/8 +// 128 : 1/4 +// 256 : 1/2 +// 512 : 1 +// 1024 : 2 +// 2047 : a little less than 4 +//============================================================================================================================== +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// +// +// GPU/CPU PORTABILITY +// +// +//------------------------------------------------------------------------------------------------------------------------------ +// This is the GPU implementation. +// See the CPU implementation for docs. +//============================================================================================================================== +#ifdef A_GPU + #define A_TRUE true + #define A_FALSE false + #define A_STATIC +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// VECTOR ARGUMENT/RETURN/INITIALIZATION PORTABILITY +//============================================================================================================================== + #define retAD2 AD2 + #define retAD3 AD3 + #define retAD4 AD4 + #define retAF2 AF2 + #define retAF3 AF3 + #define retAF4 AF4 + #define retAL2 AL2 + #define retAL3 AL3 + #define retAL4 AL4 + #define retAU2 AU2 + #define retAU3 AU3 + #define retAU4 AU4 +//------------------------------------------------------------------------------------------------------------------------------ + #define inAD2 in AD2 + #define inAD3 in AD3 + #define inAD4 in AD4 + #define inAF2 in AF2 + #define inAF3 in AF3 + #define inAF4 in AF4 + #define inAL2 in AL2 + #define inAL3 in AL3 + #define inAL4 in AL4 + #define inAU2 in AU2 + #define inAU3 in AU3 + #define inAU4 in AU4 +//------------------------------------------------------------------------------------------------------------------------------ + #define inoutAD2 inout AD2 + #define inoutAD3 inout AD3 + #define inoutAD4 inout AD4 + #define inoutAF2 inout AF2 + #define inoutAF3 inout AF3 + #define inoutAF4 inout AF4 + #define inoutAL2 inout AL2 + #define inoutAL3 inout AL3 + #define inoutAL4 inout AL4 + #define inoutAU2 inout AU2 + #define inoutAU3 inout AU3 + #define inoutAU4 inout AU4 +//------------------------------------------------------------------------------------------------------------------------------ + #define outAD2 out AD2 + #define outAD3 out AD3 + #define outAD4 out AD4 + #define outAF2 out AF2 + #define outAF3 out AF3 + #define outAF4 out AF4 + #define outAL2 out AL2 + #define outAL3 out AL3 + #define outAL4 out AL4 + #define outAU2 out AU2 + #define outAU3 out AU3 + #define outAU4 out AU4 +//------------------------------------------------------------------------------------------------------------------------------ + #define varAD2(x) AD2 x + #define varAD3(x) AD3 x + #define varAD4(x) AD4 x + #define varAF2(x) AF2 x + #define varAF3(x) AF3 x + #define varAF4(x) AF4 x + #define varAL2(x) AL2 x + #define varAL3(x) AL3 x + #define varAL4(x) AL4 x + #define varAU2(x) AU2 x + #define varAU3(x) AU3 x + #define varAU4(x) AU4 x +//------------------------------------------------------------------------------------------------------------------------------ + #define initAD2(x,y) AD2(x,y) + #define initAD3(x,y,z) AD3(x,y,z) + #define initAD4(x,y,z,w) AD4(x,y,z,w) + #define initAF2(x,y) AF2(x,y) + #define initAF3(x,y,z) AF3(x,y,z) + #define initAF4(x,y,z,w) AF4(x,y,z,w) + #define initAL2(x,y) AL2(x,y) + #define initAL3(x,y,z) AL3(x,y,z) + #define initAL4(x,y,z,w) AL4(x,y,z,w) + #define initAU2(x,y) AU2(x,y) + #define initAU3(x,y,z) AU3(x,y,z) + #define initAU4(x,y,z,w) AU4(x,y,z,w) +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// SCALAR RETURN OPS +//============================================================================================================================== + #define AAbsD1(a) abs(AD1(a)) + #define AAbsF1(a) abs(AF1(a)) +//------------------------------------------------------------------------------------------------------------------------------ + #define ACosD1(a) cos(AD1(a)) + #define ACosF1(a) cos(AF1(a)) +//------------------------------------------------------------------------------------------------------------------------------ + #define ADotD2(a,b) dot(AD2(a),AD2(b)) + #define ADotD3(a,b) dot(AD3(a),AD3(b)) + #define ADotD4(a,b) dot(AD4(a),AD4(b)) + #define ADotF2(a,b) dot(AF2(a),AF2(b)) + #define ADotF3(a,b) dot(AF3(a),AF3(b)) + #define ADotF4(a,b) dot(AF4(a),AF4(b)) +//------------------------------------------------------------------------------------------------------------------------------ + #define AExp2D1(a) exp2(AD1(a)) + #define AExp2F1(a) exp2(AF1(a)) +//------------------------------------------------------------------------------------------------------------------------------ + #define AFloorD1(a) floor(AD1(a)) + #define AFloorF1(a) floor(AF1(a)) +//------------------------------------------------------------------------------------------------------------------------------ + #define ALog2D1(a) log2(AD1(a)) + #define ALog2F1(a) log2(AF1(a)) +//------------------------------------------------------------------------------------------------------------------------------ + #define AMaxD1(a,b) max(a,b) + #define AMaxF1(a,b) max(a,b) + #define AMaxL1(a,b) max(a,b) + #define AMaxU1(a,b) max(a,b) +//------------------------------------------------------------------------------------------------------------------------------ + #define AMinD1(a,b) min(a,b) + #define AMinF1(a,b) min(a,b) + #define AMinL1(a,b) min(a,b) + #define AMinU1(a,b) min(a,b) +//------------------------------------------------------------------------------------------------------------------------------ + #define ASinD1(a) sin(AD1(a)) + #define ASinF1(a) sin(AF1(a)) +//------------------------------------------------------------------------------------------------------------------------------ + #define ASqrtD1(a) sqrt(AD1(a)) + #define ASqrtF1(a) sqrt(AF1(a)) +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// SCALAR RETURN OPS - DEPENDENT +//============================================================================================================================== + #define APowD1(a,b) pow(AD1(a),AF1(b)) + #define APowF1(a,b) pow(AF1(a),AF1(b)) +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// VECTOR OPS +//------------------------------------------------------------------------------------------------------------------------------ +// These are added as needed for production or prototyping, so not necessarily a complete set. +// They follow a convention of taking in a destination and also returning the destination value to increase utility. +//============================================================================================================================== + #ifdef A_DUBL + AD2 opAAbsD2(outAD2 d,inAD2 a){d=abs(a);return d;} + AD3 opAAbsD3(outAD3 d,inAD3 a){d=abs(a);return d;} + AD4 opAAbsD4(outAD4 d,inAD4 a){d=abs(a);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AD2 opAAddD2(outAD2 d,inAD2 a,inAD2 b){d=a+b;return d;} + AD3 opAAddD3(outAD3 d,inAD3 a,inAD3 b){d=a+b;return d;} + AD4 opAAddD4(outAD4 d,inAD4 a,inAD4 b){d=a+b;return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AD2 opAAddOneD2(outAD2 d,inAD2 a,AD1 b){d=a+AD2_(b);return d;} + AD3 opAAddOneD3(outAD3 d,inAD3 a,AD1 b){d=a+AD3_(b);return d;} + AD4 opAAddOneD4(outAD4 d,inAD4 a,AD1 b){d=a+AD4_(b);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AD2 opACpyD2(outAD2 d,inAD2 a){d=a;return d;} + AD3 opACpyD3(outAD3 d,inAD3 a){d=a;return d;} + AD4 opACpyD4(outAD4 d,inAD4 a){d=a;return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AD2 opALerpD2(outAD2 d,inAD2 a,inAD2 b,inAD2 c){d=ALerpD2(a,b,c);return d;} + AD3 opALerpD3(outAD3 d,inAD3 a,inAD3 b,inAD3 c){d=ALerpD3(a,b,c);return d;} + AD4 opALerpD4(outAD4 d,inAD4 a,inAD4 b,inAD4 c){d=ALerpD4(a,b,c);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AD2 opALerpOneD2(outAD2 d,inAD2 a,inAD2 b,AD1 c){d=ALerpD2(a,b,AD2_(c));return d;} + AD3 opALerpOneD3(outAD3 d,inAD3 a,inAD3 b,AD1 c){d=ALerpD3(a,b,AD3_(c));return d;} + AD4 opALerpOneD4(outAD4 d,inAD4 a,inAD4 b,AD1 c){d=ALerpD4(a,b,AD4_(c));return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AD2 opAMaxD2(outAD2 d,inAD2 a,inAD2 b){d=max(a,b);return d;} + AD3 opAMaxD3(outAD3 d,inAD3 a,inAD3 b){d=max(a,b);return d;} + AD4 opAMaxD4(outAD4 d,inAD4 a,inAD4 b){d=max(a,b);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AD2 opAMinD2(outAD2 d,inAD2 a,inAD2 b){d=min(a,b);return d;} + AD3 opAMinD3(outAD3 d,inAD3 a,inAD3 b){d=min(a,b);return d;} + AD4 opAMinD4(outAD4 d,inAD4 a,inAD4 b){d=min(a,b);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AD2 opAMulD2(outAD2 d,inAD2 a,inAD2 b){d=a*b;return d;} + AD3 opAMulD3(outAD3 d,inAD3 a,inAD3 b){d=a*b;return d;} + AD4 opAMulD4(outAD4 d,inAD4 a,inAD4 b){d=a*b;return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AD2 opAMulOneD2(outAD2 d,inAD2 a,AD1 b){d=a*AD2_(b);return d;} + AD3 opAMulOneD3(outAD3 d,inAD3 a,AD1 b){d=a*AD3_(b);return d;} + AD4 opAMulOneD4(outAD4 d,inAD4 a,AD1 b){d=a*AD4_(b);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AD2 opANegD2(outAD2 d,inAD2 a){d=-a;return d;} + AD3 opANegD3(outAD3 d,inAD3 a){d=-a;return d;} + AD4 opANegD4(outAD4 d,inAD4 a){d=-a;return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AD2 opARcpD2(outAD2 d,inAD2 a){d=ARcpD2(a);return d;} + AD3 opARcpD3(outAD3 d,inAD3 a){d=ARcpD3(a);return d;} + AD4 opARcpD4(outAD4 d,inAD4 a){d=ARcpD4(a);return d;} + #endif +//============================================================================================================================== + AF2 opAAbsF2(outAF2 d,inAF2 a){d=abs(a);return d;} + AF3 opAAbsF3(outAF3 d,inAF3 a){d=abs(a);return d;} + AF4 opAAbsF4(outAF4 d,inAF4 a){d=abs(a);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AF2 opAAddF2(outAF2 d,inAF2 a,inAF2 b){d=a+b;return d;} + AF3 opAAddF3(outAF3 d,inAF3 a,inAF3 b){d=a+b;return d;} + AF4 opAAddF4(outAF4 d,inAF4 a,inAF4 b){d=a+b;return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AF2 opAAddOneF2(outAF2 d,inAF2 a,AF1 b){d=a+AF2_(b);return d;} + AF3 opAAddOneF3(outAF3 d,inAF3 a,AF1 b){d=a+AF3_(b);return d;} + AF4 opAAddOneF4(outAF4 d,inAF4 a,AF1 b){d=a+AF4_(b);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AF2 opACpyF2(outAF2 d,inAF2 a){d=a;return d;} + AF3 opACpyF3(outAF3 d,inAF3 a){d=a;return d;} + AF4 opACpyF4(outAF4 d,inAF4 a){d=a;return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AF2 opALerpF2(outAF2 d,inAF2 a,inAF2 b,inAF2 c){d=ALerpF2(a,b,c);return d;} + AF3 opALerpF3(outAF3 d,inAF3 a,inAF3 b,inAF3 c){d=ALerpF3(a,b,c);return d;} + AF4 opALerpF4(outAF4 d,inAF4 a,inAF4 b,inAF4 c){d=ALerpF4(a,b,c);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AF2 opALerpOneF2(outAF2 d,inAF2 a,inAF2 b,AF1 c){d=ALerpF2(a,b,AF2_(c));return d;} + AF3 opALerpOneF3(outAF3 d,inAF3 a,inAF3 b,AF1 c){d=ALerpF3(a,b,AF3_(c));return d;} + AF4 opALerpOneF4(outAF4 d,inAF4 a,inAF4 b,AF1 c){d=ALerpF4(a,b,AF4_(c));return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AF2 opAMaxF2(outAF2 d,inAF2 a,inAF2 b){d=max(a,b);return d;} + AF3 opAMaxF3(outAF3 d,inAF3 a,inAF3 b){d=max(a,b);return d;} + AF4 opAMaxF4(outAF4 d,inAF4 a,inAF4 b){d=max(a,b);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AF2 opAMinF2(outAF2 d,inAF2 a,inAF2 b){d=min(a,b);return d;} + AF3 opAMinF3(outAF3 d,inAF3 a,inAF3 b){d=min(a,b);return d;} + AF4 opAMinF4(outAF4 d,inAF4 a,inAF4 b){d=min(a,b);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AF2 opAMulF2(outAF2 d,inAF2 a,inAF2 b){d=a*b;return d;} + AF3 opAMulF3(outAF3 d,inAF3 a,inAF3 b){d=a*b;return d;} + AF4 opAMulF4(outAF4 d,inAF4 a,inAF4 b){d=a*b;return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AF2 opAMulOneF2(outAF2 d,inAF2 a,AF1 b){d=a*AF2_(b);return d;} + AF3 opAMulOneF3(outAF3 d,inAF3 a,AF1 b){d=a*AF3_(b);return d;} + AF4 opAMulOneF4(outAF4 d,inAF4 a,AF1 b){d=a*AF4_(b);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AF2 opANegF2(outAF2 d,inAF2 a){d=-a;return d;} + AF3 opANegF3(outAF3 d,inAF3 a){d=-a;return d;} + AF4 opANegF4(outAF4 d,inAF4 a){d=-a;return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AF2 opARcpF2(outAF2 d,inAF2 a){d=ARcpF2(a);return d;} + AF3 opARcpF3(outAF3 d,inAF3 a){d=ARcpF3(a);return d;} + AF4 opARcpF4(outAF4 d,inAF4 a){d=ARcpF4(a);return d;} +#endif diff --git a/src/video_core/host_shaders/fsr/ffx_fsr1.h b/src/video_core/host_shaders/fsr/ffx_fsr1.h new file mode 100644 index 000000000..b0fe75ea9 --- /dev/null +++ b/src/video_core/host_shaders/fsr/ffx_fsr1.h @@ -0,0 +1,1200 @@ +// clang-format off +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// +// +// AMD FidelityFX SUPER RESOLUTION [FSR 1] ::: SPATIAL SCALING & EXTRAS - v1.20210629 +// +// +//------------------------------------------------------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//------------------------------------------------------------------------------------------------------------------------------ +// FidelityFX Super Resolution Sample +// +// Copyright (c) 2021 Advanced Micro Devices, Inc. All rights reserved. +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +//------------------------------------------------------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//------------------------------------------------------------------------------------------------------------------------------ +// ABOUT +// ===== +// FSR is a collection of algorithms relating to generating a higher resolution image. +// This specific header focuses on single-image non-temporal image scaling, and related tools. +// +// The core functions are EASU and RCAS: +// [EASU] Edge Adaptive Spatial Upsampling ....... 1x to 4x area range spatial scaling, clamped adaptive elliptical filter. +// [RCAS] Robust Contrast Adaptive Sharpening .... A non-scaling variation on CAS. +// RCAS needs to be applied after EASU as a separate pass. +// +// Optional utility functions are: +// [LFGA] Linear Film Grain Applicator ........... Tool to apply film grain after scaling. +// [SRTM] Simple Reversible Tone-Mapper .......... Linear HDR {0 to FP16_MAX} to {0 to 1} and back. +// [TEPD] Temporal Energy Preserving Dither ...... Temporally energy preserving dithered {0 to 1} linear to gamma 2.0 conversion. +// See each individual sub-section for inline documentation. +//------------------------------------------------------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//------------------------------------------------------------------------------------------------------------------------------ +// FUNCTION PERMUTATIONS +// ===================== +// *F() ..... Single item computation with 32-bit. +// *H() ..... Single item computation with 16-bit, with packing (aka two 16-bit ops in parallel) when possible. +// *Hx2() ... Processing two items in parallel with 16-bit, easier packing. +// Not all interfaces in this file have a *Hx2() form. +//============================================================================================================================== +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// +// FSR - [EASU] EDGE ADAPTIVE SPATIAL UPSAMPLING +// +//------------------------------------------------------------------------------------------------------------------------------ +// EASU provides a high quality spatial-only scaling at relatively low cost. +// Meaning EASU is appropiate for laptops and other low-end GPUs. +// Quality from 1x to 4x area scaling is good. +//------------------------------------------------------------------------------------------------------------------------------ +// The scalar uses a modified fast approximation to the standard lanczos(size=2) kernel. +// EASU runs in a single pass, so it applies a directionally and anisotropically adaptive radial lanczos. +// This is also kept as simple as possible to have minimum runtime. +//------------------------------------------------------------------------------------------------------------------------------ +// The lanzcos filter has negative lobes, so by itself it will introduce ringing. +// To remove all ringing, the algorithm uses the nearest 2x2 input texels as a neighborhood, +// and limits output to the minimum and maximum of that neighborhood. +//------------------------------------------------------------------------------------------------------------------------------ +// Input image requirements: +// +// Color needs to be encoded as 3 channel[red, green, blue](e.g.XYZ not supported) +// Each channel needs to be in the range[0, 1] +// Any color primaries are supported +// Display / tonemapping curve needs to be as if presenting to sRGB display or similar(e.g.Gamma 2.0) +// There should be no banding in the input +// There should be no high amplitude noise in the input +// There should be no noise in the input that is not at input pixel granularity +// For performance purposes, use 32bpp formats +//------------------------------------------------------------------------------------------------------------------------------ +// Best to apply EASU at the end of the frame after tonemapping +// but before film grain or composite of the UI. +//------------------------------------------------------------------------------------------------------------------------------ +// Example of including this header for D3D HLSL : +// +// #define A_GPU 1 +// #define A_HLSL 1 +// #define A_HALF 1 +// #include "ffx_a.h" +// #define FSR_EASU_H 1 +// #define FSR_RCAS_H 1 +// //declare input callbacks +// #include "ffx_fsr1.h" +// +// Example of including this header for Vulkan GLSL : +// +// #define A_GPU 1 +// #define A_GLSL 1 +// #define A_HALF 1 +// #include "ffx_a.h" +// #define FSR_EASU_H 1 +// #define FSR_RCAS_H 1 +// //declare input callbacks +// #include "ffx_fsr1.h" +// +// Example of including this header for Vulkan HLSL : +// +// #define A_GPU 1 +// #define A_HLSL 1 +// #define A_HLSL_6_2 1 +// #define A_NO_16_BIT_CAST 1 +// #define A_HALF 1 +// #include "ffx_a.h" +// #define FSR_EASU_H 1 +// #define FSR_RCAS_H 1 +// //declare input callbacks +// #include "ffx_fsr1.h" +// +// Example of declaring the required input callbacks for GLSL : +// The callbacks need to gather4 for each color channel using the specified texture coordinate 'p'. +// EASU uses gather4 to reduce position computation logic and for free Arrays of Structures to Structures of Arrays conversion. +// +// AH4 FsrEasuRH(AF2 p){return AH4(textureGather(sampler2D(tex,sam),p,0));} +// AH4 FsrEasuGH(AF2 p){return AH4(textureGather(sampler2D(tex,sam),p,1));} +// AH4 FsrEasuBH(AF2 p){return AH4(textureGather(sampler2D(tex,sam),p,2));} +// ... +// The FsrEasuCon function needs to be called from the CPU or GPU to set up constants. +// The difference in viewport and input image size is there to support Dynamic Resolution Scaling. +// To use FsrEasuCon() on the CPU, define A_CPU before including ffx_a and ffx_fsr1. +// Including a GPU example here, the 'con0' through 'con3' values would be stored out to a constant buffer. +// AU4 con0,con1,con2,con3; +// FsrEasuCon(con0,con1,con2,con3, +// 1920.0,1080.0, // Viewport size (top left aligned) in the input image which is to be scaled. +// 3840.0,2160.0, // The size of the input image. +// 2560.0,1440.0); // The output resolution. +//============================================================================================================================== +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// CONSTANT SETUP +//============================================================================================================================== +// Call to setup required constant values (works on CPU or GPU). +A_STATIC void FsrEasuCon( +outAU4 con0, +outAU4 con1, +outAU4 con2, +outAU4 con3, +// This the rendered image resolution being upscaled +AF1 inputViewportInPixelsX, +AF1 inputViewportInPixelsY, +// This is the resolution of the resource containing the input image (useful for dynamic resolution) +AF1 inputSizeInPixelsX, +AF1 inputSizeInPixelsY, +// This is the display resolution which the input image gets upscaled to +AF1 outputSizeInPixelsX, +AF1 outputSizeInPixelsY){ + // Output integer position to a pixel position in viewport. + con0[0]=AU1_AF1(inputViewportInPixelsX*ARcpF1(outputSizeInPixelsX)); + con0[1]=AU1_AF1(inputViewportInPixelsY*ARcpF1(outputSizeInPixelsY)); + con0[2]=AU1_AF1(AF1_(0.5)*inputViewportInPixelsX*ARcpF1(outputSizeInPixelsX)-AF1_(0.5)); + con0[3]=AU1_AF1(AF1_(0.5)*inputViewportInPixelsY*ARcpF1(outputSizeInPixelsY)-AF1_(0.5)); + // Viewport pixel position to normalized image space. + // This is used to get upper-left of 'F' tap. + con1[0]=AU1_AF1(ARcpF1(inputSizeInPixelsX)); + con1[1]=AU1_AF1(ARcpF1(inputSizeInPixelsY)); + // Centers of gather4, first offset from upper-left of 'F'. + // +---+---+ + // | | | + // +--(0)--+ + // | b | c | + // +---F---+---+---+ + // | e | f | g | h | + // +--(1)--+--(2)--+ + // | i | j | k | l | + // +---+---+---+---+ + // | n | o | + // +--(3)--+ + // | | | + // +---+---+ + con1[2]=AU1_AF1(AF1_( 1.0)*ARcpF1(inputSizeInPixelsX)); + con1[3]=AU1_AF1(AF1_(-1.0)*ARcpF1(inputSizeInPixelsY)); + // These are from (0) instead of 'F'. + con2[0]=AU1_AF1(AF1_(-1.0)*ARcpF1(inputSizeInPixelsX)); + con2[1]=AU1_AF1(AF1_( 2.0)*ARcpF1(inputSizeInPixelsY)); + con2[2]=AU1_AF1(AF1_( 1.0)*ARcpF1(inputSizeInPixelsX)); + con2[3]=AU1_AF1(AF1_( 2.0)*ARcpF1(inputSizeInPixelsY)); + con3[0]=AU1_AF1(AF1_( 0.0)*ARcpF1(inputSizeInPixelsX)); + con3[1]=AU1_AF1(AF1_( 4.0)*ARcpF1(inputSizeInPixelsY)); + con3[2]=con3[3]=0;} + +//If the an offset into the input image resource +A_STATIC void FsrEasuConOffset( + outAU4 con0, + outAU4 con1, + outAU4 con2, + outAU4 con3, + // This the rendered image resolution being upscaled + AF1 inputViewportInPixelsX, + AF1 inputViewportInPixelsY, + // This is the resolution of the resource containing the input image (useful for dynamic resolution) + AF1 inputSizeInPixelsX, + AF1 inputSizeInPixelsY, + // This is the display resolution which the input image gets upscaled to + AF1 outputSizeInPixelsX, + AF1 outputSizeInPixelsY, + // This is the input image offset into the resource containing it (useful for dynamic resolution) + AF1 inputOffsetInPixelsX, + AF1 inputOffsetInPixelsY) { + FsrEasuCon(con0, con1, con2, con3, inputViewportInPixelsX, inputViewportInPixelsY, inputSizeInPixelsX, inputSizeInPixelsY, outputSizeInPixelsX, outputSizeInPixelsY); + con0[2] = AU1_AF1(AF1_(0.5) * inputViewportInPixelsX * ARcpF1(outputSizeInPixelsX) - AF1_(0.5) + inputOffsetInPixelsX); + con0[3] = AU1_AF1(AF1_(0.5) * inputViewportInPixelsY * ARcpF1(outputSizeInPixelsY) - AF1_(0.5) + inputOffsetInPixelsY); +} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// NON-PACKED 32-BIT VERSION +//============================================================================================================================== +#if defined(A_GPU)&&defined(FSR_EASU_F) + // Input callback prototypes, need to be implemented by calling shader + AF4 FsrEasuRF(AF2 p); + AF4 FsrEasuGF(AF2 p); + AF4 FsrEasuBF(AF2 p); +//------------------------------------------------------------------------------------------------------------------------------ + // Filtering for a given tap for the scalar. + void FsrEasuTapF( + inout AF3 aC, // Accumulated color, with negative lobe. + inout AF1 aW, // Accumulated weight. + AF2 off, // Pixel offset from resolve position to tap. + AF2 dir, // Gradient direction. + AF2 len, // Length. + AF1 lob, // Negative lobe strength. + AF1 clp, // Clipping point. + AF3 c){ // Tap color. + // Rotate offset by direction. + AF2 v; + v.x=(off.x*( dir.x))+(off.y*dir.y); + v.y=(off.x*(-dir.y))+(off.y*dir.x); + // Anisotropy. + v*=len; + // Compute distance^2. + AF1 d2=v.x*v.x+v.y*v.y; + // Limit to the window as at corner, 2 taps can easily be outside. + d2=min(d2,clp); + // Approximation of lancos2 without sin() or rcp(), or sqrt() to get x. + // (25/16 * (2/5 * x^2 - 1)^2 - (25/16 - 1)) * (1/4 * x^2 - 1)^2 + // |_______________________________________| |_______________| + // base window + // The general form of the 'base' is, + // (a*(b*x^2-1)^2-(a-1)) + // Where 'a=1/(2*b-b^2)' and 'b' moves around the negative lobe. + AF1 wB=AF1_(2.0/5.0)*d2+AF1_(-1.0); + AF1 wA=lob*d2+AF1_(-1.0); + wB*=wB; + wA*=wA; + wB=AF1_(25.0/16.0)*wB+AF1_(-(25.0/16.0-1.0)); + AF1 w=wB*wA; + // Do weighted average. + aC+=c*w;aW+=w;} +//------------------------------------------------------------------------------------------------------------------------------ + // Accumulate direction and length. + void FsrEasuSetF( + inout AF2 dir, + inout AF1 len, + AF2 pp, + AP1 biS,AP1 biT,AP1 biU,AP1 biV, + AF1 lA,AF1 lB,AF1 lC,AF1 lD,AF1 lE){ + // Compute bilinear weight, branches factor out as predicates are compiler time immediates. + // s t + // u v + AF1 w = AF1_(0.0); + if(biS)w=(AF1_(1.0)-pp.x)*(AF1_(1.0)-pp.y); + if(biT)w= pp.x *(AF1_(1.0)-pp.y); + if(biU)w=(AF1_(1.0)-pp.x)* pp.y ; + if(biV)w= pp.x * pp.y ; + // Direction is the '+' diff. + // a + // b c d + // e + // Then takes magnitude from abs average of both sides of 'c'. + // Length converts gradient reversal to 0, smoothly to non-reversal at 1, shaped, then adding horz and vert terms. + AF1 dc=lD-lC; + AF1 cb=lC-lB; + AF1 lenX=max(abs(dc),abs(cb)); + lenX=APrxLoRcpF1(lenX); + AF1 dirX=lD-lB; + dir.x+=dirX*w; + lenX=ASatF1(abs(dirX)*lenX); + lenX*=lenX; + len+=lenX*w; + // Repeat for the y axis. + AF1 ec=lE-lC; + AF1 ca=lC-lA; + AF1 lenY=max(abs(ec),abs(ca)); + lenY=APrxLoRcpF1(lenY); + AF1 dirY=lE-lA; + dir.y+=dirY*w; + lenY=ASatF1(abs(dirY)*lenY); + lenY*=lenY; + len+=lenY*w;} +//------------------------------------------------------------------------------------------------------------------------------ + void FsrEasuF( + out AF3 pix, + AU2 ip, // Integer pixel position in output. + AU4 con0, // Constants generated by FsrEasuCon(). + AU4 con1, + AU4 con2, + AU4 con3){ +//------------------------------------------------------------------------------------------------------------------------------ + // Get position of 'f'. + AF2 pp=AF2(ip)*AF2_AU2(con0.xy)+AF2_AU2(con0.zw); + AF2 fp=floor(pp); + pp-=fp; +//------------------------------------------------------------------------------------------------------------------------------ + // 12-tap kernel. + // b c + // e f g h + // i j k l + // n o + // Gather 4 ordering. + // a b + // r g + // For packed FP16, need either {rg} or {ab} so using the following setup for gather in all versions, + // a b <- unused (z) + // r g + // a b a b + // r g r g + // a b + // r g <- unused (z) + // Allowing dead-code removal to remove the 'z's. + AF2 p0=fp*AF2_AU2(con1.xy)+AF2_AU2(con1.zw); + // These are from p0 to avoid pulling two constants on pre-Navi hardware. + AF2 p1=p0+AF2_AU2(con2.xy); + AF2 p2=p0+AF2_AU2(con2.zw); + AF2 p3=p0+AF2_AU2(con3.xy); + AF4 bczzR=FsrEasuRF(p0); + AF4 bczzG=FsrEasuGF(p0); + AF4 bczzB=FsrEasuBF(p0); + AF4 ijfeR=FsrEasuRF(p1); + AF4 ijfeG=FsrEasuGF(p1); + AF4 ijfeB=FsrEasuBF(p1); + AF4 klhgR=FsrEasuRF(p2); + AF4 klhgG=FsrEasuGF(p2); + AF4 klhgB=FsrEasuBF(p2); + AF4 zzonR=FsrEasuRF(p3); + AF4 zzonG=FsrEasuGF(p3); + AF4 zzonB=FsrEasuBF(p3); +//------------------------------------------------------------------------------------------------------------------------------ + // Simplest multi-channel approximate luma possible (luma times 2, in 2 FMA/MAD). + AF4 bczzL=bczzB*AF4_(0.5)+(bczzR*AF4_(0.5)+bczzG); + AF4 ijfeL=ijfeB*AF4_(0.5)+(ijfeR*AF4_(0.5)+ijfeG); + AF4 klhgL=klhgB*AF4_(0.5)+(klhgR*AF4_(0.5)+klhgG); + AF4 zzonL=zzonB*AF4_(0.5)+(zzonR*AF4_(0.5)+zzonG); + // Rename. + AF1 bL=bczzL.x; + AF1 cL=bczzL.y; + AF1 iL=ijfeL.x; + AF1 jL=ijfeL.y; + AF1 fL=ijfeL.z; + AF1 eL=ijfeL.w; + AF1 kL=klhgL.x; + AF1 lL=klhgL.y; + AF1 hL=klhgL.z; + AF1 gL=klhgL.w; + AF1 oL=zzonL.z; + AF1 nL=zzonL.w; + // Accumulate for bilinear interpolation. + AF2 dir=AF2_(0.0); + AF1 len=AF1_(0.0); + FsrEasuSetF(dir,len,pp,true, false,false,false,bL,eL,fL,gL,jL); + FsrEasuSetF(dir,len,pp,false,true ,false,false,cL,fL,gL,hL,kL); + FsrEasuSetF(dir,len,pp,false,false,true ,false,fL,iL,jL,kL,nL); + FsrEasuSetF(dir,len,pp,false,false,false,true ,gL,jL,kL,lL,oL); +//------------------------------------------------------------------------------------------------------------------------------ + // Normalize with approximation, and cleanup close to zero. + AF2 dir2=dir*dir; + AF1 dirR=dir2.x+dir2.y; + AP1 zro=dirR w = -m/(n+e+w+s) +// 1 == (w*(n+e+w+s)+m)/(4*w+1) -> w = (1-m)/(n+e+w+s-4*1) +// Then chooses the 'w' which results in no clipping, limits 'w', and multiplies by the 'sharp' amount. +// This solution above has issues with MSAA input as the steps along the gradient cause edge detection issues. +// So RCAS uses 4x the maximum and 4x the minimum (depending on equation)in place of the individual taps. +// As well as switching from 'm' to either the minimum or maximum (depending on side), to help in energy conservation. +// This stabilizes RCAS. +// RCAS does a simple highpass which is normalized against the local contrast then shaped, +// 0.25 +// 0.25 -1 0.25 +// 0.25 +// This is used as a noise detection filter, to reduce the effect of RCAS on grain, and focus on real edges. +// +// GLSL example for the required callbacks : +// +// AH4 FsrRcasLoadH(ASW2 p){return AH4(imageLoad(imgSrc,ASU2(p)));} +// void FsrRcasInputH(inout AH1 r,inout AH1 g,inout AH1 b) +// { +// //do any simple input color conversions here or leave empty if none needed +// } +// +// FsrRcasCon need to be called from the CPU or GPU to set up constants. +// Including a GPU example here, the 'con' value would be stored out to a constant buffer. +// +// AU4 con; +// FsrRcasCon(con, +// 0.0); // The scale is {0.0 := maximum sharpness, to N>0, where N is the number of stops (halving) of the reduction of sharpness}. +// --------------- +// RCAS sharpening supports a CAS-like pass-through alpha via, +// #define FSR_RCAS_PASSTHROUGH_ALPHA 1 +// RCAS also supports a define to enable a more expensive path to avoid some sharpening of noise. +// Would suggest it is better to apply film grain after RCAS sharpening (and after scaling) instead of using this define, +// #define FSR_RCAS_DENOISE 1 +//============================================================================================================================== +// This is set at the limit of providing unnatural results for sharpening. +#define FSR_RCAS_LIMIT (0.25-(1.0/16.0)) +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// CONSTANT SETUP +//============================================================================================================================== +// Call to setup required constant values (works on CPU or GPU). +A_STATIC void FsrRcasCon( +outAU4 con, +// The scale is {0.0 := maximum, to N>0, where N is the number of stops (halving) of the reduction of sharpness}. +AF1 sharpness){ + // Transform from stops to linear value. + sharpness=AExp2F1(-sharpness); + varAF2(hSharp)=initAF2(sharpness,sharpness); + con[0]=AU1_AF1(sharpness); + con[1]=AU1_AH2_AF2(hSharp); + con[2]=0; + con[3]=0;} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// NON-PACKED 32-BIT VERSION +//============================================================================================================================== +#if defined(A_GPU)&&defined(FSR_RCAS_F) + // Input callback prototypes that need to be implemented by calling shader + AF4 FsrRcasLoadF(ASU2 p); + void FsrRcasInputF(inout AF1 r,inout AF1 g,inout AF1 b); +//------------------------------------------------------------------------------------------------------------------------------ + void FsrRcasF( + out AF1 pixR, // Output values, non-vector so port between RcasFilter() and RcasFilterH() is easy. + out AF1 pixG, + out AF1 pixB, + #ifdef FSR_RCAS_PASSTHROUGH_ALPHA + out AF1 pixA, + #endif + AU2 ip, // Integer pixel position in output. + AU4 con){ // Constant generated by RcasSetup(). + // Algorithm uses minimal 3x3 pixel neighborhood. + // b + // d e f + // h + ASU2 sp=ASU2(ip); + AF3 b=FsrRcasLoadF(sp+ASU2( 0,-1)).rgb; + AF3 d=FsrRcasLoadF(sp+ASU2(-1, 0)).rgb; + #ifdef FSR_RCAS_PASSTHROUGH_ALPHA + AF4 ee=FsrRcasLoadF(sp); + AF3 e=ee.rgb;pixA=ee.a; + #else + AF3 e=FsrRcasLoadF(sp).rgb; + #endif + AF3 f=FsrRcasLoadF(sp+ASU2( 1, 0)).rgb; + AF3 h=FsrRcasLoadF(sp+ASU2( 0, 1)).rgb; + // Rename (32-bit) or regroup (16-bit). + AF1 bR=b.r; + AF1 bG=b.g; + AF1 bB=b.b; + AF1 dR=d.r; + AF1 dG=d.g; + AF1 dB=d.b; + AF1 eR=e.r; + AF1 eG=e.g; + AF1 eB=e.b; + AF1 fR=f.r; + AF1 fG=f.g; + AF1 fB=f.b; + AF1 hR=h.r; + AF1 hG=h.g; + AF1 hB=h.b; + // Run optional input transform. + FsrRcasInputF(bR,bG,bB); + FsrRcasInputF(dR,dG,dB); + FsrRcasInputF(eR,eG,eB); + FsrRcasInputF(fR,fG,fB); + FsrRcasInputF(hR,hG,hB); + // Luma times 2. + AF1 bL=bB*AF1_(0.5)+(bR*AF1_(0.5)+bG); + AF1 dL=dB*AF1_(0.5)+(dR*AF1_(0.5)+dG); + AF1 eL=eB*AF1_(0.5)+(eR*AF1_(0.5)+eG); + AF1 fL=fB*AF1_(0.5)+(fR*AF1_(0.5)+fG); + AF1 hL=hB*AF1_(0.5)+(hR*AF1_(0.5)+hG); + // Noise detection. + AF1 nz=AF1_(0.25)*bL+AF1_(0.25)*dL+AF1_(0.25)*fL+AF1_(0.25)*hL-eL; + nz=ASatF1(abs(nz)*APrxMedRcpF1(AMax3F1(AMax3F1(bL,dL,eL),fL,hL)-AMin3F1(AMin3F1(bL,dL,eL),fL,hL))); + nz=AF1_(-0.5)*nz+AF1_(1.0); + // Min and max of ring. + AF1 mn4R=min(AMin3F1(bR,dR,fR),hR); + AF1 mn4G=min(AMin3F1(bG,dG,fG),hG); + AF1 mn4B=min(AMin3F1(bB,dB,fB),hB); + AF1 mx4R=max(AMax3F1(bR,dR,fR),hR); + AF1 mx4G=max(AMax3F1(bG,dG,fG),hG); + AF1 mx4B=max(AMax3F1(bB,dB,fB),hB); + // Immediate constants for peak range. + AF2 peakC=AF2(1.0,-1.0*4.0); + // Limiters, these need to be high precision RCPs. + AF1 hitMinR=min(mn4R,eR)*ARcpF1(AF1_(4.0)*mx4R); + AF1 hitMinG=min(mn4G,eG)*ARcpF1(AF1_(4.0)*mx4G); + AF1 hitMinB=min(mn4B,eB)*ARcpF1(AF1_(4.0)*mx4B); + AF1 hitMaxR=(peakC.x-max(mx4R,eR))*ARcpF1(AF1_(4.0)*mn4R+peakC.y); + AF1 hitMaxG=(peakC.x-max(mx4G,eG))*ARcpF1(AF1_(4.0)*mn4G+peakC.y); + AF1 hitMaxB=(peakC.x-max(mx4B,eB))*ARcpF1(AF1_(4.0)*mn4B+peakC.y); + AF1 lobeR=max(-hitMinR,hitMaxR); + AF1 lobeG=max(-hitMinG,hitMaxG); + AF1 lobeB=max(-hitMinB,hitMaxB); + AF1 lobe=max(AF1_(-FSR_RCAS_LIMIT),min(AMax3F1(lobeR,lobeG,lobeB),AF1_(0.0)))*AF1_AU1(con.x); + // Apply noise removal. + #ifdef FSR_RCAS_DENOISE + lobe*=nz; + #endif + // Resolve, which needs the medium precision rcp approximation to avoid visible tonality changes. + AF1 rcpL=APrxMedRcpF1(AF1_(4.0)*lobe+AF1_(1.0)); + pixR=(lobe*bR+lobe*dR+lobe*hR+lobe*fR+eR)*rcpL; + pixG=(lobe*bG+lobe*dG+lobe*hG+lobe*fG+eG)*rcpL; + pixB=(lobe*bB+lobe*dB+lobe*hB+lobe*fB+eB)*rcpL; + return;} +#endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// NON-PACKED 16-BIT VERSION +//============================================================================================================================== +#if defined(A_GPU)&&defined(A_HALF)&&defined(FSR_RCAS_H) + // Input callback prototypes that need to be implemented by calling shader + AH4 FsrRcasLoadH(ASW2 p); + void FsrRcasInputH(inout AH1 r,inout AH1 g,inout AH1 b); +//------------------------------------------------------------------------------------------------------------------------------ + void FsrRcasH( + out AH1 pixR, // Output values, non-vector so port between RcasFilter() and RcasFilterH() is easy. + out AH1 pixG, + out AH1 pixB, + #ifdef FSR_RCAS_PASSTHROUGH_ALPHA + out AH1 pixA, + #endif + AU2 ip, // Integer pixel position in output. + AU4 con){ // Constant generated by RcasSetup(). + // Sharpening algorithm uses minimal 3x3 pixel neighborhood. + // b + // d e f + // h + ASW2 sp=ASW2(ip); + AH3 b=FsrRcasLoadH(sp+ASW2( 0,-1)).rgb; + AH3 d=FsrRcasLoadH(sp+ASW2(-1, 0)).rgb; + #ifdef FSR_RCAS_PASSTHROUGH_ALPHA + AH4 ee=FsrRcasLoadH(sp); + AH3 e=ee.rgb;pixA=ee.a; + #else + AH3 e=FsrRcasLoadH(sp).rgb; + #endif + AH3 f=FsrRcasLoadH(sp+ASW2( 1, 0)).rgb; + AH3 h=FsrRcasLoadH(sp+ASW2( 0, 1)).rgb; + // Rename (32-bit) or regroup (16-bit). + AH1 bR=b.r; + AH1 bG=b.g; + AH1 bB=b.b; + AH1 dR=d.r; + AH1 dG=d.g; + AH1 dB=d.b; + AH1 eR=e.r; + AH1 eG=e.g; + AH1 eB=e.b; + AH1 fR=f.r; + AH1 fG=f.g; + AH1 fB=f.b; + AH1 hR=h.r; + AH1 hG=h.g; + AH1 hB=h.b; + // Run optional input transform. + FsrRcasInputH(bR,bG,bB); + FsrRcasInputH(dR,dG,dB); + FsrRcasInputH(eR,eG,eB); + FsrRcasInputH(fR,fG,fB); + FsrRcasInputH(hR,hG,hB); + // Luma times 2. + AH1 bL=bB*AH1_(0.5)+(bR*AH1_(0.5)+bG); + AH1 dL=dB*AH1_(0.5)+(dR*AH1_(0.5)+dG); + AH1 eL=eB*AH1_(0.5)+(eR*AH1_(0.5)+eG); + AH1 fL=fB*AH1_(0.5)+(fR*AH1_(0.5)+fG); + AH1 hL=hB*AH1_(0.5)+(hR*AH1_(0.5)+hG); + // Noise detection. + AH1 nz=AH1_(0.25)*bL+AH1_(0.25)*dL+AH1_(0.25)*fL+AH1_(0.25)*hL-eL; + nz=ASatH1(abs(nz)*APrxMedRcpH1(AMax3H1(AMax3H1(bL,dL,eL),fL,hL)-AMin3H1(AMin3H1(bL,dL,eL),fL,hL))); + nz=AH1_(-0.5)*nz+AH1_(1.0); + // Min and max of ring. + AH1 mn4R=min(AMin3H1(bR,dR,fR),hR); + AH1 mn4G=min(AMin3H1(bG,dG,fG),hG); + AH1 mn4B=min(AMin3H1(bB,dB,fB),hB); + AH1 mx4R=max(AMax3H1(bR,dR,fR),hR); + AH1 mx4G=max(AMax3H1(bG,dG,fG),hG); + AH1 mx4B=max(AMax3H1(bB,dB,fB),hB); + // Immediate constants for peak range. + AH2 peakC=AH2(1.0,-1.0*4.0); + // Limiters, these need to be high precision RCPs. + AH1 hitMinR=min(mn4R,eR)*ARcpH1(AH1_(4.0)*mx4R); + AH1 hitMinG=min(mn4G,eG)*ARcpH1(AH1_(4.0)*mx4G); + AH1 hitMinB=min(mn4B,eB)*ARcpH1(AH1_(4.0)*mx4B); + AH1 hitMaxR=(peakC.x-max(mx4R,eR))*ARcpH1(AH1_(4.0)*mn4R+peakC.y); + AH1 hitMaxG=(peakC.x-max(mx4G,eG))*ARcpH1(AH1_(4.0)*mn4G+peakC.y); + AH1 hitMaxB=(peakC.x-max(mx4B,eB))*ARcpH1(AH1_(4.0)*mn4B+peakC.y); + AH1 lobeR=max(-hitMinR,hitMaxR); + AH1 lobeG=max(-hitMinG,hitMaxG); + AH1 lobeB=max(-hitMinB,hitMaxB); + AH1 lobe=max(AH1_(-FSR_RCAS_LIMIT),min(AMax3H1(lobeR,lobeG,lobeB),AH1_(0.0)))*AH2_AU1(con.y).x; + // Apply noise removal. + #ifdef FSR_RCAS_DENOISE + lobe*=nz; + #endif + // Resolve, which needs the medium precision rcp approximation to avoid visible tonality changes. + AH1 rcpL=APrxMedRcpH1(AH1_(4.0)*lobe+AH1_(1.0)); + pixR=(lobe*bR+lobe*dR+lobe*hR+lobe*fR+eR)*rcpL; + pixG=(lobe*bG+lobe*dG+lobe*hG+lobe*fG+eG)*rcpL; + pixB=(lobe*bB+lobe*dB+lobe*hB+lobe*fB+eB)*rcpL;} +#endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// PACKED 16-BIT VERSION +//============================================================================================================================== +#if defined(A_GPU)&&defined(A_HALF)&&defined(FSR_RCAS_HX2) + // Input callback prototypes that need to be implemented by the calling shader + AH4 FsrRcasLoadHx2(ASW2 p); + void FsrRcasInputHx2(inout AH2 r,inout AH2 g,inout AH2 b); +//------------------------------------------------------------------------------------------------------------------------------ + // Can be used to convert from packed Structures of Arrays to Arrays of Structures for store. + void FsrRcasDepackHx2(out AH4 pix0,out AH4 pix1,AH2 pixR,AH2 pixG,AH2 pixB){ + #ifdef A_HLSL + // Invoke a slower path for DX only, since it won't allow uninitialized values. + pix0.a=pix1.a=0.0; + #endif + pix0.rgb=AH3(pixR.x,pixG.x,pixB.x); + pix1.rgb=AH3(pixR.y,pixG.y,pixB.y);} +//------------------------------------------------------------------------------------------------------------------------------ + void FsrRcasHx2( + // Output values are for 2 8x8 tiles in a 16x8 region. + // pix.x = left 8x8 tile + // pix.y = right 8x8 tile + // This enables later processing to easily be packed as well. + out AH2 pixR, + out AH2 pixG, + out AH2 pixB, + #ifdef FSR_RCAS_PASSTHROUGH_ALPHA + out AH2 pixA, + #endif + AU2 ip, // Integer pixel position in output. + AU4 con){ // Constant generated by RcasSetup(). + // No scaling algorithm uses minimal 3x3 pixel neighborhood. + ASW2 sp0=ASW2(ip); + AH3 b0=FsrRcasLoadHx2(sp0+ASW2( 0,-1)).rgb; + AH3 d0=FsrRcasLoadHx2(sp0+ASW2(-1, 0)).rgb; + #ifdef FSR_RCAS_PASSTHROUGH_ALPHA + AH4 ee0=FsrRcasLoadHx2(sp0); + AH3 e0=ee0.rgb;pixA.r=ee0.a; + #else + AH3 e0=FsrRcasLoadHx2(sp0).rgb; + #endif + AH3 f0=FsrRcasLoadHx2(sp0+ASW2( 1, 0)).rgb; + AH3 h0=FsrRcasLoadHx2(sp0+ASW2( 0, 1)).rgb; + ASW2 sp1=sp0+ASW2(8,0); + AH3 b1=FsrRcasLoadHx2(sp1+ASW2( 0,-1)).rgb; + AH3 d1=FsrRcasLoadHx2(sp1+ASW2(-1, 0)).rgb; + #ifdef FSR_RCAS_PASSTHROUGH_ALPHA + AH4 ee1=FsrRcasLoadHx2(sp1); + AH3 e1=ee1.rgb;pixA.g=ee1.a; + #else + AH3 e1=FsrRcasLoadHx2(sp1).rgb; + #endif + AH3 f1=FsrRcasLoadHx2(sp1+ASW2( 1, 0)).rgb; + AH3 h1=FsrRcasLoadHx2(sp1+ASW2( 0, 1)).rgb; + // Arrays of Structures to Structures of Arrays conversion. + AH2 bR=AH2(b0.r,b1.r); + AH2 bG=AH2(b0.g,b1.g); + AH2 bB=AH2(b0.b,b1.b); + AH2 dR=AH2(d0.r,d1.r); + AH2 dG=AH2(d0.g,d1.g); + AH2 dB=AH2(d0.b,d1.b); + AH2 eR=AH2(e0.r,e1.r); + AH2 eG=AH2(e0.g,e1.g); + AH2 eB=AH2(e0.b,e1.b); + AH2 fR=AH2(f0.r,f1.r); + AH2 fG=AH2(f0.g,f1.g); + AH2 fB=AH2(f0.b,f1.b); + AH2 hR=AH2(h0.r,h1.r); + AH2 hG=AH2(h0.g,h1.g); + AH2 hB=AH2(h0.b,h1.b); + // Run optional input transform. + FsrRcasInputHx2(bR,bG,bB); + FsrRcasInputHx2(dR,dG,dB); + FsrRcasInputHx2(eR,eG,eB); + FsrRcasInputHx2(fR,fG,fB); + FsrRcasInputHx2(hR,hG,hB); + // Luma times 2. + AH2 bL=bB*AH2_(0.5)+(bR*AH2_(0.5)+bG); + AH2 dL=dB*AH2_(0.5)+(dR*AH2_(0.5)+dG); + AH2 eL=eB*AH2_(0.5)+(eR*AH2_(0.5)+eG); + AH2 fL=fB*AH2_(0.5)+(fR*AH2_(0.5)+fG); + AH2 hL=hB*AH2_(0.5)+(hR*AH2_(0.5)+hG); + // Noise detection. + AH2 nz=AH2_(0.25)*bL+AH2_(0.25)*dL+AH2_(0.25)*fL+AH2_(0.25)*hL-eL; + nz=ASatH2(abs(nz)*APrxMedRcpH2(AMax3H2(AMax3H2(bL,dL,eL),fL,hL)-AMin3H2(AMin3H2(bL,dL,eL),fL,hL))); + nz=AH2_(-0.5)*nz+AH2_(1.0); + // Min and max of ring. + AH2 mn4R=min(AMin3H2(bR,dR,fR),hR); + AH2 mn4G=min(AMin3H2(bG,dG,fG),hG); + AH2 mn4B=min(AMin3H2(bB,dB,fB),hB); + AH2 mx4R=max(AMax3H2(bR,dR,fR),hR); + AH2 mx4G=max(AMax3H2(bG,dG,fG),hG); + AH2 mx4B=max(AMax3H2(bB,dB,fB),hB); + // Immediate constants for peak range. + AH2 peakC=AH2(1.0,-1.0*4.0); + // Limiters, these need to be high precision RCPs. + AH2 hitMinR=min(mn4R,eR)*ARcpH2(AH2_(4.0)*mx4R); + AH2 hitMinG=min(mn4G,eG)*ARcpH2(AH2_(4.0)*mx4G); + AH2 hitMinB=min(mn4B,eB)*ARcpH2(AH2_(4.0)*mx4B); + AH2 hitMaxR=(peakC.x-max(mx4R,eR))*ARcpH2(AH2_(4.0)*mn4R+peakC.y); + AH2 hitMaxG=(peakC.x-max(mx4G,eG))*ARcpH2(AH2_(4.0)*mn4G+peakC.y); + AH2 hitMaxB=(peakC.x-max(mx4B,eB))*ARcpH2(AH2_(4.0)*mn4B+peakC.y); + AH2 lobeR=max(-hitMinR,hitMaxR); + AH2 lobeG=max(-hitMinG,hitMaxG); + AH2 lobeB=max(-hitMinB,hitMaxB); + AH2 lobe=max(AH2_(-FSR_RCAS_LIMIT),min(AMax3H2(lobeR,lobeG,lobeB),AH2_(0.0)))*AH2_(AH2_AU1(con.y).x); + // Apply noise removal. + #ifdef FSR_RCAS_DENOISE + lobe*=nz; + #endif + // Resolve, which needs the medium precision rcp approximation to avoid visible tonality changes. + AH2 rcpL=APrxMedRcpH2(AH2_(4.0)*lobe+AH2_(1.0)); + pixR=(lobe*bR+lobe*dR+lobe*hR+lobe*fR+eR)*rcpL; + pixG=(lobe*bG+lobe*dG+lobe*hG+lobe*fG+eG)*rcpL; + pixB=(lobe*bB+lobe*dB+lobe*hB+lobe*fB+eB)*rcpL;} +#endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// +// FSR - [LFGA] LINEAR FILM GRAIN APPLICATOR +// +//------------------------------------------------------------------------------------------------------------------------------ +// Adding output-resolution film grain after scaling is a good way to mask both rendering and scaling artifacts. +// Suggest using tiled blue noise as film grain input, with peak noise frequency set for a specific look and feel. +// The 'Lfga*()' functions provide a convenient way to introduce grain. +// These functions limit grain based on distance to signal limits. +// This is done so that the grain is temporally energy preserving, and thus won't modify image tonality. +// Grain application should be done in a linear colorspace. +// The grain should be temporally changing, but have a temporal sum per pixel that adds to zero (non-biased). +//------------------------------------------------------------------------------------------------------------------------------ +// Usage, +// FsrLfga*( +// color, // In/out linear colorspace color {0 to 1} ranged. +// grain, // Per pixel grain texture value {-0.5 to 0.5} ranged, input is 3-channel to support colored grain. +// amount); // Amount of grain (0 to 1} ranged. +//------------------------------------------------------------------------------------------------------------------------------ +// Example if grain texture is monochrome: 'FsrLfgaF(color,AF3_(grain),amount)' +//============================================================================================================================== +#if defined(A_GPU) + // Maximum grain is the minimum distance to the signal limit. + void FsrLfgaF(inout AF3 c,AF3 t,AF1 a){c+=(t*AF3_(a))*min(AF3_(1.0)-c,c);} +#endif +//============================================================================================================================== +#if defined(A_GPU)&&defined(A_HALF) + // Half precision version (slower). + void FsrLfgaH(inout AH3 c,AH3 t,AH1 a){c+=(t*AH3_(a))*min(AH3_(1.0)-c,c);} +//------------------------------------------------------------------------------------------------------------------------------ + // Packed half precision version (faster). + void FsrLfgaHx2(inout AH2 cR,inout AH2 cG,inout AH2 cB,AH2 tR,AH2 tG,AH2 tB,AH1 a){ + cR+=(tR*AH2_(a))*min(AH2_(1.0)-cR,cR);cG+=(tG*AH2_(a))*min(AH2_(1.0)-cG,cG);cB+=(tB*AH2_(a))*min(AH2_(1.0)-cB,cB);} +#endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// +// FSR - [SRTM] SIMPLE REVERSIBLE TONE-MAPPER +// +//------------------------------------------------------------------------------------------------------------------------------ +// This provides a way to take linear HDR color {0 to FP16_MAX} and convert it into a temporary {0 to 1} ranged post-tonemapped linear. +// The tonemapper preserves RGB ratio, which helps maintain HDR color bleed during filtering. +//------------------------------------------------------------------------------------------------------------------------------ +// Reversible tonemapper usage, +// FsrSrtm*(color); // {0 to FP16_MAX} converted to {0 to 1}. +// FsrSrtmInv*(color); // {0 to 1} converted into {0 to 32768, output peak safe for FP16}. +//============================================================================================================================== +#if defined(A_GPU) + void FsrSrtmF(inout AF3 c){c*=AF3_(ARcpF1(AMax3F1(c.r,c.g,c.b)+AF1_(1.0)));} + // The extra max solves the c=1.0 case (which is a /0). + void FsrSrtmInvF(inout AF3 c){c*=AF3_(ARcpF1(max(AF1_(1.0/32768.0),AF1_(1.0)-AMax3F1(c.r,c.g,c.b))));} +#endif +//============================================================================================================================== +#if defined(A_GPU)&&defined(A_HALF) + void FsrSrtmH(inout AH3 c){c*=AH3_(ARcpH1(AMax3H1(c.r,c.g,c.b)+AH1_(1.0)));} + void FsrSrtmInvH(inout AH3 c){c*=AH3_(ARcpH1(max(AH1_(1.0/32768.0),AH1_(1.0)-AMax3H1(c.r,c.g,c.b))));} +//------------------------------------------------------------------------------------------------------------------------------ + void FsrSrtmHx2(inout AH2 cR,inout AH2 cG,inout AH2 cB){ + AH2 rcp=ARcpH2(AMax3H2(cR,cG,cB)+AH2_(1.0));cR*=rcp;cG*=rcp;cB*=rcp;} + void FsrSrtmInvHx2(inout AH2 cR,inout AH2 cG,inout AH2 cB){ + AH2 rcp=ARcpH2(max(AH2_(1.0/32768.0),AH2_(1.0)-AMax3H2(cR,cG,cB)));cR*=rcp;cG*=rcp;cB*=rcp;} +#endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// +// FSR - [TEPD] TEMPORAL ENERGY PRESERVING DITHER +// +//------------------------------------------------------------------------------------------------------------------------------ +// Temporally energy preserving dithered {0 to 1} linear to gamma 2.0 conversion. +// Gamma 2.0 is used so that the conversion back to linear is just to square the color. +// The conversion comes in 8-bit and 10-bit modes, designed for output to 8-bit UNORM or 10:10:10:2 respectively. +// Given good non-biased temporal blue noise as dither input, +// the output dither will temporally conserve energy. +// This is done by choosing the linear nearest step point instead of perceptual nearest. +// See code below for details. +//------------------------------------------------------------------------------------------------------------------------------ +// DX SPEC RULES FOR FLOAT->UNORM 8-BIT CONVERSION +// =============================================== +// - Output is 'uint(floor(saturate(n)*255.0+0.5))'. +// - Thus rounding is to nearest. +// - NaN gets converted to zero. +// - INF is clamped to {0.0 to 1.0}. +//============================================================================================================================== +#if defined(A_GPU) + // Hand tuned integer position to dither value, with more values than simple checkerboard. + // Only 32-bit has enough precision for this compddation. + // Output is {0 to <1}. + AF1 FsrTepdDitF(AU2 p,AU1 f){ + AF1 x=AF1_(p.x+f); + AF1 y=AF1_(p.y); + // The 1.61803 golden ratio. + AF1 a=AF1_((1.0+sqrt(5.0))/2.0); + // Number designed to provide a good visual pattern. + AF1 b=AF1_(1.0/3.69); + x=x*a+(y*b); + return AFractF1(x);} +//------------------------------------------------------------------------------------------------------------------------------ + // This version is 8-bit gamma 2.0. + // The 'c' input is {0 to 1}. + // Output is {0 to 1} ready for image store. + void FsrTepdC8F(inout AF3 c,AF1 dit){ + AF3 n=sqrt(c); + n=floor(n*AF3_(255.0))*AF3_(1.0/255.0); + AF3 a=n*n; + AF3 b=n+AF3_(1.0/255.0);b=b*b; + // Ratio of 'a' to 'b' required to produce 'c'. + // APrxLoRcpF1() won't work here (at least for very high dynamic ranges). + // APrxMedRcpF1() is an IADD,FMA,MUL. + AF3 r=(c-b)*APrxMedRcpF3(a-b); + // Use the ratio as a cutoff to choose 'a' or 'b'. + // AGtZeroF1() is a MUL. + c=ASatF3(n+AGtZeroF3(AF3_(dit)-r)*AF3_(1.0/255.0));} +//------------------------------------------------------------------------------------------------------------------------------ + // This version is 10-bit gamma 2.0. + // The 'c' input is {0 to 1}. + // Output is {0 to 1} ready for image store. + void FsrTepdC10F(inout AF3 c,AF1 dit){ + AF3 n=sqrt(c); + n=floor(n*AF3_(1023.0))*AF3_(1.0/1023.0); + AF3 a=n*n; + AF3 b=n+AF3_(1.0/1023.0);b=b*b; + AF3 r=(c-b)*APrxMedRcpF3(a-b); + c=ASatF3(n+AGtZeroF3(AF3_(dit)-r)*AF3_(1.0/1023.0));} +#endif +//============================================================================================================================== +#if defined(A_GPU)&&defined(A_HALF) + AH1 FsrTepdDitH(AU2 p,AU1 f){ + AF1 x=AF1_(p.x+f); + AF1 y=AF1_(p.y); + AF1 a=AF1_((1.0+sqrt(5.0))/2.0); + AF1 b=AF1_(1.0/3.69); + x=x*a+(y*b); + return AH1(AFractF1(x));} +//------------------------------------------------------------------------------------------------------------------------------ + void FsrTepdC8H(inout AH3 c,AH1 dit){ + AH3 n=sqrt(c); + n=floor(n*AH3_(255.0))*AH3_(1.0/255.0); + AH3 a=n*n; + AH3 b=n+AH3_(1.0/255.0);b=b*b; + AH3 r=(c-b)*APrxMedRcpH3(a-b); + c=ASatH3(n+AGtZeroH3(AH3_(dit)-r)*AH3_(1.0/255.0));} +//------------------------------------------------------------------------------------------------------------------------------ + void FsrTepdC10H(inout AH3 c,AH1 dit){ + AH3 n=sqrt(c); + n=floor(n*AH3_(1023.0))*AH3_(1.0/1023.0); + AH3 a=n*n; + AH3 b=n+AH3_(1.0/1023.0);b=b*b; + AH3 r=(c-b)*APrxMedRcpH3(a-b); + c=ASatH3(n+AGtZeroH3(AH3_(dit)-r)*AH3_(1.0/1023.0));} +//============================================================================================================================== + // This computes dither for positions 'p' and 'p+{8,0}'. + AH2 FsrTepdDitHx2(AU2 p,AU1 f){ + AF2 x; + x.x=AF1_(p.x+f); + x.y=x.x+AF1_(8.0); + AF1 y=AF1_(p.y); + AF1 a=AF1_((1.0+sqrt(5.0))/2.0); + AF1 b=AF1_(1.0/3.69); + x=x*AF2_(a)+AF2_(y*b); + return AH2(AFractF2(x));} +//------------------------------------------------------------------------------------------------------------------------------ + void FsrTepdC8Hx2(inout AH2 cR,inout AH2 cG,inout AH2 cB,AH2 dit){ + AH2 nR=sqrt(cR); + AH2 nG=sqrt(cG); + AH2 nB=sqrt(cB); + nR=floor(nR*AH2_(255.0))*AH2_(1.0/255.0); + nG=floor(nG*AH2_(255.0))*AH2_(1.0/255.0); + nB=floor(nB*AH2_(255.0))*AH2_(1.0/255.0); + AH2 aR=nR*nR; + AH2 aG=nG*nG; + AH2 aB=nB*nB; + AH2 bR=nR+AH2_(1.0/255.0);bR=bR*bR; + AH2 bG=nG+AH2_(1.0/255.0);bG=bG*bG; + AH2 bB=nB+AH2_(1.0/255.0);bB=bB*bB; + AH2 rR=(cR-bR)*APrxMedRcpH2(aR-bR); + AH2 rG=(cG-bG)*APrxMedRcpH2(aG-bG); + AH2 rB=(cB-bB)*APrxMedRcpH2(aB-bB); + cR=ASatH2(nR+AGtZeroH2(dit-rR)*AH2_(1.0/255.0)); + cG=ASatH2(nG+AGtZeroH2(dit-rG)*AH2_(1.0/255.0)); + cB=ASatH2(nB+AGtZeroH2(dit-rB)*AH2_(1.0/255.0));} +//------------------------------------------------------------------------------------------------------------------------------ + void FsrTepdC10Hx2(inout AH2 cR,inout AH2 cG,inout AH2 cB,AH2 dit){ + AH2 nR=sqrt(cR); + AH2 nG=sqrt(cG); + AH2 nB=sqrt(cB); + nR=floor(nR*AH2_(1023.0))*AH2_(1.0/1023.0); + nG=floor(nG*AH2_(1023.0))*AH2_(1.0/1023.0); + nB=floor(nB*AH2_(1023.0))*AH2_(1.0/1023.0); + AH2 aR=nR*nR; + AH2 aG=nG*nG; + AH2 aB=nB*nB; + AH2 bR=nR+AH2_(1.0/1023.0);bR=bR*bR; + AH2 bG=nG+AH2_(1.0/1023.0);bG=bG*bG; + AH2 bB=nB+AH2_(1.0/1023.0);bB=bB*bB; + AH2 rR=(cR-bR)*APrxMedRcpH2(aR-bR); + AH2 rG=(cG-bG)*APrxMedRcpH2(aG-bG); + AH2 rB=(cB-bB)*APrxMedRcpH2(aB-bB); + cR=ASatH2(nR+AGtZeroH2(dit-rR)*AH2_(1.0/1023.0)); + cG=ASatH2(nG+AGtZeroH2(dit-rG)*AH2_(1.0/1023.0)); + cB=ASatH2(nB+AGtZeroH2(dit-rB)*AH2_(1.0/1023.0));} +#endif diff --git a/src/video_core/host_shaders/post_process.frag b/src/video_core/host_shaders/post_process.frag index d222d070c..fb0917528 100644 --- a/src/video_core/host_shaders/post_process.frag +++ b/src/video_core/host_shaders/post_process.frag @@ -8,7 +8,7 @@ layout (location = 0) out vec4 color; layout (binding = 0) uniform sampler2D texSampler; -layout(push_constant) uniform settings { +layout (push_constant) uniform settings { float gamma; bool hdr; } pp; diff --git a/src/video_core/host_shaders/source_shader.h.in b/src/video_core/host_shaders/source_shader.h.in index 43bf5b0c5..3472b2837 100644 --- a/src/video_core/host_shaders/source_shader.h.in +++ b/src/video_core/host_shaders/source_shader.h.in @@ -7,8 +7,8 @@ namespace HostShaders { -constexpr std::string_view @CONTENTS_NAME@ = { +constexpr std::string_view @CONTENTS_NAME@ = R"shader_src( @CONTENTS@ -}; +)shader_src"; } // namespace HostShaders diff --git a/src/video_core/renderer_vulkan/host_passes/fsr_pass.cpp b/src/video_core/renderer_vulkan/host_passes/fsr_pass.cpp new file mode 100644 index 000000000..1c54207e0 --- /dev/null +++ b/src/video_core/renderer_vulkan/host_passes/fsr_pass.cpp @@ -0,0 +1,445 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "fsr_pass.h" + +#include "common/assert.h" +#include "video_core/host_shaders/fsr_comp.h" +#include "video_core/renderer_vulkan/vk_platform.h" +#include "video_core/renderer_vulkan/vk_shader_util.h" + +#define A_CPU +#include "core/debug_state.h" +#include "video_core/host_shaders/fsr/ffx_a.h" +#include "video_core/host_shaders/fsr/ffx_fsr1.h" + +typedef u32 uvec4[4]; + +struct FSRConstants { + uvec4 Const0; + uvec4 Const1; + uvec4 Const2; + uvec4 Const3; + uvec4 Sample; +}; + +namespace Vulkan::HostPasses { + +void FsrPass::Create(vk::Device device, VmaAllocator allocator, u32 num_images) { + this->device = device; + this->num_images = num_images; + + sampler = Check<"create upscaling sampler">(device.createSamplerUnique(vk::SamplerCreateInfo{ + .magFilter = vk::Filter::eLinear, + .minFilter = vk::Filter::eLinear, + .mipmapMode = vk::SamplerMipmapMode::eNearest, + .addressModeU = vk::SamplerAddressMode::eClampToEdge, + .addressModeV = vk::SamplerAddressMode::eClampToEdge, + .addressModeW = vk::SamplerAddressMode::eClampToEdge, + .maxAnisotropy = 1.0f, + .minLod = -1000.0f, + .maxLod = 1000.0f, + })); + + std::array layoutBindings{{ + { + .binding = 0, + .descriptorType = vk::DescriptorType::eSampledImage, + .descriptorCount = 1, + .stageFlags = vk::ShaderStageFlagBits::eCompute, + }, + { + .binding = 1, + .descriptorType = vk::DescriptorType::eStorageImage, + .descriptorCount = 1, + .stageFlags = vk::ShaderStageFlagBits::eCompute, + }, + { + .binding = 2, + .descriptorType = vk::DescriptorType::eSampler, + .descriptorCount = 1, + .stageFlags = vk::ShaderStageFlagBits::eCompute, + .pImmutableSamplers = &sampler.get(), + }, + }}; + + descriptor_set_layout = + Check<"create fsr descriptor set layout">(device.createDescriptorSetLayoutUnique({ + .flags = vk::DescriptorSetLayoutCreateFlagBits::ePushDescriptor, + .bindingCount = layoutBindings.size(), + .pBindings = layoutBindings.data(), + })); + + const vk::PushConstantRange push_constants{ + .stageFlags = vk::ShaderStageFlagBits::eCompute, + .offset = 0, + .size = sizeof(FSRConstants), + }; + + const auto& cs_easu_module = + Compile(HostShaders::FSR_COMP, vk::ShaderStageFlagBits::eCompute, device, + { + "SAMPLE_EASU=1", + }); + ASSERT(cs_easu_module); + SetObjectName(device, cs_easu_module, "fsr.comp [EASU]"); + + const auto& cs_rcas_module = + Compile(HostShaders::FSR_COMP, vk::ShaderStageFlagBits::eCompute, device, + { + "SAMPLE_RCAS=1", + }); + ASSERT(cs_rcas_module); + SetObjectName(device, cs_rcas_module, "fsr.comp [RCAS]"); + + pipeline_layout = Check<"fsp pipeline layout">(device.createPipelineLayoutUnique({ + .setLayoutCount = 1, + .pSetLayouts = &descriptor_set_layout.get(), + .pushConstantRangeCount = 1, + .pPushConstantRanges = &push_constants, + })); + SetObjectName(device, pipeline_layout.get(), "fsr pipeline layout"); + + const vk::ComputePipelineCreateInfo easu_pinfo{ + .stage{ + .stage = vk::ShaderStageFlagBits::eCompute, + .module = cs_easu_module, + .pName = "main", + }, + .layout = pipeline_layout.get(), + }; + easu_pipeline = + Check<"fsp easu compute pipelines">(device.createComputePipelineUnique({}, easu_pinfo)); + SetObjectName(device, easu_pipeline.get(), "fsr easu pipeline"); + + const vk::ComputePipelineCreateInfo rcas_pinfo{ + .stage{ + .stage = vk::ShaderStageFlagBits::eCompute, + .module = cs_rcas_module, + .pName = "main", + }, + .layout = pipeline_layout.get(), + }; + rcas_pipeline = + Check<"fsp rcas compute pipelines">(device.createComputePipelineUnique({}, rcas_pinfo)); + SetObjectName(device, rcas_pipeline.get(), "fsr rcas pipeline"); + + device.destroyShaderModule(cs_easu_module); + device.destroyShaderModule(cs_rcas_module); + + available_imgs.resize(num_images); + for (int i = 0; i < num_images; ++i) { + auto& img = available_imgs[i]; + img.id = i; + img.intermediary_image = VideoCore::UniqueImage(device, allocator); + img.output_image = VideoCore::UniqueImage(device, allocator); + } +} + +vk::ImageView FsrPass::Render(vk::CommandBuffer cmdbuf, vk::ImageView input, + vk::Extent2D input_size, vk::Extent2D output_size, Settings settings, + bool hdr) { + if (!settings.enable) { + DebugState.is_using_fsr = false; + return input; + } + if (input_size.width >= output_size.width && input_size.height >= output_size.height) { + DebugState.is_using_fsr = false; + return input; + } + + DebugState.is_using_fsr = true; + + if (output_size != cur_size) { + ResizeAndInvalidate(output_size.width, output_size.height); + } + auto [width, height] = cur_size; + + auto& img = available_imgs[cur_image]; + if (++cur_image >= available_imgs.size()) { + cur_image = 0; + } + + if (img.dirty) { + CreateImages(img); + } + + static const int thread_group_work_region_dim = 16; + int dispatch_x = (width + (thread_group_work_region_dim - 1)) / thread_group_work_region_dim; + int dispatch_y = (height + (thread_group_work_region_dim - 1)) / thread_group_work_region_dim; + + constexpr vk::ImageSubresourceRange simple_subresource = { + .aspectMask = vk::ImageAspectFlagBits::eColor, + .levelCount = 1, + .layerCount = 1, + }; + const std::array enter_barrier{ + vk::ImageMemoryBarrier2{ + .srcStageMask = vk::PipelineStageFlagBits2::eComputeShader, + .srcAccessMask = vk::AccessFlagBits2::eShaderRead, + .dstStageMask = vk::PipelineStageFlagBits2::eComputeShader, + .dstAccessMask = vk::AccessFlagBits2::eShaderWrite, + .oldLayout = vk::ImageLayout::eUndefined, + .newLayout = vk::ImageLayout::eGeneral, + .image = img.intermediary_image, + .subresourceRange = simple_subresource, + }, + }; + cmdbuf.pipelineBarrier2({ + .imageMemoryBarrierCount = enter_barrier.size(), + .pImageMemoryBarriers = enter_barrier.data(), + }); + + FSRConstants consts{}; + FsrEasuCon(reinterpret_cast(&consts.Const0), reinterpret_cast(&consts.Const1), + reinterpret_cast(&consts.Const2), reinterpret_cast(&consts.Const3), + static_cast(input_size.width), static_cast(input_size.height), + static_cast(input_size.width), static_cast(input_size.height), (AF1)width, + (AF1)height); + consts.Sample[0] = hdr && !settings.use_rcas ? 1 : 0; + + if (settings.use_rcas) { + + { // easu + std::array img_info{{ + { + .imageView = input, + .imageLayout = vk::ImageLayout::eShaderReadOnlyOptimal, + }, + { + .imageView = img.intermediary_image_view.get(), + .imageLayout = vk::ImageLayout::eGeneral, + }, + { + .sampler = sampler.get(), + }, + }}; + + std::array set_writes{{ + { + .dstBinding = 0, + .descriptorCount = 1, + .descriptorType = vk::DescriptorType::eSampledImage, + .pImageInfo = &img_info[0], + }, + { + .dstBinding = 1, + .descriptorCount = 1, + .descriptorType = vk::DescriptorType::eStorageImage, + .pImageInfo = &img_info[1], + }, + { + .dstBinding = 2, + .descriptorCount = 1, + .descriptorType = vk::DescriptorType::eSampler, + .pImageInfo = &img_info[2], + }, + }}; + + cmdbuf.bindPipeline(vk::PipelineBindPoint::eCompute, easu_pipeline.get()); + cmdbuf.pushDescriptorSetKHR(vk::PipelineBindPoint::eCompute, pipeline_layout.get(), 0, + set_writes); + cmdbuf.pushConstants(pipeline_layout.get(), vk::ShaderStageFlagBits::eCompute, 0, + sizeof(FSRConstants), &consts); + cmdbuf.dispatch(dispatch_x, dispatch_y, 1); + } + + std::array img_barrier{ + vk::ImageMemoryBarrier2{ + .srcStageMask = vk::PipelineStageFlagBits2::eComputeShader, + .srcAccessMask = vk::AccessFlagBits2::eShaderStorageWrite, + .dstStageMask = vk::PipelineStageFlagBits2::eComputeShader, + .dstAccessMask = vk::AccessFlagBits2::eShaderRead, + .oldLayout = vk::ImageLayout::eGeneral, + .newLayout = vk::ImageLayout::eShaderReadOnlyOptimal, + .image = img.intermediary_image, + .subresourceRange = simple_subresource, + }, + vk::ImageMemoryBarrier2{ + .srcStageMask = vk::PipelineStageFlagBits2::eTopOfPipe, + .srcAccessMask = vk::AccessFlagBits2::eNone, + .dstStageMask = vk::PipelineStageFlagBits2::eComputeShader, + .dstAccessMask = vk::AccessFlagBits2::eShaderStorageWrite, + .oldLayout = vk::ImageLayout::eUndefined, + .newLayout = vk::ImageLayout::eGeneral, + .image = img.output_image, + .subresourceRange = simple_subresource, + }, + }; + cmdbuf.pipelineBarrier2(vk::DependencyInfo{ + .imageMemoryBarrierCount = img_barrier.size(), + .pImageMemoryBarriers = img_barrier.data(), + }); + + { // rcas + consts = {}; + FsrRcasCon(reinterpret_cast(&consts.Const0), settings.rcas_attenuation); + consts.Sample[0] = hdr ? 1 : 0; + + std::array img_info{{ + { + .imageView = img.intermediary_image_view.get(), + .imageLayout = vk::ImageLayout::eShaderReadOnlyOptimal, + }, + { + .imageView = img.output_image_view.get(), + .imageLayout = vk::ImageLayout::eGeneral, + }, + { + .sampler = sampler.get(), + }, + }}; + + std::array set_writes{{ + { + .dstBinding = 0, + .descriptorCount = 1, + .descriptorType = vk::DescriptorType::eSampledImage, + .pImageInfo = &img_info[0], + }, + { + .dstBinding = 1, + .descriptorCount = 1, + .descriptorType = vk::DescriptorType::eStorageImage, + .pImageInfo = &img_info[1], + }, + { + .dstBinding = 2, + .descriptorCount = 1, + .descriptorType = vk::DescriptorType::eSampler, + .pImageInfo = &img_info[2], + }, + }}; + + cmdbuf.bindPipeline(vk::PipelineBindPoint::eCompute, rcas_pipeline.get()); + cmdbuf.pushDescriptorSetKHR(vk::PipelineBindPoint::eCompute, pipeline_layout.get(), 0, + set_writes); + cmdbuf.pushConstants(pipeline_layout.get(), vk::ShaderStageFlagBits::eCompute, 0, + sizeof(FSRConstants), &consts); + cmdbuf.dispatch(dispatch_x, dispatch_y, 1); + } + + } else { + // only easu + std::array img_info{{ + { + .imageView = input, + .imageLayout = vk::ImageLayout::eShaderReadOnlyOptimal, + }, + { + .imageView = img.output_image_view.get(), + .imageLayout = vk::ImageLayout::eGeneral, + }, + { + .sampler = sampler.get(), + }, + }}; + + std::array set_writes{{ + { + .dstBinding = 0, + .descriptorCount = 1, + .descriptorType = vk::DescriptorType::eSampledImage, + .pImageInfo = &img_info[0], + }, + { + .dstBinding = 1, + .descriptorCount = 1, + .descriptorType = vk::DescriptorType::eStorageImage, + .pImageInfo = &img_info[1], + }, + { + .dstBinding = 2, + .descriptorCount = 1, + .descriptorType = vk::DescriptorType::eSampler, + .pImageInfo = &img_info[2], + }, + }}; + + cmdbuf.bindPipeline(vk::PipelineBindPoint::eCompute, easu_pipeline.get()); + cmdbuf.pushDescriptorSetKHR(vk::PipelineBindPoint::eCompute, pipeline_layout.get(), 0, + set_writes); + cmdbuf.pushConstants(pipeline_layout.get(), vk::ShaderStageFlagBits::eCompute, 0, + sizeof(FSRConstants), &consts); + cmdbuf.dispatch(dispatch_x, dispatch_y, 1); + } + + const std::array return_barrier{ + vk::ImageMemoryBarrier2{ + .srcStageMask = vk::PipelineStageFlagBits2::eComputeShader, + .srcAccessMask = vk::AccessFlagBits2::eShaderStorageWrite, + .dstStageMask = vk::PipelineStageFlagBits2::eAllCommands, + .dstAccessMask = vk::AccessFlagBits2::eShaderRead, + .oldLayout = vk::ImageLayout::eGeneral, + .newLayout = vk::ImageLayout::eShaderReadOnlyOptimal, + .image = img.output_image, + .subresourceRange = simple_subresource, + }, + }; + cmdbuf.pipelineBarrier2({ + .imageMemoryBarrierCount = return_barrier.size(), + .pImageMemoryBarriers = return_barrier.data(), + }); + + return img.output_image_view.get(); +} + +void FsrPass::ResizeAndInvalidate(u32 width, u32 height) { + this->cur_size = vk::Extent2D{ + .width = width, + .height = height, + }; + for (int i = 0; i < num_images; ++i) { + available_imgs[i].dirty = true; + } +} + +void FsrPass::CreateImages(Img& img) const { + img.dirty = false; + + vk::ImageCreateInfo image_create_info{ + .imageType = vk::ImageType::e2D, + .format = vk::Format::eR16G16B16A16Sfloat, + .extent{ + .width = cur_size.width, + .height = cur_size.height, + .depth = 1, + }, + .mipLevels = 1, + .arrayLayers = 1, + .samples = vk::SampleCountFlagBits::e1, + // .tiling = vk::ImageTiling::eOptimal, + .usage = vk::ImageUsageFlagBits::eSampled | vk::ImageUsageFlagBits::eStorage, + .initialLayout = vk::ImageLayout::eUndefined, + }; + img.intermediary_image.Create(image_create_info); + SetObjectName(device, static_cast(img.intermediary_image), + "FSR Intermediary Image #{}", img.id); + image_create_info.usage = vk::ImageUsageFlagBits::eTransferSrc | + vk::ImageUsageFlagBits::eSampled | vk::ImageUsageFlagBits::eStorage | + vk::ImageUsageFlagBits::eColorAttachment; + img.output_image.Create(image_create_info); + SetObjectName(device, static_cast(img.output_image), "FSR Output Image #{}", img.id); + + vk::ImageViewCreateInfo image_view_create_info{ + .image = img.intermediary_image, + .viewType = vk::ImageViewType::e2D, + .format = vk::Format::eR16G16B16A16Sfloat, + .subresourceRange{ + .aspectMask = vk::ImageAspectFlagBits::eColor, + .levelCount = 1, + .layerCount = 1, + }, + }; + img.intermediary_image_view = Check<"create fsr intermediary image view">( + device.createImageViewUnique(image_view_create_info)); + SetObjectName(device, img.intermediary_image_view.get(), "FSR Intermediary ImageView #{}", + img.id); + + image_view_create_info.image = img.output_image; + img.output_image_view = + Check<"create fsr output image view">(device.createImageViewUnique(image_view_create_info)); + SetObjectName(device, img.output_image_view.get(), "FSR Output ImageView #{}", img.id); +} + +} // namespace Vulkan::HostPasses \ No newline at end of file diff --git a/src/video_core/renderer_vulkan/host_passes/fsr_pass.h b/src/video_core/renderer_vulkan/host_passes/fsr_pass.h new file mode 100644 index 000000000..3d48d85be --- /dev/null +++ b/src/video_core/renderer_vulkan/host_passes/fsr_pass.h @@ -0,0 +1,56 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "common/types.h" +#include "video_core/renderer_vulkan/vk_common.h" +#include "video_core/texture_cache/image.h" + +namespace Vulkan::HostPasses { + +class FsrPass { +public: + struct Settings { + bool enable{true}; + bool use_rcas{true}; + float rcas_attenuation{0.25f}; + }; + + void Create(vk::Device device, VmaAllocator allocator, u32 num_images); + + vk::ImageView Render(vk::CommandBuffer cmdbuf, vk::ImageView input, vk::Extent2D input_size, + vk::Extent2D output_size, Settings settings, bool hdr); + +private: + struct Img { + u8 id{}; + bool dirty{true}; + + VideoCore::UniqueImage intermediary_image; + vk::UniqueImageView intermediary_image_view; + + VideoCore::UniqueImage output_image; + vk::UniqueImageView output_image_view; + }; + + void ResizeAndInvalidate(u32 width, u32 height); + void CreateImages(Img& img) const; + + vk::Device device{}; + u32 num_images{}; + + vk::UniqueDescriptorSetLayout descriptor_set_layout{}; + vk::UniqueDescriptorSet easu_descriptor_set{}; + vk::UniqueDescriptorSet rcas_descriptor_set{}; + vk::UniqueSampler sampler{}; + vk::UniquePipelineLayout pipeline_layout{}; + vk::UniquePipeline easu_pipeline{}; + vk::UniquePipeline rcas_pipeline{}; + + vk::Extent2D cur_size{}; + u32 cur_image{}; + std::vector available_imgs; +}; + +} // namespace Vulkan::HostPasses diff --git a/src/video_core/renderer_vulkan/host_passes/pp_pass.cpp b/src/video_core/renderer_vulkan/host_passes/pp_pass.cpp new file mode 100644 index 000000000..73dd3a7b5 --- /dev/null +++ b/src/video_core/renderer_vulkan/host_passes/pp_pass.cpp @@ -0,0 +1,255 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "pp_pass.h" + +#include "common/assert.h" +#include "video_core/host_shaders/fs_tri_vert.h" +#include "video_core/host_shaders/post_process_frag.h" +#include "video_core/renderer_vulkan/vk_platform.h" +#include "video_core/renderer_vulkan/vk_presenter.h" +#include "video_core/renderer_vulkan/vk_shader_util.h" + +#include + +namespace Vulkan::HostPasses { + +void PostProcessingPass::Create(vk::Device device, const vk::Format surface_format) { + static const std::array pp_shaders{ + HostShaders::FS_TRI_VERT, + HostShaders::POST_PROCESS_FRAG, + }; + + boost::container::static_vector bindings{ + { + .binding = 0, + .descriptorType = vk::DescriptorType::eCombinedImageSampler, + .descriptorCount = 1, + .stageFlags = vk::ShaderStageFlagBits::eFragment, + }, + }; + + const vk::DescriptorSetLayoutCreateInfo desc_layout_ci{ + .flags = vk::DescriptorSetLayoutCreateFlagBits::ePushDescriptorKHR, + .bindingCount = static_cast(bindings.size()), + .pBindings = bindings.data(), + }; + + desc_set_layout = Check<"create pp descriptor set layout">( + device.createDescriptorSetLayoutUnique(desc_layout_ci)); + + const vk::PushConstantRange push_constants{ + .stageFlags = vk::ShaderStageFlagBits::eFragment, + .offset = 0, + .size = sizeof(Settings), + }; + + const auto& vs_module = Compile(pp_shaders[0], vk::ShaderStageFlagBits::eVertex, device); + ASSERT(vs_module); + SetObjectName(device, vs_module, "fs_tri.vert"); + + const auto& fs_module = Compile(pp_shaders[1], vk::ShaderStageFlagBits::eFragment, device); + ASSERT(fs_module); + SetObjectName(device, fs_module, "post_process.frag"); + + const std::array shaders_ci{ + vk::PipelineShaderStageCreateInfo{ + .stage = vk::ShaderStageFlagBits::eVertex, + .module = vs_module, + .pName = "main", + }, + vk::PipelineShaderStageCreateInfo{ + .stage = vk::ShaderStageFlagBits::eFragment, + .module = fs_module, + .pName = "main", + }, + }; + + const vk::PipelineLayoutCreateInfo layout_info{ + .setLayoutCount = 1U, + .pSetLayouts = &*desc_set_layout, + .pushConstantRangeCount = 1, + .pPushConstantRanges = &push_constants, + }; + + pipeline_layout = + Check<"create pp pipeline layout">(device.createPipelineLayoutUnique(layout_info)); + + const std::array pp_color_formats{ + surface_format, + }; + const vk::PipelineRenderingCreateInfo pipeline_rendering_ci{ + .colorAttachmentCount = pp_color_formats.size(), + .pColorAttachmentFormats = pp_color_formats.data(), + }; + + const vk::PipelineVertexInputStateCreateInfo vertex_input_info{ + .vertexBindingDescriptionCount = 0u, + .vertexAttributeDescriptionCount = 0u, + }; + + const vk::PipelineInputAssemblyStateCreateInfo input_assembly{ + .topology = vk::PrimitiveTopology::eTriangleList, + }; + + const vk::Viewport viewport{ + .x = 0.0f, + .y = 0.0f, + .width = 1.0f, + .height = 1.0f, + .minDepth = 0.0f, + .maxDepth = 1.0f, + }; + + const vk::Rect2D scissor = { + .offset = {0, 0}, + .extent = {1, 1}, + }; + + const vk::PipelineViewportStateCreateInfo viewport_info{ + .viewportCount = 1, + .pViewports = &viewport, + .scissorCount = 1, + .pScissors = &scissor, + }; + + const vk::PipelineRasterizationStateCreateInfo raster_state{ + .depthClampEnable = false, + .rasterizerDiscardEnable = false, + .polygonMode = vk::PolygonMode::eFill, + .cullMode = vk::CullModeFlagBits::eBack, + .frontFace = vk::FrontFace::eClockwise, + .depthBiasEnable = false, + .lineWidth = 1.0f, + }; + + const vk::PipelineMultisampleStateCreateInfo multisampling{ + .rasterizationSamples = vk::SampleCountFlagBits::e1, + }; + + const std::array attachments{ + vk::PipelineColorBlendAttachmentState{ + .blendEnable = false, + .colorWriteMask = vk::ColorComponentFlagBits::eR | vk::ColorComponentFlagBits::eG | + vk::ColorComponentFlagBits::eB | vk::ColorComponentFlagBits::eA, + }, + }; + + const vk::PipelineColorBlendStateCreateInfo color_blending{ + .logicOpEnable = false, + .logicOp = vk::LogicOp::eCopy, + .attachmentCount = attachments.size(), + .pAttachments = attachments.data(), + .blendConstants = std::array{1.0f, 1.0f, 1.0f, 1.0f}, + }; + + const std::array dynamic_states{ + vk::DynamicState::eViewport, + vk::DynamicState::eScissor, + }; + + const vk::PipelineDynamicStateCreateInfo dynamic_info{ + .dynamicStateCount = dynamic_states.size(), + .pDynamicStates = dynamic_states.data(), + }; + + const vk::GraphicsPipelineCreateInfo pipeline_info{ + .pNext = &pipeline_rendering_ci, + .stageCount = shaders_ci.size(), + .pStages = shaders_ci.data(), + .pVertexInputState = &vertex_input_info, + .pInputAssemblyState = &input_assembly, + .pViewportState = &viewport_info, + .pRasterizationState = &raster_state, + .pMultisampleState = &multisampling, + .pColorBlendState = &color_blending, + .pDynamicState = &dynamic_info, + .layout = *pipeline_layout, + }; + + pipeline = Check<"create post process pipeline">(device.createGraphicsPipelineUnique( + /*pipeline_cache*/ {}, pipeline_info)); + + // Once pipeline is compiled, we don't need the shader module anymore + device.destroyShaderModule(vs_module); + device.destroyShaderModule(fs_module); + + // Create sampler resource + const vk::SamplerCreateInfo sampler_ci{ + .magFilter = vk::Filter::eLinear, + .minFilter = vk::Filter::eLinear, + .mipmapMode = vk::SamplerMipmapMode::eNearest, + .addressModeU = vk::SamplerAddressMode::eClampToEdge, + .addressModeV = vk::SamplerAddressMode::eClampToEdge, + }; + sampler = Check<"create pp sampler">(device.createSamplerUnique(sampler_ci)); +} + +void PostProcessingPass::Render(vk::CommandBuffer cmdbuf, vk::ImageView input, + vk::Extent2D input_size, Frame& frame, Settings settings) { + const std::array attachments{{ + { + .imageView = frame.image_view, + .imageLayout = vk::ImageLayout::eColorAttachmentOptimal, + .loadOp = vk::AttachmentLoadOp::eClear, + .storeOp = vk::AttachmentStoreOp::eStore, + }, + }}; + const vk::RenderingInfo rendering_info{ + .renderArea{ + .extent{ + .width = frame.width, + .height = frame.height, + }, + }, + .layerCount = 1, + .colorAttachmentCount = attachments.size(), + .pColorAttachments = attachments.data(), + }; + + vk::DescriptorImageInfo image_info{ + .sampler = *sampler, + .imageView = input, + .imageLayout = vk::ImageLayout::eShaderReadOnlyOptimal, + }; + + const std::array set_writes{ + vk::WriteDescriptorSet{ + .dstSet = VK_NULL_HANDLE, + .dstBinding = 0, + .dstArrayElement = 0, + .descriptorCount = 1, + .descriptorType = vk::DescriptorType::eCombinedImageSampler, + .pImageInfo = &image_info, + }, + }; + + cmdbuf.bindPipeline(vk::PipelineBindPoint::eGraphics, *pipeline); + + const std::array viewports = { + vk::Viewport{ + .width = static_cast(frame.width), + .height = static_cast(frame.height), + .minDepth = 0.0f, + .maxDepth = 1.0f, + }, + }; + + cmdbuf.setViewport(0, viewports); + cmdbuf.setScissor(0, vk::Rect2D{ + .extent{ + .width = frame.width, + .height = frame.height, + }, + }); + + cmdbuf.pushDescriptorSetKHR(vk::PipelineBindPoint::eGraphics, *pipeline_layout, 0, set_writes); + cmdbuf.pushConstants(*pipeline_layout, vk::ShaderStageFlagBits::eFragment, 0, sizeof(Settings), + &settings); + + cmdbuf.beginRendering(rendering_info); + cmdbuf.draw(3, 1, 0, 0); + cmdbuf.endRendering(); +} + +} // namespace Vulkan::HostPasses \ No newline at end of file diff --git a/src/video_core/renderer_vulkan/host_passes/pp_pass.h b/src/video_core/renderer_vulkan/host_passes/pp_pass.h new file mode 100644 index 000000000..f95c02e8d --- /dev/null +++ b/src/video_core/renderer_vulkan/host_passes/pp_pass.h @@ -0,0 +1,34 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "common/types.h" +#include "video_core/renderer_vulkan/vk_common.h" + +namespace Vulkan { +class Frame; +} + +namespace Vulkan::HostPasses { + +class PostProcessingPass { +public: + struct Settings { + float gamma = 1.0f; + u32 hdr = 0; + }; + + void Create(vk::Device device, vk::Format surface_format); + + void Render(vk::CommandBuffer cmdbuf, vk::ImageView input, vk::Extent2D input_size, + Frame& output, Settings settings); + +private: + vk::UniquePipeline pipeline{}; + vk::UniquePipelineLayout pipeline_layout{}; + vk::UniqueDescriptorSetLayout desc_set_layout{}; + vk::UniqueSampler sampler{}; +}; + +} // namespace Vulkan::HostPasses diff --git a/src/video_core/renderer_vulkan/liverpool_to_vk.cpp b/src/video_core/renderer_vulkan/liverpool_to_vk.cpp index 843bedb20..a6ae0c304 100644 --- a/src/video_core/renderer_vulkan/liverpool_to_vk.cpp +++ b/src/video_core/renderer_vulkan/liverpool_to_vk.cpp @@ -156,6 +156,18 @@ vk::CullModeFlags CullMode(Liverpool::CullMode mode) { } } +vk::FrontFace FrontFace(Liverpool::FrontFace face) { + switch (face) { + case Liverpool::FrontFace::Clockwise: + return vk::FrontFace::eClockwise; + case Liverpool::FrontFace::CounterClockwise: + return vk::FrontFace::eCounterClockwise; + default: + UNREACHABLE(); + return vk::FrontFace::eClockwise; + } +} + vk::BlendFactor BlendFactor(Liverpool::BlendControl::BlendFactor factor) { using BlendFactor = Liverpool::BlendControl::BlendFactor; switch (factor) { diff --git a/src/video_core/renderer_vulkan/liverpool_to_vk.h b/src/video_core/renderer_vulkan/liverpool_to_vk.h index 42da7aa06..fca0a8378 100644 --- a/src/video_core/renderer_vulkan/liverpool_to_vk.h +++ b/src/video_core/renderer_vulkan/liverpool_to_vk.h @@ -26,6 +26,8 @@ vk::PolygonMode PolygonMode(Liverpool::PolygonMode mode); vk::CullModeFlags CullMode(Liverpool::CullMode mode); +vk::FrontFace FrontFace(Liverpool::FrontFace mode); + vk::BlendFactor BlendFactor(Liverpool::BlendControl::BlendFactor factor); vk::BlendOp BlendOp(Liverpool::BlendControl::BlendFunc func); diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index 901096259..7c020a012 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp @@ -28,6 +28,15 @@ static constexpr std::array LogicalStageToStageBit = { vk::ShaderStageFlagBits::eCompute, }; +static bool IsPrimitiveTopologyList(const vk::PrimitiveTopology topology) { + return topology == vk::PrimitiveTopology::ePointList || + topology == vk::PrimitiveTopology::eLineList || + topology == vk::PrimitiveTopology::eTriangleList || + topology == vk::PrimitiveTopology::eLineListWithAdjacency || + topology == vk::PrimitiveTopology::eTriangleListWithAdjacency || + topology == vk::PrimitiveTopology::ePatchList; +} + GraphicsPipeline::GraphicsPipeline( const Instance& instance, Scheduler& scheduler, DescriptorHeap& desc_heap, const Shader::Profile& profile, const GraphicsPipelineKey& key_, @@ -75,19 +84,15 @@ GraphicsPipeline::GraphicsPipeline( .pVertexAttributeDescriptions = vertex_attributes.data(), }; - auto prim_restart = key.enable_primitive_restart != 0; - if (prim_restart && IsPrimitiveListTopology() && !instance.IsListRestartSupported()) { - LOG_WARNING(Render_Vulkan, - "Primitive restart is enabled for list topology but not supported by driver."); - prim_restart = false; - } + const auto topology = LiverpoolToVK::PrimitiveType(key.prim_type); const vk::PipelineInputAssemblyStateCreateInfo input_assembly = { - .topology = LiverpoolToVK::PrimitiveType(key.prim_type), - .primitiveRestartEnable = prim_restart, + .topology = topology, + // Avoid warning spam on all pipelines about unsupported restart disable, if not supported. + // However, must be false for list topologies to avoid validation errors. + .primitiveRestartEnable = + !instance.IsPrimitiveRestartDisableSupported() && !IsPrimitiveTopologyList(topology), }; - ASSERT_MSG(!prim_restart || key.primitive_restart_index == 0xFFFF || - key.primitive_restart_index == 0xFFFFFFFF, - "Primitive restart index other than -1 is not supported yet"); + const bool is_rect_list = key.prim_type == AmdGpu::PrimitiveType::RectList; const bool is_quad_list = key.prim_type == AmdGpu::PrimitiveType::QuadList; const auto& fs_info = runtime_infos[u32(Shader::LogicalStage::Fragment)].fs_info; @@ -99,13 +104,6 @@ GraphicsPipeline::GraphicsPipeline( .depthClampEnable = false, .rasterizerDiscardEnable = false, .polygonMode = LiverpoolToVK::PolygonMode(key.polygon_mode), - .cullMode = LiverpoolToVK::IsPrimitiveCulled(key.prim_type) - ? LiverpoolToVK::CullMode(key.cull_mode) - : vk::CullModeFlagBits::eNone, - .frontFace = key.front_face == Liverpool::FrontFace::Clockwise - ? vk::FrontFace::eClockwise - : vk::FrontFace::eCounterClockwise, - .depthBiasEnable = key.depth_bias_enable, .lineWidth = 1.0f, }; @@ -123,25 +121,31 @@ GraphicsPipeline::GraphicsPipeline( .pNext = instance.IsDepthClipControlSupported() ? &clip_control : nullptr, }; - boost::container::static_vector dynamic_states = { - vk::DynamicState::eViewportWithCountEXT, - vk::DynamicState::eScissorWithCountEXT, - vk::DynamicState::eBlendConstants, - vk::DynamicState::eDepthBounds, - vk::DynamicState::eDepthBias, - vk::DynamicState::eStencilReference, - vk::DynamicState::eStencilCompareMask, - vk::DynamicState::eStencilWriteMask, - vk::DynamicState::eStencilOpEXT, + boost::container::static_vector dynamic_states = { + vk::DynamicState::eViewportWithCount, vk::DynamicState::eScissorWithCount, + vk::DynamicState::eBlendConstants, vk::DynamicState::eDepthTestEnable, + vk::DynamicState::eDepthWriteEnable, vk::DynamicState::eDepthCompareOp, + vk::DynamicState::eDepthBiasEnable, vk::DynamicState::eDepthBias, + vk::DynamicState::eStencilTestEnable, vk::DynamicState::eStencilReference, + vk::DynamicState::eStencilCompareMask, vk::DynamicState::eStencilWriteMask, + vk::DynamicState::eStencilOp, vk::DynamicState::eCullMode, + vk::DynamicState::eFrontFace, }; + if (instance.IsPrimitiveRestartDisableSupported()) { + dynamic_states.push_back(vk::DynamicState::ePrimitiveRestartEnable); + } + if (instance.IsDepthBoundsSupported()) { + dynamic_states.push_back(vk::DynamicState::eDepthBoundsTestEnable); + dynamic_states.push_back(vk::DynamicState::eDepthBounds); + } if (instance.IsDynamicColorWriteMaskSupported()) { dynamic_states.push_back(vk::DynamicState::eColorWriteMaskEXT); } if (instance.IsVertexInputDynamicState()) { dynamic_states.push_back(vk::DynamicState::eVertexInputEXT); } else if (!vertex_bindings.empty()) { - dynamic_states.push_back(vk::DynamicState::eVertexInputBindingStrideEXT); + dynamic_states.push_back(vk::DynamicState::eVertexInputBindingStride); } const vk::PipelineDynamicStateCreateInfo dynamic_info = { @@ -149,14 +153,6 @@ GraphicsPipeline::GraphicsPipeline( .pDynamicStates = dynamic_states.data(), }; - const vk::PipelineDepthStencilStateCreateInfo depth_info = { - .depthTestEnable = key.depth_test_enable, - .depthWriteEnable = key.depth_write_enable, - .depthCompareOp = key.depth_compare_op, - .depthBoundsTestEnable = key.depth_bounds_test_enable, - .stencilTestEnable = key.stencil_test_enable, - }; - boost::container::static_vector shader_stages; auto stage = u32(Shader::LogicalStage::Vertex); @@ -216,7 +212,7 @@ GraphicsPipeline::GraphicsPipeline( }); } - const vk::PipelineRenderingCreateInfoKHR pipeline_rendering_ci = { + const vk::PipelineRenderingCreateInfo pipeline_rendering_ci = { .colorAttachmentCount = key.num_color_attachments, .pColorAttachmentFormats = key.color_formats.data(), .depthAttachmentFormat = key.depth_format, @@ -292,7 +288,6 @@ GraphicsPipeline::GraphicsPipeline( .pViewportState = &viewport_info, .pRasterizationState = &raster_state, .pMultisampleState = &multisampling, - .pDepthStencilState = &depth_info, .pColorBlendState = &color_blending, .pDynamicState = &dynamic_info, .layout = *pipeline_layout, diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.h b/src/video_core/renderer_vulkan/vk_graphics_pipeline.h index e6596db2f..59230ae46 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.h +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.h @@ -39,26 +39,10 @@ struct GraphicsPipelineKey { vk::Format depth_format; vk::Format stencil_format; - struct { - bool clip_disable : 1; - bool depth_test_enable : 1; - bool depth_write_enable : 1; - bool depth_bounds_test_enable : 1; - bool depth_bias_enable : 1; - bool stencil_test_enable : 1; - // Must be named to be zero-initialized. - u8 _unused : 2; - }; - vk::CompareOp depth_compare_op; - u32 num_samples; u32 mrt_mask; AmdGpu::PrimitiveType prim_type; - u32 enable_primitive_restart; - u32 primitive_restart_index; Liverpool::PolygonMode polygon_mode; - Liverpool::CullMode cull_mode; - Liverpool::FrontFace front_face; Liverpool::ClipSpace clip_space; Liverpool::ColorBufferMask cb_shader_mask; std::array blend_controls; @@ -94,20 +78,6 @@ public: return key.mrt_mask; } - auto IsClipDisabled() const { - return key.clip_disable; - } - - [[nodiscard]] bool IsPrimitiveListTopology() const { - return key.prim_type == AmdGpu::PrimitiveType::PointList || - key.prim_type == AmdGpu::PrimitiveType::LineList || - key.prim_type == AmdGpu::PrimitiveType::TriangleList || - key.prim_type == AmdGpu::PrimitiveType::AdjLineList || - key.prim_type == AmdGpu::PrimitiveType::AdjTriangleList || - key.prim_type == AmdGpu::PrimitiveType::RectList || - key.prim_type == AmdGpu::PrimitiveType::QuadList; - } - /// Gets the attributes and bindings for vertex inputs. template void GetVertexInputs(VertexInputs& attributes, VertexInputs& bindings, diff --git a/src/video_core/renderer_vulkan/vk_instance.cpp b/src/video_core/renderer_vulkan/vk_instance.cpp index ab8f074cd..072807124 100644 --- a/src/video_core/renderer_vulkan/vk_instance.cpp +++ b/src/video_core/renderer_vulkan/vk_instance.cpp @@ -203,12 +203,14 @@ std::string Instance::GetDriverVersionName() { } bool Instance::CreateDevice() { - const vk::StructureChain feature_chain = physical_device.getFeatures2< - vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceVulkan11Features, - vk::PhysicalDeviceVulkan12Features, vk::PhysicalDeviceRobustness2FeaturesEXT, - vk::PhysicalDeviceExtendedDynamicState3FeaturesEXT, - vk::PhysicalDevicePrimitiveTopologyListRestartFeaturesEXT, - vk::PhysicalDevicePortabilitySubsetFeaturesKHR>(); + const vk::StructureChain feature_chain = + physical_device + .getFeatures2(); features = feature_chain.get().features; const vk::StructureChain properties_chain = physical_device.getProperties2< @@ -240,19 +242,12 @@ bool Instance::CreateDevice() { return false; }; - // These extensions are promoted by Vulkan 1.3, but for greater compatibility we use Vulkan 1.2 - // with extensions. - add_extension(VK_KHR_FORMAT_FEATURE_FLAGS_2_EXTENSION_NAME); - add_extension(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); - add_extension(VK_EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION_EXTENSION_NAME); - add_extension(VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME); - add_extension(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME); - add_extension(VK_EXT_TOOLING_INFO_EXTENSION_NAME); - const bool maintenance4 = add_extension(VK_KHR_MAINTENANCE_4_EXTENSION_NAME); + // Required + ASSERT(add_extension(VK_KHR_SWAPCHAIN_EXTENSION_NAME)); + ASSERT(add_extension(VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME)); - add_extension(VK_KHR_SWAPCHAIN_EXTENSION_NAME); - add_extension(VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME); - add_extension(VK_EXT_DEPTH_RANGE_UNRESTRICTED_EXTENSION_NAME); + // Optional + depth_range_unrestricted = add_extension(VK_EXT_DEPTH_RANGE_UNRESTRICTED_EXTENSION_NAME); dynamic_state_3 = add_extension(VK_EXT_EXTENDED_DYNAMIC_STATE_3_EXTENSION_NAME); if (dynamic_state_3) { dynamic_state_3_features = @@ -276,6 +271,7 @@ bool Instance::CreateDevice() { shader_stencil_export = add_extension(VK_EXT_SHADER_STENCIL_EXPORT_EXTENSION_NAME); image_load_store_lod = add_extension(VK_AMD_SHADER_IMAGE_LOAD_STORE_LOD_EXTENSION_NAME); amd_gcn_shader = add_extension(VK_AMD_GCN_SHADER_EXTENSION_NAME); + amd_shader_trinary_minmax = add_extension(VK_AMD_SHADER_TRINARY_MINMAX_EXTENSION_NAME); const bool calibrated_timestamps = TRACY_GPU_ENABLED ? add_extension(VK_EXT_CALIBRATED_TIMESTAMPS_EXTENSION_NAME) : false; @@ -318,6 +314,7 @@ bool Instance::CreateDevice() { feature_chain.get(); const auto vk11_features = feature_chain.get(); const auto vk12_features = feature_chain.get(); + const auto vk13_features = feature_chain.get(); vk::StructureChain device_chain = { vk::DeviceCreateInfo{ .queueCreateInfoCount = 1u, @@ -335,6 +332,7 @@ bool Instance::CreateDevice() { .logicOp = features.logicOp, .depthBiasClamp = features.depthBiasClamp, .fillModeNonSolid = features.fillModeNonSolid, + .depthBounds = features.depthBounds, .multiViewport = features.multiViewport, .samplerAnisotropy = features.samplerAnisotropy, .vertexPipelineStoresAndAtomics = features.vertexPipelineStoresAndAtomics, @@ -366,23 +364,14 @@ bool Instance::CreateDevice() { .hostQueryReset = vk12_features.hostQueryReset, .timelineSemaphore = vk12_features.timelineSemaphore, }, - // Vulkan 1.3 promoted extensions - vk::PhysicalDeviceDynamicRenderingFeaturesKHR{ - .dynamicRendering = true, + vk::PhysicalDeviceVulkan13Features{ + .robustImageAccess = vk13_features.robustImageAccess, + .shaderDemoteToHelperInvocation = vk13_features.shaderDemoteToHelperInvocation, + .synchronization2 = vk13_features.synchronization2, + .dynamicRendering = vk13_features.dynamicRendering, + .maintenance4 = vk13_features.maintenance4, }, - vk::PhysicalDeviceShaderDemoteToHelperInvocationFeaturesEXT{ - .shaderDemoteToHelperInvocation = true, - }, - vk::PhysicalDeviceSynchronization2Features{ - .synchronization2 = true, - }, - vk::PhysicalDeviceExtendedDynamicStateFeaturesEXT{ - .extendedDynamicState = true, - }, - vk::PhysicalDeviceMaintenance4FeaturesKHR{ - .maintenance4 = true, - }, - // Other extensions + // Extensions vk::PhysicalDeviceCustomBorderColorFeaturesEXT{ .customBorderColors = true, .customBorderColorWithoutFormat = true, @@ -417,9 +406,6 @@ bool Instance::CreateDevice() { #endif }; - if (!maintenance4) { - device_chain.unlink(); - } if (!custom_border_color) { device_chain.unlink(); } @@ -536,12 +522,14 @@ void Instance::CollectDeviceParameters() { LOG_INFO(Render_Vulkan, "GPU_Vulkan_Extensions: {}", extensions); } -void Instance::CollectToolingInfo() { - if (GetDriverID() == vk::DriverId::eAmdProprietary) { - // Currently causes issues with Reshade on AMD proprietary, disabled until fix released. +void Instance::CollectToolingInfo() const { + if (driver_id == vk::DriverId::eAmdProprietary || + driver_id == vk::DriverId::eIntelProprietaryWindows) { + // AMD: Causes issues with Reshade. + // Intel: Causes crash on start. return; } - const auto [tools_result, tools] = physical_device.getToolPropertiesEXT(); + const auto [tools_result, tools] = physical_device.getToolProperties(); if (tools_result != vk::Result::eSuccess) { LOG_ERROR(Render_Vulkan, "Could not get Vulkan tool properties: {}", vk::to_string(tools_result)); diff --git a/src/video_core/renderer_vulkan/vk_instance.h b/src/video_core/renderer_vulkan/vk_instance.h index 3ccf89276..bf9af1f24 100644 --- a/src/video_core/renderer_vulkan/vk_instance.h +++ b/src/video_core/renderer_vulkan/vk_instance.h @@ -84,6 +84,16 @@ public: return features.samplerAnisotropy; } + /// Returns true if depth bounds testing is supported + bool IsDepthBoundsSupported() const { + return features.depthBounds; + } + + /// Returns true if 64-bit floats are supported in shaders + bool IsShaderFloat64Supported() const { + return features.shaderFloat64; + } + /// Returns true when VK_EXT_custom_border_color is supported bool IsCustomBorderColorSupported() const { return custom_border_color; @@ -99,6 +109,11 @@ public: return depth_clip_control; } + /// Returns true when VK_EXT_depth_range_unrestricted is supported + bool IsDepthRangeUnrestrictedSupported() const { + return depth_range_unrestricted; + } + /// Returns true when the extendedDynamicState3ColorWriteMask feature of /// VK_EXT_extended_dynamic_state3 is supported. bool IsDynamicColorWriteMaskSupported() const { @@ -145,6 +160,11 @@ public: return amd_gcn_shader; } + /// Returns true when VK_AMD_shader_trinary_minmax is supported. + bool IsAmdShaderTrinaryMinMaxSupported() const { + return amd_shader_trinary_minmax; + } + /// Returns true when geometry shaders are supported by the device bool IsGeometryStageSupported() const { return features.geometryShader; @@ -282,6 +302,11 @@ public: properties.limits.framebufferStencilSampleCounts; } + /// Returns whether disabling primitive restart is supported. + bool IsPrimitiveRestartDisableSupported() const { + return driver_id != vk::DriverId::eMoltenvk; + } + private: /// Creates the logical device opportunistically enabling extensions bool CreateDevice(); @@ -291,7 +316,7 @@ private: /// Collects telemetry information from the device. void CollectDeviceParameters(); - void CollectToolingInfo(); + void CollectToolingInfo() const; /// Gets the supported feature flags for a format. [[nodiscard]] vk::FormatFeatureFlags2 GetFormatFeatureFlags(vk::Format format) const; @@ -325,6 +350,7 @@ private: bool custom_border_color{}; bool fragment_shader_barycentric{}; bool depth_clip_control{}; + bool depth_range_unrestricted{}; bool dynamic_state_3{}; bool vertex_input_dynamic_state{}; bool robustness2{}; @@ -333,6 +359,7 @@ private: bool shader_stencil_export{}; bool image_load_store_lod{}; bool amd_gcn_shader{}; + bool amd_shader_trinary_minmax{}; bool portability_subset{}; }; diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index bb46c8375..49f3ba706 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp @@ -27,6 +27,8 @@ using Shader::LogicalStage; using Shader::Stage; using Shader::VsOutput; +constexpr static auto SpirvVersion1_6 = 0x00010600U; + constexpr static std::array DescriptorHeapSizes = { vk::DescriptorPoolSize{vk::DescriptorType::eUniformBuffer, 8192}, vk::DescriptorPoolSize{vk::DescriptorType::eStorageBuffer, 1024}, @@ -124,7 +126,7 @@ const Shader::RuntimeInfo& PipelineCache::BuildRuntimeInfo(Stage stage, LogicalS info.vs_info.emulate_depth_negative_one_to_one = !instance.IsDepthClipControlSupported() && regs.clipper_control.clip_space == Liverpool::ClipSpace::MinusWToW; - info.vs_info.clip_disable = graphics_key.clip_disable; + info.vs_info.clip_disable = regs.IsClipDisabled(); if (l_stage == LogicalStage::TessellationEval) { info.vs_info.tess_type = regs.tess_config.type; info.vs_info.tess_topology = regs.tess_config.topology; @@ -193,8 +195,9 @@ PipelineCache::PipelineCache(const Instance& instance_, Scheduler& scheduler_, desc_heap{instance, scheduler.GetMasterSemaphore(), DescriptorHeapSizes} { const auto& vk12_props = instance.GetVk12Properties(); profile = Shader::Profile{ - .supported_spirv = instance.ApiVersion() >= VK_API_VERSION_1_3 ? 0x00010600U : 0x00010500U, + .supported_spirv = SpirvVersion1_6, .subgroup_size = instance.SubgroupSize(), + .support_float64 = instance.IsShaderFloat64Supported(), .support_fp32_denorm_preserve = bool(vk12_props.shaderDenormPreserveFloat32), .support_fp32_denorm_flush = bool(vk12_props.shaderDenormFlushToZeroFloat32), .support_fp32_round_to_zero = bool(vk12_props.shaderRoundingModeRTZFloat32), @@ -202,6 +205,7 @@ PipelineCache::PipelineCache(const Instance& instance_, Scheduler& scheduler_, .support_legacy_vertex_attributes = instance_.IsLegacyVertexAttributesSupported(), .supports_image_load_store_lod = instance_.IsImageLoadStoreLodSupported(), .supports_native_cube_calc = instance_.IsAmdGcnShaderSupported(), + .supports_trinary_minmax = instance_.IsAmdShaderTrinaryMinMaxSupported(), .supports_robust_buffer_access = instance_.IsRobustBufferAccess2Supported(), .needs_manual_interpolation = instance.IsFragmentShaderBarycentricSupported() && instance.GetDriverID() == vk::DriverId::eNvidiaProprietary, @@ -267,16 +271,6 @@ bool PipelineCache::RefreshGraphicsKey() { auto& regs = liverpool->regs; auto& key = graphics_key; - key.clip_disable = - regs.clipper_control.clip_disable || regs.primitive_type == AmdGpu::PrimitiveType::RectList; - key.depth_test_enable = regs.depth_control.depth_enable; - key.depth_write_enable = - regs.depth_control.depth_write_enable && !regs.depth_render_control.depth_clear_enable; - key.depth_bounds_test_enable = regs.depth_control.depth_bounds_enable; - key.depth_bias_enable = regs.polygon_control.NeedsBias(); - key.depth_compare_op = LiverpoolToVK::CompareOp(regs.depth_control.depth_func); - key.stencil_test_enable = regs.depth_control.stencil_enable; - const auto depth_format = instance.GetSupportedFormat( LiverpoolToVK::DepthFormat(regs.depth_buffer.z_info.format, regs.depth_buffer.stencil_info.format), @@ -285,22 +279,16 @@ bool PipelineCache::RefreshGraphicsKey() { key.depth_format = depth_format; } else { key.depth_format = vk::Format::eUndefined; - key.depth_test_enable = false; } if (regs.depth_buffer.StencilValid()) { key.stencil_format = depth_format; } else { key.stencil_format = vk::Format::eUndefined; - key.stencil_test_enable = false; } key.prim_type = regs.primitive_type; - key.enable_primitive_restart = regs.enable_primitive_restart & 1; - key.primitive_restart_index = regs.primitive_restart_index; key.polygon_mode = regs.polygon_control.PolyMode(); - key.cull_mode = regs.polygon_control.CullingMode(); key.clip_space = regs.clipper_control.clip_space; - key.front_face = regs.polygon_control.front_face; key.num_samples = regs.NumSamples(); const bool skip_cb_binding = diff --git a/src/video_core/renderer_vulkan/vk_platform.cpp b/src/video_core/renderer_vulkan/vk_platform.cpp index 716473377..c49e62f4e 100644 --- a/src/video_core/renderer_vulkan/vk_platform.cpp +++ b/src/video_core/renderer_vulkan/vk_platform.cpp @@ -22,6 +22,10 @@ #include "sdl_window.h" #include "video_core/renderer_vulkan/vk_platform.h" +#ifdef __APPLE__ +#include +#endif + namespace Vulkan { static const char* const VALIDATION_LAYER_NAME = "VK_LAYER_KHRONOS_validation"; @@ -223,8 +227,19 @@ vk::UniqueInstance CreateInstance(Frontend::WindowSystemType window_type, bool e LOG_INFO(Render_Vulkan, "Creating vulkan instance"); #ifdef __APPLE__ +#ifndef ENABLE_QT_GUI + // Initialize the environment with the path to the MoltenVK ICD, so that the loader will + // find it. + static const auto icd_path = [] { + char path[PATH_MAX]; + u32 length = PATH_MAX; + _NSGetExecutablePath(path, &length); + return std::filesystem::path(path).parent_path() / "MoltenVK_icd.json"; + }(); + setenv("VK_DRIVER_FILES", icd_path.c_str(), true); +#endif // If the Vulkan loader exists in /usr/local/lib, give it priority. The Vulkan SDK - // installs it here by default but it is not in the default library search path. + // installs it here by default, but it is not in the default library search path. // The loader has a clause to check for it, but at a lower priority than the bundled // libMoltenVK.dylib, so we need to handle it ourselves to give it priority. static const std::string usr_local_path = "/usr/local/lib/libvulkan.dylib"; @@ -278,7 +293,6 @@ vk::UniqueInstance CreateInstance(Frontend::WindowSystemType window_type, bool e vk::Bool32 enable_force_barriers = vk::True; #ifdef __APPLE__ const vk::Bool32 mvk_debug_mode = enable_crash_diagnostic ? vk::True : vk::False; - constexpr vk::Bool32 mvk_use_mtlheap = vk::True; #endif const std::array layer_setings = { @@ -355,15 +369,6 @@ vk::UniqueInstance CreateInstance(Frontend::WindowSystemType window_type, bool e .valueCount = 1, .pValues = &mvk_debug_mode, }, - // Use MTLHeap to back device memory, which among other things allows us to - // use VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT via memory aliasing. - vk::LayerSettingEXT{ - .pLayerName = "MoltenVK", - .pSettingName = "MVK_CONFIG_USE_MTLHEAP", - .type = vk::LayerSettingTypeEXT::eBool32, - .valueCount = 1, - .pValues = &mvk_use_mtlheap, - }, #endif }; diff --git a/src/video_core/renderer_vulkan/vk_platform.h b/src/video_core/renderer_vulkan/vk_platform.h index 0f70312ed..b8f5f9f11 100644 --- a/src/video_core/renderer_vulkan/vk_platform.h +++ b/src/video_core/renderer_vulkan/vk_platform.h @@ -5,7 +5,9 @@ #include +#include "common/assert.h" #include "common/logging/log.h" +#include "common/string_literal.h" #include "common/types.h" #include "video_core/renderer_vulkan/vk_common.h" @@ -16,7 +18,7 @@ class WindowSDL; namespace Vulkan { -constexpr u32 TargetVulkanApiVersion = VK_API_VERSION_1_2; +constexpr u32 TargetVulkanApiVersion = VK_API_VERSION_1_3; vk::SurfaceKHR CreateSurface(vk::Instance instance, const Frontend::WindowSDL& emu_window); @@ -48,4 +50,25 @@ void SetObjectName(vk::Device device, const HandleType& handle, const char* form SetObjectName(device, handle, debug_name); } +template +static void Check(vk::Result r) { + if constexpr (msg.len <= 1) { + ASSERT_MSG(r == vk::Result::eSuccess, "vk::Result={}", vk::to_string(r)); + } else { + ASSERT_MSG(r == vk::Result::eSuccess, "Failed to {}: vk::Result={}", msg.value, + vk::to_string(r)); + } +} + +template +static T Check(vk::ResultValue r) { + if constexpr (msg.len <= 1) { + ASSERT_MSG(r.result == vk::Result::eSuccess, "vk::Result={}", vk::to_string(r.result)); + } else { + ASSERT_MSG(r.result == vk::Result::eSuccess, "Failed to {}: vk::Result={}", msg.value, + vk::to_string(r.result)); + } + return std::move(r.value); +} + } // namespace Vulkan diff --git a/src/video_core/renderer_vulkan/vk_presenter.cpp b/src/video_core/renderer_vulkan/vk_presenter.cpp index 04d0e7ac9..6bd4b26fa 100644 --- a/src/video_core/renderer_vulkan/vk_presenter.cpp +++ b/src/video_core/renderer_vulkan/vk_presenter.cpp @@ -6,21 +6,22 @@ #include "common/singleton.h" #include "core/debug_state.h" #include "core/devtools/layer.h" -#include "core/file_format/splash.h" #include "core/libraries/system/systemservice.h" #include "imgui/renderer/imgui_core.h" #include "sdl_window.h" +#include "video_core/renderer_vulkan/vk_platform.h" #include "video_core/renderer_vulkan/vk_presenter.h" #include "video_core/renderer_vulkan/vk_rasterizer.h" #include "video_core/renderer_vulkan/vk_shader_util.h" #include "video_core/texture_cache/image.h" #include "video_core/host_shaders/fs_tri_vert.h" -#include "video_core/host_shaders/post_process_frag.h" #include #include + +#include "common/elf_info.h" #include "imgui/renderer/imgui_impl_vulkan.h" namespace Vulkan { @@ -106,191 +107,6 @@ static vk::Rect2D FitImage(s32 frame_width, s32 frame_height, s32 swapchain_widt dst_rect.offset.x, dst_rect.offset.y); } -void Presenter::CreatePostProcessPipeline() { - static const std::array pp_shaders{ - HostShaders::FS_TRI_VERT, - HostShaders::POST_PROCESS_FRAG, - }; - - boost::container::static_vector bindings{ - { - .binding = 0, - .descriptorType = vk::DescriptorType::eCombinedImageSampler, - .descriptorCount = 1, - .stageFlags = vk::ShaderStageFlagBits::eFragment, - }, - }; - - const vk::DescriptorSetLayoutCreateInfo desc_layout_ci = { - .flags = vk::DescriptorSetLayoutCreateFlagBits::ePushDescriptorKHR, - .bindingCount = static_cast(bindings.size()), - .pBindings = bindings.data(), - }; - auto desc_layout_result = instance.GetDevice().createDescriptorSetLayoutUnique(desc_layout_ci); - ASSERT_MSG(desc_layout_result.result == vk::Result::eSuccess, - "Failed to create descriptor set layout: {}", - vk::to_string(desc_layout_result.result)); - pp_desc_set_layout = std::move(desc_layout_result.value); - - const vk::PushConstantRange push_constants = { - .stageFlags = vk::ShaderStageFlagBits::eFragment, - .offset = 0, - .size = sizeof(PostProcessSettings), - }; - - const auto& vs_module = - Vulkan::Compile(pp_shaders[0], vk::ShaderStageFlagBits::eVertex, instance.GetDevice()); - ASSERT(vs_module); - Vulkan::SetObjectName(instance.GetDevice(), vs_module, "fs_tri.vert"); - - const auto& fs_module = - Vulkan::Compile(pp_shaders[1], vk::ShaderStageFlagBits::eFragment, instance.GetDevice()); - ASSERT(fs_module); - Vulkan::SetObjectName(instance.GetDevice(), fs_module, "post_process.frag"); - - const std::array shaders_ci{ - vk::PipelineShaderStageCreateInfo{ - .stage = vk::ShaderStageFlagBits::eVertex, - .module = vs_module, - .pName = "main", - }, - vk::PipelineShaderStageCreateInfo{ - .stage = vk::ShaderStageFlagBits::eFragment, - .module = fs_module, - .pName = "main", - }, - }; - - const vk::DescriptorSetLayout set_layout = *pp_desc_set_layout; - const vk::PipelineLayoutCreateInfo layout_info = { - .setLayoutCount = 1U, - .pSetLayouts = &set_layout, - .pushConstantRangeCount = 1, - .pPushConstantRanges = &push_constants, - }; - auto [layout_result, layout] = instance.GetDevice().createPipelineLayoutUnique(layout_info); - ASSERT_MSG(layout_result == vk::Result::eSuccess, "Failed to create pipeline layout: {}", - vk::to_string(layout_result)); - pp_pipeline_layout = std::move(layout); - - const std::array pp_color_formats{ - vk::Format::eB8G8R8A8Unorm, // swapchain.GetSurfaceFormat().format, - }; - const vk::PipelineRenderingCreateInfoKHR pipeline_rendering_ci = { - .colorAttachmentCount = 1u, - .pColorAttachmentFormats = pp_color_formats.data(), - }; - - const vk::PipelineVertexInputStateCreateInfo vertex_input_info = { - .vertexBindingDescriptionCount = 0u, - .vertexAttributeDescriptionCount = 0u, - }; - - const vk::PipelineInputAssemblyStateCreateInfo input_assembly = { - .topology = vk::PrimitiveTopology::eTriangleList, - }; - - const vk::Viewport viewport = { - .x = 0.0f, - .y = 0.0f, - .width = 1.0f, - .height = 1.0f, - .minDepth = 0.0f, - .maxDepth = 1.0f, - }; - - const vk::Rect2D scissor = { - .offset = {0, 0}, - .extent = {1, 1}, - }; - - const vk::PipelineViewportStateCreateInfo viewport_info = { - .viewportCount = 1, - .pViewports = &viewport, - .scissorCount = 1, - .pScissors = &scissor, - }; - - const vk::PipelineRasterizationStateCreateInfo raster_state = { - .depthClampEnable = false, - .rasterizerDiscardEnable = false, - .polygonMode = vk::PolygonMode::eFill, - .cullMode = vk::CullModeFlagBits::eBack, - .frontFace = vk::FrontFace::eClockwise, - .depthBiasEnable = false, - .lineWidth = 1.0f, - }; - - const vk::PipelineMultisampleStateCreateInfo multisampling = { - .rasterizationSamples = vk::SampleCountFlagBits::e1, - }; - - const std::array attachments{ - vk::PipelineColorBlendAttachmentState{ - .blendEnable = false, - .colorWriteMask = vk::ColorComponentFlagBits::eR | vk::ColorComponentFlagBits::eG | - vk::ColorComponentFlagBits::eB | vk::ColorComponentFlagBits::eA, - }, - }; - - const vk::PipelineColorBlendStateCreateInfo color_blending = { - .logicOpEnable = false, - .logicOp = vk::LogicOp::eCopy, - .attachmentCount = attachments.size(), - .pAttachments = attachments.data(), - .blendConstants = std::array{1.0f, 1.0f, 1.0f, 1.0f}, - }; - - const std::array dynamic_states = { - vk::DynamicState::eViewport, - vk::DynamicState::eScissor, - }; - - const vk::PipelineDynamicStateCreateInfo dynamic_info = { - .dynamicStateCount = static_cast(dynamic_states.size()), - .pDynamicStates = dynamic_states.data(), - }; - - const vk::GraphicsPipelineCreateInfo pipeline_info = { - .pNext = &pipeline_rendering_ci, - .stageCount = static_cast(shaders_ci.size()), - .pStages = shaders_ci.data(), - .pVertexInputState = &vertex_input_info, - .pInputAssemblyState = &input_assembly, - .pViewportState = &viewport_info, - .pRasterizationState = &raster_state, - .pMultisampleState = &multisampling, - .pColorBlendState = &color_blending, - .pDynamicState = &dynamic_info, - .layout = *pp_pipeline_layout, - }; - - auto result = instance.GetDevice().createGraphicsPipelineUnique( - /*pipeline_cache*/ {}, pipeline_info); - if (result.result == vk::Result::eSuccess) { - pp_pipeline = std::move(result.value); - } else { - UNREACHABLE_MSG("Post process pipeline creation failed!"); - } - - // Once pipeline is compiled, we don't need the shader module anymore - instance.GetDevice().destroyShaderModule(vs_module); - instance.GetDevice().destroyShaderModule(fs_module); - - // Create sampler resource - const vk::SamplerCreateInfo sampler_ci = { - .magFilter = vk::Filter::eLinear, - .minFilter = vk::Filter::eLinear, - .mipmapMode = vk::SamplerMipmapMode::eNearest, - .addressModeU = vk::SamplerAddressMode::eClampToEdge, - .addressModeV = vk::SamplerAddressMode::eClampToEdge, - }; - auto [sampler_result, smplr] = instance.GetDevice().createSamplerUnique(sampler_ci); - ASSERT_MSG(sampler_result == vk::Result::eSuccess, "Failed to create sampler: {}", - vk::to_string(sampler_result)); - pp_sampler = std::move(smplr); -} - Presenter::Presenter(Frontend::WindowSDL& window_, AmdGpu::Liverpool* liverpool_) : window{window_}, liverpool{liverpool_}, instance{window, Config::getGpuId(), Config::vkValidationEnabled(), @@ -306,15 +122,15 @@ Presenter::Presenter(Frontend::WindowSDL& window_, AmdGpu::Liverpool* liverpool_ present_frames.resize(num_images); for (u32 i = 0; i < num_images; i++) { Frame& frame = present_frames[i]; - auto [fence_result, fence] = - device.createFence({.flags = vk::FenceCreateFlagBits::eSignaled}); - ASSERT_MSG(fence_result == vk::Result::eSuccess, "Failed to create present done fence: {}", - vk::to_string(fence_result)); + frame.id = i; + auto fence = Check<"create present done fence">( + device.createFence({.flags = vk::FenceCreateFlagBits::eSignaled})); frame.present_done = fence; free_queue.push(&frame); } - CreatePostProcessPipeline(); + fsr_pass.Create(device, instance.GetAllocator(), num_images); + pp_pass.Create(device, swapchain.GetSurfaceFormat().format); ImGui::Layer::AddLayer(Common::Singleton::Instance()); } @@ -376,6 +192,7 @@ void Presenter::RecreateFrame(Frame* frame, u32 width, u32 height) { UNREACHABLE(); } frame->image = vk::Image{unsafe_image}; + SetObjectName(device, frame->image, "Frame image #{}", frame->id); const vk::ImageViewCreateInfo view_info = { .image = frame->image, @@ -389,9 +206,7 @@ void Presenter::RecreateFrame(Frame* frame, u32 width, u32 height) { .layerCount = 1, }, }; - auto [view_result, view] = device.createImageView(view_info); - ASSERT_MSG(view_result == vk::Result::eSuccess, "Failed to create frame image view: {}", - vk::to_string(view_result)); + auto view = Check<"create frame image view">(device.createImageView(view_info)); frame->image_view = view; frame->width = width; frame->height = height; @@ -455,127 +270,19 @@ Frame* Presenter::PrepareLastFrame() { return frame; } -bool Presenter::ShowSplash(Frame* frame /*= nullptr*/) { - const auto* splash = Common::Singleton::Instance(); - if (splash->GetImageData().empty()) { - return false; - } - - if (!Libraries::SystemService::IsSplashVisible()) { - return false; - } - - draw_scheduler.EndRendering(); - const auto cmdbuf = draw_scheduler.CommandBuffer(); - - if (Config::getVkHostMarkersEnabled()) { - cmdbuf.beginDebugUtilsLabelEXT(vk::DebugUtilsLabelEXT{ - .pLabelName = "ShowSplash", - }); - } - - if (!frame) { - if (!splash_img.has_value()) { - VideoCore::ImageInfo info{}; - info.pixel_format = vk::Format::eR8G8B8A8Unorm; - info.type = vk::ImageType::e2D; - info.size = - VideoCore::Extent3D{splash->GetImageInfo().width, splash->GetImageInfo().height, 1}; - info.pitch = splash->GetImageInfo().width; - info.guest_address = VAddr(splash->GetImageData().data()); - info.guest_size = splash->GetImageData().size(); - info.mips_layout.emplace_back(splash->GetImageData().size(), - splash->GetImageInfo().width, - splash->GetImageInfo().height, 0); - splash_img.emplace(instance, present_scheduler, info); - splash_img->flags &= ~VideoCore::GpuDirty; - texture_cache.RefreshImage(*splash_img); - - splash_img->Transit(vk::ImageLayout::eTransferSrcOptimal, - vk::AccessFlagBits2::eTransferRead, {}, cmdbuf); - } - - frame = GetRenderFrame(); - } - - const auto frame_subresources = vk::ImageSubresourceRange{ - .aspectMask = vk::ImageAspectFlagBits::eColor, - .baseMipLevel = 0, - .levelCount = 1, - .baseArrayLayer = 0, - .layerCount = VK_REMAINING_ARRAY_LAYERS, - }; - - const auto pre_barrier = - vk::ImageMemoryBarrier2{.srcStageMask = vk::PipelineStageFlagBits2::eTransfer, - .srcAccessMask = vk::AccessFlagBits2::eTransferRead, - .dstStageMask = vk::PipelineStageFlagBits2::eTransfer, - .dstAccessMask = vk::AccessFlagBits2::eTransferWrite, - .oldLayout = vk::ImageLayout::eUndefined, - .newLayout = vk::ImageLayout::eTransferDstOptimal, - .image = frame->image, - .subresourceRange{frame_subresources}}; - - cmdbuf.pipelineBarrier2(vk::DependencyInfo{ - .imageMemoryBarrierCount = 1, - .pImageMemoryBarriers = &pre_barrier, - }); - - cmdbuf.blitImage(splash_img->image, vk::ImageLayout::eTransferSrcOptimal, frame->image, - vk::ImageLayout::eTransferDstOptimal, - MakeImageBlitFit(splash->GetImageInfo().width, splash->GetImageInfo().height, - frame->width, frame->height), - vk::Filter::eLinear); - - const auto post_barrier = - vk::ImageMemoryBarrier2{.srcStageMask = vk::PipelineStageFlagBits2::eTransfer, - .srcAccessMask = vk::AccessFlagBits2::eTransferWrite, - .dstStageMask = vk::PipelineStageFlagBits2::eColorAttachmentOutput, - .dstAccessMask = vk::AccessFlagBits2::eColorAttachmentWrite, - .oldLayout = vk::ImageLayout::eTransferDstOptimal, - .newLayout = vk::ImageLayout::eGeneral, - .image = frame->image, - .subresourceRange{frame_subresources}}; - - cmdbuf.pipelineBarrier2(vk::DependencyInfo{ - .imageMemoryBarrierCount = 1, - .pImageMemoryBarriers = &post_barrier, - }); - - if (Config::getVkHostMarkersEnabled()) { - cmdbuf.endDebugUtilsLabelEXT(); - } - - // Flush frame creation commands. - frame->ready_semaphore = draw_scheduler.GetMasterSemaphore()->Handle(); - frame->ready_tick = draw_scheduler.CurrentTick(); - SubmitInfo info{}; - draw_scheduler.Flush(info); - - Present(frame); - return true; -} - Frame* Presenter::PrepareFrameInternal(VideoCore::ImageId image_id, bool is_eop) { // Request a free presentation frame. Frame* frame = GetRenderFrame(); - if (image_id != VideoCore::NULL_IMAGE_ID) { - const auto& image = texture_cache.GetImage(image_id); - const auto extent = image.info.size; - if (frame->width != extent.width || frame->height != extent.height || - frame->is_hdr != swapchain.GetHDR()) { - RecreateFrame(frame, extent.width, extent.height); - } - } - // EOP flips are triggered from GPU thread so use the drawing scheduler to record // commands. Otherwise we are dealing with a CPU flip which could have arrived // from any guest thread. Use a separate scheduler for that. auto& scheduler = is_eop ? draw_scheduler : flip_scheduler; scheduler.EndRendering(); const auto cmdbuf = scheduler.CommandBuffer(); - if (Config::getVkHostMarkersEnabled()) { + + bool vk_host_markers_enabled = Config::getVkHostMarkersEnabled(); + if (vk_host_markers_enabled) { const auto label = fmt::format("PrepareFrameInternal:{}", image_id.index); cmdbuf.beginDebugUtilsLabelEXT(vk::DebugUtilsLabelEXT{ .pLabelName = label.c_str(), @@ -605,33 +312,17 @@ Frame* Presenter::PrepareFrameInternal(VideoCore::ImageId image_id, bool is_eop) .pImageMemoryBarriers = &pre_barrier, }); - const std::array attachments = {vk::RenderingAttachmentInfo{ - .imageView = frame->image_view, - .imageLayout = vk::ImageLayout::eColorAttachmentOptimal, - .loadOp = vk::AttachmentLoadOp::eClear, - .storeOp = vk::AttachmentStoreOp::eStore, - }}; - const vk::RenderingInfo rendering_info{ - .renderArea = - vk::Rect2D{ - .offset = {0, 0}, - .extent = {frame->width, frame->height}, - }, - .layerCount = 1, - .colorAttachmentCount = attachments.size(), - .pColorAttachments = attachments.data(), - }; - if (image_id != VideoCore::NULL_IMAGE_ID) { auto& image = texture_cache.GetImage(image_id); + vk::Extent2D image_size = {image.info.size.width, image.info.size.height}; + float ratio = (float)image_size.width / (float)image_size.height; + if (ratio != expected_ratio) { + expected_ratio = ratio; + } + image.Transit(vk::ImageLayout::eShaderReadOnlyOptimal, vk::AccessFlagBits2::eShaderRead, {}, cmdbuf); - static vk::DescriptorImageInfo image_info{ - .sampler = *pp_sampler, - .imageLayout = vk::ImageLayout::eShaderReadOnlyOptimal, - }; - VideoCore::ImageViewInfo info{}; info.format = image.info.pixel_format; // Exclude alpha from output frame to avoid blending with UI. @@ -641,52 +332,53 @@ Frame* Presenter::PrepareFrameInternal(VideoCore::ImageId image_id, bool is_eop) .b = vk::ComponentSwizzle::eIdentity, .a = vk::ComponentSwizzle::eOne, }; + vk::ImageView imageView; if (auto view = image.FindView(info)) { - image_info.imageView = *texture_cache.GetImageView(view).image_view; + imageView = *texture_cache.GetImageView(view).image_view; } else { - image_info.imageView = *texture_cache.RegisterImageView(image_id, info).image_view; + imageView = *texture_cache.RegisterImageView(image_id, info).image_view; } - static const std::array set_writes{ - vk::WriteDescriptorSet{ - .dstSet = VK_NULL_HANDLE, - .dstBinding = 0, - .dstArrayElement = 0, - .descriptorCount = 1, - .descriptorType = vk::DescriptorType::eCombinedImageSampler, - .pImageInfo = &image_info, - }, - }; + if (vk_host_markers_enabled) { + cmdbuf.beginDebugUtilsLabelEXT(vk::DebugUtilsLabelEXT{ + .pLabelName = "Host/FSR", + }); + } - cmdbuf.bindPipeline(vk::PipelineBindPoint::eGraphics, *pp_pipeline); + imageView = fsr_pass.Render(cmdbuf, imageView, image_size, {frame->width, frame->height}, + fsr_settings, frame->is_hdr); - const auto& dst_rect = - FitImage(image.info.size.width, image.info.size.height, frame->width, frame->height); + if (vk_host_markers_enabled) { + cmdbuf.endDebugUtilsLabelEXT(); + cmdbuf.beginDebugUtilsLabelEXT(vk::DebugUtilsLabelEXT{ + .pLabelName = "Host/Post processing", + }); + } + pp_pass.Render(cmdbuf, imageView, image_size, *frame, pp_settings); + if (vk_host_markers_enabled) { + cmdbuf.endDebugUtilsLabelEXT(); + } - const std::array viewports = { - vk::Viewport{ - .x = 1.0f * dst_rect.offset.x, - .y = 1.0f * dst_rect.offset.y, - .width = 1.0f * dst_rect.extent.width, - .height = 1.0f * dst_rect.extent.height, - .minDepth = 0.0f, - .maxDepth = 1.0f, - }, - }; - - cmdbuf.setViewport(0, viewports); - cmdbuf.setScissor(0, {dst_rect}); - - cmdbuf.pushDescriptorSetKHR(vk::PipelineBindPoint::eGraphics, *pp_pipeline_layout, 0, - set_writes); - cmdbuf.pushConstants(*pp_pipeline_layout, vk::ShaderStageFlagBits::eFragment, 0, - sizeof(PostProcessSettings), &pp_settings); - - cmdbuf.beginRendering(rendering_info); - cmdbuf.draw(3, 1, 0, 0); - cmdbuf.endRendering(); + DebugState.game_resolution = {image_size.width, image_size.height}; + DebugState.output_resolution = {frame->width, frame->height}; } else { // Fix display of garbage images on startup on some drivers + const std::array attachments = {{ + { + .imageView = frame->image_view, + .imageLayout = vk::ImageLayout::eColorAttachmentOptimal, + .loadOp = vk::AttachmentLoadOp::eClear, + .storeOp = vk::AttachmentStoreOp::eStore, + }, + }}; + const vk::RenderingInfo rendering_info{ + .renderArea{ + .extent{frame->width, frame->height}, + }, + .layerCount = 1, + .colorAttachmentCount = attachments.size(), + .pColorAttachments = attachments.data(), + }; cmdbuf.beginRendering(rendering_info); cmdbuf.endRendering(); } @@ -706,7 +398,7 @@ Frame* Presenter::PrepareFrameInternal(VideoCore::ImageId image_id, bool is_eop) .pImageMemoryBarriers = &post_barrier, }); - if (Config::getVkHostMarkersEnabled()) { + if (vk_host_markers_enabled) { cmdbuf.endDebugUtilsLabelEXT(); } @@ -833,17 +525,43 @@ void Presenter::Present(Frame* frame, bool is_reusing_frame) { ImGui::SetNextWindowDockID(dockId, ImGuiCond_Once); ImGui::Begin("Display##game_display", nullptr, ImGuiWindowFlags_NoNav); + auto game_texture = frame->imgui_texture; + auto game_width = frame->width; + auto game_height = frame->height; + + if (Libraries::SystemService::IsSplashVisible()) { // draw splash + if (!splash_img.has_value()) { + splash_img.emplace(); + auto splash_path = Common::ElfInfo::Instance().GetSplashPath(); + if (!splash_path.empty()) { + splash_img = ImGui::RefCountedTexture::DecodePngFile(splash_path); + } + } + if (auto& splash_image = this->splash_img.value()) { + auto [im_id, width, height] = splash_image.GetTexture(); + game_texture = im_id; + game_width = width; + game_height = height; + } + } + ImVec2 contentArea = ImGui::GetContentRegionAvail(); - const vk::Rect2D imgRect = - FitImage(frame->width, frame->height, (s32)contentArea.x, (s32)contentArea.y); - ImGui::SetCursorPos(ImGui::GetCursorStartPos() + ImVec2{ - (float)imgRect.offset.x, - (float)imgRect.offset.y, - }); - ImGui::Image(frame->imgui_texture, { - static_cast(imgRect.extent.width), - static_cast(imgRect.extent.height), - }); + SetExpectedGameSize((s32)contentArea.x, (s32)contentArea.y); + + const auto imgRect = + FitImage(game_width, game_height, (s32)contentArea.x, (s32)contentArea.y); + ImVec2 offset{ + static_cast(imgRect.offset.x), + static_cast(imgRect.offset.y), + }; + ImVec2 size{ + static_cast(imgRect.extent.width), + static_cast(imgRect.extent.height), + }; + + ImGui::SetCursorPos(ImGui::GetCursorStartPos() + offset); + ImGui::Image(game_texture, size); + ImGui::End(); ImGui::PopStyleVar(3); ImGui::PopStyleColor(); @@ -914,12 +632,24 @@ Frame* Presenter::GetRenderFrame() { } } - // Initialize default frame image - if (frame->width == 0 || frame->height == 0 || frame->is_hdr != swapchain.GetHDR()) { - RecreateFrame(frame, Config::getScreenWidth(), Config::getScreenHeight()); + if (frame->width != expected_frame_width || frame->height != expected_frame_height || + frame->is_hdr != swapchain.GetHDR()) { + RecreateFrame(frame, expected_frame_width, expected_frame_height); } return frame; } +void Presenter::SetExpectedGameSize(s32 width, s32 height) { + const float ratio = (float)width / (float)height; + + expected_frame_height = height; + expected_frame_width = width; + if (ratio > expected_ratio) { + expected_frame_width = static_cast(height * expected_ratio); + } else { + expected_frame_height = static_cast(width / expected_ratio); + } +} + } // namespace Vulkan diff --git a/src/video_core/renderer_vulkan/vk_presenter.h b/src/video_core/renderer_vulkan/vk_presenter.h index 2bfe6e66c..ad2708474 100644 --- a/src/video_core/renderer_vulkan/vk_presenter.h +++ b/src/video_core/renderer_vulkan/vk_presenter.h @@ -6,7 +6,10 @@ #include #include "imgui/imgui_config.h" +#include "imgui/imgui_texture.h" #include "video_core/amdgpu/liverpool.h" +#include "video_core/renderer_vulkan/host_passes/fsr_pass.h" +#include "video_core/renderer_vulkan/host_passes/pp_pass.h" #include "video_core/renderer_vulkan/vk_instance.h" #include "video_core/renderer_vulkan/vk_scheduler.h" #include "video_core/renderer_vulkan/vk_swapchain.h" @@ -32,6 +35,7 @@ struct Frame { vk::Semaphore ready_semaphore; u64 ready_tick; bool is_hdr{false}; + u8 id{}; ImTextureID imgui_texture; }; @@ -45,17 +49,16 @@ enum SchedulerType { class Rasterizer; class Presenter { - struct PostProcessSettings { - float gamma = 1.0f; - u32 hdr = 0; - }; - public: Presenter(Frontend::WindowSDL& window, AmdGpu::Liverpool* liverpool); ~Presenter(); - float& GetGammaRef() { - return pp_settings.gamma; + HostPasses::PostProcessingPass::Settings& GetPPSettingsRef() { + return pp_settings; + } + + HostPasses::FsrPass::Settings& GetFsrSettingsRef() { + return fsr_settings; } Frontend::WindowSDL& GetWindow() const { @@ -90,7 +93,6 @@ public: }) != vo_buffers_addr.cend(); } - bool ShowSplash(Frame* frame = nullptr); void Present(Frame* frame, bool is_reusing_frame = false); void RecreateFrame(Frame* frame, u32 width, u32 height); Frame* PrepareLastFrame(); @@ -117,16 +119,20 @@ public: } private: - void CreatePostProcessPipeline(); Frame* PrepareFrameInternal(VideoCore::ImageId image_id, bool is_eop = true); Frame* GetRenderFrame(); + void SetExpectedGameSize(s32 width, s32 height); + private: - PostProcessSettings pp_settings{}; - vk::UniquePipeline pp_pipeline{}; - vk::UniquePipelineLayout pp_pipeline_layout{}; - vk::UniqueDescriptorSetLayout pp_desc_set_layout{}; - vk::UniqueSampler pp_sampler{}; + float expected_ratio{1920.0 / 1080.0f}; + u32 expected_frame_width{1920}; + u32 expected_frame_height{1080}; + + HostPasses::FsrPass fsr_pass; + HostPasses::FsrPass::Settings fsr_settings{}; + HostPasses::PostProcessingPass::Settings pp_settings{}; + HostPasses::PostProcessingPass pp_pass; Frontend::WindowSDL& window; AmdGpu::Liverpool* liverpool; Instance instance; @@ -143,7 +149,7 @@ private: std::mutex free_mutex; std::condition_variable free_cv; std::condition_variable_any frame_cv; - std::optional splash_img; + std::optional splash_img; std::vector vo_buffers_addr; }; diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 87d07a967..4caa781b9 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -696,14 +696,19 @@ void Rasterizer::BindTextures(const Shader::Info& stage, Shader::Backend::Bindin void Rasterizer::BeginRendering(const GraphicsPipeline& pipeline, RenderState& state) { int cb_index = 0; - for (auto& [image_id, desc] : cb_descs) { + for (auto attach_idx = 0u; attach_idx < state.num_color_attachments; ++attach_idx) { + if (state.color_attachments[attach_idx].imageView == VK_NULL_HANDLE) { + continue; + } + + auto& [image_id, desc] = cb_descs[cb_index++]; if (auto& old_img = texture_cache.GetImage(image_id); old_img.binding.needs_rebind) { auto& view = texture_cache.FindRenderTarget(desc); ASSERT(view.image_id != image_id); image_id = bound_images.emplace_back(view.image_id); auto& image = texture_cache.GetImage(view.image_id); - state.color_attachments[cb_index].imageView = *view.image_view; - state.color_attachments[cb_index].imageLayout = image.last_state.layout; + state.color_attachments[attach_idx].imageView = *view.image_view; + state.color_attachments[attach_idx].imageLayout = image.last_state.layout; const auto mip = view.info.range.base.level; state.width = std::min(state.width, std::max(image.info.size.width >> mip, 1u)); @@ -722,8 +727,7 @@ void Rasterizer::BeginRendering(const GraphicsPipeline& pipeline, RenderState& s desc.view_info.range); } image.usage.render_target = 1u; - state.color_attachments[cb_index].imageLayout = image.last_state.layout; - ++cb_index; + state.color_attachments[attach_idx].imageLayout = image.last_state.layout; } if (db_desc) { @@ -930,12 +934,17 @@ bool Rasterizer::IsMapped(VAddr addr, u64 size) { // There is no memory, so not mapped. return false; } - return mapped_ranges.find(boost::icl::interval::right_open(addr, addr + size)) != - mapped_ranges.end(); + const auto range = decltype(mapped_ranges)::interval_type::right_open(addr, addr + size); + + std::shared_lock lock{mapped_ranges_mutex}; + return boost::icl::contains(mapped_ranges, range); } void Rasterizer::MapMemory(VAddr addr, u64 size) { - mapped_ranges += boost::icl::interval::right_open(addr, addr + size); + { + std::unique_lock lock{mapped_ranges_mutex}; + mapped_ranges += decltype(mapped_ranges)::interval_type::right_open(addr, addr + size); + } page_manager.OnGpuMap(addr, size); } @@ -943,85 +952,26 @@ void Rasterizer::UnmapMemory(VAddr addr, u64 size) { buffer_cache.InvalidateMemory(addr, size); texture_cache.UnmapMemory(addr, size); page_manager.OnGpuUnmap(addr, size); - mapped_ranges -= boost::icl::interval::right_open(addr, addr + size); -} - -void Rasterizer::UpdateDynamicState(const GraphicsPipeline& pipeline) { - UpdateViewportScissorState(pipeline); - - auto& regs = liverpool->regs; - const auto cmdbuf = scheduler.CommandBuffer(); - cmdbuf.setBlendConstants(®s.blend_constants.red); - - if (instance.IsDynamicColorWriteMaskSupported()) { - cmdbuf.setColorWriteMaskEXT(0, pipeline.GetWriteMasks()); - } - if (regs.depth_control.depth_bounds_enable) { - cmdbuf.setDepthBounds(regs.depth_bounds_min, regs.depth_bounds_max); - } - if (regs.polygon_control.enable_polygon_offset_front) { - cmdbuf.setDepthBias(regs.poly_offset.front_offset, regs.poly_offset.depth_bias, - regs.poly_offset.front_scale / 16.f); - } else if (regs.polygon_control.enable_polygon_offset_back) { - cmdbuf.setDepthBias(regs.poly_offset.back_offset, regs.poly_offset.depth_bias, - regs.poly_offset.back_scale / 16.f); - } - - if (regs.depth_control.stencil_enable) { - const auto front_fail_op = - LiverpoolToVK::StencilOp(regs.stencil_control.stencil_fail_front); - const auto front_pass_op = - LiverpoolToVK::StencilOp(regs.stencil_control.stencil_zpass_front); - const auto front_depth_fail_op = - LiverpoolToVK::StencilOp(regs.stencil_control.stencil_zfail_front); - const auto front_compare_op = LiverpoolToVK::CompareOp(regs.depth_control.stencil_ref_func); - if (regs.depth_control.backface_enable) { - const auto back_fail_op = - LiverpoolToVK::StencilOp(regs.stencil_control.stencil_fail_back); - const auto back_pass_op = - LiverpoolToVK::StencilOp(regs.stencil_control.stencil_zpass_back); - const auto back_depth_fail_op = - LiverpoolToVK::StencilOp(regs.stencil_control.stencil_zfail_back); - const auto back_compare_op = - LiverpoolToVK::CompareOp(regs.depth_control.stencil_bf_func); - cmdbuf.setStencilOpEXT(vk::StencilFaceFlagBits::eFront, front_fail_op, front_pass_op, - front_depth_fail_op, front_compare_op); - cmdbuf.setStencilOpEXT(vk::StencilFaceFlagBits::eBack, back_fail_op, back_pass_op, - back_depth_fail_op, back_compare_op); - } else { - cmdbuf.setStencilOpEXT(vk::StencilFaceFlagBits::eFrontAndBack, front_fail_op, - front_pass_op, front_depth_fail_op, front_compare_op); - } - - const auto front = regs.stencil_ref_front; - const auto back = regs.stencil_ref_back; - if (front.stencil_test_val == back.stencil_test_val) { - cmdbuf.setStencilReference(vk::StencilFaceFlagBits::eFrontAndBack, - front.stencil_test_val); - } else { - cmdbuf.setStencilReference(vk::StencilFaceFlagBits::eFront, front.stencil_test_val); - cmdbuf.setStencilReference(vk::StencilFaceFlagBits::eBack, back.stencil_test_val); - } - - if (front.stencil_write_mask == back.stencil_write_mask) { - cmdbuf.setStencilWriteMask(vk::StencilFaceFlagBits::eFrontAndBack, - front.stencil_write_mask); - } else { - cmdbuf.setStencilWriteMask(vk::StencilFaceFlagBits::eFront, front.stencil_write_mask); - cmdbuf.setStencilWriteMask(vk::StencilFaceFlagBits::eBack, back.stencil_write_mask); - } - - if (front.stencil_mask == back.stencil_mask) { - cmdbuf.setStencilCompareMask(vk::StencilFaceFlagBits::eFrontAndBack, - front.stencil_mask); - } else { - cmdbuf.setStencilCompareMask(vk::StencilFaceFlagBits::eFront, front.stencil_mask); - cmdbuf.setStencilCompareMask(vk::StencilFaceFlagBits::eBack, back.stencil_mask); - } + { + std::unique_lock lock{mapped_ranges_mutex}; + mapped_ranges -= decltype(mapped_ranges)::interval_type::right_open(addr, addr + size); } } -void Rasterizer::UpdateViewportScissorState(const GraphicsPipeline& pipeline) { +void Rasterizer::UpdateDynamicState(const GraphicsPipeline& pipeline) const { + UpdateViewportScissorState(); + UpdateDepthStencilState(); + UpdatePrimitiveState(); + + auto& dynamic_state = scheduler.GetDynamicState(); + dynamic_state.SetBlendConstants(&liverpool->regs.blend_constants.red); + dynamic_state.SetColorWriteMasks(pipeline.GetWriteMasks()); + + // Commit new dynamic state to the command buffer. + dynamic_state.Commit(instance, scheduler.CommandBuffer()); +} + +void Rasterizer::UpdateViewportScissorState() const { const auto& regs = liverpool->regs; const auto combined_scissor_value_tl = [](s16 scr, s16 win, s16 gen, s16 win_offset) { @@ -1053,16 +1003,13 @@ void Rasterizer::UpdateViewportScissorState(const GraphicsPipeline& pipeline) { boost::container::static_vector viewports; boost::container::static_vector scissors; - const auto& vp_ctl = regs.viewport_control; - const float reduce_z = - regs.clipper_control.clip_space == AmdGpu::Liverpool::ClipSpace::MinusWToW ? 1.0f : 0.0f; - if (regs.polygon_control.enable_window_offset && (regs.window_offset.window_x_offset != 0 || regs.window_offset.window_y_offset != 0)) { LOG_ERROR(Render_Vulkan, "PA_SU_SC_MODE_CNTL.VTX_WINDOW_OFFSET_ENABLE support is not yet implemented."); } + const auto& vp_ctl = regs.viewport_control; for (u32 i = 0; i < Liverpool::NumViewports; i++) { const auto& vp = regs.viewports[i]; const auto& vp_d = regs.viewport_depths[i]; @@ -1072,33 +1019,55 @@ void Rasterizer::UpdateViewportScissorState(const GraphicsPipeline& pipeline) { const auto zoffset = vp_ctl.zoffset_enable ? vp.zoffset : 0.f; const auto zscale = vp_ctl.zscale_enable ? vp.zscale : 1.f; - if (pipeline.IsClipDisabled()) { + + vk::Viewport viewport{}; + + // https://gitlab.freedesktop.org/mesa/mesa/-/blob/209a0ed/src/amd/vulkan/radv_pipeline_graphics.c#L688-689 + // https://gitlab.freedesktop.org/mesa/mesa/-/blob/209a0ed/src/amd/vulkan/radv_cmd_buffer.c#L3103-3109 + // When the clip space is ranged [-1...1], the zoffset is centered. + // By reversing the above viewport calculations, we get the following: + if (regs.clipper_control.clip_space == AmdGpu::Liverpool::ClipSpace::MinusWToW) { + viewport.minDepth = zoffset - zscale; + viewport.maxDepth = zoffset + zscale; + } else { + viewport.minDepth = zoffset; + viewport.maxDepth = zoffset + zscale; + } + + if (!regs.depth_render_override.disable_viewport_clamp) { + // Apply depth clamp. + viewport.minDepth = std::max(viewport.minDepth, vp_d.zmin); + viewport.maxDepth = std::min(viewport.maxDepth, vp_d.zmax); + } + + if (!instance.IsDepthRangeUnrestrictedSupported()) { + // Unrestricted depth range not supported by device. Restrict to valid range. + viewport.minDepth = std::max(viewport.minDepth, 0.f); + viewport.maxDepth = std::min(viewport.maxDepth, 1.f); + } + + if (regs.IsClipDisabled()) { // In case if clipping is disabled we patch the shader to convert vertex position // from screen space coordinates to NDC by defining a render space as full hardware // window range [0..16383, 0..16383] and setting the viewport to its size. - viewports.push_back({ - .x = 0.f, - .y = 0.f, - .width = float(std::min(instance.GetMaxViewportWidth(), 16_KB)), - .height = float(std::min(instance.GetMaxViewportHeight(), 16_KB)), - .minDepth = zoffset - zscale * reduce_z, - .maxDepth = zscale + zoffset, - }); + viewport.x = 0.f; + viewport.y = 0.f; + viewport.width = float(std::min(instance.GetMaxViewportWidth(), 16_KB)); + viewport.height = float(std::min(instance.GetMaxViewportHeight(), 16_KB)); } else { const auto xoffset = vp_ctl.xoffset_enable ? vp.xoffset : 0.f; const auto xscale = vp_ctl.xscale_enable ? vp.xscale : 1.f; const auto yoffset = vp_ctl.yoffset_enable ? vp.yoffset : 0.f; const auto yscale = vp_ctl.yscale_enable ? vp.yscale : 1.f; - viewports.push_back({ - .x = xoffset - xscale, - .y = yoffset - yscale, - .width = xscale * 2.0f, - .height = yscale * 2.0f, - .minDepth = zoffset - zscale * reduce_z, - .maxDepth = zscale + zoffset, - }); + + viewport.x = xoffset - xscale; + viewport.y = yoffset - yscale; + viewport.width = xscale * 2.0f; + viewport.height = yscale * 2.0f; } + viewports.push_back(viewport); + auto vp_scsr = scsr; if (regs.mode_control.vport_scissor_enable) { vp_scsr.top_left_x = @@ -1134,9 +1103,84 @@ void Rasterizer::UpdateViewportScissorState(const GraphicsPipeline& pipeline) { scissors.push_back(empty_scissor); } - const auto cmdbuf = scheduler.CommandBuffer(); - cmdbuf.setViewportWithCountEXT(viewports); - cmdbuf.setScissorWithCountEXT(scissors); + auto& dynamic_state = scheduler.GetDynamicState(); + dynamic_state.SetViewports(viewports); + dynamic_state.SetScissors(scissors); +} + +void Rasterizer::UpdateDepthStencilState() const { + const auto& regs = liverpool->regs; + auto& dynamic_state = scheduler.GetDynamicState(); + + const auto depth_test_enabled = + regs.depth_control.depth_enable && regs.depth_buffer.DepthValid(); + dynamic_state.SetDepthTestEnabled(depth_test_enabled); + if (depth_test_enabled) { + dynamic_state.SetDepthWriteEnabled(regs.depth_control.depth_write_enable && + !regs.depth_render_control.depth_clear_enable); + dynamic_state.SetDepthCompareOp(LiverpoolToVK::CompareOp(regs.depth_control.depth_func)); + } + + const auto depth_bounds_test_enabled = regs.depth_control.depth_bounds_enable; + dynamic_state.SetDepthBoundsTestEnabled(depth_bounds_test_enabled); + if (depth_bounds_test_enabled) { + dynamic_state.SetDepthBounds(regs.depth_bounds_min, regs.depth_bounds_max); + } + + const auto depth_bias_enabled = regs.polygon_control.NeedsBias(); + dynamic_state.SetDepthBiasEnabled(depth_bias_enabled); + if (depth_bias_enabled) { + const bool front = regs.polygon_control.enable_polygon_offset_front; + dynamic_state.SetDepthBias( + front ? regs.poly_offset.front_offset : regs.poly_offset.back_offset, + regs.poly_offset.depth_bias, + (front ? regs.poly_offset.front_scale : regs.poly_offset.back_scale) / 16.f); + } + + const auto stencil_test_enabled = + regs.depth_control.stencil_enable && regs.depth_buffer.StencilValid(); + dynamic_state.SetStencilTestEnabled(stencil_test_enabled); + if (stencil_test_enabled) { + const StencilOps front_ops{ + .fail_op = LiverpoolToVK::StencilOp(regs.stencil_control.stencil_fail_front), + .pass_op = LiverpoolToVK::StencilOp(regs.stencil_control.stencil_zpass_front), + .depth_fail_op = LiverpoolToVK::StencilOp(regs.stencil_control.stencil_zfail_front), + .compare_op = LiverpoolToVK::CompareOp(regs.depth_control.stencil_ref_func), + }; + const StencilOps back_ops = regs.depth_control.backface_enable ? StencilOps{ + .fail_op = LiverpoolToVK::StencilOp(regs.stencil_control.stencil_fail_back), + .pass_op = LiverpoolToVK::StencilOp(regs.stencil_control.stencil_zpass_back), + .depth_fail_op = LiverpoolToVK::StencilOp(regs.stencil_control.stencil_zfail_back), + .compare_op = LiverpoolToVK::CompareOp(regs.depth_control.stencil_bf_func), + } : front_ops; + dynamic_state.SetStencilOps(front_ops, back_ops); + + const auto front = regs.stencil_ref_front; + const auto back = + regs.depth_control.backface_enable ? regs.stencil_ref_back : regs.stencil_ref_front; + dynamic_state.SetStencilReferences(front.stencil_test_val, back.stencil_test_val); + dynamic_state.SetStencilWriteMasks(front.stencil_write_mask, back.stencil_write_mask); + dynamic_state.SetStencilCompareMasks(front.stencil_mask, back.stencil_mask); + } +} + +void Rasterizer::UpdatePrimitiveState() const { + const auto& regs = liverpool->regs; + auto& dynamic_state = scheduler.GetDynamicState(); + + const auto prim_restart = (regs.enable_primitive_restart & 1) != 0; + ASSERT_MSG(!prim_restart || regs.primitive_restart_index == 0xFFFF || + regs.primitive_restart_index == 0xFFFFFFFF, + "Primitive restart index other than -1 is not supported yet"); + + const auto cull_mode = LiverpoolToVK::IsPrimitiveCulled(regs.primitive_type) + ? LiverpoolToVK::CullMode(regs.polygon_control.CullingMode()) + : vk::CullModeFlagBits::eNone; + const auto front_face = LiverpoolToVK::FrontFace(regs.polygon_control.front_face); + + dynamic_state.SetPrimitiveRestartEnabled(prim_restart); + dynamic_state.SetCullMode(cull_mode); + dynamic_state.SetFrontFace(front_face); } void Rasterizer::ScopeMarkerBegin(const std::string_view& str, bool from_guest) { diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.h b/src/video_core/renderer_vulkan/vk_rasterizer.h index 2fac8c8da..4e0ed0996 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.h +++ b/src/video_core/renderer_vulkan/vk_rasterizer.h @@ -3,6 +3,8 @@ #pragma once +#include + #include "video_core/buffer_cache/buffer_cache.h" #include "video_core/page_manager.h" #include "video_core/renderer_vulkan/vk_pipeline_cache.h" @@ -75,8 +77,10 @@ private: void DepthStencilCopy(bool is_depth, bool is_stencil); void EliminateFastClear(); - void UpdateDynamicState(const GraphicsPipeline& pipeline); - void UpdateViewportScissorState(const GraphicsPipeline& pipeline); + void UpdateDynamicState(const GraphicsPipeline& pipeline) const; + void UpdateViewportScissorState() const; + void UpdateDepthStencilState() const; + void UpdatePrimitiveState() const; bool FilterDraw(); @@ -104,6 +108,7 @@ private: AmdGpu::Liverpool* liverpool; Core::MemoryManager* memory; boost::icl::interval_set mapped_ranges; + std::shared_mutex mapped_ranges_mutex; PipelineCache pipeline_cache; boost::container::static_vector< diff --git a/src/video_core/renderer_vulkan/vk_scheduler.cpp b/src/video_core/renderer_vulkan/vk_scheduler.cpp index fd84c54ed..8d4188a22 100644 --- a/src/video_core/renderer_vulkan/vk_scheduler.cpp +++ b/src/video_core/renderer_vulkan/vk_scheduler.cpp @@ -97,6 +97,9 @@ void Scheduler::AllocateWorkerCommandBuffers() { ASSERT_MSG(begin_result == vk::Result::eSuccess, "Failed to begin command buffer: {}", vk::to_string(begin_result)); + // Invalidate dynamic state so it gets applied to the new command buffer. + dynamic_state.Invalidate(); + #if TRACY_GPU_ENABLED auto* profiler_ctx = instance.GetProfilerContext(); if (profiler_ctx) { @@ -164,4 +167,151 @@ void Scheduler::SubmitExecution(SubmitInfo& info) { } } +void DynamicState::Commit(const Instance& instance, const vk::CommandBuffer& cmdbuf) { + if (dirty_state.viewports) { + dirty_state.viewports = false; + cmdbuf.setViewportWithCount(viewports); + } + if (dirty_state.scissors) { + dirty_state.scissors = false; + cmdbuf.setScissorWithCount(scissors); + } + if (dirty_state.depth_test_enabled) { + dirty_state.depth_test_enabled = false; + cmdbuf.setDepthTestEnable(depth_test_enabled); + } + if (dirty_state.depth_write_enabled) { + dirty_state.depth_write_enabled = false; + // Note that this must be set in a command buffer even if depth test is disabled. + cmdbuf.setDepthWriteEnable(depth_write_enabled); + } + if (depth_test_enabled && dirty_state.depth_compare_op) { + dirty_state.depth_compare_op = false; + cmdbuf.setDepthCompareOp(depth_compare_op); + } + if (dirty_state.depth_bounds_test_enabled) { + dirty_state.depth_bounds_test_enabled = false; + if (instance.IsDepthBoundsSupported()) { + cmdbuf.setDepthBoundsTestEnable(depth_bounds_test_enabled); + } + } + if (depth_bounds_test_enabled && dirty_state.depth_bounds) { + dirty_state.depth_bounds = false; + if (instance.IsDepthBoundsSupported()) { + cmdbuf.setDepthBounds(depth_bounds_min, depth_bounds_max); + } + } + if (dirty_state.depth_bias_enabled) { + dirty_state.depth_bias_enabled = false; + cmdbuf.setDepthBiasEnable(depth_bias_enabled); + } + if (depth_bias_enabled && dirty_state.depth_bias) { + dirty_state.depth_bias = false; + cmdbuf.setDepthBias(depth_bias_constant, depth_bias_clamp, depth_bias_slope); + } + if (dirty_state.stencil_test_enabled) { + dirty_state.stencil_test_enabled = false; + cmdbuf.setStencilTestEnable(stencil_test_enabled); + } + if (stencil_test_enabled) { + if (dirty_state.stencil_front_ops && dirty_state.stencil_back_ops && + stencil_front_ops == stencil_back_ops) { + dirty_state.stencil_front_ops = false; + dirty_state.stencil_back_ops = false; + cmdbuf.setStencilOp(vk::StencilFaceFlagBits::eFrontAndBack, stencil_front_ops.fail_op, + stencil_front_ops.pass_op, stencil_front_ops.depth_fail_op, + stencil_front_ops.compare_op); + } else { + if (dirty_state.stencil_front_ops) { + dirty_state.stencil_front_ops = false; + cmdbuf.setStencilOp(vk::StencilFaceFlagBits::eFront, stencil_front_ops.fail_op, + stencil_front_ops.pass_op, stencil_front_ops.depth_fail_op, + stencil_front_ops.compare_op); + } + if (dirty_state.stencil_back_ops) { + dirty_state.stencil_back_ops = false; + cmdbuf.setStencilOp(vk::StencilFaceFlagBits::eBack, stencil_back_ops.fail_op, + stencil_back_ops.pass_op, stencil_back_ops.depth_fail_op, + stencil_back_ops.compare_op); + } + } + if (dirty_state.stencil_front_reference && dirty_state.stencil_back_reference && + stencil_front_reference == stencil_back_reference) { + dirty_state.stencil_front_reference = false; + dirty_state.stencil_back_reference = false; + cmdbuf.setStencilReference(vk::StencilFaceFlagBits::eFrontAndBack, + stencil_front_reference); + } else { + if (dirty_state.stencil_front_reference) { + dirty_state.stencil_front_reference = false; + cmdbuf.setStencilReference(vk::StencilFaceFlagBits::eFront, + stencil_front_reference); + } + if (dirty_state.stencil_back_reference) { + dirty_state.stencil_back_reference = false; + cmdbuf.setStencilReference(vk::StencilFaceFlagBits::eBack, stencil_back_reference); + } + } + if (dirty_state.stencil_front_write_mask && dirty_state.stencil_back_write_mask && + stencil_front_write_mask == stencil_back_write_mask) { + dirty_state.stencil_front_write_mask = false; + dirty_state.stencil_back_write_mask = false; + cmdbuf.setStencilWriteMask(vk::StencilFaceFlagBits::eFrontAndBack, + stencil_front_write_mask); + } else { + if (dirty_state.stencil_front_write_mask) { + dirty_state.stencil_front_write_mask = false; + cmdbuf.setStencilWriteMask(vk::StencilFaceFlagBits::eFront, + stencil_front_write_mask); + } + if (dirty_state.stencil_back_write_mask) { + dirty_state.stencil_back_write_mask = false; + cmdbuf.setStencilWriteMask(vk::StencilFaceFlagBits::eBack, stencil_back_write_mask); + } + } + if (dirty_state.stencil_front_compare_mask && dirty_state.stencil_back_compare_mask && + stencil_front_compare_mask == stencil_back_compare_mask) { + dirty_state.stencil_front_compare_mask = false; + dirty_state.stencil_back_compare_mask = false; + cmdbuf.setStencilCompareMask(vk::StencilFaceFlagBits::eFrontAndBack, + stencil_front_compare_mask); + } else { + if (dirty_state.stencil_front_compare_mask) { + dirty_state.stencil_front_compare_mask = false; + cmdbuf.setStencilCompareMask(vk::StencilFaceFlagBits::eFront, + stencil_front_compare_mask); + } + if (dirty_state.stencil_back_compare_mask) { + dirty_state.stencil_back_compare_mask = false; + cmdbuf.setStencilCompareMask(vk::StencilFaceFlagBits::eBack, + stencil_back_compare_mask); + } + } + } + if (dirty_state.primitive_restart_enable) { + dirty_state.primitive_restart_enable = false; + if (instance.IsPrimitiveRestartDisableSupported()) { + cmdbuf.setPrimitiveRestartEnable(primitive_restart_enable); + } + } + if (dirty_state.cull_mode) { + dirty_state.cull_mode = false; + cmdbuf.setCullMode(cull_mode); + } + if (dirty_state.front_face) { + dirty_state.front_face = false; + cmdbuf.setFrontFace(front_face); + } + if (dirty_state.blend_constants) { + dirty_state.blend_constants = false; + cmdbuf.setBlendConstants(blend_constants); + } + if (dirty_state.color_write_masks) { + dirty_state.color_write_masks = false; + if (instance.IsDynamicColorWriteMaskSupported()) { + cmdbuf.setColorWriteMaskEXT(0, color_write_masks); + } + } +} + } // namespace Vulkan diff --git a/src/video_core/renderer_vulkan/vk_scheduler.h b/src/video_core/renderer_vulkan/vk_scheduler.h index fd5e68373..7709e1d41 100644 --- a/src/video_core/renderer_vulkan/vk_scheduler.h +++ b/src/video_core/renderer_vulkan/vk_scheduler.h @@ -7,6 +7,7 @@ #include #include "common/types.h" #include "common/unique_function.h" +#include "video_core/amdgpu/liverpool.h" #include "video_core/renderer_vulkan/vk_master_semaphore.h" #include "video_core/renderer_vulkan/vk_resource_pool.h" @@ -55,6 +56,248 @@ struct SubmitInfo { } }; +using Viewports = boost::container::static_vector; +using Scissors = boost::container::static_vector; +using ColorWriteMasks = std::array; +struct StencilOps { + vk::StencilOp fail_op{}; + vk::StencilOp pass_op{}; + vk::StencilOp depth_fail_op{}; + vk::CompareOp compare_op{}; + + bool operator==(const StencilOps& other) const { + return fail_op == other.fail_op && pass_op == other.pass_op && + depth_fail_op == other.depth_fail_op && compare_op == other.compare_op; + } +}; +struct DynamicState { + struct { + bool viewports : 1; + bool scissors : 1; + + bool depth_test_enabled : 1; + bool depth_write_enabled : 1; + bool depth_compare_op : 1; + + bool depth_bounds_test_enabled : 1; + bool depth_bounds : 1; + + bool depth_bias_enabled : 1; + bool depth_bias : 1; + + bool stencil_test_enabled : 1; + bool stencil_front_ops : 1; + bool stencil_front_reference : 1; + bool stencil_front_write_mask : 1; + bool stencil_front_compare_mask : 1; + bool stencil_back_ops : 1; + bool stencil_back_reference : 1; + bool stencil_back_write_mask : 1; + bool stencil_back_compare_mask : 1; + + bool primitive_restart_enable : 1; + bool cull_mode : 1; + bool front_face : 1; + + bool blend_constants : 1; + bool color_write_masks : 1; + } dirty_state{}; + + Viewports viewports{}; + Scissors scissors{}; + + bool depth_test_enabled{}; + bool depth_write_enabled{}; + vk::CompareOp depth_compare_op{}; + + bool depth_bounds_test_enabled{}; + float depth_bounds_min{}; + float depth_bounds_max{}; + + bool depth_bias_enabled{}; + float depth_bias_constant{}; + float depth_bias_clamp{}; + float depth_bias_slope{}; + + bool stencil_test_enabled{}; + StencilOps stencil_front_ops{}; + u32 stencil_front_reference{}; + u32 stencil_front_write_mask{}; + u32 stencil_front_compare_mask{}; + StencilOps stencil_back_ops{}; + u32 stencil_back_reference{}; + u32 stencil_back_write_mask{}; + u32 stencil_back_compare_mask{}; + + bool primitive_restart_enable{}; + vk::CullModeFlags cull_mode{}; + vk::FrontFace front_face{}; + + float blend_constants[4]{}; + ColorWriteMasks color_write_masks{}; + + /// Commits the dynamic state to the provided command buffer. + void Commit(const Instance& instance, const vk::CommandBuffer& cmdbuf); + + /// Invalidates all dynamic state to be flushed into the next command buffer. + void Invalidate() { + std::memset(&dirty_state, 0xFF, sizeof(dirty_state)); + } + + void SetViewports(const Viewports& viewports_) { + if (!std::ranges::equal(viewports, viewports_)) { + viewports = viewports_; + dirty_state.viewports = true; + } + } + + void SetScissors(const Scissors& scissors_) { + if (!std::ranges::equal(scissors, scissors_)) { + scissors = scissors_; + dirty_state.scissors = true; + } + } + + void SetDepthTestEnabled(const bool enabled) { + if (depth_test_enabled != enabled) { + depth_test_enabled = enabled; + dirty_state.depth_test_enabled = true; + } + } + + void SetDepthWriteEnabled(const bool enabled) { + if (depth_write_enabled != enabled) { + depth_write_enabled = enabled; + dirty_state.depth_write_enabled = true; + } + } + + void SetDepthCompareOp(const vk::CompareOp compare_op) { + if (depth_compare_op != compare_op) { + depth_compare_op = compare_op; + dirty_state.depth_compare_op = true; + } + } + + void SetDepthBoundsTestEnabled(const bool enabled) { + if (depth_bounds_test_enabled != enabled) { + depth_bounds_test_enabled = enabled; + dirty_state.depth_bounds_test_enabled = true; + } + } + + void SetDepthBounds(const float min, const float max) { + if (depth_bounds_min != min || depth_bounds_max != max) { + depth_bounds_min = min; + depth_bounds_max = max; + dirty_state.depth_bounds = true; + } + } + + void SetDepthBiasEnabled(const bool enabled) { + if (depth_bias_enabled != enabled) { + depth_bias_enabled = enabled; + dirty_state.depth_bias_enabled = true; + } + } + + void SetDepthBias(const float constant, const float clamp, const float slope) { + if (depth_bias_constant != constant || depth_bias_clamp != clamp || + depth_bias_slope != slope) { + depth_bias_constant = constant; + depth_bias_clamp = clamp; + depth_bias_slope = slope; + dirty_state.depth_bias = true; + } + } + + void SetStencilTestEnabled(const bool enabled) { + if (stencil_test_enabled != enabled) { + stencil_test_enabled = enabled; + dirty_state.stencil_test_enabled = true; + } + } + + void SetStencilOps(const StencilOps& front_ops, const StencilOps& back_ops) { + if (stencil_front_ops != front_ops) { + stencil_front_ops = front_ops; + dirty_state.stencil_front_ops = true; + } + if (stencil_back_ops != back_ops) { + stencil_back_ops = back_ops; + dirty_state.stencil_back_ops = true; + } + } + + void SetStencilReferences(const u32 front_reference, const u32 back_reference) { + if (stencil_front_reference != front_reference) { + stencil_front_reference = front_reference; + dirty_state.stencil_front_reference = true; + } + if (stencil_back_reference != back_reference) { + stencil_back_reference = back_reference; + dirty_state.stencil_back_reference = true; + } + } + + void SetStencilWriteMasks(const u32 front_write_mask, const u32 back_write_mask) { + if (stencil_front_write_mask != front_write_mask) { + stencil_front_write_mask = front_write_mask; + dirty_state.stencil_front_write_mask = true; + } + if (stencil_back_write_mask != back_write_mask) { + stencil_back_write_mask = back_write_mask; + dirty_state.stencil_back_write_mask = true; + } + } + + void SetStencilCompareMasks(const u32 front_compare_mask, const u32 back_compare_mask) { + if (stencil_front_compare_mask != front_compare_mask) { + stencil_front_compare_mask = front_compare_mask; + dirty_state.stencil_front_compare_mask = true; + } + if (stencil_back_compare_mask != back_compare_mask) { + stencil_back_compare_mask = back_compare_mask; + dirty_state.stencil_back_compare_mask = true; + } + } + + void SetPrimitiveRestartEnabled(const bool enabled) { + if (primitive_restart_enable != enabled) { + primitive_restart_enable = enabled; + dirty_state.primitive_restart_enable = true; + } + } + + void SetCullMode(const vk::CullModeFlags cull_mode_) { + if (cull_mode != cull_mode_) { + cull_mode = cull_mode_; + dirty_state.cull_mode = true; + } + } + + void SetFrontFace(const vk::FrontFace front_face_) { + if (front_face != front_face_) { + front_face = front_face_; + dirty_state.front_face = true; + } + } + + void SetBlendConstants(const float blend_constants_[4]) { + if (!std::equal(blend_constants, std::end(blend_constants), blend_constants_)) { + std::memcpy(blend_constants, blend_constants_, sizeof(blend_constants)); + dirty_state.blend_constants = true; + } + } + + void SetColorWriteMasks(const ColorWriteMasks& color_write_masks_) { + if (!std::ranges::equal(color_write_masks, color_write_masks_)) { + color_write_masks = color_write_masks_; + dirty_state.color_write_masks = true; + } + } +}; + class Scheduler { public: explicit Scheduler(const Instance& instance); @@ -81,6 +324,10 @@ public: return render_state; } + DynamicState& GetDynamicState() { + return dynamic_state; + } + /// Returns the current command buffer. vk::CommandBuffer CommandBuffer() const { return current_cmdbuf; @@ -125,6 +372,7 @@ private: }; std::queue pending_ops; RenderState render_state; + DynamicState dynamic_state; bool is_rendering = false; tracy::VkCtxScope* profiler_scope{}; }; diff --git a/src/video_core/renderer_vulkan/vk_shader_util.cpp b/src/video_core/renderer_vulkan/vk_shader_util.cpp index 08703c3de..1eb9b27c6 100644 --- a/src/video_core/renderer_vulkan/vk_shader_util.cpp +++ b/src/video_core/renderer_vulkan/vk_shader_util.cpp @@ -159,7 +159,8 @@ bool InitializeCompiler() { } } // Anonymous namespace -vk::ShaderModule Compile(std::string_view code, vk::ShaderStageFlagBits stage, vk::Device device) { +vk::ShaderModule Compile(std::string_view code, vk::ShaderStageFlagBits stage, vk::Device device, + std::vector defines) { if (!InitializeCompiler()) { return {}; } @@ -178,12 +179,46 @@ vk::ShaderModule Compile(std::string_view code, vk::ShaderStageFlagBits stage, v glslang::EShTargetLanguageVersion::EShTargetSpv_1_3); shader->setStringsWithLengths(&pass_source_code, &pass_source_code_length, 1); + std::string preambleString; + std::vector processes; + + for (auto& def : defines) { + processes.push_back("define-macro "); + processes.back().append(def); + + preambleString.append("#define "); + if (const size_t equal = def.find_first_of("="); equal != def.npos) { + def[equal] = ' '; + } + preambleString.append(def); + preambleString.append("\n"); + } + + shader->setPreamble(preambleString.c_str()); + shader->addProcesses(processes); + glslang::TShader::ForbidIncluder includer; + + std::string preprocessedStr; + if (!shader->preprocess(&DefaultTBuiltInResource, default_version, profile, false, true, + messages, &preprocessedStr, includer)) [[unlikely]] { + LOG_ERROR(Render_Vulkan, + "Shader preprocess error\n" + "Shader Info Log:\n" + "{}\n{}", + shader->getInfoLog(), shader->getInfoDebugLog()); + LOG_ERROR(Render_Vulkan, "Shader Source:\n{}", code); + return {}; + } + if (!shader->parse(&DefaultTBuiltInResource, default_version, profile, false, true, messages, includer)) [[unlikely]] { - LOG_INFO(Render_Vulkan, "Shader Info Log:\n{}\n{}", shader->getInfoLog(), - shader->getInfoDebugLog()); - LOG_INFO(Render_Vulkan, "Shader Source:\n{}", code); + LOG_ERROR(Render_Vulkan, + "Shader parse error\n" + "Shader Info Log:\n" + "{}\n{}", + shader->getInfoLog(), shader->getInfoDebugLog()); + LOG_ERROR(Render_Vulkan, "Shader Source:\n{}", code); return {}; } @@ -191,8 +226,11 @@ vk::ShaderModule Compile(std::string_view code, vk::ShaderStageFlagBits stage, v auto program = std::make_unique(); program->addShader(shader.get()); if (!program->link(messages)) { - LOG_INFO(Render_Vulkan, "Program Info Log:\n{}\n{}", program->getInfoLog(), - program->getInfoDebugLog()); + LOG_ERROR(Render_Vulkan, + "Shader link error\n" + "Program Info Log:\n" + "{}\n{}", + program->getInfoLog(), program->getInfoDebugLog()); return {}; } diff --git a/src/video_core/renderer_vulkan/vk_shader_util.h b/src/video_core/renderer_vulkan/vk_shader_util.h index 3a86acf2b..14b929782 100644 --- a/src/video_core/renderer_vulkan/vk_shader_util.h +++ b/src/video_core/renderer_vulkan/vk_shader_util.h @@ -16,7 +16,8 @@ namespace Vulkan { * @param stage The pipeline stage the shader will be used in. * @param device The vulkan device handle. */ -vk::ShaderModule Compile(std::string_view code, vk::ShaderStageFlagBits stage, vk::Device device); +vk::ShaderModule Compile(std::string_view code, vk::ShaderStageFlagBits stage, vk::Device device, + std::vector defines = {}); /** * @brief Creates a vulkan shader module from SPIR-V bytecode. diff --git a/src/video_core/texture_cache/image.cpp b/src/video_core/texture_cache/image.cpp index 3c85c451c..522e6fd5b 100644 --- a/src/video_core/texture_cache/image.cpp +++ b/src/video_core/texture_cache/image.cpp @@ -113,6 +113,8 @@ static vk::FormatFeatureFlags2 FormatFeatureFlags(const vk::ImageUsageFlags usag return feature_flags; } +UniqueImage::UniqueImage() {} + UniqueImage::UniqueImage(vk::Device device_, VmaAllocator allocator_) : device{device_}, allocator{allocator_} {} @@ -123,6 +125,9 @@ UniqueImage::~UniqueImage() { } void UniqueImage::Create(const vk::ImageCreateInfo& image_ci) { + if (image) { + vmaDestroyImage(allocator, image, allocation); + } const VmaAllocationCreateInfo alloc_info = { .flags = VMA_ALLOCATION_CREATE_WITHIN_BUDGET_BIT, .usage = VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE, diff --git a/src/video_core/texture_cache/image.h b/src/video_core/texture_cache/image.h index 66d65ceec..404e25e88 100644 --- a/src/video_core/texture_cache/image.h +++ b/src/video_core/texture_cache/image.h @@ -35,6 +35,7 @@ enum ImageFlagBits : u32 { DECLARE_ENUM_FLAG_OPERATORS(ImageFlagBits) struct UniqueImage { + explicit UniqueImage(); explicit UniqueImage(vk::Device device, VmaAllocator allocator); ~UniqueImage(); diff --git a/src/video_core/texture_cache/texture_cache.cpp b/src/video_core/texture_cache/texture_cache.cpp index d41ee57cc..047bb3dfe 100644 --- a/src/video_core/texture_cache/texture_cache.cpp +++ b/src/video_core/texture_cache/texture_cache.cpp @@ -319,15 +319,14 @@ ImageId TextureCache::FindImage(BaseDesc& desc, FindFlags flags) { continue; } if (False(flags & FindFlags::RelaxFmt) && - !IsVulkanFormatCompatible(info.pixel_format, cache_image.info.pixel_format)) { + (!IsVulkanFormatCompatible(info.pixel_format, cache_image.info.pixel_format) || + (cache_image.info.type != info.type && info.size != Extent3D{1, 1, 1}))) { continue; } if (True(flags & FindFlags::ExactFmt) && info.pixel_format != cache_image.info.pixel_format) { continue; } - ASSERT((cache_image.info.type == info.type || info.size == Extent3D{1, 1, 1} || - True(flags & FindFlags::RelaxFmt))); image_id = cache_id; }