diff options
206 files changed, 2259 insertions, 3643 deletions
diff --git a/.ci/scripts/format/script.sh b/.ci/scripts/format/script.sh index 969ab637c..c2550c966 100644 --- a/.ci/scripts/format/script.sh +++ b/.ci/scripts/format/script.sh | |||
| @@ -7,7 +7,7 @@ if grep -nrI '\s$' src *.yml *.txt *.md Doxyfile .gitignore .gitmodules .ci* dis | |||
| 7 | fi | 7 | fi |
| 8 | 8 | ||
| 9 | # Default clang-format points to default 3.5 version one | 9 | # Default clang-format points to default 3.5 version one |
| 10 | CLANG_FORMAT=clang-format-10 | 10 | CLANG_FORMAT=clang-format-12 |
| 11 | $CLANG_FORMAT --version | 11 | $CLANG_FORMAT --version |
| 12 | 12 | ||
| 13 | if [ "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then | 13 | if [ "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then |
diff --git a/.ci/templates/merge-private.yml b/.ci/templates/merge-private.yml index f15a74355..c74561c46 100644 --- a/.ci/templates/merge-private.yml +++ b/.ci/templates/merge-private.yml | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | jobs: | 1 | jobs: |
| 2 | - job: merge | 2 | - job: merge |
| 3 | displayName: 'pull requests' | 3 | displayName: 'pull requests' |
| 4 | pool: | ||
| 5 | vmImage: 'ubuntu-latest' | ||
| 4 | steps: | 6 | steps: |
| 5 | - checkout: self | 7 | - checkout: self |
| 6 | submodules: recursive | 8 | submodules: recursive |
| @@ -24,6 +26,8 @@ jobs: | |||
| 24 | - job: upload_source | 26 | - job: upload_source |
| 25 | displayName: 'upload' | 27 | displayName: 'upload' |
| 26 | dependsOn: merge | 28 | dependsOn: merge |
| 29 | pool: | ||
| 30 | vmImage: 'ubuntu-latest' | ||
| 27 | steps: | 31 | steps: |
| 28 | - template: ./sync-source.yml | 32 | - template: ./sync-source.yml |
| 29 | parameters: | 33 | parameters: |
diff --git a/.ci/templates/merge.yml b/.ci/templates/merge.yml index 460dfa1c1..27c36e162 100644 --- a/.ci/templates/merge.yml +++ b/.ci/templates/merge.yml | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | jobs: | 1 | jobs: |
| 2 | - job: merge | 2 | - job: merge |
| 3 | displayName: 'pull requests' | 3 | displayName: 'pull requests' |
| 4 | pool: | ||
| 5 | vmImage: 'ubuntu-latest' | ||
| 4 | steps: | 6 | steps: |
| 5 | - checkout: self | 7 | - checkout: self |
| 6 | submodules: recursive | 8 | submodules: recursive |
| @@ -23,6 +25,8 @@ jobs: | |||
| 23 | - job: upload_source | 25 | - job: upload_source |
| 24 | displayName: 'upload' | 26 | displayName: 'upload' |
| 25 | dependsOn: merge | 27 | dependsOn: merge |
| 28 | pool: | ||
| 29 | vmImage: 'ubuntu-latest' | ||
| 26 | steps: | 30 | steps: |
| 27 | - template: ./sync-source.yml | 31 | - template: ./sync-source.yml |
| 28 | parameters: | 32 | parameters: |
diff --git a/.ci/yuzu-mainline-step1.yml b/.ci/yuzu-mainline-step1.yml index 3fd33d75a..6b6acb5c6 100644 --- a/.ci/yuzu-mainline-step1.yml +++ b/.ci/yuzu-mainline-step1.yml | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | trigger: | 1 | trigger: |
| 2 | - master | 2 | - master |
| 3 | 3 | ||
| 4 | pool: | ||
| 5 | vmImage: 'ubuntu-latest' | ||
| 6 | |||
| 4 | stages: | 7 | stages: |
| 5 | - stage: merge | 8 | - stage: merge |
| 6 | displayName: 'merge' | 9 | displayName: 'merge' |
diff --git a/.ci/yuzu-mainline-step2.yml b/.ci/yuzu-mainline-step2.yml index 3159ce3ed..91e21a126 100644 --- a/.ci/yuzu-mainline-step2.yml +++ b/.ci/yuzu-mainline-step2.yml | |||
| @@ -66,5 +66,7 @@ stages: | |||
| 66 | jobs: | 66 | jobs: |
| 67 | - job: github | 67 | - job: github |
| 68 | displayName: 'github' | 68 | displayName: 'github' |
| 69 | pool: | ||
| 70 | vmImage: ubuntu-latest | ||
| 69 | steps: | 71 | steps: |
| 70 | - template: ./templates/release-github.yml | 72 | - template: ./templates/release-github.yml |
diff --git a/.ci/yuzu-patreon-step1.yml b/.ci/yuzu-patreon-step1.yml index cf30397cd..c63d7a066 100644 --- a/.ci/yuzu-patreon-step1.yml +++ b/.ci/yuzu-patreon-step1.yml | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | trigger: | 1 | trigger: |
| 2 | - master | 2 | - master |
| 3 | 3 | ||
| 4 | pool: | ||
| 5 | vmImage: 'ubuntu-latest' | ||
| 6 | |||
| 4 | stages: | 7 | stages: |
| 5 | - stage: merge | 8 | - stage: merge |
| 6 | displayName: 'merge' | 9 | displayName: 'merge' |
diff --git a/.ci/yuzu-patreon-step2.yml b/.ci/yuzu-patreon-step2.yml index 3f338e2a0..ad61ac74e 100644 --- a/.ci/yuzu-patreon-step2.yml +++ b/.ci/yuzu-patreon-step2.yml | |||
| @@ -29,5 +29,7 @@ stages: | |||
| 29 | jobs: | 29 | jobs: |
| 30 | - job: release | 30 | - job: release |
| 31 | displayName: 'source' | 31 | displayName: 'source' |
| 32 | pool: | ||
| 33 | vmImage: 'ubuntu-latest' | ||
| 32 | steps: | 34 | steps: |
| 33 | - template: ./templates/release-private-tag.yml | 35 | - template: ./templates/release-private-tag.yml |
diff --git a/.gitmodules b/.gitmodules index 749cd0408..dc6ed500f 100644 --- a/.gitmodules +++ b/.gitmodules | |||
| @@ -28,9 +28,6 @@ | |||
| 28 | [submodule "mbedtls"] | 28 | [submodule "mbedtls"] |
| 29 | path = externals/mbedtls | 29 | path = externals/mbedtls |
| 30 | url = https://github.com/yuzu-emu/mbedtls | 30 | url = https://github.com/yuzu-emu/mbedtls |
| 31 | [submodule "libzip"] | ||
| 32 | path = externals/libzip/libzip | ||
| 33 | url = https://github.com/nih-at/libzip.git | ||
| 34 | [submodule "xbyak"] | 31 | [submodule "xbyak"] |
| 35 | path = externals/xbyak | 32 | path = externals/xbyak |
| 36 | url = https://github.com/herumi/xbyak.git | 33 | url = https://github.com/herumi/xbyak.git |
diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 93fda1dfa..000000000 --- a/.travis.yml +++ /dev/null | |||
| @@ -1,59 +0,0 @@ | |||
| 1 | language: cpp | ||
| 2 | matrix: | ||
| 3 | include: | ||
| 4 | - os: linux | ||
| 5 | env: NAME="clang-format" | ||
| 6 | sudo: required | ||
| 7 | dist: trusty | ||
| 8 | services: docker | ||
| 9 | install: "./.travis/clang-format/deps.sh" | ||
| 10 | script: "./.travis/clang-format/build.sh" | ||
| 11 | - os: linux | ||
| 12 | env: NAME="linux build" | ||
| 13 | sudo: required | ||
| 14 | dist: trusty | ||
| 15 | services: docker | ||
| 16 | addons: | ||
| 17 | apt: | ||
| 18 | packages: | ||
| 19 | - p7zip-full | ||
| 20 | install: "./.travis/linux/deps.sh" | ||
| 21 | script: "./.travis/linux/build.sh" | ||
| 22 | after_success: "./.travis/linux/upload.sh" | ||
| 23 | cache: ccache | ||
| 24 | - os: osx | ||
| 25 | env: NAME="macos build" | ||
| 26 | sudo: false | ||
| 27 | osx_image: xcode10.2 | ||
| 28 | install: "./.travis/macos/deps.sh" | ||
| 29 | script: "./.travis/macos/build.sh" | ||
| 30 | after_success: "./.travis/macos/upload.sh" | ||
| 31 | cache: ccache | ||
| 32 | - os: linux | ||
| 33 | env: NAME="MinGW build" | ||
| 34 | sudo: required | ||
| 35 | dist: trusty | ||
| 36 | services: docker | ||
| 37 | addons: | ||
| 38 | apt: | ||
| 39 | packages: | ||
| 40 | - p7zip-full | ||
| 41 | install: "./.travis/linux-mingw/deps.sh" | ||
| 42 | script: "./.travis/linux-mingw/build.sh" | ||
| 43 | after_success: "./.travis/linux-mingw/upload.sh" | ||
| 44 | cache: ccache | ||
| 45 | |||
| 46 | deploy: | ||
| 47 | provider: releases | ||
| 48 | api_key: | ||
| 49 | secure: ElsIAlbvVXBNKsP31nVPysh+mf0GQA4DiL/y5iJeQxKQYR6iRoNo+RfzOBmdswdo0bE/PGeBAlfzCkp15gjhWf6Je0N6dRpczmcmLq6SSQFn1Mpq00xMJB2AgQIlaHs6KFgoUA173EBKbPwgU/NubTFpJFm/Wa+NcSWAHQXKL9KT2M3qKpxNkPl3mKEVsbch4REP+T/46vsa+ikw0VE0kIs6V93LqUQZpI2F0Dhihx8Cxr5iedkE1QsNK+QSX9iItMHbfek9OH980gP7L3lkZltyAA1Pk0c37OAgz2PwczwNKwCT8jg9PMzdcKmWouvLyAkZFuA806ElzwHY3oEd91Zm6+Bk5n24yBKZ9027AZzw38NK2Z2m9Akb8+ar8PdsKU6N5pDutX9qSLayr0oMgJ0s7/xnGBGdL3gfkPCFc50xO/2DxlsOR+zAhPNM9Y76hhGy6A7/40+9uzrJvd4nAuDvIXRzi2Yl2L7mKBE4suMKbFLtk2LlgM0qY5JMVTQ8NliaEtqopfPur2KWFVJUpWDNLtNX8xGqhfwg7cLjIiGmnxSaJBTDuZI6dpEjkWkU0n1xYhGqEqit8DbehYzazozMJ+Vsr8hku7jGlUtlw+U6HG1e19O2y4aGeSwYPROcCNz+BLwmVM8oZE3Roy3qoaa2yiFf+sy6rUHznrhsfEM= | ||
| 50 | file_glob: true | ||
| 51 | file: "artifacts/*" | ||
| 52 | skip_cleanup: true | ||
| 53 | on: | ||
| 54 | tags: true | ||
| 55 | |||
| 56 | notifications: | ||
| 57 | webhooks: | ||
| 58 | urls: | ||
| 59 | - https://api.yuzu-emu.org/code/travis/notify | ||
diff --git a/.travis/clang-format/build.sh b/.travis/clang-format/build.sh deleted file mode 100755 index 36c276c43..000000000 --- a/.travis/clang-format/build.sh +++ /dev/null | |||
| @@ -1,3 +0,0 @@ | |||
| 1 | #!/bin/bash -ex | ||
| 2 | |||
| 3 | docker run --env-file .travis/common/travis-ci.env -v $(pwd):/yuzu -v "$HOME/.ccache":/root/.ccache citraemu/build-environments:linux-clang-format /bin/bash -ex /yuzu/.travis/clang-format/docker.sh | ||
diff --git a/.travis/clang-format/deps.sh b/.travis/clang-format/deps.sh deleted file mode 100755 index a15d164c7..000000000 --- a/.travis/clang-format/deps.sh +++ /dev/null | |||
| @@ -1,3 +0,0 @@ | |||
| 1 | #!/bin/sh -ex | ||
| 2 | |||
| 3 | docker pull citraemu/build-environments:linux-clang-format | ||
diff --git a/.travis/clang-format/docker.sh b/.travis/clang-format/docker.sh deleted file mode 100755 index b519ab40e..000000000 --- a/.travis/clang-format/docker.sh +++ /dev/null | |||
| @@ -1,5 +0,0 @@ | |||
| 1 | #!/bin/bash -ex | ||
| 2 | |||
| 3 | # Run clang-format | ||
| 4 | cd /yuzu | ||
| 5 | ./.travis/clang-format/script.sh | ||
diff --git a/.travis/clang-format/script.sh b/.travis/clang-format/script.sh deleted file mode 100755 index 56a785fe0..000000000 --- a/.travis/clang-format/script.sh +++ /dev/null | |||
| @@ -1,37 +0,0 @@ | |||
| 1 | #!/bin/bash -ex | ||
| 2 | |||
| 3 | if grep -nrI '\s$' src *.yml *.txt *.md Doxyfile .gitignore .gitmodules .travis* dist/*.desktop \ | ||
| 4 | dist/*.svg dist/*.xml; then | ||
| 5 | echo Trailing whitespace found, aborting | ||
| 6 | exit 1 | ||
| 7 | fi | ||
| 8 | |||
| 9 | # Default clang-format points to default 3.5 version one | ||
| 10 | CLANG_FORMAT=clang-format-10.0 | ||
| 11 | $CLANG_FORMAT --version | ||
| 12 | |||
| 13 | if [ "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then | ||
| 14 | # Get list of every file modified in this pull request | ||
| 15 | files_to_lint="$(git diff --name-only --diff-filter=ACMRTUXB $TRAVIS_COMMIT_RANGE | grep '^src/[^.]*[.]\(cpp\|h\)$' || true)" | ||
| 16 | else | ||
| 17 | # Check everything for branch pushes | ||
| 18 | files_to_lint="$(find src/ -name '*.cpp' -or -name '*.h')" | ||
| 19 | fi | ||
| 20 | |||
| 21 | # Turn off tracing for this because it's too verbose | ||
| 22 | set +x | ||
| 23 | |||
| 24 | for f in $files_to_lint; do | ||
| 25 | d=$(diff -u "$f" <($CLANG_FORMAT "$f") || true) | ||
| 26 | if ! [ -z "$d" ]; then | ||
| 27 | echo "!!! $f not compliant to coding style, here is the fix:" | ||
| 28 | echo "$d" | ||
| 29 | fail=1 | ||
| 30 | fi | ||
| 31 | done | ||
| 32 | |||
| 33 | set -x | ||
| 34 | |||
| 35 | if [ "$fail" = 1 ]; then | ||
| 36 | exit 1 | ||
| 37 | fi | ||
diff --git a/.travis/common/post-upload.sh b/.travis/common/post-upload.sh deleted file mode 100755 index 28735a9cf..000000000 --- a/.travis/common/post-upload.sh +++ /dev/null | |||
| @@ -1,25 +0,0 @@ | |||
| 1 | #!/bin/bash -ex | ||
| 2 | |||
| 3 | # Copy documentation | ||
| 4 | cp license.txt "$REV_NAME" | ||
| 5 | cp README.md "$REV_NAME" | ||
| 6 | |||
| 7 | tar $COMPRESSION_FLAGS "$ARCHIVE_NAME" "$REV_NAME" | ||
| 8 | |||
| 9 | # Find out what release we are building | ||
| 10 | if [ -z $TRAVIS_TAG ]; then | ||
| 11 | RELEASE_NAME=head | ||
| 12 | else | ||
| 13 | RELEASE_NAME=$(echo $TRAVIS_TAG | cut -d- -f1) | ||
| 14 | if [ "$NAME" = "MinGW build" ]; then | ||
| 15 | RELEASE_NAME="${RELEASE_NAME}-mingw" | ||
| 16 | fi | ||
| 17 | fi | ||
| 18 | |||
| 19 | mv "$REV_NAME" $RELEASE_NAME | ||
| 20 | |||
| 21 | 7z a "$REV_NAME.7z" $RELEASE_NAME | ||
| 22 | |||
| 23 | # move the compiled archive into the artifacts directory to be uploaded by travis releases | ||
| 24 | mv "$ARCHIVE_NAME" artifacts/ | ||
| 25 | mv "$REV_NAME.7z" artifacts/ | ||
diff --git a/.travis/common/pre-upload.sh b/.travis/common/pre-upload.sh deleted file mode 100755 index 3c2fc79a2..000000000 --- a/.travis/common/pre-upload.sh +++ /dev/null | |||
| @@ -1,6 +0,0 @@ | |||
| 1 | #!/bin/bash -ex | ||
| 2 | |||
| 3 | GITDATE="`git show -s --date=short --format='%ad' | sed 's/-//g'`" | ||
| 4 | GITREV="`git show -s --format='%h'`" | ||
| 5 | |||
| 6 | mkdir -p artifacts | ||
diff --git a/.travis/common/travis-ci.env b/.travis/common/travis-ci.env deleted file mode 100644 index cffeb2e2b..000000000 --- a/.travis/common/travis-ci.env +++ /dev/null | |||
| @@ -1,18 +0,0 @@ | |||
| 1 | # List of environment variables to be shared with Docker containers | ||
| 2 | CI | ||
| 3 | TRAVIS | ||
| 4 | CONTINUOUS_INTEGRATION | ||
| 5 | TRAVIS_BRANCH | ||
| 6 | TRAVIS_BUILD_ID | ||
| 7 | TRAVIS_BUILD_NUMBER | ||
| 8 | TRAVIS_COMMIT | ||
| 9 | TRAVIS_COMMIT_RANGE | ||
| 10 | TRAVIS_EVENT_TYPE | ||
| 11 | TRAVIS_JOB_ID | ||
| 12 | TRAVIS_JOB_NUMBER | ||
| 13 | TRAVIS_REPO_SLUG | ||
| 14 | TRAVIS_TAG | ||
| 15 | |||
| 16 | # yuzu specific flags | ||
| 17 | ENABLE_COMPATIBILITY_REPORTING | ||
| 18 | USE_DISCORD_PRESENCE | ||
diff --git a/.travis/linux-mingw/build.sh b/.travis/linux-mingw/build.sh deleted file mode 100755 index b12d70b12..000000000 --- a/.travis/linux-mingw/build.sh +++ /dev/null | |||
| @@ -1,3 +0,0 @@ | |||
| 1 | #!/bin/bash -ex | ||
| 2 | mkdir "$HOME/.ccache" || true | ||
| 3 | docker run --env-file .travis/common/travis-ci.env -v $(pwd):/yuzu -v "$HOME/.ccache":/root/.ccache yuzuemu/build-environments:linux-mingw /bin/bash -ex /yuzu/.travis/linux-mingw/docker.sh | ||
diff --git a/.travis/linux-mingw/deps.sh b/.travis/linux-mingw/deps.sh deleted file mode 100755 index 55b5d6006..000000000 --- a/.travis/linux-mingw/deps.sh +++ /dev/null | |||
| @@ -1,3 +0,0 @@ | |||
| 1 | #!/bin/sh -ex | ||
| 2 | |||
| 3 | docker pull yuzuemu/build-environments:linux-mingw | ||
diff --git a/.travis/linux-mingw/docker.sh b/.travis/linux-mingw/docker.sh deleted file mode 100755 index 80d7dfe9b..000000000 --- a/.travis/linux-mingw/docker.sh +++ /dev/null | |||
| @@ -1,42 +0,0 @@ | |||
| 1 | #!/bin/bash -ex | ||
| 2 | |||
| 3 | cd /yuzu | ||
| 4 | # override Travis CI unreasonable ccache size | ||
| 5 | echo 'max_size = 3.0G' > "$HOME/.ccache/ccache.conf" | ||
| 6 | |||
| 7 | mkdir build && cd build | ||
| 8 | cmake .. -G Ninja -DCMAKE_TOOLCHAIN_FILE="$(pwd)/../CMakeModules/MinGWCross.cmake" -DUSE_CCACHE=ON -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DCMAKE_BUILD_TYPE=Release | ||
| 9 | ninja | ||
| 10 | |||
| 11 | # Clean up the dirty hacks | ||
| 12 | rm /bin/uname && mv /bin/uname1 /bin/uname | ||
| 13 | rm /bin/cmd | ||
| 14 | |||
| 15 | ccache -s | ||
| 16 | |||
| 17 | echo "Tests skipped" | ||
| 18 | #ctest -VV -C Release | ||
| 19 | |||
| 20 | echo 'Prepare binaries...' | ||
| 21 | cd .. | ||
| 22 | mkdir package | ||
| 23 | |||
| 24 | QT_PLATFORM_DLL_PATH='/usr/x86_64-w64-mingw32/lib/qt5/plugins/platforms/' | ||
| 25 | find build/ -name "yuzu*.exe" -exec cp {} 'package' \; | ||
| 26 | |||
| 27 | # copy Qt plugins | ||
| 28 | mkdir package/platforms | ||
| 29 | cp "${QT_PLATFORM_DLL_PATH}/qwindows.dll" package/platforms/ | ||
| 30 | cp -rv "${QT_PLATFORM_DLL_PATH}/../mediaservice/" package/ | ||
| 31 | cp -rv "${QT_PLATFORM_DLL_PATH}/../imageformats/" package/ | ||
| 32 | rm -f package/mediaservice/*d.dll | ||
| 33 | |||
| 34 | for i in package/*.exe; do | ||
| 35 | # we need to process pdb here, however, cv2pdb | ||
| 36 | # does not work here, so we just simply strip all the debug symbols | ||
| 37 | x86_64-w64-mingw32-strip "${i}" | ||
| 38 | done | ||
| 39 | |||
| 40 | pip3 install pefile | ||
| 41 | python3 .travis/linux-mingw/scan_dll.py package/*.exe "package/" | ||
| 42 | python3 .travis/linux-mingw/scan_dll.py package/imageformats/*.dll "package/" | ||
diff --git a/.travis/linux-mingw/scan_dll.py b/.travis/linux-mingw/scan_dll.py deleted file mode 100644 index 163183f2e..000000000 --- a/.travis/linux-mingw/scan_dll.py +++ /dev/null | |||
| @@ -1,106 +0,0 @@ | |||
| 1 | import pefile | ||
| 2 | import sys | ||
| 3 | import re | ||
| 4 | import os | ||
| 5 | import queue | ||
| 6 | import shutil | ||
| 7 | |||
| 8 | # constant definitions | ||
| 9 | KNOWN_SYS_DLLS = ['WINMM.DLL', 'MSVCRT.DLL', 'VERSION.DLL', 'MPR.DLL', | ||
| 10 | 'DWMAPI.DLL', 'UXTHEME.DLL', 'DNSAPI.DLL', 'IPHLPAPI.DLL'] | ||
| 11 | # below is for Ubuntu 18.04 with specified PPA enabled, if you are using | ||
| 12 | # other distro or different repositories, change the following accordingly | ||
| 13 | DLL_PATH = [ | ||
| 14 | '/usr/x86_64-w64-mingw32/bin/', | ||
| 15 | '/usr/x86_64-w64-mingw32/lib/', | ||
| 16 | '/usr/lib/gcc/x86_64-w64-mingw32/7.3-posix/' | ||
| 17 | ] | ||
| 18 | |||
| 19 | missing = [] | ||
| 20 | |||
| 21 | |||
| 22 | def parse_imports(file_name): | ||
| 23 | results = [] | ||
| 24 | pe = pefile.PE(file_name, fast_load=True) | ||
| 25 | pe.parse_data_directories() | ||
| 26 | |||
| 27 | for entry in pe.DIRECTORY_ENTRY_IMPORT: | ||
| 28 | current = entry.dll.decode() | ||
| 29 | current_u = current.upper() # b/c Windows is often case insensitive | ||
| 30 | # here we filter out system dlls | ||
| 31 | # dll w/ names like *32.dll are likely to be system dlls | ||
| 32 | if current_u.upper() not in KNOWN_SYS_DLLS and not re.match(string=current_u, pattern=r'.*32\.DLL'): | ||
| 33 | results.append(current) | ||
| 34 | |||
| 35 | return results | ||
| 36 | |||
| 37 | |||
| 38 | def parse_imports_recursive(file_name, path_list=[]): | ||
| 39 | q = queue.Queue() # create a FIFO queue | ||
| 40 | # file_name can be a string or a list for the convience | ||
| 41 | if isinstance(file_name, str): | ||
| 42 | q.put(file_name) | ||
| 43 | elif isinstance(file_name, list): | ||
| 44 | for i in file_name: | ||
| 45 | q.put(i) | ||
| 46 | full_list = [] | ||
| 47 | while q.qsize(): | ||
| 48 | current = q.get_nowait() | ||
| 49 | print('> %s' % current) | ||
| 50 | deps = parse_imports(current) | ||
| 51 | # if this dll does not have any import, ignore it | ||
| 52 | if not deps: | ||
| 53 | continue | ||
| 54 | for dep in deps: | ||
| 55 | # the dependency already included in the list, skip | ||
| 56 | if dep in full_list: | ||
| 57 | continue | ||
| 58 | # find the requested dll in the provided paths | ||
| 59 | full_path = find_dll(dep) | ||
| 60 | if not full_path: | ||
| 61 | missing.append(dep) | ||
| 62 | continue | ||
| 63 | full_list.append(dep) | ||
| 64 | q.put(full_path) | ||
| 65 | path_list.append(full_path) | ||
| 66 | return full_list | ||
| 67 | |||
| 68 | |||
| 69 | def find_dll(name): | ||
| 70 | for path in DLL_PATH: | ||
| 71 | for root, _, files in os.walk(path): | ||
| 72 | for f in files: | ||
| 73 | if name.lower() == f.lower(): | ||
| 74 | return os.path.join(root, f) | ||
| 75 | |||
| 76 | |||
| 77 | def deploy(name, dst, dry_run=False): | ||
| 78 | dlls_path = [] | ||
| 79 | parse_imports_recursive(name, dlls_path) | ||
| 80 | for dll_entry in dlls_path: | ||
| 81 | if not dry_run: | ||
| 82 | shutil.copy(dll_entry, dst) | ||
| 83 | else: | ||
| 84 | print('[Dry-Run] Copy %s to %s' % (dll_entry, dst)) | ||
| 85 | print('Deploy completed.') | ||
| 86 | return dlls_path | ||
| 87 | |||
| 88 | |||
| 89 | def main(): | ||
| 90 | if len(sys.argv) < 3: | ||
| 91 | print('Usage: %s [files to examine ...] [target deploy directory]') | ||
| 92 | return 1 | ||
| 93 | to_deploy = sys.argv[1:-1] | ||
| 94 | tgt_dir = sys.argv[-1] | ||
| 95 | if not os.path.isdir(tgt_dir): | ||
| 96 | print('%s is not a directory.' % tgt_dir) | ||
| 97 | return 1 | ||
| 98 | print('Scanning dependencies...') | ||
| 99 | deploy(to_deploy, tgt_dir) | ||
| 100 | if missing: | ||
| 101 | print('Following DLLs are not found: %s' % ('\n'.join(missing))) | ||
| 102 | return 0 | ||
| 103 | |||
| 104 | |||
| 105 | if __name__ == '__main__': | ||
| 106 | main() | ||
diff --git a/.travis/linux-mingw/upload.sh b/.travis/linux-mingw/upload.sh deleted file mode 100755 index 66e896bc4..000000000 --- a/.travis/linux-mingw/upload.sh +++ /dev/null | |||
| @@ -1,13 +0,0 @@ | |||
| 1 | #!/bin/bash -ex | ||
| 2 | |||
| 3 | . .travis/common/pre-upload.sh | ||
| 4 | |||
| 5 | REV_NAME="yuzu-windows-mingw-${GITDATE}-${GITREV}" | ||
| 6 | ARCHIVE_NAME="${REV_NAME}.tar.gz" | ||
| 7 | COMPRESSION_FLAGS="-czvf" | ||
| 8 | |||
| 9 | mkdir "$REV_NAME" | ||
| 10 | # get around the permission issues | ||
| 11 | cp -r package/* "$REV_NAME" | ||
| 12 | |||
| 13 | . .travis/common/post-upload.sh | ||
diff --git a/.travis/linux/build.sh b/.travis/linux/build.sh deleted file mode 100755 index 0c7fb8c9d..000000000 --- a/.travis/linux/build.sh +++ /dev/null | |||
| @@ -1,4 +0,0 @@ | |||
| 1 | #!/bin/bash -ex | ||
| 2 | |||
| 3 | mkdir -p "$HOME/.ccache" | ||
| 4 | docker run -e ENABLE_COMPATIBILITY_REPORTING --env-file .travis/common/travis-ci.env -v $(pwd):/yuzu -v "$HOME/.ccache":/home/yuzu/.ccache yuzuemu/build-environments:linux-fresh /bin/bash /yuzu/.travis/linux/docker.sh | ||
diff --git a/.travis/linux/deps.sh b/.travis/linux/deps.sh deleted file mode 100755 index 8d23c517d..000000000 --- a/.travis/linux/deps.sh +++ /dev/null | |||
| @@ -1,3 +0,0 @@ | |||
| 1 | #!/bin/sh -ex | ||
| 2 | |||
| 3 | docker pull yuzuemu/build-environments:linux-fresh | ||
diff --git a/.travis/linux/docker.sh b/.travis/linux/docker.sh deleted file mode 100755 index 166fb6d4c..000000000 --- a/.travis/linux/docker.sh +++ /dev/null | |||
| @@ -1,11 +0,0 @@ | |||
| 1 | #!/bin/bash -ex | ||
| 2 | |||
| 3 | cd /yuzu | ||
| 4 | |||
| 5 | mkdir build && cd build | ||
| 6 | cmake .. -G Ninja -DYUZU_USE_QT_WEB_ENGINE=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/lib/ccache/gcc -DCMAKE_CXX_COMPILER=/usr/lib/ccache/g++ -DYUZU_ENABLE_COMPATIBILITY_REPORTING=${ENABLE_COMPATIBILITY_REPORTING:-"OFF"} -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DUSE_DISCORD_PRESENCE=ON | ||
| 7 | ninja | ||
| 8 | |||
| 9 | ccache -s | ||
| 10 | |||
| 11 | ctest -VV -C Release | ||
diff --git a/.travis/linux/upload.sh b/.travis/linux/upload.sh deleted file mode 100755 index 61842be12..000000000 --- a/.travis/linux/upload.sh +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | #!/bin/bash -ex | ||
| 2 | |||
| 3 | . .travis/common/pre-upload.sh | ||
| 4 | |||
| 5 | REV_NAME="yuzu-linux-${GITDATE}-${GITREV}" | ||
| 6 | ARCHIVE_NAME="${REV_NAME}.tar.xz" | ||
| 7 | COMPRESSION_FLAGS="-cJvf" | ||
| 8 | |||
| 9 | mkdir "$REV_NAME" | ||
| 10 | |||
| 11 | cp build/bin/yuzu-cmd "$REV_NAME" | ||
| 12 | cp build/bin/yuzu "$REV_NAME" | ||
| 13 | |||
| 14 | . .travis/common/post-upload.sh | ||
diff --git a/.travis/macos/build.sh b/.travis/macos/build.sh deleted file mode 100755 index db1c7cae7..000000000 --- a/.travis/macos/build.sh +++ /dev/null | |||
| @@ -1,17 +0,0 @@ | |||
| 1 | #!/bin/bash -ex | ||
| 2 | |||
| 3 | set -o pipefail | ||
| 4 | |||
| 5 | export MACOSX_DEPLOYMENT_TARGET=10.14 | ||
| 6 | export Qt5_DIR=$(brew --prefix)/opt/qt5 | ||
| 7 | export PATH="/usr/local/opt/ccache/libexec:$PATH" | ||
| 8 | |||
| 9 | # TODO: Build using ninja instead of make | ||
| 10 | mkdir build && cd build | ||
| 11 | cmake --version | ||
| 12 | cmake .. -DYUZU_USE_QT_WEB_ENGINE=ON -DCMAKE_BUILD_TYPE=Release -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DYUZU_ENABLE_COMPATIBILITY_REPORTING=${ENABLE_COMPATIBILITY_REPORTING:-"OFF"} -DUSE_DISCORD_PRESENCE=ON | ||
| 13 | make -j4 | ||
| 14 | |||
| 15 | ccache -s | ||
| 16 | |||
| 17 | ctest -VV -C Release | ||
diff --git a/.travis/macos/deps.sh b/.travis/macos/deps.sh deleted file mode 100755 index faeafa216..000000000 --- a/.travis/macos/deps.sh +++ /dev/null | |||
| @@ -1,6 +0,0 @@ | |||
| 1 | #!/bin/sh -ex | ||
| 2 | |||
| 3 | brew update | ||
| 4 | brew install p7zip qt5 sdl2 ccache | ||
| 5 | brew outdated cmake || brew upgrade cmake | ||
| 6 | pip3 install macpack | ||
diff --git a/.travis/macos/upload.sh b/.travis/macos/upload.sh deleted file mode 100755 index c2f43a906..000000000 --- a/.travis/macos/upload.sh +++ /dev/null | |||
| @@ -1,28 +0,0 @@ | |||
| 1 | #!/bin/bash -ex | ||
| 2 | |||
| 3 | . .travis/common/pre-upload.sh | ||
| 4 | |||
| 5 | REV_NAME="yuzu-osx-${GITDATE}-${GITREV}" | ||
| 6 | ARCHIVE_NAME="${REV_NAME}.tar.gz" | ||
| 7 | COMPRESSION_FLAGS="-czvf" | ||
| 8 | |||
| 9 | mkdir "$REV_NAME" | ||
| 10 | |||
| 11 | cp build/bin/yuzu-cmd "$REV_NAME" | ||
| 12 | cp -r build/bin/yuzu.app "$REV_NAME" | ||
| 13 | |||
| 14 | # move libs into folder for deployment | ||
| 15 | macpack "${REV_NAME}/yuzu.app/Contents/MacOS/yuzu" -d "../Frameworks" | ||
| 16 | # move qt frameworks into app bundle for deployment | ||
| 17 | $(brew --prefix)/opt/qt5/bin/macdeployqt "${REV_NAME}/yuzu.app" -executable="${REV_NAME}/yuzu.app/Contents/MacOS/yuzu" | ||
| 18 | |||
| 19 | # move libs into folder for deployment | ||
| 20 | macpack "${REV_NAME}/yuzu-cmd" -d "libs" | ||
| 21 | |||
| 22 | # Make the launching script executable | ||
| 23 | chmod +x ${REV_NAME}/yuzu.app/Contents/MacOS/yuzu | ||
| 24 | |||
| 25 | # Verify loader instructions | ||
| 26 | find "$REV_NAME" -exec otool -L {} \; | ||
| 27 | |||
| 28 | . .travis/common/post-upload.sh | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt index 870d0ebdd..123a3082a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
| @@ -29,16 +29,10 @@ option(YUZU_USE_BUNDLED_FFMPEG "Download/Build bundled FFmpeg" "${WIN32}") | |||
| 29 | 29 | ||
| 30 | option(YUZU_USE_QT_WEB_ENGINE "Use QtWebEngine for web applet implementation" OFF) | 30 | option(YUZU_USE_QT_WEB_ENGINE "Use QtWebEngine for web applet implementation" OFF) |
| 31 | 31 | ||
| 32 | option(YUZU_ENABLE_BOXCAT "Enable the Boxcat service, a yuzu high-level implementation of BCAT" ON) | ||
| 33 | |||
| 34 | option(ENABLE_CUBEB "Enables the cubeb audio backend" ON) | 32 | option(ENABLE_CUBEB "Enables the cubeb audio backend" ON) |
| 35 | 33 | ||
| 36 | option(USE_DISCORD_PRESENCE "Enables Discord Rich Presence" OFF) | 34 | option(USE_DISCORD_PRESENCE "Enables Discord Rich Presence" OFF) |
| 37 | 35 | ||
| 38 | if (NOT ENABLE_WEB_SERVICE) | ||
| 39 | set(YUZU_ENABLE_BOXCAT OFF) | ||
| 40 | endif() | ||
| 41 | |||
| 42 | # Default to a Release build | 36 | # Default to a Release build |
| 43 | get_property(IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) | 37 | get_property(IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) |
| 44 | if (NOT IS_MULTI_CONFIG AND NOT CMAKE_BUILD_TYPE) | 38 | if (NOT IS_MULTI_CONFIG AND NOT CMAKE_BUILD_TYPE) |
| @@ -243,7 +237,7 @@ yuzu_find_packages() | |||
| 243 | 237 | ||
| 244 | # Qt5 requires that we find components, so it doesn't fit our pretty little find package function | 238 | # Qt5 requires that we find components, so it doesn't fit our pretty little find package function |
| 245 | if(ENABLE_QT) | 239 | if(ENABLE_QT) |
| 246 | set(QT_VERSION 5.12) | 240 | set(QT_VERSION 5.15) |
| 247 | # We want to load the generated conan qt config so that we get the QT_ROOT var so that we can use the official | 241 | # We want to load the generated conan qt config so that we get the QT_ROOT var so that we can use the official |
| 248 | # Qt5Config inside the root folder instead of the conan generated one. | 242 | # Qt5Config inside the root folder instead of the conan generated one. |
| 249 | if(EXISTS ${CMAKE_BINARY_DIR}/qtConfig.cmake) | 243 | if(EXISTS ${CMAKE_BINARY_DIR}/qtConfig.cmake) |
| @@ -345,8 +339,8 @@ if(ENABLE_QT) | |||
| 345 | set(QT_PREFIX_HINT) | 339 | set(QT_PREFIX_HINT) |
| 346 | 340 | ||
| 347 | if(YUZU_USE_BUNDLED_QT) | 341 | if(YUZU_USE_BUNDLED_QT) |
| 348 | if ((MSVC_VERSION GREATER_EQUAL 1910 AND MSVC_VERSION LESS 1930) AND ARCHITECTURE_x86_64) | 342 | if ((MSVC_VERSION GREATER_EQUAL 1920 AND MSVC_VERSION LESS 1940) AND ARCHITECTURE_x86_64) |
| 349 | set(QT_BUILD qt-5.12.8-msvc2017_64) | 343 | set(QT_BUILD qt-5.15.2-msvc2019_64) |
| 350 | elseif ((${CMAKE_SYSTEM_NAME} STREQUAL "Linux") AND NOT MINGW AND ARCHITECTURE_x86_64) | 344 | elseif ((${CMAKE_SYSTEM_NAME} STREQUAL "Linux") AND NOT MINGW AND ARCHITECTURE_x86_64) |
| 351 | set(QT_BUILD qt5_5_15_2) | 345 | set(QT_BUILD qt5_5_15_2) |
| 352 | else() | 346 | else() |
| @@ -375,7 +369,7 @@ endif() | |||
| 375 | if (ENABLE_SDL2) | 369 | if (ENABLE_SDL2) |
| 376 | if (YUZU_USE_BUNDLED_SDL2) | 370 | if (YUZU_USE_BUNDLED_SDL2) |
| 377 | # Detect toolchain and platform | 371 | # Detect toolchain and platform |
| 378 | if ((MSVC_VERSION GREATER_EQUAL 1910 AND MSVC_VERSION LESS 1930) AND ARCHITECTURE_x86_64) | 372 | if ((MSVC_VERSION GREATER_EQUAL 1920 AND MSVC_VERSION LESS 1940) AND ARCHITECTURE_x86_64) |
| 379 | set(SDL2_VER "SDL2-2.0.16") | 373 | set(SDL2_VER "SDL2-2.0.16") |
| 380 | else() | 374 | else() |
| 381 | message(FATAL_ERROR "No bundled SDL2 binaries for your toolchain. Disable YUZU_USE_BUNDLED_SDL2 and provide your own.") | 375 | message(FATAL_ERROR "No bundled SDL2 binaries for your toolchain. Disable YUZU_USE_BUNDLED_SDL2 and provide your own.") |
| @@ -422,11 +416,6 @@ if (CONAN_REQUIRED_LIBS) | |||
| 422 | endif() | 416 | endif() |
| 423 | include(${CMAKE_BINARY_DIR}/conan.cmake) | 417 | include(${CMAKE_BINARY_DIR}/conan.cmake) |
| 424 | 418 | ||
| 425 | set(CONAN_LIB_OPTIONS | ||
| 426 | libzip:with_openssl=False | ||
| 427 | libzip:enable_windows_crypto=False | ||
| 428 | ) | ||
| 429 | |||
| 430 | conan_check(VERSION 1.24.0 REQUIRED) | 419 | conan_check(VERSION 1.24.0 REQUIRED) |
| 431 | 420 | ||
| 432 | # Manually add iconv to fix a dep conflict between qt and sdl2 | 421 | # Manually add iconv to fix a dep conflict between qt and sdl2 |
| @@ -473,7 +462,7 @@ if (CONAN_REQUIRED_LIBS) | |||
| 473 | if(ENABLE_QT) | 462 | if(ENABLE_QT) |
| 474 | list(APPEND CMAKE_MODULE_PATH "${CONAN_QT_ROOT_RELEASE}") | 463 | list(APPEND CMAKE_MODULE_PATH "${CONAN_QT_ROOT_RELEASE}") |
| 475 | list(APPEND CMAKE_PREFIX_PATH "${CONAN_QT_ROOT_RELEASE}") | 464 | list(APPEND CMAKE_PREFIX_PATH "${CONAN_QT_ROOT_RELEASE}") |
| 476 | find_package(Qt5 5.12 REQUIRED COMPONENTS Widgets) | 465 | find_package(Qt5 5.15 REQUIRED COMPONENTS Widgets) |
| 477 | if (YUZU_USE_QT_WEB_ENGINE) | 466 | if (YUZU_USE_QT_WEB_ENGINE) |
| 478 | find_package(Qt5 REQUIRED COMPONENTS WebEngineCore WebEngineWidgets) | 467 | find_package(Qt5 REQUIRED COMPONENTS WebEngineCore WebEngineWidgets) |
| 479 | endif() | 468 | endif() |
| @@ -780,7 +769,7 @@ endif() | |||
| 780 | # against all the src files. This should be used before making a pull request. | 769 | # against all the src files. This should be used before making a pull request. |
| 781 | # ======================================================================= | 770 | # ======================================================================= |
| 782 | 771 | ||
| 783 | set(CLANG_FORMAT_POSTFIX "-10") | 772 | set(CLANG_FORMAT_POSTFIX "-12") |
| 784 | find_program(CLANG_FORMAT | 773 | find_program(CLANG_FORMAT |
| 785 | NAMES clang-format${CLANG_FORMAT_POSTFIX} | 774 | NAMES clang-format${CLANG_FORMAT_POSTFIX} |
| 786 | clang-format | 775 | clang-format |
diff --git a/CMakeModules/CopyYuzuQt5Deps.cmake b/CMakeModules/CopyYuzuQt5Deps.cmake index 4a6aeebbb..dd97f5b2b 100644 --- a/CMakeModules/CopyYuzuQt5Deps.cmake +++ b/CMakeModules/CopyYuzuQt5Deps.cmake | |||
| @@ -33,6 +33,7 @@ function(copy_yuzu_Qt5_deps target_dir) | |||
| 33 | Qt5Positioning$<$<CONFIG:Debug>:d>.* | 33 | Qt5Positioning$<$<CONFIG:Debug>:d>.* |
| 34 | Qt5PrintSupport$<$<CONFIG:Debug>:d>.* | 34 | Qt5PrintSupport$<$<CONFIG:Debug>:d>.* |
| 35 | Qt5Qml$<$<CONFIG:Debug>:d>.* | 35 | Qt5Qml$<$<CONFIG:Debug>:d>.* |
| 36 | Qt5QmlModels$<$<CONFIG:Debug>:d>.* | ||
| 36 | Qt5Quick$<$<CONFIG:Debug>:d>.* | 37 | Qt5Quick$<$<CONFIG:Debug>:d>.* |
| 37 | Qt5QuickWidgets$<$<CONFIG:Debug>:d>.* | 38 | Qt5QuickWidgets$<$<CONFIG:Debug>:d>.* |
| 38 | Qt5WebChannel$<$<CONFIG:Debug>:d>.* | 39 | Qt5WebChannel$<$<CONFIG:Debug>:d>.* |
diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index 0c2c059a9..a76a3d800 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt | |||
| @@ -93,13 +93,6 @@ endif() | |||
| 93 | # Sirit | 93 | # Sirit |
| 94 | add_subdirectory(sirit) | 94 | add_subdirectory(sirit) |
| 95 | 95 | ||
| 96 | # libzip | ||
| 97 | find_package(libzip 1.5) | ||
| 98 | if (NOT libzip_FOUND) | ||
| 99 | message(STATUS "libzip 1.5 or newer not found, falling back to externals") | ||
| 100 | add_subdirectory(libzip EXCLUDE_FROM_ALL) | ||
| 101 | endif() | ||
| 102 | |||
| 103 | if (ENABLE_WEB_SERVICE) | 96 | if (ENABLE_WEB_SERVICE) |
| 104 | find_package(OpenSSL 1.1) | 97 | find_package(OpenSSL 1.1) |
| 105 | if (OPENSSL_FOUND) | 98 | if (OPENSSL_FOUND) |
diff --git a/externals/find-modules/Findlibzip.cmake b/externals/find-modules/Findlibzip.cmake deleted file mode 100644 index 8934de3b8..000000000 --- a/externals/find-modules/Findlibzip.cmake +++ /dev/null | |||
| @@ -1,72 +0,0 @@ | |||
| 1 | |||
| 2 | find_package(PkgConfig QUIET) | ||
| 3 | pkg_check_modules(PC_libzip QUIET libzip) | ||
| 4 | |||
| 5 | find_path(libzip_INCLUDE_DIR | ||
| 6 | NAMES zip.h | ||
| 7 | PATHS ${PC_libzip_INCLUDE_DIRS} | ||
| 8 | "$ENV{LIB_DIR}/include" | ||
| 9 | "$ENV{INCLUDE}" | ||
| 10 | /usr/local/include | ||
| 11 | /usr/include | ||
| 12 | ) | ||
| 13 | find_path(libzip_INCLUDE_DIR_ZIPCONF | ||
| 14 | NAMES zipconf.h | ||
| 15 | HINTS ${PC_libzip_INCLUDE_DIRS} | ||
| 16 | "$ENV{LIB_DIR}/include" | ||
| 17 | "$ENV{LIB_DIR}/lib/libzip/include" | ||
| 18 | "$ENV{LIB}/lib/libzip/include" | ||
| 19 | /usr/local/lib/libzip/include | ||
| 20 | /usr/lib/libzip/include | ||
| 21 | /usr/local/include | ||
| 22 | /usr/include | ||
| 23 | "$ENV{INCLUDE}" | ||
| 24 | ) | ||
| 25 | find_library(libzip_LIBRARY | ||
| 26 | NAMES zip | ||
| 27 | PATHS ${PC_libzip_LIBRARY_DIRS} | ||
| 28 | "$ENV{LIB_DIR}/lib" "$ENV{LIB}" /usr/local/lib /usr/lib | ||
| 29 | ) | ||
| 30 | |||
| 31 | if (libzip_INCLUDE_DIR_ZIPCONF) | ||
| 32 | FILE(READ "${libzip_INCLUDE_DIR_ZIPCONF}/zipconf.h" _libzip_VERSION_CONTENTS) | ||
| 33 | if (_libzip_VERSION_CONTENTS) | ||
| 34 | STRING(REGEX REPLACE ".*#define LIBZIP_VERSION \"([0-9.]+)\".*" "\\1" libzip_VERSION "${_libzip_VERSION_CONTENTS}") | ||
| 35 | endif() | ||
| 36 | unset(_libzip_VERSION_CONTENTS) | ||
| 37 | endif() | ||
| 38 | |||
| 39 | set(libzip_VERSION ${libzip_VERSION} CACHE STRING "Version number of libzip") | ||
| 40 | |||
| 41 | include(FindPackageHandleStandardArgs) | ||
| 42 | find_package_handle_standard_args(libzip | ||
| 43 | FOUND_VAR libzip_FOUND | ||
| 44 | REQUIRED_VARS | ||
| 45 | libzip_LIBRARY | ||
| 46 | libzip_INCLUDE_DIR | ||
| 47 | libzip_INCLUDE_DIR_ZIPCONF | ||
| 48 | libzip_VERSION | ||
| 49 | VERSION_VAR libzip_VERSION | ||
| 50 | ) | ||
| 51 | |||
| 52 | if(libzip_FOUND) | ||
| 53 | set(libzip_LIBRARIES ${libzip_LIBRARY}) | ||
| 54 | set(libzip_INCLUDE_DIRS ${libzip_INCLUDE_DIR}) | ||
| 55 | set(libzip_DEFINITIONS ${PC_libzip_CFLAGS_OTHER}) | ||
| 56 | endif() | ||
| 57 | |||
| 58 | if(libzip_FOUND AND NOT TARGET libzip::libzip) | ||
| 59 | add_library(libzip::libzip UNKNOWN IMPORTED) | ||
| 60 | set_target_properties(libzip::libzip PROPERTIES | ||
| 61 | IMPORTED_LOCATION "${libzip_LIBRARY}" | ||
| 62 | INTERFACE_COMPILE_OPTIONS "${PC_libzip_CFLAGS_OTHER}" | ||
| 63 | INTERFACE_INCLUDE_DIRECTORIES "${libzip_INCLUDE_DIR}" | ||
| 64 | ) | ||
| 65 | endif() | ||
| 66 | |||
| 67 | mark_as_advanced( | ||
| 68 | libzip_INCLUDE_DIR | ||
| 69 | libzip_INCLUDE_DIR_ZIPCONF | ||
| 70 | libzip_LIBRARY | ||
| 71 | libzip_VERSION | ||
| 72 | ) | ||
diff --git a/externals/libzip/CMakeLists.txt b/externals/libzip/CMakeLists.txt deleted file mode 100644 index ea5329fa0..000000000 --- a/externals/libzip/CMakeLists.txt +++ /dev/null | |||
| @@ -1,564 +0,0 @@ | |||
| 1 | # TODO: | ||
| 2 | # create usable libtool .la file | ||
| 3 | |||
| 4 | CMAKE_MINIMUM_REQUIRED(VERSION 3.0.2) | ||
| 5 | |||
| 6 | LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/libzip") | ||
| 7 | |||
| 8 | PROJECT(libzip C) | ||
| 9 | |||
| 10 | OPTION(ENABLE_COMMONCRYPTO "Enable use of CommonCrypto" ON) | ||
| 11 | OPTION(ENABLE_GNUTLS "Enable use of GnuTLS" ON) | ||
| 12 | OPTION(ENABLE_MBEDTLS "Enable use of mbed TLS" ON) | ||
| 13 | OPTION(ENABLE_OPENSSL "Enable use of OpenSSL" ON) | ||
| 14 | OPTION(ENABLE_WINDOWS_CRYPTO "Enable use of Windows cryptography libraries" ON) | ||
| 15 | |||
| 16 | OPTION(ENABLE_BZIP2 "Enable use of BZip2" OFF) | ||
| 17 | OPTION(ENABLE_LZMA "Enable use of LZMA" OFF) | ||
| 18 | |||
| 19 | INCLUDE(CheckFunctionExists) | ||
| 20 | INCLUDE(CheckIncludeFiles) | ||
| 21 | INCLUDE(CheckSymbolExists) | ||
| 22 | INCLUDE(CheckTypeSize) | ||
| 23 | INCLUDE(CheckCSourceRuns) | ||
| 24 | INCLUDE(CheckCSourceCompiles) | ||
| 25 | INCLUDE(CheckStructHasMember) | ||
| 26 | INCLUDE(TestBigEndian) | ||
| 27 | INCLUDE(GNUInstallDirs) | ||
| 28 | IF(ENABLE_COMMONCRYPTO) | ||
| 29 | CHECK_INCLUDE_FILES(CommonCrypto/CommonCrypto.h COMMONCRYPTO_FOUND) | ||
| 30 | ELSE() | ||
| 31 | SET(COMMONCRYPTO_FOUND FALSE) | ||
| 32 | ENDIF() | ||
| 33 | IF(ENABLE_GNUTLS) | ||
| 34 | INCLUDE(FindNettle) | ||
| 35 | INCLUDE(FindGnuTLS) | ||
| 36 | ELSE() | ||
| 37 | SET(GNUTLS_FOUND FALSE) | ||
| 38 | ENDIF() | ||
| 39 | IF(ENABLE_MBEDTLS) | ||
| 40 | FIND_PATH(MBEDTLS_INCLUDE_DIR mbedtls/aes.h) | ||
| 41 | FIND_LIBRARY(MBEDTLS_LIBRARIES NAMES mbedcrypto) | ||
| 42 | ELSE() | ||
| 43 | SET(MBEDTLS_LIBRARIES FALSE) | ||
| 44 | ENDIF() | ||
| 45 | IF(ENABLE_OPENSSL) | ||
| 46 | INCLUDE(FindOpenSSL) | ||
| 47 | ELSE() | ||
| 48 | SET(OPENSSL_FOUND FALSE) | ||
| 49 | ENDIF() | ||
| 50 | IF(WIN32) | ||
| 51 | IF(ENABLE_WINDOWS_CRYPTO) | ||
| 52 | SET(WINDOWS_CRYPTO_FOUND TRUE) | ||
| 53 | ENDIF() | ||
| 54 | ELSE() | ||
| 55 | SET(WINDOWS_CRYPTO_FOUND FALSE) | ||
| 56 | ENDIF() | ||
| 57 | |||
| 58 | OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON) | ||
| 59 | OPTION(SHARED_LIB_VERSIONNING "Add SO version in .so build" ON) | ||
| 60 | |||
| 61 | SET(PACKAGE "libzip") | ||
| 62 | SET(PACKAGE_NAME ${PACKAGE}) | ||
| 63 | SET(PACKAGE_VERSION_MAJOR "1") | ||
| 64 | SET(PACKAGE_VERSION_MINOR "5") | ||
| 65 | SET(PACKAGE_VERSION_MICRO "2a") | ||
| 66 | #SET(VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}") | ||
| 67 | SET(VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_MICRO}") | ||
| 68 | SET(PACKAGE_VERSION ${VERSION}) | ||
| 69 | SET(LIBZIP_VERSION ${PACKAGE_VERSION}) | ||
| 70 | SET(LIBZIP_VERSION_MAJOR ${PACKAGE_VERSION_MAJOR}) | ||
| 71 | SET(LIBZIP_VERSION_MINOR ${PACKAGE_VERSION_MINOR}) | ||
| 72 | SET(LIBZIP_VERSION_MICRO ${PACKAGE_VERSION_MICRO}) | ||
| 73 | SET(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") | ||
| 74 | |||
| 75 | SET(ARCHIVE_NAME ${PACKAGE_NAME}-${PACKAGE_VERSION}) | ||
| 76 | IF(NOT TARGET dist) | ||
| 77 | ADD_CUSTOM_TARGET(dist | ||
| 78 | COMMAND git config tar.tar.xz.command "xz -c" | ||
| 79 | COMMAND git archive --prefix=${ARCHIVE_NAME}/ -o ${ARCHIVE_NAME}.tar.gz HEAD | ||
| 80 | COMMAND git archive --prefix=${ARCHIVE_NAME}/ -o ${ARCHIVE_NAME}.tar.xz HEAD | ||
| 81 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | ||
| 82 | ) | ||
| 83 | ADD_CUSTOM_TARGET(distcheck | ||
| 84 | COMMAND chmod -R u+w ${ARCHIVE_NAME} ${ARCHIVE_NAME}-build ${ARCHIVE_NAME}-dest 2>/dev/null || true | ||
| 85 | COMMAND rm -rf ${ARCHIVE_NAME} ${ARCHIVE_NAME}-build ${ARCHIVE_NAME}-dest | ||
| 86 | COMMAND cmake -E tar xf ${ARCHIVE_NAME}.tar.gz | ||
| 87 | COMMAND chmod -R u-w ${ARCHIVE_NAME} | ||
| 88 | COMMAND mkdir ${ARCHIVE_NAME}-build | ||
| 89 | COMMAND mkdir ${ARCHIVE_NAME}-dest | ||
| 90 | COMMAND cd ${ARCHIVE_NAME}-build && cmake -DCMAKE_INSTALL_PREFIX=../${ARCHIVE_NAME}-dest ../${ARCHIVE_NAME} | ||
| 91 | COMMAND cd ${ARCHIVE_NAME}-build && make -j4 | ||
| 92 | COMMAND cd ${ARCHIVE_NAME}-build && make test | ||
| 93 | COMMAND cd ${ARCHIVE_NAME}-build && make install | ||
| 94 | # COMMAND cd ${ARCHIVE_NAME}-build && make uninstall | ||
| 95 | # COMMAND if [ `find ${ARCHIVE_NAME}-dest ! -type d | wc -l` -ne 0 ]; then echo leftover files in ${ARCHIVE_NAME}-dest; false; fi | ||
| 96 | COMMAND cd ${ARCHIVE_NAME}-build && make clean | ||
| 97 | COMMAND chmod -R u+w ${ARCHIVE_NAME} ${ARCHIVE_NAME}-build ${ARCHIVE_NAME}-dest | ||
| 98 | COMMAND rm -rf ${ARCHIVE_NAME} ${ARCHIVE_NAME}-build ${ARCHIVE_NAME}-dest | ||
| 99 | COMMAND echo "${ARCHIVE_NAME}.tar.gz is ready for distribution." | ||
| 100 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | ||
| 101 | ) | ||
| 102 | ADD_DEPENDENCIES(distcheck dist) | ||
| 103 | ENDIF(NOT TARGET dist) | ||
| 104 | |||
| 105 | IF(BUILD_SHARED_LIBS) | ||
| 106 | SET(HAVE_SHARED TRUE) | ||
| 107 | ELSE() | ||
| 108 | SET(ZIP_STATIC TRUE) | ||
| 109 | ENDIF() | ||
| 110 | |||
| 111 | # Checks | ||
| 112 | |||
| 113 | CHECK_FUNCTION_EXISTS(_chmod HAVE__CHMOD) | ||
| 114 | CHECK_FUNCTION_EXISTS(_close HAVE__CLOSE) | ||
| 115 | CHECK_FUNCTION_EXISTS(_dup HAVE__DUP) | ||
| 116 | CHECK_FUNCTION_EXISTS(_fdopen HAVE__FDOPEN) | ||
| 117 | CHECK_FUNCTION_EXISTS(_fileno HAVE__FILENO) | ||
| 118 | CHECK_FUNCTION_EXISTS(_open HAVE__OPEN) | ||
| 119 | CHECK_FUNCTION_EXISTS(_setmode HAVE__SETMODE) | ||
| 120 | CHECK_FUNCTION_EXISTS(_snprintf HAVE__SNPRINTF) | ||
| 121 | CHECK_FUNCTION_EXISTS(_strdup HAVE__STRDUP) | ||
| 122 | CHECK_FUNCTION_EXISTS(_stricmp HAVE__STRICMP) | ||
| 123 | CHECK_FUNCTION_EXISTS(_strtoi64 HAVE__STRTOI64) | ||
| 124 | CHECK_FUNCTION_EXISTS(_strtoui64 HAVE__STRTOUI64) | ||
| 125 | CHECK_FUNCTION_EXISTS(_unlink HAVE__UNLINK) | ||
| 126 | CHECK_FUNCTION_EXISTS(arc4random HAVE_ARC4RANDOM) | ||
| 127 | CHECK_FUNCTION_EXISTS(clonefile HAVE_CLONEFILE) | ||
| 128 | CHECK_FUNCTION_EXISTS(explicit_bzero HAVE_EXPLICIT_BZERO) | ||
| 129 | CHECK_FUNCTION_EXISTS(explicit_memset HAVE_EXPLICIT_MEMSET) | ||
| 130 | CHECK_FUNCTION_EXISTS(fileno HAVE_FILENO) | ||
| 131 | CHECK_FUNCTION_EXISTS(fseeko HAVE_FSEEKO) | ||
| 132 | CHECK_FUNCTION_EXISTS(ftello HAVE_FTELLO) | ||
| 133 | CHECK_FUNCTION_EXISTS(getprogname HAVE_GETPROGNAME) | ||
| 134 | CHECK_FUNCTION_EXISTS(localtime_r HAVE_LOCALTIME_R) | ||
| 135 | CHECK_FUNCTION_EXISTS(open HAVE_OPEN) | ||
| 136 | CHECK_FUNCTION_EXISTS(setmode HAVE_SETMODE) | ||
| 137 | CHECK_FUNCTION_EXISTS(snprintf HAVE_SNPRINTF) | ||
| 138 | CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP) | ||
| 139 | CHECK_FUNCTION_EXISTS(strdup HAVE_STRDUP) | ||
| 140 | CHECK_FUNCTION_EXISTS(stricmp HAVE_STRICMP) | ||
| 141 | CHECK_FUNCTION_EXISTS(strtoll HAVE_STRTOLL) | ||
| 142 | CHECK_FUNCTION_EXISTS(strtoull HAVE_STRTOULL) | ||
| 143 | |||
| 144 | CHECK_INCLUDE_FILES("sys/types.h;sys/stat.h;fts.h" HAVE_FTS_H) | ||
| 145 | CHECK_INCLUDE_FILES(stdbool.h HAVE_STDBOOL_H) | ||
| 146 | CHECK_INCLUDE_FILES(strings.h HAVE_STRINGS_H) | ||
| 147 | CHECK_INCLUDE_FILES(unistd.h HAVE_UNISTD_H) | ||
| 148 | |||
| 149 | CHECK_INCLUDE_FILES(inttypes.h HAVE_INTTYPES_H_LIBZIP) | ||
| 150 | CHECK_INCLUDE_FILES(stdint.h HAVE_STDINT_H_LIBZIP) | ||
| 151 | CHECK_INCLUDE_FILES(sys/types.h HAVE_SYS_TYPES_H_LIBZIP) | ||
| 152 | |||
| 153 | # TODO: fix test | ||
| 154 | # this test does not find __progname even when it exists | ||
| 155 | #CHECK_SYMBOL_EXISTS(__progname stdlib.h HAVE___PROGNAME) | ||
| 156 | |||
| 157 | CHECK_TYPE_SIZE(__int8 __INT8_LIBZIP) | ||
| 158 | CHECK_TYPE_SIZE(int8_t INT8_T_LIBZIP) | ||
| 159 | CHECK_TYPE_SIZE(uint8_t UINT8_T_LIBZIP) | ||
| 160 | CHECK_TYPE_SIZE(__int16 __INT16_LIBZIP) | ||
| 161 | CHECK_TYPE_SIZE(int16_t INT16_T_LIBZIP) | ||
| 162 | CHECK_TYPE_SIZE(uint16_t UINT16_T_LIBZIP) | ||
| 163 | CHECK_TYPE_SIZE(__int32 __INT32_LIBZIP) | ||
| 164 | CHECK_TYPE_SIZE(int32_t INT32_T_LIBZIP) | ||
| 165 | CHECK_TYPE_SIZE(uint32_t UINT32_T_LIBZIP) | ||
| 166 | CHECK_TYPE_SIZE(__int64 __INT64_LIBZIP) | ||
| 167 | CHECK_TYPE_SIZE(int64_t INT64_T_LIBZIP) | ||
| 168 | CHECK_TYPE_SIZE(uint64_t UINT64_T_LIBZIP) | ||
| 169 | CHECK_TYPE_SIZE("short" SHORT_LIBZIP) | ||
| 170 | CHECK_TYPE_SIZE("int" INT_LIBZIP) | ||
| 171 | CHECK_TYPE_SIZE("long" LONG_LIBZIP) | ||
| 172 | CHECK_TYPE_SIZE("long long" LONG_LONG_LIBZIP) | ||
| 173 | CHECK_TYPE_SIZE("off_t" SIZEOF_OFF_T) | ||
| 174 | CHECK_TYPE_SIZE("size_t" SIZE_T_LIBZIP) | ||
| 175 | CHECK_TYPE_SIZE("ssize_t" SSIZE_T_LIBZIP) | ||
| 176 | |||
| 177 | CHECK_C_SOURCE_COMPILES("#include <sys/ioctl.h> | ||
| 178 | #include <linux/fs.h> | ||
| 179 | int main(int argc, char *argv[]) { unsigned long x = FICLONERANGE; }" HAVE_FICLONERANGE) | ||
| 180 | |||
| 181 | CHECK_C_SOURCE_COMPILES(" | ||
| 182 | int foo(char * _Nullable bar); | ||
| 183 | int main(int argc, char *argv[]) { }" HAVE_NULLABLE) | ||
| 184 | |||
| 185 | TEST_BIG_ENDIAN(WORDS_BIGENDIAN) | ||
| 186 | |||
| 187 | #FIND_PACKAGE(ZLIB 1.1.2 REQUIRED) | ||
| 188 | INCLUDE_DIRECTORIES(../zlib/zlib) | ||
| 189 | SET(CMAKE_REQUIRED_INCLUDES ../zlib/zlib) | ||
| 190 | |||
| 191 | IF(ENABLE_BZIP2) | ||
| 192 | FIND_PACKAGE(BZip2) | ||
| 193 | IF(BZIP2_FOUND) | ||
| 194 | SET (HAVE_LIBBZ2 1) | ||
| 195 | |||
| 196 | INCLUDE_DIRECTORIES(${BZIP2_INCLUDE_DIR}) | ||
| 197 | SET (OPTIONAL_LIBRARY ${OPTIONAL_LIBRARY} ${BZIP2_LIBRARIES}) | ||
| 198 | ELSE() | ||
| 199 | MESSAGE(WARNING "-- bzip2 library not found; bzip2 support disabled") | ||
| 200 | ENDIF(BZIP2_FOUND) | ||
| 201 | ENDIF(ENABLE_BZIP2) | ||
| 202 | |||
| 203 | IF(ENABLE_LZMA) | ||
| 204 | FIND_PACKAGE(LibLZMA) | ||
| 205 | IF(LIBLZMA_FOUND) | ||
| 206 | SET (HAVE_LIBLZMA 1) | ||
| 207 | |||
| 208 | INCLUDE_DIRECTORIES(${LIBLZMA_INCLUDE_DIR}) | ||
| 209 | SET (OPTIONAL_LIBRARY ${OPTIONAL_LIBRARY} ${LIBLZMA_LIBRARY}) | ||
| 210 | ELSE() | ||
| 211 | MESSAGE(WARNING "-- lzma library not found; lzma support disabled") | ||
| 212 | ENDIF(LIBLZMA_FOUND) | ||
| 213 | ENDIF(ENABLE_LZMA) | ||
| 214 | |||
| 215 | |||
| 216 | IF (COMMONCRYPTO_FOUND) | ||
| 217 | SET (HAVE_CRYPTO 1) | ||
| 218 | SET (HAVE_COMMONCRYPTO 1) | ||
| 219 | ELSEIF (WINDOWS_CRYPTO_FOUND) | ||
| 220 | SET (HAVE_CRYPTO 1) | ||
| 221 | SET (HAVE_WINDOWS_CRYPTO 1) | ||
| 222 | ELSEIF (GNUTLS_FOUND AND NETTLE_FOUND) | ||
| 223 | SET (HAVE_CRYPTO 1) | ||
| 224 | SET (HAVE_GNUTLS 1) | ||
| 225 | INCLUDE_DIRECTORIES(${GNUTLS_INCLUDE_DIR} ${NETTLE_INCLUDE_DIR}) | ||
| 226 | SET (OPTIONAL_LIBRARY ${OPTIONAL_LIBRARY} ${GNUTLS_LIBRARY} ${NETTLE_LIBRARY}) | ||
| 227 | ELSEIF (OPENSSL_FOUND) | ||
| 228 | SET (HAVE_CRYPTO 1) | ||
| 229 | SET (HAVE_OPENSSL 1) | ||
| 230 | INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR}) | ||
| 231 | SET (OPTIONAL_LIBRARY ${OPTIONAL_LIBRARY} ${OPENSSL_LIBRARIES}) | ||
| 232 | ELSEIF (MBEDTLS_LIBRARIES) | ||
| 233 | SET (HAVE_CRYPTO 1) | ||
| 234 | SET (HAVE_MBEDTLS 1) | ||
| 235 | INCLUDE_DIRECTORIES(${MBEDTLS_INCLUDE_DIR}) | ||
| 236 | SET (OPTIONAL_LIBRARY ${OPTIONAL_LIBRARY} ${MBEDTLS_LIBRARIES}) | ||
| 237 | ENDIF() | ||
| 238 | |||
| 239 | IF (NOT HAVE_CRYPTO) | ||
| 240 | MESSAGE(WARNING "-- neither Common Crypto, GnuTLS, mbed TLS, OpenSSL, nor Windows Cryptography found; AES support disabled") | ||
| 241 | ENDIF() | ||
| 242 | |||
| 243 | IF(MSVC) | ||
| 244 | ADD_DEFINITIONS("-D_CRT_SECURE_NO_WARNINGS") | ||
| 245 | ADD_DEFINITIONS("-D_CRT_NONSTDC_NO_DEPRECATE") | ||
| 246 | ENDIF(MSVC) | ||
| 247 | |||
| 248 | if(WIN32) | ||
| 249 | if(HAVE_WINDOWS_CRYPTO) | ||
| 250 | SET (OPTIONAL_LIBRARY ${OPTIONAL_LIBRARY} bcrypt) | ||
| 251 | endif() | ||
| 252 | if(CMAKE_SYSTEM_NAME MATCHES WindowsPhone OR CMAKE_SYSTEM_NAME MATCHES WindowsStore) | ||
| 253 | ADD_DEFINITIONS(-DMS_UWP) | ||
| 254 | else(CMAKE_SYSTEM_NAME MATCHES WindowsPhone OR CMAKE_SYSTEM_NAME MATCHES WindowsStore) | ||
| 255 | SET (OPTIONAL_LIBRARY ${OPTIONAL_LIBRARY} advapi32) | ||
| 256 | endif(CMAKE_SYSTEM_NAME MATCHES WindowsPhone OR CMAKE_SYSTEM_NAME MATCHES WindowsStore) | ||
| 257 | endif(WIN32) | ||
| 258 | |||
| 259 | ADD_DEFINITIONS("-DHAVE_CONFIG_H") | ||
| 260 | |||
| 261 | # rpath handling: use rpath in installed binaries | ||
| 262 | IF(NOT CMAKE_SYSTEM_NAME MATCHES Linux) | ||
| 263 | SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") | ||
| 264 | SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) | ||
| 265 | ENDIF() | ||
| 266 | |||
| 267 | # fixed size integral types | ||
| 268 | |||
| 269 | IF(HAVE_INTTYPES_H_LIBZIP) | ||
| 270 | SET(LIBZIP_TYPES_INCLUDE "#define __STDC_FORMAT_MACROS 1 | ||
| 271 | #include <inttypes.h>") | ||
| 272 | ELSEIF(HAVE_STDINT_H_LIBZIP) | ||
| 273 | SET(LIBZIP_TYPES_INCLUDE "#include <stdint.h>") | ||
| 274 | ELSEIF(HAVE_SYS_TYPES_H_LIBZIP) | ||
| 275 | SET(LIBZIP_TYPES_INCLUDE "#include <sys/types.h>") | ||
| 276 | ENDIF() | ||
| 277 | |||
| 278 | IF(HAVE_INT8_T_LIBZIP) | ||
| 279 | SET(ZIP_INT8_T int8_t) | ||
| 280 | ELSEIF(HAVE___INT8_LIBZIP) | ||
| 281 | SET(ZIP_INT8_T __int8) | ||
| 282 | ELSE() | ||
| 283 | SET(ZIP_INT8_T "signed char") | ||
| 284 | ENDIF() | ||
| 285 | |||
| 286 | IF(HAVE_UINT8_T_LIBZIP) | ||
| 287 | SET(ZIP_UINT8_T uint8_t) | ||
| 288 | ELSEIF(HAVE___INT8_LIBZIP) | ||
| 289 | SET(ZIP_UINT8_T "unsigned __int8") | ||
| 290 | ELSE() | ||
| 291 | SET(ZIP_UINT8_T "unsigned char") | ||
| 292 | ENDIF() | ||
| 293 | |||
| 294 | IF(HAVE_INT16_T_LIBZIP) | ||
| 295 | SET(ZIP_INT16_T int16_t) | ||
| 296 | ELSEIF(HAVE___INT16_LIBZIP) | ||
| 297 | SET(INT16_T_LIBZIP __int16) | ||
| 298 | ELSEIF(SHORT_LIBZIP EQUAL 2) | ||
| 299 | SET(INT16_T_LIBZIP short) | ||
| 300 | ENDIF() | ||
| 301 | |||
| 302 | IF(HAVE_UINT16_T_LIBZIP) | ||
| 303 | SET(ZIP_UINT16_T uint16_t) | ||
| 304 | ELSEIF(HAVE___INT16_LIBZIP) | ||
| 305 | SET(UINT16_T_LIBZIP "unsigned __int16") | ||
| 306 | ELSEIF(SHORT_LIBZIP EQUAL 2) | ||
| 307 | SET(UINT16_T_LIBZIP "unsigned short") | ||
| 308 | ENDIF() | ||
| 309 | |||
| 310 | IF(HAVE_INT32_T_LIBZIP) | ||
| 311 | SET(ZIP_INT32_T int32_t) | ||
| 312 | ELSEIF(HAVE___INT32_LIBZIP) | ||
| 313 | SET(ZIP_INT32_T __int32) | ||
| 314 | ELSEIF(INT_LIBZIP EQUAL 4) | ||
| 315 | SET(ZIP_INT32_T int) | ||
| 316 | ELSEIF(LONG_LIBZIP EQUAL 4) | ||
| 317 | SET(ZIP_INT32_T long) | ||
| 318 | ENDIF() | ||
| 319 | |||
| 320 | IF(HAVE_UINT32_T_LIBZIP) | ||
| 321 | SET(ZIP_UINT32_T uint32_t) | ||
| 322 | ELSEIF(HAVE___INT32_LIBZIP) | ||
| 323 | SET(ZIP_UINT32_T "unsigned __int32") | ||
| 324 | ELSEIF(INT_LIBZIP EQUAL 4) | ||
| 325 | SET(ZIP_UINT32_T "unsigned int") | ||
| 326 | ELSEIF(LONG_LIBZIP EQUAL 4) | ||
| 327 | SET(ZIP_UINT32_T "unsigned long") | ||
| 328 | ENDIF() | ||
| 329 | |||
| 330 | IF(HAVE_INT64_T_LIBZIP) | ||
| 331 | SET(ZIP_INT64_T int64_t) | ||
| 332 | ELSEIF(HAVE___INT64_LIBZIP) | ||
| 333 | SET(ZIP_INT64_T __int64) | ||
| 334 | ELSEIF(LONG_LIBZIP EQUAL 8) | ||
| 335 | SET(ZIP_INT64_T long) | ||
| 336 | ELSEIF(LONG_LONG_LIBZIP EQUAL 8) | ||
| 337 | SET(ZIP_INT64_T "long long") | ||
| 338 | ENDIF() | ||
| 339 | |||
| 340 | IF(HAVE_UINT64_T_LIBZIP) | ||
| 341 | SET(ZIP_UINT64_T uint64_t) | ||
| 342 | ELSEIF(HAVE___INT64_LIBZIP) | ||
| 343 | SET(ZIP_UINT64_T "unsigned __int64") | ||
| 344 | ELSEIF(LONG_LIBZIP EQUAL 8) | ||
| 345 | SET(ZIP_UINT64_T "unsigned long") | ||
| 346 | ELSEIF(LONG_LONG_LIBZIP EQUAL 8) | ||
| 347 | SET(ZIP_UINT64_T "unsigned long long") | ||
| 348 | ENDIF() | ||
| 349 | |||
| 350 | IF(HAVE_NULLABLE) | ||
| 351 | SET(ZIP_NULLABLE_DEFINES) | ||
| 352 | ELSE() | ||
| 353 | SET(ZIP_NULLABLE_DEFINES "#define _Nullable | ||
| 354 | #define _Nonnull") | ||
| 355 | ENDIF() | ||
| 356 | |||
| 357 | # write out config file | ||
| 358 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libzip/cmake-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/libzip/config.h) | ||
| 359 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libzip/cmake-zipconf.h.in ${CMAKE_CURRENT_BINARY_DIR}/libzip/zipconf.h) | ||
| 360 | |||
| 361 | # installation | ||
| 362 | INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libzip/zipconf.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
| 363 | INSTALL(FILES libzip/lib/zip.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
| 364 | |||
| 365 | SET(CMAKE_C_VISIBILITY_PRESET hidden) | ||
| 366 | |||
| 367 | ADD_LIBRARY(zip | ||
| 368 | libzip/lib/zip_add.c | ||
| 369 | libzip/lib/zip_add_dir.c | ||
| 370 | libzip/lib/zip_add_entry.c | ||
| 371 | libzip/lib/zip_algorithm_deflate.c | ||
| 372 | libzip/lib/zip_buffer.c | ||
| 373 | libzip/lib/zip_close.c | ||
| 374 | libzip/lib/zip_delete.c | ||
| 375 | libzip/lib/zip_dir_add.c | ||
| 376 | libzip/lib/zip_dirent.c | ||
| 377 | libzip/lib/zip_discard.c | ||
| 378 | libzip/lib/zip_entry.c | ||
| 379 | libzip/lib/zip_err_str.c | ||
| 380 | libzip/lib/zip_error.c | ||
| 381 | libzip/lib/zip_error_clear.c | ||
| 382 | libzip/lib/zip_error_get.c | ||
| 383 | libzip/lib/zip_error_get_sys_type.c | ||
| 384 | libzip/lib/zip_error_strerror.c | ||
| 385 | libzip/lib/zip_error_to_str.c | ||
| 386 | libzip/lib/zip_extra_field.c | ||
| 387 | libzip/lib/zip_extra_field_api.c | ||
| 388 | libzip/lib/zip_fclose.c | ||
| 389 | libzip/lib/zip_fdopen.c | ||
| 390 | libzip/lib/zip_file_add.c | ||
| 391 | libzip/lib/zip_file_error_clear.c | ||
| 392 | libzip/lib/zip_file_error_get.c | ||
| 393 | libzip/lib/zip_file_get_comment.c | ||
| 394 | libzip/lib/zip_file_get_external_attributes.c | ||
| 395 | libzip/lib/zip_file_get_offset.c | ||
| 396 | libzip/lib/zip_file_rename.c | ||
| 397 | libzip/lib/zip_file_replace.c | ||
| 398 | libzip/lib/zip_file_set_comment.c | ||
| 399 | libzip/lib/zip_file_set_encryption.c | ||
| 400 | libzip/lib/zip_file_set_external_attributes.c | ||
| 401 | libzip/lib/zip_file_set_mtime.c | ||
| 402 | libzip/lib/zip_file_strerror.c | ||
| 403 | libzip/lib/zip_filerange_crc.c | ||
| 404 | libzip/lib/zip_fopen.c | ||
| 405 | libzip/lib/zip_fopen_encrypted.c | ||
| 406 | libzip/lib/zip_fopen_index.c | ||
| 407 | libzip/lib/zip_fopen_index_encrypted.c | ||
| 408 | libzip/lib/zip_fread.c | ||
| 409 | libzip/lib/zip_fseek.c | ||
| 410 | libzip/lib/zip_ftell.c | ||
| 411 | libzip/lib/zip_get_archive_comment.c | ||
| 412 | libzip/lib/zip_get_archive_flag.c | ||
| 413 | libzip/lib/zip_get_encryption_implementation.c | ||
| 414 | libzip/lib/zip_get_file_comment.c | ||
| 415 | libzip/lib/zip_get_name.c | ||
| 416 | libzip/lib/zip_get_num_entries.c | ||
| 417 | libzip/lib/zip_get_num_files.c | ||
| 418 | libzip/lib/zip_hash.c | ||
| 419 | libzip/lib/zip_io_util.c | ||
| 420 | libzip/lib/zip_libzip_version.c | ||
| 421 | libzip/lib/zip_memdup.c | ||
| 422 | libzip/lib/zip_name_locate.c | ||
| 423 | libzip/lib/zip_new.c | ||
| 424 | libzip/lib/zip_open.c | ||
| 425 | libzip/lib/zip_progress.c | ||
| 426 | libzip/lib/zip_rename.c | ||
| 427 | libzip/lib/zip_replace.c | ||
| 428 | libzip/lib/zip_set_archive_comment.c | ||
| 429 | libzip/lib/zip_set_archive_flag.c | ||
| 430 | libzip/lib/zip_set_default_password.c | ||
| 431 | libzip/lib/zip_set_file_comment.c | ||
| 432 | libzip/lib/zip_set_file_compression.c | ||
| 433 | libzip/lib/zip_set_name.c | ||
| 434 | libzip/lib/zip_source_accept_empty.c | ||
| 435 | libzip/lib/zip_source_begin_write.c | ||
| 436 | libzip/lib/zip_source_begin_write_cloning.c | ||
| 437 | libzip/lib/zip_source_buffer.c | ||
| 438 | libzip/lib/zip_source_call.c | ||
| 439 | libzip/lib/zip_source_close.c | ||
| 440 | libzip/lib/zip_source_commit_write.c | ||
| 441 | libzip/lib/zip_source_compress.c | ||
| 442 | libzip/lib/zip_source_crc.c | ||
| 443 | libzip/lib/zip_source_error.c | ||
| 444 | libzip/lib/zip_source_filep.c | ||
| 445 | libzip/lib/zip_source_free.c | ||
| 446 | libzip/lib/zip_source_function.c | ||
| 447 | libzip/lib/zip_source_get_compression_flags.c | ||
| 448 | libzip/lib/zip_source_is_deleted.c | ||
| 449 | libzip/lib/zip_source_layered.c | ||
| 450 | libzip/lib/zip_source_open.c | ||
| 451 | libzip/lib/zip_source_pkware.c | ||
| 452 | libzip/lib/zip_source_read.c | ||
| 453 | libzip/lib/zip_source_remove.c | ||
| 454 | libzip/lib/zip_source_rollback_write.c | ||
| 455 | libzip/lib/zip_source_seek.c | ||
| 456 | libzip/lib/zip_source_seek_write.c | ||
| 457 | libzip/lib/zip_source_stat.c | ||
| 458 | libzip/lib/zip_source_supports.c | ||
| 459 | libzip/lib/zip_source_tell.c | ||
| 460 | libzip/lib/zip_source_tell_write.c | ||
| 461 | libzip/lib/zip_source_window.c | ||
| 462 | libzip/lib/zip_source_write.c | ||
| 463 | libzip/lib/zip_source_zip.c | ||
| 464 | libzip/lib/zip_source_zip_new.c | ||
| 465 | libzip/lib/zip_stat.c | ||
| 466 | libzip/lib/zip_stat_index.c | ||
| 467 | libzip/lib/zip_stat_init.c | ||
| 468 | libzip/lib/zip_strerror.c | ||
| 469 | libzip/lib/zip_string.c | ||
| 470 | libzip/lib/zip_unchange.c | ||
| 471 | libzip/lib/zip_unchange_all.c | ||
| 472 | libzip/lib/zip_unchange_archive.c | ||
| 473 | libzip/lib/zip_unchange_data.c | ||
| 474 | libzip/lib/zip_utf-8.c | ||
| 475 | ) | ||
| 476 | |||
| 477 | IF(WIN32) | ||
| 478 | target_sources(zip PRIVATE | ||
| 479 | libzip/lib/zip_source_win32handle.c | ||
| 480 | libzip/lib/zip_source_win32utf8.c | ||
| 481 | libzip/lib/zip_source_win32w.c | ||
| 482 | ) | ||
| 483 | IF(CMAKE_SYSTEM_NAME MATCHES WindowsPhone OR CMAKE_SYSTEM_NAME MATCHES WindowsStore) | ||
| 484 | ELSE() | ||
| 485 | target_sources(zip PRIVATE libzip/lib/zip_source_win32a.c) | ||
| 486 | ENDIF() | ||
| 487 | ELSE() | ||
| 488 | target_sources(zip PRIVATE | ||
| 489 | libzip/lib/zip_mkstempm.c | ||
| 490 | libzip/lib/zip_source_file.c | ||
| 491 | libzip/lib/zip_random_unix.c | ||
| 492 | ) | ||
| 493 | ENDIF() | ||
| 494 | |||
| 495 | IF(HAVE_LIBBZ2) | ||
| 496 | target_sources(zip PRIVATE libzip/lib/zip_algorithm_bzip2.c) | ||
| 497 | ENDIF() | ||
| 498 | |||
| 499 | IF(HAVE_LIBLZMA) | ||
| 500 | target_sources(zip PRIVATE libzip/lib/zip_algorithm_xz.c) | ||
| 501 | ENDIF() | ||
| 502 | |||
| 503 | IF(HAVE_COMMONCRYPTO) | ||
| 504 | target_sources(zip PRIVATE libzip/lib/zip_crypto_commoncrypto.c) | ||
| 505 | ELSEIF(HAVE_WINDOWS_CRYPTO) | ||
| 506 | target_sources(zip PRIVATE libzip/lib/zip_crypto_win.c) | ||
| 507 | ELSEIF(HAVE_GNUTLS) | ||
| 508 | target_sources(zip PRIVATE libzip/lib/zip_crypto_gnutls.c) | ||
| 509 | ELSEIF(HAVE_OPENSSL) | ||
| 510 | target_sources(zip PRIVATE libzip/lib/zip_crypto_openssl.c) | ||
| 511 | ELSEIF(HAVE_MBEDTLS) | ||
| 512 | target_sources(zip PRIVATE libzip/lib/zip_crypto_mbedtls.c) | ||
| 513 | ENDIF() | ||
| 514 | |||
| 515 | IF(HAVE_CRYPTO) | ||
| 516 | target_sources(zip PRIVATE | ||
| 517 | libzip/lib/zip_winzip_aes.c | ||
| 518 | libzip/lib/zip_source_winzip_aes_decode.c | ||
| 519 | libzip/lib/zip_source_winzip_aes_encode.c | ||
| 520 | ) | ||
| 521 | ENDIF() | ||
| 522 | |||
| 523 | target_include_directories(zip | ||
| 524 | PUBLIC | ||
| 525 | libzip/lib | ||
| 526 | ${CMAKE_CURRENT_BINARY_DIR}/libzip | ||
| 527 | ) | ||
| 528 | |||
| 529 | # pkgconfig file | ||
| 530 | SET(prefix ${CMAKE_INSTALL_PREFIX}) | ||
| 531 | SET(exec_prefix \${prefix}) | ||
| 532 | SET(bindir \${exec_prefix}/${CMAKE_INSTALL_BINDIR}) | ||
| 533 | SET(libdir \${exec_prefix}/${CMAKE_INSTALL_LIBDIR}) | ||
| 534 | SET(includedir \${prefix}/${CMAKE_INSTALL_INCLUDEDIR}) | ||
| 535 | IF(CMAKE_SYSTEM_NAME MATCHES BSD) | ||
| 536 | SET(PKG_CONFIG_RPATH "-Wl,-R\${libdir}") | ||
| 537 | ENDIF(CMAKE_SYSTEM_NAME MATCHES BSD) | ||
| 538 | get_target_property(LIBS_PRIVATE zip LINK_LIBRARIES) | ||
| 539 | foreach(LIB ${LIBS_PRIVATE}) | ||
| 540 | if(LIB MATCHES "^/") | ||
| 541 | get_filename_component(LIB ${LIB} NAME_WE) | ||
| 542 | string(REGEX REPLACE "^lib" "" LIB ${LIB}) | ||
| 543 | endif() | ||
| 544 | set(LIBS "${LIBS} -l${LIB}") | ||
| 545 | endforeach() | ||
| 546 | CONFIGURE_FILE(libzip/libzip.pc.in libzip/libzip.pc @ONLY) | ||
| 547 | INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libzip.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) | ||
| 548 | |||
| 549 | ADD_CUSTOM_TARGET(update_zip_err_str | ||
| 550 | COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/libzip/lib/make_zip_err_str.sh ${CMAKE_CURRENT_SOURCE_DIR}/libzip/lib/zip.h ${CMAKE_CURRENT_SOURCE_DIR}/libzip/lib/zip_err_str.c | ||
| 551 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libzip/lib/zip.h ${CMAKE_CURRENT_SOURCE_DIR}/libzip/lib/make_zip_err_str.sh | ||
| 552 | ) | ||
| 553 | |||
| 554 | IF(SHARED_LIB_VERSIONNING) | ||
| 555 | SET_TARGET_PROPERTIES(zip PROPERTIES VERSION 5.0 SOVERSION 5) | ||
| 556 | ENDIF() | ||
| 557 | |||
| 558 | TARGET_LINK_LIBRARIES(zip ${ZLIB_LIBRARIES} ${OPTIONAL_LIBRARY}) | ||
| 559 | INSTALL(TARGETS zip | ||
| 560 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
| 561 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
| 562 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
| 563 | ) | ||
| 564 | |||
diff --git a/externals/libzip/libzip b/externals/libzip/libzip deleted file mode 160000 | |||
| Subproject 89bd6d63bdea9da7627695f6c82e54f16d368b5 | |||
diff --git a/src/audio_core/command_generator.cpp b/src/audio_core/command_generator.cpp index 45b2eef52..830af46ad 100644 --- a/src/audio_core/command_generator.cpp +++ b/src/audio_core/command_generator.cpp | |||
| @@ -2,13 +2,16 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | ||
| 5 | #include <cmath> | 6 | #include <cmath> |
| 6 | #include <numbers> | 7 | #include <numbers> |
| 8 | |||
| 7 | #include "audio_core/algorithm/interpolate.h" | 9 | #include "audio_core/algorithm/interpolate.h" |
| 8 | #include "audio_core/command_generator.h" | 10 | #include "audio_core/command_generator.h" |
| 9 | #include "audio_core/effect_context.h" | 11 | #include "audio_core/effect_context.h" |
| 10 | #include "audio_core/mix_context.h" | 12 | #include "audio_core/mix_context.h" |
| 11 | #include "audio_core/voice_context.h" | 13 | #include "audio_core/voice_context.h" |
| 14 | #include "common/common_types.h" | ||
| 12 | #include "core/memory.h" | 15 | #include "core/memory.h" |
| 13 | 16 | ||
| 14 | namespace AudioCore { | 17 | namespace AudioCore { |
diff --git a/src/audio_core/mix_context.cpp b/src/audio_core/mix_context.cpp index 4bca72eb0..057aab5ad 100644 --- a/src/audio_core/mix_context.cpp +++ b/src/audio_core/mix_context.cpp | |||
| @@ -2,6 +2,8 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | ||
| 6 | |||
| 5 | #include "audio_core/behavior_info.h" | 7 | #include "audio_core/behavior_info.h" |
| 6 | #include "audio_core/common.h" | 8 | #include "audio_core/common.h" |
| 7 | #include "audio_core/effect_context.h" | 9 | #include "audio_core/effect_context.h" |
diff --git a/src/audio_core/voice_context.cpp b/src/audio_core/voice_context.cpp index d8c954b60..75012a887 100644 --- a/src/audio_core/voice_context.cpp +++ b/src/audio_core/voice_context.cpp | |||
| @@ -2,6 +2,8 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | ||
| 6 | |||
| 5 | #include "audio_core/behavior_info.h" | 7 | #include "audio_core/behavior_info.h" |
| 6 | #include "audio_core/voice_context.h" | 8 | #include "audio_core/voice_context.h" |
| 7 | #include "core/memory.h" | 9 | #include "core/memory.h" |
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index b18a2a2f5..cb5c0f326 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt | |||
| @@ -79,6 +79,7 @@ add_library(common STATIC | |||
| 79 | logging/filter.cpp | 79 | logging/filter.cpp |
| 80 | logging/filter.h | 80 | logging/filter.h |
| 81 | logging/log.h | 81 | logging/log.h |
| 82 | logging/log_entry.h | ||
| 82 | logging/text_formatter.cpp | 83 | logging/text_formatter.cpp |
| 83 | logging/text_formatter.h | 84 | logging/text_formatter.h |
| 84 | logging/types.h | 85 | logging/types.h |
diff --git a/src/common/alignment.h b/src/common/alignment.h index 32d796ffa..1b56569d1 100644 --- a/src/common/alignment.h +++ b/src/common/alignment.h | |||
| @@ -9,41 +9,48 @@ | |||
| 9 | namespace Common { | 9 | namespace Common { |
| 10 | 10 | ||
| 11 | template <typename T> | 11 | template <typename T> |
| 12 | requires std::is_unsigned_v<T>[[nodiscard]] constexpr T AlignUp(T value, size_t size) { | 12 | requires std::is_unsigned_v<T> |
| 13 | [[nodiscard]] constexpr T AlignUp(T value, size_t size) { | ||
| 13 | auto mod{static_cast<T>(value % size)}; | 14 | auto mod{static_cast<T>(value % size)}; |
| 14 | value -= mod; | 15 | value -= mod; |
| 15 | return static_cast<T>(mod == T{0} ? value : value + size); | 16 | return static_cast<T>(mod == T{0} ? value : value + size); |
| 16 | } | 17 | } |
| 17 | 18 | ||
| 18 | template <typename T> | 19 | template <typename T> |
| 19 | requires std::is_unsigned_v<T>[[nodiscard]] constexpr T AlignUpLog2(T value, size_t align_log2) { | 20 | requires std::is_unsigned_v<T> |
| 21 | [[nodiscard]] constexpr T AlignUpLog2(T value, size_t align_log2) { | ||
| 20 | return static_cast<T>((value + ((1ULL << align_log2) - 1)) >> align_log2 << align_log2); | 22 | return static_cast<T>((value + ((1ULL << align_log2) - 1)) >> align_log2 << align_log2); |
| 21 | } | 23 | } |
| 22 | 24 | ||
| 23 | template <typename T> | 25 | template <typename T> |
| 24 | requires std::is_unsigned_v<T>[[nodiscard]] constexpr T AlignDown(T value, size_t size) { | 26 | requires std::is_unsigned_v<T> |
| 27 | [[nodiscard]] constexpr T AlignDown(T value, size_t size) { | ||
| 25 | return static_cast<T>(value - value % size); | 28 | return static_cast<T>(value - value % size); |
| 26 | } | 29 | } |
| 27 | 30 | ||
| 28 | template <typename T> | 31 | template <typename T> |
| 29 | requires std::is_unsigned_v<T>[[nodiscard]] constexpr bool Is4KBAligned(T value) { | 32 | requires std::is_unsigned_v<T> |
| 33 | [[nodiscard]] constexpr bool Is4KBAligned(T value) { | ||
| 30 | return (value & 0xFFF) == 0; | 34 | return (value & 0xFFF) == 0; |
| 31 | } | 35 | } |
| 32 | 36 | ||
| 33 | template <typename T> | 37 | template <typename T> |
| 34 | requires std::is_unsigned_v<T>[[nodiscard]] constexpr bool IsWordAligned(T value) { | 38 | requires std::is_unsigned_v<T> |
| 39 | [[nodiscard]] constexpr bool IsWordAligned(T value) { | ||
| 35 | return (value & 0b11) == 0; | 40 | return (value & 0b11) == 0; |
| 36 | } | 41 | } |
| 37 | 42 | ||
| 38 | template <typename T> | 43 | template <typename T> |
| 39 | requires std::is_integral_v<T>[[nodiscard]] constexpr bool IsAligned(T value, size_t alignment) { | 44 | requires std::is_integral_v<T> |
| 45 | [[nodiscard]] constexpr bool IsAligned(T value, size_t alignment) { | ||
| 40 | using U = typename std::make_unsigned_t<T>; | 46 | using U = typename std::make_unsigned_t<T>; |
| 41 | const U mask = static_cast<U>(alignment - 1); | 47 | const U mask = static_cast<U>(alignment - 1); |
| 42 | return (value & mask) == 0; | 48 | return (value & mask) == 0; |
| 43 | } | 49 | } |
| 44 | 50 | ||
| 45 | template <typename T, typename U> | 51 | template <typename T, typename U> |
| 46 | requires std::is_integral_v<T>[[nodiscard]] constexpr T DivideUp(T x, U y) { | 52 | requires std::is_integral_v<T> |
| 53 | [[nodiscard]] constexpr T DivideUp(T x, U y) { | ||
| 47 | return (x + (y - 1)) / y; | 54 | return (x + (y - 1)) / y; |
| 48 | } | 55 | } |
| 49 | 56 | ||
diff --git a/src/common/div_ceil.h b/src/common/div_ceil.h index 95e1489a9..e1db35464 100644 --- a/src/common/div_ceil.h +++ b/src/common/div_ceil.h | |||
| @@ -11,15 +11,15 @@ namespace Common { | |||
| 11 | 11 | ||
| 12 | /// Ceiled integer division. | 12 | /// Ceiled integer division. |
| 13 | template <typename N, typename D> | 13 | template <typename N, typename D> |
| 14 | requires std::is_integral_v<N>&& std::is_unsigned_v<D>[[nodiscard]] constexpr N DivCeil(N number, | 14 | requires std::is_integral_v<N> && std::is_unsigned_v<D> |
| 15 | D divisor) { | 15 | [[nodiscard]] constexpr N DivCeil(N number, D divisor) { |
| 16 | return static_cast<N>((static_cast<D>(number) + divisor - 1) / divisor); | 16 | return static_cast<N>((static_cast<D>(number) + divisor - 1) / divisor); |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | /// Ceiled integer division with logarithmic divisor in base 2 | 19 | /// Ceiled integer division with logarithmic divisor in base 2 |
| 20 | template <typename N, typename D> | 20 | template <typename N, typename D> |
| 21 | requires std::is_integral_v<N>&& std::is_unsigned_v<D>[[nodiscard]] constexpr N DivCeilLog2( | 21 | requires std::is_integral_v<N> && std::is_unsigned_v<D> |
| 22 | N value, D alignment_log2) { | 22 | [[nodiscard]] constexpr N DivCeilLog2(N value, D alignment_log2) { |
| 23 | return static_cast<N>((static_cast<D>(value) + (D(1) << alignment_log2) - 1) >> alignment_log2); | 23 | return static_cast<N>((static_cast<D>(value) + (D(1) << alignment_log2) - 1) >> alignment_log2); |
| 24 | } | 24 | } |
| 25 | 25 | ||
diff --git a/src/common/fs/path_util.cpp b/src/common/fs/path_util.cpp index 43b79bd6d..1bcb897b5 100644 --- a/src/common/fs/path_util.cpp +++ b/src/common/fs/path_util.cpp | |||
| @@ -82,32 +82,35 @@ public: | |||
| 82 | 82 | ||
| 83 | private: | 83 | private: |
| 84 | PathManagerImpl() { | 84 | PathManagerImpl() { |
| 85 | fs::path yuzu_path; | ||
| 86 | fs::path yuzu_path_cache; | ||
| 87 | fs::path yuzu_path_config; | ||
| 88 | |||
| 85 | #ifdef _WIN32 | 89 | #ifdef _WIN32 |
| 86 | auto yuzu_path = GetExeDirectory() / PORTABLE_DIR; | 90 | yuzu_path = GetExeDirectory() / PORTABLE_DIR; |
| 87 | 91 | ||
| 88 | if (!IsDir(yuzu_path)) { | 92 | if (!IsDir(yuzu_path)) { |
| 89 | yuzu_path = GetAppDataRoamingDirectory() / YUZU_DIR; | 93 | yuzu_path = GetAppDataRoamingDirectory() / YUZU_DIR; |
| 90 | } | 94 | } |
| 91 | 95 | ||
| 92 | GenerateYuzuPath(YuzuPath::YuzuDir, yuzu_path); | 96 | yuzu_path_cache = yuzu_path / CACHE_DIR; |
| 93 | GenerateYuzuPath(YuzuPath::CacheDir, yuzu_path / CACHE_DIR); | 97 | yuzu_path_config = yuzu_path / CONFIG_DIR; |
| 94 | GenerateYuzuPath(YuzuPath::ConfigDir, yuzu_path / CONFIG_DIR); | ||
| 95 | #else | 98 | #else |
| 96 | auto yuzu_path = GetCurrentDir() / PORTABLE_DIR; | 99 | yuzu_path = GetCurrentDir() / PORTABLE_DIR; |
| 97 | 100 | ||
| 98 | if (Exists(yuzu_path) && IsDir(yuzu_path)) { | 101 | if (Exists(yuzu_path) && IsDir(yuzu_path)) { |
| 99 | GenerateYuzuPath(YuzuPath::YuzuDir, yuzu_path); | 102 | yuzu_path_cache = yuzu_path / CACHE_DIR; |
| 100 | GenerateYuzuPath(YuzuPath::CacheDir, yuzu_path / CACHE_DIR); | 103 | yuzu_path_config = yuzu_path / CONFIG_DIR; |
| 101 | GenerateYuzuPath(YuzuPath::ConfigDir, yuzu_path / CONFIG_DIR); | ||
| 102 | } else { | 104 | } else { |
| 103 | yuzu_path = GetDataDirectory("XDG_DATA_HOME") / YUZU_DIR; | 105 | yuzu_path = GetDataDirectory("XDG_DATA_HOME") / YUZU_DIR; |
| 104 | 106 | yuzu_path_cache = GetDataDirectory("XDG_CACHE_HOME") / YUZU_DIR; | |
| 105 | GenerateYuzuPath(YuzuPath::YuzuDir, yuzu_path); | 107 | yuzu_path_config = GetDataDirectory("XDG_CONFIG_HOME") / YUZU_DIR; |
| 106 | GenerateYuzuPath(YuzuPath::CacheDir, GetDataDirectory("XDG_CACHE_HOME") / YUZU_DIR); | ||
| 107 | GenerateYuzuPath(YuzuPath::ConfigDir, GetDataDirectory("XDG_CONFIG_HOME") / YUZU_DIR); | ||
| 108 | } | 108 | } |
| 109 | #endif | 109 | #endif |
| 110 | 110 | ||
| 111 | GenerateYuzuPath(YuzuPath::YuzuDir, yuzu_path); | ||
| 112 | GenerateYuzuPath(YuzuPath::CacheDir, yuzu_path_cache); | ||
| 113 | GenerateYuzuPath(YuzuPath::ConfigDir, yuzu_path_config); | ||
| 111 | GenerateYuzuPath(YuzuPath::DumpDir, yuzu_path / DUMP_DIR); | 114 | GenerateYuzuPath(YuzuPath::DumpDir, yuzu_path / DUMP_DIR); |
| 112 | GenerateYuzuPath(YuzuPath::KeysDir, yuzu_path / KEYS_DIR); | 115 | GenerateYuzuPath(YuzuPath::KeysDir, yuzu_path / KEYS_DIR); |
| 113 | GenerateYuzuPath(YuzuPath::LoadDir, yuzu_path / LOAD_DIR); | 116 | GenerateYuzuPath(YuzuPath::LoadDir, yuzu_path / LOAD_DIR); |
diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index 6661244cf..b44a44949 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp | |||
| @@ -314,8 +314,8 @@ private: | |||
| 314 | } | 314 | } |
| 315 | 315 | ||
| 316 | void UntrackPlaceholder(boost::icl::separate_interval_set<size_t>::iterator it) { | 316 | void UntrackPlaceholder(boost::icl::separate_interval_set<size_t>::iterator it) { |
| 317 | placeholders.erase(it); | ||
| 318 | placeholder_host_pointers.erase(it->lower()); | 317 | placeholder_host_pointers.erase(it->lower()); |
| 318 | placeholders.erase(it); | ||
| 319 | } | 319 | } |
| 320 | 320 | ||
| 321 | /// Return true when a given memory region is a "nieche" and the placeholders don't have to be | 321 | /// Return true when a given memory region is a "nieche" and the placeholders don't have to be |
diff --git a/src/common/intrusive_red_black_tree.h b/src/common/intrusive_red_black_tree.h index 1f696fe80..3173cc449 100644 --- a/src/common/intrusive_red_black_tree.h +++ b/src/common/intrusive_red_black_tree.h | |||
| @@ -235,20 +235,19 @@ public: | |||
| 235 | 235 | ||
| 236 | template <typename T> | 236 | template <typename T> |
| 237 | concept HasLightCompareType = requires { | 237 | concept HasLightCompareType = requires { |
| 238 | { std::is_same<typename T::LightCompareType, void>::value } | 238 | { std::is_same<typename T::LightCompareType, void>::value } -> std::convertible_to<bool>; |
| 239 | ->std::convertible_to<bool>; | ||
| 240 | }; | 239 | }; |
| 241 | 240 | ||
| 242 | namespace impl { | 241 | namespace impl { |
| 243 | 242 | ||
| 244 | template <typename T, typename Default> | 243 | template <typename T, typename Default> |
| 245 | consteval auto* GetLightCompareType() { | 244 | consteval auto* GetLightCompareType() { |
| 246 | if constexpr (HasLightCompareType<T>) { | 245 | if constexpr (HasLightCompareType<T>) { |
| 247 | return static_cast<typename T::LightCompareType*>(nullptr); | 246 | return static_cast<typename T::LightCompareType*>(nullptr); |
| 248 | } else { | 247 | } else { |
| 249 | return static_cast<Default*>(nullptr); | 248 | return static_cast<Default*>(nullptr); |
| 249 | } | ||
| 250 | } | 250 | } |
| 251 | } | ||
| 252 | 251 | ||
| 253 | } // namespace impl | 252 | } // namespace impl |
| 254 | 253 | ||
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index e40d117d6..0e85a9c1d 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp | |||
| @@ -9,6 +9,8 @@ | |||
| 9 | #include <thread> | 9 | #include <thread> |
| 10 | #include <vector> | 10 | #include <vector> |
| 11 | 11 | ||
| 12 | #include <fmt/format.h> | ||
| 13 | |||
| 12 | #ifdef _WIN32 | 14 | #ifdef _WIN32 |
| 13 | #include <windows.h> // For OutputDebugStringW | 15 | #include <windows.h> // For OutputDebugStringW |
| 14 | #endif | 16 | #endif |
| @@ -22,6 +24,7 @@ | |||
| 22 | 24 | ||
| 23 | #include "common/logging/backend.h" | 25 | #include "common/logging/backend.h" |
| 24 | #include "common/logging/log.h" | 26 | #include "common/logging/log.h" |
| 27 | #include "common/logging/log_entry.h" | ||
| 25 | #include "common/logging/text_formatter.h" | 28 | #include "common/logging/text_formatter.h" |
| 26 | #include "common/settings.h" | 29 | #include "common/settings.h" |
| 27 | #ifdef _WIN32 | 30 | #ifdef _WIN32 |
diff --git a/src/common/logging/log.h b/src/common/logging/log.h index 8d43eddc7..c186d55ef 100644 --- a/src/common/logging/log.h +++ b/src/common/logging/log.h | |||
| @@ -4,7 +4,11 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <fmt/format.h> | 7 | #include <algorithm> |
| 8 | #include <string_view> | ||
| 9 | |||
| 10 | #include <fmt/core.h> | ||
| 11 | |||
| 8 | #include "common/logging/types.h" | 12 | #include "common/logging/types.h" |
| 9 | 13 | ||
| 10 | namespace Common::Log { | 14 | namespace Common::Log { |
diff --git a/src/common/logging/log_entry.h b/src/common/logging/log_entry.h new file mode 100644 index 000000000..dd6f44841 --- /dev/null +++ b/src/common/logging/log_entry.h | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | // Copyright 2021 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <chrono> | ||
| 8 | |||
| 9 | #include "common/logging/types.h" | ||
| 10 | |||
| 11 | namespace Common::Log { | ||
| 12 | |||
| 13 | /** | ||
| 14 | * A log entry. Log entries are store in a structured format to permit more varied output | ||
| 15 | * formatting on different frontends, as well as facilitating filtering and aggregation. | ||
| 16 | */ | ||
| 17 | struct Entry { | ||
| 18 | std::chrono::microseconds timestamp; | ||
| 19 | Class log_class{}; | ||
| 20 | Level log_level{}; | ||
| 21 | const char* filename = nullptr; | ||
| 22 | unsigned int line_num = 0; | ||
| 23 | std::string function; | ||
| 24 | std::string message; | ||
| 25 | bool final_entry = false; | ||
| 26 | }; | ||
| 27 | |||
| 28 | } // namespace Common::Log | ||
diff --git a/src/common/logging/text_formatter.cpp b/src/common/logging/text_formatter.cpp index cfc0d5846..10b2281db 100644 --- a/src/common/logging/text_formatter.cpp +++ b/src/common/logging/text_formatter.cpp | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | #include "common/common_funcs.h" | 13 | #include "common/common_funcs.h" |
| 14 | #include "common/logging/filter.h" | 14 | #include "common/logging/filter.h" |
| 15 | #include "common/logging/log.h" | 15 | #include "common/logging/log.h" |
| 16 | #include "common/logging/log_entry.h" | ||
| 16 | #include "common/logging/text_formatter.h" | 17 | #include "common/logging/text_formatter.h" |
| 17 | #include "common/string_util.h" | 18 | #include "common/string_util.h" |
| 18 | 19 | ||
diff --git a/src/common/logging/types.h b/src/common/logging/types.h index ddf9d27ca..2d21fc483 100644 --- a/src/common/logging/types.h +++ b/src/common/logging/types.h | |||
| @@ -4,8 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <chrono> | ||
| 8 | |||
| 9 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 10 | 8 | ||
| 11 | namespace Common::Log { | 9 | namespace Common::Log { |
| @@ -131,19 +129,4 @@ enum class Class : u8 { | |||
| 131 | Count ///< Total number of logging classes | 129 | Count ///< Total number of logging classes |
| 132 | }; | 130 | }; |
| 133 | 131 | ||
| 134 | /** | ||
| 135 | * A log entry. Log entries are store in a structured format to permit more varied output | ||
| 136 | * formatting on different frontends, as well as facilitating filtering and aggregation. | ||
| 137 | */ | ||
| 138 | struct Entry { | ||
| 139 | std::chrono::microseconds timestamp; | ||
| 140 | Class log_class{}; | ||
| 141 | Level log_level{}; | ||
| 142 | const char* filename = nullptr; | ||
| 143 | unsigned int line_num = 0; | ||
| 144 | std::string function; | ||
| 145 | std::string message; | ||
| 146 | bool final_entry = false; | ||
| 147 | }; | ||
| 148 | |||
| 149 | } // namespace Common::Log | 132 | } // namespace Common::Log |
diff --git a/src/common/param_package.cpp b/src/common/param_package.cpp index b916b4866..bbf20f5eb 100644 --- a/src/common/param_package.cpp +++ b/src/common/param_package.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <array> | 5 | #include <array> |
| 6 | #include <stdexcept> | ||
| 6 | #include <utility> | 7 | #include <utility> |
| 7 | #include <vector> | 8 | #include <vector> |
| 8 | 9 | ||
diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 69f0bd8c0..9dd5e3efb 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp | |||
| @@ -69,8 +69,6 @@ void LogSettings() { | |||
| 69 | log_path("DataStorage_NANDDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir)); | 69 | log_path("DataStorage_NANDDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir)); |
| 70 | log_path("DataStorage_SDMCDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::SDMCDir)); | 70 | log_path("DataStorage_SDMCDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::SDMCDir)); |
| 71 | log_setting("Debugging_ProgramArgs", values.program_args.GetValue()); | 71 | log_setting("Debugging_ProgramArgs", values.program_args.GetValue()); |
| 72 | log_setting("Services_BCATBackend", values.bcat_backend.GetValue()); | ||
| 73 | log_setting("Services_BCATBoxcatLocal", values.bcat_boxcat_local.GetValue()); | ||
| 74 | log_setting("Input_EnableMotion", values.motion_enabled.GetValue()); | 72 | log_setting("Input_EnableMotion", values.motion_enabled.GetValue()); |
| 75 | log_setting("Input_EnableVibration", values.vibration_enabled.GetValue()); | 73 | log_setting("Input_EnableVibration", values.vibration_enabled.GetValue()); |
| 76 | log_setting("Input_EnableRawInput", values.enable_raw_input.GetValue()); | 74 | log_setting("Input_EnableRawInput", values.enable_raw_input.GetValue()); |
diff --git a/src/common/settings.h b/src/common/settings.h index c53d5acc3..402339443 100644 --- a/src/common/settings.h +++ b/src/common/settings.h | |||
| @@ -568,8 +568,6 @@ struct Values { | |||
| 568 | BasicSetting<bool> use_dev_keys{false, "use_dev_keys"}; | 568 | BasicSetting<bool> use_dev_keys{false, "use_dev_keys"}; |
| 569 | 569 | ||
| 570 | // Network | 570 | // Network |
| 571 | BasicSetting<std::string> bcat_backend{"none", "bcat_backend"}; | ||
| 572 | BasicSetting<bool> bcat_boxcat_local{false, "bcat_boxcat_local"}; | ||
| 573 | BasicSetting<std::string> network_interface{std::string(), "network_interface"}; | 571 | BasicSetting<std::string> network_interface{std::string(), "network_interface"}; |
| 574 | 572 | ||
| 575 | // WebService | 573 | // WebService |
diff --git a/src/common/uuid.h b/src/common/uuid.h index 2353179d8..8ea01f8da 100644 --- a/src/common/uuid.h +++ b/src/common/uuid.h | |||
| @@ -58,6 +58,13 @@ struct UUID { | |||
| 58 | uuid = INVALID_UUID; | 58 | uuid = INVALID_UUID; |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | [[nodiscard]] constexpr bool IsInvalid() const { | ||
| 62 | return uuid == INVALID_UUID; | ||
| 63 | } | ||
| 64 | [[nodiscard]] constexpr bool IsValid() const { | ||
| 65 | return !IsInvalid(); | ||
| 66 | } | ||
| 67 | |||
| 61 | // TODO(ogniK): Properly generate a Nintendo ID | 68 | // TODO(ogniK): Properly generate a Nintendo ID |
| 62 | [[nodiscard]] constexpr u64 GetNintendoID() const { | 69 | [[nodiscard]] constexpr u64 GetNintendoID() const { |
| 63 | return uuid[0]; | 70 | return uuid[0]; |
diff --git a/src/common/vector_math.h b/src/common/vector_math.h index 22dba3c2d..ba7c363c1 100644 --- a/src/common/vector_math.h +++ b/src/common/vector_math.h | |||
| @@ -667,8 +667,8 @@ template <typename T> | |||
| 667 | 667 | ||
| 668 | // linear interpolation via float: 0.0=begin, 1.0=end | 668 | // linear interpolation via float: 0.0=begin, 1.0=end |
| 669 | template <typename X> | 669 | template <typename X> |
| 670 | [[nodiscard]] constexpr decltype(X{} * float{} + X{} * float{}) Lerp(const X& begin, const X& end, | 670 | [[nodiscard]] constexpr decltype(X{} * float{} + X{} * float{}) |
| 671 | const float t) { | 671 | Lerp(const X& begin, const X& end, const float t) { |
| 672 | return begin * (1.f - t) + end * t; | 672 | return begin * (1.f - t) + end * t; |
| 673 | } | 673 | } |
| 674 | 674 | ||
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 7140d0db8..9f0fbba2d 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -106,8 +106,6 @@ add_library(core STATIC | |||
| 106 | file_sys/vfs_concat.h | 106 | file_sys/vfs_concat.h |
| 107 | file_sys/vfs_layered.cpp | 107 | file_sys/vfs_layered.cpp |
| 108 | file_sys/vfs_layered.h | 108 | file_sys/vfs_layered.h |
| 109 | file_sys/vfs_libzip.cpp | ||
| 110 | file_sys/vfs_libzip.h | ||
| 111 | file_sys/vfs_offset.cpp | 109 | file_sys/vfs_offset.cpp |
| 112 | file_sys/vfs_offset.h | 110 | file_sys/vfs_offset.h |
| 113 | file_sys/vfs_real.cpp | 111 | file_sys/vfs_real.cpp |
| @@ -218,6 +216,7 @@ add_library(core STATIC | |||
| 218 | hle/kernel/k_session.h | 216 | hle/kernel/k_session.h |
| 219 | hle/kernel/k_shared_memory.cpp | 217 | hle/kernel/k_shared_memory.cpp |
| 220 | hle/kernel/k_shared_memory.h | 218 | hle/kernel/k_shared_memory.h |
| 219 | hle/kernel/k_shared_memory_info.h | ||
| 221 | hle/kernel/k_slab_heap.h | 220 | hle/kernel/k_slab_heap.h |
| 222 | hle/kernel/k_spin_lock.cpp | 221 | hle/kernel/k_spin_lock.cpp |
| 223 | hle/kernel/k_spin_lock.h | 222 | hle/kernel/k_spin_lock.h |
| @@ -653,13 +652,6 @@ add_library(core STATIC | |||
| 653 | tools/freezer.h | 652 | tools/freezer.h |
| 654 | ) | 653 | ) |
| 655 | 654 | ||
| 656 | if (YUZU_ENABLE_BOXCAT) | ||
| 657 | target_sources(core PRIVATE | ||
| 658 | hle/service/bcat/backend/boxcat.cpp | ||
| 659 | hle/service/bcat/backend/boxcat.h | ||
| 660 | ) | ||
| 661 | endif() | ||
| 662 | |||
| 663 | if (MSVC) | 655 | if (MSVC) |
| 664 | target_compile_options(core PRIVATE | 656 | target_compile_options(core PRIVATE |
| 665 | /we4242 # 'identifier': conversion from 'type1' to 'type2', possible loss of data | 657 | /we4242 # 'identifier': conversion from 'type1' to 'type2', possible loss of data |
| @@ -690,12 +682,7 @@ endif() | |||
| 690 | create_target_directory_groups(core) | 682 | create_target_directory_groups(core) |
| 691 | 683 | ||
| 692 | target_link_libraries(core PUBLIC common PRIVATE audio_core video_core) | 684 | target_link_libraries(core PUBLIC common PRIVATE audio_core video_core) |
| 693 | target_link_libraries(core PUBLIC Boost::boost PRIVATE fmt::fmt nlohmann_json::nlohmann_json mbedtls Opus::Opus zip) | 685 | target_link_libraries(core PUBLIC Boost::boost PRIVATE fmt::fmt nlohmann_json::nlohmann_json mbedtls Opus::Opus) |
| 694 | |||
| 695 | if (YUZU_ENABLE_BOXCAT) | ||
| 696 | target_compile_definitions(core PRIVATE -DYUZU_ENABLE_BOXCAT) | ||
| 697 | target_link_libraries(core PRIVATE httplib nlohmann_json::nlohmann_json) | ||
| 698 | endif() | ||
| 699 | 686 | ||
| 700 | if (ENABLE_WEB_SERVICE) | 687 | if (ENABLE_WEB_SERVICE) |
| 701 | target_compile_definitions(core PRIVATE -DENABLE_WEB_SERVICE) | 688 | target_compile_definitions(core PRIVATE -DENABLE_WEB_SERVICE) |
diff --git a/src/core/core.cpp b/src/core/core.cpp index 54ebed2c1..bb268a319 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -305,7 +305,6 @@ struct System::Impl { | |||
| 305 | is_powered_on = false; | 305 | is_powered_on = false; |
| 306 | exit_lock = false; | 306 | exit_lock = false; |
| 307 | 307 | ||
| 308 | gpu_core.reset(); | ||
| 309 | services.reset(); | 308 | services.reset(); |
| 310 | service_manager.reset(); | 309 | service_manager.reset(); |
| 311 | cheat_engine.reset(); | 310 | cheat_engine.reset(); |
| @@ -315,6 +314,7 @@ struct System::Impl { | |||
| 315 | core_timing.Shutdown(); | 314 | core_timing.Shutdown(); |
| 316 | app_loader.reset(); | 315 | app_loader.reset(); |
| 317 | perf_stats.reset(); | 316 | perf_stats.reset(); |
| 317 | gpu_core.reset(); | ||
| 318 | kernel.Shutdown(); | 318 | kernel.Shutdown(); |
| 319 | memory.Reset(); | 319 | memory.Reset(); |
| 320 | applet_manager.ClearAll(); | 320 | applet_manager.ClearAll(); |
| @@ -421,6 +421,7 @@ struct System::Impl { | |||
| 421 | bool is_async_gpu{}; | 421 | bool is_async_gpu{}; |
| 422 | 422 | ||
| 423 | ExecuteProgramCallback execute_program_callback; | 423 | ExecuteProgramCallback execute_program_callback; |
| 424 | ExitCallback exit_callback; | ||
| 424 | 425 | ||
| 425 | std::array<u64, Core::Hardware::NUM_CPU_CORES> dynarmic_ticks{}; | 426 | std::array<u64, Core::Hardware::NUM_CPU_CORES> dynarmic_ticks{}; |
| 426 | std::array<MicroProfileToken, Core::Hardware::NUM_CPU_CORES> microprofile_dynarmic{}; | 427 | std::array<MicroProfileToken, Core::Hardware::NUM_CPU_CORES> microprofile_dynarmic{}; |
| @@ -798,6 +799,18 @@ void System::ExecuteProgram(std::size_t program_index) { | |||
| 798 | } | 799 | } |
| 799 | } | 800 | } |
| 800 | 801 | ||
| 802 | void System::RegisterExitCallback(ExitCallback&& callback) { | ||
| 803 | impl->exit_callback = std::move(callback); | ||
| 804 | } | ||
| 805 | |||
| 806 | void System::Exit() { | ||
| 807 | if (impl->exit_callback) { | ||
| 808 | impl->exit_callback(); | ||
| 809 | } else { | ||
| 810 | LOG_CRITICAL(Core, "exit_callback must be initialized by the frontend"); | ||
| 811 | } | ||
| 812 | } | ||
| 813 | |||
| 801 | void System::ApplySettings() { | 814 | void System::ApplySettings() { |
| 802 | if (IsPoweredOn()) { | 815 | if (IsPoweredOn()) { |
| 803 | Renderer().RefreshBaseSettings(); | 816 | Renderer().RefreshBaseSettings(); |
diff --git a/src/core/core.h b/src/core/core.h index 715ab88e7..a796472b2 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
| @@ -387,6 +387,18 @@ public: | |||
| 387 | */ | 387 | */ |
| 388 | void ExecuteProgram(std::size_t program_index); | 388 | void ExecuteProgram(std::size_t program_index); |
| 389 | 389 | ||
| 390 | /// Type used for the frontend to designate a callback for System to exit the application. | ||
| 391 | using ExitCallback = std::function<void()>; | ||
| 392 | |||
| 393 | /** | ||
| 394 | * Registers a callback from the frontend for System to exit the application. | ||
| 395 | * @param callback Callback from the frontend to exit the application. | ||
| 396 | */ | ||
| 397 | void RegisterExitCallback(ExitCallback&& callback); | ||
| 398 | |||
| 399 | /// Instructs the frontend to exit the application. | ||
| 400 | void Exit(); | ||
| 401 | |||
| 390 | /// Applies any changes to settings to this core instance. | 402 | /// Applies any changes to settings to this core instance. |
| 391 | void ApplySettings(); | 403 | void ApplySettings(); |
| 392 | 404 | ||
diff --git a/src/core/file_sys/program_metadata.cpp b/src/core/file_sys/program_metadata.cpp index 01ae1a567..35a53d36c 100644 --- a/src/core/file_sys/program_metadata.cpp +++ b/src/core/file_sys/program_metadata.cpp | |||
| @@ -77,7 +77,7 @@ void ProgramMetadata::LoadManual(bool is_64_bit, ProgramAddressSpaceType address | |||
| 77 | aci_header.title_id = title_id; | 77 | aci_header.title_id = title_id; |
| 78 | aci_file_access.permissions = filesystem_permissions; | 78 | aci_file_access.permissions = filesystem_permissions; |
| 79 | npdm_header.system_resource_size = system_resource_size; | 79 | npdm_header.system_resource_size = system_resource_size; |
| 80 | aci_kernel_capabilities = std ::move(capabilities); | 80 | aci_kernel_capabilities = std::move(capabilities); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | bool ProgramMetadata::Is64BitProgram() const { | 83 | bool ProgramMetadata::Is64BitProgram() const { |
diff --git a/src/core/file_sys/vfs_libzip.cpp b/src/core/file_sys/vfs_libzip.cpp deleted file mode 100644 index 00e256779..000000000 --- a/src/core/file_sys/vfs_libzip.cpp +++ /dev/null | |||
| @@ -1,88 +0,0 @@ | |||
| 1 | // Copyright 2019 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <string> | ||
| 6 | |||
| 7 | #ifdef __GNUC__ | ||
| 8 | #pragma GCC diagnostic push | ||
| 9 | #pragma GCC diagnostic ignored "-Wshadow" | ||
| 10 | #endif | ||
| 11 | #include <zip.h> | ||
| 12 | #ifdef __GNUC__ | ||
| 13 | #pragma GCC diagnostic pop | ||
| 14 | #endif | ||
| 15 | |||
| 16 | #include "common/fs/path_util.h" | ||
| 17 | #include "core/file_sys/vfs.h" | ||
| 18 | #include "core/file_sys/vfs_libzip.h" | ||
| 19 | #include "core/file_sys/vfs_vector.h" | ||
| 20 | |||
| 21 | namespace FileSys { | ||
| 22 | |||
| 23 | VirtualDir ExtractZIP(VirtualFile file) { | ||
| 24 | zip_error_t error{}; | ||
| 25 | |||
| 26 | const auto data = file->ReadAllBytes(); | ||
| 27 | std::unique_ptr<zip_source_t, decltype(&zip_source_close)> src{ | ||
| 28 | zip_source_buffer_create(data.data(), data.size(), 0, &error), zip_source_close}; | ||
| 29 | if (src == nullptr) | ||
| 30 | return nullptr; | ||
| 31 | |||
| 32 | std::unique_ptr<zip_t, decltype(&zip_close)> zip{zip_open_from_source(src.get(), 0, &error), | ||
| 33 | zip_close}; | ||
| 34 | if (zip == nullptr) | ||
| 35 | return nullptr; | ||
| 36 | |||
| 37 | std::shared_ptr<VectorVfsDirectory> out = std::make_shared<VectorVfsDirectory>(); | ||
| 38 | |||
| 39 | const auto num_entries = static_cast<std::size_t>(zip_get_num_entries(zip.get(), 0)); | ||
| 40 | |||
| 41 | zip_stat_t stat{}; | ||
| 42 | zip_stat_init(&stat); | ||
| 43 | |||
| 44 | for (std::size_t i = 0; i < num_entries; ++i) { | ||
| 45 | const auto stat_res = zip_stat_index(zip.get(), i, 0, &stat); | ||
| 46 | if (stat_res == -1) | ||
| 47 | return nullptr; | ||
| 48 | |||
| 49 | const std::string name(stat.name); | ||
| 50 | if (name.empty()) | ||
| 51 | continue; | ||
| 52 | |||
| 53 | if (name.back() != '/') { | ||
| 54 | std::unique_ptr<zip_file_t, decltype(&zip_fclose)> file2{ | ||
| 55 | zip_fopen_index(zip.get(), i, 0), zip_fclose}; | ||
| 56 | |||
| 57 | std::vector<u8> buf(stat.size); | ||
| 58 | if (zip_fread(file2.get(), buf.data(), buf.size()) != s64(buf.size())) | ||
| 59 | return nullptr; | ||
| 60 | |||
| 61 | const auto parts = Common::FS::SplitPathComponents(stat.name); | ||
| 62 | const auto new_file = std::make_shared<VectorVfsFile>(buf, parts.back()); | ||
| 63 | |||
| 64 | std::shared_ptr<VectorVfsDirectory> dtrv = out; | ||
| 65 | for (std::size_t j = 0; j < parts.size() - 1; ++j) { | ||
| 66 | if (dtrv == nullptr) | ||
| 67 | return nullptr; | ||
| 68 | const auto subdir = dtrv->GetSubdirectory(parts[j]); | ||
| 69 | if (subdir == nullptr) { | ||
| 70 | const auto temp = std::make_shared<VectorVfsDirectory>( | ||
| 71 | std::vector<VirtualFile>{}, std::vector<VirtualDir>{}, parts[j]); | ||
| 72 | dtrv->AddDirectory(temp); | ||
| 73 | dtrv = temp; | ||
| 74 | } else { | ||
| 75 | dtrv = std::dynamic_pointer_cast<VectorVfsDirectory>(subdir); | ||
| 76 | } | ||
| 77 | } | ||
| 78 | |||
| 79 | if (dtrv == nullptr) | ||
| 80 | return nullptr; | ||
| 81 | dtrv->AddFile(new_file); | ||
| 82 | } | ||
| 83 | } | ||
| 84 | |||
| 85 | return out; | ||
| 86 | } | ||
| 87 | |||
| 88 | } // namespace FileSys | ||
diff --git a/src/core/file_sys/vfs_libzip.h b/src/core/file_sys/vfs_libzip.h deleted file mode 100644 index f68af576a..000000000 --- a/src/core/file_sys/vfs_libzip.h +++ /dev/null | |||
| @@ -1,13 +0,0 @@ | |||
| 1 | // Copyright 2019 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "core/file_sys/vfs_types.h" | ||
| 8 | |||
| 9 | namespace FileSys { | ||
| 10 | |||
| 11 | VirtualDir ExtractZIP(VirtualFile zip); | ||
| 12 | |||
| 13 | } // namespace FileSys | ||
diff --git a/src/core/frontend/applets/profile_select.cpp b/src/core/frontend/applets/profile_select.cpp index 4c58c310f..3e4f90be2 100644 --- a/src/core/frontend/applets/profile_select.cpp +++ b/src/core/frontend/applets/profile_select.cpp | |||
| @@ -13,7 +13,8 @@ ProfileSelectApplet::~ProfileSelectApplet() = default; | |||
| 13 | void DefaultProfileSelectApplet::SelectProfile( | 13 | void DefaultProfileSelectApplet::SelectProfile( |
| 14 | std::function<void(std::optional<Common::UUID>)> callback) const { | 14 | std::function<void(std::optional<Common::UUID>)> callback) const { |
| 15 | Service::Account::ProfileManager manager; | 15 | Service::Account::ProfileManager manager; |
| 16 | callback(manager.GetUser(Settings::values.current_user.GetValue()).value_or(Common::UUID{})); | 16 | callback(manager.GetUser(Settings::values.current_user.GetValue()) |
| 17 | .value_or(Common::UUID{Common::INVALID_UUID})); | ||
| 17 | LOG_INFO(Service_ACC, "called, selecting current user instead of prompting..."); | 18 | LOG_INFO(Service_ACC, "called, selecting current user instead of prompting..."); |
| 18 | } | 19 | } |
| 19 | 20 | ||
diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h index ceff2532d..cf204f570 100644 --- a/src/core/hle/ipc_helpers.h +++ b/src/core/hle/ipc_helpers.h | |||
| @@ -4,17 +4,14 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | ||
| 8 | #include <cstring> | 7 | #include <cstring> |
| 9 | #include <memory> | 8 | #include <memory> |
| 10 | #include <tuple> | ||
| 11 | #include <type_traits> | 9 | #include <type_traits> |
| 12 | #include <utility> | 10 | #include <utility> |
| 13 | #include "common/assert.h" | 11 | #include "common/assert.h" |
| 14 | #include "common/common_types.h" | 12 | #include "common/common_types.h" |
| 15 | #include "core/hle/ipc.h" | 13 | #include "core/hle/ipc.h" |
| 16 | #include "core/hle/kernel/hle_ipc.h" | 14 | #include "core/hle/kernel/hle_ipc.h" |
| 17 | #include "core/hle/kernel/k_client_port.h" | ||
| 18 | #include "core/hle/kernel/k_process.h" | 15 | #include "core/hle/kernel/k_process.h" |
| 19 | #include "core/hle/kernel/k_resource_limit.h" | 16 | #include "core/hle/kernel/k_resource_limit.h" |
| 20 | #include "core/hle/kernel/k_session.h" | 17 | #include "core/hle/kernel/k_session.h" |
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index ca68fc325..cee96dd9b 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #include "common/logging/log.h" | 15 | #include "common/logging/log.h" |
| 16 | #include "core/hle/ipc_helpers.h" | 16 | #include "core/hle/ipc_helpers.h" |
| 17 | #include "core/hle/kernel/hle_ipc.h" | 17 | #include "core/hle/kernel/hle_ipc.h" |
| 18 | #include "core/hle/kernel/k_auto_object.h" | ||
| 18 | #include "core/hle/kernel/k_handle_table.h" | 19 | #include "core/hle/kernel/k_handle_table.h" |
| 19 | #include "core/hle/kernel/k_process.h" | 20 | #include "core/hle/kernel/k_process.h" |
| 20 | #include "core/hle/kernel/k_readable_event.h" | 21 | #include "core/hle/kernel/k_readable_event.h" |
diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index a61870f8b..55e6fb9f7 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h | |||
| @@ -17,7 +17,6 @@ | |||
| 17 | #include "common/concepts.h" | 17 | #include "common/concepts.h" |
| 18 | #include "common/swap.h" | 18 | #include "common/swap.h" |
| 19 | #include "core/hle/ipc.h" | 19 | #include "core/hle/ipc.h" |
| 20 | #include "core/hle/kernel/k_auto_object.h" | ||
| 21 | #include "core/hle/kernel/svc_common.h" | 20 | #include "core/hle/kernel/svc_common.h" |
| 22 | 21 | ||
| 23 | union ResultCode; | 22 | union ResultCode; |
| @@ -38,6 +37,7 @@ namespace Kernel { | |||
| 38 | 37 | ||
| 39 | class Domain; | 38 | class Domain; |
| 40 | class HLERequestContext; | 39 | class HLERequestContext; |
| 40 | class KAutoObject; | ||
| 41 | class KernelCore; | 41 | class KernelCore; |
| 42 | class KHandleTable; | 42 | class KHandleTable; |
| 43 | class KProcess; | 43 | class KProcess; |
diff --git a/src/core/hle/kernel/k_auto_object_container.cpp b/src/core/hle/kernel/k_auto_object_container.cpp index 010006bb7..d5f80d5b2 100644 --- a/src/core/hle/kernel/k_auto_object_container.cpp +++ b/src/core/hle/kernel/k_auto_object_container.cpp | |||
| @@ -2,6 +2,8 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | ||
| 6 | |||
| 5 | #include "core/hle/kernel/k_auto_object_container.h" | 7 | #include "core/hle/kernel/k_auto_object_container.h" |
| 6 | 8 | ||
| 7 | namespace Kernel { | 9 | namespace Kernel { |
diff --git a/src/core/hle/kernel/k_handle_table.cpp b/src/core/hle/kernel/k_handle_table.cpp index 6a420d5b0..44d13169f 100644 --- a/src/core/hle/kernel/k_handle_table.cpp +++ b/src/core/hle/kernel/k_handle_table.cpp | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | namespace Kernel { | 7 | namespace Kernel { |
| 8 | 8 | ||
| 9 | KHandleTable::KHandleTable(KernelCore& kernel_) : kernel{kernel_} {} | 9 | KHandleTable::KHandleTable(KernelCore& kernel_) : kernel{kernel_} {} |
| 10 | KHandleTable ::~KHandleTable() = default; | 10 | KHandleTable::~KHandleTable() = default; |
| 11 | 11 | ||
| 12 | ResultCode KHandleTable::Finalize() { | 12 | ResultCode KHandleTable::Finalize() { |
| 13 | // Get the table and clear our record of it. | 13 | // Get the table and clear our record of it. |
diff --git a/src/core/hle/kernel/k_priority_queue.h b/src/core/hle/kernel/k_priority_queue.h index 4aa669d95..f4d71ad7e 100644 --- a/src/core/hle/kernel/k_priority_queue.h +++ b/src/core/hle/kernel/k_priority_queue.h | |||
| @@ -22,12 +22,10 @@ class KThread; | |||
| 22 | 22 | ||
| 23 | template <typename T> | 23 | template <typename T> |
| 24 | concept KPriorityQueueAffinityMask = !std::is_reference_v<T> && requires(T & t) { | 24 | concept KPriorityQueueAffinityMask = !std::is_reference_v<T> && requires(T & t) { |
| 25 | { t.GetAffinityMask() } | 25 | { t.GetAffinityMask() } -> Common::ConvertibleTo<u64>; |
| 26 | ->Common::ConvertibleTo<u64>; | ||
| 27 | {t.SetAffinityMask(0)}; | 26 | {t.SetAffinityMask(0)}; |
| 28 | 27 | ||
| 29 | { t.GetAffinity(0) } | 28 | { t.GetAffinity(0) } -> std::same_as<bool>; |
| 30 | ->std::same_as<bool>; | ||
| 31 | {t.SetAffinity(0, false)}; | 29 | {t.SetAffinity(0, false)}; |
| 32 | {t.SetAll()}; | 30 | {t.SetAll()}; |
| 33 | }; | 31 | }; |
| @@ -38,25 +36,20 @@ concept KPriorityQueueMember = !std::is_reference_v<T> && requires(T & t) { | |||
| 38 | {(typename T::QueueEntry()).Initialize()}; | 36 | {(typename T::QueueEntry()).Initialize()}; |
| 39 | {(typename T::QueueEntry()).SetPrev(std::addressof(t))}; | 37 | {(typename T::QueueEntry()).SetPrev(std::addressof(t))}; |
| 40 | {(typename T::QueueEntry()).SetNext(std::addressof(t))}; | 38 | {(typename T::QueueEntry()).SetNext(std::addressof(t))}; |
| 41 | { (typename T::QueueEntry()).GetNext() } | 39 | { (typename T::QueueEntry()).GetNext() } -> std::same_as<T*>; |
| 42 | ->std::same_as<T*>; | 40 | { (typename T::QueueEntry()).GetPrev() } -> std::same_as<T*>; |
| 43 | { (typename T::QueueEntry()).GetPrev() } | 41 | { t.GetPriorityQueueEntry(0) } -> std::same_as<typename T::QueueEntry&>; |
| 44 | ->std::same_as<T*>; | ||
| 45 | { t.GetPriorityQueueEntry(0) } | ||
| 46 | ->std::same_as<typename T::QueueEntry&>; | ||
| 47 | 42 | ||
| 48 | {t.GetAffinityMask()}; | 43 | {t.GetAffinityMask()}; |
| 49 | { std::remove_cvref_t<decltype(t.GetAffinityMask())>() } | 44 | { std::remove_cvref_t<decltype(t.GetAffinityMask())>() } -> KPriorityQueueAffinityMask; |
| 50 | ->KPriorityQueueAffinityMask; | ||
| 51 | 45 | ||
| 52 | { t.GetActiveCore() } | 46 | { t.GetActiveCore() } -> Common::ConvertibleTo<s32>; |
| 53 | ->Common::ConvertibleTo<s32>; | 47 | { t.GetPriority() } -> Common::ConvertibleTo<s32>; |
| 54 | { t.GetPriority() } | ||
| 55 | ->Common::ConvertibleTo<s32>; | ||
| 56 | }; | 48 | }; |
| 57 | 49 | ||
| 58 | template <typename Member, size_t NumCores_, int LowestPriority, int HighestPriority> | 50 | template <typename Member, size_t NumCores_, int LowestPriority, int HighestPriority> |
| 59 | requires KPriorityQueueMember<Member> class KPriorityQueue { | 51 | requires KPriorityQueueMember<Member> |
| 52 | class KPriorityQueue { | ||
| 60 | public: | 53 | public: |
| 61 | using AffinityMaskType = std::remove_cv_t< | 54 | using AffinityMaskType = std::remove_cv_t< |
| 62 | std::remove_reference_t<decltype(std::declval<Member>().GetAffinityMask())>>; | 55 | std::remove_reference_t<decltype(std::declval<Member>().GetAffinityMask())>>; |
diff --git a/src/core/hle/kernel/k_process.cpp b/src/core/hle/kernel/k_process.cpp index 8ead1a769..211157ccc 100644 --- a/src/core/hle/kernel/k_process.cpp +++ b/src/core/hle/kernel/k_process.cpp | |||
| @@ -23,6 +23,7 @@ | |||
| 23 | #include "core/hle/kernel/k_scheduler.h" | 23 | #include "core/hle/kernel/k_scheduler.h" |
| 24 | #include "core/hle/kernel/k_scoped_resource_reservation.h" | 24 | #include "core/hle/kernel/k_scoped_resource_reservation.h" |
| 25 | #include "core/hle/kernel/k_shared_memory.h" | 25 | #include "core/hle/kernel/k_shared_memory.h" |
| 26 | #include "core/hle/kernel/k_shared_memory_info.h" | ||
| 26 | #include "core/hle/kernel/k_slab_heap.h" | 27 | #include "core/hle/kernel/k_slab_heap.h" |
| 27 | #include "core/hle/kernel/k_thread.h" | 28 | #include "core/hle/kernel/k_thread.h" |
| 28 | #include "core/hle/kernel/kernel.h" | 29 | #include "core/hle/kernel/kernel.h" |
| @@ -254,10 +255,26 @@ ResultCode KProcess::AddSharedMemory(KSharedMemory* shmem, [[maybe_unused]] VAdd | |||
| 254 | // Lock ourselves, to prevent concurrent access. | 255 | // Lock ourselves, to prevent concurrent access. |
| 255 | KScopedLightLock lk(state_lock); | 256 | KScopedLightLock lk(state_lock); |
| 256 | 257 | ||
| 257 | // TODO(bunnei): Manage KSharedMemoryInfo list here. | 258 | // Try to find an existing info for the memory. |
| 259 | KSharedMemoryInfo* shemen_info = nullptr; | ||
| 260 | const auto iter = std::find_if( | ||
| 261 | shared_memory_list.begin(), shared_memory_list.end(), | ||
| 262 | [shmem](const KSharedMemoryInfo* info) { return info->GetSharedMemory() == shmem; }); | ||
| 263 | if (iter != shared_memory_list.end()) { | ||
| 264 | shemen_info = *iter; | ||
| 265 | } | ||
| 266 | |||
| 267 | if (shemen_info == nullptr) { | ||
| 268 | shemen_info = KSharedMemoryInfo::Allocate(kernel); | ||
| 269 | R_UNLESS(shemen_info != nullptr, ResultOutOfMemory); | ||
| 270 | |||
| 271 | shemen_info->Initialize(shmem); | ||
| 272 | shared_memory_list.push_back(shemen_info); | ||
| 273 | } | ||
| 258 | 274 | ||
| 259 | // Open a reference to the shared memory. | 275 | // Open a reference to the shared memory and its info. |
| 260 | shmem->Open(); | 276 | shmem->Open(); |
| 277 | shemen_info->Open(); | ||
| 261 | 278 | ||
| 262 | return ResultSuccess; | 279 | return ResultSuccess; |
| 263 | } | 280 | } |
| @@ -267,7 +284,20 @@ void KProcess::RemoveSharedMemory(KSharedMemory* shmem, [[maybe_unused]] VAddr a | |||
| 267 | // Lock ourselves, to prevent concurrent access. | 284 | // Lock ourselves, to prevent concurrent access. |
| 268 | KScopedLightLock lk(state_lock); | 285 | KScopedLightLock lk(state_lock); |
| 269 | 286 | ||
| 270 | // TODO(bunnei): Manage KSharedMemoryInfo list here. | 287 | KSharedMemoryInfo* shemen_info = nullptr; |
| 288 | const auto iter = std::find_if( | ||
| 289 | shared_memory_list.begin(), shared_memory_list.end(), | ||
| 290 | [shmem](const KSharedMemoryInfo* info) { return info->GetSharedMemory() == shmem; }); | ||
| 291 | if (iter != shared_memory_list.end()) { | ||
| 292 | shemen_info = *iter; | ||
| 293 | } | ||
| 294 | |||
| 295 | ASSERT(shemen_info != nullptr); | ||
| 296 | |||
| 297 | if (shemen_info->Close()) { | ||
| 298 | shared_memory_list.erase(iter); | ||
| 299 | KSharedMemoryInfo::Free(kernel, shemen_info); | ||
| 300 | } | ||
| 271 | 301 | ||
| 272 | // Close a reference to the shared memory. | 302 | // Close a reference to the shared memory. |
| 273 | shmem->Close(); | 303 | shmem->Close(); |
| @@ -412,6 +442,24 @@ void KProcess::Finalize() { | |||
| 412 | // Finalize the handle table and close any open handles. | 442 | // Finalize the handle table and close any open handles. |
| 413 | handle_table.Finalize(); | 443 | handle_table.Finalize(); |
| 414 | 444 | ||
| 445 | // Free all shared memory infos. | ||
| 446 | { | ||
| 447 | auto it = shared_memory_list.begin(); | ||
| 448 | while (it != shared_memory_list.end()) { | ||
| 449 | KSharedMemoryInfo* info = *it; | ||
| 450 | KSharedMemory* shmem = info->GetSharedMemory(); | ||
| 451 | |||
| 452 | while (!info->Close()) { | ||
| 453 | shmem->Close(); | ||
| 454 | } | ||
| 455 | |||
| 456 | shmem->Close(); | ||
| 457 | |||
| 458 | it = shared_memory_list.erase(it); | ||
| 459 | KSharedMemoryInfo::Free(kernel, info); | ||
| 460 | } | ||
| 461 | } | ||
| 462 | |||
| 415 | // Perform inherited finalization. | 463 | // Perform inherited finalization. |
| 416 | KAutoObjectWithSlabHeapAndContainer<KProcess, KSynchronizationObject>::Finalize(); | 464 | KAutoObjectWithSlabHeapAndContainer<KProcess, KSynchronizationObject>::Finalize(); |
| 417 | } | 465 | } |
diff --git a/src/core/hle/kernel/k_process.h b/src/core/hle/kernel/k_process.h index a03c074fb..1a53e2be7 100644 --- a/src/core/hle/kernel/k_process.h +++ b/src/core/hle/kernel/k_process.h | |||
| @@ -34,6 +34,7 @@ class KernelCore; | |||
| 34 | class KPageTable; | 34 | class KPageTable; |
| 35 | class KResourceLimit; | 35 | class KResourceLimit; |
| 36 | class KThread; | 36 | class KThread; |
| 37 | class KSharedMemoryInfo; | ||
| 37 | class TLSPage; | 38 | class TLSPage; |
| 38 | 39 | ||
| 39 | struct CodeSet; | 40 | struct CodeSet; |
| @@ -448,6 +449,9 @@ private: | |||
| 448 | /// List of threads that are running with this process as their owner. | 449 | /// List of threads that are running with this process as their owner. |
| 449 | std::list<const KThread*> thread_list; | 450 | std::list<const KThread*> thread_list; |
| 450 | 451 | ||
| 452 | /// List of shared memory that are running with this process as their owner. | ||
| 453 | std::list<KSharedMemoryInfo*> shared_memory_list; | ||
| 454 | |||
| 451 | /// Address of the top of the main thread's stack | 455 | /// Address of the top of the main thread's stack |
| 452 | VAddr main_thread_stack_top{}; | 456 | VAddr main_thread_stack_top{}; |
| 453 | 457 | ||
diff --git a/src/core/hle/kernel/k_scheduler.h b/src/core/hle/kernel/k_scheduler.h index 12cfae919..c8ccc1ae4 100644 --- a/src/core/hle/kernel/k_scheduler.h +++ b/src/core/hle/kernel/k_scheduler.h | |||
| @@ -197,7 +197,7 @@ private: | |||
| 197 | 197 | ||
| 198 | class [[nodiscard]] KScopedSchedulerLock : KScopedLock<GlobalSchedulerContext::LockType> { | 198 | class [[nodiscard]] KScopedSchedulerLock : KScopedLock<GlobalSchedulerContext::LockType> { |
| 199 | public: | 199 | public: |
| 200 | explicit KScopedSchedulerLock(KernelCore & kernel); | 200 | explicit KScopedSchedulerLock(KernelCore& kernel); |
| 201 | ~KScopedSchedulerLock(); | 201 | ~KScopedSchedulerLock(); |
| 202 | }; | 202 | }; |
| 203 | 203 | ||
diff --git a/src/core/hle/kernel/k_scoped_lock.h b/src/core/hle/kernel/k_scoped_lock.h index 72c3b0252..4fb180fc6 100644 --- a/src/core/hle/kernel/k_scoped_lock.h +++ b/src/core/hle/kernel/k_scoped_lock.h | |||
| @@ -13,19 +13,18 @@ namespace Kernel { | |||
| 13 | 13 | ||
| 14 | template <typename T> | 14 | template <typename T> |
| 15 | concept KLockable = !std::is_reference_v<T> && requires(T & t) { | 15 | concept KLockable = !std::is_reference_v<T> && requires(T & t) { |
| 16 | { t.Lock() } | 16 | { t.Lock() } -> std::same_as<void>; |
| 17 | ->std::same_as<void>; | 17 | { t.Unlock() } -> std::same_as<void>; |
| 18 | { t.Unlock() } | ||
| 19 | ->std::same_as<void>; | ||
| 20 | }; | 18 | }; |
| 21 | 19 | ||
| 22 | template <typename T> | 20 | template <typename T> |
| 23 | requires KLockable<T> class [[nodiscard]] KScopedLock { | 21 | requires KLockable<T> |
| 22 | class [[nodiscard]] KScopedLock { | ||
| 24 | public: | 23 | public: |
| 25 | explicit KScopedLock(T * l) : lock_ptr(l) { | 24 | explicit KScopedLock(T* l) : lock_ptr(l) { |
| 26 | this->lock_ptr->Lock(); | 25 | this->lock_ptr->Lock(); |
| 27 | } | 26 | } |
| 28 | explicit KScopedLock(T & l) : KScopedLock(std::addressof(l)) {} | 27 | explicit KScopedLock(T& l) : KScopedLock(std::addressof(l)) {} |
| 29 | 28 | ||
| 30 | ~KScopedLock() { | 29 | ~KScopedLock() { |
| 31 | this->lock_ptr->Unlock(); | 30 | this->lock_ptr->Unlock(); |
| @@ -34,7 +33,7 @@ public: | |||
| 34 | KScopedLock(const KScopedLock&) = delete; | 33 | KScopedLock(const KScopedLock&) = delete; |
| 35 | KScopedLock& operator=(const KScopedLock&) = delete; | 34 | KScopedLock& operator=(const KScopedLock&) = delete; |
| 36 | 35 | ||
| 37 | KScopedLock(KScopedLock &&) = delete; | 36 | KScopedLock(KScopedLock&&) = delete; |
| 38 | KScopedLock& operator=(KScopedLock&&) = delete; | 37 | KScopedLock& operator=(KScopedLock&&) = delete; |
| 39 | 38 | ||
| 40 | private: | 39 | private: |
diff --git a/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h b/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h index a86af56dd..f6c75f2d9 100644 --- a/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h +++ b/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h | |||
| @@ -17,7 +17,7 @@ namespace Kernel { | |||
| 17 | 17 | ||
| 18 | class [[nodiscard]] KScopedSchedulerLockAndSleep { | 18 | class [[nodiscard]] KScopedSchedulerLockAndSleep { |
| 19 | public: | 19 | public: |
| 20 | explicit KScopedSchedulerLockAndSleep(KernelCore & kernel_, KThread * t, s64 timeout) | 20 | explicit KScopedSchedulerLockAndSleep(KernelCore& kernel_, KThread* t, s64 timeout) |
| 21 | : kernel(kernel_), thread(t), timeout_tick(timeout) { | 21 | : kernel(kernel_), thread(t), timeout_tick(timeout) { |
| 22 | // Lock the scheduler. | 22 | // Lock the scheduler. |
| 23 | kernel.GlobalSchedulerContext().scheduler_lock.Lock(); | 23 | kernel.GlobalSchedulerContext().scheduler_lock.Lock(); |
diff --git a/src/core/hle/kernel/k_shared_memory_info.h b/src/core/hle/kernel/k_shared_memory_info.h new file mode 100644 index 000000000..bf97a0184 --- /dev/null +++ b/src/core/hle/kernel/k_shared_memory_info.h | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | // Copyright 2021 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <memory> | ||
| 8 | #include <string> | ||
| 9 | |||
| 10 | #include <boost/intrusive/list.hpp> | ||
| 11 | |||
| 12 | #include "common/assert.h" | ||
| 13 | #include "core/hle/kernel/slab_helpers.h" | ||
| 14 | |||
| 15 | namespace Kernel { | ||
| 16 | |||
| 17 | class KSharedMemory; | ||
| 18 | |||
| 19 | class KSharedMemoryInfo final : public KSlabAllocated<KSharedMemoryInfo>, | ||
| 20 | public boost::intrusive::list_base_hook<> { | ||
| 21 | |||
| 22 | public: | ||
| 23 | explicit KSharedMemoryInfo() = default; | ||
| 24 | |||
| 25 | constexpr void Initialize(KSharedMemory* shmem) { | ||
| 26 | shared_memory = shmem; | ||
| 27 | } | ||
| 28 | |||
| 29 | constexpr KSharedMemory* GetSharedMemory() const { | ||
| 30 | return shared_memory; | ||
| 31 | } | ||
| 32 | |||
| 33 | constexpr void Open() { | ||
| 34 | ++reference_count; | ||
| 35 | } | ||
| 36 | |||
| 37 | constexpr bool Close() { | ||
| 38 | return (--reference_count) == 0; | ||
| 39 | } | ||
| 40 | |||
| 41 | private: | ||
| 42 | KSharedMemory* shared_memory{}; | ||
| 43 | size_t reference_count{}; | ||
| 44 | }; | ||
| 45 | |||
| 46 | } // namespace Kernel | ||
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 901d43da9..b6658b437 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h | |||
| @@ -49,6 +49,7 @@ class KScheduler; | |||
| 49 | class KServerSession; | 49 | class KServerSession; |
| 50 | class KSession; | 50 | class KSession; |
| 51 | class KSharedMemory; | 51 | class KSharedMemory; |
| 52 | class KSharedMemoryInfo; | ||
| 52 | class KThread; | 53 | class KThread; |
| 53 | class KTransferMemory; | 54 | class KTransferMemory; |
| 54 | class KWritableEvent; | 55 | class KWritableEvent; |
| @@ -309,6 +310,8 @@ public: | |||
| 309 | return slab_heap_container->session; | 310 | return slab_heap_container->session; |
| 310 | } else if constexpr (std::is_same_v<T, KSharedMemory>) { | 311 | } else if constexpr (std::is_same_v<T, KSharedMemory>) { |
| 311 | return slab_heap_container->shared_memory; | 312 | return slab_heap_container->shared_memory; |
| 313 | } else if constexpr (std::is_same_v<T, KSharedMemoryInfo>) { | ||
| 314 | return slab_heap_container->shared_memory_info; | ||
| 312 | } else if constexpr (std::is_same_v<T, KThread>) { | 315 | } else if constexpr (std::is_same_v<T, KThread>) { |
| 313 | return slab_heap_container->thread; | 316 | return slab_heap_container->thread; |
| 314 | } else if constexpr (std::is_same_v<T, KTransferMemory>) { | 317 | } else if constexpr (std::is_same_v<T, KTransferMemory>) { |
| @@ -362,6 +365,7 @@ private: | |||
| 362 | KSlabHeap<KResourceLimit> resource_limit; | 365 | KSlabHeap<KResourceLimit> resource_limit; |
| 363 | KSlabHeap<KSession> session; | 366 | KSlabHeap<KSession> session; |
| 364 | KSlabHeap<KSharedMemory> shared_memory; | 367 | KSlabHeap<KSharedMemory> shared_memory; |
| 368 | KSlabHeap<KSharedMemoryInfo> shared_memory_info; | ||
| 365 | KSlabHeap<KThread> thread; | 369 | KSlabHeap<KThread> thread; |
| 366 | KSlabHeap<KTransferMemory> transfer_memory; | 370 | KSlabHeap<KTransferMemory> transfer_memory; |
| 367 | KSlabHeap<KWritableEvent> writeable_event; | 371 | KSlabHeap<KWritableEvent> writeable_event; |
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 62fb06c45..f98f24a60 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -320,17 +320,19 @@ static ResultCode SendSyncRequest(Core::System& system, Handle handle) { | |||
| 320 | 320 | ||
| 321 | auto& kernel = system.Kernel(); | 321 | auto& kernel = system.Kernel(); |
| 322 | 322 | ||
| 323 | KScopedAutoObject session = | ||
| 324 | kernel.CurrentProcess()->GetHandleTable().GetObject<KClientSession>(handle); | ||
| 325 | R_UNLESS(session.IsNotNull(), ResultInvalidHandle); | ||
| 326 | LOG_TRACE(Kernel_SVC, "called handle=0x{:08X}({})", handle, session->GetName()); | ||
| 327 | |||
| 328 | auto thread = kernel.CurrentScheduler()->GetCurrentThread(); | 323 | auto thread = kernel.CurrentScheduler()->GetCurrentThread(); |
| 329 | { | 324 | { |
| 330 | KScopedSchedulerLock lock(kernel); | 325 | KScopedSchedulerLock lock(kernel); |
| 331 | thread->SetState(ThreadState::Waiting); | 326 | thread->SetState(ThreadState::Waiting); |
| 332 | thread->SetWaitReasonForDebugging(ThreadWaitReasonForDebugging::IPC); | 327 | thread->SetWaitReasonForDebugging(ThreadWaitReasonForDebugging::IPC); |
| 333 | session->SendSyncRequest(thread, system.Memory(), system.CoreTiming()); | 328 | |
| 329 | { | ||
| 330 | KScopedAutoObject session = | ||
| 331 | kernel.CurrentProcess()->GetHandleTable().GetObject<KClientSession>(handle); | ||
| 332 | R_UNLESS(session.IsNotNull(), ResultInvalidHandle); | ||
| 333 | LOG_TRACE(Kernel_SVC, "called handle=0x{:08X}({})", handle, session->GetName()); | ||
| 334 | session->SendSyncRequest(thread, system.Memory(), system.CoreTiming()); | ||
| 335 | } | ||
| 334 | } | 336 | } |
| 335 | 337 | ||
| 336 | KSynchronizationObject* dummy{}; | 338 | KSynchronizationObject* dummy{}; |
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp index 6d9ec0a8a..689b36056 100644 --- a/src/core/hle/service/acc/acc.cpp +++ b/src/core/hle/service/acc/acc.cpp | |||
| @@ -929,8 +929,7 @@ void Module::Interface::TrySelectUserWithoutInteraction(Kernel::HLERequestContex | |||
| 929 | } | 929 | } |
| 930 | 930 | ||
| 931 | const auto user_list = profile_manager->GetAllUsers(); | 931 | const auto user_list = profile_manager->GetAllUsers(); |
| 932 | if (std::all_of(user_list.begin(), user_list.end(), | 932 | if (std::ranges::all_of(user_list, [](const auto& user) { return user.IsInvalid(); })) { |
| 933 | [](const auto& user) { return user.uuid == Common::INVALID_UUID; })) { | ||
| 934 | rb.Push(ResultUnknown); // TODO(ogniK): Find the correct error code | 933 | rb.Push(ResultUnknown); // TODO(ogniK): Find the correct error code |
| 935 | rb.PushRaw<u128>(Common::INVALID_UUID); | 934 | rb.PushRaw<u128>(Common::INVALID_UUID); |
| 936 | return; | 935 | return; |
diff --git a/src/core/hle/service/acc/async_context.cpp b/src/core/hle/service/acc/async_context.cpp index 459323132..a49dfdec7 100644 --- a/src/core/hle/service/acc/async_context.cpp +++ b/src/core/hle/service/acc/async_context.cpp | |||
| @@ -4,15 +4,12 @@ | |||
| 4 | 4 | ||
| 5 | #include "core/core.h" | 5 | #include "core/core.h" |
| 6 | #include "core/hle/ipc_helpers.h" | 6 | #include "core/hle/ipc_helpers.h" |
| 7 | #include "core/hle/kernel/k_event.h" | ||
| 7 | #include "core/hle/service/acc/async_context.h" | 8 | #include "core/hle/service/acc/async_context.h" |
| 8 | 9 | ||
| 9 | namespace Service::Account { | 10 | namespace Service::Account { |
| 10 | IAsyncContext::IAsyncContext(Core::System& system_) | 11 | IAsyncContext::IAsyncContext(Core::System& system_) |
| 11 | : ServiceFramework{system_, "IAsyncContext"}, compeletion_event{system_.Kernel()} { | 12 | : ServiceFramework{system_, "IAsyncContext"}, service_context{system_, "IAsyncContext"} { |
| 12 | |||
| 13 | Kernel::KAutoObject::Create(std::addressof(compeletion_event)); | ||
| 14 | compeletion_event.Initialize("IAsyncContext:CompletionEvent"); | ||
| 15 | |||
| 16 | // clang-format off | 13 | // clang-format off |
| 17 | static const FunctionInfo functions[] = { | 14 | static const FunctionInfo functions[] = { |
| 18 | {0, &IAsyncContext::GetSystemEvent, "GetSystemEvent"}, | 15 | {0, &IAsyncContext::GetSystemEvent, "GetSystemEvent"}, |
| @@ -23,6 +20,12 @@ IAsyncContext::IAsyncContext(Core::System& system_) | |||
| 23 | // clang-format on | 20 | // clang-format on |
| 24 | 21 | ||
| 25 | RegisterHandlers(functions); | 22 | RegisterHandlers(functions); |
| 23 | |||
| 24 | completion_event = service_context.CreateEvent("IAsyncContext:CompletionEvent"); | ||
| 25 | } | ||
| 26 | |||
| 27 | IAsyncContext::~IAsyncContext() { | ||
| 28 | service_context.CloseEvent(completion_event); | ||
| 26 | } | 29 | } |
| 27 | 30 | ||
| 28 | void IAsyncContext::GetSystemEvent(Kernel::HLERequestContext& ctx) { | 31 | void IAsyncContext::GetSystemEvent(Kernel::HLERequestContext& ctx) { |
| @@ -30,7 +33,7 @@ void IAsyncContext::GetSystemEvent(Kernel::HLERequestContext& ctx) { | |||
| 30 | 33 | ||
| 31 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 34 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 32 | rb.Push(ResultSuccess); | 35 | rb.Push(ResultSuccess); |
| 33 | rb.PushCopyObjects(compeletion_event.GetReadableEvent()); | 36 | rb.PushCopyObjects(completion_event->GetReadableEvent()); |
| 34 | } | 37 | } |
| 35 | 38 | ||
| 36 | void IAsyncContext::Cancel(Kernel::HLERequestContext& ctx) { | 39 | void IAsyncContext::Cancel(Kernel::HLERequestContext& ctx) { |
| @@ -62,7 +65,7 @@ void IAsyncContext::GetResult(Kernel::HLERequestContext& ctx) { | |||
| 62 | 65 | ||
| 63 | void IAsyncContext::MarkComplete() { | 66 | void IAsyncContext::MarkComplete() { |
| 64 | is_complete.store(true); | 67 | is_complete.store(true); |
| 65 | compeletion_event.GetWritableEvent().Signal(); | 68 | completion_event->GetWritableEvent().Signal(); |
| 66 | } | 69 | } |
| 67 | 70 | ||
| 68 | } // namespace Service::Account | 71 | } // namespace Service::Account |
diff --git a/src/core/hle/service/acc/async_context.h b/src/core/hle/service/acc/async_context.h index c694b4946..cc3a0a9fe 100644 --- a/src/core/hle/service/acc/async_context.h +++ b/src/core/hle/service/acc/async_context.h | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <atomic> | 7 | #include <atomic> |
| 8 | #include "core/hle/kernel/k_event.h" | 8 | #include "core/hle/service/kernel_helpers.h" |
| 9 | #include "core/hle/service/service.h" | 9 | #include "core/hle/service/service.h" |
| 10 | 10 | ||
| 11 | namespace Core { | 11 | namespace Core { |
| @@ -17,6 +17,7 @@ namespace Service::Account { | |||
| 17 | class IAsyncContext : public ServiceFramework<IAsyncContext> { | 17 | class IAsyncContext : public ServiceFramework<IAsyncContext> { |
| 18 | public: | 18 | public: |
| 19 | explicit IAsyncContext(Core::System& system_); | 19 | explicit IAsyncContext(Core::System& system_); |
| 20 | ~IAsyncContext() override; | ||
| 20 | 21 | ||
| 21 | void GetSystemEvent(Kernel::HLERequestContext& ctx); | 22 | void GetSystemEvent(Kernel::HLERequestContext& ctx); |
| 22 | void Cancel(Kernel::HLERequestContext& ctx); | 23 | void Cancel(Kernel::HLERequestContext& ctx); |
| @@ -30,8 +31,10 @@ protected: | |||
| 30 | 31 | ||
| 31 | void MarkComplete(); | 32 | void MarkComplete(); |
| 32 | 33 | ||
| 34 | KernelHelpers::ServiceContext service_context; | ||
| 35 | |||
| 33 | std::atomic<bool> is_complete{false}; | 36 | std::atomic<bool> is_complete{false}; |
| 34 | Kernel::KEvent compeletion_event; | 37 | Kernel::KEvent* completion_event; |
| 35 | }; | 38 | }; |
| 36 | 39 | ||
| 37 | } // namespace Service::Account | 40 | } // namespace Service::Account |
diff --git a/src/core/hle/service/acc/profile_manager.cpp b/src/core/hle/service/acc/profile_manager.cpp index 24a1c9157..568303ced 100644 --- a/src/core/hle/service/acc/profile_manager.cpp +++ b/src/core/hle/service/acc/profile_manager.cpp | |||
| @@ -208,9 +208,10 @@ bool ProfileManager::UserExists(UUID uuid) const { | |||
| 208 | } | 208 | } |
| 209 | 209 | ||
| 210 | bool ProfileManager::UserExistsIndex(std::size_t index) const { | 210 | bool ProfileManager::UserExistsIndex(std::size_t index) const { |
| 211 | if (index >= MAX_USERS) | 211 | if (index >= MAX_USERS) { |
| 212 | return false; | 212 | return false; |
| 213 | return profiles[index].user_uuid.uuid != Common::INVALID_UUID; | 213 | } |
| 214 | return profiles[index].user_uuid.IsValid(); | ||
| 214 | } | 215 | } |
| 215 | 216 | ||
| 216 | /// Opens a specific user | 217 | /// Opens a specific user |
| @@ -304,7 +305,7 @@ bool ProfileManager::RemoveUser(UUID uuid) { | |||
| 304 | 305 | ||
| 305 | bool ProfileManager::SetProfileBase(UUID uuid, const ProfileBase& profile_new) { | 306 | bool ProfileManager::SetProfileBase(UUID uuid, const ProfileBase& profile_new) { |
| 306 | const auto index = GetUserIndex(uuid); | 307 | const auto index = GetUserIndex(uuid); |
| 307 | if (!index || profile_new.user_uuid == UUID(Common::INVALID_UUID)) { | 308 | if (!index || profile_new.user_uuid.IsInvalid()) { |
| 308 | return false; | 309 | return false; |
| 309 | } | 310 | } |
| 310 | 311 | ||
| @@ -346,7 +347,7 @@ void ProfileManager::ParseUserSaveFile() { | |||
| 346 | } | 347 | } |
| 347 | 348 | ||
| 348 | for (const auto& user : data.users) { | 349 | for (const auto& user : data.users) { |
| 349 | if (user.uuid == UUID(Common::INVALID_UUID)) { | 350 | if (user.uuid.IsInvalid()) { |
| 350 | continue; | 351 | continue; |
| 351 | } | 352 | } |
| 352 | 353 | ||
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index c3ac73131..eccdcc20d 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp | |||
| @@ -16,9 +16,7 @@ | |||
| 16 | #include "core/hle/ipc_helpers.h" | 16 | #include "core/hle/ipc_helpers.h" |
| 17 | #include "core/hle/kernel/k_event.h" | 17 | #include "core/hle/kernel/k_event.h" |
| 18 | #include "core/hle/kernel/k_process.h" | 18 | #include "core/hle/kernel/k_process.h" |
| 19 | #include "core/hle/kernel/k_readable_event.h" | ||
| 20 | #include "core/hle/kernel/k_transfer_memory.h" | 19 | #include "core/hle/kernel/k_transfer_memory.h" |
| 21 | #include "core/hle/kernel/k_writable_event.h" | ||
| 22 | #include "core/hle/kernel/kernel.h" | 20 | #include "core/hle/kernel/kernel.h" |
| 23 | #include "core/hle/service/acc/profile_manager.h" | 21 | #include "core/hle/service/acc/profile_manager.h" |
| 24 | #include "core/hle/service/am/am.h" | 22 | #include "core/hle/service/am/am.h" |
| @@ -254,8 +252,9 @@ IDebugFunctions::IDebugFunctions(Core::System& system_) | |||
| 254 | IDebugFunctions::~IDebugFunctions() = default; | 252 | IDebugFunctions::~IDebugFunctions() = default; |
| 255 | 253 | ||
| 256 | ISelfController::ISelfController(Core::System& system_, NVFlinger::NVFlinger& nvflinger_) | 254 | ISelfController::ISelfController(Core::System& system_, NVFlinger::NVFlinger& nvflinger_) |
| 257 | : ServiceFramework{system_, "ISelfController"}, nvflinger{nvflinger_}, | 255 | : ServiceFramework{system_, "ISelfController"}, nvflinger{nvflinger_}, service_context{ |
| 258 | launchable_event{system.Kernel()}, accumulated_suspended_tick_changed_event{system.Kernel()} { | 256 | system, |
| 257 | "ISelfController"} { | ||
| 259 | // clang-format off | 258 | // clang-format off |
| 260 | static const FunctionInfo functions[] = { | 259 | static const FunctionInfo functions[] = { |
| 261 | {0, &ISelfController::Exit, "Exit"}, | 260 | {0, &ISelfController::Exit, "Exit"}, |
| @@ -275,12 +274,14 @@ ISelfController::ISelfController(Core::System& system_, NVFlinger::NVFlinger& nv | |||
| 275 | {18, nullptr, "SetRequiresCaptureButtonShortPressedMessage"}, | 274 | {18, nullptr, "SetRequiresCaptureButtonShortPressedMessage"}, |
| 276 | {19, &ISelfController::SetAlbumImageOrientation, "SetAlbumImageOrientation"}, | 275 | {19, &ISelfController::SetAlbumImageOrientation, "SetAlbumImageOrientation"}, |
| 277 | {20, nullptr, "SetDesirableKeyboardLayout"}, | 276 | {20, nullptr, "SetDesirableKeyboardLayout"}, |
| 277 | {21, nullptr, "GetScreenShotProgramId"}, | ||
| 278 | {40, &ISelfController::CreateManagedDisplayLayer, "CreateManagedDisplayLayer"}, | 278 | {40, &ISelfController::CreateManagedDisplayLayer, "CreateManagedDisplayLayer"}, |
| 279 | {41, nullptr, "IsSystemBufferSharingEnabled"}, | 279 | {41, nullptr, "IsSystemBufferSharingEnabled"}, |
| 280 | {42, nullptr, "GetSystemSharedLayerHandle"}, | 280 | {42, nullptr, "GetSystemSharedLayerHandle"}, |
| 281 | {43, nullptr, "GetSystemSharedBufferHandle"}, | 281 | {43, nullptr, "GetSystemSharedBufferHandle"}, |
| 282 | {44, &ISelfController::CreateManagedDisplaySeparableLayer, "CreateManagedDisplaySeparableLayer"}, | 282 | {44, &ISelfController::CreateManagedDisplaySeparableLayer, "CreateManagedDisplaySeparableLayer"}, |
| 283 | {45, nullptr, "SetManagedDisplayLayerSeparationMode"}, | 283 | {45, nullptr, "SetManagedDisplayLayerSeparationMode"}, |
| 284 | {46, nullptr, "SetRecordingLayerCompositionEnabled"}, | ||
| 284 | {50, &ISelfController::SetHandlesRequestToDisplay, "SetHandlesRequestToDisplay"}, | 285 | {50, &ISelfController::SetHandlesRequestToDisplay, "SetHandlesRequestToDisplay"}, |
| 285 | {51, nullptr, "ApproveToDisplay"}, | 286 | {51, nullptr, "ApproveToDisplay"}, |
| 286 | {60, nullptr, "OverrideAutoSleepTimeAndDimmingTime"}, | 287 | {60, nullptr, "OverrideAutoSleepTimeAndDimmingTime"}, |
| @@ -302,15 +303,14 @@ ISelfController::ISelfController(Core::System& system_, NVFlinger::NVFlinger& nv | |||
| 302 | {100, &ISelfController::SetAlbumImageTakenNotificationEnabled, "SetAlbumImageTakenNotificationEnabled"}, | 303 | {100, &ISelfController::SetAlbumImageTakenNotificationEnabled, "SetAlbumImageTakenNotificationEnabled"}, |
| 303 | {110, nullptr, "SetApplicationAlbumUserData"}, | 304 | {110, nullptr, "SetApplicationAlbumUserData"}, |
| 304 | {120, nullptr, "SaveCurrentScreenshot"}, | 305 | {120, nullptr, "SaveCurrentScreenshot"}, |
| 306 | {130, nullptr, "SetRecordVolumeMuted"}, | ||
| 305 | {1000, nullptr, "GetDebugStorageChannel"}, | 307 | {1000, nullptr, "GetDebugStorageChannel"}, |
| 306 | }; | 308 | }; |
| 307 | // clang-format on | 309 | // clang-format on |
| 308 | 310 | ||
| 309 | RegisterHandlers(functions); | 311 | RegisterHandlers(functions); |
| 310 | 312 | ||
| 311 | Kernel::KAutoObject::Create(std::addressof(launchable_event)); | 313 | launchable_event = service_context.CreateEvent("ISelfController:LaunchableEvent"); |
| 312 | |||
| 313 | launchable_event.Initialize("ISelfController:LaunchableEvent"); | ||
| 314 | 314 | ||
| 315 | // This event is created by AM on the first time GetAccumulatedSuspendedTickChangedEvent() is | 315 | // This event is created by AM on the first time GetAccumulatedSuspendedTickChangedEvent() is |
| 316 | // called. Yuzu can just create it unconditionally, since it doesn't need to support multiple | 316 | // called. Yuzu can just create it unconditionally, since it doesn't need to support multiple |
| @@ -318,21 +318,23 @@ ISelfController::ISelfController(Core::System& system_, NVFlinger::NVFlinger& nv | |||
| 318 | // suspended if the event has previously been created by a call to | 318 | // suspended if the event has previously been created by a call to |
| 319 | // GetAccumulatedSuspendedTickChangedEvent. | 319 | // GetAccumulatedSuspendedTickChangedEvent. |
| 320 | 320 | ||
| 321 | Kernel::KAutoObject::Create(std::addressof(accumulated_suspended_tick_changed_event)); | 321 | accumulated_suspended_tick_changed_event = |
| 322 | accumulated_suspended_tick_changed_event.Initialize( | 322 | service_context.CreateEvent("ISelfController:AccumulatedSuspendedTickChangedEvent"); |
| 323 | "ISelfController:AccumulatedSuspendedTickChangedEvent"); | 323 | accumulated_suspended_tick_changed_event->GetWritableEvent().Signal(); |
| 324 | accumulated_suspended_tick_changed_event.GetWritableEvent().Signal(); | ||
| 325 | } | 324 | } |
| 326 | 325 | ||
| 327 | ISelfController::~ISelfController() = default; | 326 | ISelfController::~ISelfController() { |
| 327 | service_context.CloseEvent(launchable_event); | ||
| 328 | service_context.CloseEvent(accumulated_suspended_tick_changed_event); | ||
| 329 | } | ||
| 328 | 330 | ||
| 329 | void ISelfController::Exit(Kernel::HLERequestContext& ctx) { | 331 | void ISelfController::Exit(Kernel::HLERequestContext& ctx) { |
| 330 | LOG_DEBUG(Service_AM, "called"); | 332 | LOG_DEBUG(Service_AM, "called"); |
| 331 | 333 | ||
| 332 | system.Shutdown(); | ||
| 333 | |||
| 334 | IPC::ResponseBuilder rb{ctx, 2}; | 334 | IPC::ResponseBuilder rb{ctx, 2}; |
| 335 | rb.Push(ResultSuccess); | 335 | rb.Push(ResultSuccess); |
| 336 | |||
| 337 | system.Exit(); | ||
| 336 | } | 338 | } |
| 337 | 339 | ||
| 338 | void ISelfController::LockExit(Kernel::HLERequestContext& ctx) { | 340 | void ISelfController::LockExit(Kernel::HLERequestContext& ctx) { |
| @@ -380,11 +382,11 @@ void ISelfController::LeaveFatalSection(Kernel::HLERequestContext& ctx) { | |||
| 380 | void ISelfController::GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx) { | 382 | void ISelfController::GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx) { |
| 381 | LOG_WARNING(Service_AM, "(STUBBED) called"); | 383 | LOG_WARNING(Service_AM, "(STUBBED) called"); |
| 382 | 384 | ||
| 383 | launchable_event.GetWritableEvent().Signal(); | 385 | launchable_event->GetWritableEvent().Signal(); |
| 384 | 386 | ||
| 385 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 387 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 386 | rb.Push(ResultSuccess); | 388 | rb.Push(ResultSuccess); |
| 387 | rb.PushCopyObjects(launchable_event.GetReadableEvent()); | 389 | rb.PushCopyObjects(launchable_event->GetReadableEvent()); |
| 388 | } | 390 | } |
| 389 | 391 | ||
| 390 | void ISelfController::SetScreenShotPermission(Kernel::HLERequestContext& ctx) { | 392 | void ISelfController::SetScreenShotPermission(Kernel::HLERequestContext& ctx) { |
| @@ -563,7 +565,7 @@ void ISelfController::GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequest | |||
| 563 | 565 | ||
| 564 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 566 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 565 | rb.Push(ResultSuccess); | 567 | rb.Push(ResultSuccess); |
| 566 | rb.PushCopyObjects(accumulated_suspended_tick_changed_event.GetReadableEvent()); | 568 | rb.PushCopyObjects(accumulated_suspended_tick_changed_event->GetReadableEvent()); |
| 567 | } | 569 | } |
| 568 | 570 | ||
| 569 | void ISelfController::SetAlbumImageTakenNotificationEnabled(Kernel::HLERequestContext& ctx) { | 571 | void ISelfController::SetAlbumImageTakenNotificationEnabled(Kernel::HLERequestContext& ctx) { |
| @@ -581,40 +583,39 @@ void ISelfController::SetAlbumImageTakenNotificationEnabled(Kernel::HLERequestCo | |||
| 581 | rb.Push(ResultSuccess); | 583 | rb.Push(ResultSuccess); |
| 582 | } | 584 | } |
| 583 | 585 | ||
| 584 | AppletMessageQueue::AppletMessageQueue(Kernel::KernelCore& kernel) | 586 | AppletMessageQueue::AppletMessageQueue(Core::System& system) |
| 585 | : on_new_message{kernel}, on_operation_mode_changed{kernel} { | 587 | : service_context{system, "AppletMessageQueue"} { |
| 586 | 588 | on_new_message = service_context.CreateEvent("AMMessageQueue:OnMessageReceived"); | |
| 587 | Kernel::KAutoObject::Create(std::addressof(on_new_message)); | 589 | on_operation_mode_changed = service_context.CreateEvent("AMMessageQueue:OperationModeChanged"); |
| 588 | Kernel::KAutoObject::Create(std::addressof(on_operation_mode_changed)); | ||
| 589 | |||
| 590 | on_new_message.Initialize("AMMessageQueue:OnMessageReceived"); | ||
| 591 | on_operation_mode_changed.Initialize("AMMessageQueue:OperationModeChanged"); | ||
| 592 | } | 590 | } |
| 593 | 591 | ||
| 594 | AppletMessageQueue::~AppletMessageQueue() = default; | 592 | AppletMessageQueue::~AppletMessageQueue() { |
| 593 | service_context.CloseEvent(on_new_message); | ||
| 594 | service_context.CloseEvent(on_operation_mode_changed); | ||
| 595 | } | ||
| 595 | 596 | ||
| 596 | Kernel::KReadableEvent& AppletMessageQueue::GetMessageReceiveEvent() { | 597 | Kernel::KReadableEvent& AppletMessageQueue::GetMessageReceiveEvent() { |
| 597 | return on_new_message.GetReadableEvent(); | 598 | return on_new_message->GetReadableEvent(); |
| 598 | } | 599 | } |
| 599 | 600 | ||
| 600 | Kernel::KReadableEvent& AppletMessageQueue::GetOperationModeChangedEvent() { | 601 | Kernel::KReadableEvent& AppletMessageQueue::GetOperationModeChangedEvent() { |
| 601 | return on_operation_mode_changed.GetReadableEvent(); | 602 | return on_operation_mode_changed->GetReadableEvent(); |
| 602 | } | 603 | } |
| 603 | 604 | ||
| 604 | void AppletMessageQueue::PushMessage(AppletMessage msg) { | 605 | void AppletMessageQueue::PushMessage(AppletMessage msg) { |
| 605 | messages.push(msg); | 606 | messages.push(msg); |
| 606 | on_new_message.GetWritableEvent().Signal(); | 607 | on_new_message->GetWritableEvent().Signal(); |
| 607 | } | 608 | } |
| 608 | 609 | ||
| 609 | AppletMessageQueue::AppletMessage AppletMessageQueue::PopMessage() { | 610 | AppletMessageQueue::AppletMessage AppletMessageQueue::PopMessage() { |
| 610 | if (messages.empty()) { | 611 | if (messages.empty()) { |
| 611 | on_new_message.GetWritableEvent().Clear(); | 612 | on_new_message->GetWritableEvent().Clear(); |
| 612 | return AppletMessage::NoMessage; | 613 | return AppletMessage::NoMessage; |
| 613 | } | 614 | } |
| 614 | auto msg = messages.front(); | 615 | auto msg = messages.front(); |
| 615 | messages.pop(); | 616 | messages.pop(); |
| 616 | if (messages.empty()) { | 617 | if (messages.empty()) { |
| 617 | on_new_message.GetWritableEvent().Clear(); | 618 | on_new_message->GetWritableEvent().Clear(); |
| 618 | } | 619 | } |
| 619 | return msg; | 620 | return msg; |
| 620 | } | 621 | } |
| @@ -634,7 +635,7 @@ void AppletMessageQueue::FocusStateChanged() { | |||
| 634 | void AppletMessageQueue::OperationModeChanged() { | 635 | void AppletMessageQueue::OperationModeChanged() { |
| 635 | PushMessage(AppletMessage::OperationModeChanged); | 636 | PushMessage(AppletMessage::OperationModeChanged); |
| 636 | PushMessage(AppletMessage::PerformanceModeChanged); | 637 | PushMessage(AppletMessage::PerformanceModeChanged); |
| 637 | on_operation_mode_changed.GetWritableEvent().Signal(); | 638 | on_operation_mode_changed->GetWritableEvent().Signal(); |
| 638 | } | 639 | } |
| 639 | 640 | ||
| 640 | ICommonStateGetter::ICommonStateGetter(Core::System& system_, | 641 | ICommonStateGetter::ICommonStateGetter(Core::System& system_, |
| @@ -683,6 +684,7 @@ ICommonStateGetter::ICommonStateGetter(Core::System& system_, | |||
| 683 | {91, nullptr, "GetCurrentPerformanceConfiguration"}, | 684 | {91, nullptr, "GetCurrentPerformanceConfiguration"}, |
| 684 | {100, nullptr, "SetHandlingHomeButtonShortPressedEnabled"}, | 685 | {100, nullptr, "SetHandlingHomeButtonShortPressedEnabled"}, |
| 685 | {110, nullptr, "OpenMyGpuErrorHandler"}, | 686 | {110, nullptr, "OpenMyGpuErrorHandler"}, |
| 687 | {120, nullptr, "GetAppletLaunchedHistory"}, | ||
| 686 | {200, nullptr, "GetOperationModeSystemInfo"}, | 688 | {200, nullptr, "GetOperationModeSystemInfo"}, |
| 687 | {300, nullptr, "GetSettingsPlatformRegion"}, | 689 | {300, nullptr, "GetSettingsPlatformRegion"}, |
| 688 | {400, nullptr, "ActivateMigrationService"}, | 690 | {400, nullptr, "ActivateMigrationService"}, |
| @@ -1268,10 +1270,8 @@ void ILibraryAppletCreator::CreateHandleStorage(Kernel::HLERequestContext& ctx) | |||
| 1268 | } | 1270 | } |
| 1269 | 1271 | ||
| 1270 | IApplicationFunctions::IApplicationFunctions(Core::System& system_) | 1272 | IApplicationFunctions::IApplicationFunctions(Core::System& system_) |
| 1271 | : ServiceFramework{system_, "IApplicationFunctions"}, gpu_error_detected_event{system.Kernel()}, | 1273 | : ServiceFramework{system_, "IApplicationFunctions"}, service_context{system, |
| 1272 | friend_invitation_storage_channel_event{system.Kernel()}, | 1274 | "IApplicationFunctions"} { |
| 1273 | notification_storage_channel_event{system.Kernel()}, health_warning_disappeared_system_event{ | ||
| 1274 | system.Kernel()} { | ||
| 1275 | // clang-format off | 1275 | // clang-format off |
| 1276 | static const FunctionInfo functions[] = { | 1276 | static const FunctionInfo functions[] = { |
| 1277 | {1, &IApplicationFunctions::PopLaunchParameter, "PopLaunchParameter"}, | 1277 | {1, &IApplicationFunctions::PopLaunchParameter, "PopLaunchParameter"}, |
| @@ -1339,21 +1339,22 @@ IApplicationFunctions::IApplicationFunctions(Core::System& system_) | |||
| 1339 | 1339 | ||
| 1340 | RegisterHandlers(functions); | 1340 | RegisterHandlers(functions); |
| 1341 | 1341 | ||
| 1342 | Kernel::KAutoObject::Create(std::addressof(gpu_error_detected_event)); | 1342 | gpu_error_detected_event = |
| 1343 | Kernel::KAutoObject::Create(std::addressof(friend_invitation_storage_channel_event)); | 1343 | service_context.CreateEvent("IApplicationFunctions:GpuErrorDetectedSystemEvent"); |
| 1344 | Kernel::KAutoObject::Create(std::addressof(notification_storage_channel_event)); | 1344 | friend_invitation_storage_channel_event = |
| 1345 | Kernel::KAutoObject::Create(std::addressof(health_warning_disappeared_system_event)); | 1345 | service_context.CreateEvent("IApplicationFunctions:FriendInvitationStorageChannelEvent"); |
| 1346 | 1346 | notification_storage_channel_event = | |
| 1347 | gpu_error_detected_event.Initialize("IApplicationFunctions:GpuErrorDetectedSystemEvent"); | 1347 | service_context.CreateEvent("IApplicationFunctions:NotificationStorageChannelEvent"); |
| 1348 | friend_invitation_storage_channel_event.Initialize( | 1348 | health_warning_disappeared_system_event = |
| 1349 | "IApplicationFunctions:FriendInvitationStorageChannelEvent"); | 1349 | service_context.CreateEvent("IApplicationFunctions:HealthWarningDisappearedSystemEvent"); |
| 1350 | notification_storage_channel_event.Initialize( | ||
| 1351 | "IApplicationFunctions:NotificationStorageChannelEvent"); | ||
| 1352 | health_warning_disappeared_system_event.Initialize( | ||
| 1353 | "IApplicationFunctions:HealthWarningDisappearedSystemEvent"); | ||
| 1354 | } | 1350 | } |
| 1355 | 1351 | ||
| 1356 | IApplicationFunctions::~IApplicationFunctions() = default; | 1352 | IApplicationFunctions::~IApplicationFunctions() { |
| 1353 | service_context.CloseEvent(gpu_error_detected_event); | ||
| 1354 | service_context.CloseEvent(friend_invitation_storage_channel_event); | ||
| 1355 | service_context.CloseEvent(notification_storage_channel_event); | ||
| 1356 | service_context.CloseEvent(health_warning_disappeared_system_event); | ||
| 1357 | } | ||
| 1357 | 1358 | ||
| 1358 | void IApplicationFunctions::EnableApplicationCrashReport(Kernel::HLERequestContext& ctx) { | 1359 | void IApplicationFunctions::EnableApplicationCrashReport(Kernel::HLERequestContext& ctx) { |
| 1359 | LOG_WARNING(Service_AM, "(STUBBED) called"); | 1360 | LOG_WARNING(Service_AM, "(STUBBED) called"); |
| @@ -1747,7 +1748,7 @@ void IApplicationFunctions::GetGpuErrorDetectedSystemEvent(Kernel::HLERequestCon | |||
| 1747 | 1748 | ||
| 1748 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 1749 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 1749 | rb.Push(ResultSuccess); | 1750 | rb.Push(ResultSuccess); |
| 1750 | rb.PushCopyObjects(gpu_error_detected_event.GetReadableEvent()); | 1751 | rb.PushCopyObjects(gpu_error_detected_event->GetReadableEvent()); |
| 1751 | } | 1752 | } |
| 1752 | 1753 | ||
| 1753 | void IApplicationFunctions::GetFriendInvitationStorageChannelEvent(Kernel::HLERequestContext& ctx) { | 1754 | void IApplicationFunctions::GetFriendInvitationStorageChannelEvent(Kernel::HLERequestContext& ctx) { |
| @@ -1755,7 +1756,7 @@ void IApplicationFunctions::GetFriendInvitationStorageChannelEvent(Kernel::HLERe | |||
| 1755 | 1756 | ||
| 1756 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 1757 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 1757 | rb.Push(ResultSuccess); | 1758 | rb.Push(ResultSuccess); |
| 1758 | rb.PushCopyObjects(friend_invitation_storage_channel_event.GetReadableEvent()); | 1759 | rb.PushCopyObjects(friend_invitation_storage_channel_event->GetReadableEvent()); |
| 1759 | } | 1760 | } |
| 1760 | 1761 | ||
| 1761 | void IApplicationFunctions::TryPopFromFriendInvitationStorageChannel( | 1762 | void IApplicationFunctions::TryPopFromFriendInvitationStorageChannel( |
| @@ -1771,7 +1772,7 @@ void IApplicationFunctions::GetNotificationStorageChannelEvent(Kernel::HLEReques | |||
| 1771 | 1772 | ||
| 1772 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 1773 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 1773 | rb.Push(ResultSuccess); | 1774 | rb.Push(ResultSuccess); |
| 1774 | rb.PushCopyObjects(notification_storage_channel_event.GetReadableEvent()); | 1775 | rb.PushCopyObjects(notification_storage_channel_event->GetReadableEvent()); |
| 1775 | } | 1776 | } |
| 1776 | 1777 | ||
| 1777 | void IApplicationFunctions::GetHealthWarningDisappearedSystemEvent(Kernel::HLERequestContext& ctx) { | 1778 | void IApplicationFunctions::GetHealthWarningDisappearedSystemEvent(Kernel::HLERequestContext& ctx) { |
| @@ -1779,12 +1780,12 @@ void IApplicationFunctions::GetHealthWarningDisappearedSystemEvent(Kernel::HLERe | |||
| 1779 | 1780 | ||
| 1780 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 1781 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 1781 | rb.Push(ResultSuccess); | 1782 | rb.Push(ResultSuccess); |
| 1782 | rb.PushCopyObjects(health_warning_disappeared_system_event.GetReadableEvent()); | 1783 | rb.PushCopyObjects(health_warning_disappeared_system_event->GetReadableEvent()); |
| 1783 | } | 1784 | } |
| 1784 | 1785 | ||
| 1785 | void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nvflinger, | 1786 | void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nvflinger, |
| 1786 | Core::System& system) { | 1787 | Core::System& system) { |
| 1787 | auto message_queue = std::make_shared<AppletMessageQueue>(system.Kernel()); | 1788 | auto message_queue = std::make_shared<AppletMessageQueue>(system); |
| 1788 | // Needed on game boot | 1789 | // Needed on game boot |
| 1789 | message_queue->PushMessage(AppletMessageQueue::AppletMessage::FocusStateChanged); | 1790 | message_queue->PushMessage(AppletMessageQueue::AppletMessage::FocusStateChanged); |
| 1790 | 1791 | ||
| @@ -1797,8 +1798,8 @@ void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger | |||
| 1797 | } | 1798 | } |
| 1798 | 1799 | ||
| 1799 | IHomeMenuFunctions::IHomeMenuFunctions(Core::System& system_) | 1800 | IHomeMenuFunctions::IHomeMenuFunctions(Core::System& system_) |
| 1800 | : ServiceFramework{system_, "IHomeMenuFunctions"}, pop_from_general_channel_event{ | 1801 | : ServiceFramework{system_, "IHomeMenuFunctions"}, service_context{system, |
| 1801 | system.Kernel()} { | 1802 | "IHomeMenuFunctions"} { |
| 1802 | // clang-format off | 1803 | // clang-format off |
| 1803 | static const FunctionInfo functions[] = { | 1804 | static const FunctionInfo functions[] = { |
| 1804 | {10, &IHomeMenuFunctions::RequestToGetForeground, "RequestToGetForeground"}, | 1805 | {10, &IHomeMenuFunctions::RequestToGetForeground, "RequestToGetForeground"}, |
| @@ -1819,11 +1820,13 @@ IHomeMenuFunctions::IHomeMenuFunctions(Core::System& system_) | |||
| 1819 | 1820 | ||
| 1820 | RegisterHandlers(functions); | 1821 | RegisterHandlers(functions); |
| 1821 | 1822 | ||
| 1822 | Kernel::KAutoObject::Create(std::addressof(pop_from_general_channel_event)); | 1823 | pop_from_general_channel_event = |
| 1823 | pop_from_general_channel_event.Initialize("IHomeMenuFunctions:PopFromGeneralChannelEvent"); | 1824 | service_context.CreateEvent("IHomeMenuFunctions:PopFromGeneralChannelEvent"); |
| 1824 | } | 1825 | } |
| 1825 | 1826 | ||
| 1826 | IHomeMenuFunctions::~IHomeMenuFunctions() = default; | 1827 | IHomeMenuFunctions::~IHomeMenuFunctions() { |
| 1828 | service_context.CloseEvent(pop_from_general_channel_event); | ||
| 1829 | } | ||
| 1827 | 1830 | ||
| 1828 | void IHomeMenuFunctions::RequestToGetForeground(Kernel::HLERequestContext& ctx) { | 1831 | void IHomeMenuFunctions::RequestToGetForeground(Kernel::HLERequestContext& ctx) { |
| 1829 | LOG_WARNING(Service_AM, "(STUBBED) called"); | 1832 | LOG_WARNING(Service_AM, "(STUBBED) called"); |
| @@ -1837,7 +1840,7 @@ void IHomeMenuFunctions::GetPopFromGeneralChannelEvent(Kernel::HLERequestContext | |||
| 1837 | 1840 | ||
| 1838 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 1841 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 1839 | rb.Push(ResultSuccess); | 1842 | rb.Push(ResultSuccess); |
| 1840 | rb.PushCopyObjects(pop_from_general_channel_event.GetReadableEvent()); | 1843 | rb.PushCopyObjects(pop_from_general_channel_event->GetReadableEvent()); |
| 1841 | } | 1844 | } |
| 1842 | 1845 | ||
| 1843 | IGlobalStateController::IGlobalStateController(Core::System& system_) | 1846 | IGlobalStateController::IGlobalStateController(Core::System& system_) |
diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index c13aa5787..202d20757 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | #include <memory> | 8 | #include <memory> |
| 9 | #include <queue> | 9 | #include <queue> |
| 10 | 10 | ||
| 11 | #include "core/hle/kernel/k_event.h" | 11 | #include "core/hle/service/kernel_helpers.h" |
| 12 | #include "core/hle/service/service.h" | 12 | #include "core/hle/service/service.h" |
| 13 | 13 | ||
| 14 | namespace Kernel { | 14 | namespace Kernel { |
| @@ -53,7 +53,7 @@ public: | |||
| 53 | PerformanceModeChanged = 31, | 53 | PerformanceModeChanged = 31, |
| 54 | }; | 54 | }; |
| 55 | 55 | ||
| 56 | explicit AppletMessageQueue(Kernel::KernelCore& kernel); | 56 | explicit AppletMessageQueue(Core::System& system); |
| 57 | ~AppletMessageQueue(); | 57 | ~AppletMessageQueue(); |
| 58 | 58 | ||
| 59 | Kernel::KReadableEvent& GetMessageReceiveEvent(); | 59 | Kernel::KReadableEvent& GetMessageReceiveEvent(); |
| @@ -66,9 +66,12 @@ public: | |||
| 66 | void OperationModeChanged(); | 66 | void OperationModeChanged(); |
| 67 | 67 | ||
| 68 | private: | 68 | private: |
| 69 | KernelHelpers::ServiceContext service_context; | ||
| 70 | |||
| 71 | Kernel::KEvent* on_new_message; | ||
| 72 | Kernel::KEvent* on_operation_mode_changed; | ||
| 73 | |||
| 69 | std::queue<AppletMessage> messages; | 74 | std::queue<AppletMessage> messages; |
| 70 | Kernel::KEvent on_new_message; | ||
| 71 | Kernel::KEvent on_operation_mode_changed; | ||
| 72 | }; | 75 | }; |
| 73 | 76 | ||
| 74 | class IWindowController final : public ServiceFramework<IWindowController> { | 77 | class IWindowController final : public ServiceFramework<IWindowController> { |
| @@ -156,8 +159,11 @@ private: | |||
| 156 | }; | 159 | }; |
| 157 | 160 | ||
| 158 | NVFlinger::NVFlinger& nvflinger; | 161 | NVFlinger::NVFlinger& nvflinger; |
| 159 | Kernel::KEvent launchable_event; | 162 | |
| 160 | Kernel::KEvent accumulated_suspended_tick_changed_event; | 163 | KernelHelpers::ServiceContext service_context; |
| 164 | |||
| 165 | Kernel::KEvent* launchable_event; | ||
| 166 | Kernel::KEvent* accumulated_suspended_tick_changed_event; | ||
| 161 | 167 | ||
| 162 | u32 idle_time_detection_extension = 0; | 168 | u32 idle_time_detection_extension = 0; |
| 163 | u64 num_fatal_sections_entered = 0; | 169 | u64 num_fatal_sections_entered = 0; |
| @@ -298,13 +304,15 @@ private: | |||
| 298 | void GetNotificationStorageChannelEvent(Kernel::HLERequestContext& ctx); | 304 | void GetNotificationStorageChannelEvent(Kernel::HLERequestContext& ctx); |
| 299 | void GetHealthWarningDisappearedSystemEvent(Kernel::HLERequestContext& ctx); | 305 | void GetHealthWarningDisappearedSystemEvent(Kernel::HLERequestContext& ctx); |
| 300 | 306 | ||
| 307 | KernelHelpers::ServiceContext service_context; | ||
| 308 | |||
| 301 | bool launch_popped_application_specific = false; | 309 | bool launch_popped_application_specific = false; |
| 302 | bool launch_popped_account_preselect = false; | 310 | bool launch_popped_account_preselect = false; |
| 303 | s32 previous_program_index{-1}; | 311 | s32 previous_program_index{-1}; |
| 304 | Kernel::KEvent gpu_error_detected_event; | 312 | Kernel::KEvent* gpu_error_detected_event; |
| 305 | Kernel::KEvent friend_invitation_storage_channel_event; | 313 | Kernel::KEvent* friend_invitation_storage_channel_event; |
| 306 | Kernel::KEvent notification_storage_channel_event; | 314 | Kernel::KEvent* notification_storage_channel_event; |
| 307 | Kernel::KEvent health_warning_disappeared_system_event; | 315 | Kernel::KEvent* health_warning_disappeared_system_event; |
| 308 | }; | 316 | }; |
| 309 | 317 | ||
| 310 | class IHomeMenuFunctions final : public ServiceFramework<IHomeMenuFunctions> { | 318 | class IHomeMenuFunctions final : public ServiceFramework<IHomeMenuFunctions> { |
| @@ -316,7 +324,9 @@ private: | |||
| 316 | void RequestToGetForeground(Kernel::HLERequestContext& ctx); | 324 | void RequestToGetForeground(Kernel::HLERequestContext& ctx); |
| 317 | void GetPopFromGeneralChannelEvent(Kernel::HLERequestContext& ctx); | 325 | void GetPopFromGeneralChannelEvent(Kernel::HLERequestContext& ctx); |
| 318 | 326 | ||
| 319 | Kernel::KEvent pop_from_general_channel_event; | 327 | KernelHelpers::ServiceContext service_context; |
| 328 | |||
| 329 | Kernel::KEvent* pop_from_general_channel_event; | ||
| 320 | }; | 330 | }; |
| 321 | 331 | ||
| 322 | class IGlobalStateController final : public ServiceFramework<IGlobalStateController> { | 332 | class IGlobalStateController final : public ServiceFramework<IGlobalStateController> { |
diff --git a/src/core/hle/service/am/applet_ae.h b/src/core/hle/service/am/applet_ae.h index adb207349..f89f65649 100644 --- a/src/core/hle/service/am/applet_ae.h +++ b/src/core/hle/service/am/applet_ae.h | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include "core/hle/kernel/hle_ipc.h" | 8 | |
| 9 | #include "core/hle/service/service.h" | 9 | #include "core/hle/service/service.h" |
| 10 | 10 | ||
| 11 | namespace Service { | 11 | namespace Service { |
diff --git a/src/core/hle/service/am/applet_oe.h b/src/core/hle/service/am/applet_oe.h index 6c1aa255a..64b874ead 100644 --- a/src/core/hle/service/am/applet_oe.h +++ b/src/core/hle/service/am/applet_oe.h | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include "core/hle/kernel/hle_ipc.h" | 8 | |
| 9 | #include "core/hle/service/service.h" | 9 | #include "core/hle/service/service.h" |
| 10 | 10 | ||
| 11 | namespace Service { | 11 | namespace Service { |
diff --git a/src/core/hle/service/am/applets/applet_profile_select.cpp b/src/core/hle/service/am/applets/applet_profile_select.cpp index bdc21778e..a6e891944 100644 --- a/src/core/hle/service/am/applets/applet_profile_select.cpp +++ b/src/core/hle/service/am/applets/applet_profile_select.cpp | |||
| @@ -60,7 +60,7 @@ void ProfileSelect::Execute() { | |||
| 60 | void ProfileSelect::SelectionComplete(std::optional<Common::UUID> uuid) { | 60 | void ProfileSelect::SelectionComplete(std::optional<Common::UUID> uuid) { |
| 61 | UserSelectionOutput output{}; | 61 | UserSelectionOutput output{}; |
| 62 | 62 | ||
| 63 | if (uuid.has_value() && uuid->uuid != Common::INVALID_UUID) { | 63 | if (uuid.has_value() && uuid->IsValid()) { |
| 64 | output.result = 0; | 64 | output.result = 0; |
| 65 | output.uuid_selected = uuid->uuid; | 65 | output.uuid_selected = uuid->uuid; |
| 66 | } else { | 66 | } else { |
diff --git a/src/core/hle/service/am/applets/applet_web_browser.cpp b/src/core/hle/service/am/applets/applet_web_browser.cpp index 35f194961..927eeefff 100644 --- a/src/core/hle/service/am/applets/applet_web_browser.cpp +++ b/src/core/hle/service/am/applets/applet_web_browser.cpp | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #include "core/hle/service/am/applets/applet_web_browser.h" | 24 | #include "core/hle/service/am/applets/applet_web_browser.h" |
| 25 | #include "core/hle/service/filesystem/filesystem.h" | 25 | #include "core/hle/service/filesystem/filesystem.h" |
| 26 | #include "core/hle/service/ns/pl_u.h" | 26 | #include "core/hle/service/ns/pl_u.h" |
| 27 | #include "core/loader/loader.h" | ||
| 27 | 28 | ||
| 28 | namespace Service::AM::Applets { | 29 | namespace Service::AM::Applets { |
| 29 | 30 | ||
| @@ -122,6 +123,15 @@ FileSys::VirtualFile GetOfflineRomFS(Core::System& system, u64 title_id, | |||
| 122 | const auto nca = system.GetContentProvider().GetEntry(title_id, nca_type); | 123 | const auto nca = system.GetContentProvider().GetEntry(title_id, nca_type); |
| 123 | 124 | ||
| 124 | if (nca == nullptr) { | 125 | if (nca == nullptr) { |
| 126 | if (nca_type == FileSys::ContentRecordType::HtmlDocument) { | ||
| 127 | LOG_WARNING(Service_AM, "Falling back to AppLoader to get the RomFS."); | ||
| 128 | FileSys::VirtualFile romfs; | ||
| 129 | system.GetAppLoader().ReadManualRomFS(romfs); | ||
| 130 | if (romfs != nullptr) { | ||
| 131 | return romfs; | ||
| 132 | } | ||
| 133 | } | ||
| 134 | |||
| 125 | LOG_ERROR(Service_AM, | 135 | LOG_ERROR(Service_AM, |
| 126 | "NCA of type={} with title_id={:016X} is not found in the ContentProvider!", | 136 | "NCA of type={} with title_id={:016X} is not found in the ContentProvider!", |
| 127 | nca_type, title_id); | 137 | nca_type, title_id); |
diff --git a/src/core/hle/service/am/applets/applets.cpp b/src/core/hle/service/am/applets/applets.cpp index 2b7685d42..7320b1c0f 100644 --- a/src/core/hle/service/am/applets/applets.cpp +++ b/src/core/hle/service/am/applets/applets.cpp | |||
| @@ -12,8 +12,7 @@ | |||
| 12 | #include "core/frontend/applets/profile_select.h" | 12 | #include "core/frontend/applets/profile_select.h" |
| 13 | #include "core/frontend/applets/software_keyboard.h" | 13 | #include "core/frontend/applets/software_keyboard.h" |
| 14 | #include "core/frontend/applets/web_browser.h" | 14 | #include "core/frontend/applets/web_browser.h" |
| 15 | #include "core/hle/kernel/k_readable_event.h" | 15 | #include "core/hle/kernel/k_event.h" |
| 16 | #include "core/hle/kernel/k_writable_event.h" | ||
| 17 | #include "core/hle/service/am/am.h" | 16 | #include "core/hle/service/am/am.h" |
| 18 | #include "core/hle/service/am/applet_ae.h" | 17 | #include "core/hle/service/am/applet_ae.h" |
| 19 | #include "core/hle/service/am/applet_oe.h" | 18 | #include "core/hle/service/am/applet_oe.h" |
| @@ -29,19 +28,19 @@ | |||
| 29 | namespace Service::AM::Applets { | 28 | namespace Service::AM::Applets { |
| 30 | 29 | ||
| 31 | AppletDataBroker::AppletDataBroker(Core::System& system_, LibraryAppletMode applet_mode_) | 30 | AppletDataBroker::AppletDataBroker(Core::System& system_, LibraryAppletMode applet_mode_) |
| 32 | : system{system_}, applet_mode{applet_mode_}, state_changed_event{system.Kernel()}, | 31 | : system{system_}, applet_mode{applet_mode_}, service_context{system, |
| 33 | pop_out_data_event{system.Kernel()}, pop_interactive_out_data_event{system.Kernel()} { | 32 | "ILibraryAppletAccessor"} { |
| 34 | 33 | state_changed_event = service_context.CreateEvent("ILibraryAppletAccessor:StateChangedEvent"); | |
| 35 | Kernel::KAutoObject::Create(std::addressof(state_changed_event)); | 34 | pop_out_data_event = service_context.CreateEvent("ILibraryAppletAccessor:PopDataOutEvent"); |
| 36 | Kernel::KAutoObject::Create(std::addressof(pop_out_data_event)); | 35 | pop_interactive_out_data_event = |
| 37 | Kernel::KAutoObject::Create(std::addressof(pop_interactive_out_data_event)); | 36 | service_context.CreateEvent("ILibraryAppletAccessor:PopInteractiveDataOutEvent"); |
| 38 | |||
| 39 | state_changed_event.Initialize("ILibraryAppletAccessor:StateChangedEvent"); | ||
| 40 | pop_out_data_event.Initialize("ILibraryAppletAccessor:PopDataOutEvent"); | ||
| 41 | pop_interactive_out_data_event.Initialize("ILibraryAppletAccessor:PopInteractiveDataOutEvent"); | ||
| 42 | } | 37 | } |
| 43 | 38 | ||
| 44 | AppletDataBroker::~AppletDataBroker() = default; | 39 | AppletDataBroker::~AppletDataBroker() { |
| 40 | service_context.CloseEvent(state_changed_event); | ||
| 41 | service_context.CloseEvent(pop_out_data_event); | ||
| 42 | service_context.CloseEvent(pop_interactive_out_data_event); | ||
| 43 | } | ||
| 45 | 44 | ||
| 46 | AppletDataBroker::RawChannelData AppletDataBroker::PeekDataToAppletForDebug() const { | 45 | AppletDataBroker::RawChannelData AppletDataBroker::PeekDataToAppletForDebug() const { |
| 47 | std::vector<std::vector<u8>> out_normal; | 46 | std::vector<std::vector<u8>> out_normal; |
| @@ -65,7 +64,7 @@ std::shared_ptr<IStorage> AppletDataBroker::PopNormalDataToGame() { | |||
| 65 | 64 | ||
| 66 | auto out = std::move(out_channel.front()); | 65 | auto out = std::move(out_channel.front()); |
| 67 | out_channel.pop_front(); | 66 | out_channel.pop_front(); |
| 68 | pop_out_data_event.GetWritableEvent().Clear(); | 67 | pop_out_data_event->GetWritableEvent().Clear(); |
| 69 | return out; | 68 | return out; |
| 70 | } | 69 | } |
| 71 | 70 | ||
| @@ -84,7 +83,7 @@ std::shared_ptr<IStorage> AppletDataBroker::PopInteractiveDataToGame() { | |||
| 84 | 83 | ||
| 85 | auto out = std::move(out_interactive_channel.front()); | 84 | auto out = std::move(out_interactive_channel.front()); |
| 86 | out_interactive_channel.pop_front(); | 85 | out_interactive_channel.pop_front(); |
| 87 | pop_interactive_out_data_event.GetWritableEvent().Clear(); | 86 | pop_interactive_out_data_event->GetWritableEvent().Clear(); |
| 88 | return out; | 87 | return out; |
| 89 | } | 88 | } |
| 90 | 89 | ||
| @@ -103,7 +102,7 @@ void AppletDataBroker::PushNormalDataFromGame(std::shared_ptr<IStorage>&& storag | |||
| 103 | 102 | ||
| 104 | void AppletDataBroker::PushNormalDataFromApplet(std::shared_ptr<IStorage>&& storage) { | 103 | void AppletDataBroker::PushNormalDataFromApplet(std::shared_ptr<IStorage>&& storage) { |
| 105 | out_channel.emplace_back(std::move(storage)); | 104 | out_channel.emplace_back(std::move(storage)); |
| 106 | pop_out_data_event.GetWritableEvent().Signal(); | 105 | pop_out_data_event->GetWritableEvent().Signal(); |
| 107 | } | 106 | } |
| 108 | 107 | ||
| 109 | void AppletDataBroker::PushInteractiveDataFromGame(std::shared_ptr<IStorage>&& storage) { | 108 | void AppletDataBroker::PushInteractiveDataFromGame(std::shared_ptr<IStorage>&& storage) { |
| @@ -112,11 +111,11 @@ void AppletDataBroker::PushInteractiveDataFromGame(std::shared_ptr<IStorage>&& s | |||
| 112 | 111 | ||
| 113 | void AppletDataBroker::PushInteractiveDataFromApplet(std::shared_ptr<IStorage>&& storage) { | 112 | void AppletDataBroker::PushInteractiveDataFromApplet(std::shared_ptr<IStorage>&& storage) { |
| 114 | out_interactive_channel.emplace_back(std::move(storage)); | 113 | out_interactive_channel.emplace_back(std::move(storage)); |
| 115 | pop_interactive_out_data_event.GetWritableEvent().Signal(); | 114 | pop_interactive_out_data_event->GetWritableEvent().Signal(); |
| 116 | } | 115 | } |
| 117 | 116 | ||
| 118 | void AppletDataBroker::SignalStateChanged() { | 117 | void AppletDataBroker::SignalStateChanged() { |
| 119 | state_changed_event.GetWritableEvent().Signal(); | 118 | state_changed_event->GetWritableEvent().Signal(); |
| 120 | 119 | ||
| 121 | switch (applet_mode) { | 120 | switch (applet_mode) { |
| 122 | case LibraryAppletMode::AllForeground: | 121 | case LibraryAppletMode::AllForeground: |
| @@ -141,15 +140,15 @@ void AppletDataBroker::SignalStateChanged() { | |||
| 141 | } | 140 | } |
| 142 | 141 | ||
| 143 | Kernel::KReadableEvent& AppletDataBroker::GetNormalDataEvent() { | 142 | Kernel::KReadableEvent& AppletDataBroker::GetNormalDataEvent() { |
| 144 | return pop_out_data_event.GetReadableEvent(); | 143 | return pop_out_data_event->GetReadableEvent(); |
| 145 | } | 144 | } |
| 146 | 145 | ||
| 147 | Kernel::KReadableEvent& AppletDataBroker::GetInteractiveDataEvent() { | 146 | Kernel::KReadableEvent& AppletDataBroker::GetInteractiveDataEvent() { |
| 148 | return pop_interactive_out_data_event.GetReadableEvent(); | 147 | return pop_interactive_out_data_event->GetReadableEvent(); |
| 149 | } | 148 | } |
| 150 | 149 | ||
| 151 | Kernel::KReadableEvent& AppletDataBroker::GetStateChangedEvent() { | 150 | Kernel::KReadableEvent& AppletDataBroker::GetStateChangedEvent() { |
| 152 | return state_changed_event.GetReadableEvent(); | 151 | return state_changed_event->GetReadableEvent(); |
| 153 | } | 152 | } |
| 154 | 153 | ||
| 155 | Applet::Applet(Core::System& system_, LibraryAppletMode applet_mode_) | 154 | Applet::Applet(Core::System& system_, LibraryAppletMode applet_mode_) |
diff --git a/src/core/hle/service/am/applets/applets.h b/src/core/hle/service/am/applets/applets.h index 5c0b4b459..15eeb4ee1 100644 --- a/src/core/hle/service/am/applets/applets.h +++ b/src/core/hle/service/am/applets/applets.h | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | #include <queue> | 8 | #include <queue> |
| 9 | 9 | ||
| 10 | #include "common/swap.h" | 10 | #include "common/swap.h" |
| 11 | #include "core/hle/kernel/k_event.h" | 11 | #include "core/hle/service/kernel_helpers.h" |
| 12 | 12 | ||
| 13 | union ResultCode; | 13 | union ResultCode; |
| 14 | 14 | ||
| @@ -105,6 +105,8 @@ private: | |||
| 105 | Core::System& system; | 105 | Core::System& system; |
| 106 | LibraryAppletMode applet_mode; | 106 | LibraryAppletMode applet_mode; |
| 107 | 107 | ||
| 108 | KernelHelpers::ServiceContext service_context; | ||
| 109 | |||
| 108 | // Queues are named from applet's perspective | 110 | // Queues are named from applet's perspective |
| 109 | 111 | ||
| 110 | // PopNormalDataToApplet and PushNormalDataFromGame | 112 | // PopNormalDataToApplet and PushNormalDataFromGame |
| @@ -119,13 +121,13 @@ private: | |||
| 119 | // PopInteractiveDataToGame and PushInteractiveDataFromApplet | 121 | // PopInteractiveDataToGame and PushInteractiveDataFromApplet |
| 120 | std::deque<std::shared_ptr<IStorage>> out_interactive_channel; | 122 | std::deque<std::shared_ptr<IStorage>> out_interactive_channel; |
| 121 | 123 | ||
| 122 | Kernel::KEvent state_changed_event; | 124 | Kernel::KEvent* state_changed_event; |
| 123 | 125 | ||
| 124 | // Signaled on PushNormalDataFromApplet | 126 | // Signaled on PushNormalDataFromApplet |
| 125 | Kernel::KEvent pop_out_data_event; | 127 | Kernel::KEvent* pop_out_data_event; |
| 126 | 128 | ||
| 127 | // Signaled on PushInteractiveDataFromApplet | 129 | // Signaled on PushInteractiveDataFromApplet |
| 128 | Kernel::KEvent pop_interactive_out_data_event; | 130 | Kernel::KEvent* pop_interactive_out_data_event; |
| 129 | }; | 131 | }; |
| 130 | 132 | ||
| 131 | class Applet { | 133 | class Applet { |
diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp index dd945e058..4c54066c6 100644 --- a/src/core/hle/service/aoc/aoc_u.cpp +++ b/src/core/hle/service/aoc/aoc_u.cpp | |||
| @@ -16,8 +16,8 @@ | |||
| 16 | #include "core/file_sys/patch_manager.h" | 16 | #include "core/file_sys/patch_manager.h" |
| 17 | #include "core/file_sys/registered_cache.h" | 17 | #include "core/file_sys/registered_cache.h" |
| 18 | #include "core/hle/ipc_helpers.h" | 18 | #include "core/hle/ipc_helpers.h" |
| 19 | #include "core/hle/kernel/k_event.h" | ||
| 19 | #include "core/hle/kernel/k_process.h" | 20 | #include "core/hle/kernel/k_process.h" |
| 20 | #include "core/hle/kernel/k_readable_event.h" | ||
| 21 | #include "core/hle/kernel/kernel.h" | 21 | #include "core/hle/kernel/kernel.h" |
| 22 | #include "core/hle/service/aoc/aoc_u.h" | 22 | #include "core/hle/service/aoc/aoc_u.h" |
| 23 | #include "core/loader/loader.h" | 23 | #include "core/loader/loader.h" |
| @@ -49,7 +49,8 @@ static std::vector<u64> AccumulateAOCTitleIDs(Core::System& system) { | |||
| 49 | class IPurchaseEventManager final : public ServiceFramework<IPurchaseEventManager> { | 49 | class IPurchaseEventManager final : public ServiceFramework<IPurchaseEventManager> { |
| 50 | public: | 50 | public: |
| 51 | explicit IPurchaseEventManager(Core::System& system_) | 51 | explicit IPurchaseEventManager(Core::System& system_) |
| 52 | : ServiceFramework{system_, "IPurchaseEventManager"}, purchased_event{system.Kernel()} { | 52 | : ServiceFramework{system_, "IPurchaseEventManager"}, service_context{ |
| 53 | system, "IPurchaseEventManager"} { | ||
| 53 | // clang-format off | 54 | // clang-format off |
| 54 | static const FunctionInfo functions[] = { | 55 | static const FunctionInfo functions[] = { |
| 55 | {0, &IPurchaseEventManager::SetDefaultDeliveryTarget, "SetDefaultDeliveryTarget"}, | 56 | {0, &IPurchaseEventManager::SetDefaultDeliveryTarget, "SetDefaultDeliveryTarget"}, |
| @@ -62,8 +63,11 @@ public: | |||
| 62 | 63 | ||
| 63 | RegisterHandlers(functions); | 64 | RegisterHandlers(functions); |
| 64 | 65 | ||
| 65 | Kernel::KAutoObject::Create(std::addressof(purchased_event)); | 66 | purchased_event = service_context.CreateEvent("IPurchaseEventManager:PurchasedEvent"); |
| 66 | purchased_event.Initialize("IPurchaseEventManager:PurchasedEvent"); | 67 | } |
| 68 | |||
| 69 | ~IPurchaseEventManager() override { | ||
| 70 | service_context.CloseEvent(purchased_event); | ||
| 67 | } | 71 | } |
| 68 | 72 | ||
| 69 | private: | 73 | private: |
| @@ -96,15 +100,17 @@ private: | |||
| 96 | 100 | ||
| 97 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 101 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 98 | rb.Push(ResultSuccess); | 102 | rb.Push(ResultSuccess); |
| 99 | rb.PushCopyObjects(purchased_event.GetReadableEvent()); | 103 | rb.PushCopyObjects(purchased_event->GetReadableEvent()); |
| 100 | } | 104 | } |
| 101 | 105 | ||
| 102 | Kernel::KEvent purchased_event; | 106 | KernelHelpers::ServiceContext service_context; |
| 107 | |||
| 108 | Kernel::KEvent* purchased_event; | ||
| 103 | }; | 109 | }; |
| 104 | 110 | ||
| 105 | AOC_U::AOC_U(Core::System& system_) | 111 | AOC_U::AOC_U(Core::System& system_) |
| 106 | : ServiceFramework{system_, "aoc:u"}, add_on_content{AccumulateAOCTitleIDs(system)}, | 112 | : ServiceFramework{system_, "aoc:u"}, add_on_content{AccumulateAOCTitleIDs(system)}, |
| 107 | aoc_change_event{system.Kernel()} { | 113 | service_context{system_, "aoc:u"} { |
| 108 | // clang-format off | 114 | // clang-format off |
| 109 | static const FunctionInfo functions[] = { | 115 | static const FunctionInfo functions[] = { |
| 110 | {0, nullptr, "CountAddOnContentByApplicationId"}, | 116 | {0, nullptr, "CountAddOnContentByApplicationId"}, |
| @@ -126,11 +132,12 @@ AOC_U::AOC_U(Core::System& system_) | |||
| 126 | 132 | ||
| 127 | RegisterHandlers(functions); | 133 | RegisterHandlers(functions); |
| 128 | 134 | ||
| 129 | Kernel::KAutoObject::Create(std::addressof(aoc_change_event)); | 135 | aoc_change_event = service_context.CreateEvent("GetAddOnContentListChanged:Event"); |
| 130 | aoc_change_event.Initialize("GetAddOnContentListChanged:Event"); | ||
| 131 | } | 136 | } |
| 132 | 137 | ||
| 133 | AOC_U::~AOC_U() = default; | 138 | AOC_U::~AOC_U() { |
| 139 | service_context.CloseEvent(aoc_change_event); | ||
| 140 | } | ||
| 134 | 141 | ||
| 135 | void AOC_U::CountAddOnContent(Kernel::HLERequestContext& ctx) { | 142 | void AOC_U::CountAddOnContent(Kernel::HLERequestContext& ctx) { |
| 136 | struct Parameters { | 143 | struct Parameters { |
| @@ -254,7 +261,7 @@ void AOC_U::GetAddOnContentListChangedEvent(Kernel::HLERequestContext& ctx) { | |||
| 254 | 261 | ||
| 255 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 262 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 256 | rb.Push(ResultSuccess); | 263 | rb.Push(ResultSuccess); |
| 257 | rb.PushCopyObjects(aoc_change_event.GetReadableEvent()); | 264 | rb.PushCopyObjects(aoc_change_event->GetReadableEvent()); |
| 258 | } | 265 | } |
| 259 | 266 | ||
| 260 | void AOC_U::GetAddOnContentListChangedEventWithProcessId(Kernel::HLERequestContext& ctx) { | 267 | void AOC_U::GetAddOnContentListChangedEventWithProcessId(Kernel::HLERequestContext& ctx) { |
| @@ -262,7 +269,7 @@ void AOC_U::GetAddOnContentListChangedEventWithProcessId(Kernel::HLERequestConte | |||
| 262 | 269 | ||
| 263 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 270 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 264 | rb.Push(ResultSuccess); | 271 | rb.Push(ResultSuccess); |
| 265 | rb.PushCopyObjects(aoc_change_event.GetReadableEvent()); | 272 | rb.PushCopyObjects(aoc_change_event->GetReadableEvent()); |
| 266 | } | 273 | } |
| 267 | 274 | ||
| 268 | void AOC_U::CreateEcPurchasedEventManager(Kernel::HLERequestContext& ctx) { | 275 | void AOC_U::CreateEcPurchasedEventManager(Kernel::HLERequestContext& ctx) { |
diff --git a/src/core/hle/service/aoc/aoc_u.h b/src/core/hle/service/aoc/aoc_u.h index bb6ffb8eb..31d645be8 100644 --- a/src/core/hle/service/aoc/aoc_u.h +++ b/src/core/hle/service/aoc/aoc_u.h | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include "core/hle/kernel/k_event.h" | 7 | #include "core/hle/service/kernel_helpers.h" |
| 8 | #include "core/hle/service/service.h" | 8 | #include "core/hle/service/service.h" |
| 9 | 9 | ||
| 10 | namespace Core { | 10 | namespace Core { |
| @@ -33,7 +33,9 @@ private: | |||
| 33 | void CreatePermanentEcPurchasedEventManager(Kernel::HLERequestContext& ctx); | 33 | void CreatePermanentEcPurchasedEventManager(Kernel::HLERequestContext& ctx); |
| 34 | 34 | ||
| 35 | std::vector<u64> add_on_content; | 35 | std::vector<u64> add_on_content; |
| 36 | Kernel::KEvent aoc_change_event; | 36 | KernelHelpers::ServiceContext service_context; |
| 37 | |||
| 38 | Kernel::KEvent* aoc_change_event; | ||
| 37 | }; | 39 | }; |
| 38 | 40 | ||
| 39 | /// Registers all AOC services with the specified service manager. | 41 | /// Registers all AOC services with the specified service manager. |
diff --git a/src/core/hle/service/audio/audctl.cpp b/src/core/hle/service/audio/audctl.cpp index 8c4c49b85..2e46e7161 100644 --- a/src/core/hle/service/audio/audctl.cpp +++ b/src/core/hle/service/audio/audctl.cpp | |||
| @@ -41,6 +41,14 @@ AudCtl::AudCtl(Core::System& system_) : ServiceFramework{system_, "audctl"} { | |||
| 41 | {27, nullptr, "SetVolumeMappingTableForDev"}, | 41 | {27, nullptr, "SetVolumeMappingTableForDev"}, |
| 42 | {28, nullptr, "GetAudioOutputChannelCountForPlayReport"}, | 42 | {28, nullptr, "GetAudioOutputChannelCountForPlayReport"}, |
| 43 | {29, nullptr, "BindAudioOutputChannelCountUpdateEventForPlayReport"}, | 43 | {29, nullptr, "BindAudioOutputChannelCountUpdateEventForPlayReport"}, |
| 44 | {30, nullptr, "Unknown30"}, | ||
| 45 | {31, nullptr, "Unknown31"}, | ||
| 46 | {32, nullptr, "Unknown32"}, | ||
| 47 | {33, nullptr, "Unknown33"}, | ||
| 48 | {34, nullptr, "Unknown34"}, | ||
| 49 | {10000, nullptr, "Unknown10000"}, | ||
| 50 | {10001, nullptr, "Unknown10001"}, | ||
| 51 | {10002, nullptr, "Unknown10002"}, | ||
| 44 | }; | 52 | }; |
| 45 | // clang-format on | 53 | // clang-format on |
| 46 | 54 | ||
diff --git a/src/core/hle/service/audio/audin_u.cpp b/src/core/hle/service/audio/audin_u.cpp index 3e7fd6024..34cc659ed 100644 --- a/src/core/hle/service/audio/audin_u.cpp +++ b/src/core/hle/service/audio/audin_u.cpp | |||
| @@ -3,38 +3,65 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "common/logging/log.h" | 5 | #include "common/logging/log.h" |
| 6 | #include "core/core.h" | ||
| 6 | #include "core/hle/ipc_helpers.h" | 7 | #include "core/hle/ipc_helpers.h" |
| 7 | #include "core/hle/kernel/hle_ipc.h" | 8 | #include "core/hle/kernel/k_event.h" |
| 8 | #include "core/hle/service/audio/audin_u.h" | 9 | #include "core/hle/service/audio/audin_u.h" |
| 9 | 10 | ||
| 10 | namespace Service::Audio { | 11 | namespace Service::Audio { |
| 11 | 12 | ||
| 12 | class IAudioIn final : public ServiceFramework<IAudioIn> { | 13 | IAudioIn::IAudioIn(Core::System& system_) |
| 13 | public: | 14 | : ServiceFramework{system_, "IAudioIn"}, service_context{system_, "IAudioIn"} { |
| 14 | explicit IAudioIn(Core::System& system_) : ServiceFramework{system_, "IAudioIn"} { | 15 | // clang-format off |
| 15 | // clang-format off | 16 | static const FunctionInfo functions[] = { |
| 16 | static const FunctionInfo functions[] = { | 17 | {0, nullptr, "GetAudioInState"}, |
| 17 | {0, nullptr, "GetAudioInState"}, | 18 | {1, &IAudioIn::Start, "Start"}, |
| 18 | {1, nullptr, "Start"}, | 19 | {2, nullptr, "Stop"}, |
| 19 | {2, nullptr, "Stop"}, | 20 | {3, nullptr, "AppendAudioInBuffer"}, |
| 20 | {3, nullptr, "AppendAudioInBuffer"}, | 21 | {4, &IAudioIn::RegisterBufferEvent, "RegisterBufferEvent"}, |
| 21 | {4, nullptr, "RegisterBufferEvent"}, | 22 | {5, nullptr, "GetReleasedAudioInBuffer"}, |
| 22 | {5, nullptr, "GetReleasedAudioInBuffer"}, | 23 | {6, nullptr, "ContainsAudioInBuffer"}, |
| 23 | {6, nullptr, "ContainsAudioInBuffer"}, | 24 | {7, nullptr, "AppendUacInBuffer"}, |
| 24 | {7, nullptr, "AppendUacInBuffer"}, | 25 | {8, &IAudioIn::AppendAudioInBufferAuto, "AppendAudioInBufferAuto"}, |
| 25 | {8, nullptr, "AppendAudioInBufferAuto"}, | 26 | {9, nullptr, "GetReleasedAudioInBuffersAuto"}, |
| 26 | {9, nullptr, "GetReleasedAudioInBuffersAuto"}, | 27 | {10, nullptr, "AppendUacInBufferAuto"}, |
| 27 | {10, nullptr, "AppendUacInBufferAuto"}, | 28 | {11, nullptr, "GetAudioInBufferCount"}, |
| 28 | {11, nullptr, "GetAudioInBufferCount"}, | 29 | {12, nullptr, "SetDeviceGain"}, |
| 29 | {12, nullptr, "SetDeviceGain"}, | 30 | {13, nullptr, "GetDeviceGain"}, |
| 30 | {13, nullptr, "GetDeviceGain"}, | 31 | {14, nullptr, "FlushAudioInBuffers"}, |
| 31 | {14, nullptr, "FlushAudioInBuffers"}, | 32 | }; |
| 32 | }; | 33 | // clang-format on |
| 33 | // clang-format on | 34 | |
| 34 | 35 | RegisterHandlers(functions); | |
| 35 | RegisterHandlers(functions); | 36 | |
| 36 | } | 37 | buffer_event = service_context.CreateEvent("IAudioIn:BufferEvent"); |
| 37 | }; | 38 | } |
| 39 | |||
| 40 | IAudioIn::~IAudioIn() { | ||
| 41 | service_context.CloseEvent(buffer_event); | ||
| 42 | } | ||
| 43 | |||
| 44 | void IAudioIn::Start(Kernel::HLERequestContext& ctx) { | ||
| 45 | LOG_WARNING(Service_Audio, "(STUBBED) called"); | ||
| 46 | |||
| 47 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 48 | rb.Push(ResultSuccess); | ||
| 49 | } | ||
| 50 | |||
| 51 | void IAudioIn::RegisterBufferEvent(Kernel::HLERequestContext& ctx) { | ||
| 52 | LOG_WARNING(Service_Audio, "(STUBBED) called"); | ||
| 53 | |||
| 54 | IPC::ResponseBuilder rb{ctx, 2, 1}; | ||
| 55 | rb.Push(ResultSuccess); | ||
| 56 | rb.PushCopyObjects(buffer_event->GetReadableEvent()); | ||
| 57 | } | ||
| 58 | |||
| 59 | void IAudioIn::AppendAudioInBufferAuto(Kernel::HLERequestContext& ctx) { | ||
| 60 | LOG_WARNING(Service_Audio, "(STUBBED) called"); | ||
| 61 | |||
| 62 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 63 | rb.Push(ResultSuccess); | ||
| 64 | } | ||
| 38 | 65 | ||
| 39 | AudInU::AudInU(Core::System& system_) : ServiceFramework{system_, "audin:u"} { | 66 | AudInU::AudInU(Core::System& system_) : ServiceFramework{system_, "audin:u"} { |
| 40 | // clang-format off | 67 | // clang-format off |
diff --git a/src/core/hle/service/audio/audin_u.h b/src/core/hle/service/audio/audin_u.h index 0d75ae5ac..bf3418613 100644 --- a/src/core/hle/service/audio/audin_u.h +++ b/src/core/hle/service/audio/audin_u.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include "core/hle/service/kernel_helpers.h" | ||
| 7 | #include "core/hle/service/service.h" | 8 | #include "core/hle/service/service.h" |
| 8 | 9 | ||
| 9 | namespace Core { | 10 | namespace Core { |
| @@ -16,6 +17,21 @@ class HLERequestContext; | |||
| 16 | 17 | ||
| 17 | namespace Service::Audio { | 18 | namespace Service::Audio { |
| 18 | 19 | ||
| 20 | class IAudioIn final : public ServiceFramework<IAudioIn> { | ||
| 21 | public: | ||
| 22 | explicit IAudioIn(Core::System& system_); | ||
| 23 | ~IAudioIn() override; | ||
| 24 | |||
| 25 | private: | ||
| 26 | void Start(Kernel::HLERequestContext& ctx); | ||
| 27 | void RegisterBufferEvent(Kernel::HLERequestContext& ctx); | ||
| 28 | void AppendAudioInBufferAuto(Kernel::HLERequestContext& ctx); | ||
| 29 | |||
| 30 | KernelHelpers::ServiceContext service_context; | ||
| 31 | |||
| 32 | Kernel::KEvent* buffer_event; | ||
| 33 | }; | ||
| 34 | |||
| 19 | class AudInU final : public ServiceFramework<AudInU> { | 35 | class AudInU final : public ServiceFramework<AudInU> { |
| 20 | public: | 36 | public: |
| 21 | explicit AudInU(Core::System& system_); | 37 | explicit AudInU(Core::System& system_); |
diff --git a/src/core/hle/service/audio/audout_u.cpp b/src/core/hle/service/audio/audout_u.cpp index 92d4510b1..81adbfe09 100644 --- a/src/core/hle/service/audio/audout_u.cpp +++ b/src/core/hle/service/audio/audout_u.cpp | |||
| @@ -13,13 +13,11 @@ | |||
| 13 | #include "common/swap.h" | 13 | #include "common/swap.h" |
| 14 | #include "core/core.h" | 14 | #include "core/core.h" |
| 15 | #include "core/hle/ipc_helpers.h" | 15 | #include "core/hle/ipc_helpers.h" |
| 16 | #include "core/hle/kernel/hle_ipc.h" | ||
| 17 | #include "core/hle/kernel/k_event.h" | 16 | #include "core/hle/kernel/k_event.h" |
| 18 | #include "core/hle/kernel/k_readable_event.h" | ||
| 19 | #include "core/hle/kernel/k_writable_event.h" | ||
| 20 | #include "core/hle/kernel/kernel.h" | 17 | #include "core/hle/kernel/kernel.h" |
| 21 | #include "core/hle/service/audio/audout_u.h" | 18 | #include "core/hle/service/audio/audout_u.h" |
| 22 | #include "core/hle/service/audio/errors.h" | 19 | #include "core/hle/service/audio/errors.h" |
| 20 | #include "core/hle/service/kernel_helpers.h" | ||
| 23 | #include "core/memory.h" | 21 | #include "core/memory.h" |
| 24 | 22 | ||
| 25 | namespace Service::Audio { | 23 | namespace Service::Audio { |
| @@ -41,11 +39,12 @@ enum class AudioState : u32 { | |||
| 41 | 39 | ||
| 42 | class IAudioOut final : public ServiceFramework<IAudioOut> { | 40 | class IAudioOut final : public ServiceFramework<IAudioOut> { |
| 43 | public: | 41 | public: |
| 44 | IAudioOut(Core::System& system_, AudoutParams audio_params_, AudioCore::AudioOut& audio_core_, | 42 | explicit IAudioOut(Core::System& system_, AudoutParams audio_params_, |
| 45 | std::string&& device_name_, std::string&& unique_name) | 43 | AudioCore::AudioOut& audio_core_, std::string&& device_name_, |
| 46 | : ServiceFramework{system_, "IAudioOut"}, audio_core{audio_core_}, device_name{std::move( | 44 | std::string&& unique_name) |
| 47 | device_name_)}, | 45 | : ServiceFramework{system_, "IAudioOut"}, audio_core{audio_core_}, |
| 48 | audio_params{audio_params_}, buffer_event{system.Kernel()}, main_memory{system.Memory()} { | 46 | device_name{std::move(device_name_)}, audio_params{audio_params_}, |
| 47 | main_memory{system.Memory()}, service_context{system_, "IAudioOut"} { | ||
| 49 | // clang-format off | 48 | // clang-format off |
| 50 | static const FunctionInfo functions[] = { | 49 | static const FunctionInfo functions[] = { |
| 51 | {0, &IAudioOut::GetAudioOutState, "GetAudioOutState"}, | 50 | {0, &IAudioOut::GetAudioOutState, "GetAudioOutState"}, |
| @@ -67,16 +66,19 @@ public: | |||
| 67 | RegisterHandlers(functions); | 66 | RegisterHandlers(functions); |
| 68 | 67 | ||
| 69 | // This is the event handle used to check if the audio buffer was released | 68 | // This is the event handle used to check if the audio buffer was released |
| 70 | Kernel::KAutoObject::Create(std::addressof(buffer_event)); | 69 | buffer_event = service_context.CreateEvent("IAudioOutBufferReleased"); |
| 71 | buffer_event.Initialize("IAudioOutBufferReleased"); | ||
| 72 | 70 | ||
| 73 | stream = audio_core.OpenStream(system.CoreTiming(), audio_params.sample_rate, | 71 | stream = audio_core.OpenStream(system.CoreTiming(), audio_params.sample_rate, |
| 74 | audio_params.channel_count, std::move(unique_name), [this] { | 72 | audio_params.channel_count, std::move(unique_name), [this] { |
| 75 | const auto guard = LockService(); | 73 | const auto guard = LockService(); |
| 76 | buffer_event.GetWritableEvent().Signal(); | 74 | buffer_event->GetWritableEvent().Signal(); |
| 77 | }); | 75 | }); |
| 78 | } | 76 | } |
| 79 | 77 | ||
| 78 | ~IAudioOut() override { | ||
| 79 | service_context.CloseEvent(buffer_event); | ||
| 80 | } | ||
| 81 | |||
| 80 | private: | 82 | private: |
| 81 | struct AudioBuffer { | 83 | struct AudioBuffer { |
| 82 | u64_le next; | 84 | u64_le next; |
| @@ -126,7 +128,7 @@ private: | |||
| 126 | 128 | ||
| 127 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 129 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 128 | rb.Push(ResultSuccess); | 130 | rb.Push(ResultSuccess); |
| 129 | rb.PushCopyObjects(buffer_event.GetReadableEvent()); | 131 | rb.PushCopyObjects(buffer_event->GetReadableEvent()); |
| 130 | } | 132 | } |
| 131 | 133 | ||
| 132 | void AppendAudioOutBufferImpl(Kernel::HLERequestContext& ctx) { | 134 | void AppendAudioOutBufferImpl(Kernel::HLERequestContext& ctx) { |
| @@ -227,9 +229,12 @@ private: | |||
| 227 | 229 | ||
| 228 | [[maybe_unused]] AudoutParams audio_params{}; | 230 | [[maybe_unused]] AudoutParams audio_params{}; |
| 229 | 231 | ||
| 230 | /// This is the event handle used to check if the audio buffer was released | ||
| 231 | Kernel::KEvent buffer_event; | ||
| 232 | Core::Memory::Memory& main_memory; | 232 | Core::Memory::Memory& main_memory; |
| 233 | |||
| 234 | KernelHelpers::ServiceContext service_context; | ||
| 235 | |||
| 236 | /// This is the event handle used to check if the audio buffer was released | ||
| 237 | Kernel::KEvent* buffer_event; | ||
| 233 | }; | 238 | }; |
| 234 | 239 | ||
| 235 | AudOutU::AudOutU(Core::System& system_) : ServiceFramework{system_, "audout:u"} { | 240 | AudOutU::AudOutU(Core::System& system_) : ServiceFramework{system_, "audout:u"} { |
diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp index b769fe959..cdb2a9521 100644 --- a/src/core/hle/service/audio/audren_u.cpp +++ b/src/core/hle/service/audio/audren_u.cpp | |||
| @@ -15,10 +15,7 @@ | |||
| 15 | #include "common/string_util.h" | 15 | #include "common/string_util.h" |
| 16 | #include "core/core.h" | 16 | #include "core/core.h" |
| 17 | #include "core/hle/ipc_helpers.h" | 17 | #include "core/hle/ipc_helpers.h" |
| 18 | #include "core/hle/kernel/hle_ipc.h" | ||
| 19 | #include "core/hle/kernel/k_event.h" | 18 | #include "core/hle/kernel/k_event.h" |
| 20 | #include "core/hle/kernel/k_readable_event.h" | ||
| 21 | #include "core/hle/kernel/k_writable_event.h" | ||
| 22 | #include "core/hle/kernel/kernel.h" | 19 | #include "core/hle/kernel/kernel.h" |
| 23 | #include "core/hle/service/audio/audren_u.h" | 20 | #include "core/hle/service/audio/audren_u.h" |
| 24 | #include "core/hle/service/audio/errors.h" | 21 | #include "core/hle/service/audio/errors.h" |
| @@ -30,7 +27,7 @@ public: | |||
| 30 | explicit IAudioRenderer(Core::System& system_, | 27 | explicit IAudioRenderer(Core::System& system_, |
| 31 | const AudioCommon::AudioRendererParameter& audren_params, | 28 | const AudioCommon::AudioRendererParameter& audren_params, |
| 32 | const std::size_t instance_number) | 29 | const std::size_t instance_number) |
| 33 | : ServiceFramework{system_, "IAudioRenderer"}, system_event{system.Kernel()} { | 30 | : ServiceFramework{system_, "IAudioRenderer"}, service_context{system_, "IAudioRenderer"} { |
| 34 | // clang-format off | 31 | // clang-format off |
| 35 | static const FunctionInfo functions[] = { | 32 | static const FunctionInfo functions[] = { |
| 36 | {0, &IAudioRenderer::GetSampleRate, "GetSampleRate"}, | 33 | {0, &IAudioRenderer::GetSampleRate, "GetSampleRate"}, |
| @@ -49,17 +46,20 @@ public: | |||
| 49 | // clang-format on | 46 | // clang-format on |
| 50 | RegisterHandlers(functions); | 47 | RegisterHandlers(functions); |
| 51 | 48 | ||
| 52 | Kernel::KAutoObject::Create(std::addressof(system_event)); | 49 | system_event = service_context.CreateEvent("IAudioRenderer:SystemEvent"); |
| 53 | system_event.Initialize("IAudioRenderer:SystemEvent"); | ||
| 54 | renderer = std::make_unique<AudioCore::AudioRenderer>( | 50 | renderer = std::make_unique<AudioCore::AudioRenderer>( |
| 55 | system.CoreTiming(), system.Memory(), audren_params, | 51 | system.CoreTiming(), system.Memory(), audren_params, |
| 56 | [this]() { | 52 | [this]() { |
| 57 | const auto guard = LockService(); | 53 | const auto guard = LockService(); |
| 58 | system_event.GetWritableEvent().Signal(); | 54 | system_event->GetWritableEvent().Signal(); |
| 59 | }, | 55 | }, |
| 60 | instance_number); | 56 | instance_number); |
| 61 | } | 57 | } |
| 62 | 58 | ||
| 59 | ~IAudioRenderer() override { | ||
| 60 | service_context.CloseEvent(system_event); | ||
| 61 | } | ||
| 62 | |||
| 63 | private: | 63 | private: |
| 64 | void GetSampleRate(Kernel::HLERequestContext& ctx) { | 64 | void GetSampleRate(Kernel::HLERequestContext& ctx) { |
| 65 | LOG_DEBUG(Service_Audio, "called"); | 65 | LOG_DEBUG(Service_Audio, "called"); |
| @@ -130,7 +130,7 @@ private: | |||
| 130 | 130 | ||
| 131 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 131 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 132 | rb.Push(ResultSuccess); | 132 | rb.Push(ResultSuccess); |
| 133 | rb.PushCopyObjects(system_event.GetReadableEvent()); | 133 | rb.PushCopyObjects(system_event->GetReadableEvent()); |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | void SetRenderingTimeLimit(Kernel::HLERequestContext& ctx) { | 136 | void SetRenderingTimeLimit(Kernel::HLERequestContext& ctx) { |
| @@ -164,14 +164,16 @@ private: | |||
| 164 | rb.Push(ERR_NOT_SUPPORTED); | 164 | rb.Push(ERR_NOT_SUPPORTED); |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | Kernel::KEvent system_event; | 167 | KernelHelpers::ServiceContext service_context; |
| 168 | |||
| 169 | Kernel::KEvent* system_event; | ||
| 168 | std::unique_ptr<AudioCore::AudioRenderer> renderer; | 170 | std::unique_ptr<AudioCore::AudioRenderer> renderer; |
| 169 | u32 rendering_time_limit_percent = 100; | 171 | u32 rendering_time_limit_percent = 100; |
| 170 | }; | 172 | }; |
| 171 | 173 | ||
| 172 | class IAudioDevice final : public ServiceFramework<IAudioDevice> { | 174 | class IAudioDevice final : public ServiceFramework<IAudioDevice> { |
| 173 | public: | 175 | public: |
| 174 | explicit IAudioDevice(Core::System& system_, Kernel::KEvent& buffer_event_, u32_le revision_) | 176 | explicit IAudioDevice(Core::System& system_, Kernel::KEvent* buffer_event_, u32_le revision_) |
| 175 | : ServiceFramework{system_, "IAudioDevice"}, buffer_event{buffer_event_}, revision{ | 177 | : ServiceFramework{system_, "IAudioDevice"}, buffer_event{buffer_event_}, revision{ |
| 176 | revision_} { | 178 | revision_} { |
| 177 | static const FunctionInfo functions[] = { | 179 | static const FunctionInfo functions[] = { |
| @@ -187,7 +189,8 @@ public: | |||
| 187 | {10, &IAudioDevice::GetActiveAudioDeviceName, "GetActiveAudioDeviceNameAuto"}, | 189 | {10, &IAudioDevice::GetActiveAudioDeviceName, "GetActiveAudioDeviceNameAuto"}, |
| 188 | {11, &IAudioDevice::QueryAudioDeviceInputEvent, "QueryAudioDeviceInputEvent"}, | 190 | {11, &IAudioDevice::QueryAudioDeviceInputEvent, "QueryAudioDeviceInputEvent"}, |
| 189 | {12, &IAudioDevice::QueryAudioDeviceOutputEvent, "QueryAudioDeviceOutputEvent"}, | 191 | {12, &IAudioDevice::QueryAudioDeviceOutputEvent, "QueryAudioDeviceOutputEvent"}, |
| 190 | {13, nullptr, "GetAudioSystemMasterVolumeSetting"}, | 192 | {13, nullptr, "GetActiveAudioOutputDeviceName"}, |
| 193 | {14, nullptr, "ListAudioOutputDeviceName"}, | ||
| 191 | }; | 194 | }; |
| 192 | RegisterHandlers(functions); | 195 | RegisterHandlers(functions); |
| 193 | } | 196 | } |
| @@ -278,11 +281,11 @@ private: | |||
| 278 | void QueryAudioDeviceSystemEvent(Kernel::HLERequestContext& ctx) { | 281 | void QueryAudioDeviceSystemEvent(Kernel::HLERequestContext& ctx) { |
| 279 | LOG_WARNING(Service_Audio, "(STUBBED) called"); | 282 | LOG_WARNING(Service_Audio, "(STUBBED) called"); |
| 280 | 283 | ||
| 281 | buffer_event.GetWritableEvent().Signal(); | 284 | buffer_event->GetWritableEvent().Signal(); |
| 282 | 285 | ||
| 283 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 286 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 284 | rb.Push(ResultSuccess); | 287 | rb.Push(ResultSuccess); |
| 285 | rb.PushCopyObjects(buffer_event.GetReadableEvent()); | 288 | rb.PushCopyObjects(buffer_event->GetReadableEvent()); |
| 286 | } | 289 | } |
| 287 | 290 | ||
| 288 | void GetActiveChannelCount(Kernel::HLERequestContext& ctx) { | 291 | void GetActiveChannelCount(Kernel::HLERequestContext& ctx) { |
| @@ -299,7 +302,7 @@ private: | |||
| 299 | 302 | ||
| 300 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 303 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 301 | rb.Push(ResultSuccess); | 304 | rb.Push(ResultSuccess); |
| 302 | rb.PushCopyObjects(buffer_event.GetReadableEvent()); | 305 | rb.PushCopyObjects(buffer_event->GetReadableEvent()); |
| 303 | } | 306 | } |
| 304 | 307 | ||
| 305 | void QueryAudioDeviceOutputEvent(Kernel::HLERequestContext& ctx) { | 308 | void QueryAudioDeviceOutputEvent(Kernel::HLERequestContext& ctx) { |
| @@ -307,16 +310,15 @@ private: | |||
| 307 | 310 | ||
| 308 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 311 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 309 | rb.Push(ResultSuccess); | 312 | rb.Push(ResultSuccess); |
| 310 | rb.PushCopyObjects(buffer_event.GetReadableEvent()); | 313 | rb.PushCopyObjects(buffer_event->GetReadableEvent()); |
| 311 | } | 314 | } |
| 312 | 315 | ||
| 313 | Kernel::KEvent& buffer_event; | 316 | Kernel::KEvent* buffer_event; |
| 314 | u32_le revision = 0; | 317 | u32_le revision = 0; |
| 315 | }; | 318 | }; |
| 316 | 319 | ||
| 317 | AudRenU::AudRenU(Core::System& system_) | 320 | AudRenU::AudRenU(Core::System& system_) |
| 318 | : ServiceFramework{system_, "audren:u"}, buffer_event{system.Kernel()} { | 321 | : ServiceFramework{system_, "audren:u"}, service_context{system_, "audren:u"} { |
| 319 | |||
| 320 | // clang-format off | 322 | // clang-format off |
| 321 | static const FunctionInfo functions[] = { | 323 | static const FunctionInfo functions[] = { |
| 322 | {0, &AudRenU::OpenAudioRenderer, "OpenAudioRenderer"}, | 324 | {0, &AudRenU::OpenAudioRenderer, "OpenAudioRenderer"}, |
| @@ -329,11 +331,12 @@ AudRenU::AudRenU(Core::System& system_) | |||
| 329 | 331 | ||
| 330 | RegisterHandlers(functions); | 332 | RegisterHandlers(functions); |
| 331 | 333 | ||
| 332 | Kernel::KAutoObject::Create(std::addressof(buffer_event)); | 334 | buffer_event = service_context.CreateEvent("IAudioOutBufferReleasedEvent"); |
| 333 | buffer_event.Initialize("IAudioOutBufferReleasedEvent"); | ||
| 334 | } | 335 | } |
| 335 | 336 | ||
| 336 | AudRenU::~AudRenU() = default; | 337 | AudRenU::~AudRenU() { |
| 338 | service_context.CloseEvent(buffer_event); | ||
| 339 | } | ||
| 337 | 340 | ||
| 338 | void AudRenU::OpenAudioRenderer(Kernel::HLERequestContext& ctx) { | 341 | void AudRenU::OpenAudioRenderer(Kernel::HLERequestContext& ctx) { |
| 339 | LOG_DEBUG(Service_Audio, "called"); | 342 | LOG_DEBUG(Service_Audio, "called"); |
diff --git a/src/core/hle/service/audio/audren_u.h b/src/core/hle/service/audio/audren_u.h index 0ee6f9542..5922b4b27 100644 --- a/src/core/hle/service/audio/audren_u.h +++ b/src/core/hle/service/audio/audren_u.h | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include "core/hle/kernel/k_event.h" | 7 | #include "core/hle/service/kernel_helpers.h" |
| 8 | #include "core/hle/service/service.h" | 8 | #include "core/hle/service/service.h" |
| 9 | 9 | ||
| 10 | namespace Core { | 10 | namespace Core { |
| @@ -31,8 +31,10 @@ private: | |||
| 31 | 31 | ||
| 32 | void OpenAudioRendererImpl(Kernel::HLERequestContext& ctx); | 32 | void OpenAudioRendererImpl(Kernel::HLERequestContext& ctx); |
| 33 | 33 | ||
| 34 | KernelHelpers::ServiceContext service_context; | ||
| 35 | |||
| 34 | std::size_t audren_instance_count = 0; | 36 | std::size_t audren_instance_count = 0; |
| 35 | Kernel::KEvent buffer_event; | 37 | Kernel::KEvent* buffer_event; |
| 36 | }; | 38 | }; |
| 37 | 39 | ||
| 38 | // Describes a particular audio feature that may be supported in a particular revision. | 40 | // Describes a particular audio feature that may be supported in a particular revision. |
diff --git a/src/core/hle/service/audio/hwopus.cpp b/src/core/hle/service/audio/hwopus.cpp index 33a6dbbb6..7da1f2969 100644 --- a/src/core/hle/service/audio/hwopus.cpp +++ b/src/core/hle/service/audio/hwopus.cpp | |||
| @@ -13,7 +13,6 @@ | |||
| 13 | #include "common/assert.h" | 13 | #include "common/assert.h" |
| 14 | #include "common/logging/log.h" | 14 | #include "common/logging/log.h" |
| 15 | #include "core/hle/ipc_helpers.h" | 15 | #include "core/hle/ipc_helpers.h" |
| 16 | #include "core/hle/kernel/hle_ipc.h" | ||
| 17 | #include "core/hle/service/audio/hwopus.h" | 16 | #include "core/hle/service/audio/hwopus.h" |
| 18 | 17 | ||
| 19 | namespace Service::Audio { | 18 | namespace Service::Audio { |
diff --git a/src/core/hle/service/bcat/backend/backend.cpp b/src/core/hle/service/bcat/backend/backend.cpp index a78544c88..4c7d3bb6e 100644 --- a/src/core/hle/service/bcat/backend/backend.cpp +++ b/src/core/hle/service/bcat/backend/backend.cpp | |||
| @@ -5,22 +5,24 @@ | |||
| 5 | #include "common/hex_util.h" | 5 | #include "common/hex_util.h" |
| 6 | #include "common/logging/log.h" | 6 | #include "common/logging/log.h" |
| 7 | #include "core/core.h" | 7 | #include "core/core.h" |
| 8 | #include "core/hle/kernel/k_readable_event.h" | 8 | #include "core/hle/kernel/k_event.h" |
| 9 | #include "core/hle/kernel/k_writable_event.h" | ||
| 10 | #include "core/hle/lock.h" | 9 | #include "core/hle/lock.h" |
| 11 | #include "core/hle/service/bcat/backend/backend.h" | 10 | #include "core/hle/service/bcat/backend/backend.h" |
| 12 | 11 | ||
| 13 | namespace Service::BCAT { | 12 | namespace Service::BCAT { |
| 14 | 13 | ||
| 15 | ProgressServiceBackend::ProgressServiceBackend(Kernel::KernelCore& kernel, | 14 | ProgressServiceBackend::ProgressServiceBackend(Core::System& system, std::string_view event_name) |
| 16 | std::string_view event_name) | 15 | : service_context{system, "ProgressServiceBackend"} { |
| 17 | : update_event{kernel} { | 16 | update_event = service_context.CreateEvent("ProgressServiceBackend:UpdateEvent:" + |
| 18 | Kernel::KAutoObject::Create(std::addressof(update_event)); | 17 | std::string(event_name)); |
| 19 | update_event.Initialize("ProgressServiceBackend:UpdateEvent:" + std::string(event_name)); | 18 | } |
| 19 | |||
| 20 | ProgressServiceBackend::~ProgressServiceBackend() { | ||
| 21 | service_context.CloseEvent(update_event); | ||
| 20 | } | 22 | } |
| 21 | 23 | ||
| 22 | Kernel::KReadableEvent& ProgressServiceBackend::GetEvent() { | 24 | Kernel::KReadableEvent& ProgressServiceBackend::GetEvent() { |
| 23 | return update_event.GetReadableEvent(); | 25 | return update_event->GetReadableEvent(); |
| 24 | } | 26 | } |
| 25 | 27 | ||
| 26 | DeliveryCacheProgressImpl& ProgressServiceBackend::GetImpl() { | 28 | DeliveryCacheProgressImpl& ProgressServiceBackend::GetImpl() { |
| @@ -88,9 +90,9 @@ void ProgressServiceBackend::FinishDownload(ResultCode result) { | |||
| 88 | void ProgressServiceBackend::SignalUpdate() { | 90 | void ProgressServiceBackend::SignalUpdate() { |
| 89 | if (need_hle_lock) { | 91 | if (need_hle_lock) { |
| 90 | std::lock_guard lock(HLE::g_hle_lock); | 92 | std::lock_guard lock(HLE::g_hle_lock); |
| 91 | update_event.GetWritableEvent().Signal(); | 93 | update_event->GetWritableEvent().Signal(); |
| 92 | } else { | 94 | } else { |
| 93 | update_event.GetWritableEvent().Signal(); | 95 | update_event->GetWritableEvent().Signal(); |
| 94 | } | 96 | } |
| 95 | } | 97 | } |
| 96 | 98 | ||
diff --git a/src/core/hle/service/bcat/backend/backend.h b/src/core/hle/service/bcat/backend/backend.h index e79a9c2ad..749e046c7 100644 --- a/src/core/hle/service/bcat/backend/backend.h +++ b/src/core/hle/service/bcat/backend/backend.h | |||
| @@ -11,8 +11,8 @@ | |||
| 11 | 11 | ||
| 12 | #include "common/common_types.h" | 12 | #include "common/common_types.h" |
| 13 | #include "core/file_sys/vfs_types.h" | 13 | #include "core/file_sys/vfs_types.h" |
| 14 | #include "core/hle/kernel/k_event.h" | ||
| 15 | #include "core/hle/result.h" | 14 | #include "core/hle/result.h" |
| 15 | #include "core/hle/service/kernel_helpers.h" | ||
| 16 | 16 | ||
| 17 | namespace Core { | 17 | namespace Core { |
| 18 | class System; | 18 | class System; |
| @@ -70,6 +70,8 @@ class ProgressServiceBackend { | |||
| 70 | friend class IBcatService; | 70 | friend class IBcatService; |
| 71 | 71 | ||
| 72 | public: | 72 | public: |
| 73 | ~ProgressServiceBackend(); | ||
| 74 | |||
| 73 | // Clients should call this with true if any of the functions are going to be called from a | 75 | // Clients should call this with true if any of the functions are going to be called from a |
| 74 | // non-HLE thread and this class need to lock the hle mutex. (default is false) | 76 | // non-HLE thread and this class need to lock the hle mutex. (default is false) |
| 75 | void SetNeedHLELock(bool need); | 77 | void SetNeedHLELock(bool need); |
| @@ -97,15 +99,17 @@ public: | |||
| 97 | void FinishDownload(ResultCode result); | 99 | void FinishDownload(ResultCode result); |
| 98 | 100 | ||
| 99 | private: | 101 | private: |
| 100 | explicit ProgressServiceBackend(Kernel::KernelCore& kernel, std::string_view event_name); | 102 | explicit ProgressServiceBackend(Core::System& system, std::string_view event_name); |
| 101 | 103 | ||
| 102 | Kernel::KReadableEvent& GetEvent(); | 104 | Kernel::KReadableEvent& GetEvent(); |
| 103 | DeliveryCacheProgressImpl& GetImpl(); | 105 | DeliveryCacheProgressImpl& GetImpl(); |
| 104 | 106 | ||
| 105 | void SignalUpdate(); | 107 | void SignalUpdate(); |
| 106 | 108 | ||
| 109 | KernelHelpers::ServiceContext service_context; | ||
| 110 | |||
| 107 | DeliveryCacheProgressImpl impl{}; | 111 | DeliveryCacheProgressImpl impl{}; |
| 108 | Kernel::KEvent update_event; | 112 | Kernel::KEvent* update_event; |
| 109 | bool need_hle_lock = false; | 113 | bool need_hle_lock = false; |
| 110 | }; | 114 | }; |
| 111 | 115 | ||
diff --git a/src/core/hle/service/bcat/backend/boxcat.cpp b/src/core/hle/service/bcat/backend/boxcat.cpp deleted file mode 100644 index 7ca7f2aac..000000000 --- a/src/core/hle/service/bcat/backend/boxcat.cpp +++ /dev/null | |||
| @@ -1,548 +0,0 @@ | |||
| 1 | // Copyright 2019 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <fmt/ostream.h> | ||
| 6 | |||
| 7 | #ifdef __GNUC__ | ||
| 8 | #pragma GCC diagnostic push | ||
| 9 | #pragma GCC diagnostic ignored "-Wshadow" | ||
| 10 | #ifndef __clang__ | ||
| 11 | #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" | ||
| 12 | #endif | ||
| 13 | #endif | ||
| 14 | #include <httplib.h> | ||
| 15 | #include <mbedtls/sha256.h> | ||
| 16 | #include <nlohmann/json.hpp> | ||
| 17 | #ifdef __GNUC__ | ||
| 18 | #pragma GCC diagnostic pop | ||
| 19 | #endif | ||
| 20 | |||
| 21 | #include "common/fs/file.h" | ||
| 22 | #include "common/fs/fs.h" | ||
| 23 | #include "common/fs/path_util.h" | ||
| 24 | #include "common/hex_util.h" | ||
| 25 | #include "common/logging/log.h" | ||
| 26 | #include "common/settings.h" | ||
| 27 | #include "core/core.h" | ||
| 28 | #include "core/file_sys/vfs.h" | ||
| 29 | #include "core/file_sys/vfs_libzip.h" | ||
| 30 | #include "core/file_sys/vfs_vector.h" | ||
| 31 | #include "core/frontend/applets/error.h" | ||
| 32 | #include "core/hle/service/am/applets/applets.h" | ||
| 33 | #include "core/hle/service/bcat/backend/boxcat.h" | ||
| 34 | |||
| 35 | namespace Service::BCAT { | ||
| 36 | namespace { | ||
| 37 | |||
| 38 | // Prevents conflicts with windows macro called CreateFile | ||
| 39 | FileSys::VirtualFile VfsCreateFileWrap(FileSys::VirtualDir dir, std::string_view name) { | ||
| 40 | return dir->CreateFile(name); | ||
| 41 | } | ||
| 42 | |||
| 43 | // Prevents conflicts with windows macro called DeleteFile | ||
| 44 | bool VfsDeleteFileWrap(FileSys::VirtualDir dir, std::string_view name) { | ||
| 45 | return dir->DeleteFile(name); | ||
| 46 | } | ||
| 47 | |||
| 48 | constexpr ResultCode ERROR_GENERAL_BCAT_FAILURE{ErrorModule::BCAT, 1}; | ||
| 49 | |||
| 50 | constexpr char BOXCAT_HOSTNAME[] = "api.yuzu-emu.org"; | ||
| 51 | |||
| 52 | // Formatted using fmt with arg[0] = hex title id | ||
| 53 | constexpr char BOXCAT_PATHNAME_DATA[] = "/game-assets/{:016X}/boxcat"; | ||
| 54 | constexpr char BOXCAT_PATHNAME_LAUNCHPARAM[] = "/game-assets/{:016X}/launchparam"; | ||
| 55 | |||
| 56 | constexpr char BOXCAT_PATHNAME_EVENTS[] = "/game-assets/boxcat/events"; | ||
| 57 | |||
| 58 | constexpr char BOXCAT_API_VERSION[] = "1"; | ||
| 59 | constexpr char BOXCAT_CLIENT_TYPE[] = "yuzu"; | ||
| 60 | |||
| 61 | // HTTP status codes for Boxcat | ||
| 62 | enum class ResponseStatus { | ||
| 63 | Ok = 200, ///< Operation completed successfully. | ||
| 64 | BadClientVersion = 301, ///< The Boxcat-Client-Version doesn't match the server. | ||
| 65 | NoUpdate = 304, ///< The digest provided would match the new data, no need to update. | ||
| 66 | NoMatchTitleId = 404, ///< The title ID provided doesn't have a boxcat implementation. | ||
| 67 | NoMatchBuildId = 406, ///< The build ID provided is blacklisted (potentially because of format | ||
| 68 | ///< issues or whatnot) and has no data. | ||
| 69 | }; | ||
| 70 | |||
| 71 | enum class DownloadResult { | ||
| 72 | Success = 0, | ||
| 73 | NoResponse, | ||
| 74 | GeneralWebError, | ||
| 75 | NoMatchTitleId, | ||
| 76 | NoMatchBuildId, | ||
| 77 | InvalidContentType, | ||
| 78 | GeneralFSError, | ||
| 79 | BadClientVersion, | ||
| 80 | }; | ||
| 81 | |||
| 82 | constexpr std::array<const char*, 8> DOWNLOAD_RESULT_LOG_MESSAGES{ | ||
| 83 | "Success", | ||
| 84 | "There was no response from the server.", | ||
| 85 | "There was a general web error code returned from the server.", | ||
| 86 | "The title ID of the current game doesn't have a boxcat implementation. If you believe an " | ||
| 87 | "implementation should be added, contact yuzu support.", | ||
| 88 | "The build ID of the current version of the game is marked as incompatible with the current " | ||
| 89 | "BCAT distribution. Try upgrading or downgrading your game version or contacting yuzu support.", | ||
| 90 | "The content type of the web response was invalid.", | ||
| 91 | "There was a general filesystem error while saving the zip file.", | ||
| 92 | "The server is either too new or too old to serve the request. Try using the latest version of " | ||
| 93 | "an official release of yuzu.", | ||
| 94 | }; | ||
| 95 | |||
| 96 | std::ostream& operator<<(std::ostream& os, DownloadResult result) { | ||
| 97 | return os << DOWNLOAD_RESULT_LOG_MESSAGES.at(static_cast<std::size_t>(result)); | ||
| 98 | } | ||
| 99 | |||
| 100 | constexpr u32 PORT = 443; | ||
| 101 | constexpr u32 TIMEOUT_SECONDS = 30; | ||
| 102 | [[maybe_unused]] constexpr u64 VFS_COPY_BLOCK_SIZE = 1ULL << 24; // 4MB | ||
| 103 | |||
| 104 | std::filesystem::path GetBINFilePath(u64 title_id) { | ||
| 105 | return Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) / "bcat" / | ||
| 106 | fmt::format("{:016X}/launchparam.bin", title_id); | ||
| 107 | } | ||
| 108 | |||
| 109 | std::filesystem::path GetZIPFilePath(u64 title_id) { | ||
| 110 | return Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) / "bcat" / | ||
| 111 | fmt::format("{:016X}/data.zip", title_id); | ||
| 112 | } | ||
| 113 | |||
| 114 | // If the error is something the user should know about (build ID mismatch, bad client version), | ||
| 115 | // display an error. | ||
| 116 | void HandleDownloadDisplayResult(const AM::Applets::AppletManager& applet_manager, | ||
| 117 | DownloadResult res) { | ||
| 118 | if (res == DownloadResult::Success || res == DownloadResult::NoResponse || | ||
| 119 | res == DownloadResult::GeneralWebError || res == DownloadResult::GeneralFSError || | ||
| 120 | res == DownloadResult::NoMatchTitleId || res == DownloadResult::InvalidContentType) { | ||
| 121 | return; | ||
| 122 | } | ||
| 123 | |||
| 124 | const auto& frontend{applet_manager.GetAppletFrontendSet()}; | ||
| 125 | frontend.error->ShowCustomErrorText( | ||
| 126 | ResultUnknown, "There was an error while attempting to use Boxcat.", | ||
| 127 | DOWNLOAD_RESULT_LOG_MESSAGES[static_cast<std::size_t>(res)], [] {}); | ||
| 128 | } | ||
| 129 | |||
| 130 | bool VfsRawCopyProgress(FileSys::VirtualFile src, FileSys::VirtualFile dest, | ||
| 131 | std::string_view dir_name, ProgressServiceBackend& progress, | ||
| 132 | std::size_t block_size = 0x1000) { | ||
| 133 | if (src == nullptr || dest == nullptr || !src->IsReadable() || !dest->IsWritable()) | ||
| 134 | return false; | ||
| 135 | if (!dest->Resize(src->GetSize())) | ||
| 136 | return false; | ||
| 137 | |||
| 138 | progress.StartDownloadingFile(dir_name, src->GetName(), src->GetSize()); | ||
| 139 | |||
| 140 | std::vector<u8> temp(std::min(block_size, src->GetSize())); | ||
| 141 | for (std::size_t i = 0; i < src->GetSize(); i += block_size) { | ||
| 142 | const auto read = std::min(block_size, src->GetSize() - i); | ||
| 143 | |||
| 144 | if (src->Read(temp.data(), read, i) != read) { | ||
| 145 | return false; | ||
| 146 | } | ||
| 147 | |||
| 148 | if (dest->Write(temp.data(), read, i) != read) { | ||
| 149 | return false; | ||
| 150 | } | ||
| 151 | |||
| 152 | progress.UpdateFileProgress(i); | ||
| 153 | } | ||
| 154 | |||
| 155 | progress.FinishDownloadingFile(); | ||
| 156 | |||
| 157 | return true; | ||
| 158 | } | ||
| 159 | |||
| 160 | bool VfsRawCopyDProgressSingle(FileSys::VirtualDir src, FileSys::VirtualDir dest, | ||
| 161 | ProgressServiceBackend& progress, std::size_t block_size = 0x1000) { | ||
| 162 | if (src == nullptr || dest == nullptr || !src->IsReadable() || !dest->IsWritable()) | ||
| 163 | return false; | ||
| 164 | |||
| 165 | for (const auto& file : src->GetFiles()) { | ||
| 166 | const auto out_file = VfsCreateFileWrap(dest, file->GetName()); | ||
| 167 | if (!VfsRawCopyProgress(file, out_file, src->GetName(), progress, block_size)) { | ||
| 168 | return false; | ||
| 169 | } | ||
| 170 | } | ||
| 171 | progress.CommitDirectory(src->GetName()); | ||
| 172 | |||
| 173 | return true; | ||
| 174 | } | ||
| 175 | |||
| 176 | bool VfsRawCopyDProgress(FileSys::VirtualDir src, FileSys::VirtualDir dest, | ||
| 177 | ProgressServiceBackend& progress, std::size_t block_size = 0x1000) { | ||
| 178 | if (src == nullptr || dest == nullptr || !src->IsReadable() || !dest->IsWritable()) | ||
| 179 | return false; | ||
| 180 | |||
| 181 | for (const auto& dir : src->GetSubdirectories()) { | ||
| 182 | const auto out = dest->CreateSubdirectory(dir->GetName()); | ||
| 183 | if (!VfsRawCopyDProgressSingle(dir, out, progress, block_size)) { | ||
| 184 | return false; | ||
| 185 | } | ||
| 186 | } | ||
| 187 | |||
| 188 | return true; | ||
| 189 | } | ||
| 190 | |||
| 191 | } // Anonymous namespace | ||
| 192 | |||
| 193 | class Boxcat::Client { | ||
| 194 | public: | ||
| 195 | Client(std::filesystem::path path_, u64 title_id_, u64 build_id_) | ||
| 196 | : path(std::move(path_)), title_id(title_id_), build_id(build_id_) {} | ||
| 197 | |||
| 198 | DownloadResult DownloadDataZip() { | ||
| 199 | return DownloadInternal(fmt::format(BOXCAT_PATHNAME_DATA, title_id), TIMEOUT_SECONDS, | ||
| 200 | "application/zip"); | ||
| 201 | } | ||
| 202 | |||
| 203 | DownloadResult DownloadLaunchParam() { | ||
| 204 | return DownloadInternal(fmt::format(BOXCAT_PATHNAME_LAUNCHPARAM, title_id), | ||
| 205 | TIMEOUT_SECONDS / 3, "application/octet-stream"); | ||
| 206 | } | ||
| 207 | |||
| 208 | private: | ||
| 209 | DownloadResult DownloadInternal(const std::string& resolved_path, u32 timeout_seconds, | ||
| 210 | const std::string& content_type_name) { | ||
| 211 | if (client == nullptr) { | ||
| 212 | client = std::make_unique<httplib::SSLClient>(BOXCAT_HOSTNAME, PORT); | ||
| 213 | client->set_connection_timeout(timeout_seconds); | ||
| 214 | client->set_read_timeout(timeout_seconds); | ||
| 215 | client->set_write_timeout(timeout_seconds); | ||
| 216 | } | ||
| 217 | |||
| 218 | httplib::Headers headers{ | ||
| 219 | {std::string("Game-Assets-API-Version"), std::string(BOXCAT_API_VERSION)}, | ||
| 220 | {std::string("Boxcat-Client-Type"), std::string(BOXCAT_CLIENT_TYPE)}, | ||
| 221 | {std::string("Game-Build-Id"), fmt::format("{:016X}", build_id)}, | ||
| 222 | }; | ||
| 223 | |||
| 224 | if (Common::FS::Exists(path)) { | ||
| 225 | Common::FS::IOFile file{path, Common::FS::FileAccessMode::Read, | ||
| 226 | Common::FS::FileType::BinaryFile}; | ||
| 227 | if (file.IsOpen()) { | ||
| 228 | std::vector<u8> bytes(file.GetSize()); | ||
| 229 | void(file.Read(bytes)); | ||
| 230 | const auto digest = DigestFile(bytes); | ||
| 231 | headers.insert({std::string("If-None-Match"), Common::HexToString(digest, false)}); | ||
| 232 | } | ||
| 233 | } | ||
| 234 | |||
| 235 | const auto response = client->Get(resolved_path.c_str(), headers); | ||
| 236 | if (response == nullptr) | ||
| 237 | return DownloadResult::NoResponse; | ||
| 238 | |||
| 239 | if (response->status == static_cast<int>(ResponseStatus::NoUpdate)) | ||
| 240 | return DownloadResult::Success; | ||
| 241 | if (response->status == static_cast<int>(ResponseStatus::BadClientVersion)) | ||
| 242 | return DownloadResult::BadClientVersion; | ||
| 243 | if (response->status == static_cast<int>(ResponseStatus::NoMatchTitleId)) | ||
| 244 | return DownloadResult::NoMatchTitleId; | ||
| 245 | if (response->status == static_cast<int>(ResponseStatus::NoMatchBuildId)) | ||
| 246 | return DownloadResult::NoMatchBuildId; | ||
| 247 | if (response->status != static_cast<int>(ResponseStatus::Ok)) | ||
| 248 | return DownloadResult::GeneralWebError; | ||
| 249 | |||
| 250 | const auto content_type = response->headers.find("content-type"); | ||
| 251 | if (content_type == response->headers.end() || | ||
| 252 | content_type->second.find(content_type_name) == std::string::npos) { | ||
| 253 | return DownloadResult::InvalidContentType; | ||
| 254 | } | ||
| 255 | |||
| 256 | if (!Common::FS::CreateDirs(path)) { | ||
| 257 | return DownloadResult::GeneralFSError; | ||
| 258 | } | ||
| 259 | |||
| 260 | Common::FS::IOFile file{path, Common::FS::FileAccessMode::Append, | ||
| 261 | Common::FS::FileType::BinaryFile}; | ||
| 262 | if (!file.IsOpen()) { | ||
| 263 | return DownloadResult::GeneralFSError; | ||
| 264 | } | ||
| 265 | |||
| 266 | if (!file.SetSize(response->body.size())) { | ||
| 267 | return DownloadResult::GeneralFSError; | ||
| 268 | } | ||
| 269 | |||
| 270 | if (file.Write(response->body) != response->body.size()) { | ||
| 271 | return DownloadResult::GeneralFSError; | ||
| 272 | } | ||
| 273 | |||
| 274 | return DownloadResult::Success; | ||
| 275 | } | ||
| 276 | |||
| 277 | using Digest = std::array<u8, 0x20>; | ||
| 278 | static Digest DigestFile(std::vector<u8> bytes) { | ||
| 279 | Digest out{}; | ||
| 280 | mbedtls_sha256_ret(bytes.data(), bytes.size(), out.data(), 0); | ||
| 281 | return out; | ||
| 282 | } | ||
| 283 | |||
| 284 | std::unique_ptr<httplib::SSLClient> client; | ||
| 285 | std::filesystem::path path; | ||
| 286 | u64 title_id; | ||
| 287 | u64 build_id; | ||
| 288 | }; | ||
| 289 | |||
| 290 | Boxcat::Boxcat(AM::Applets::AppletManager& applet_manager_, DirectoryGetter getter) | ||
| 291 | : Backend(std::move(getter)), applet_manager{applet_manager_} {} | ||
| 292 | |||
| 293 | Boxcat::~Boxcat() = default; | ||
| 294 | |||
| 295 | void SynchronizeInternal(AM::Applets::AppletManager& applet_manager, DirectoryGetter dir_getter, | ||
| 296 | TitleIDVersion title, ProgressServiceBackend& progress, | ||
| 297 | std::optional<std::string> dir_name = {}) { | ||
| 298 | progress.SetNeedHLELock(true); | ||
| 299 | |||
| 300 | if (Settings::values.bcat_boxcat_local) { | ||
| 301 | LOG_INFO(Service_BCAT, "Boxcat using local data by override, skipping download."); | ||
| 302 | const auto dir = dir_getter(title.title_id); | ||
| 303 | if (dir) | ||
| 304 | progress.SetTotalSize(dir->GetSize()); | ||
| 305 | progress.FinishDownload(ResultSuccess); | ||
| 306 | return; | ||
| 307 | } | ||
| 308 | |||
| 309 | const auto zip_path = GetZIPFilePath(title.title_id); | ||
| 310 | Boxcat::Client client{zip_path, title.title_id, title.build_id}; | ||
| 311 | |||
| 312 | progress.StartConnecting(); | ||
| 313 | |||
| 314 | const auto res = client.DownloadDataZip(); | ||
| 315 | if (res != DownloadResult::Success) { | ||
| 316 | LOG_ERROR(Service_BCAT, "Boxcat synchronization failed with error '{}'!", res); | ||
| 317 | |||
| 318 | if (res == DownloadResult::NoMatchBuildId || res == DownloadResult::NoMatchTitleId) { | ||
| 319 | Common::FS::RemoveFile(zip_path); | ||
| 320 | } | ||
| 321 | |||
| 322 | HandleDownloadDisplayResult(applet_manager, res); | ||
| 323 | progress.FinishDownload(ERROR_GENERAL_BCAT_FAILURE); | ||
| 324 | return; | ||
| 325 | } | ||
| 326 | |||
| 327 | progress.StartProcessingDataList(); | ||
| 328 | |||
| 329 | Common::FS::IOFile zip{zip_path, Common::FS::FileAccessMode::Read, | ||
| 330 | Common::FS::FileType::BinaryFile}; | ||
| 331 | const auto size = zip.GetSize(); | ||
| 332 | std::vector<u8> bytes(size); | ||
| 333 | if (!zip.IsOpen() || size == 0 || zip.Read(bytes) != bytes.size()) { | ||
| 334 | LOG_ERROR(Service_BCAT, "Boxcat failed to read ZIP file at path '{}'!", | ||
| 335 | Common::FS::PathToUTF8String(zip_path)); | ||
| 336 | progress.FinishDownload(ERROR_GENERAL_BCAT_FAILURE); | ||
| 337 | return; | ||
| 338 | } | ||
| 339 | |||
| 340 | const auto extracted = FileSys::ExtractZIP(std::make_shared<FileSys::VectorVfsFile>(bytes)); | ||
| 341 | if (extracted == nullptr) { | ||
| 342 | LOG_ERROR(Service_BCAT, "Boxcat failed to extract ZIP file!"); | ||
| 343 | progress.FinishDownload(ERROR_GENERAL_BCAT_FAILURE); | ||
| 344 | return; | ||
| 345 | } | ||
| 346 | |||
| 347 | if (dir_name == std::nullopt) { | ||
| 348 | progress.SetTotalSize(extracted->GetSize()); | ||
| 349 | |||
| 350 | const auto target_dir = dir_getter(title.title_id); | ||
| 351 | if (target_dir == nullptr || !VfsRawCopyDProgress(extracted, target_dir, progress)) { | ||
| 352 | LOG_ERROR(Service_BCAT, "Boxcat failed to copy extracted ZIP to target directory!"); | ||
| 353 | progress.FinishDownload(ERROR_GENERAL_BCAT_FAILURE); | ||
| 354 | return; | ||
| 355 | } | ||
| 356 | } else { | ||
| 357 | const auto target_dir = dir_getter(title.title_id); | ||
| 358 | if (target_dir == nullptr) { | ||
| 359 | LOG_ERROR(Service_BCAT, "Boxcat failed to get directory for title ID!"); | ||
| 360 | progress.FinishDownload(ERROR_GENERAL_BCAT_FAILURE); | ||
| 361 | return; | ||
| 362 | } | ||
| 363 | |||
| 364 | const auto target_sub = target_dir->GetSubdirectory(*dir_name); | ||
| 365 | const auto source_sub = extracted->GetSubdirectory(*dir_name); | ||
| 366 | |||
| 367 | progress.SetTotalSize(source_sub->GetSize()); | ||
| 368 | |||
| 369 | std::vector<std::string> filenames; | ||
| 370 | { | ||
| 371 | const auto files = target_sub->GetFiles(); | ||
| 372 | std::transform(files.begin(), files.end(), std::back_inserter(filenames), | ||
| 373 | [](const auto& vfile) { return vfile->GetName(); }); | ||
| 374 | } | ||
| 375 | |||
| 376 | for (const auto& filename : filenames) { | ||
| 377 | VfsDeleteFileWrap(target_sub, filename); | ||
| 378 | } | ||
| 379 | |||
| 380 | if (target_sub == nullptr || source_sub == nullptr || | ||
| 381 | !VfsRawCopyDProgressSingle(source_sub, target_sub, progress)) { | ||
| 382 | LOG_ERROR(Service_BCAT, "Boxcat failed to copy extracted ZIP to target directory!"); | ||
| 383 | progress.FinishDownload(ERROR_GENERAL_BCAT_FAILURE); | ||
| 384 | return; | ||
| 385 | } | ||
| 386 | } | ||
| 387 | |||
| 388 | progress.FinishDownload(ResultSuccess); | ||
| 389 | } | ||
| 390 | |||
| 391 | bool Boxcat::Synchronize(TitleIDVersion title, ProgressServiceBackend& progress) { | ||
| 392 | is_syncing.exchange(true); | ||
| 393 | |||
| 394 | std::thread([this, title, &progress] { | ||
| 395 | SynchronizeInternal(applet_manager, dir_getter, title, progress); | ||
| 396 | }).detach(); | ||
| 397 | |||
| 398 | return true; | ||
| 399 | } | ||
| 400 | |||
| 401 | bool Boxcat::SynchronizeDirectory(TitleIDVersion title, std::string name, | ||
| 402 | ProgressServiceBackend& progress) { | ||
| 403 | is_syncing.exchange(true); | ||
| 404 | |||
| 405 | std::thread([this, title, name, &progress] { | ||
| 406 | SynchronizeInternal(applet_manager, dir_getter, title, progress, name); | ||
| 407 | }).detach(); | ||
| 408 | |||
| 409 | return true; | ||
| 410 | } | ||
| 411 | |||
| 412 | bool Boxcat::Clear(u64 title_id) { | ||
| 413 | if (Settings::values.bcat_boxcat_local) { | ||
| 414 | LOG_INFO(Service_BCAT, "Boxcat using local data by override, skipping clear."); | ||
| 415 | return true; | ||
| 416 | } | ||
| 417 | |||
| 418 | const auto dir = dir_getter(title_id); | ||
| 419 | |||
| 420 | std::vector<std::string> dirnames; | ||
| 421 | |||
| 422 | for (const auto& subdir : dir->GetSubdirectories()) | ||
| 423 | dirnames.push_back(subdir->GetName()); | ||
| 424 | |||
| 425 | for (const auto& subdir : dirnames) { | ||
| 426 | if (!dir->DeleteSubdirectoryRecursive(subdir)) | ||
| 427 | return false; | ||
| 428 | } | ||
| 429 | |||
| 430 | return true; | ||
| 431 | } | ||
| 432 | |||
| 433 | void Boxcat::SetPassphrase(u64 title_id, const Passphrase& passphrase) { | ||
| 434 | LOG_DEBUG(Service_BCAT, "called, title_id={:016X}, passphrase={}", title_id, | ||
| 435 | Common::HexToString(passphrase)); | ||
| 436 | } | ||
| 437 | |||
| 438 | std::optional<std::vector<u8>> Boxcat::GetLaunchParameter(TitleIDVersion title) { | ||
| 439 | const auto bin_file_path = GetBINFilePath(title.title_id); | ||
| 440 | |||
| 441 | if (Settings::values.bcat_boxcat_local) { | ||
| 442 | LOG_INFO(Service_BCAT, "Boxcat using local data by override, skipping download."); | ||
| 443 | } else { | ||
| 444 | Client launch_client{bin_file_path, title.title_id, title.build_id}; | ||
| 445 | |||
| 446 | const auto res = launch_client.DownloadLaunchParam(); | ||
| 447 | if (res != DownloadResult::Success) { | ||
| 448 | LOG_ERROR(Service_BCAT, "Boxcat synchronization failed with error '{}'!", res); | ||
| 449 | |||
| 450 | if (res == DownloadResult::NoMatchBuildId || res == DownloadResult::NoMatchTitleId) { | ||
| 451 | Common::FS::RemoveFile(bin_file_path); | ||
| 452 | } | ||
| 453 | |||
| 454 | HandleDownloadDisplayResult(applet_manager, res); | ||
| 455 | return std::nullopt; | ||
| 456 | } | ||
| 457 | } | ||
| 458 | |||
| 459 | Common::FS::IOFile bin{bin_file_path, Common::FS::FileAccessMode::Read, | ||
| 460 | Common::FS::FileType::BinaryFile}; | ||
| 461 | const auto size = bin.GetSize(); | ||
| 462 | std::vector<u8> bytes(size); | ||
| 463 | if (!bin.IsOpen() || size == 0 || bin.Read(bytes) != bytes.size()) { | ||
| 464 | LOG_ERROR(Service_BCAT, "Boxcat failed to read launch parameter binary at path '{}'!", | ||
| 465 | Common::FS::PathToUTF8String(bin_file_path)); | ||
| 466 | return std::nullopt; | ||
| 467 | } | ||
| 468 | |||
| 469 | return bytes; | ||
| 470 | } | ||
| 471 | |||
| 472 | Boxcat::StatusResult Boxcat::GetStatus(std::optional<std::string>& global, | ||
| 473 | std::map<std::string, EventStatus>& games) { | ||
| 474 | httplib::SSLClient client{BOXCAT_HOSTNAME, static_cast<int>(PORT)}; | ||
| 475 | client.set_connection_timeout(static_cast<int>(TIMEOUT_SECONDS)); | ||
| 476 | client.set_read_timeout(static_cast<int>(TIMEOUT_SECONDS)); | ||
| 477 | client.set_write_timeout(static_cast<int>(TIMEOUT_SECONDS)); | ||
| 478 | |||
| 479 | httplib::Headers headers{ | ||
| 480 | {std::string("Game-Assets-API-Version"), std::string(BOXCAT_API_VERSION)}, | ||
| 481 | {std::string("Boxcat-Client-Type"), std::string(BOXCAT_CLIENT_TYPE)}, | ||
| 482 | }; | ||
| 483 | |||
| 484 | if (!client.is_valid()) { | ||
| 485 | LOG_ERROR(Service_BCAT, "Client is invalid, going offline!"); | ||
| 486 | return StatusResult::Offline; | ||
| 487 | } | ||
| 488 | |||
| 489 | if (!client.is_socket_open()) { | ||
| 490 | LOG_ERROR(Service_BCAT, "Failed to open socket, going offline!"); | ||
| 491 | return StatusResult::Offline; | ||
| 492 | } | ||
| 493 | |||
| 494 | const auto response = client.Get(BOXCAT_PATHNAME_EVENTS, headers); | ||
| 495 | if (response == nullptr) | ||
| 496 | return StatusResult::Offline; | ||
| 497 | |||
| 498 | if (response->status == static_cast<int>(ResponseStatus::BadClientVersion)) | ||
| 499 | return StatusResult::BadClientVersion; | ||
| 500 | |||
| 501 | try { | ||
| 502 | nlohmann::json json = nlohmann::json::parse(response->body); | ||
| 503 | |||
| 504 | if (!json["online"].get<bool>()) | ||
| 505 | return StatusResult::Offline; | ||
| 506 | |||
| 507 | if (json["global"].is_null()) | ||
| 508 | global = std::nullopt; | ||
| 509 | else | ||
| 510 | global = json["global"].get<std::string>(); | ||
| 511 | |||
| 512 | if (json["games"].is_array()) { | ||
| 513 | for (const auto& object : json["games"]) { | ||
| 514 | if (object.is_object() && object.find("name") != object.end()) { | ||
| 515 | EventStatus detail{}; | ||
| 516 | if (object["header"].is_string()) { | ||
| 517 | detail.header = object["header"].get<std::string>(); | ||
| 518 | } else { | ||
| 519 | detail.header = std::nullopt; | ||
| 520 | } | ||
| 521 | |||
| 522 | if (object["footer"].is_string()) { | ||
| 523 | detail.footer = object["footer"].get<std::string>(); | ||
| 524 | } else { | ||
| 525 | detail.footer = std::nullopt; | ||
| 526 | } | ||
| 527 | |||
| 528 | if (object["events"].is_array()) { | ||
| 529 | for (const auto& event : object["events"]) { | ||
| 530 | if (!event.is_string()) | ||
| 531 | continue; | ||
| 532 | detail.events.push_back(event.get<std::string>()); | ||
| 533 | } | ||
| 534 | } | ||
| 535 | |||
| 536 | games.insert_or_assign(object["name"], std::move(detail)); | ||
| 537 | } | ||
| 538 | } | ||
| 539 | } | ||
| 540 | |||
| 541 | return StatusResult::Success; | ||
| 542 | } catch (const nlohmann::json::parse_error& error) { | ||
| 543 | LOG_ERROR(Service_BCAT, "{}", error.what()); | ||
| 544 | return StatusResult::ParseError; | ||
| 545 | } | ||
| 546 | } | ||
| 547 | |||
| 548 | } // namespace Service::BCAT | ||
diff --git a/src/core/hle/service/bcat/backend/boxcat.h b/src/core/hle/service/bcat/backend/boxcat.h deleted file mode 100644 index d65b42e58..000000000 --- a/src/core/hle/service/bcat/backend/boxcat.h +++ /dev/null | |||
| @@ -1,64 +0,0 @@ | |||
| 1 | // Copyright 2019 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <atomic> | ||
| 8 | #include <map> | ||
| 9 | #include <optional> | ||
| 10 | #include "core/hle/service/bcat/backend/backend.h" | ||
| 11 | |||
| 12 | namespace Service::AM::Applets { | ||
| 13 | class AppletManager; | ||
| 14 | } | ||
| 15 | |||
| 16 | namespace Service::BCAT { | ||
| 17 | |||
| 18 | struct EventStatus { | ||
| 19 | std::optional<std::string> header; | ||
| 20 | std::optional<std::string> footer; | ||
| 21 | std::vector<std::string> events; | ||
| 22 | }; | ||
| 23 | |||
| 24 | /// Boxcat is yuzu's custom backend implementation of Nintendo's BCAT service. It is free to use and | ||
| 25 | /// doesn't require a switch or nintendo account. The content is controlled by the yuzu team. | ||
| 26 | class Boxcat final : public Backend { | ||
| 27 | friend void SynchronizeInternal(AM::Applets::AppletManager& applet_manager, | ||
| 28 | DirectoryGetter dir_getter, TitleIDVersion title, | ||
| 29 | ProgressServiceBackend& progress, | ||
| 30 | std::optional<std::string> dir_name); | ||
| 31 | |||
| 32 | public: | ||
| 33 | explicit Boxcat(AM::Applets::AppletManager& applet_manager_, DirectoryGetter getter); | ||
| 34 | ~Boxcat() override; | ||
| 35 | |||
| 36 | bool Synchronize(TitleIDVersion title, ProgressServiceBackend& progress) override; | ||
| 37 | bool SynchronizeDirectory(TitleIDVersion title, std::string name, | ||
| 38 | ProgressServiceBackend& progress) override; | ||
| 39 | |||
| 40 | bool Clear(u64 title_id) override; | ||
| 41 | |||
| 42 | void SetPassphrase(u64 title_id, const Passphrase& passphrase) override; | ||
| 43 | |||
| 44 | std::optional<std::vector<u8>> GetLaunchParameter(TitleIDVersion title) override; | ||
| 45 | |||
| 46 | enum class StatusResult { | ||
| 47 | Success, | ||
| 48 | Offline, | ||
| 49 | ParseError, | ||
| 50 | BadClientVersion, | ||
| 51 | }; | ||
| 52 | |||
| 53 | static StatusResult GetStatus(std::optional<std::string>& global, | ||
| 54 | std::map<std::string, EventStatus>& games); | ||
| 55 | |||
| 56 | private: | ||
| 57 | std::atomic_bool is_syncing{false}; | ||
| 58 | |||
| 59 | class Client; | ||
| 60 | std::unique_ptr<Client> client; | ||
| 61 | AM::Applets::AppletManager& applet_manager; | ||
| 62 | }; | ||
| 63 | |||
| 64 | } // namespace Service::BCAT | ||
diff --git a/src/core/hle/service/bcat/bcat_module.cpp b/src/core/hle/service/bcat/bcat_module.cpp index 72294eb2e..27e9b8df8 100644 --- a/src/core/hle/service/bcat/bcat_module.cpp +++ b/src/core/hle/service/bcat/bcat_module.cpp | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | #include <cctype> | 5 | #include <cctype> |
| 6 | #include <mbedtls/md5.h> | 6 | #include <mbedtls/md5.h> |
| 7 | #include "backend/boxcat.h" | ||
| 8 | #include "common/hex_util.h" | 7 | #include "common/hex_util.h" |
| 9 | #include "common/logging/log.h" | 8 | #include "common/logging/log.h" |
| 10 | #include "common/settings.h" | 9 | #include "common/settings.h" |
| @@ -128,8 +127,8 @@ public: | |||
| 128 | explicit IBcatService(Core::System& system_, Backend& backend_) | 127 | explicit IBcatService(Core::System& system_, Backend& backend_) |
| 129 | : ServiceFramework{system_, "IBcatService"}, backend{backend_}, | 128 | : ServiceFramework{system_, "IBcatService"}, backend{backend_}, |
| 130 | progress{{ | 129 | progress{{ |
| 131 | ProgressServiceBackend{system_.Kernel(), "Normal"}, | 130 | ProgressServiceBackend{system_, "Normal"}, |
| 132 | ProgressServiceBackend{system_.Kernel(), "Directory"}, | 131 | ProgressServiceBackend{system_, "Directory"}, |
| 133 | }} { | 132 | }} { |
| 134 | // clang-format off | 133 | // clang-format off |
| 135 | static const FunctionInfo functions[] = { | 134 | static const FunctionInfo functions[] = { |
| @@ -578,12 +577,6 @@ void Module::Interface::CreateDeliveryCacheStorageServiceWithApplicationId( | |||
| 578 | 577 | ||
| 579 | std::unique_ptr<Backend> CreateBackendFromSettings([[maybe_unused]] Core::System& system, | 578 | std::unique_ptr<Backend> CreateBackendFromSettings([[maybe_unused]] Core::System& system, |
| 580 | DirectoryGetter getter) { | 579 | DirectoryGetter getter) { |
| 581 | #ifdef YUZU_ENABLE_BOXCAT | ||
| 582 | if (Settings::values.bcat_backend.GetValue() == "boxcat") { | ||
| 583 | return std::make_unique<Boxcat>(system.GetAppletManager(), std::move(getter)); | ||
| 584 | } | ||
| 585 | #endif | ||
| 586 | |||
| 587 | return std::make_unique<NullBackend>(std::move(getter)); | 580 | return std::make_unique<NullBackend>(std::move(getter)); |
| 588 | } | 581 | } |
| 589 | 582 | ||
diff --git a/src/core/hle/service/btdrv/btdrv.cpp b/src/core/hle/service/btdrv/btdrv.cpp index 46da438ef..088a1a18a 100644 --- a/src/core/hle/service/btdrv/btdrv.cpp +++ b/src/core/hle/service/btdrv/btdrv.cpp | |||
| @@ -5,11 +5,10 @@ | |||
| 5 | #include "common/logging/log.h" | 5 | #include "common/logging/log.h" |
| 6 | #include "core/core.h" | 6 | #include "core/core.h" |
| 7 | #include "core/hle/ipc_helpers.h" | 7 | #include "core/hle/ipc_helpers.h" |
| 8 | #include "core/hle/kernel/hle_ipc.h" | ||
| 9 | #include "core/hle/kernel/k_event.h" | 8 | #include "core/hle/kernel/k_event.h" |
| 10 | #include "core/hle/kernel/k_readable_event.h" | ||
| 11 | #include "core/hle/kernel/kernel.h" | 9 | #include "core/hle/kernel/kernel.h" |
| 12 | #include "core/hle/service/btdrv/btdrv.h" | 10 | #include "core/hle/service/btdrv/btdrv.h" |
| 11 | #include "core/hle/service/kernel_helpers.h" | ||
| 13 | #include "core/hle/service/service.h" | 12 | #include "core/hle/service/service.h" |
| 14 | #include "core/hle/service/sm/sm.h" | 13 | #include "core/hle/service/sm/sm.h" |
| 15 | 14 | ||
| @@ -18,7 +17,7 @@ namespace Service::BtDrv { | |||
| 18 | class Bt final : public ServiceFramework<Bt> { | 17 | class Bt final : public ServiceFramework<Bt> { |
| 19 | public: | 18 | public: |
| 20 | explicit Bt(Core::System& system_) | 19 | explicit Bt(Core::System& system_) |
| 21 | : ServiceFramework{system_, "bt"}, register_event{system.Kernel()} { | 20 | : ServiceFramework{system_, "bt"}, service_context{system_, "bt"} { |
| 22 | // clang-format off | 21 | // clang-format off |
| 23 | static const FunctionInfo functions[] = { | 22 | static const FunctionInfo functions[] = { |
| 24 | {0, nullptr, "LeClientReadCharacteristic"}, | 23 | {0, nullptr, "LeClientReadCharacteristic"}, |
| @@ -35,8 +34,11 @@ public: | |||
| 35 | // clang-format on | 34 | // clang-format on |
| 36 | RegisterHandlers(functions); | 35 | RegisterHandlers(functions); |
| 37 | 36 | ||
| 38 | Kernel::KAutoObject::Create(std::addressof(register_event)); | 37 | register_event = service_context.CreateEvent("BT:RegisterEvent"); |
| 39 | register_event.Initialize("BT:RegisterEvent"); | 38 | } |
| 39 | |||
| 40 | ~Bt() override { | ||
| 41 | service_context.CloseEvent(register_event); | ||
| 40 | } | 42 | } |
| 41 | 43 | ||
| 42 | private: | 44 | private: |
| @@ -45,10 +47,12 @@ private: | |||
| 45 | 47 | ||
| 46 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 48 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 47 | rb.Push(ResultSuccess); | 49 | rb.Push(ResultSuccess); |
| 48 | rb.PushCopyObjects(register_event.GetReadableEvent()); | 50 | rb.PushCopyObjects(register_event->GetReadableEvent()); |
| 49 | } | 51 | } |
| 50 | 52 | ||
| 51 | Kernel::KEvent register_event; | 53 | KernelHelpers::ServiceContext service_context; |
| 54 | |||
| 55 | Kernel::KEvent* register_event; | ||
| 52 | }; | 56 | }; |
| 53 | 57 | ||
| 54 | class BtDrv final : public ServiceFramework<BtDrv> { | 58 | class BtDrv final : public ServiceFramework<BtDrv> { |
| @@ -175,6 +179,10 @@ public: | |||
| 175 | {143, nullptr, "GetAudioControlInputState"}, | 179 | {143, nullptr, "GetAudioControlInputState"}, |
| 176 | {144, nullptr, "AcquireAudioConnectionStateChangedEvent"}, | 180 | {144, nullptr, "AcquireAudioConnectionStateChangedEvent"}, |
| 177 | {145, nullptr, "GetConnectedAudioDevice"}, | 181 | {145, nullptr, "GetConnectedAudioDevice"}, |
| 182 | {146, nullptr, "CloseAudioControlInput"}, | ||
| 183 | {147, nullptr, "RegisterAudioControlNotification"}, | ||
| 184 | {148, nullptr, "SendAudioControlPassthroughCommand"}, | ||
| 185 | {149, nullptr, "SendAudioControlSetAbsoluteVolumeCommand"}, | ||
| 178 | {256, nullptr, "IsManufacturingMode"}, | 186 | {256, nullptr, "IsManufacturingMode"}, |
| 179 | {257, nullptr, "EmulateBluetoothCrash"}, | 187 | {257, nullptr, "EmulateBluetoothCrash"}, |
| 180 | {258, nullptr, "GetBleChannelMap"}, | 188 | {258, nullptr, "GetBleChannelMap"}, |
diff --git a/src/core/hle/service/btm/btm.cpp b/src/core/hle/service/btm/btm.cpp index 3ab29036a..7aabacc19 100644 --- a/src/core/hle/service/btm/btm.cpp +++ b/src/core/hle/service/btm/btm.cpp | |||
| @@ -7,11 +7,10 @@ | |||
| 7 | #include "common/logging/log.h" | 7 | #include "common/logging/log.h" |
| 8 | #include "core/core.h" | 8 | #include "core/core.h" |
| 9 | #include "core/hle/ipc_helpers.h" | 9 | #include "core/hle/ipc_helpers.h" |
| 10 | #include "core/hle/kernel/hle_ipc.h" | ||
| 11 | #include "core/hle/kernel/k_event.h" | 10 | #include "core/hle/kernel/k_event.h" |
| 12 | #include "core/hle/kernel/k_readable_event.h" | ||
| 13 | #include "core/hle/kernel/kernel.h" | 11 | #include "core/hle/kernel/kernel.h" |
| 14 | #include "core/hle/service/btm/btm.h" | 12 | #include "core/hle/service/btm/btm.h" |
| 13 | #include "core/hle/service/kernel_helpers.h" | ||
| 15 | #include "core/hle/service/service.h" | 14 | #include "core/hle/service/service.h" |
| 16 | 15 | ||
| 17 | namespace Service::BTM { | 16 | namespace Service::BTM { |
| @@ -19,9 +18,7 @@ namespace Service::BTM { | |||
| 19 | class IBtmUserCore final : public ServiceFramework<IBtmUserCore> { | 18 | class IBtmUserCore final : public ServiceFramework<IBtmUserCore> { |
| 20 | public: | 19 | public: |
| 21 | explicit IBtmUserCore(Core::System& system_) | 20 | explicit IBtmUserCore(Core::System& system_) |
| 22 | : ServiceFramework{system_, "IBtmUserCore"}, scan_event{system.Kernel()}, | 21 | : ServiceFramework{system_, "IBtmUserCore"}, service_context{system_, "IBtmUserCore"} { |
| 23 | connection_event{system.Kernel()}, service_discovery{system.Kernel()}, | ||
| 24 | config_event{system.Kernel()} { | ||
| 25 | // clang-format off | 22 | // clang-format off |
| 26 | static const FunctionInfo functions[] = { | 23 | static const FunctionInfo functions[] = { |
| 27 | {0, &IBtmUserCore::AcquireBleScanEvent, "AcquireBleScanEvent"}, | 24 | {0, &IBtmUserCore::AcquireBleScanEvent, "AcquireBleScanEvent"}, |
| @@ -60,15 +57,17 @@ public: | |||
| 60 | // clang-format on | 57 | // clang-format on |
| 61 | RegisterHandlers(functions); | 58 | RegisterHandlers(functions); |
| 62 | 59 | ||
| 63 | Kernel::KAutoObject::Create(std::addressof(scan_event)); | 60 | scan_event = service_context.CreateEvent("IBtmUserCore:ScanEvent"); |
| 64 | Kernel::KAutoObject::Create(std::addressof(connection_event)); | 61 | connection_event = service_context.CreateEvent("IBtmUserCore:ConnectionEvent"); |
| 65 | Kernel::KAutoObject::Create(std::addressof(service_discovery)); | 62 | service_discovery_event = service_context.CreateEvent("IBtmUserCore:DiscoveryEvent"); |
| 66 | Kernel::KAutoObject::Create(std::addressof(config_event)); | 63 | config_event = service_context.CreateEvent("IBtmUserCore:ConfigEvent"); |
| 64 | } | ||
| 67 | 65 | ||
| 68 | scan_event.Initialize("IBtmUserCore:ScanEvent"); | 66 | ~IBtmUserCore() override { |
| 69 | connection_event.Initialize("IBtmUserCore:ConnectionEvent"); | 67 | service_context.CloseEvent(scan_event); |
| 70 | service_discovery.Initialize("IBtmUserCore:Discovery"); | 68 | service_context.CloseEvent(connection_event); |
| 71 | config_event.Initialize("IBtmUserCore:ConfigEvent"); | 69 | service_context.CloseEvent(service_discovery_event); |
| 70 | service_context.CloseEvent(config_event); | ||
| 72 | } | 71 | } |
| 73 | 72 | ||
| 74 | private: | 73 | private: |
| @@ -77,7 +76,7 @@ private: | |||
| 77 | 76 | ||
| 78 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 77 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 79 | rb.Push(ResultSuccess); | 78 | rb.Push(ResultSuccess); |
| 80 | rb.PushCopyObjects(scan_event.GetReadableEvent()); | 79 | rb.PushCopyObjects(scan_event->GetReadableEvent()); |
| 81 | } | 80 | } |
| 82 | 81 | ||
| 83 | void AcquireBleConnectionEvent(Kernel::HLERequestContext& ctx) { | 82 | void AcquireBleConnectionEvent(Kernel::HLERequestContext& ctx) { |
| @@ -85,7 +84,7 @@ private: | |||
| 85 | 84 | ||
| 86 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 85 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 87 | rb.Push(ResultSuccess); | 86 | rb.Push(ResultSuccess); |
| 88 | rb.PushCopyObjects(connection_event.GetReadableEvent()); | 87 | rb.PushCopyObjects(connection_event->GetReadableEvent()); |
| 89 | } | 88 | } |
| 90 | 89 | ||
| 91 | void AcquireBleServiceDiscoveryEvent(Kernel::HLERequestContext& ctx) { | 90 | void AcquireBleServiceDiscoveryEvent(Kernel::HLERequestContext& ctx) { |
| @@ -93,7 +92,7 @@ private: | |||
| 93 | 92 | ||
| 94 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 93 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 95 | rb.Push(ResultSuccess); | 94 | rb.Push(ResultSuccess); |
| 96 | rb.PushCopyObjects(service_discovery.GetReadableEvent()); | 95 | rb.PushCopyObjects(service_discovery_event->GetReadableEvent()); |
| 97 | } | 96 | } |
| 98 | 97 | ||
| 99 | void AcquireBleMtuConfigEvent(Kernel::HLERequestContext& ctx) { | 98 | void AcquireBleMtuConfigEvent(Kernel::HLERequestContext& ctx) { |
| @@ -101,13 +100,15 @@ private: | |||
| 101 | 100 | ||
| 102 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 101 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 103 | rb.Push(ResultSuccess); | 102 | rb.Push(ResultSuccess); |
| 104 | rb.PushCopyObjects(config_event.GetReadableEvent()); | 103 | rb.PushCopyObjects(config_event->GetReadableEvent()); |
| 105 | } | 104 | } |
| 106 | 105 | ||
| 107 | Kernel::KEvent scan_event; | 106 | KernelHelpers::ServiceContext service_context; |
| 108 | Kernel::KEvent connection_event; | 107 | |
| 109 | Kernel::KEvent service_discovery; | 108 | Kernel::KEvent* scan_event; |
| 110 | Kernel::KEvent config_event; | 109 | Kernel::KEvent* connection_event; |
| 110 | Kernel::KEvent* service_discovery_event; | ||
| 111 | Kernel::KEvent* config_event; | ||
| 111 | }; | 112 | }; |
| 112 | 113 | ||
| 113 | class BTM_USR final : public ServiceFramework<BTM_USR> { | 114 | class BTM_USR final : public ServiceFramework<BTM_USR> { |
diff --git a/src/core/hle/service/caps/caps.h b/src/core/hle/service/caps/caps.h index 3c4290c88..b18adcb9d 100644 --- a/src/core/hle/service/caps/caps.h +++ b/src/core/hle/service/caps/caps.h | |||
| @@ -4,7 +4,8 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include "core/hle/service/service.h" | 7 | #include "common/common_funcs.h" |
| 8 | #include "common/common_types.h" | ||
| 8 | 9 | ||
| 9 | namespace Core { | 10 | namespace Core { |
| 10 | class System; | 11 | class System; |
diff --git a/src/core/hle/service/caps/caps_ss.cpp b/src/core/hle/service/caps/caps_ss.cpp index 2b5314691..33a976ddf 100644 --- a/src/core/hle/service/caps/caps_ss.cpp +++ b/src/core/hle/service/caps/caps_ss.cpp | |||
| @@ -15,6 +15,7 @@ CAPS_SS::CAPS_SS(Core::System& system_) : ServiceFramework{system_, "caps:ss"} { | |||
| 15 | {204, nullptr, "SaveEditedScreenShotEx0"}, | 15 | {204, nullptr, "SaveEditedScreenShotEx0"}, |
| 16 | {206, nullptr, "Unknown206"}, | 16 | {206, nullptr, "Unknown206"}, |
| 17 | {208, nullptr, "SaveScreenShotOfMovieEx1"}, | 17 | {208, nullptr, "SaveScreenShotOfMovieEx1"}, |
| 18 | {1000, nullptr, "Unknown1000"}, | ||
| 18 | }; | 19 | }; |
| 19 | // clang-format on | 20 | // clang-format on |
| 20 | 21 | ||
diff --git a/src/core/hle/service/es/es.cpp b/src/core/hle/service/es/es.cpp index 110c7cb1c..f6184acc9 100644 --- a/src/core/hle/service/es/es.cpp +++ b/src/core/hle/service/es/es.cpp | |||
| @@ -55,6 +55,8 @@ public: | |||
| 55 | {36, nullptr, "DeleteAllInactiveELicenseRequiredPersonalizedTicket"}, | 55 | {36, nullptr, "DeleteAllInactiveELicenseRequiredPersonalizedTicket"}, |
| 56 | {37, nullptr, "OwnTicket2"}, | 56 | {37, nullptr, "OwnTicket2"}, |
| 57 | {38, nullptr, "OwnTicket3"}, | 57 | {38, nullptr, "OwnTicket3"}, |
| 58 | {39, nullptr, "DeleteAllInactivePersonalizedTicket"}, | ||
| 59 | {40, nullptr, "DeletePrepurchaseRecordByNintendoAccountId"}, | ||
| 58 | {501, nullptr, "Unknown501"}, | 60 | {501, nullptr, "Unknown501"}, |
| 59 | {502, nullptr, "Unknown502"}, | 61 | {502, nullptr, "Unknown502"}, |
| 60 | {503, nullptr, "GetTitleKey"}, | 62 | {503, nullptr, "GetTitleKey"}, |
| @@ -88,11 +90,15 @@ public: | |||
| 88 | {1503, nullptr, "Unknown1503"}, | 90 | {1503, nullptr, "Unknown1503"}, |
| 89 | {1504, nullptr, "Unknown1504"}, | 91 | {1504, nullptr, "Unknown1504"}, |
| 90 | {1505, nullptr, "Unknown1505"}, | 92 | {1505, nullptr, "Unknown1505"}, |
| 93 | {1506, nullptr, "Unknown1506"}, | ||
| 91 | {2000, nullptr, "Unknown2000"}, | 94 | {2000, nullptr, "Unknown2000"}, |
| 92 | {2001, nullptr, "Unknown2001"}, | 95 | {2001, nullptr, "Unknown2001"}, |
| 96 | {2002, nullptr, "Unknown2002"}, | ||
| 97 | {2003, nullptr, "Unknown2003"}, | ||
| 93 | {2100, nullptr, "Unknown2100"}, | 98 | {2100, nullptr, "Unknown2100"}, |
| 94 | {2501, nullptr, "Unknown2501"}, | 99 | {2501, nullptr, "Unknown2501"}, |
| 95 | {2502, nullptr, "Unknown2502"}, | 100 | {2502, nullptr, "Unknown2502"}, |
| 101 | {2601, nullptr, "Unknown2601"}, | ||
| 96 | {3001, nullptr, "Unknown3001"}, | 102 | {3001, nullptr, "Unknown3001"}, |
| 97 | {3002, nullptr, "Unknown3002"}, | 103 | {3002, nullptr, "Unknown3002"}, |
| 98 | }; | 104 | }; |
diff --git a/src/core/hle/service/fgm/fgm.cpp b/src/core/hle/service/fgm/fgm.cpp index 25c6c0194..d7a638f96 100644 --- a/src/core/hle/service/fgm/fgm.cpp +++ b/src/core/hle/service/fgm/fgm.cpp | |||
| @@ -5,7 +5,6 @@ | |||
| 5 | #include <memory> | 5 | #include <memory> |
| 6 | 6 | ||
| 7 | #include "core/hle/ipc_helpers.h" | 7 | #include "core/hle/ipc_helpers.h" |
| 8 | #include "core/hle/kernel/hle_ipc.h" | ||
| 9 | #include "core/hle/service/fgm/fgm.h" | 8 | #include "core/hle/service/fgm/fgm.h" |
| 10 | #include "core/hle/service/service.h" | 9 | #include "core/hle/service/service.h" |
| 11 | #include "core/hle/service/sm/sm.h" | 10 | #include "core/hle/service/sm/sm.h" |
diff --git a/src/core/hle/service/filesystem/fsp_ldr.cpp b/src/core/hle/service/filesystem/fsp_ldr.cpp index 1f6c17ba5..f112ae9d0 100644 --- a/src/core/hle/service/filesystem/fsp_ldr.cpp +++ b/src/core/hle/service/filesystem/fsp_ldr.cpp | |||
| @@ -3,7 +3,6 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "core/hle/service/filesystem/fsp_ldr.h" | 5 | #include "core/hle/service/filesystem/fsp_ldr.h" |
| 6 | #include "core/hle/service/service.h" | ||
| 7 | 6 | ||
| 8 | namespace Service::FileSystem { | 7 | namespace Service::FileSystem { |
| 9 | 8 | ||
diff --git a/src/core/hle/service/filesystem/fsp_pr.cpp b/src/core/hle/service/filesystem/fsp_pr.cpp index 00e4d1662..9b7f7d861 100644 --- a/src/core/hle/service/filesystem/fsp_pr.cpp +++ b/src/core/hle/service/filesystem/fsp_pr.cpp | |||
| @@ -3,7 +3,6 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "core/hle/service/filesystem/fsp_pr.h" | 5 | #include "core/hle/service/filesystem/fsp_pr.h" |
| 6 | #include "core/hle/service/service.h" | ||
| 7 | 6 | ||
| 8 | namespace Service::FileSystem { | 7 | namespace Service::FileSystem { |
| 9 | 8 | ||
diff --git a/src/core/hle/service/friend/friend.cpp b/src/core/hle/service/friend/friend.cpp index b58c152ce..68c9240ae 100644 --- a/src/core/hle/service/friend/friend.cpp +++ b/src/core/hle/service/friend/friend.cpp | |||
| @@ -8,11 +8,10 @@ | |||
| 8 | #include "core/core.h" | 8 | #include "core/core.h" |
| 9 | #include "core/hle/ipc_helpers.h" | 9 | #include "core/hle/ipc_helpers.h" |
| 10 | #include "core/hle/kernel/k_event.h" | 10 | #include "core/hle/kernel/k_event.h" |
| 11 | #include "core/hle/kernel/k_readable_event.h" | ||
| 12 | #include "core/hle/kernel/k_writable_event.h" | ||
| 13 | #include "core/hle/service/friend/errors.h" | 11 | #include "core/hle/service/friend/errors.h" |
| 14 | #include "core/hle/service/friend/friend.h" | 12 | #include "core/hle/service/friend/friend.h" |
| 15 | #include "core/hle/service/friend/friend_interface.h" | 13 | #include "core/hle/service/friend/friend_interface.h" |
| 14 | #include "core/hle/service/kernel_helpers.h" | ||
| 16 | 15 | ||
| 17 | namespace Service::Friend { | 16 | namespace Service::Friend { |
| 18 | 17 | ||
| @@ -184,9 +183,9 @@ private: | |||
| 184 | 183 | ||
| 185 | class INotificationService final : public ServiceFramework<INotificationService> { | 184 | class INotificationService final : public ServiceFramework<INotificationService> { |
| 186 | public: | 185 | public: |
| 187 | explicit INotificationService(Common::UUID uuid_, Core::System& system_) | 186 | explicit INotificationService(Core::System& system_, Common::UUID uuid_) |
| 188 | : ServiceFramework{system_, "INotificationService"}, uuid{uuid_}, notification_event{ | 187 | : ServiceFramework{system_, "INotificationService"}, uuid{uuid_}, |
| 189 | system.Kernel()} { | 188 | service_context{system_, "INotificationService"} { |
| 190 | // clang-format off | 189 | // clang-format off |
| 191 | static const FunctionInfo functions[] = { | 190 | static const FunctionInfo functions[] = { |
| 192 | {0, &INotificationService::GetEvent, "GetEvent"}, | 191 | {0, &INotificationService::GetEvent, "GetEvent"}, |
| @@ -197,8 +196,11 @@ public: | |||
| 197 | 196 | ||
| 198 | RegisterHandlers(functions); | 197 | RegisterHandlers(functions); |
| 199 | 198 | ||
| 200 | Kernel::KAutoObject::Create(std::addressof(notification_event)); | 199 | notification_event = service_context.CreateEvent("INotificationService:NotifyEvent"); |
| 201 | notification_event.Initialize("INotificationService:NotifyEvent"); | 200 | } |
| 201 | |||
| 202 | ~INotificationService() override { | ||
| 203 | service_context.CloseEvent(notification_event); | ||
| 202 | } | 204 | } |
| 203 | 205 | ||
| 204 | private: | 206 | private: |
| @@ -207,7 +209,7 @@ private: | |||
| 207 | 209 | ||
| 208 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 210 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 209 | rb.Push(ResultSuccess); | 211 | rb.Push(ResultSuccess); |
| 210 | rb.PushCopyObjects(notification_event.GetReadableEvent()); | 212 | rb.PushCopyObjects(notification_event->GetReadableEvent()); |
| 211 | } | 213 | } |
| 212 | 214 | ||
| 213 | void Clear(Kernel::HLERequestContext& ctx) { | 215 | void Clear(Kernel::HLERequestContext& ctx) { |
| @@ -272,8 +274,10 @@ private: | |||
| 272 | bool has_received_friend_request; | 274 | bool has_received_friend_request; |
| 273 | }; | 275 | }; |
| 274 | 276 | ||
| 275 | Common::UUID uuid{Common::INVALID_UUID}; | 277 | Common::UUID uuid; |
| 276 | Kernel::KEvent notification_event; | 278 | KernelHelpers::ServiceContext service_context; |
| 279 | |||
| 280 | Kernel::KEvent* notification_event; | ||
| 277 | std::queue<SizedNotificationInfo> notifications; | 281 | std::queue<SizedNotificationInfo> notifications; |
| 278 | States states{}; | 282 | States states{}; |
| 279 | }; | 283 | }; |
| @@ -293,7 +297,7 @@ void Module::Interface::CreateNotificationService(Kernel::HLERequestContext& ctx | |||
| 293 | 297 | ||
| 294 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 298 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 295 | rb.Push(ResultSuccess); | 299 | rb.Push(ResultSuccess); |
| 296 | rb.PushIpcInterface<INotificationService>(uuid, system); | 300 | rb.PushIpcInterface<INotificationService>(system, uuid); |
| 297 | } | 301 | } |
| 298 | 302 | ||
| 299 | Module::Interface::Interface(std::shared_ptr<Module> module_, Core::System& system_, | 303 | Module::Interface::Interface(std::shared_ptr<Module> module_, Core::System& system_, |
diff --git a/src/core/hle/service/glue/arp.cpp b/src/core/hle/service/glue/arp.cpp index 5a3b54cc1..70cd63c6b 100644 --- a/src/core/hle/service/glue/arp.cpp +++ b/src/core/hle/service/glue/arp.cpp | |||
| @@ -8,13 +8,11 @@ | |||
| 8 | #include "core/core.h" | 8 | #include "core/core.h" |
| 9 | #include "core/file_sys/control_metadata.h" | 9 | #include "core/file_sys/control_metadata.h" |
| 10 | #include "core/hle/ipc_helpers.h" | 10 | #include "core/hle/ipc_helpers.h" |
| 11 | #include "core/hle/kernel/hle_ipc.h" | ||
| 12 | #include "core/hle/kernel/k_process.h" | 11 | #include "core/hle/kernel/k_process.h" |
| 13 | #include "core/hle/kernel/kernel.h" | 12 | #include "core/hle/kernel/kernel.h" |
| 14 | #include "core/hle/service/glue/arp.h" | 13 | #include "core/hle/service/glue/arp.h" |
| 15 | #include "core/hle/service/glue/errors.h" | 14 | #include "core/hle/service/glue/errors.h" |
| 16 | #include "core/hle/service/glue/glue_manager.h" | 15 | #include "core/hle/service/glue/glue_manager.h" |
| 17 | #include "core/hle/service/service.h" | ||
| 18 | 16 | ||
| 19 | namespace Service::Glue { | 17 | namespace Service::Glue { |
| 20 | 18 | ||
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index 4fcc6f93a..9ee146caf 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h | |||
| @@ -507,6 +507,7 @@ private: | |||
| 507 | LarkNesRight = 18, | 507 | LarkNesRight = 18, |
| 508 | Lucia = 19, | 508 | Lucia = 19, |
| 509 | Verification = 20, | 509 | Verification = 20, |
| 510 | Lagon = 21, | ||
| 510 | }; | 511 | }; |
| 511 | 512 | ||
| 512 | struct NPadEntry { | 513 | struct NPadEntry { |
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index a1707a72a..043320d50 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp | |||
| @@ -8,12 +8,9 @@ | |||
| 8 | #include "common/settings.h" | 8 | #include "common/settings.h" |
| 9 | #include "core/core.h" | 9 | #include "core/core.h" |
| 10 | #include "core/core_timing.h" | 10 | #include "core/core_timing.h" |
| 11 | #include "core/core_timing_util.h" | ||
| 12 | #include "core/frontend/emu_window.h" | 11 | #include "core/frontend/emu_window.h" |
| 13 | #include "core/frontend/input.h" | 12 | #include "core/frontend/input.h" |
| 14 | #include "core/hardware_properties.h" | ||
| 15 | #include "core/hle/ipc_helpers.h" | 13 | #include "core/hle/ipc_helpers.h" |
| 16 | #include "core/hle/kernel/k_client_port.h" | ||
| 17 | #include "core/hle/kernel/k_readable_event.h" | 14 | #include "core/hle/kernel/k_readable_event.h" |
| 18 | #include "core/hle/kernel/k_shared_memory.h" | 15 | #include "core/hle/kernel/k_shared_memory.h" |
| 19 | #include "core/hle/kernel/k_transfer_memory.h" | 16 | #include "core/hle/kernel/k_transfer_memory.h" |
| @@ -23,7 +20,6 @@ | |||
| 23 | #include "core/hle/service/hid/hid.h" | 20 | #include "core/hle/service/hid/hid.h" |
| 24 | #include "core/hle/service/hid/irs.h" | 21 | #include "core/hle/service/hid/irs.h" |
| 25 | #include "core/hle/service/hid/xcd.h" | 22 | #include "core/hle/service/hid/xcd.h" |
| 26 | #include "core/hle/service/service.h" | ||
| 27 | #include "core/memory.h" | 23 | #include "core/memory.h" |
| 28 | 24 | ||
| 29 | #include "core/hle/service/hid/controllers/console_sixaxis.h" | 25 | #include "core/hle/service/hid/controllers/console_sixaxis.h" |
| @@ -106,7 +102,7 @@ void IAppletResource::DeactivateController(HidController controller) { | |||
| 106 | controllers[static_cast<size_t>(controller)]->DeactivateController(); | 102 | controllers[static_cast<size_t>(controller)]->DeactivateController(); |
| 107 | } | 103 | } |
| 108 | 104 | ||
| 109 | IAppletResource ::~IAppletResource() { | 105 | IAppletResource::~IAppletResource() { |
| 110 | system.CoreTiming().UnscheduleEvent(pad_update_event, 0); | 106 | system.CoreTiming().UnscheduleEvent(pad_update_event, 0); |
| 111 | system.CoreTiming().UnscheduleEvent(motion_update_event, 0); | 107 | system.CoreTiming().UnscheduleEvent(motion_update_event, 0); |
| 112 | } | 108 | } |
| @@ -239,6 +235,12 @@ Hid::Hid(Core::System& system_) | |||
| 239 | {81, &Hid::ResetGyroscopeZeroDriftMode, "ResetGyroscopeZeroDriftMode"}, | 235 | {81, &Hid::ResetGyroscopeZeroDriftMode, "ResetGyroscopeZeroDriftMode"}, |
| 240 | {82, &Hid::IsSixAxisSensorAtRest, "IsSixAxisSensorAtRest"}, | 236 | {82, &Hid::IsSixAxisSensorAtRest, "IsSixAxisSensorAtRest"}, |
| 241 | {83, &Hid::IsFirmwareUpdateAvailableForSixAxisSensor, "IsFirmwareUpdateAvailableForSixAxisSensor"}, | 237 | {83, &Hid::IsFirmwareUpdateAvailableForSixAxisSensor, "IsFirmwareUpdateAvailableForSixAxisSensor"}, |
| 238 | {84, nullptr, "EnableSixAxisSensorUnalteredPassthrough"}, | ||
| 239 | {85, nullptr, "IsSixAxisSensorUnalteredPassthroughEnabled"}, | ||
| 240 | {86, nullptr, "StoreSixAxisSensorCalibrationParameter"}, | ||
| 241 | {87, nullptr, "LoadSixAxisSensorCalibrationParameter"}, | ||
| 242 | {88, nullptr, "GetSixAxisSensorIcInformation"}, | ||
| 243 | {89, nullptr, "ResetIsSixAxisSensorDeviceNewlyAssigned"}, | ||
| 242 | {91, &Hid::ActivateGesture, "ActivateGesture"}, | 244 | {91, &Hid::ActivateGesture, "ActivateGesture"}, |
| 243 | {100, &Hid::SetSupportedNpadStyleSet, "SetSupportedNpadStyleSet"}, | 245 | {100, &Hid::SetSupportedNpadStyleSet, "SetSupportedNpadStyleSet"}, |
| 244 | {101, &Hid::GetSupportedNpadStyleSet, "GetSupportedNpadStyleSet"}, | 246 | {101, &Hid::GetSupportedNpadStyleSet, "GetSupportedNpadStyleSet"}, |
| @@ -1656,6 +1658,9 @@ public: | |||
| 1656 | {12, nullptr, "UnsetTouchScreenAutoPilotState"}, | 1658 | {12, nullptr, "UnsetTouchScreenAutoPilotState"}, |
| 1657 | {13, nullptr, "GetTouchScreenConfiguration"}, | 1659 | {13, nullptr, "GetTouchScreenConfiguration"}, |
| 1658 | {14, nullptr, "ProcessTouchScreenAutoTune"}, | 1660 | {14, nullptr, "ProcessTouchScreenAutoTune"}, |
| 1661 | {15, nullptr, "ForceStopTouchScreenManagement"}, | ||
| 1662 | {16, nullptr, "ForceRestartTouchScreenManagement"}, | ||
| 1663 | {17, nullptr, "IsTouchScreenManaged"}, | ||
| 1659 | {20, nullptr, "DeactivateMouse"}, | 1664 | {20, nullptr, "DeactivateMouse"}, |
| 1660 | {21, nullptr, "SetMouseAutoPilotState"}, | 1665 | {21, nullptr, "SetMouseAutoPilotState"}, |
| 1661 | {22, nullptr, "UnsetMouseAutoPilotState"}, | 1666 | {22, nullptr, "UnsetMouseAutoPilotState"}, |
diff --git a/src/core/hle/service/lbl/lbl.cpp b/src/core/hle/service/lbl/lbl.cpp index 24890c830..5c8ae029c 100644 --- a/src/core/hle/service/lbl/lbl.cpp +++ b/src/core/hle/service/lbl/lbl.cpp | |||
| @@ -2,11 +2,11 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <cmath> | ||
| 5 | #include <memory> | 6 | #include <memory> |
| 6 | 7 | ||
| 7 | #include "common/logging/log.h" | 8 | #include "common/logging/log.h" |
| 8 | #include "core/hle/ipc_helpers.h" | 9 | #include "core/hle/ipc_helpers.h" |
| 9 | #include "core/hle/kernel/hle_ipc.h" | ||
| 10 | #include "core/hle/service/lbl/lbl.h" | 10 | #include "core/hle/service/lbl/lbl.h" |
| 11 | #include "core/hle/service/service.h" | 11 | #include "core/hle/service/service.h" |
| 12 | #include "core/hle/service/sm/sm.h" | 12 | #include "core/hle/service/sm/sm.h" |
diff --git a/src/core/hle/service/mii/mii.cpp b/src/core/hle/service/mii/mii.cpp index 9d863486a..0b907824d 100644 --- a/src/core/hle/service/mii/mii.cpp +++ b/src/core/hle/service/mii/mii.cpp | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | 6 | ||
| 7 | #include "common/logging/log.h" | 7 | #include "common/logging/log.h" |
| 8 | #include "core/hle/ipc_helpers.h" | 8 | #include "core/hle/ipc_helpers.h" |
| 9 | #include "core/hle/kernel/hle_ipc.h" | ||
| 10 | #include "core/hle/service/mii/mii.h" | 9 | #include "core/hle/service/mii/mii.h" |
| 11 | #include "core/hle/service/mii/mii_manager.h" | 10 | #include "core/hle/service/mii/mii_manager.h" |
| 12 | #include "core/hle/service/service.h" | 11 | #include "core/hle/service/service.h" |
diff --git a/src/core/hle/service/nfc/nfc.cpp b/src/core/hle/service/nfc/nfc.cpp index b014ea826..f77037842 100644 --- a/src/core/hle/service/nfc/nfc.cpp +++ b/src/core/hle/service/nfc/nfc.cpp | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | #include "common/logging/log.h" | 7 | #include "common/logging/log.h" |
| 8 | #include "common/settings.h" | 8 | #include "common/settings.h" |
| 9 | #include "core/hle/ipc_helpers.h" | 9 | #include "core/hle/ipc_helpers.h" |
| 10 | #include "core/hle/kernel/hle_ipc.h" | ||
| 11 | #include "core/hle/service/nfc/nfc.h" | 10 | #include "core/hle/service/nfc/nfc.h" |
| 12 | #include "core/hle/service/service.h" | 11 | #include "core/hle/service/service.h" |
| 13 | #include "core/hle/service/sm/sm.h" | 12 | #include "core/hle/service/sm/sm.h" |
diff --git a/src/core/hle/service/nfp/nfp.cpp b/src/core/hle/service/nfp/nfp.cpp index 5f1ca029d..6791f20a5 100644 --- a/src/core/hle/service/nfp/nfp.cpp +++ b/src/core/hle/service/nfp/nfp.cpp | |||
| @@ -8,9 +8,8 @@ | |||
| 8 | #include "common/logging/log.h" | 8 | #include "common/logging/log.h" |
| 9 | #include "core/core.h" | 9 | #include "core/core.h" |
| 10 | #include "core/hle/ipc_helpers.h" | 10 | #include "core/hle/ipc_helpers.h" |
| 11 | #include "core/hle/kernel/k_readable_event.h" | 11 | #include "core/hle/kernel/k_event.h" |
| 12 | #include "core/hle/kernel/k_thread.h" | 12 | #include "core/hle/kernel/k_thread.h" |
| 13 | #include "core/hle/kernel/k_writable_event.h" | ||
| 14 | #include "core/hle/kernel/kernel.h" | 13 | #include "core/hle/kernel/kernel.h" |
| 15 | #include "core/hle/lock.h" | 14 | #include "core/hle/lock.h" |
| 16 | #include "core/hle/service/nfp/nfp.h" | 15 | #include "core/hle/service/nfp/nfp.h" |
| @@ -23,18 +22,21 @@ constexpr ResultCode ERR_NO_APPLICATION_AREA(ErrorModule::NFP, 152); | |||
| 23 | 22 | ||
| 24 | Module::Interface::Interface(std::shared_ptr<Module> module_, Core::System& system_, | 23 | Module::Interface::Interface(std::shared_ptr<Module> module_, Core::System& system_, |
| 25 | const char* name) | 24 | const char* name) |
| 26 | : ServiceFramework{system_, name}, nfc_tag_load{system.Kernel()}, module{std::move(module_)} { | 25 | : ServiceFramework{system_, name}, module{std::move(module_)}, service_context{system_, |
| 27 | Kernel::KAutoObject::Create(std::addressof(nfc_tag_load)); | 26 | "NFP::IUser"} { |
| 28 | nfc_tag_load.Initialize("IUser:NFCTagDetected"); | 27 | nfc_tag_load = service_context.CreateEvent("NFP::IUser:NFCTagDetected"); |
| 29 | } | 28 | } |
| 30 | 29 | ||
| 31 | Module::Interface::~Interface() = default; | 30 | Module::Interface::~Interface() { |
| 31 | service_context.CloseEvent(nfc_tag_load); | ||
| 32 | } | ||
| 32 | 33 | ||
| 33 | class IUser final : public ServiceFramework<IUser> { | 34 | class IUser final : public ServiceFramework<IUser> { |
| 34 | public: | 35 | public: |
| 35 | explicit IUser(Module::Interface& nfp_interface_, Core::System& system_) | 36 | explicit IUser(Module::Interface& nfp_interface_, Core::System& system_, |
| 37 | KernelHelpers::ServiceContext& service_context_) | ||
| 36 | : ServiceFramework{system_, "NFP::IUser"}, nfp_interface{nfp_interface_}, | 38 | : ServiceFramework{system_, "NFP::IUser"}, nfp_interface{nfp_interface_}, |
| 37 | deactivate_event{system.Kernel()}, availability_change_event{system.Kernel()} { | 39 | service_context{service_context_} { |
| 38 | static const FunctionInfo functions[] = { | 40 | static const FunctionInfo functions[] = { |
| 39 | {0, &IUser::Initialize, "Initialize"}, | 41 | {0, &IUser::Initialize, "Initialize"}, |
| 40 | {1, &IUser::Finalize, "Finalize"}, | 42 | {1, &IUser::Finalize, "Finalize"}, |
| @@ -64,11 +66,14 @@ public: | |||
| 64 | }; | 66 | }; |
| 65 | RegisterHandlers(functions); | 67 | RegisterHandlers(functions); |
| 66 | 68 | ||
| 67 | Kernel::KAutoObject::Create(std::addressof(deactivate_event)); | 69 | deactivate_event = service_context.CreateEvent("NFP::IUser:DeactivateEvent"); |
| 68 | Kernel::KAutoObject::Create(std::addressof(availability_change_event)); | 70 | availability_change_event = |
| 71 | service_context.CreateEvent("NFP::IUser:AvailabilityChangeEvent"); | ||
| 72 | } | ||
| 69 | 73 | ||
| 70 | deactivate_event.Initialize("IUser:DeactivateEvent"); | 74 | ~IUser() override { |
| 71 | availability_change_event.Initialize("IUser:AvailabilityChangeEvent"); | 75 | service_context.CloseEvent(deactivate_event); |
| 76 | service_context.CloseEvent(availability_change_event); | ||
| 72 | } | 77 | } |
| 73 | 78 | ||
| 74 | private: | 79 | private: |
| @@ -166,7 +171,7 @@ private: | |||
| 166 | 171 | ||
| 167 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 172 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 168 | rb.Push(ResultSuccess); | 173 | rb.Push(ResultSuccess); |
| 169 | rb.PushCopyObjects(deactivate_event.GetReadableEvent()); | 174 | rb.PushCopyObjects(deactivate_event->GetReadableEvent()); |
| 170 | } | 175 | } |
| 171 | 176 | ||
| 172 | void StopDetection(Kernel::HLERequestContext& ctx) { | 177 | void StopDetection(Kernel::HLERequestContext& ctx) { |
| @@ -175,7 +180,7 @@ private: | |||
| 175 | switch (device_state) { | 180 | switch (device_state) { |
| 176 | case DeviceState::TagFound: | 181 | case DeviceState::TagFound: |
| 177 | case DeviceState::TagNearby: | 182 | case DeviceState::TagNearby: |
| 178 | deactivate_event.GetWritableEvent().Signal(); | 183 | deactivate_event->GetWritableEvent().Signal(); |
| 179 | device_state = DeviceState::Initialized; | 184 | device_state = DeviceState::Initialized; |
| 180 | break; | 185 | break; |
| 181 | case DeviceState::SearchingForTag: | 186 | case DeviceState::SearchingForTag: |
| @@ -264,7 +269,7 @@ private: | |||
| 264 | 269 | ||
| 265 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 270 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 266 | rb.Push(ResultSuccess); | 271 | rb.Push(ResultSuccess); |
| 267 | rb.PushCopyObjects(availability_change_event.GetReadableEvent()); | 272 | rb.PushCopyObjects(availability_change_event->GetReadableEvent()); |
| 268 | } | 273 | } |
| 269 | 274 | ||
| 270 | void GetRegisterInfo(Kernel::HLERequestContext& ctx) { | 275 | void GetRegisterInfo(Kernel::HLERequestContext& ctx) { |
| @@ -313,14 +318,16 @@ private: | |||
| 313 | rb.PushRaw<u32>(0); // This is from the GetCommonInfo stub | 318 | rb.PushRaw<u32>(0); // This is from the GetCommonInfo stub |
| 314 | } | 319 | } |
| 315 | 320 | ||
| 321 | Module::Interface& nfp_interface; | ||
| 322 | KernelHelpers::ServiceContext& service_context; | ||
| 323 | |||
| 316 | bool has_attached_handle{}; | 324 | bool has_attached_handle{}; |
| 317 | const u64 device_handle{0}; // Npad device 1 | 325 | const u64 device_handle{0}; // Npad device 1 |
| 318 | const u32 npad_id{0}; // Player 1 controller | 326 | const u32 npad_id{0}; // Player 1 controller |
| 319 | State state{State::NonInitialized}; | 327 | State state{State::NonInitialized}; |
| 320 | DeviceState device_state{DeviceState::Initialized}; | 328 | DeviceState device_state{DeviceState::Initialized}; |
| 321 | Module::Interface& nfp_interface; | 329 | Kernel::KEvent* deactivate_event; |
| 322 | Kernel::KEvent deactivate_event; | 330 | Kernel::KEvent* availability_change_event; |
| 323 | Kernel::KEvent availability_change_event; | ||
| 324 | }; | 331 | }; |
| 325 | 332 | ||
| 326 | void Module::Interface::CreateUserInterface(Kernel::HLERequestContext& ctx) { | 333 | void Module::Interface::CreateUserInterface(Kernel::HLERequestContext& ctx) { |
| @@ -328,7 +335,7 @@ void Module::Interface::CreateUserInterface(Kernel::HLERequestContext& ctx) { | |||
| 328 | 335 | ||
| 329 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 336 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 330 | rb.Push(ResultSuccess); | 337 | rb.Push(ResultSuccess); |
| 331 | rb.PushIpcInterface<IUser>(*this, system); | 338 | rb.PushIpcInterface<IUser>(*this, system, service_context); |
| 332 | } | 339 | } |
| 333 | 340 | ||
| 334 | bool Module::Interface::LoadAmiibo(const std::vector<u8>& buffer) { | 341 | bool Module::Interface::LoadAmiibo(const std::vector<u8>& buffer) { |
| @@ -338,12 +345,12 @@ bool Module::Interface::LoadAmiibo(const std::vector<u8>& buffer) { | |||
| 338 | } | 345 | } |
| 339 | 346 | ||
| 340 | std::memcpy(&amiibo, buffer.data(), sizeof(amiibo)); | 347 | std::memcpy(&amiibo, buffer.data(), sizeof(amiibo)); |
| 341 | nfc_tag_load.GetWritableEvent().Signal(); | 348 | nfc_tag_load->GetWritableEvent().Signal(); |
| 342 | return true; | 349 | return true; |
| 343 | } | 350 | } |
| 344 | 351 | ||
| 345 | Kernel::KReadableEvent& Module::Interface::GetNFCEvent() { | 352 | Kernel::KReadableEvent& Module::Interface::GetNFCEvent() { |
| 346 | return nfc_tag_load.GetReadableEvent(); | 353 | return nfc_tag_load->GetReadableEvent(); |
| 347 | } | 354 | } |
| 348 | 355 | ||
| 349 | const Module::Interface::AmiiboFile& Module::Interface::GetAmiiboBuffer() const { | 356 | const Module::Interface::AmiiboFile& Module::Interface::GetAmiiboBuffer() const { |
diff --git a/src/core/hle/service/nfp/nfp.h b/src/core/hle/service/nfp/nfp.h index 5e4e49bc6..95c127efb 100644 --- a/src/core/hle/service/nfp/nfp.h +++ b/src/core/hle/service/nfp/nfp.h | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <vector> | 8 | #include <vector> |
| 9 | 9 | ||
| 10 | #include "core/hle/kernel/k_event.h" | 10 | #include "core/hle/service/kernel_helpers.h" |
| 11 | #include "core/hle/service/service.h" | 11 | #include "core/hle/service/service.h" |
| 12 | 12 | ||
| 13 | namespace Kernel { | 13 | namespace Kernel { |
| @@ -42,12 +42,13 @@ public: | |||
| 42 | Kernel::KReadableEvent& GetNFCEvent(); | 42 | Kernel::KReadableEvent& GetNFCEvent(); |
| 43 | const AmiiboFile& GetAmiiboBuffer() const; | 43 | const AmiiboFile& GetAmiiboBuffer() const; |
| 44 | 44 | ||
| 45 | private: | ||
| 46 | Kernel::KEvent nfc_tag_load; | ||
| 47 | AmiiboFile amiibo{}; | ||
| 48 | |||
| 49 | protected: | 45 | protected: |
| 50 | std::shared_ptr<Module> module; | 46 | std::shared_ptr<Module> module; |
| 47 | |||
| 48 | private: | ||
| 49 | KernelHelpers::ServiceContext service_context; | ||
| 50 | Kernel::KEvent* nfc_tag_load; | ||
| 51 | AmiiboFile amiibo{}; | ||
| 51 | }; | 52 | }; |
| 52 | }; | 53 | }; |
| 53 | 54 | ||
diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp index 9decb9290..f13dc8b0d 100644 --- a/src/core/hle/service/nifm/nifm.cpp +++ b/src/core/hle/service/nifm/nifm.cpp | |||
| @@ -6,10 +6,21 @@ | |||
| 6 | #include "core/core.h" | 6 | #include "core/core.h" |
| 7 | #include "core/hle/ipc_helpers.h" | 7 | #include "core/hle/ipc_helpers.h" |
| 8 | #include "core/hle/kernel/k_event.h" | 8 | #include "core/hle/kernel/k_event.h" |
| 9 | #include "core/hle/kernel/k_readable_event.h" | ||
| 10 | #include "core/hle/kernel/kernel.h" | 9 | #include "core/hle/kernel/kernel.h" |
| 10 | #include "core/hle/service/kernel_helpers.h" | ||
| 11 | #include "core/hle/service/nifm/nifm.h" | 11 | #include "core/hle/service/nifm/nifm.h" |
| 12 | #include "core/hle/service/service.h" | 12 | #include "core/hle/service/service.h" |
| 13 | |||
| 14 | namespace { | ||
| 15 | |||
| 16 | // Avoids name conflict with Windows' CreateEvent macro. | ||
| 17 | [[nodiscard]] Kernel::KEvent* CreateKEvent(Service::KernelHelpers::ServiceContext& service_context, | ||
| 18 | std::string&& name) { | ||
| 19 | return service_context.CreateEvent(std::move(name)); | ||
| 20 | } | ||
| 21 | |||
| 22 | } // Anonymous namespace | ||
| 23 | |||
| 13 | #include "core/network/network.h" | 24 | #include "core/network/network.h" |
| 14 | #include "core/network/network_interface.h" | 25 | #include "core/network/network_interface.h" |
| 15 | 26 | ||
| @@ -129,7 +140,7 @@ public: | |||
| 129 | class IRequest final : public ServiceFramework<IRequest> { | 140 | class IRequest final : public ServiceFramework<IRequest> { |
| 130 | public: | 141 | public: |
| 131 | explicit IRequest(Core::System& system_) | 142 | explicit IRequest(Core::System& system_) |
| 132 | : ServiceFramework{system_, "IRequest"}, event1{system.Kernel()}, event2{system.Kernel()} { | 143 | : ServiceFramework{system_, "IRequest"}, service_context{system_, "IRequest"} { |
| 133 | static const FunctionInfo functions[] = { | 144 | static const FunctionInfo functions[] = { |
| 134 | {0, &IRequest::GetRequestState, "GetRequestState"}, | 145 | {0, &IRequest::GetRequestState, "GetRequestState"}, |
| 135 | {1, &IRequest::GetResult, "GetResult"}, | 146 | {1, &IRequest::GetResult, "GetResult"}, |
| @@ -159,11 +170,13 @@ public: | |||
| 159 | }; | 170 | }; |
| 160 | RegisterHandlers(functions); | 171 | RegisterHandlers(functions); |
| 161 | 172 | ||
| 162 | Kernel::KAutoObject::Create(std::addressof(event1)); | 173 | event1 = CreateKEvent(service_context, "IRequest:Event1"); |
| 163 | Kernel::KAutoObject::Create(std::addressof(event2)); | 174 | event2 = CreateKEvent(service_context, "IRequest:Event2"); |
| 175 | } | ||
| 164 | 176 | ||
| 165 | event1.Initialize("IRequest:Event1"); | 177 | ~IRequest() override { |
| 166 | event2.Initialize("IRequest:Event2"); | 178 | service_context.CloseEvent(event1); |
| 179 | service_context.CloseEvent(event2); | ||
| 167 | } | 180 | } |
| 168 | 181 | ||
| 169 | private: | 182 | private: |
| @@ -199,7 +212,7 @@ private: | |||
| 199 | 212 | ||
| 200 | IPC::ResponseBuilder rb{ctx, 2, 2}; | 213 | IPC::ResponseBuilder rb{ctx, 2, 2}; |
| 201 | rb.Push(ResultSuccess); | 214 | rb.Push(ResultSuccess); |
| 202 | rb.PushCopyObjects(event1.GetReadableEvent(), event2.GetReadableEvent()); | 215 | rb.PushCopyObjects(event1->GetReadableEvent(), event2->GetReadableEvent()); |
| 203 | } | 216 | } |
| 204 | 217 | ||
| 205 | void Cancel(Kernel::HLERequestContext& ctx) { | 218 | void Cancel(Kernel::HLERequestContext& ctx) { |
| @@ -230,7 +243,10 @@ private: | |||
| 230 | rb.Push<u32>(0); | 243 | rb.Push<u32>(0); |
| 231 | } | 244 | } |
| 232 | 245 | ||
| 233 | Kernel::KEvent event1, event2; | 246 | KernelHelpers::ServiceContext service_context; |
| 247 | |||
| 248 | Kernel::KEvent* event1; | ||
| 249 | Kernel::KEvent* event2; | ||
| 234 | }; | 250 | }; |
| 235 | 251 | ||
| 236 | class INetworkProfile final : public ServiceFramework<INetworkProfile> { | 252 | class INetworkProfile final : public ServiceFramework<INetworkProfile> { |
diff --git a/src/core/hle/service/nim/nim.cpp b/src/core/hle/service/nim/nim.cpp index 7447cc38f..30fb060b8 100644 --- a/src/core/hle/service/nim/nim.cpp +++ b/src/core/hle/service/nim/nim.cpp | |||
| @@ -7,9 +7,8 @@ | |||
| 7 | #include "core/core.h" | 7 | #include "core/core.h" |
| 8 | #include "core/hle/ipc_helpers.h" | 8 | #include "core/hle/ipc_helpers.h" |
| 9 | #include "core/hle/kernel/k_event.h" | 9 | #include "core/hle/kernel/k_event.h" |
| 10 | #include "core/hle/kernel/k_readable_event.h" | ||
| 11 | #include "core/hle/kernel/k_writable_event.h" | ||
| 12 | #include "core/hle/kernel/kernel.h" | 10 | #include "core/hle/kernel/kernel.h" |
| 11 | #include "core/hle/service/kernel_helpers.h" | ||
| 13 | #include "core/hle/service/nim/nim.h" | 12 | #include "core/hle/service/nim/nim.h" |
| 14 | #include "core/hle/service/service.h" | 13 | #include "core/hle/service/service.h" |
| 15 | #include "core/hle/service/sm/sm.h" | 14 | #include "core/hle/service/sm/sm.h" |
| @@ -301,7 +300,7 @@ class IEnsureNetworkClockAvailabilityService final | |||
| 301 | public: | 300 | public: |
| 302 | explicit IEnsureNetworkClockAvailabilityService(Core::System& system_) | 301 | explicit IEnsureNetworkClockAvailabilityService(Core::System& system_) |
| 303 | : ServiceFramework{system_, "IEnsureNetworkClockAvailabilityService"}, | 302 | : ServiceFramework{system_, "IEnsureNetworkClockAvailabilityService"}, |
| 304 | finished_event{system.Kernel()} { | 303 | service_context{system_, "IEnsureNetworkClockAvailabilityService"} { |
| 305 | static const FunctionInfo functions[] = { | 304 | static const FunctionInfo functions[] = { |
| 306 | {0, &IEnsureNetworkClockAvailabilityService::StartTask, "StartTask"}, | 305 | {0, &IEnsureNetworkClockAvailabilityService::StartTask, "StartTask"}, |
| 307 | {1, &IEnsureNetworkClockAvailabilityService::GetFinishNotificationEvent, | 306 | {1, &IEnsureNetworkClockAvailabilityService::GetFinishNotificationEvent, |
| @@ -313,17 +312,19 @@ public: | |||
| 313 | }; | 312 | }; |
| 314 | RegisterHandlers(functions); | 313 | RegisterHandlers(functions); |
| 315 | 314 | ||
| 316 | Kernel::KAutoObject::Create(std::addressof(finished_event)); | 315 | finished_event = |
| 317 | finished_event.Initialize("IEnsureNetworkClockAvailabilityService:FinishEvent"); | 316 | service_context.CreateEvent("IEnsureNetworkClockAvailabilityService:FinishEvent"); |
| 318 | } | 317 | } |
| 319 | 318 | ||
| 320 | private: | 319 | ~IEnsureNetworkClockAvailabilityService() override { |
| 321 | Kernel::KEvent finished_event; | 320 | service_context.CloseEvent(finished_event); |
| 321 | } | ||
| 322 | 322 | ||
| 323 | private: | ||
| 323 | void StartTask(Kernel::HLERequestContext& ctx) { | 324 | void StartTask(Kernel::HLERequestContext& ctx) { |
| 324 | // No need to connect to the internet, just finish the task straight away. | 325 | // No need to connect to the internet, just finish the task straight away. |
| 325 | LOG_DEBUG(Service_NIM, "called"); | 326 | LOG_DEBUG(Service_NIM, "called"); |
| 326 | finished_event.GetWritableEvent().Signal(); | 327 | finished_event->GetWritableEvent().Signal(); |
| 327 | IPC::ResponseBuilder rb{ctx, 2}; | 328 | IPC::ResponseBuilder rb{ctx, 2}; |
| 328 | rb.Push(ResultSuccess); | 329 | rb.Push(ResultSuccess); |
| 329 | } | 330 | } |
| @@ -333,7 +334,7 @@ private: | |||
| 333 | 334 | ||
| 334 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 335 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 335 | rb.Push(ResultSuccess); | 336 | rb.Push(ResultSuccess); |
| 336 | rb.PushCopyObjects(finished_event.GetReadableEvent()); | 337 | rb.PushCopyObjects(finished_event->GetReadableEvent()); |
| 337 | } | 338 | } |
| 338 | 339 | ||
| 339 | void GetResult(Kernel::HLERequestContext& ctx) { | 340 | void GetResult(Kernel::HLERequestContext& ctx) { |
| @@ -345,7 +346,7 @@ private: | |||
| 345 | 346 | ||
| 346 | void Cancel(Kernel::HLERequestContext& ctx) { | 347 | void Cancel(Kernel::HLERequestContext& ctx) { |
| 347 | LOG_DEBUG(Service_NIM, "called"); | 348 | LOG_DEBUG(Service_NIM, "called"); |
| 348 | finished_event.GetWritableEvent().Clear(); | 349 | finished_event->GetWritableEvent().Clear(); |
| 349 | IPC::ResponseBuilder rb{ctx, 2}; | 350 | IPC::ResponseBuilder rb{ctx, 2}; |
| 350 | rb.Push(ResultSuccess); | 351 | rb.Push(ResultSuccess); |
| 351 | } | 352 | } |
| @@ -368,6 +369,10 @@ private: | |||
| 368 | rb.Push(ResultSuccess); | 369 | rb.Push(ResultSuccess); |
| 369 | rb.PushRaw<s64>(server_time); | 370 | rb.PushRaw<s64>(server_time); |
| 370 | } | 371 | } |
| 372 | |||
| 373 | KernelHelpers::ServiceContext service_context; | ||
| 374 | |||
| 375 | Kernel::KEvent* finished_event; | ||
| 371 | }; | 376 | }; |
| 372 | 377 | ||
| 373 | class NTC final : public ServiceFramework<NTC> { | 378 | class NTC final : public ServiceFramework<NTC> { |
diff --git a/src/core/hle/service/npns/npns.cpp b/src/core/hle/service/npns/npns.cpp index e4c703da4..32533cd94 100644 --- a/src/core/hle/service/npns/npns.cpp +++ b/src/core/hle/service/npns/npns.cpp | |||
| @@ -31,6 +31,7 @@ public: | |||
| 31 | {24, nullptr, "DestroyTokenWithApplicationId"}, | 31 | {24, nullptr, "DestroyTokenWithApplicationId"}, |
| 32 | {25, nullptr, "QueryIsTokenValid"}, | 32 | {25, nullptr, "QueryIsTokenValid"}, |
| 33 | {26, nullptr, "ListenToMyApplicationId"}, | 33 | {26, nullptr, "ListenToMyApplicationId"}, |
| 34 | {27, nullptr, "DestroyTokenAll"}, | ||
| 34 | {31, nullptr, "UploadTokenToBaaS"}, | 35 | {31, nullptr, "UploadTokenToBaaS"}, |
| 35 | {32, nullptr, "DestroyTokenForBaaS"}, | 36 | {32, nullptr, "DestroyTokenForBaaS"}, |
| 36 | {33, nullptr, "CreateTokenForBaaS"}, | 37 | {33, nullptr, "CreateTokenForBaaS"}, |
diff --git a/src/core/hle/service/ns/ns.cpp b/src/core/hle/service/ns/ns.cpp index 8ce1f3296..931b48f72 100644 --- a/src/core/hle/service/ns/ns.cpp +++ b/src/core/hle/service/ns/ns.cpp | |||
| @@ -9,7 +9,6 @@ | |||
| 9 | #include "core/file_sys/patch_manager.h" | 9 | #include "core/file_sys/patch_manager.h" |
| 10 | #include "core/file_sys/vfs.h" | 10 | #include "core/file_sys/vfs.h" |
| 11 | #include "core/hle/ipc_helpers.h" | 11 | #include "core/hle/ipc_helpers.h" |
| 12 | #include "core/hle/kernel/hle_ipc.h" | ||
| 13 | #include "core/hle/service/ns/errors.h" | 12 | #include "core/hle/service/ns/errors.h" |
| 14 | #include "core/hle/service/ns/language.h" | 13 | #include "core/hle/service/ns/language.h" |
| 15 | #include "core/hle/service/ns/ns.h" | 14 | #include "core/hle/service/ns/ns.h" |
diff --git a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp index a33e47d0b..4ee8c5733 100644 --- a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp +++ b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp | |||
| @@ -16,7 +16,7 @@ namespace Service::Nvidia::Devices { | |||
| 16 | 16 | ||
| 17 | nvdisp_disp0::nvdisp_disp0(Core::System& system_, std::shared_ptr<nvmap> nvmap_dev_) | 17 | nvdisp_disp0::nvdisp_disp0(Core::System& system_, std::shared_ptr<nvmap> nvmap_dev_) |
| 18 | : nvdevice{system_}, nvmap_dev{std::move(nvmap_dev_)} {} | 18 | : nvdevice{system_}, nvmap_dev{std::move(nvmap_dev_)} {} |
| 19 | nvdisp_disp0 ::~nvdisp_disp0() = default; | 19 | nvdisp_disp0::~nvdisp_disp0() = default; |
| 20 | 20 | ||
| 21 | NvResult nvdisp_disp0::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input, | 21 | NvResult nvdisp_disp0::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input, |
| 22 | std::vector<u8>& output) { | 22 | std::vector<u8>& output) { |
| @@ -48,8 +48,9 @@ void nvdisp_disp0::flip(u32 buffer_handle, u32 offset, u32 format, u32 width, u3 | |||
| 48 | addr, offset, width, height, stride, format); | 48 | addr, offset, width, height, stride, format); |
| 49 | 49 | ||
| 50 | const auto pixel_format = static_cast<Tegra::FramebufferConfig::PixelFormat>(format); | 50 | const auto pixel_format = static_cast<Tegra::FramebufferConfig::PixelFormat>(format); |
| 51 | const Tegra::FramebufferConfig framebuffer{addr, offset, width, height, | 51 | const auto transform_flags = static_cast<Tegra::FramebufferConfig::TransformFlags>(transform); |
| 52 | stride, pixel_format, transform, crop_rect}; | 52 | const Tegra::FramebufferConfig framebuffer{addr, offset, width, height, |
| 53 | stride, pixel_format, transform_flags, crop_rect}; | ||
| 53 | 54 | ||
| 54 | system.GetPerfStats().EndSystemFrame(); | 55 | system.GetPerfStats().EndSystemFrame(); |
| 55 | system.GPU().SwapBuffers(&framebuffer); | 56 | system.GPU().SwapBuffers(&framebuffer); |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp index 775e76330..8b4867ca7 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp | |||
| @@ -111,7 +111,6 @@ NvResult nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector | |||
| 111 | event.event->GetWritableEvent().Signal(); | 111 | event.event->GetWritableEvent().Signal(); |
| 112 | return NvResult::Success; | 112 | return NvResult::Success; |
| 113 | } | 113 | } |
| 114 | auto lock = gpu.LockSync(); | ||
| 115 | const u32 current_syncpoint_value = event.fence.value; | 114 | const u32 current_syncpoint_value = event.fence.value; |
| 116 | const s32 diff = current_syncpoint_value - params.threshold; | 115 | const s32 diff = current_syncpoint_value - params.threshold; |
| 117 | if (diff >= 0) { | 116 | if (diff >= 0) { |
| @@ -132,23 +131,24 @@ NvResult nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector | |||
| 132 | } | 131 | } |
| 133 | 132 | ||
| 134 | EventState status = events_interface.status[event_id]; | 133 | EventState status = events_interface.status[event_id]; |
| 135 | if (event_id < MaxNvEvents || status == EventState::Free || status == EventState::Registered) { | 134 | const bool bad_parameter = status != EventState::Free && status != EventState::Registered; |
| 136 | events_interface.SetEventStatus(event_id, EventState::Waiting); | 135 | if (bad_parameter) { |
| 137 | events_interface.assigned_syncpt[event_id] = params.syncpt_id; | ||
| 138 | events_interface.assigned_value[event_id] = target_value; | ||
| 139 | if (is_async) { | ||
| 140 | params.value = params.syncpt_id << 4; | ||
| 141 | } else { | ||
| 142 | params.value = ((params.syncpt_id & 0xfff) << 16) | 0x10000000; | ||
| 143 | } | ||
| 144 | params.value |= event_id; | ||
| 145 | event.event->GetWritableEvent().Clear(); | ||
| 146 | gpu.RegisterSyncptInterrupt(params.syncpt_id, target_value); | ||
| 147 | std::memcpy(output.data(), ¶ms, sizeof(params)); | 136 | std::memcpy(output.data(), ¶ms, sizeof(params)); |
| 148 | return NvResult::Timeout; | 137 | return NvResult::BadParameter; |
| 149 | } | 138 | } |
| 139 | events_interface.SetEventStatus(event_id, EventState::Waiting); | ||
| 140 | events_interface.assigned_syncpt[event_id] = params.syncpt_id; | ||
| 141 | events_interface.assigned_value[event_id] = target_value; | ||
| 142 | if (is_async) { | ||
| 143 | params.value = params.syncpt_id << 4; | ||
| 144 | } else { | ||
| 145 | params.value = ((params.syncpt_id & 0xfff) << 16) | 0x10000000; | ||
| 146 | } | ||
| 147 | params.value |= event_id; | ||
| 148 | event.event->GetWritableEvent().Clear(); | ||
| 149 | gpu.RegisterSyncptInterrupt(params.syncpt_id, target_value); | ||
| 150 | std::memcpy(output.data(), ¶ms, sizeof(params)); | 150 | std::memcpy(output.data(), ¶ms, sizeof(params)); |
| 151 | return NvResult::BadParameter; | 151 | return NvResult::Timeout; |
| 152 | } | 152 | } |
| 153 | 153 | ||
| 154 | NvResult nvhost_ctrl::IocCtrlEventRegister(const std::vector<u8>& input, std::vector<u8>& output) { | 154 | NvResult nvhost_ctrl::IocCtrlEventRegister(const std::vector<u8>& input, std::vector<u8>& output) { |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp index c0a380088..54ac105d5 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp | |||
| @@ -13,6 +13,14 @@ | |||
| 13 | #include "video_core/memory_manager.h" | 13 | #include "video_core/memory_manager.h" |
| 14 | 14 | ||
| 15 | namespace Service::Nvidia::Devices { | 15 | namespace Service::Nvidia::Devices { |
| 16 | namespace { | ||
| 17 | Tegra::CommandHeader BuildFenceAction(Tegra::GPU::FenceOperation op, u32 syncpoint_id) { | ||
| 18 | Tegra::GPU::FenceAction result{}; | ||
| 19 | result.op.Assign(op); | ||
| 20 | result.syncpoint_id.Assign(syncpoint_id); | ||
| 21 | return {result.raw}; | ||
| 22 | } | ||
| 23 | } // namespace | ||
| 16 | 24 | ||
| 17 | nvhost_gpu::nvhost_gpu(Core::System& system_, std::shared_ptr<nvmap> nvmap_dev_, | 25 | nvhost_gpu::nvhost_gpu(Core::System& system_, std::shared_ptr<nvmap> nvmap_dev_, |
| 18 | SyncpointManager& syncpoint_manager_) | 26 | SyncpointManager& syncpoint_manager_) |
| @@ -187,7 +195,7 @@ static std::vector<Tegra::CommandHeader> BuildWaitCommandList(Fence fence) { | |||
| 187 | {fence.value}, | 195 | {fence.value}, |
| 188 | Tegra::BuildCommandHeader(Tegra::BufferMethods::FenceAction, 1, | 196 | Tegra::BuildCommandHeader(Tegra::BufferMethods::FenceAction, 1, |
| 189 | Tegra::SubmissionMode::Increasing), | 197 | Tegra::SubmissionMode::Increasing), |
| 190 | Tegra::GPU::FenceAction::Build(Tegra::GPU::FenceOperation::Acquire, fence.id), | 198 | BuildFenceAction(Tegra::GPU::FenceOperation::Acquire, fence.id), |
| 191 | }; | 199 | }; |
| 192 | } | 200 | } |
| 193 | 201 | ||
| @@ -200,8 +208,7 @@ static std::vector<Tegra::CommandHeader> BuildIncrementCommandList(Fence fence, | |||
| 200 | for (u32 count = 0; count < add_increment; ++count) { | 208 | for (u32 count = 0; count < add_increment; ++count) { |
| 201 | result.emplace_back(Tegra::BuildCommandHeader(Tegra::BufferMethods::FenceAction, 1, | 209 | result.emplace_back(Tegra::BuildCommandHeader(Tegra::BufferMethods::FenceAction, 1, |
| 202 | Tegra::SubmissionMode::Increasing)); | 210 | Tegra::SubmissionMode::Increasing)); |
| 203 | result.emplace_back( | 211 | result.emplace_back(BuildFenceAction(Tegra::GPU::FenceOperation::Increment, fence.id)); |
| 204 | Tegra::GPU::FenceAction::Build(Tegra::GPU::FenceOperation::Increment, fence.id)); | ||
| 205 | } | 212 | } |
| 206 | 213 | ||
| 207 | return result; | 214 | return result; |
diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp index 3ead813b0..a22811ec1 100644 --- a/src/core/hle/service/nvflinger/nvflinger.cpp +++ b/src/core/hle/service/nvflinger/nvflinger.cpp | |||
| @@ -13,28 +13,20 @@ | |||
| 13 | #include "common/thread.h" | 13 | #include "common/thread.h" |
| 14 | #include "core/core.h" | 14 | #include "core/core.h" |
| 15 | #include "core/core_timing.h" | 15 | #include "core/core_timing.h" |
| 16 | #include "core/core_timing_util.h" | ||
| 17 | #include "core/hardware_properties.h" | ||
| 18 | #include "core/hle/kernel/k_readable_event.h" | 16 | #include "core/hle/kernel/k_readable_event.h" |
| 19 | #include "core/hle/kernel/kernel.h" | ||
| 20 | #include "core/hle/service/nvdrv/devices/nvdisp_disp0.h" | 17 | #include "core/hle/service/nvdrv/devices/nvdisp_disp0.h" |
| 21 | #include "core/hle/service/nvdrv/nvdrv.h" | 18 | #include "core/hle/service/nvdrv/nvdrv.h" |
| 22 | #include "core/hle/service/nvflinger/buffer_queue.h" | 19 | #include "core/hle/service/nvflinger/buffer_queue.h" |
| 23 | #include "core/hle/service/nvflinger/nvflinger.h" | 20 | #include "core/hle/service/nvflinger/nvflinger.h" |
| 24 | #include "core/hle/service/vi/display/vi_display.h" | 21 | #include "core/hle/service/vi/display/vi_display.h" |
| 25 | #include "core/hle/service/vi/layer/vi_layer.h" | 22 | #include "core/hle/service/vi/layer/vi_layer.h" |
| 26 | #include "core/perf_stats.h" | 23 | #include "video_core/gpu.h" |
| 27 | #include "video_core/renderer_base.h" | ||
| 28 | 24 | ||
| 29 | namespace Service::NVFlinger { | 25 | namespace Service::NVFlinger { |
| 30 | 26 | ||
| 31 | constexpr auto frame_ns = std::chrono::nanoseconds{1000000000 / 60}; | 27 | constexpr auto frame_ns = std::chrono::nanoseconds{1000000000 / 60}; |
| 32 | 28 | ||
| 33 | void NVFlinger::VSyncThread(NVFlinger& nv_flinger) { | 29 | void NVFlinger::SplitVSync(std::stop_token stop_token) { |
| 34 | nv_flinger.SplitVSync(); | ||
| 35 | } | ||
| 36 | |||
| 37 | void NVFlinger::SplitVSync() { | ||
| 38 | system.RegisterHostThread(); | 30 | system.RegisterHostThread(); |
| 39 | std::string name = "yuzu:VSyncThread"; | 31 | std::string name = "yuzu:VSyncThread"; |
| 40 | MicroProfileOnThreadCreate(name.c_str()); | 32 | MicroProfileOnThreadCreate(name.c_str()); |
| @@ -45,7 +37,7 @@ void NVFlinger::SplitVSync() { | |||
| 45 | Common::SetCurrentThreadName(name.c_str()); | 37 | Common::SetCurrentThreadName(name.c_str()); |
| 46 | Common::SetCurrentThreadPriority(Common::ThreadPriority::High); | 38 | Common::SetCurrentThreadPriority(Common::ThreadPriority::High); |
| 47 | s64 delay = 0; | 39 | s64 delay = 0; |
| 48 | while (is_running) { | 40 | while (!stop_token.stop_requested()) { |
| 49 | guard->lock(); | 41 | guard->lock(); |
| 50 | const s64 time_start = system.CoreTiming().GetGlobalTimeNs().count(); | 42 | const s64 time_start = system.CoreTiming().GetGlobalTimeNs().count(); |
| 51 | Compose(); | 43 | Compose(); |
| @@ -55,7 +47,7 @@ void NVFlinger::SplitVSync() { | |||
| 55 | const s64 next_time = std::max<s64>(0, ticks - time_passed - delay); | 47 | const s64 next_time = std::max<s64>(0, ticks - time_passed - delay); |
| 56 | guard->unlock(); | 48 | guard->unlock(); |
| 57 | if (next_time > 0) { | 49 | if (next_time > 0) { |
| 58 | wait_event->WaitFor(std::chrono::nanoseconds{next_time}); | 50 | std::this_thread::sleep_for(std::chrono::nanoseconds{next_time}); |
| 59 | } | 51 | } |
| 60 | delay = (system.CoreTiming().GetGlobalTimeNs().count() - time_end) - next_time; | 52 | delay = (system.CoreTiming().GetGlobalTimeNs().count() - time_end) - next_time; |
| 61 | } | 53 | } |
| @@ -84,9 +76,7 @@ NVFlinger::NVFlinger(Core::System& system_) | |||
| 84 | }); | 76 | }); |
| 85 | 77 | ||
| 86 | if (system.IsMulticore()) { | 78 | if (system.IsMulticore()) { |
| 87 | is_running = true; | 79 | vsync_thread = std::jthread([this](std::stop_token token) { SplitVSync(token); }); |
| 88 | wait_event = std::make_unique<Common::Event>(); | ||
| 89 | vsync_thread = std::make_unique<std::thread>(VSyncThread, std::ref(*this)); | ||
| 90 | } else { | 80 | } else { |
| 91 | system.CoreTiming().ScheduleEvent(frame_ns, composition_event); | 81 | system.CoreTiming().ScheduleEvent(frame_ns, composition_event); |
| 92 | } | 82 | } |
| @@ -96,14 +86,7 @@ NVFlinger::~NVFlinger() { | |||
| 96 | for (auto& buffer_queue : buffer_queues) { | 86 | for (auto& buffer_queue : buffer_queues) { |
| 97 | buffer_queue->Disconnect(); | 87 | buffer_queue->Disconnect(); |
| 98 | } | 88 | } |
| 99 | 89 | if (!system.IsMulticore()) { | |
| 100 | if (system.IsMulticore()) { | ||
| 101 | is_running = false; | ||
| 102 | wait_event->Set(); | ||
| 103 | vsync_thread->join(); | ||
| 104 | vsync_thread.reset(); | ||
| 105 | wait_event.reset(); | ||
| 106 | } else { | ||
| 107 | system.CoreTiming().UnscheduleEvent(composition_event, 0); | 90 | system.CoreTiming().UnscheduleEvent(composition_event, 0); |
| 108 | } | 91 | } |
| 109 | } | 92 | } |
diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvflinger/nvflinger.h index 6d84cafb4..7935cf773 100644 --- a/src/core/hle/service/nvflinger/nvflinger.h +++ b/src/core/hle/service/nvflinger/nvflinger.h | |||
| @@ -4,13 +4,10 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <atomic> | ||
| 8 | #include <list> | 7 | #include <list> |
| 9 | #include <memory> | 8 | #include <memory> |
| 10 | #include <mutex> | 9 | #include <mutex> |
| 11 | #include <optional> | 10 | #include <optional> |
| 12 | #include <string> | ||
| 13 | #include <string_view> | ||
| 14 | #include <thread> | 11 | #include <thread> |
| 15 | #include <vector> | 12 | #include <vector> |
| 16 | 13 | ||
| @@ -109,9 +106,7 @@ private: | |||
| 109 | /// Creates a layer with the specified layer ID in the desired display. | 106 | /// Creates a layer with the specified layer ID in the desired display. |
| 110 | void CreateLayerAtId(VI::Display& display, u64 layer_id); | 107 | void CreateLayerAtId(VI::Display& display, u64 layer_id); |
| 111 | 108 | ||
| 112 | static void VSyncThread(NVFlinger& nv_flinger); | 109 | void SplitVSync(std::stop_token stop_token); |
| 113 | |||
| 114 | void SplitVSync(); | ||
| 115 | 110 | ||
| 116 | std::shared_ptr<Nvidia::Module> nvdrv; | 111 | std::shared_ptr<Nvidia::Module> nvdrv; |
| 117 | 112 | ||
| @@ -133,9 +128,7 @@ private: | |||
| 133 | 128 | ||
| 134 | Core::System& system; | 129 | Core::System& system; |
| 135 | 130 | ||
| 136 | std::unique_ptr<std::thread> vsync_thread; | 131 | std::jthread vsync_thread; |
| 137 | std::unique_ptr<Common::Event> wait_event; | ||
| 138 | std::atomic<bool> is_running{}; | ||
| 139 | 132 | ||
| 140 | KernelHelpers::ServiceContext service_context; | 133 | KernelHelpers::ServiceContext service_context; |
| 141 | }; | 134 | }; |
diff --git a/src/core/hle/service/olsc/olsc.cpp b/src/core/hle/service/olsc/olsc.cpp index 3bbe1bfe2..39a8031a5 100644 --- a/src/core/hle/service/olsc/olsc.cpp +++ b/src/core/hle/service/olsc/olsc.cpp | |||
| @@ -3,7 +3,6 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "core/hle/ipc_helpers.h" | 5 | #include "core/hle/ipc_helpers.h" |
| 6 | #include "core/hle/kernel/hle_ipc.h" | ||
| 7 | #include "core/hle/service/olsc/olsc.h" | 6 | #include "core/hle/service/olsc/olsc.h" |
| 8 | #include "core/hle/service/service.h" | 7 | #include "core/hle/service/service.h" |
| 9 | #include "core/hle/service/sm/sm.h" | 8 | #include "core/hle/service/sm/sm.h" |
diff --git a/src/core/hle/service/ptm/psm.cpp b/src/core/hle/service/ptm/psm.cpp index d9897c5c5..22ff5269c 100644 --- a/src/core/hle/service/ptm/psm.cpp +++ b/src/core/hle/service/ptm/psm.cpp | |||
| @@ -8,9 +8,8 @@ | |||
| 8 | #include "core/core.h" | 8 | #include "core/core.h" |
| 9 | #include "core/hle/ipc_helpers.h" | 9 | #include "core/hle/ipc_helpers.h" |
| 10 | #include "core/hle/kernel/k_event.h" | 10 | #include "core/hle/kernel/k_event.h" |
| 11 | #include "core/hle/kernel/k_readable_event.h" | ||
| 12 | #include "core/hle/kernel/k_writable_event.h" | ||
| 13 | #include "core/hle/kernel/kernel.h" | 11 | #include "core/hle/kernel/kernel.h" |
| 12 | #include "core/hle/service/kernel_helpers.h" | ||
| 14 | #include "core/hle/service/ptm/psm.h" | 13 | #include "core/hle/service/ptm/psm.h" |
| 15 | #include "core/hle/service/service.h" | 14 | #include "core/hle/service/service.h" |
| 16 | #include "core/hle/service/sm/sm.h" | 15 | #include "core/hle/service/sm/sm.h" |
| @@ -20,7 +19,7 @@ namespace Service::PSM { | |||
| 20 | class IPsmSession final : public ServiceFramework<IPsmSession> { | 19 | class IPsmSession final : public ServiceFramework<IPsmSession> { |
| 21 | public: | 20 | public: |
| 22 | explicit IPsmSession(Core::System& system_) | 21 | explicit IPsmSession(Core::System& system_) |
| 23 | : ServiceFramework{system_, "IPsmSession"}, state_change_event{system.Kernel()} { | 22 | : ServiceFramework{system_, "IPsmSession"}, service_context{system_, "IPsmSession"} { |
| 24 | // clang-format off | 23 | // clang-format off |
| 25 | static const FunctionInfo functions[] = { | 24 | static const FunctionInfo functions[] = { |
| 26 | {0, &IPsmSession::BindStateChangeEvent, "BindStateChangeEvent"}, | 25 | {0, &IPsmSession::BindStateChangeEvent, "BindStateChangeEvent"}, |
| @@ -33,27 +32,28 @@ public: | |||
| 33 | 32 | ||
| 34 | RegisterHandlers(functions); | 33 | RegisterHandlers(functions); |
| 35 | 34 | ||
| 36 | Kernel::KAutoObject::Create(std::addressof(state_change_event)); | 35 | state_change_event = service_context.CreateEvent("IPsmSession::state_change_event"); |
| 37 | state_change_event.Initialize("IPsmSession::state_change_event"); | ||
| 38 | } | 36 | } |
| 39 | 37 | ||
| 40 | ~IPsmSession() override = default; | 38 | ~IPsmSession() override { |
| 39 | service_context.CloseEvent(state_change_event); | ||
| 40 | } | ||
| 41 | 41 | ||
| 42 | void SignalChargerTypeChanged() { | 42 | void SignalChargerTypeChanged() { |
| 43 | if (should_signal && should_signal_charger_type) { | 43 | if (should_signal && should_signal_charger_type) { |
| 44 | state_change_event.GetWritableEvent().Signal(); | 44 | state_change_event->GetWritableEvent().Signal(); |
| 45 | } | 45 | } |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | void SignalPowerSupplyChanged() { | 48 | void SignalPowerSupplyChanged() { |
| 49 | if (should_signal && should_signal_power_supply) { | 49 | if (should_signal && should_signal_power_supply) { |
| 50 | state_change_event.GetWritableEvent().Signal(); | 50 | state_change_event->GetWritableEvent().Signal(); |
| 51 | } | 51 | } |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | void SignalBatteryVoltageStateChanged() { | 54 | void SignalBatteryVoltageStateChanged() { |
| 55 | if (should_signal && should_signal_battery_voltage) { | 55 | if (should_signal && should_signal_battery_voltage) { |
| 56 | state_change_event.GetWritableEvent().Signal(); | 56 | state_change_event->GetWritableEvent().Signal(); |
| 57 | } | 57 | } |
| 58 | } | 58 | } |
| 59 | 59 | ||
| @@ -65,7 +65,7 @@ private: | |||
| 65 | 65 | ||
| 66 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 66 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 67 | rb.Push(ResultSuccess); | 67 | rb.Push(ResultSuccess); |
| 68 | rb.PushCopyObjects(state_change_event.GetReadableEvent()); | 68 | rb.PushCopyObjects(state_change_event->GetReadableEvent()); |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | void UnbindStateChangeEvent(Kernel::HLERequestContext& ctx) { | 71 | void UnbindStateChangeEvent(Kernel::HLERequestContext& ctx) { |
| @@ -110,11 +110,13 @@ private: | |||
| 110 | rb.Push(ResultSuccess); | 110 | rb.Push(ResultSuccess); |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | KernelHelpers::ServiceContext service_context; | ||
| 114 | |||
| 113 | bool should_signal_charger_type{}; | 115 | bool should_signal_charger_type{}; |
| 114 | bool should_signal_power_supply{}; | 116 | bool should_signal_power_supply{}; |
| 115 | bool should_signal_battery_voltage{}; | 117 | bool should_signal_battery_voltage{}; |
| 116 | bool should_signal{}; | 118 | bool should_signal{}; |
| 117 | Kernel::KEvent state_change_event; | 119 | Kernel::KEvent* state_change_event; |
| 118 | }; | 120 | }; |
| 119 | 121 | ||
| 120 | class PSM final : public ServiceFramework<PSM> { | 122 | class PSM final : public ServiceFramework<PSM> { |
diff --git a/src/core/hle/service/set/set_sys.cpp b/src/core/hle/service/set/set_sys.cpp index 8299c6b68..286578b17 100644 --- a/src/core/hle/service/set/set_sys.cpp +++ b/src/core/hle/service/set/set_sys.cpp | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | #include "core/file_sys/errors.h" | 7 | #include "core/file_sys/errors.h" |
| 8 | #include "core/file_sys/system_archive/system_version.h" | 8 | #include "core/file_sys/system_archive/system_version.h" |
| 9 | #include "core/hle/ipc_helpers.h" | 9 | #include "core/hle/ipc_helpers.h" |
| 10 | #include "core/hle/kernel/k_client_port.h" | ||
| 11 | #include "core/hle/service/filesystem/filesystem.h" | 10 | #include "core/hle/service/filesystem/filesystem.h" |
| 12 | #include "core/hle/service/set/set_sys.h" | 11 | #include "core/hle/service/set/set_sys.h" |
| 13 | 12 | ||
diff --git a/src/core/hle/service/sockets/bsd.cpp b/src/core/hle/service/sockets/bsd.cpp index 7d85ecb6a..b9e765f1d 100644 --- a/src/core/hle/service/sockets/bsd.cpp +++ b/src/core/hle/service/sockets/bsd.cpp | |||
| @@ -415,6 +415,18 @@ void BSD::Write(Kernel::HLERequestContext& ctx) { | |||
| 415 | }); | 415 | }); |
| 416 | } | 416 | } |
| 417 | 417 | ||
| 418 | void BSD::Read(Kernel::HLERequestContext& ctx) { | ||
| 419 | IPC::RequestParser rp{ctx}; | ||
| 420 | const s32 fd = rp.Pop<s32>(); | ||
| 421 | |||
| 422 | LOG_WARNING(Service, "(STUBBED) called. fd={} len={}", fd, ctx.GetWriteBufferSize()); | ||
| 423 | |||
| 424 | IPC::ResponseBuilder rb{ctx, 4}; | ||
| 425 | rb.Push(ResultSuccess); | ||
| 426 | rb.Push<u32>(0); // ret | ||
| 427 | rb.Push<u32>(0); // bsd errno | ||
| 428 | } | ||
| 429 | |||
| 418 | void BSD::Close(Kernel::HLERequestContext& ctx) { | 430 | void BSD::Close(Kernel::HLERequestContext& ctx) { |
| 419 | IPC::RequestParser rp{ctx}; | 431 | IPC::RequestParser rp{ctx}; |
| 420 | const s32 fd = rp.Pop<s32>(); | 432 | const s32 fd = rp.Pop<s32>(); |
| @@ -855,7 +867,7 @@ BSD::BSD(Core::System& system_, const char* name) : ServiceFramework{system_, na | |||
| 855 | {22, &BSD::Shutdown, "Shutdown"}, | 867 | {22, &BSD::Shutdown, "Shutdown"}, |
| 856 | {23, nullptr, "ShutdownAllSockets"}, | 868 | {23, nullptr, "ShutdownAllSockets"}, |
| 857 | {24, &BSD::Write, "Write"}, | 869 | {24, &BSD::Write, "Write"}, |
| 858 | {25, nullptr, "Read"}, | 870 | {25, &BSD::Read, "Read"}, |
| 859 | {26, &BSD::Close, "Close"}, | 871 | {26, &BSD::Close, "Close"}, |
| 860 | {27, nullptr, "DuplicateSocket"}, | 872 | {27, nullptr, "DuplicateSocket"}, |
| 861 | {28, nullptr, "GetResourceStatistics"}, | 873 | {28, nullptr, "GetResourceStatistics"}, |
diff --git a/src/core/hle/service/sockets/bsd.h b/src/core/hle/service/sockets/bsd.h index 1d2df9c61..a387e50df 100644 --- a/src/core/hle/service/sockets/bsd.h +++ b/src/core/hle/service/sockets/bsd.h | |||
| @@ -5,11 +5,9 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <string_view> | ||
| 9 | #include <vector> | 8 | #include <vector> |
| 10 | 9 | ||
| 11 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 12 | #include "core/hle/kernel/hle_ipc.h" | ||
| 13 | #include "core/hle/service/service.h" | 11 | #include "core/hle/service/service.h" |
| 14 | #include "core/hle/service/sockets/sockets.h" | 12 | #include "core/hle/service/sockets/sockets.h" |
| 15 | 13 | ||
| @@ -135,6 +133,7 @@ private: | |||
| 135 | void Send(Kernel::HLERequestContext& ctx); | 133 | void Send(Kernel::HLERequestContext& ctx); |
| 136 | void SendTo(Kernel::HLERequestContext& ctx); | 134 | void SendTo(Kernel::HLERequestContext& ctx); |
| 137 | void Write(Kernel::HLERequestContext& ctx); | 135 | void Write(Kernel::HLERequestContext& ctx); |
| 136 | void Read(Kernel::HLERequestContext& ctx); | ||
| 138 | void Close(Kernel::HLERequestContext& ctx); | 137 | void Close(Kernel::HLERequestContext& ctx); |
| 139 | void EventFd(Kernel::HLERequestContext& ctx); | 138 | void EventFd(Kernel::HLERequestContext& ctx); |
| 140 | 139 | ||
diff --git a/src/core/hle/service/sockets/sfdnsres.h b/src/core/hle/service/sockets/sfdnsres.h index faa6b7d0d..5d3b4dc2d 100644 --- a/src/core/hle/service/sockets/sfdnsres.h +++ b/src/core/hle/service/sockets/sfdnsres.h | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include "core/hle/kernel/hle_ipc.h" | ||
| 8 | #include "core/hle/service/service.h" | 7 | #include "core/hle/service/service.h" |
| 9 | 8 | ||
| 10 | namespace Core { | 9 | namespace Core { |
diff --git a/src/core/hle/service/sockets/sockets.h b/src/core/hle/service/sockets/sockets.h index 5a65ed2a9..02dbbae40 100644 --- a/src/core/hle/service/sockets/sockets.h +++ b/src/core/hle/service/sockets/sockets.h | |||
| @@ -4,13 +4,17 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include "common/common_funcs.h" | ||
| 7 | #include "common/common_types.h" | 8 | #include "common/common_types.h" |
| 8 | #include "core/hle/service/service.h" | ||
| 9 | 9 | ||
| 10 | namespace Core { | 10 | namespace Core { |
| 11 | class System; | 11 | class System; |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | namespace Service::SM { | ||
| 15 | class ServiceManager; | ||
| 16 | } | ||
| 17 | |||
| 14 | namespace Service::Sockets { | 18 | namespace Service::Sockets { |
| 15 | 19 | ||
| 16 | enum class Errno : u32 { | 20 | enum class Errno : u32 { |
diff --git a/src/core/hle/service/spl/spl_module.cpp b/src/core/hle/service/spl/spl_module.cpp index 918633af5..ed4c06260 100644 --- a/src/core/hle/service/spl/spl_module.cpp +++ b/src/core/hle/service/spl/spl_module.cpp | |||
| @@ -3,10 +3,8 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <chrono> | ||
| 7 | #include <cstdlib> | 6 | #include <cstdlib> |
| 8 | #include <ctime> | 7 | #include <ctime> |
| 9 | #include <functional> | ||
| 10 | #include <vector> | 8 | #include <vector> |
| 11 | #include "common/logging/log.h" | 9 | #include "common/logging/log.h" |
| 12 | #include "common/settings.h" | 10 | #include "common/settings.h" |
diff --git a/src/core/hle/service/ssl/ssl.cpp b/src/core/hle/service/ssl/ssl.cpp index 921f4d776..a81a595ea 100644 --- a/src/core/hle/service/ssl/ssl.cpp +++ b/src/core/hle/service/ssl/ssl.cpp | |||
| @@ -3,7 +3,6 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "core/hle/ipc_helpers.h" | 5 | #include "core/hle/ipc_helpers.h" |
| 6 | #include "core/hle/kernel/hle_ipc.h" | ||
| 7 | #include "core/hle/service/service.h" | 6 | #include "core/hle/service/service.h" |
| 8 | #include "core/hle/service/sm/sm.h" | 7 | #include "core/hle/service/sm/sm.h" |
| 9 | #include "core/hle/service/ssl/ssl.h" | 8 | #include "core/hle/service/ssl/ssl.h" |
diff --git a/src/core/hle/service/time/standard_user_system_clock_core.cpp b/src/core/hle/service/time/standard_user_system_clock_core.cpp index ef79ab917..e94220a44 100644 --- a/src/core/hle/service/time/standard_user_system_clock_core.cpp +++ b/src/core/hle/service/time/standard_user_system_clock_core.cpp | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #include "common/assert.h" | 5 | #include "common/assert.h" |
| 6 | #include "core/core.h" | 6 | #include "core/core.h" |
| 7 | #include "core/hle/kernel/k_event.h" | ||
| 7 | #include "core/hle/service/time/standard_local_system_clock_core.h" | 8 | #include "core/hle/service/time/standard_local_system_clock_core.h" |
| 8 | #include "core/hle/service/time/standard_network_system_clock_core.h" | 9 | #include "core/hle/service/time/standard_network_system_clock_core.h" |
| 9 | #include "core/hle/service/time/standard_user_system_clock_core.h" | 10 | #include "core/hle/service/time/standard_user_system_clock_core.h" |
| @@ -16,10 +17,15 @@ StandardUserSystemClockCore::StandardUserSystemClockCore( | |||
| 16 | : SystemClockCore(local_system_clock_core_.GetSteadyClockCore()), | 17 | : SystemClockCore(local_system_clock_core_.GetSteadyClockCore()), |
| 17 | local_system_clock_core{local_system_clock_core_}, | 18 | local_system_clock_core{local_system_clock_core_}, |
| 18 | network_system_clock_core{network_system_clock_core_}, | 19 | network_system_clock_core{network_system_clock_core_}, |
| 19 | auto_correction_time{SteadyClockTimePoint::GetRandom()}, auto_correction_event{ | 20 | auto_correction_time{SteadyClockTimePoint::GetRandom()}, service_context{ |
| 20 | system_.Kernel()} { | 21 | system_, |
| 21 | Kernel::KAutoObject::Create(std::addressof(auto_correction_event)); | 22 | "StandardUserSystemClockCore"} { |
| 22 | auto_correction_event.Initialize("StandardUserSystemClockCore:AutoCorrectionEvent"); | 23 | auto_correction_event = |
| 24 | service_context.CreateEvent("StandardUserSystemClockCore:AutoCorrectionEvent"); | ||
| 25 | } | ||
| 26 | |||
| 27 | StandardUserSystemClockCore::~StandardUserSystemClockCore() { | ||
| 28 | service_context.CloseEvent(auto_correction_event); | ||
| 23 | } | 29 | } |
| 24 | 30 | ||
| 25 | ResultCode StandardUserSystemClockCore::SetAutomaticCorrectionEnabled(Core::System& system, | 31 | ResultCode StandardUserSystemClockCore::SetAutomaticCorrectionEnabled(Core::System& system, |
diff --git a/src/core/hle/service/time/standard_user_system_clock_core.h b/src/core/hle/service/time/standard_user_system_clock_core.h index bf9ec5e42..b7cb2b045 100644 --- a/src/core/hle/service/time/standard_user_system_clock_core.h +++ b/src/core/hle/service/time/standard_user_system_clock_core.h | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include "core/hle/kernel/k_event.h" | 7 | #include "core/hle/service/kernel_helpers.h" |
| 8 | #include "core/hle/service/time/clock_types.h" | 8 | #include "core/hle/service/time/clock_types.h" |
| 9 | #include "core/hle/service/time/system_clock_core.h" | 9 | #include "core/hle/service/time/system_clock_core.h" |
| 10 | 10 | ||
| @@ -27,6 +27,8 @@ public: | |||
| 27 | StandardNetworkSystemClockCore& network_system_clock_core_, | 27 | StandardNetworkSystemClockCore& network_system_clock_core_, |
| 28 | Core::System& system_); | 28 | Core::System& system_); |
| 29 | 29 | ||
| 30 | ~StandardUserSystemClockCore() override; | ||
| 31 | |||
| 30 | ResultCode SetAutomaticCorrectionEnabled(Core::System& system, bool value); | 32 | ResultCode SetAutomaticCorrectionEnabled(Core::System& system, bool value); |
| 31 | 33 | ||
| 32 | ResultCode GetClockContext(Core::System& system, SystemClockContext& ctx) const override; | 34 | ResultCode GetClockContext(Core::System& system, SystemClockContext& ctx) const override; |
| @@ -55,7 +57,8 @@ private: | |||
| 55 | StandardNetworkSystemClockCore& network_system_clock_core; | 57 | StandardNetworkSystemClockCore& network_system_clock_core; |
| 56 | bool auto_correction_enabled{}; | 58 | bool auto_correction_enabled{}; |
| 57 | SteadyClockTimePoint auto_correction_time; | 59 | SteadyClockTimePoint auto_correction_time; |
| 58 | Kernel::KEvent auto_correction_event; | 60 | KernelHelpers::ServiceContext service_context; |
| 61 | Kernel::KEvent* auto_correction_event; | ||
| 59 | }; | 62 | }; |
| 60 | 63 | ||
| 61 | } // namespace Service::Time::Clock | 64 | } // namespace Service::Time::Clock |
diff --git a/src/core/hle/service/time/system_clock_context_update_callback.h b/src/core/hle/service/time/system_clock_context_update_callback.h index 797954958..6936397a5 100644 --- a/src/core/hle/service/time/system_clock_context_update_callback.h +++ b/src/core/hle/service/time/system_clock_context_update_callback.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <memory> | ||
| 7 | #include <vector> | 8 | #include <vector> |
| 8 | 9 | ||
| 9 | #include "core/hle/service/time/clock_types.h" | 10 | #include "core/hle/service/time/clock_types.h" |
diff --git a/src/core/hle/service/time/system_clock_core.cpp b/src/core/hle/service/time/system_clock_core.cpp index bd334bbef..5c2354cdd 100644 --- a/src/core/hle/service/time/system_clock_core.cpp +++ b/src/core/hle/service/time/system_clock_core.cpp | |||
| @@ -13,7 +13,7 @@ SystemClockCore::SystemClockCore(SteadyClockCore& steady_clock_core_) | |||
| 13 | context.steady_time_point.clock_source_id = steady_clock_core.GetClockSourceId(); | 13 | context.steady_time_point.clock_source_id = steady_clock_core.GetClockSourceId(); |
| 14 | } | 14 | } |
| 15 | 15 | ||
| 16 | SystemClockCore ::~SystemClockCore() = default; | 16 | SystemClockCore::~SystemClockCore() = default; |
| 17 | 17 | ||
| 18 | ResultCode SystemClockCore::GetCurrentTime(Core::System& system, s64& posix_time) const { | 18 | ResultCode SystemClockCore::GetCurrentTime(Core::System& system, s64& posix_time) const { |
| 19 | posix_time = 0; | 19 | posix_time = 0; |
diff --git a/src/core/hle/service/time/system_clock_core.h b/src/core/hle/service/time/system_clock_core.h index 83d0e5d62..b9237ad28 100644 --- a/src/core/hle/service/time/system_clock_core.h +++ b/src/core/hle/service/time/system_clock_core.h | |||
| @@ -4,6 +4,8 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <memory> | ||
| 8 | |||
| 7 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 8 | #include "core/hle/service/time/clock_types.h" | 10 | #include "core/hle/service/time/clock_types.h" |
| 9 | 11 | ||
diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp index 8fdd5076f..d84a111c2 100644 --- a/src/core/hle/service/time/time.cpp +++ b/src/core/hle/service/time/time.cpp | |||
| @@ -8,11 +8,11 @@ | |||
| 8 | #include "core/core_timing_util.h" | 8 | #include "core/core_timing_util.h" |
| 9 | #include "core/hardware_properties.h" | 9 | #include "core/hardware_properties.h" |
| 10 | #include "core/hle/ipc_helpers.h" | 10 | #include "core/hle/ipc_helpers.h" |
| 11 | #include "core/hle/kernel/k_client_port.h" | ||
| 12 | #include "core/hle/kernel/k_scheduler.h" | 11 | #include "core/hle/kernel/k_scheduler.h" |
| 13 | #include "core/hle/kernel/kernel.h" | 12 | #include "core/hle/kernel/kernel.h" |
| 14 | #include "core/hle/service/time/time.h" | 13 | #include "core/hle/service/time/time.h" |
| 15 | #include "core/hle/service/time/time_interface.h" | 14 | #include "core/hle/service/time/time_interface.h" |
| 15 | #include "core/hle/service/time/time_manager.h" | ||
| 16 | #include "core/hle/service/time/time_sharedmemory.h" | 16 | #include "core/hle/service/time/time_sharedmemory.h" |
| 17 | #include "core/hle/service/time/time_zone_service.h" | 17 | #include "core/hle/service/time/time_zone_service.h" |
| 18 | 18 | ||
diff --git a/src/core/hle/service/time/time.h b/src/core/hle/service/time/time.h index ce9c479c6..30e2cd369 100644 --- a/src/core/hle/service/time/time.h +++ b/src/core/hle/service/time/time.h | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | 6 | ||
| 7 | #include "core/hle/service/service.h" | 7 | #include "core/hle/service/service.h" |
| 8 | #include "core/hle/service/time/clock_types.h" | 8 | #include "core/hle/service/time/clock_types.h" |
| 9 | #include "core/hle/service/time/time_manager.h" | ||
| 10 | 9 | ||
| 11 | namespace Core { | 10 | namespace Core { |
| 12 | class System; | 11 | class System; |
diff --git a/src/core/hle/service/time/time_zone_service.cpp b/src/core/hle/service/time/time_zone_service.cpp index 5c3108768..3871e7316 100644 --- a/src/core/hle/service/time/time_zone_service.cpp +++ b/src/core/hle/service/time/time_zone_service.cpp | |||
| @@ -10,8 +10,8 @@ | |||
| 10 | 10 | ||
| 11 | namespace Service::Time { | 11 | namespace Service::Time { |
| 12 | 12 | ||
| 13 | ITimeZoneService ::ITimeZoneService(Core::System& system_, | 13 | ITimeZoneService::ITimeZoneService(Core::System& system_, |
| 14 | TimeZone::TimeZoneContentManager& time_zone_manager_) | 14 | TimeZone::TimeZoneContentManager& time_zone_manager_) |
| 15 | : ServiceFramework{system_, "ITimeZoneService"}, time_zone_content_manager{time_zone_manager_} { | 15 | : ServiceFramework{system_, "ITimeZoneService"}, time_zone_content_manager{time_zone_manager_} { |
| 16 | static const FunctionInfo functions[] = { | 16 | static const FunctionInfo functions[] = { |
| 17 | {0, &ITimeZoneService::GetDeviceLocationName, "GetDeviceLocationName"}, | 17 | {0, &ITimeZoneService::GetDeviceLocationName, "GetDeviceLocationName"}, |
diff --git a/src/core/hle/service/usb/usb.cpp b/src/core/hle/service/usb/usb.cpp index 7f436c3bb..502dfbb4a 100644 --- a/src/core/hle/service/usb/usb.cpp +++ b/src/core/hle/service/usb/usb.cpp | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | 6 | ||
| 7 | #include "common/logging/log.h" | 7 | #include "common/logging/log.h" |
| 8 | #include "core/hle/ipc_helpers.h" | 8 | #include "core/hle/ipc_helpers.h" |
| 9 | #include "core/hle/kernel/hle_ipc.h" | ||
| 10 | #include "core/hle/service/service.h" | 9 | #include "core/hle/service/service.h" |
| 11 | #include "core/hle/service/sm/sm.h" | 10 | #include "core/hle/service/sm/sm.h" |
| 12 | #include "core/hle/service/usb/usb.h" | 11 | #include "core/hle/service/usb/usb.h" |
| @@ -97,7 +96,7 @@ public: | |||
| 97 | {3, nullptr, "GetAlternateInterface"}, | 96 | {3, nullptr, "GetAlternateInterface"}, |
| 98 | {4, nullptr, "GetCurrentFrame"}, | 97 | {4, nullptr, "GetCurrentFrame"}, |
| 99 | {5, nullptr, "CtrlXferAsync"}, | 98 | {5, nullptr, "CtrlXferAsync"}, |
| 100 | {6, nullptr, "Unknown6"}, | 99 | {6, nullptr, "GetCtrlXferCompletionEvent"}, |
| 101 | {7, nullptr, "GetCtrlXferReport"}, | 100 | {7, nullptr, "GetCtrlXferReport"}, |
| 102 | {8, nullptr, "ResetDevice"}, | 101 | {8, nullptr, "ResetDevice"}, |
| 103 | {9, nullptr, "OpenUsbEp"}, | 102 | {9, nullptr, "OpenUsbEp"}, |
| @@ -183,8 +182,8 @@ public: | |||
| 183 | {4, nullptr, "GetHostPdcFirmwareRevision"}, | 182 | {4, nullptr, "GetHostPdcFirmwareRevision"}, |
| 184 | {5, nullptr, "GetHostPdcManufactureId"}, | 183 | {5, nullptr, "GetHostPdcManufactureId"}, |
| 185 | {6, nullptr, "GetHostPdcDeviceId"}, | 184 | {6, nullptr, "GetHostPdcDeviceId"}, |
| 186 | {7, nullptr, "AwakeCradle"}, | 185 | {7, nullptr, "EnableCradleRecovery"}, |
| 187 | {8, nullptr, "SleepCradle"}, | 186 | {8, nullptr, "DisableCradleRecovery"}, |
| 188 | }; | 187 | }; |
| 189 | // clang-format on | 188 | // clang-format on |
| 190 | 189 | ||
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 8e8fc40ca..be3d52d54 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp | |||
| @@ -831,6 +831,7 @@ public: | |||
| 831 | {6010, nullptr, "GetLayerPresentationAllFencesExpiredEvent"}, | 831 | {6010, nullptr, "GetLayerPresentationAllFencesExpiredEvent"}, |
| 832 | {6011, nullptr, "EnableLayerAutoClearTransitionBuffer"}, | 832 | {6011, nullptr, "EnableLayerAutoClearTransitionBuffer"}, |
| 833 | {6012, nullptr, "DisableLayerAutoClearTransitionBuffer"}, | 833 | {6012, nullptr, "DisableLayerAutoClearTransitionBuffer"}, |
| 834 | {6013, nullptr, "SetLayerOpacity"}, | ||
| 834 | {7000, nullptr, "SetContentVisibility"}, | 835 | {7000, nullptr, "SetContentVisibility"}, |
| 835 | {8000, nullptr, "SetConductorLayer"}, | 836 | {8000, nullptr, "SetConductorLayer"}, |
| 836 | {8001, nullptr, "SetTimestampTracking"}, | 837 | {8001, nullptr, "SetTimestampTracking"}, |
diff --git a/src/core/hle/service/vi/vi.h b/src/core/hle/service/vi/vi.h index eec531d54..2fd7f8e61 100644 --- a/src/core/hle/service/vi/vi.h +++ b/src/core/hle/service/vi/vi.h | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <memory> | ||
| 8 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 9 | 8 | ||
| 10 | namespace Core { | 9 | namespace Core { |
diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 51c4dea26..88d6ec908 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp | |||
| @@ -587,7 +587,11 @@ void Memory::UnmapRegion(Common::PageTable& page_table, VAddr base, u64 size) { | |||
| 587 | bool Memory::IsValidVirtualAddress(const VAddr vaddr) const { | 587 | bool Memory::IsValidVirtualAddress(const VAddr vaddr) const { |
| 588 | const Kernel::KProcess& process = *system.CurrentProcess(); | 588 | const Kernel::KProcess& process = *system.CurrentProcess(); |
| 589 | const auto& page_table = process.PageTable().PageTableImpl(); | 589 | const auto& page_table = process.PageTable().PageTableImpl(); |
| 590 | const auto [pointer, type] = page_table.pointers[vaddr >> PAGE_BITS].PointerType(); | 590 | const size_t page = vaddr >> PAGE_BITS; |
| 591 | if (page >= page_table.pointers.size()) { | ||
| 592 | return false; | ||
| 593 | } | ||
| 594 | const auto [pointer, type] = page_table.pointers[page].PointerType(); | ||
| 591 | return pointer != nullptr || type == Common::PageType::RasterizerCachedMemory; | 595 | return pointer != nullptr || type == Common::PageType::RasterizerCachedMemory; |
| 592 | } | 596 | } |
| 593 | 597 | ||
diff --git a/src/core/network/network.cpp b/src/core/network/network.cpp index 72eea52f0..a3e0664b9 100644 --- a/src/core/network/network.cpp +++ b/src/core/network/network.cpp | |||
| @@ -366,8 +366,6 @@ std::optional<IPv4Address> GetHostIPv4Address() { | |||
| 366 | if (res != network_interfaces.end()) { | 366 | if (res != network_interfaces.end()) { |
| 367 | char ip_addr[16] = {}; | 367 | char ip_addr[16] = {}; |
| 368 | ASSERT(inet_ntop(AF_INET, &res->ip_address, ip_addr, sizeof(ip_addr)) != nullptr); | 368 | ASSERT(inet_ntop(AF_INET, &res->ip_address, ip_addr, sizeof(ip_addr)) != nullptr); |
| 369 | LOG_INFO(Network, "IP address: {}", ip_addr); | ||
| 370 | |||
| 371 | return TranslateIPv4(res->ip_address); | 369 | return TranslateIPv4(res->ip_address); |
| 372 | } else { | 370 | } else { |
| 373 | LOG_ERROR(Network, "Couldn't find selected interface \"{}\"", selected_network_interface); | 371 | LOG_ERROR(Network, "Couldn't find selected interface \"{}\"", selected_network_interface); |
diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index 18d7d8817..f3907c65a 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp | |||
| @@ -346,8 +346,8 @@ void InputSubsystem::ReloadInputDevices() { | |||
| 346 | impl->udp->ReloadSockets(); | 346 | impl->udp->ReloadSockets(); |
| 347 | } | 347 | } |
| 348 | 348 | ||
| 349 | std::vector<std::unique_ptr<Polling::DevicePoller>> InputSubsystem::GetPollers([ | 349 | std::vector<std::unique_ptr<Polling::DevicePoller>> InputSubsystem::GetPollers( |
| 350 | [maybe_unused]] Polling::DeviceType type) const { | 350 | [[maybe_unused]] Polling::DeviceType type) const { |
| 351 | #ifdef HAVE_SDL2 | 351 | #ifdef HAVE_SDL2 |
| 352 | return impl->sdl->GetPollers(type); | 352 | return impl->sdl->GetPollers(type); |
| 353 | #else | 353 | #else |
diff --git a/src/input_common/sdl/sdl_impl.cpp b/src/input_common/sdl/sdl_impl.cpp index 03888b7cb..ab6211b29 100644 --- a/src/input_common/sdl/sdl_impl.cpp +++ b/src/input_common/sdl/sdl_impl.cpp | |||
| @@ -254,11 +254,25 @@ public: | |||
| 254 | } | 254 | } |
| 255 | 255 | ||
| 256 | bool IsJoyconLeft() const { | 256 | bool IsJoyconLeft() const { |
| 257 | return std::strstr(GetControllerName().c_str(), "Joy-Con Left") != nullptr; | 257 | const std::string controller_name = GetControllerName(); |
| 258 | if (std::strstr(controller_name.c_str(), "Joy-Con Left") != nullptr) { | ||
| 259 | return true; | ||
| 260 | } | ||
| 261 | if (std::strstr(controller_name.c_str(), "Joy-Con (L)") != nullptr) { | ||
| 262 | return true; | ||
| 263 | } | ||
| 264 | return false; | ||
| 258 | } | 265 | } |
| 259 | 266 | ||
| 260 | bool IsJoyconRight() const { | 267 | bool IsJoyconRight() const { |
| 261 | return std::strstr(GetControllerName().c_str(), "Joy-Con Right") != nullptr; | 268 | const std::string controller_name = GetControllerName(); |
| 269 | if (std::strstr(controller_name.c_str(), "Joy-Con Right") != nullptr) { | ||
| 270 | return true; | ||
| 271 | } | ||
| 272 | if (std::strstr(controller_name.c_str(), "Joy-Con (R)") != nullptr) { | ||
| 273 | return true; | ||
| 274 | } | ||
| 275 | return false; | ||
| 262 | } | 276 | } |
| 263 | 277 | ||
| 264 | std::string GetControllerName() const { | 278 | std::string GetControllerName() const { |
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp index 580063fa9..170db269a 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp | |||
| @@ -58,8 +58,8 @@ void GetCbuf(EmitContext& ctx, std::string_view ret, const IR::Value& binding, | |||
| 58 | const auto cbuf{fmt::format("{}_cbuf{}", ctx.stage_name, binding.U32())}; | 58 | const auto cbuf{fmt::format("{}_cbuf{}", ctx.stage_name, binding.U32())}; |
| 59 | const auto cbuf_cast{fmt::format("{}({}[{}]{{}})", cast, cbuf, index)}; | 59 | const auto cbuf_cast{fmt::format("{}({}[{}]{{}})", cast, cbuf, index)}; |
| 60 | const auto extraction{num_bits == 32 ? cbuf_cast | 60 | const auto extraction{num_bits == 32 ? cbuf_cast |
| 61 | : fmt ::format("bitfieldExtract({},int({}),{})", cbuf_cast, | 61 | : fmt::format("bitfieldExtract({},int({}),{})", cbuf_cast, |
| 62 | bit_offset, num_bits)}; | 62 | bit_offset, num_bits)}; |
| 63 | if (!component_indexing_bug) { | 63 | if (!component_indexing_bug) { |
| 64 | const auto result{fmt::format(fmt::runtime(extraction), swizzle)}; | 64 | const auto result{fmt::format(fmt::runtime(extraction), swizzle)}; |
| 65 | ctx.Add("{}={};", ret, result); | 65 | ctx.Add("{}={};", ret, result); |
diff --git a/src/shader_recompiler/object_pool.h b/src/shader_recompiler/object_pool.h index f3b12d04b..a12ddcc8f 100644 --- a/src/shader_recompiler/object_pool.h +++ b/src/shader_recompiler/object_pool.h | |||
| @@ -11,14 +11,16 @@ | |||
| 11 | namespace Shader { | 11 | namespace Shader { |
| 12 | 12 | ||
| 13 | template <typename T> | 13 | template <typename T> |
| 14 | requires std::is_destructible_v<T> class ObjectPool { | 14 | requires std::is_destructible_v<T> |
| 15 | class ObjectPool { | ||
| 15 | public: | 16 | public: |
| 16 | explicit ObjectPool(size_t chunk_size = 8192) : new_chunk_size{chunk_size} { | 17 | explicit ObjectPool(size_t chunk_size = 8192) : new_chunk_size{chunk_size} { |
| 17 | node = &chunks.emplace_back(new_chunk_size); | 18 | node = &chunks.emplace_back(new_chunk_size); |
| 18 | } | 19 | } |
| 19 | 20 | ||
| 20 | template <typename... Args> | 21 | template <typename... Args> |
| 21 | requires std::is_constructible_v<T, Args...>[[nodiscard]] T* Create(Args&&... args) { | 22 | requires std::is_constructible_v<T, Args...> |
| 23 | [[nodiscard]] T* Create(Args&&... args) { | ||
| 22 | return std::construct_at(Memory(), std::forward<Args>(args)...); | 24 | return std::construct_at(Memory(), std::forward<Args>(args)...); |
| 23 | } | 25 | } |
| 24 | 26 | ||
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index 7bfd57369..d350c9b36 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h | |||
| @@ -570,13 +570,12 @@ bool BufferCache<P>::DMACopy(GPUVAddr src_address, GPUVAddr dest_address, u64 am | |||
| 570 | ForEachWrittenRange(*cpu_src_address, amount, mirror); | 570 | ForEachWrittenRange(*cpu_src_address, amount, mirror); |
| 571 | // This subtraction in this order is important for overlapping copies. | 571 | // This subtraction in this order is important for overlapping copies. |
| 572 | common_ranges.subtract(subtract_interval); | 572 | common_ranges.subtract(subtract_interval); |
| 573 | bool atleast_1_download = tmp_intervals.size() != 0; | 573 | const bool has_new_downloads = tmp_intervals.size() != 0; |
| 574 | for (const IntervalType add_interval : tmp_intervals) { | 574 | for (const IntervalType& add_interval : tmp_intervals) { |
| 575 | common_ranges.add(add_interval); | 575 | common_ranges.add(add_interval); |
| 576 | } | 576 | } |
| 577 | |||
| 578 | runtime.CopyBuffer(dest_buffer, src_buffer, copies); | 577 | runtime.CopyBuffer(dest_buffer, src_buffer, copies); |
| 579 | if (atleast_1_download) { | 578 | if (has_new_downloads) { |
| 580 | dest_buffer.MarkRegionAsGpuModified(*cpu_dest_address, amount); | 579 | dest_buffer.MarkRegionAsGpuModified(*cpu_dest_address, amount); |
| 581 | } | 580 | } |
| 582 | std::vector<u8> tmp_buffer(amount); | 581 | std::vector<u8> tmp_buffer(amount); |
diff --git a/src/video_core/cdma_pusher.cpp b/src/video_core/cdma_pusher.cpp index 8b86ad050..a8c4b4415 100644 --- a/src/video_core/cdma_pusher.cpp +++ b/src/video_core/cdma_pusher.cpp | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #include "command_classes/vic.h" | 24 | #include "command_classes/vic.h" |
| 25 | #include "video_core/cdma_pusher.h" | 25 | #include "video_core/cdma_pusher.h" |
| 26 | #include "video_core/command_classes/nvdec_common.h" | 26 | #include "video_core/command_classes/nvdec_common.h" |
| 27 | #include "video_core/command_classes/sync_manager.h" | ||
| 27 | #include "video_core/engines/maxwell_3d.h" | 28 | #include "video_core/engines/maxwell_3d.h" |
| 28 | #include "video_core/gpu.h" | 29 | #include "video_core/gpu.h" |
| 29 | #include "video_core/memory_manager.h" | 30 | #include "video_core/memory_manager.h" |
diff --git a/src/video_core/cdma_pusher.h b/src/video_core/cdma_pusher.h index 1bada44dd..87b49d6ea 100644 --- a/src/video_core/cdma_pusher.h +++ b/src/video_core/cdma_pusher.h | |||
| @@ -9,13 +9,13 @@ | |||
| 9 | 9 | ||
| 10 | #include "common/bit_field.h" | 10 | #include "common/bit_field.h" |
| 11 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 12 | #include "video_core/command_classes/sync_manager.h" | ||
| 13 | 12 | ||
| 14 | namespace Tegra { | 13 | namespace Tegra { |
| 15 | 14 | ||
| 16 | class GPU; | 15 | class GPU; |
| 17 | class Host1x; | 16 | class Host1x; |
| 18 | class Nvdec; | 17 | class Nvdec; |
| 18 | class SyncptIncrManager; | ||
| 19 | class Vic; | 19 | class Vic; |
| 20 | 20 | ||
| 21 | enum class ChSubmissionMode : u32 { | 21 | enum class ChSubmissionMode : u32 { |
diff --git a/src/video_core/command_classes/vic.cpp b/src/video_core/command_classes/vic.cpp index 0ee07f398..dc768b952 100644 --- a/src/video_core/command_classes/vic.cpp +++ b/src/video_core/command_classes/vic.cpp | |||
| @@ -16,6 +16,7 @@ extern "C" { | |||
| 16 | } | 16 | } |
| 17 | 17 | ||
| 18 | #include "common/assert.h" | 18 | #include "common/assert.h" |
| 19 | #include "common/bit_field.h" | ||
| 19 | #include "common/logging/log.h" | 20 | #include "common/logging/log.h" |
| 20 | 21 | ||
| 21 | #include "video_core/command_classes/nvdec.h" | 22 | #include "video_core/command_classes/nvdec.h" |
| @@ -26,6 +27,25 @@ extern "C" { | |||
| 26 | #include "video_core/textures/decoders.h" | 27 | #include "video_core/textures/decoders.h" |
| 27 | 28 | ||
| 28 | namespace Tegra { | 29 | namespace Tegra { |
| 30 | namespace { | ||
| 31 | enum class VideoPixelFormat : u64_le { | ||
| 32 | RGBA8 = 0x1f, | ||
| 33 | BGRA8 = 0x20, | ||
| 34 | RGBX8 = 0x23, | ||
| 35 | Yuv420 = 0x44, | ||
| 36 | }; | ||
| 37 | } // Anonymous namespace | ||
| 38 | |||
| 39 | union VicConfig { | ||
| 40 | u64_le raw{}; | ||
| 41 | BitField<0, 7, VideoPixelFormat> pixel_format; | ||
| 42 | BitField<7, 2, u64_le> chroma_loc_horiz; | ||
| 43 | BitField<9, 2, u64_le> chroma_loc_vert; | ||
| 44 | BitField<11, 4, u64_le> block_linear_kind; | ||
| 45 | BitField<15, 4, u64_le> block_linear_height_log2; | ||
| 46 | BitField<32, 14, u64_le> surface_width_minus1; | ||
| 47 | BitField<46, 14, u64_le> surface_height_minus1; | ||
| 48 | }; | ||
| 29 | 49 | ||
| 30 | Vic::Vic(GPU& gpu_, std::shared_ptr<Nvdec> nvdec_processor_) | 50 | Vic::Vic(GPU& gpu_, std::shared_ptr<Nvdec> nvdec_processor_) |
| 31 | : gpu(gpu_), | 51 | : gpu(gpu_), |
| @@ -65,134 +85,156 @@ void Vic::Execute() { | |||
| 65 | if (!frame) { | 85 | if (!frame) { |
| 66 | return; | 86 | return; |
| 67 | } | 87 | } |
| 68 | const auto pixel_format = static_cast<VideoPixelFormat>(config.pixel_format.Value()); | 88 | const u64 surface_width = config.surface_width_minus1 + 1; |
| 69 | switch (pixel_format) { | 89 | const u64 surface_height = config.surface_height_minus1 + 1; |
| 90 | if (static_cast<u64>(frame->width) != surface_width || | ||
| 91 | static_cast<u64>(frame->height) > surface_height) { | ||
| 92 | // TODO: Properly support multiple video streams with differing frame dimensions | ||
| 93 | LOG_WARNING(Debug, | ||
| 94 | "Frame dimensions {}x{} can't be safely decoded into surface dimensions {}x{}", | ||
| 95 | frame->width, frame->height, surface_width, surface_height); | ||
| 96 | return; | ||
| 97 | } | ||
| 98 | switch (config.pixel_format) { | ||
| 99 | case VideoPixelFormat::RGBA8: | ||
| 70 | case VideoPixelFormat::BGRA8: | 100 | case VideoPixelFormat::BGRA8: |
| 71 | case VideoPixelFormat::RGBA8: { | 101 | case VideoPixelFormat::RGBX8: |
| 72 | LOG_TRACE(Service_NVDRV, "Writing RGB Frame"); | 102 | WriteRGBFrame(frame, config); |
| 103 | break; | ||
| 104 | case VideoPixelFormat::Yuv420: | ||
| 105 | WriteYUVFrame(frame, config); | ||
| 106 | break; | ||
| 107 | default: | ||
| 108 | UNIMPLEMENTED_MSG("Unknown video pixel format {:X}", config.pixel_format.Value()); | ||
| 109 | break; | ||
| 110 | } | ||
| 111 | } | ||
| 73 | 112 | ||
| 74 | if (scaler_ctx == nullptr || frame->width != scaler_width || | 113 | void Vic::WriteRGBFrame(const AVFrame* frame, const VicConfig& config) { |
| 75 | frame->height != scaler_height) { | 114 | LOG_TRACE(Service_NVDRV, "Writing RGB Frame"); |
| 76 | const AVPixelFormat target_format = | 115 | |
| 77 | (pixel_format == VideoPixelFormat::RGBA8) ? AV_PIX_FMT_RGBA : AV_PIX_FMT_BGRA; | 116 | if (!scaler_ctx || frame->width != scaler_width || frame->height != scaler_height) { |
| 117 | const AVPixelFormat target_format = [pixel_format = config.pixel_format]() { | ||
| 118 | switch (pixel_format) { | ||
| 119 | case VideoPixelFormat::RGBA8: | ||
| 120 | return AV_PIX_FMT_RGBA; | ||
| 121 | case VideoPixelFormat::BGRA8: | ||
| 122 | return AV_PIX_FMT_BGRA; | ||
| 123 | case VideoPixelFormat::RGBX8: | ||
| 124 | return AV_PIX_FMT_RGB0; | ||
| 125 | default: | ||
| 126 | return AV_PIX_FMT_RGBA; | ||
| 127 | } | ||
| 128 | }(); | ||
| 129 | |||
| 130 | sws_freeContext(scaler_ctx); | ||
| 131 | // Frames are decoded into either YUV420 or NV12 formats. Convert to desired RGB format | ||
| 132 | scaler_ctx = sws_getContext(frame->width, frame->height, | ||
| 133 | static_cast<AVPixelFormat>(frame->format), frame->width, | ||
| 134 | frame->height, target_format, 0, nullptr, nullptr, nullptr); | ||
| 135 | scaler_width = frame->width; | ||
| 136 | scaler_height = frame->height; | ||
| 137 | converted_frame_buffer.reset(); | ||
| 138 | } | ||
| 139 | // Get Converted frame | ||
| 140 | const u32 width = static_cast<u32>(frame->width); | ||
| 141 | const u32 height = static_cast<u32>(frame->height); | ||
| 142 | const std::size_t linear_size = width * height * 4; | ||
| 143 | |||
| 144 | // Only allocate frame_buffer once per stream, as the size is not expected to change | ||
| 145 | if (!converted_frame_buffer) { | ||
| 146 | converted_frame_buffer = AVMallocPtr{static_cast<u8*>(av_malloc(linear_size)), av_free}; | ||
| 147 | } | ||
| 148 | const std::array<int, 4> converted_stride{frame->width * 4, frame->height * 4, 0, 0}; | ||
| 149 | u8* const converted_frame_buf_addr{converted_frame_buffer.get()}; | ||
| 150 | |||
| 151 | sws_scale(scaler_ctx, frame->data, frame->linesize, 0, frame->height, &converted_frame_buf_addr, | ||
| 152 | converted_stride.data()); | ||
| 153 | |||
| 154 | const u32 blk_kind = static_cast<u32>(config.block_linear_kind); | ||
| 155 | if (blk_kind != 0) { | ||
| 156 | // swizzle pitch linear to block linear | ||
| 157 | const u32 block_height = static_cast<u32>(config.block_linear_height_log2); | ||
| 158 | const auto size = Texture::CalculateSize(true, 4, width, height, 1, block_height, 0); | ||
| 159 | luma_buffer.resize(size); | ||
| 160 | Texture::SwizzleSubrect(width, height, width * 4, width, 4, luma_buffer.data(), | ||
| 161 | converted_frame_buffer.get(), block_height, 0, 0); | ||
| 162 | |||
| 163 | gpu.MemoryManager().WriteBlock(output_surface_luma_address, luma_buffer.data(), size); | ||
| 164 | } else { | ||
| 165 | // send pitch linear frame | ||
| 166 | gpu.MemoryManager().WriteBlock(output_surface_luma_address, converted_frame_buf_addr, | ||
| 167 | linear_size); | ||
| 168 | } | ||
| 169 | } | ||
| 78 | 170 | ||
| 79 | sws_freeContext(scaler_ctx); | 171 | void Vic::WriteYUVFrame(const AVFrame* frame, const VicConfig& config) { |
| 80 | scaler_ctx = nullptr; | 172 | LOG_TRACE(Service_NVDRV, "Writing YUV420 Frame"); |
| 81 | 173 | ||
| 82 | // Frames are decoded into either YUV420 or NV12 formats. Convert to desired format | 174 | const std::size_t surface_width = config.surface_width_minus1 + 1; |
| 83 | scaler_ctx = sws_getContext(frame->width, frame->height, | 175 | const std::size_t surface_height = config.surface_height_minus1 + 1; |
| 84 | static_cast<AVPixelFormat>(frame->format), frame->width, | 176 | const auto frame_width = std::min(surface_width, static_cast<size_t>(frame->width)); |
| 85 | frame->height, target_format, 0, nullptr, nullptr, nullptr); | 177 | const auto frame_height = std::min(surface_height, static_cast<size_t>(frame->height)); |
| 178 | const std::size_t aligned_width = (surface_width + 0xff) & ~0xffUL; | ||
| 86 | 179 | ||
| 87 | scaler_width = frame->width; | 180 | const auto stride = static_cast<size_t>(frame->linesize[0]); |
| 88 | scaler_height = frame->height; | 181 | |
| 89 | } | 182 | luma_buffer.resize(aligned_width * surface_height); |
| 90 | // Get Converted frame | 183 | chroma_buffer.resize(aligned_width * surface_height / 2); |
| 91 | const u32 width = static_cast<u32>(frame->width); | 184 | |
| 92 | const u32 height = static_cast<u32>(frame->height); | 185 | // Populate luma buffer |
| 93 | const std::size_t linear_size = width * height * 4; | 186 | const u8* luma_src = frame->data[0]; |
| 94 | 187 | for (std::size_t y = 0; y < frame_height; ++y) { | |
| 95 | // Only allocate frame_buffer once per stream, as the size is not expected to change | 188 | const std::size_t src = y * stride; |
| 96 | if (!converted_frame_buffer) { | 189 | const std::size_t dst = y * aligned_width; |
| 97 | converted_frame_buffer = AVMallocPtr{static_cast<u8*>(av_malloc(linear_size)), av_free}; | 190 | for (std::size_t x = 0; x < frame_width; ++x) { |
| 191 | luma_buffer[dst + x] = luma_src[src + x]; | ||
| 98 | } | 192 | } |
| 99 | const std::array<int, 4> converted_stride{frame->width * 4, frame->height * 4, 0, 0}; | 193 | } |
| 100 | u8* const converted_frame_buf_addr{converted_frame_buffer.get()}; | 194 | gpu.MemoryManager().WriteBlock(output_surface_luma_address, luma_buffer.data(), |
| 101 | 195 | luma_buffer.size()); | |
| 102 | sws_scale(scaler_ctx, frame->data, frame->linesize, 0, frame->height, | 196 | |
| 103 | &converted_frame_buf_addr, converted_stride.data()); | 197 | // Chroma |
| 104 | 198 | const std::size_t half_height = frame_height / 2; | |
| 105 | const u32 blk_kind = static_cast<u32>(config.block_linear_kind); | 199 | const auto half_stride = static_cast<size_t>(frame->linesize[1]); |
| 106 | if (blk_kind != 0) { | 200 | |
| 107 | // swizzle pitch linear to block linear | 201 | switch (frame->format) { |
| 108 | const u32 block_height = static_cast<u32>(config.block_linear_height_log2); | 202 | case AV_PIX_FMT_YUV420P: { |
| 109 | const auto size = | 203 | // Frame from FFmpeg software |
| 110 | Tegra::Texture::CalculateSize(true, 4, width, height, 1, block_height, 0); | 204 | // Populate chroma buffer from both channels with interleaving. |
| 111 | luma_buffer.resize(size); | 205 | const std::size_t half_width = frame_width / 2; |
| 112 | Tegra::Texture::SwizzleSubrect(width, height, width * 4, width, 4, luma_buffer.data(), | 206 | const u8* chroma_b_src = frame->data[1]; |
| 113 | converted_frame_buffer.get(), block_height, 0, 0); | 207 | const u8* chroma_r_src = frame->data[2]; |
| 114 | 208 | for (std::size_t y = 0; y < half_height; ++y) { | |
| 115 | gpu.MemoryManager().WriteBlock(output_surface_luma_address, luma_buffer.data(), size); | 209 | const std::size_t src = y * half_stride; |
| 116 | } else { | 210 | const std::size_t dst = y * aligned_width; |
| 117 | // send pitch linear frame | 211 | |
| 118 | gpu.MemoryManager().WriteBlock(output_surface_luma_address, converted_frame_buf_addr, | 212 | for (std::size_t x = 0; x < half_width; ++x) { |
| 119 | linear_size); | 213 | chroma_buffer[dst + x * 2] = chroma_b_src[src + x]; |
| 214 | chroma_buffer[dst + x * 2 + 1] = chroma_r_src[src + x]; | ||
| 215 | } | ||
| 120 | } | 216 | } |
| 121 | break; | 217 | break; |
| 122 | } | 218 | } |
| 123 | case VideoPixelFormat::Yuv420: { | 219 | case AV_PIX_FMT_NV12: { |
| 124 | LOG_TRACE(Service_NVDRV, "Writing YUV420 Frame"); | 220 | // Frame from VA-API hardware |
| 125 | 221 | // This is already interleaved so just copy | |
| 126 | const std::size_t surface_width = config.surface_width_minus1 + 1; | 222 | const u8* chroma_src = frame->data[1]; |
| 127 | const std::size_t surface_height = config.surface_height_minus1 + 1; | 223 | for (std::size_t y = 0; y < half_height; ++y) { |
| 128 | const auto frame_width = std::min(surface_width, static_cast<size_t>(frame->width)); | ||
| 129 | const auto frame_height = std::min(surface_height, static_cast<size_t>(frame->height)); | ||
| 130 | const std::size_t aligned_width = (surface_width + 0xff) & ~0xffUL; | ||
| 131 | |||
| 132 | const auto stride = static_cast<size_t>(frame->linesize[0]); | ||
| 133 | |||
| 134 | luma_buffer.resize(aligned_width * surface_height); | ||
| 135 | chroma_buffer.resize(aligned_width * surface_height / 2); | ||
| 136 | |||
| 137 | // Populate luma buffer | ||
| 138 | const u8* luma_src = frame->data[0]; | ||
| 139 | for (std::size_t y = 0; y < frame_height; ++y) { | ||
| 140 | const std::size_t src = y * stride; | 224 | const std::size_t src = y * stride; |
| 141 | const std::size_t dst = y * aligned_width; | 225 | const std::size_t dst = y * aligned_width; |
| 142 | for (std::size_t x = 0; x < frame_width; ++x) { | 226 | for (std::size_t x = 0; x < frame_width; ++x) { |
| 143 | luma_buffer[dst + x] = luma_src[src + x]; | 227 | chroma_buffer[dst + x] = chroma_src[src + x]; |
| 144 | } | ||
| 145 | } | ||
| 146 | gpu.MemoryManager().WriteBlock(output_surface_luma_address, luma_buffer.data(), | ||
| 147 | luma_buffer.size()); | ||
| 148 | |||
| 149 | // Chroma | ||
| 150 | const std::size_t half_height = frame_height / 2; | ||
| 151 | const auto half_stride = static_cast<size_t>(frame->linesize[1]); | ||
| 152 | |||
| 153 | switch (frame->format) { | ||
| 154 | case AV_PIX_FMT_YUV420P: { | ||
| 155 | // Frame from FFmpeg software | ||
| 156 | // Populate chroma buffer from both channels with interleaving. | ||
| 157 | const std::size_t half_width = frame_width / 2; | ||
| 158 | const u8* chroma_b_src = frame->data[1]; | ||
| 159 | const u8* chroma_r_src = frame->data[2]; | ||
| 160 | for (std::size_t y = 0; y < half_height; ++y) { | ||
| 161 | const std::size_t src = y * half_stride; | ||
| 162 | const std::size_t dst = y * aligned_width; | ||
| 163 | |||
| 164 | for (std::size_t x = 0; x < half_width; ++x) { | ||
| 165 | chroma_buffer[dst + x * 2] = chroma_b_src[src + x]; | ||
| 166 | chroma_buffer[dst + x * 2 + 1] = chroma_r_src[src + x]; | ||
| 167 | } | ||
| 168 | } | 228 | } |
| 169 | break; | ||
| 170 | } | ||
| 171 | case AV_PIX_FMT_NV12: { | ||
| 172 | // Frame from VA-API hardware | ||
| 173 | // This is already interleaved so just copy | ||
| 174 | const u8* chroma_src = frame->data[1]; | ||
| 175 | for (std::size_t y = 0; y < half_height; ++y) { | ||
| 176 | const std::size_t src = y * stride; | ||
| 177 | const std::size_t dst = y * aligned_width; | ||
| 178 | for (std::size_t x = 0; x < frame_width; ++x) { | ||
| 179 | chroma_buffer[dst + x] = chroma_src[src + x]; | ||
| 180 | } | ||
| 181 | } | ||
| 182 | break; | ||
| 183 | } | ||
| 184 | default: | ||
| 185 | UNREACHABLE(); | ||
| 186 | break; | ||
| 187 | } | 229 | } |
| 188 | gpu.MemoryManager().WriteBlock(output_surface_chroma_address, chroma_buffer.data(), | ||
| 189 | chroma_buffer.size()); | ||
| 190 | break; | 230 | break; |
| 191 | } | 231 | } |
| 192 | default: | 232 | default: |
| 193 | UNIMPLEMENTED_MSG("Unknown video pixel format {}", config.pixel_format.Value()); | 233 | UNREACHABLE(); |
| 194 | break; | 234 | break; |
| 195 | } | 235 | } |
| 236 | gpu.MemoryManager().WriteBlock(output_surface_chroma_address, chroma_buffer.data(), | ||
| 237 | chroma_buffer.size()); | ||
| 196 | } | 238 | } |
| 197 | 239 | ||
| 198 | } // namespace Tegra | 240 | } // namespace Tegra |
diff --git a/src/video_core/command_classes/vic.h b/src/video_core/command_classes/vic.h index 74246e08c..6d4cdfd57 100644 --- a/src/video_core/command_classes/vic.h +++ b/src/video_core/command_classes/vic.h | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | 6 | ||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <vector> | 8 | #include <vector> |
| 9 | #include "common/bit_field.h" | ||
| 10 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 11 | 10 | ||
| 12 | struct SwsContext; | 11 | struct SwsContext; |
| @@ -14,6 +13,7 @@ struct SwsContext; | |||
| 14 | namespace Tegra { | 13 | namespace Tegra { |
| 15 | class GPU; | 14 | class GPU; |
| 16 | class Nvdec; | 15 | class Nvdec; |
| 16 | union VicConfig; | ||
| 17 | 17 | ||
| 18 | class Vic { | 18 | class Vic { |
| 19 | public: | 19 | public: |
| @@ -27,6 +27,7 @@ public: | |||
| 27 | }; | 27 | }; |
| 28 | 28 | ||
| 29 | explicit Vic(GPU& gpu, std::shared_ptr<Nvdec> nvdec_processor); | 29 | explicit Vic(GPU& gpu, std::shared_ptr<Nvdec> nvdec_processor); |
| 30 | |||
| 30 | ~Vic(); | 31 | ~Vic(); |
| 31 | 32 | ||
| 32 | /// Write to the device state. | 33 | /// Write to the device state. |
| @@ -35,22 +36,9 @@ public: | |||
| 35 | private: | 36 | private: |
| 36 | void Execute(); | 37 | void Execute(); |
| 37 | 38 | ||
| 38 | enum class VideoPixelFormat : u64_le { | 39 | void WriteRGBFrame(const AVFrame* frame, const VicConfig& config); |
| 39 | RGBA8 = 0x1f, | ||
| 40 | BGRA8 = 0x20, | ||
| 41 | Yuv420 = 0x44, | ||
| 42 | }; | ||
| 43 | 40 | ||
| 44 | union VicConfig { | 41 | void WriteYUVFrame(const AVFrame* frame, const VicConfig& config); |
| 45 | u64_le raw{}; | ||
| 46 | BitField<0, 7, u64_le> pixel_format; | ||
| 47 | BitField<7, 2, u64_le> chroma_loc_horiz; | ||
| 48 | BitField<9, 2, u64_le> chroma_loc_vert; | ||
| 49 | BitField<11, 4, u64_le> block_linear_kind; | ||
| 50 | BitField<15, 4, u64_le> block_linear_height_log2; | ||
| 51 | BitField<32, 14, u64_le> surface_width_minus1; | ||
| 52 | BitField<46, 14, u64_le> surface_height_minus1; | ||
| 53 | }; | ||
| 54 | 42 | ||
| 55 | GPU& gpu; | 43 | GPU& gpu; |
| 56 | std::shared_ptr<Tegra::Nvdec> nvdec_processor; | 44 | std::shared_ptr<Tegra::Nvdec> nvdec_processor; |
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index 7f4ca6282..f22342dfb 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <bitset> | 8 | #include <bitset> |
| 9 | #include <cmath> | ||
| 9 | #include <limits> | 10 | #include <limits> |
| 10 | #include <optional> | 11 | #include <optional> |
| 11 | #include <type_traits> | 12 | #include <type_traits> |
diff --git a/src/video_core/engines/maxwell_dma.cpp b/src/video_core/engines/maxwell_dma.cpp index c7ec1eac9..67388d980 100644 --- a/src/video_core/engines/maxwell_dma.cpp +++ b/src/video_core/engines/maxwell_dma.cpp | |||
| @@ -82,41 +82,41 @@ void MaxwellDMA::Launch() { | |||
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | void MaxwellDMA::CopyPitchToPitch() { | 84 | void MaxwellDMA::CopyPitchToPitch() { |
| 85 | // When `multi_line_enable` bit is disabled the copy is performed as if we were copying a 1D | 85 | // When `multi_line_enable` bit is enabled we copy a 2D image of dimensions |
| 86 | // buffer of length `line_length_in`. | 86 | // (line_length_in, line_count). |
| 87 | // Otherwise we copy a 2D image of dimensions (line_length_in, line_count). | 87 | // Otherwise the copy is performed as if we were copying a 1D buffer of length line_length_in. |
| 88 | auto& accelerate = rasterizer->AccessAccelerateDMA(); | 88 | const bool remap_enabled = regs.launch_dma.remap_enable != 0; |
| 89 | if (!regs.launch_dma.multi_line_enable) { | 89 | if (regs.launch_dma.multi_line_enable) { |
| 90 | const bool is_buffer_clear = regs.launch_dma.remap_enable != 0 && | 90 | UNIMPLEMENTED_IF(remap_enabled); |
| 91 | regs.remap_const.dst_x == RemapConst::Swizzle::CONST_A; | 91 | |
| 92 | // TODO: allow multisized components. | 92 | // Perform a line-by-line copy. |
| 93 | if (is_buffer_clear) { | 93 | // We're going to take a subrect of size (line_length_in, line_count) from the source |
| 94 | ASSERT(regs.remap_const.component_size_minus_one == 3); | 94 | // rectangle. There is no need to manually flush/invalidate the regions because CopyBlock |
| 95 | accelerate.BufferClear(regs.offset_out, regs.line_length_in, regs.remap_consta_value); | 95 | // does that for us. |
| 96 | std::vector<u32> tmp_buffer(regs.line_length_in, regs.remap_consta_value); | 96 | for (u32 line = 0; line < regs.line_count; ++line) { |
| 97 | memory_manager.WriteBlockUnsafe(regs.offset_out, | 97 | const GPUVAddr source_line = regs.offset_in + static_cast<size_t>(line) * regs.pitch_in; |
| 98 | reinterpret_cast<u8*>(tmp_buffer.data()), | 98 | const GPUVAddr dest_line = regs.offset_out + static_cast<size_t>(line) * regs.pitch_out; |
| 99 | regs.line_length_in * sizeof(u32)); | 99 | memory_manager.CopyBlock(dest_line, source_line, regs.line_length_in); |
| 100 | return; | ||
| 101 | } | ||
| 102 | UNIMPLEMENTED_IF(regs.launch_dma.remap_enable != 0); | ||
| 103 | if (!accelerate.BufferCopy(regs.offset_in, regs.offset_out, regs.line_length_in)) { | ||
| 104 | std::vector<u8> tmp_buffer(regs.line_length_in); | ||
| 105 | memory_manager.ReadBlockUnsafe(regs.offset_in, tmp_buffer.data(), regs.line_length_in); | ||
| 106 | memory_manager.WriteBlock(regs.offset_out, tmp_buffer.data(), regs.line_length_in); | ||
| 107 | } | 100 | } |
| 108 | return; | 101 | return; |
| 109 | } | 102 | } |
| 110 | 103 | // TODO: allow multisized components. | |
| 111 | UNIMPLEMENTED_IF(regs.launch_dma.remap_enable != 0); | 104 | auto& accelerate = rasterizer->AccessAccelerateDMA(); |
| 112 | 105 | const bool is_const_a_dst = regs.remap_const.dst_x == RemapConst::Swizzle::CONST_A; | |
| 113 | // Perform a line-by-line copy. | 106 | const bool is_buffer_clear = remap_enabled && is_const_a_dst; |
| 114 | // We're going to take a subrect of size (line_length_in, line_count) from the source rectangle. | 107 | if (is_buffer_clear) { |
| 115 | // There is no need to manually flush/invalidate the regions because CopyBlock does that for us. | 108 | ASSERT(regs.remap_const.component_size_minus_one == 3); |
| 116 | for (u32 line = 0; line < regs.line_count; ++line) { | 109 | accelerate.BufferClear(regs.offset_out, regs.line_length_in, regs.remap_consta_value); |
| 117 | const GPUVAddr source_line = regs.offset_in + static_cast<size_t>(line) * regs.pitch_in; | 110 | std::vector<u32> tmp_buffer(regs.line_length_in, regs.remap_consta_value); |
| 118 | const GPUVAddr dest_line = regs.offset_out + static_cast<size_t>(line) * regs.pitch_out; | 111 | memory_manager.WriteBlockUnsafe(regs.offset_out, reinterpret_cast<u8*>(tmp_buffer.data()), |
| 119 | memory_manager.CopyBlock(dest_line, source_line, regs.line_length_in); | 112 | regs.line_length_in * sizeof(u32)); |
| 113 | return; | ||
| 114 | } | ||
| 115 | UNIMPLEMENTED_IF(remap_enabled); | ||
| 116 | if (!accelerate.BufferCopy(regs.offset_in, regs.offset_out, regs.line_length_in)) { | ||
| 117 | std::vector<u8> tmp_buffer(regs.line_length_in); | ||
| 118 | memory_manager.ReadBlockUnsafe(regs.offset_in, tmp_buffer.data(), regs.line_length_in); | ||
| 119 | memory_manager.WriteBlock(regs.offset_out, tmp_buffer.data(), regs.line_length_in); | ||
| 120 | } | 120 | } |
| 121 | } | 121 | } |
| 122 | 122 | ||
diff --git a/src/video_core/engines/maxwell_dma.h b/src/video_core/engines/maxwell_dma.h index 9e457ae16..a04514425 100644 --- a/src/video_core/engines/maxwell_dma.h +++ b/src/video_core/engines/maxwell_dma.h | |||
| @@ -175,7 +175,7 @@ public: | |||
| 175 | static_assert(sizeof(LaunchDMA) == 4); | 175 | static_assert(sizeof(LaunchDMA) == 4); |
| 176 | 176 | ||
| 177 | struct RemapConst { | 177 | struct RemapConst { |
| 178 | enum Swizzle : u32 { | 178 | enum class Swizzle : u32 { |
| 179 | SRC_X = 0, | 179 | SRC_X = 0, |
| 180 | SRC_Y = 1, | 180 | SRC_Y = 1, |
| 181 | SRC_Z = 2, | 181 | SRC_Z = 2, |
diff --git a/src/video_core/framebuffer_config.h b/src/video_core/framebuffer_config.h index b86c3a757..b1d455e30 100644 --- a/src/video_core/framebuffer_config.h +++ b/src/video_core/framebuffer_config.h | |||
| @@ -4,8 +4,10 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | namespace Tegra { | 7 | #include "common/common_types.h" |
| 8 | #include "common/math_util.h" | ||
| 8 | 9 | ||
| 10 | namespace Tegra { | ||
| 9 | /** | 11 | /** |
| 10 | * Struct describing framebuffer configuration | 12 | * Struct describing framebuffer configuration |
| 11 | */ | 13 | */ |
| @@ -16,6 +18,21 @@ struct FramebufferConfig { | |||
| 16 | B8G8R8A8_UNORM = 5, | 18 | B8G8R8A8_UNORM = 5, |
| 17 | }; | 19 | }; |
| 18 | 20 | ||
| 21 | enum class TransformFlags : u32 { | ||
| 22 | /// No transform flags are set | ||
| 23 | Unset = 0x00, | ||
| 24 | /// Flip source image horizontally (around the vertical axis) | ||
| 25 | FlipH = 0x01, | ||
| 26 | /// Flip source image vertically (around the horizontal axis) | ||
| 27 | FlipV = 0x02, | ||
| 28 | /// Rotate source image 90 degrees clockwise | ||
| 29 | Rotate90 = 0x04, | ||
| 30 | /// Rotate source image 180 degrees | ||
| 31 | Rotate180 = 0x03, | ||
| 32 | /// Rotate source image 270 degrees clockwise | ||
| 33 | Rotate270 = 0x07, | ||
| 34 | }; | ||
| 35 | |||
| 19 | VAddr address{}; | 36 | VAddr address{}; |
| 20 | u32 offset{}; | 37 | u32 offset{}; |
| 21 | u32 width{}; | 38 | u32 width{}; |
| @@ -23,7 +40,6 @@ struct FramebufferConfig { | |||
| 23 | u32 stride{}; | 40 | u32 stride{}; |
| 24 | PixelFormat pixel_format{}; | 41 | PixelFormat pixel_format{}; |
| 25 | 42 | ||
| 26 | using TransformFlags = Service::NVFlinger::BufferQueue::BufferTransformFlags; | ||
| 27 | TransformFlags transform_flags{}; | 43 | TransformFlags transform_flags{}; |
| 28 | Common::Rectangle<int> crop_rect; | 44 | Common::Rectangle<int> crop_rect; |
| 29 | }; | 45 | }; |
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index 2ae3639b5..ab7c21a49 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp | |||
| @@ -2,540 +2,913 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <array> | ||
| 6 | #include <atomic> | ||
| 5 | #include <chrono> | 7 | #include <chrono> |
| 8 | #include <condition_variable> | ||
| 9 | #include <list> | ||
| 10 | #include <memory> | ||
| 6 | 11 | ||
| 7 | #include "common/assert.h" | 12 | #include "common/assert.h" |
| 8 | #include "common/microprofile.h" | 13 | #include "common/microprofile.h" |
| 9 | #include "common/settings.h" | 14 | #include "common/settings.h" |
| 10 | #include "core/core.h" | 15 | #include "core/core.h" |
| 11 | #include "core/core_timing.h" | 16 | #include "core/core_timing.h" |
| 12 | #include "core/core_timing_util.h" | ||
| 13 | #include "core/frontend/emu_window.h" | 17 | #include "core/frontend/emu_window.h" |
| 14 | #include "core/hardware_interrupt_manager.h" | 18 | #include "core/hardware_interrupt_manager.h" |
| 15 | #include "core/memory.h" | 19 | #include "core/hle/service/nvdrv/nvdata.h" |
| 20 | #include "core/hle/service/nvflinger/buffer_queue.h" | ||
| 16 | #include "core/perf_stats.h" | 21 | #include "core/perf_stats.h" |
| 22 | #include "video_core/cdma_pusher.h" | ||
| 23 | #include "video_core/dma_pusher.h" | ||
| 17 | #include "video_core/engines/fermi_2d.h" | 24 | #include "video_core/engines/fermi_2d.h" |
| 18 | #include "video_core/engines/kepler_compute.h" | 25 | #include "video_core/engines/kepler_compute.h" |
| 19 | #include "video_core/engines/kepler_memory.h" | 26 | #include "video_core/engines/kepler_memory.h" |
| 20 | #include "video_core/engines/maxwell_3d.h" | 27 | #include "video_core/engines/maxwell_3d.h" |
| 21 | #include "video_core/engines/maxwell_dma.h" | 28 | #include "video_core/engines/maxwell_dma.h" |
| 22 | #include "video_core/gpu.h" | 29 | #include "video_core/gpu.h" |
| 30 | #include "video_core/gpu_thread.h" | ||
| 23 | #include "video_core/memory_manager.h" | 31 | #include "video_core/memory_manager.h" |
| 24 | #include "video_core/renderer_base.h" | 32 | #include "video_core/renderer_base.h" |
| 25 | #include "video_core/shader_notify.h" | 33 | #include "video_core/shader_notify.h" |
| 26 | #include "video_core/video_core.h" | ||
| 27 | 34 | ||
| 28 | namespace Tegra { | 35 | namespace Tegra { |
| 29 | 36 | ||
| 30 | MICROPROFILE_DEFINE(GPU_wait, "GPU", "Wait for the GPU", MP_RGB(128, 128, 192)); | 37 | MICROPROFILE_DEFINE(GPU_wait, "GPU", "Wait for the GPU", MP_RGB(128, 128, 192)); |
| 31 | 38 | ||
| 32 | GPU::GPU(Core::System& system_, bool is_async_, bool use_nvdec_) | 39 | struct GPU::Impl { |
| 33 | : system{system_}, memory_manager{std::make_unique<Tegra::MemoryManager>(system)}, | 40 | explicit Impl(GPU& gpu_, Core::System& system_, bool is_async_, bool use_nvdec_) |
| 34 | dma_pusher{std::make_unique<Tegra::DmaPusher>(system, *this)}, use_nvdec{use_nvdec_}, | 41 | : gpu{gpu_}, system{system_}, memory_manager{std::make_unique<Tegra::MemoryManager>( |
| 35 | maxwell_3d{std::make_unique<Engines::Maxwell3D>(system, *memory_manager)}, | 42 | system)}, |
| 36 | fermi_2d{std::make_unique<Engines::Fermi2D>()}, | 43 | dma_pusher{std::make_unique<Tegra::DmaPusher>(system, gpu)}, use_nvdec{use_nvdec_}, |
| 37 | kepler_compute{std::make_unique<Engines::KeplerCompute>(system, *memory_manager)}, | 44 | maxwell_3d{std::make_unique<Engines::Maxwell3D>(system, *memory_manager)}, |
| 38 | maxwell_dma{std::make_unique<Engines::MaxwellDMA>(system, *memory_manager)}, | 45 | fermi_2d{std::make_unique<Engines::Fermi2D>()}, |
| 39 | kepler_memory{std::make_unique<Engines::KeplerMemory>(system, *memory_manager)}, | 46 | kepler_compute{std::make_unique<Engines::KeplerCompute>(system, *memory_manager)}, |
| 40 | shader_notify{std::make_unique<VideoCore::ShaderNotify>()}, is_async{is_async_}, | 47 | maxwell_dma{std::make_unique<Engines::MaxwellDMA>(system, *memory_manager)}, |
| 41 | gpu_thread{system_, is_async_} {} | 48 | kepler_memory{std::make_unique<Engines::KeplerMemory>(system, *memory_manager)}, |
| 49 | shader_notify{std::make_unique<VideoCore::ShaderNotify>()}, is_async{is_async_}, | ||
| 50 | gpu_thread{system_, is_async_} {} | ||
| 51 | |||
| 52 | ~Impl() = default; | ||
| 53 | |||
| 54 | /// Binds a renderer to the GPU. | ||
| 55 | void BindRenderer(std::unique_ptr<VideoCore::RendererBase> renderer_) { | ||
| 56 | renderer = std::move(renderer_); | ||
| 57 | rasterizer = renderer->ReadRasterizer(); | ||
| 58 | |||
| 59 | memory_manager->BindRasterizer(rasterizer); | ||
| 60 | maxwell_3d->BindRasterizer(rasterizer); | ||
| 61 | fermi_2d->BindRasterizer(rasterizer); | ||
| 62 | kepler_compute->BindRasterizer(rasterizer); | ||
| 63 | maxwell_dma->BindRasterizer(rasterizer); | ||
| 64 | } | ||
| 42 | 65 | ||
| 43 | GPU::~GPU() = default; | 66 | /// Calls a GPU method. |
| 67 | void CallMethod(const GPU::MethodCall& method_call) { | ||
| 68 | LOG_TRACE(HW_GPU, "Processing method {:08X} on subchannel {}", method_call.method, | ||
| 69 | method_call.subchannel); | ||
| 70 | |||
| 71 | ASSERT(method_call.subchannel < bound_engines.size()); | ||
| 72 | |||
| 73 | if (ExecuteMethodOnEngine(method_call.method)) { | ||
| 74 | CallEngineMethod(method_call); | ||
| 75 | } else { | ||
| 76 | CallPullerMethod(method_call); | ||
| 77 | } | ||
| 78 | } | ||
| 79 | |||
| 80 | /// Calls a GPU multivalue method. | ||
| 81 | void CallMultiMethod(u32 method, u32 subchannel, const u32* base_start, u32 amount, | ||
| 82 | u32 methods_pending) { | ||
| 83 | LOG_TRACE(HW_GPU, "Processing method {:08X} on subchannel {}", method, subchannel); | ||
| 44 | 84 | ||
| 45 | void GPU::BindRenderer(std::unique_ptr<VideoCore::RendererBase> renderer_) { | 85 | ASSERT(subchannel < bound_engines.size()); |
| 46 | renderer = std::move(renderer_); | 86 | |
| 47 | rasterizer = renderer->ReadRasterizer(); | 87 | if (ExecuteMethodOnEngine(method)) { |
| 88 | CallEngineMultiMethod(method, subchannel, base_start, amount, methods_pending); | ||
| 89 | } else { | ||
| 90 | for (std::size_t i = 0; i < amount; i++) { | ||
| 91 | CallPullerMethod(GPU::MethodCall{ | ||
| 92 | method, | ||
| 93 | base_start[i], | ||
| 94 | subchannel, | ||
| 95 | methods_pending - static_cast<u32>(i), | ||
| 96 | }); | ||
| 97 | } | ||
| 98 | } | ||
| 99 | } | ||
| 100 | |||
| 101 | /// Flush all current written commands into the host GPU for execution. | ||
| 102 | void FlushCommands() { | ||
| 103 | rasterizer->FlushCommands(); | ||
| 104 | } | ||
| 105 | |||
| 106 | /// Synchronizes CPU writes with Host GPU memory. | ||
| 107 | void SyncGuestHost() { | ||
| 108 | rasterizer->SyncGuestHost(); | ||
| 109 | } | ||
| 110 | |||
| 111 | /// Signal the ending of command list. | ||
| 112 | void OnCommandListEnd() { | ||
| 113 | if (is_async) { | ||
| 114 | // This command only applies to asynchronous GPU mode | ||
| 115 | gpu_thread.OnCommandListEnd(); | ||
| 116 | } | ||
| 117 | } | ||
| 118 | |||
| 119 | /// Request a host GPU memory flush from the CPU. | ||
| 120 | [[nodiscard]] u64 RequestFlush(VAddr addr, std::size_t size) { | ||
| 121 | std::unique_lock lck{flush_request_mutex}; | ||
| 122 | const u64 fence = ++last_flush_fence; | ||
| 123 | flush_requests.emplace_back(fence, addr, size); | ||
| 124 | return fence; | ||
| 125 | } | ||
| 126 | |||
| 127 | /// Obtains current flush request fence id. | ||
| 128 | [[nodiscard]] u64 CurrentFlushRequestFence() const { | ||
| 129 | return current_flush_fence.load(std::memory_order_relaxed); | ||
| 130 | } | ||
| 131 | |||
| 132 | /// Tick pending requests within the GPU. | ||
| 133 | void TickWork() { | ||
| 134 | std::unique_lock lck{flush_request_mutex}; | ||
| 135 | while (!flush_requests.empty()) { | ||
| 136 | auto& request = flush_requests.front(); | ||
| 137 | const u64 fence = request.fence; | ||
| 138 | const VAddr addr = request.addr; | ||
| 139 | const std::size_t size = request.size; | ||
| 140 | flush_requests.pop_front(); | ||
| 141 | flush_request_mutex.unlock(); | ||
| 142 | rasterizer->FlushRegion(addr, size); | ||
| 143 | current_flush_fence.store(fence); | ||
| 144 | flush_request_mutex.lock(); | ||
| 145 | } | ||
| 146 | } | ||
| 147 | |||
| 148 | /// Returns a reference to the Maxwell3D GPU engine. | ||
| 149 | [[nodiscard]] Engines::Maxwell3D& Maxwell3D() { | ||
| 150 | return *maxwell_3d; | ||
| 151 | } | ||
| 152 | |||
| 153 | /// Returns a const reference to the Maxwell3D GPU engine. | ||
| 154 | [[nodiscard]] const Engines::Maxwell3D& Maxwell3D() const { | ||
| 155 | return *maxwell_3d; | ||
| 156 | } | ||
| 157 | |||
| 158 | /// Returns a reference to the KeplerCompute GPU engine. | ||
| 159 | [[nodiscard]] Engines::KeplerCompute& KeplerCompute() { | ||
| 160 | return *kepler_compute; | ||
| 161 | } | ||
| 162 | |||
| 163 | /// Returns a reference to the KeplerCompute GPU engine. | ||
| 164 | [[nodiscard]] const Engines::KeplerCompute& KeplerCompute() const { | ||
| 165 | return *kepler_compute; | ||
| 166 | } | ||
| 167 | |||
| 168 | /// Returns a reference to the GPU memory manager. | ||
| 169 | [[nodiscard]] Tegra::MemoryManager& MemoryManager() { | ||
| 170 | return *memory_manager; | ||
| 171 | } | ||
| 172 | |||
| 173 | /// Returns a const reference to the GPU memory manager. | ||
| 174 | [[nodiscard]] const Tegra::MemoryManager& MemoryManager() const { | ||
| 175 | return *memory_manager; | ||
| 176 | } | ||
| 177 | |||
| 178 | /// Returns a reference to the GPU DMA pusher. | ||
| 179 | [[nodiscard]] Tegra::DmaPusher& DmaPusher() { | ||
| 180 | return *dma_pusher; | ||
| 181 | } | ||
| 182 | |||
| 183 | /// Returns a const reference to the GPU DMA pusher. | ||
| 184 | [[nodiscard]] const Tegra::DmaPusher& DmaPusher() const { | ||
| 185 | return *dma_pusher; | ||
| 186 | } | ||
| 187 | |||
| 188 | /// Returns a reference to the GPU CDMA pusher. | ||
| 189 | [[nodiscard]] Tegra::CDmaPusher& CDmaPusher() { | ||
| 190 | return *cdma_pusher; | ||
| 191 | } | ||
| 192 | |||
| 193 | /// Returns a const reference to the GPU CDMA pusher. | ||
| 194 | [[nodiscard]] const Tegra::CDmaPusher& CDmaPusher() const { | ||
| 195 | return *cdma_pusher; | ||
| 196 | } | ||
| 197 | |||
| 198 | /// Returns a reference to the underlying renderer. | ||
| 199 | [[nodiscard]] VideoCore::RendererBase& Renderer() { | ||
| 200 | return *renderer; | ||
| 201 | } | ||
| 202 | |||
| 203 | /// Returns a const reference to the underlying renderer. | ||
| 204 | [[nodiscard]] const VideoCore::RendererBase& Renderer() const { | ||
| 205 | return *renderer; | ||
| 206 | } | ||
| 207 | |||
| 208 | /// Returns a reference to the shader notifier. | ||
| 209 | [[nodiscard]] VideoCore::ShaderNotify& ShaderNotify() { | ||
| 210 | return *shader_notify; | ||
| 211 | } | ||
| 212 | |||
| 213 | /// Returns a const reference to the shader notifier. | ||
| 214 | [[nodiscard]] const VideoCore::ShaderNotify& ShaderNotify() const { | ||
| 215 | return *shader_notify; | ||
| 216 | } | ||
| 217 | |||
| 218 | /// Allows the CPU/NvFlinger to wait on the GPU before presenting a frame. | ||
| 219 | void WaitFence(u32 syncpoint_id, u32 value) { | ||
| 220 | // Synced GPU, is always in sync | ||
| 221 | if (!is_async) { | ||
| 222 | return; | ||
| 223 | } | ||
| 224 | if (syncpoint_id == UINT32_MAX) { | ||
| 225 | // TODO: Research what this does. | ||
| 226 | LOG_ERROR(HW_GPU, "Waiting for syncpoint -1 not implemented"); | ||
| 227 | return; | ||
| 228 | } | ||
| 229 | MICROPROFILE_SCOPE(GPU_wait); | ||
| 230 | std::unique_lock lock{sync_mutex}; | ||
| 231 | sync_cv.wait(lock, [=, this] { | ||
| 232 | if (shutting_down.load(std::memory_order_relaxed)) { | ||
| 233 | // We're shutting down, ensure no threads continue to wait for the next syncpoint | ||
| 234 | return true; | ||
| 235 | } | ||
| 236 | return syncpoints.at(syncpoint_id).load() >= value; | ||
| 237 | }); | ||
| 238 | } | ||
| 239 | |||
| 240 | void IncrementSyncPoint(u32 syncpoint_id) { | ||
| 241 | auto& syncpoint = syncpoints.at(syncpoint_id); | ||
| 242 | syncpoint++; | ||
| 243 | std::lock_guard lock{sync_mutex}; | ||
| 244 | sync_cv.notify_all(); | ||
| 245 | auto& interrupt = syncpt_interrupts.at(syncpoint_id); | ||
| 246 | if (!interrupt.empty()) { | ||
| 247 | u32 value = syncpoint.load(); | ||
| 248 | auto it = interrupt.begin(); | ||
| 249 | while (it != interrupt.end()) { | ||
| 250 | if (value >= *it) { | ||
| 251 | TriggerCpuInterrupt(syncpoint_id, *it); | ||
| 252 | it = interrupt.erase(it); | ||
| 253 | continue; | ||
| 254 | } | ||
| 255 | it++; | ||
| 256 | } | ||
| 257 | } | ||
| 258 | } | ||
| 259 | |||
| 260 | [[nodiscard]] u32 GetSyncpointValue(u32 syncpoint_id) const { | ||
| 261 | return syncpoints.at(syncpoint_id).load(); | ||
| 262 | } | ||
| 263 | |||
| 264 | void RegisterSyncptInterrupt(u32 syncpoint_id, u32 value) { | ||
| 265 | std::lock_guard lock{sync_mutex}; | ||
| 266 | auto& interrupt = syncpt_interrupts.at(syncpoint_id); | ||
| 267 | bool contains = std::any_of(interrupt.begin(), interrupt.end(), | ||
| 268 | [value](u32 in_value) { return in_value == value; }); | ||
| 269 | if (contains) { | ||
| 270 | return; | ||
| 271 | } | ||
| 272 | interrupt.emplace_back(value); | ||
| 273 | } | ||
| 274 | |||
| 275 | [[nodiscard]] bool CancelSyncptInterrupt(u32 syncpoint_id, u32 value) { | ||
| 276 | std::lock_guard lock{sync_mutex}; | ||
| 277 | auto& interrupt = syncpt_interrupts.at(syncpoint_id); | ||
| 278 | const auto iter = | ||
| 279 | std::find_if(interrupt.begin(), interrupt.end(), | ||
| 280 | [value](u32 interrupt_value) { return value == interrupt_value; }); | ||
| 281 | |||
| 282 | if (iter == interrupt.end()) { | ||
| 283 | return false; | ||
| 284 | } | ||
| 285 | interrupt.erase(iter); | ||
| 286 | return true; | ||
| 287 | } | ||
| 288 | |||
| 289 | [[nodiscard]] u64 GetTicks() const { | ||
| 290 | // This values were reversed engineered by fincs from NVN | ||
| 291 | // The gpu clock is reported in units of 385/625 nanoseconds | ||
| 292 | constexpr u64 gpu_ticks_num = 384; | ||
| 293 | constexpr u64 gpu_ticks_den = 625; | ||
| 294 | |||
| 295 | u64 nanoseconds = system.CoreTiming().GetGlobalTimeNs().count(); | ||
| 296 | if (Settings::values.use_fast_gpu_time.GetValue()) { | ||
| 297 | nanoseconds /= 256; | ||
| 298 | } | ||
| 299 | const u64 nanoseconds_num = nanoseconds / gpu_ticks_den; | ||
| 300 | const u64 nanoseconds_rem = nanoseconds % gpu_ticks_den; | ||
| 301 | return nanoseconds_num * gpu_ticks_num + (nanoseconds_rem * gpu_ticks_num) / gpu_ticks_den; | ||
| 302 | } | ||
| 303 | |||
| 304 | [[nodiscard]] bool IsAsync() const { | ||
| 305 | return is_async; | ||
| 306 | } | ||
| 307 | |||
| 308 | [[nodiscard]] bool UseNvdec() const { | ||
| 309 | return use_nvdec; | ||
| 310 | } | ||
| 311 | |||
| 312 | void RendererFrameEndNotify() { | ||
| 313 | system.GetPerfStats().EndGameFrame(); | ||
| 314 | } | ||
| 315 | |||
| 316 | /// Performs any additional setup necessary in order to begin GPU emulation. | ||
| 317 | /// This can be used to launch any necessary threads and register any necessary | ||
| 318 | /// core timing events. | ||
| 319 | void Start() { | ||
| 320 | gpu_thread.StartThread(*renderer, renderer->Context(), *dma_pusher); | ||
| 321 | cpu_context = renderer->GetRenderWindow().CreateSharedContext(); | ||
| 322 | cpu_context->MakeCurrent(); | ||
| 323 | } | ||
| 324 | |||
| 325 | /// Obtain the CPU Context | ||
| 326 | void ObtainContext() { | ||
| 327 | cpu_context->MakeCurrent(); | ||
| 328 | } | ||
| 329 | |||
| 330 | /// Release the CPU Context | ||
| 331 | void ReleaseContext() { | ||
| 332 | cpu_context->DoneCurrent(); | ||
| 333 | } | ||
| 334 | |||
| 335 | /// Push GPU command entries to be processed | ||
| 336 | void PushGPUEntries(Tegra::CommandList&& entries) { | ||
| 337 | gpu_thread.SubmitList(std::move(entries)); | ||
| 338 | } | ||
| 339 | |||
| 340 | /// Push GPU command buffer entries to be processed | ||
| 341 | void PushCommandBuffer(Tegra::ChCommandHeaderList& entries) { | ||
| 342 | if (!use_nvdec) { | ||
| 343 | return; | ||
| 344 | } | ||
| 345 | |||
| 346 | if (!cdma_pusher) { | ||
| 347 | cdma_pusher = std::make_unique<Tegra::CDmaPusher>(gpu); | ||
| 348 | } | ||
| 349 | |||
| 350 | // SubmitCommandBuffer would make the nvdec operations async, this is not currently working | ||
| 351 | // TODO(ameerj): RE proper async nvdec operation | ||
| 352 | // gpu_thread.SubmitCommandBuffer(std::move(entries)); | ||
| 353 | |||
| 354 | cdma_pusher->ProcessEntries(std::move(entries)); | ||
| 355 | } | ||
| 356 | |||
| 357 | /// Frees the CDMAPusher instance to free up resources | ||
| 358 | void ClearCdmaInstance() { | ||
| 359 | cdma_pusher.reset(); | ||
| 360 | } | ||
| 361 | |||
| 362 | /// Swap buffers (render frame) | ||
| 363 | void SwapBuffers(const Tegra::FramebufferConfig* framebuffer) { | ||
| 364 | gpu_thread.SwapBuffers(framebuffer); | ||
| 365 | } | ||
| 366 | |||
| 367 | /// Notify rasterizer that any caches of the specified region should be flushed to Switch memory | ||
| 368 | void FlushRegion(VAddr addr, u64 size) { | ||
| 369 | gpu_thread.FlushRegion(addr, size); | ||
| 370 | } | ||
| 371 | |||
| 372 | /// Notify rasterizer that any caches of the specified region should be invalidated | ||
| 373 | void InvalidateRegion(VAddr addr, u64 size) { | ||
| 374 | gpu_thread.InvalidateRegion(addr, size); | ||
| 375 | } | ||
| 376 | |||
| 377 | /// Notify rasterizer that any caches of the specified region should be flushed and invalidated | ||
| 378 | void FlushAndInvalidateRegion(VAddr addr, u64 size) { | ||
| 379 | gpu_thread.FlushAndInvalidateRegion(addr, size); | ||
| 380 | } | ||
| 381 | |||
| 382 | void TriggerCpuInterrupt(u32 syncpoint_id, u32 value) const { | ||
| 383 | auto& interrupt_manager = system.InterruptManager(); | ||
| 384 | interrupt_manager.GPUInterruptSyncpt(syncpoint_id, value); | ||
| 385 | } | ||
| 386 | |||
| 387 | void ProcessBindMethod(const GPU::MethodCall& method_call) { | ||
| 388 | // Bind the current subchannel to the desired engine id. | ||
| 389 | LOG_DEBUG(HW_GPU, "Binding subchannel {} to engine {}", method_call.subchannel, | ||
| 390 | method_call.argument); | ||
| 391 | const auto engine_id = static_cast<EngineID>(method_call.argument); | ||
| 392 | bound_engines[method_call.subchannel] = static_cast<EngineID>(engine_id); | ||
| 393 | switch (engine_id) { | ||
| 394 | case EngineID::FERMI_TWOD_A: | ||
| 395 | dma_pusher->BindSubchannel(fermi_2d.get(), method_call.subchannel); | ||
| 396 | break; | ||
| 397 | case EngineID::MAXWELL_B: | ||
| 398 | dma_pusher->BindSubchannel(maxwell_3d.get(), method_call.subchannel); | ||
| 399 | break; | ||
| 400 | case EngineID::KEPLER_COMPUTE_B: | ||
| 401 | dma_pusher->BindSubchannel(kepler_compute.get(), method_call.subchannel); | ||
| 402 | break; | ||
| 403 | case EngineID::MAXWELL_DMA_COPY_A: | ||
| 404 | dma_pusher->BindSubchannel(maxwell_dma.get(), method_call.subchannel); | ||
| 405 | break; | ||
| 406 | case EngineID::KEPLER_INLINE_TO_MEMORY_B: | ||
| 407 | dma_pusher->BindSubchannel(kepler_memory.get(), method_call.subchannel); | ||
| 408 | break; | ||
| 409 | default: | ||
| 410 | UNIMPLEMENTED_MSG("Unimplemented engine {:04X}", engine_id); | ||
| 411 | } | ||
| 412 | } | ||
| 48 | 413 | ||
| 49 | memory_manager->BindRasterizer(rasterizer); | 414 | void ProcessFenceActionMethod() { |
| 50 | maxwell_3d->BindRasterizer(rasterizer); | 415 | switch (regs.fence_action.op) { |
| 51 | fermi_2d->BindRasterizer(rasterizer); | 416 | case GPU::FenceOperation::Acquire: |
| 52 | kepler_compute->BindRasterizer(rasterizer); | 417 | WaitFence(regs.fence_action.syncpoint_id, regs.fence_value); |
| 53 | maxwell_dma->BindRasterizer(rasterizer); | 418 | break; |
| 419 | case GPU::FenceOperation::Increment: | ||
| 420 | IncrementSyncPoint(regs.fence_action.syncpoint_id); | ||
| 421 | break; | ||
| 422 | default: | ||
| 423 | UNIMPLEMENTED_MSG("Unimplemented operation {}", regs.fence_action.op.Value()); | ||
| 424 | } | ||
| 425 | } | ||
| 426 | |||
| 427 | void ProcessWaitForInterruptMethod() { | ||
| 428 | // TODO(bunnei) ImplementMe | ||
| 429 | LOG_WARNING(HW_GPU, "(STUBBED) called"); | ||
| 430 | } | ||
| 431 | |||
| 432 | void ProcessSemaphoreTriggerMethod() { | ||
| 433 | const auto semaphoreOperationMask = 0xF; | ||
| 434 | const auto op = | ||
| 435 | static_cast<GpuSemaphoreOperation>(regs.semaphore_trigger & semaphoreOperationMask); | ||
| 436 | if (op == GpuSemaphoreOperation::WriteLong) { | ||
| 437 | struct Block { | ||
| 438 | u32 sequence; | ||
| 439 | u32 zeros = 0; | ||
| 440 | u64 timestamp; | ||
| 441 | }; | ||
| 442 | |||
| 443 | Block block{}; | ||
| 444 | block.sequence = regs.semaphore_sequence; | ||
| 445 | // TODO(Kmather73): Generate a real GPU timestamp and write it here instead of | ||
| 446 | // CoreTiming | ||
| 447 | block.timestamp = GetTicks(); | ||
| 448 | memory_manager->WriteBlock(regs.semaphore_address.SemaphoreAddress(), &block, | ||
| 449 | sizeof(block)); | ||
| 450 | } else { | ||
| 451 | const u32 word{memory_manager->Read<u32>(regs.semaphore_address.SemaphoreAddress())}; | ||
| 452 | if ((op == GpuSemaphoreOperation::AcquireEqual && word == regs.semaphore_sequence) || | ||
| 453 | (op == GpuSemaphoreOperation::AcquireGequal && | ||
| 454 | static_cast<s32>(word - regs.semaphore_sequence) > 0) || | ||
| 455 | (op == GpuSemaphoreOperation::AcquireMask && (word & regs.semaphore_sequence))) { | ||
| 456 | // Nothing to do in this case | ||
| 457 | } else { | ||
| 458 | regs.acquire_source = true; | ||
| 459 | regs.acquire_value = regs.semaphore_sequence; | ||
| 460 | if (op == GpuSemaphoreOperation::AcquireEqual) { | ||
| 461 | regs.acquire_active = true; | ||
| 462 | regs.acquire_mode = false; | ||
| 463 | } else if (op == GpuSemaphoreOperation::AcquireGequal) { | ||
| 464 | regs.acquire_active = true; | ||
| 465 | regs.acquire_mode = true; | ||
| 466 | } else if (op == GpuSemaphoreOperation::AcquireMask) { | ||
| 467 | // TODO(kemathe) The acquire mask operation waits for a value that, ANDed with | ||
| 468 | // semaphore_sequence, gives a non-0 result | ||
| 469 | LOG_ERROR(HW_GPU, "Invalid semaphore operation AcquireMask not implemented"); | ||
| 470 | } else { | ||
| 471 | LOG_ERROR(HW_GPU, "Invalid semaphore operation"); | ||
| 472 | } | ||
| 473 | } | ||
| 474 | } | ||
| 475 | } | ||
| 476 | |||
| 477 | void ProcessSemaphoreRelease() { | ||
| 478 | memory_manager->Write<u32>(regs.semaphore_address.SemaphoreAddress(), | ||
| 479 | regs.semaphore_release); | ||
| 480 | } | ||
| 481 | |||
| 482 | void ProcessSemaphoreAcquire() { | ||
| 483 | const u32 word = memory_manager->Read<u32>(regs.semaphore_address.SemaphoreAddress()); | ||
| 484 | const auto value = regs.semaphore_acquire; | ||
| 485 | if (word != value) { | ||
| 486 | regs.acquire_active = true; | ||
| 487 | regs.acquire_value = value; | ||
| 488 | // TODO(kemathe73) figure out how to do the acquire_timeout | ||
| 489 | regs.acquire_mode = false; | ||
| 490 | regs.acquire_source = false; | ||
| 491 | } | ||
| 492 | } | ||
| 493 | |||
| 494 | /// Calls a GPU puller method. | ||
| 495 | void CallPullerMethod(const GPU::MethodCall& method_call) { | ||
| 496 | regs.reg_array[method_call.method] = method_call.argument; | ||
| 497 | const auto method = static_cast<BufferMethods>(method_call.method); | ||
| 498 | |||
| 499 | switch (method) { | ||
| 500 | case BufferMethods::BindObject: { | ||
| 501 | ProcessBindMethod(method_call); | ||
| 502 | break; | ||
| 503 | } | ||
| 504 | case BufferMethods::Nop: | ||
| 505 | case BufferMethods::SemaphoreAddressHigh: | ||
| 506 | case BufferMethods::SemaphoreAddressLow: | ||
| 507 | case BufferMethods::SemaphoreSequence: | ||
| 508 | case BufferMethods::UnkCacheFlush: | ||
| 509 | case BufferMethods::WrcacheFlush: | ||
| 510 | case BufferMethods::FenceValue: | ||
| 511 | break; | ||
| 512 | case BufferMethods::RefCnt: | ||
| 513 | rasterizer->SignalReference(); | ||
| 514 | break; | ||
| 515 | case BufferMethods::FenceAction: | ||
| 516 | ProcessFenceActionMethod(); | ||
| 517 | break; | ||
| 518 | case BufferMethods::WaitForInterrupt: | ||
| 519 | ProcessWaitForInterruptMethod(); | ||
| 520 | break; | ||
| 521 | case BufferMethods::SemaphoreTrigger: { | ||
| 522 | ProcessSemaphoreTriggerMethod(); | ||
| 523 | break; | ||
| 524 | } | ||
| 525 | case BufferMethods::NotifyIntr: { | ||
| 526 | // TODO(Kmather73): Research and implement this method. | ||
| 527 | LOG_ERROR(HW_GPU, "Special puller engine method NotifyIntr not implemented"); | ||
| 528 | break; | ||
| 529 | } | ||
| 530 | case BufferMethods::Unk28: { | ||
| 531 | // TODO(Kmather73): Research and implement this method. | ||
| 532 | LOG_ERROR(HW_GPU, "Special puller engine method Unk28 not implemented"); | ||
| 533 | break; | ||
| 534 | } | ||
| 535 | case BufferMethods::SemaphoreAcquire: { | ||
| 536 | ProcessSemaphoreAcquire(); | ||
| 537 | break; | ||
| 538 | } | ||
| 539 | case BufferMethods::SemaphoreRelease: { | ||
| 540 | ProcessSemaphoreRelease(); | ||
| 541 | break; | ||
| 542 | } | ||
| 543 | case BufferMethods::Yield: { | ||
| 544 | // TODO(Kmather73): Research and implement this method. | ||
| 545 | LOG_ERROR(HW_GPU, "Special puller engine method Yield not implemented"); | ||
| 546 | break; | ||
| 547 | } | ||
| 548 | default: | ||
| 549 | LOG_ERROR(HW_GPU, "Special puller engine method {:X} not implemented", method); | ||
| 550 | break; | ||
| 551 | } | ||
| 552 | } | ||
| 553 | |||
| 554 | /// Calls a GPU engine method. | ||
| 555 | void CallEngineMethod(const GPU::MethodCall& method_call) { | ||
| 556 | const EngineID engine = bound_engines[method_call.subchannel]; | ||
| 557 | |||
| 558 | switch (engine) { | ||
| 559 | case EngineID::FERMI_TWOD_A: | ||
| 560 | fermi_2d->CallMethod(method_call.method, method_call.argument, | ||
| 561 | method_call.IsLastCall()); | ||
| 562 | break; | ||
| 563 | case EngineID::MAXWELL_B: | ||
| 564 | maxwell_3d->CallMethod(method_call.method, method_call.argument, | ||
| 565 | method_call.IsLastCall()); | ||
| 566 | break; | ||
| 567 | case EngineID::KEPLER_COMPUTE_B: | ||
| 568 | kepler_compute->CallMethod(method_call.method, method_call.argument, | ||
| 569 | method_call.IsLastCall()); | ||
| 570 | break; | ||
| 571 | case EngineID::MAXWELL_DMA_COPY_A: | ||
| 572 | maxwell_dma->CallMethod(method_call.method, method_call.argument, | ||
| 573 | method_call.IsLastCall()); | ||
| 574 | break; | ||
| 575 | case EngineID::KEPLER_INLINE_TO_MEMORY_B: | ||
| 576 | kepler_memory->CallMethod(method_call.method, method_call.argument, | ||
| 577 | method_call.IsLastCall()); | ||
| 578 | break; | ||
| 579 | default: | ||
| 580 | UNIMPLEMENTED_MSG("Unimplemented engine"); | ||
| 581 | } | ||
| 582 | } | ||
| 583 | |||
| 584 | /// Calls a GPU engine multivalue method. | ||
| 585 | void CallEngineMultiMethod(u32 method, u32 subchannel, const u32* base_start, u32 amount, | ||
| 586 | u32 methods_pending) { | ||
| 587 | const EngineID engine = bound_engines[subchannel]; | ||
| 588 | |||
| 589 | switch (engine) { | ||
| 590 | case EngineID::FERMI_TWOD_A: | ||
| 591 | fermi_2d->CallMultiMethod(method, base_start, amount, methods_pending); | ||
| 592 | break; | ||
| 593 | case EngineID::MAXWELL_B: | ||
| 594 | maxwell_3d->CallMultiMethod(method, base_start, amount, methods_pending); | ||
| 595 | break; | ||
| 596 | case EngineID::KEPLER_COMPUTE_B: | ||
| 597 | kepler_compute->CallMultiMethod(method, base_start, amount, methods_pending); | ||
| 598 | break; | ||
| 599 | case EngineID::MAXWELL_DMA_COPY_A: | ||
| 600 | maxwell_dma->CallMultiMethod(method, base_start, amount, methods_pending); | ||
| 601 | break; | ||
| 602 | case EngineID::KEPLER_INLINE_TO_MEMORY_B: | ||
| 603 | kepler_memory->CallMultiMethod(method, base_start, amount, methods_pending); | ||
| 604 | break; | ||
| 605 | default: | ||
| 606 | UNIMPLEMENTED_MSG("Unimplemented engine"); | ||
| 607 | } | ||
| 608 | } | ||
| 609 | |||
| 610 | /// Determines where the method should be executed. | ||
| 611 | [[nodiscard]] bool ExecuteMethodOnEngine(u32 method) { | ||
| 612 | const auto buffer_method = static_cast<BufferMethods>(method); | ||
| 613 | return buffer_method >= BufferMethods::NonPullerMethods; | ||
| 614 | } | ||
| 615 | |||
| 616 | struct Regs { | ||
| 617 | static constexpr size_t NUM_REGS = 0x40; | ||
| 618 | |||
| 619 | union { | ||
| 620 | struct { | ||
| 621 | INSERT_PADDING_WORDS_NOINIT(0x4); | ||
| 622 | struct { | ||
| 623 | u32 address_high; | ||
| 624 | u32 address_low; | ||
| 625 | |||
| 626 | [[nodiscard]] GPUVAddr SemaphoreAddress() const { | ||
| 627 | return static_cast<GPUVAddr>((static_cast<GPUVAddr>(address_high) << 32) | | ||
| 628 | address_low); | ||
| 629 | } | ||
| 630 | } semaphore_address; | ||
| 631 | |||
| 632 | u32 semaphore_sequence; | ||
| 633 | u32 semaphore_trigger; | ||
| 634 | INSERT_PADDING_WORDS_NOINIT(0xC); | ||
| 635 | |||
| 636 | // The pusher and the puller share the reference counter, the pusher only has read | ||
| 637 | // access | ||
| 638 | u32 reference_count; | ||
| 639 | INSERT_PADDING_WORDS_NOINIT(0x5); | ||
| 640 | |||
| 641 | u32 semaphore_acquire; | ||
| 642 | u32 semaphore_release; | ||
| 643 | u32 fence_value; | ||
| 644 | GPU::FenceAction fence_action; | ||
| 645 | INSERT_PADDING_WORDS_NOINIT(0xE2); | ||
| 646 | |||
| 647 | // Puller state | ||
| 648 | u32 acquire_mode; | ||
| 649 | u32 acquire_source; | ||
| 650 | u32 acquire_active; | ||
| 651 | u32 acquire_timeout; | ||
| 652 | u32 acquire_value; | ||
| 653 | }; | ||
| 654 | std::array<u32, NUM_REGS> reg_array; | ||
| 655 | }; | ||
| 656 | } regs{}; | ||
| 657 | |||
| 658 | GPU& gpu; | ||
| 659 | Core::System& system; | ||
| 660 | std::unique_ptr<Tegra::MemoryManager> memory_manager; | ||
| 661 | std::unique_ptr<Tegra::DmaPusher> dma_pusher; | ||
| 662 | std::unique_ptr<Tegra::CDmaPusher> cdma_pusher; | ||
| 663 | std::unique_ptr<VideoCore::RendererBase> renderer; | ||
| 664 | VideoCore::RasterizerInterface* rasterizer = nullptr; | ||
| 665 | const bool use_nvdec; | ||
| 666 | |||
| 667 | /// Mapping of command subchannels to their bound engine ids | ||
| 668 | std::array<EngineID, 8> bound_engines{}; | ||
| 669 | /// 3D engine | ||
| 670 | std::unique_ptr<Engines::Maxwell3D> maxwell_3d; | ||
| 671 | /// 2D engine | ||
| 672 | std::unique_ptr<Engines::Fermi2D> fermi_2d; | ||
| 673 | /// Compute engine | ||
| 674 | std::unique_ptr<Engines::KeplerCompute> kepler_compute; | ||
| 675 | /// DMA engine | ||
| 676 | std::unique_ptr<Engines::MaxwellDMA> maxwell_dma; | ||
| 677 | /// Inline memory engine | ||
| 678 | std::unique_ptr<Engines::KeplerMemory> kepler_memory; | ||
| 679 | /// Shader build notifier | ||
| 680 | std::unique_ptr<VideoCore::ShaderNotify> shader_notify; | ||
| 681 | /// When true, we are about to shut down emulation session, so terminate outstanding tasks | ||
| 682 | std::atomic_bool shutting_down{}; | ||
| 683 | |||
| 684 | std::array<std::atomic<u32>, Service::Nvidia::MaxSyncPoints> syncpoints{}; | ||
| 685 | |||
| 686 | std::array<std::list<u32>, Service::Nvidia::MaxSyncPoints> syncpt_interrupts; | ||
| 687 | |||
| 688 | std::mutex sync_mutex; | ||
| 689 | std::mutex device_mutex; | ||
| 690 | |||
| 691 | std::condition_variable sync_cv; | ||
| 692 | |||
| 693 | struct FlushRequest { | ||
| 694 | explicit FlushRequest(u64 fence_, VAddr addr_, std::size_t size_) | ||
| 695 | : fence{fence_}, addr{addr_}, size{size_} {} | ||
| 696 | u64 fence; | ||
| 697 | VAddr addr; | ||
| 698 | std::size_t size; | ||
| 699 | }; | ||
| 700 | |||
| 701 | std::list<FlushRequest> flush_requests; | ||
| 702 | std::atomic<u64> current_flush_fence{}; | ||
| 703 | u64 last_flush_fence{}; | ||
| 704 | std::mutex flush_request_mutex; | ||
| 705 | |||
| 706 | const bool is_async; | ||
| 707 | |||
| 708 | VideoCommon::GPUThread::ThreadManager gpu_thread; | ||
| 709 | std::unique_ptr<Core::Frontend::GraphicsContext> cpu_context; | ||
| 710 | |||
| 711 | #define ASSERT_REG_POSITION(field_name, position) \ | ||
| 712 | static_assert(offsetof(Regs, field_name) == position * 4, \ | ||
| 713 | "Field " #field_name " has invalid position") | ||
| 714 | |||
| 715 | ASSERT_REG_POSITION(semaphore_address, 0x4); | ||
| 716 | ASSERT_REG_POSITION(semaphore_sequence, 0x6); | ||
| 717 | ASSERT_REG_POSITION(semaphore_trigger, 0x7); | ||
| 718 | ASSERT_REG_POSITION(reference_count, 0x14); | ||
| 719 | ASSERT_REG_POSITION(semaphore_acquire, 0x1A); | ||
| 720 | ASSERT_REG_POSITION(semaphore_release, 0x1B); | ||
| 721 | ASSERT_REG_POSITION(fence_value, 0x1C); | ||
| 722 | ASSERT_REG_POSITION(fence_action, 0x1D); | ||
| 723 | |||
| 724 | ASSERT_REG_POSITION(acquire_mode, 0x100); | ||
| 725 | ASSERT_REG_POSITION(acquire_source, 0x101); | ||
| 726 | ASSERT_REG_POSITION(acquire_active, 0x102); | ||
| 727 | ASSERT_REG_POSITION(acquire_timeout, 0x103); | ||
| 728 | ASSERT_REG_POSITION(acquire_value, 0x104); | ||
| 729 | |||
| 730 | #undef ASSERT_REG_POSITION | ||
| 731 | |||
| 732 | enum class GpuSemaphoreOperation { | ||
| 733 | AcquireEqual = 0x1, | ||
| 734 | WriteLong = 0x2, | ||
| 735 | AcquireGequal = 0x4, | ||
| 736 | AcquireMask = 0x8, | ||
| 737 | }; | ||
| 738 | }; | ||
| 739 | |||
| 740 | GPU::GPU(Core::System& system, bool is_async, bool use_nvdec) | ||
| 741 | : impl{std::make_unique<Impl>(*this, system, is_async, use_nvdec)} {} | ||
| 742 | |||
| 743 | GPU::~GPU() = default; | ||
| 744 | |||
| 745 | void GPU::BindRenderer(std::unique_ptr<VideoCore::RendererBase> renderer) { | ||
| 746 | impl->BindRenderer(std::move(renderer)); | ||
| 54 | } | 747 | } |
| 55 | 748 | ||
| 56 | Engines::Maxwell3D& GPU::Maxwell3D() { | 749 | void GPU::CallMethod(const MethodCall& method_call) { |
| 57 | return *maxwell_3d; | 750 | impl->CallMethod(method_call); |
| 58 | } | 751 | } |
| 59 | 752 | ||
| 60 | const Engines::Maxwell3D& GPU::Maxwell3D() const { | 753 | void GPU::CallMultiMethod(u32 method, u32 subchannel, const u32* base_start, u32 amount, |
| 61 | return *maxwell_3d; | 754 | u32 methods_pending) { |
| 755 | impl->CallMultiMethod(method, subchannel, base_start, amount, methods_pending); | ||
| 62 | } | 756 | } |
| 63 | 757 | ||
| 64 | Engines::KeplerCompute& GPU::KeplerCompute() { | 758 | void GPU::FlushCommands() { |
| 65 | return *kepler_compute; | 759 | impl->FlushCommands(); |
| 66 | } | 760 | } |
| 67 | 761 | ||
| 68 | const Engines::KeplerCompute& GPU::KeplerCompute() const { | 762 | void GPU::SyncGuestHost() { |
| 69 | return *kepler_compute; | 763 | impl->SyncGuestHost(); |
| 70 | } | 764 | } |
| 71 | 765 | ||
| 72 | MemoryManager& GPU::MemoryManager() { | 766 | void GPU::OnCommandListEnd() { |
| 73 | return *memory_manager; | 767 | impl->OnCommandListEnd(); |
| 74 | } | 768 | } |
| 75 | 769 | ||
| 76 | const MemoryManager& GPU::MemoryManager() const { | 770 | u64 GPU::RequestFlush(VAddr addr, std::size_t size) { |
| 77 | return *memory_manager; | 771 | return impl->RequestFlush(addr, size); |
| 78 | } | 772 | } |
| 79 | 773 | ||
| 80 | DmaPusher& GPU::DmaPusher() { | 774 | u64 GPU::CurrentFlushRequestFence() const { |
| 81 | return *dma_pusher; | 775 | return impl->CurrentFlushRequestFence(); |
| 82 | } | 776 | } |
| 83 | 777 | ||
| 84 | Tegra::CDmaPusher& GPU::CDmaPusher() { | 778 | void GPU::TickWork() { |
| 85 | return *cdma_pusher; | 779 | impl->TickWork(); |
| 86 | } | 780 | } |
| 87 | 781 | ||
| 88 | const DmaPusher& GPU::DmaPusher() const { | 782 | Engines::Maxwell3D& GPU::Maxwell3D() { |
| 89 | return *dma_pusher; | 783 | return impl->Maxwell3D(); |
| 90 | } | 784 | } |
| 91 | 785 | ||
| 92 | const Tegra::CDmaPusher& GPU::CDmaPusher() const { | 786 | const Engines::Maxwell3D& GPU::Maxwell3D() const { |
| 93 | return *cdma_pusher; | 787 | return impl->Maxwell3D(); |
| 94 | } | 788 | } |
| 95 | 789 | ||
| 96 | void GPU::WaitFence(u32 syncpoint_id, u32 value) { | 790 | Engines::KeplerCompute& GPU::KeplerCompute() { |
| 97 | // Synced GPU, is always in sync | 791 | return impl->KeplerCompute(); |
| 98 | if (!is_async) { | ||
| 99 | return; | ||
| 100 | } | ||
| 101 | if (syncpoint_id == UINT32_MAX) { | ||
| 102 | // TODO: Research what this does. | ||
| 103 | LOG_ERROR(HW_GPU, "Waiting for syncpoint -1 not implemented"); | ||
| 104 | return; | ||
| 105 | } | ||
| 106 | MICROPROFILE_SCOPE(GPU_wait); | ||
| 107 | std::unique_lock lock{sync_mutex}; | ||
| 108 | sync_cv.wait(lock, [=, this] { | ||
| 109 | if (shutting_down.load(std::memory_order_relaxed)) { | ||
| 110 | // We're shutting down, ensure no threads continue to wait for the next syncpoint | ||
| 111 | return true; | ||
| 112 | } | ||
| 113 | return syncpoints.at(syncpoint_id).load() >= value; | ||
| 114 | }); | ||
| 115 | } | ||
| 116 | |||
| 117 | void GPU::IncrementSyncPoint(const u32 syncpoint_id) { | ||
| 118 | auto& syncpoint = syncpoints.at(syncpoint_id); | ||
| 119 | syncpoint++; | ||
| 120 | std::lock_guard lock{sync_mutex}; | ||
| 121 | sync_cv.notify_all(); | ||
| 122 | auto& interrupt = syncpt_interrupts.at(syncpoint_id); | ||
| 123 | if (!interrupt.empty()) { | ||
| 124 | u32 value = syncpoint.load(); | ||
| 125 | auto it = interrupt.begin(); | ||
| 126 | while (it != interrupt.end()) { | ||
| 127 | if (value >= *it) { | ||
| 128 | TriggerCpuInterrupt(syncpoint_id, *it); | ||
| 129 | it = interrupt.erase(it); | ||
| 130 | continue; | ||
| 131 | } | ||
| 132 | it++; | ||
| 133 | } | ||
| 134 | } | ||
| 135 | } | 792 | } |
| 136 | 793 | ||
| 137 | u32 GPU::GetSyncpointValue(const u32 syncpoint_id) const { | 794 | const Engines::KeplerCompute& GPU::KeplerCompute() const { |
| 138 | return syncpoints.at(syncpoint_id).load(); | 795 | return impl->KeplerCompute(); |
| 139 | } | 796 | } |
| 140 | 797 | ||
| 141 | void GPU::RegisterSyncptInterrupt(const u32 syncpoint_id, const u32 value) { | 798 | Tegra::MemoryManager& GPU::MemoryManager() { |
| 142 | auto& interrupt = syncpt_interrupts.at(syncpoint_id); | 799 | return impl->MemoryManager(); |
| 143 | bool contains = std::any_of(interrupt.begin(), interrupt.end(), | ||
| 144 | [value](u32 in_value) { return in_value == value; }); | ||
| 145 | if (contains) { | ||
| 146 | return; | ||
| 147 | } | ||
| 148 | interrupt.emplace_back(value); | ||
| 149 | } | 800 | } |
| 150 | 801 | ||
| 151 | bool GPU::CancelSyncptInterrupt(const u32 syncpoint_id, const u32 value) { | 802 | const Tegra::MemoryManager& GPU::MemoryManager() const { |
| 152 | std::lock_guard lock{sync_mutex}; | 803 | return impl->MemoryManager(); |
| 153 | auto& interrupt = syncpt_interrupts.at(syncpoint_id); | 804 | } |
| 154 | const auto iter = | ||
| 155 | std::find_if(interrupt.begin(), interrupt.end(), | ||
| 156 | [value](u32 interrupt_value) { return value == interrupt_value; }); | ||
| 157 | 805 | ||
| 158 | if (iter == interrupt.end()) { | 806 | Tegra::DmaPusher& GPU::DmaPusher() { |
| 159 | return false; | 807 | return impl->DmaPusher(); |
| 160 | } | ||
| 161 | interrupt.erase(iter); | ||
| 162 | return true; | ||
| 163 | } | 808 | } |
| 164 | 809 | ||
| 165 | u64 GPU::RequestFlush(VAddr addr, std::size_t size) { | 810 | const Tegra::DmaPusher& GPU::DmaPusher() const { |
| 166 | std::unique_lock lck{flush_request_mutex}; | 811 | return impl->DmaPusher(); |
| 167 | const u64 fence = ++last_flush_fence; | ||
| 168 | flush_requests.emplace_back(fence, addr, size); | ||
| 169 | return fence; | ||
| 170 | } | 812 | } |
| 171 | 813 | ||
| 172 | void GPU::TickWork() { | 814 | Tegra::CDmaPusher& GPU::CDmaPusher() { |
| 173 | std::unique_lock lck{flush_request_mutex}; | 815 | return impl->CDmaPusher(); |
| 174 | while (!flush_requests.empty()) { | ||
| 175 | auto& request = flush_requests.front(); | ||
| 176 | const u64 fence = request.fence; | ||
| 177 | const VAddr addr = request.addr; | ||
| 178 | const std::size_t size = request.size; | ||
| 179 | flush_requests.pop_front(); | ||
| 180 | flush_request_mutex.unlock(); | ||
| 181 | rasterizer->FlushRegion(addr, size); | ||
| 182 | current_flush_fence.store(fence); | ||
| 183 | flush_request_mutex.lock(); | ||
| 184 | } | ||
| 185 | } | 816 | } |
| 186 | 817 | ||
| 187 | u64 GPU::GetTicks() const { | 818 | const Tegra::CDmaPusher& GPU::CDmaPusher() const { |
| 188 | // This values were reversed engineered by fincs from NVN | 819 | return impl->CDmaPusher(); |
| 189 | // The gpu clock is reported in units of 385/625 nanoseconds | 820 | } |
| 190 | constexpr u64 gpu_ticks_num = 384; | ||
| 191 | constexpr u64 gpu_ticks_den = 625; | ||
| 192 | 821 | ||
| 193 | u64 nanoseconds = system.CoreTiming().GetGlobalTimeNs().count(); | 822 | VideoCore::RendererBase& GPU::Renderer() { |
| 194 | if (Settings::values.use_fast_gpu_time.GetValue()) { | 823 | return impl->Renderer(); |
| 195 | nanoseconds /= 256; | ||
| 196 | } | ||
| 197 | const u64 nanoseconds_num = nanoseconds / gpu_ticks_den; | ||
| 198 | const u64 nanoseconds_rem = nanoseconds % gpu_ticks_den; | ||
| 199 | return nanoseconds_num * gpu_ticks_num + (nanoseconds_rem * gpu_ticks_num) / gpu_ticks_den; | ||
| 200 | } | 824 | } |
| 201 | 825 | ||
| 202 | void GPU::RendererFrameEndNotify() { | 826 | const VideoCore::RendererBase& GPU::Renderer() const { |
| 203 | system.GetPerfStats().EndGameFrame(); | 827 | return impl->Renderer(); |
| 204 | } | 828 | } |
| 205 | 829 | ||
| 206 | void GPU::FlushCommands() { | 830 | VideoCore::ShaderNotify& GPU::ShaderNotify() { |
| 207 | rasterizer->FlushCommands(); | 831 | return impl->ShaderNotify(); |
| 208 | } | 832 | } |
| 209 | 833 | ||
| 210 | void GPU::SyncGuestHost() { | 834 | const VideoCore::ShaderNotify& GPU::ShaderNotify() const { |
| 211 | rasterizer->SyncGuestHost(); | 835 | return impl->ShaderNotify(); |
| 212 | } | 836 | } |
| 213 | 837 | ||
| 214 | enum class GpuSemaphoreOperation { | 838 | void GPU::WaitFence(u32 syncpoint_id, u32 value) { |
| 215 | AcquireEqual = 0x1, | 839 | impl->WaitFence(syncpoint_id, value); |
| 216 | WriteLong = 0x2, | 840 | } |
| 217 | AcquireGequal = 0x4, | ||
| 218 | AcquireMask = 0x8, | ||
| 219 | }; | ||
| 220 | 841 | ||
| 221 | void GPU::CallMethod(const MethodCall& method_call) { | 842 | void GPU::IncrementSyncPoint(u32 syncpoint_id) { |
| 222 | LOG_TRACE(HW_GPU, "Processing method {:08X} on subchannel {}", method_call.method, | 843 | impl->IncrementSyncPoint(syncpoint_id); |
| 223 | method_call.subchannel); | 844 | } |
| 224 | 845 | ||
| 225 | ASSERT(method_call.subchannel < bound_engines.size()); | 846 | u32 GPU::GetSyncpointValue(u32 syncpoint_id) const { |
| 847 | return impl->GetSyncpointValue(syncpoint_id); | ||
| 848 | } | ||
| 226 | 849 | ||
| 227 | if (ExecuteMethodOnEngine(method_call.method)) { | 850 | void GPU::RegisterSyncptInterrupt(u32 syncpoint_id, u32 value) { |
| 228 | CallEngineMethod(method_call); | 851 | impl->RegisterSyncptInterrupt(syncpoint_id, value); |
| 229 | } else { | ||
| 230 | CallPullerMethod(method_call); | ||
| 231 | } | ||
| 232 | } | 852 | } |
| 233 | 853 | ||
| 234 | void GPU::CallMultiMethod(u32 method, u32 subchannel, const u32* base_start, u32 amount, | 854 | bool GPU::CancelSyncptInterrupt(u32 syncpoint_id, u32 value) { |
| 235 | u32 methods_pending) { | 855 | return impl->CancelSyncptInterrupt(syncpoint_id, value); |
| 236 | LOG_TRACE(HW_GPU, "Processing method {:08X} on subchannel {}", method, subchannel); | ||
| 237 | |||
| 238 | ASSERT(subchannel < bound_engines.size()); | ||
| 239 | |||
| 240 | if (ExecuteMethodOnEngine(method)) { | ||
| 241 | CallEngineMultiMethod(method, subchannel, base_start, amount, methods_pending); | ||
| 242 | } else { | ||
| 243 | for (std::size_t i = 0; i < amount; i++) { | ||
| 244 | CallPullerMethod(MethodCall{ | ||
| 245 | method, | ||
| 246 | base_start[i], | ||
| 247 | subchannel, | ||
| 248 | methods_pending - static_cast<u32>(i), | ||
| 249 | }); | ||
| 250 | } | ||
| 251 | } | ||
| 252 | } | 856 | } |
| 253 | 857 | ||
| 254 | bool GPU::ExecuteMethodOnEngine(u32 method) { | 858 | u64 GPU::GetTicks() const { |
| 255 | const auto buffer_method = static_cast<BufferMethods>(method); | 859 | return impl->GetTicks(); |
| 256 | return buffer_method >= BufferMethods::NonPullerMethods; | 860 | } |
| 257 | } | ||
| 258 | |||
| 259 | void GPU::CallPullerMethod(const MethodCall& method_call) { | ||
| 260 | regs.reg_array[method_call.method] = method_call.argument; | ||
| 261 | const auto method = static_cast<BufferMethods>(method_call.method); | ||
| 262 | |||
| 263 | switch (method) { | ||
| 264 | case BufferMethods::BindObject: { | ||
| 265 | ProcessBindMethod(method_call); | ||
| 266 | break; | ||
| 267 | } | ||
| 268 | case BufferMethods::Nop: | ||
| 269 | case BufferMethods::SemaphoreAddressHigh: | ||
| 270 | case BufferMethods::SemaphoreAddressLow: | ||
| 271 | case BufferMethods::SemaphoreSequence: | ||
| 272 | case BufferMethods::UnkCacheFlush: | ||
| 273 | case BufferMethods::WrcacheFlush: | ||
| 274 | case BufferMethods::FenceValue: | ||
| 275 | break; | ||
| 276 | case BufferMethods::RefCnt: | ||
| 277 | rasterizer->SignalReference(); | ||
| 278 | break; | ||
| 279 | case BufferMethods::FenceAction: | ||
| 280 | ProcessFenceActionMethod(); | ||
| 281 | break; | ||
| 282 | case BufferMethods::WaitForInterrupt: | ||
| 283 | ProcessWaitForInterruptMethod(); | ||
| 284 | break; | ||
| 285 | case BufferMethods::SemaphoreTrigger: { | ||
| 286 | ProcessSemaphoreTriggerMethod(); | ||
| 287 | break; | ||
| 288 | } | ||
| 289 | case BufferMethods::NotifyIntr: { | ||
| 290 | // TODO(Kmather73): Research and implement this method. | ||
| 291 | LOG_ERROR(HW_GPU, "Special puller engine method NotifyIntr not implemented"); | ||
| 292 | break; | ||
| 293 | } | ||
| 294 | case BufferMethods::Unk28: { | ||
| 295 | // TODO(Kmather73): Research and implement this method. | ||
| 296 | LOG_ERROR(HW_GPU, "Special puller engine method Unk28 not implemented"); | ||
| 297 | break; | ||
| 298 | } | ||
| 299 | case BufferMethods::SemaphoreAcquire: { | ||
| 300 | ProcessSemaphoreAcquire(); | ||
| 301 | break; | ||
| 302 | } | ||
| 303 | case BufferMethods::SemaphoreRelease: { | ||
| 304 | ProcessSemaphoreRelease(); | ||
| 305 | break; | ||
| 306 | } | ||
| 307 | case BufferMethods::Yield: { | ||
| 308 | // TODO(Kmather73): Research and implement this method. | ||
| 309 | LOG_ERROR(HW_GPU, "Special puller engine method Yield not implemented"); | ||
| 310 | break; | ||
| 311 | } | ||
| 312 | default: | ||
| 313 | LOG_ERROR(HW_GPU, "Special puller engine method {:X} not implemented", method); | ||
| 314 | break; | ||
| 315 | } | ||
| 316 | } | ||
| 317 | |||
| 318 | void GPU::CallEngineMethod(const MethodCall& method_call) { | ||
| 319 | const EngineID engine = bound_engines[method_call.subchannel]; | ||
| 320 | |||
| 321 | switch (engine) { | ||
| 322 | case EngineID::FERMI_TWOD_A: | ||
| 323 | fermi_2d->CallMethod(method_call.method, method_call.argument, method_call.IsLastCall()); | ||
| 324 | break; | ||
| 325 | case EngineID::MAXWELL_B: | ||
| 326 | maxwell_3d->CallMethod(method_call.method, method_call.argument, method_call.IsLastCall()); | ||
| 327 | break; | ||
| 328 | case EngineID::KEPLER_COMPUTE_B: | ||
| 329 | kepler_compute->CallMethod(method_call.method, method_call.argument, | ||
| 330 | method_call.IsLastCall()); | ||
| 331 | break; | ||
| 332 | case EngineID::MAXWELL_DMA_COPY_A: | ||
| 333 | maxwell_dma->CallMethod(method_call.method, method_call.argument, method_call.IsLastCall()); | ||
| 334 | break; | ||
| 335 | case EngineID::KEPLER_INLINE_TO_MEMORY_B: | ||
| 336 | kepler_memory->CallMethod(method_call.method, method_call.argument, | ||
| 337 | method_call.IsLastCall()); | ||
| 338 | break; | ||
| 339 | default: | ||
| 340 | UNIMPLEMENTED_MSG("Unimplemented engine"); | ||
| 341 | } | ||
| 342 | } | ||
| 343 | |||
| 344 | void GPU::CallEngineMultiMethod(u32 method, u32 subchannel, const u32* base_start, u32 amount, | ||
| 345 | u32 methods_pending) { | ||
| 346 | const EngineID engine = bound_engines[subchannel]; | ||
| 347 | |||
| 348 | switch (engine) { | ||
| 349 | case EngineID::FERMI_TWOD_A: | ||
| 350 | fermi_2d->CallMultiMethod(method, base_start, amount, methods_pending); | ||
| 351 | break; | ||
| 352 | case EngineID::MAXWELL_B: | ||
| 353 | maxwell_3d->CallMultiMethod(method, base_start, amount, methods_pending); | ||
| 354 | break; | ||
| 355 | case EngineID::KEPLER_COMPUTE_B: | ||
| 356 | kepler_compute->CallMultiMethod(method, base_start, amount, methods_pending); | ||
| 357 | break; | ||
| 358 | case EngineID::MAXWELL_DMA_COPY_A: | ||
| 359 | maxwell_dma->CallMultiMethod(method, base_start, amount, methods_pending); | ||
| 360 | break; | ||
| 361 | case EngineID::KEPLER_INLINE_TO_MEMORY_B: | ||
| 362 | kepler_memory->CallMultiMethod(method, base_start, amount, methods_pending); | ||
| 363 | break; | ||
| 364 | default: | ||
| 365 | UNIMPLEMENTED_MSG("Unimplemented engine"); | ||
| 366 | } | ||
| 367 | } | ||
| 368 | |||
| 369 | void GPU::ProcessBindMethod(const MethodCall& method_call) { | ||
| 370 | // Bind the current subchannel to the desired engine id. | ||
| 371 | LOG_DEBUG(HW_GPU, "Binding subchannel {} to engine {}", method_call.subchannel, | ||
| 372 | method_call.argument); | ||
| 373 | const auto engine_id = static_cast<EngineID>(method_call.argument); | ||
| 374 | bound_engines[method_call.subchannel] = static_cast<EngineID>(engine_id); | ||
| 375 | switch (engine_id) { | ||
| 376 | case EngineID::FERMI_TWOD_A: | ||
| 377 | dma_pusher->BindSubchannel(fermi_2d.get(), method_call.subchannel); | ||
| 378 | break; | ||
| 379 | case EngineID::MAXWELL_B: | ||
| 380 | dma_pusher->BindSubchannel(maxwell_3d.get(), method_call.subchannel); | ||
| 381 | break; | ||
| 382 | case EngineID::KEPLER_COMPUTE_B: | ||
| 383 | dma_pusher->BindSubchannel(kepler_compute.get(), method_call.subchannel); | ||
| 384 | break; | ||
| 385 | case EngineID::MAXWELL_DMA_COPY_A: | ||
| 386 | dma_pusher->BindSubchannel(maxwell_dma.get(), method_call.subchannel); | ||
| 387 | break; | ||
| 388 | case EngineID::KEPLER_INLINE_TO_MEMORY_B: | ||
| 389 | dma_pusher->BindSubchannel(kepler_memory.get(), method_call.subchannel); | ||
| 390 | break; | ||
| 391 | default: | ||
| 392 | UNIMPLEMENTED_MSG("Unimplemented engine {:04X}", engine_id); | ||
| 393 | } | ||
| 394 | } | ||
| 395 | |||
| 396 | void GPU::ProcessFenceActionMethod() { | ||
| 397 | switch (regs.fence_action.op) { | ||
| 398 | case FenceOperation::Acquire: | ||
| 399 | WaitFence(regs.fence_action.syncpoint_id, regs.fence_value); | ||
| 400 | break; | ||
| 401 | case FenceOperation::Increment: | ||
| 402 | IncrementSyncPoint(regs.fence_action.syncpoint_id); | ||
| 403 | break; | ||
| 404 | default: | ||
| 405 | UNIMPLEMENTED_MSG("Unimplemented operation {}", regs.fence_action.op.Value()); | ||
| 406 | } | ||
| 407 | } | ||
| 408 | |||
| 409 | void GPU::ProcessWaitForInterruptMethod() { | ||
| 410 | // TODO(bunnei) ImplementMe | ||
| 411 | LOG_WARNING(HW_GPU, "(STUBBED) called"); | ||
| 412 | } | ||
| 413 | |||
| 414 | void GPU::ProcessSemaphoreTriggerMethod() { | ||
| 415 | const auto semaphoreOperationMask = 0xF; | ||
| 416 | const auto op = | ||
| 417 | static_cast<GpuSemaphoreOperation>(regs.semaphore_trigger & semaphoreOperationMask); | ||
| 418 | if (op == GpuSemaphoreOperation::WriteLong) { | ||
| 419 | struct Block { | ||
| 420 | u32 sequence; | ||
| 421 | u32 zeros = 0; | ||
| 422 | u64 timestamp; | ||
| 423 | }; | ||
| 424 | 861 | ||
| 425 | Block block{}; | 862 | bool GPU::IsAsync() const { |
| 426 | block.sequence = regs.semaphore_sequence; | 863 | return impl->IsAsync(); |
| 427 | // TODO(Kmather73): Generate a real GPU timestamp and write it here instead of | ||
| 428 | // CoreTiming | ||
| 429 | block.timestamp = GetTicks(); | ||
| 430 | memory_manager->WriteBlock(regs.semaphore_address.SemaphoreAddress(), &block, | ||
| 431 | sizeof(block)); | ||
| 432 | } else { | ||
| 433 | const u32 word{memory_manager->Read<u32>(regs.semaphore_address.SemaphoreAddress())}; | ||
| 434 | if ((op == GpuSemaphoreOperation::AcquireEqual && word == regs.semaphore_sequence) || | ||
| 435 | (op == GpuSemaphoreOperation::AcquireGequal && | ||
| 436 | static_cast<s32>(word - regs.semaphore_sequence) > 0) || | ||
| 437 | (op == GpuSemaphoreOperation::AcquireMask && (word & regs.semaphore_sequence))) { | ||
| 438 | // Nothing to do in this case | ||
| 439 | } else { | ||
| 440 | regs.acquire_source = true; | ||
| 441 | regs.acquire_value = regs.semaphore_sequence; | ||
| 442 | if (op == GpuSemaphoreOperation::AcquireEqual) { | ||
| 443 | regs.acquire_active = true; | ||
| 444 | regs.acquire_mode = false; | ||
| 445 | } else if (op == GpuSemaphoreOperation::AcquireGequal) { | ||
| 446 | regs.acquire_active = true; | ||
| 447 | regs.acquire_mode = true; | ||
| 448 | } else if (op == GpuSemaphoreOperation::AcquireMask) { | ||
| 449 | // TODO(kemathe) The acquire mask operation waits for a value that, ANDed with | ||
| 450 | // semaphore_sequence, gives a non-0 result | ||
| 451 | LOG_ERROR(HW_GPU, "Invalid semaphore operation AcquireMask not implemented"); | ||
| 452 | } else { | ||
| 453 | LOG_ERROR(HW_GPU, "Invalid semaphore operation"); | ||
| 454 | } | ||
| 455 | } | ||
| 456 | } | ||
| 457 | } | 864 | } |
| 458 | 865 | ||
| 459 | void GPU::ProcessSemaphoreRelease() { | 866 | bool GPU::UseNvdec() const { |
| 460 | memory_manager->Write<u32>(regs.semaphore_address.SemaphoreAddress(), regs.semaphore_release); | 867 | return impl->UseNvdec(); |
| 461 | } | 868 | } |
| 462 | 869 | ||
| 463 | void GPU::ProcessSemaphoreAcquire() { | 870 | void GPU::RendererFrameEndNotify() { |
| 464 | const u32 word = memory_manager->Read<u32>(regs.semaphore_address.SemaphoreAddress()); | 871 | impl->RendererFrameEndNotify(); |
| 465 | const auto value = regs.semaphore_acquire; | ||
| 466 | if (word != value) { | ||
| 467 | regs.acquire_active = true; | ||
| 468 | regs.acquire_value = value; | ||
| 469 | // TODO(kemathe73) figure out how to do the acquire_timeout | ||
| 470 | regs.acquire_mode = false; | ||
| 471 | regs.acquire_source = false; | ||
| 472 | } | ||
| 473 | } | 872 | } |
| 474 | 873 | ||
| 475 | void GPU::Start() { | 874 | void GPU::Start() { |
| 476 | gpu_thread.StartThread(*renderer, renderer->Context(), *dma_pusher); | 875 | impl->Start(); |
| 477 | cpu_context = renderer->GetRenderWindow().CreateSharedContext(); | ||
| 478 | cpu_context->MakeCurrent(); | ||
| 479 | } | 876 | } |
| 480 | 877 | ||
| 481 | void GPU::ObtainContext() { | 878 | void GPU::ObtainContext() { |
| 482 | cpu_context->MakeCurrent(); | 879 | impl->ObtainContext(); |
| 483 | } | 880 | } |
| 484 | 881 | ||
| 485 | void GPU::ReleaseContext() { | 882 | void GPU::ReleaseContext() { |
| 486 | cpu_context->DoneCurrent(); | 883 | impl->ReleaseContext(); |
| 487 | } | 884 | } |
| 488 | 885 | ||
| 489 | void GPU::PushGPUEntries(Tegra::CommandList&& entries) { | 886 | void GPU::PushGPUEntries(Tegra::CommandList&& entries) { |
| 490 | gpu_thread.SubmitList(std::move(entries)); | 887 | impl->PushGPUEntries(std::move(entries)); |
| 491 | } | 888 | } |
| 492 | 889 | ||
| 493 | void GPU::PushCommandBuffer(Tegra::ChCommandHeaderList& entries) { | 890 | void GPU::PushCommandBuffer(Tegra::ChCommandHeaderList& entries) { |
| 494 | if (!use_nvdec) { | 891 | impl->PushCommandBuffer(entries); |
| 495 | return; | ||
| 496 | } | ||
| 497 | |||
| 498 | if (!cdma_pusher) { | ||
| 499 | cdma_pusher = std::make_unique<Tegra::CDmaPusher>(*this); | ||
| 500 | } | ||
| 501 | |||
| 502 | // SubmitCommandBuffer would make the nvdec operations async, this is not currently working | ||
| 503 | // TODO(ameerj): RE proper async nvdec operation | ||
| 504 | // gpu_thread.SubmitCommandBuffer(std::move(entries)); | ||
| 505 | |||
| 506 | cdma_pusher->ProcessEntries(std::move(entries)); | ||
| 507 | } | 892 | } |
| 508 | 893 | ||
| 509 | void GPU::ClearCdmaInstance() { | 894 | void GPU::ClearCdmaInstance() { |
| 510 | cdma_pusher.reset(); | 895 | impl->ClearCdmaInstance(); |
| 511 | } | 896 | } |
| 512 | 897 | ||
| 513 | void GPU::SwapBuffers(const Tegra::FramebufferConfig* framebuffer) { | 898 | void GPU::SwapBuffers(const Tegra::FramebufferConfig* framebuffer) { |
| 514 | gpu_thread.SwapBuffers(framebuffer); | 899 | impl->SwapBuffers(framebuffer); |
| 515 | } | 900 | } |
| 516 | 901 | ||
| 517 | void GPU::FlushRegion(VAddr addr, u64 size) { | 902 | void GPU::FlushRegion(VAddr addr, u64 size) { |
| 518 | gpu_thread.FlushRegion(addr, size); | 903 | impl->FlushRegion(addr, size); |
| 519 | } | 904 | } |
| 520 | 905 | ||
| 521 | void GPU::InvalidateRegion(VAddr addr, u64 size) { | 906 | void GPU::InvalidateRegion(VAddr addr, u64 size) { |
| 522 | gpu_thread.InvalidateRegion(addr, size); | 907 | impl->InvalidateRegion(addr, size); |
| 523 | } | 908 | } |
| 524 | 909 | ||
| 525 | void GPU::FlushAndInvalidateRegion(VAddr addr, u64 size) { | 910 | void GPU::FlushAndInvalidateRegion(VAddr addr, u64 size) { |
| 526 | gpu_thread.FlushAndInvalidateRegion(addr, size); | 911 | impl->FlushAndInvalidateRegion(addr, size); |
| 527 | } | ||
| 528 | |||
| 529 | void GPU::TriggerCpuInterrupt(const u32 syncpoint_id, const u32 value) const { | ||
| 530 | auto& interrupt_manager = system.InterruptManager(); | ||
| 531 | interrupt_manager.GPUInterruptSyncpt(syncpoint_id, value); | ||
| 532 | } | ||
| 533 | |||
| 534 | void GPU::OnCommandListEnd() { | ||
| 535 | if (is_async) { | ||
| 536 | // This command only applies to asynchronous GPU mode | ||
| 537 | gpu_thread.OnCommandListEnd(); | ||
| 538 | } | ||
| 539 | } | 912 | } |
| 540 | 913 | ||
| 541 | } // namespace Tegra | 914 | } // namespace Tegra |
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index e6a02a71b..05e5c94f3 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h | |||
| @@ -4,28 +4,12 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | ||
| 8 | #include <atomic> | ||
| 9 | #include <condition_variable> | ||
| 10 | #include <list> | ||
| 11 | #include <memory> | 7 | #include <memory> |
| 12 | #include <mutex> | 8 | |
| 9 | #include "common/bit_field.h" | ||
| 13 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 14 | #include "core/hle/service/nvdrv/nvdata.h" | ||
| 15 | #include "core/hle/service/nvflinger/buffer_queue.h" | ||
| 16 | #include "video_core/cdma_pusher.h" | 11 | #include "video_core/cdma_pusher.h" |
| 17 | #include "video_core/dma_pusher.h" | ||
| 18 | #include "video_core/framebuffer_config.h" | 12 | #include "video_core/framebuffer_config.h" |
| 19 | #include "video_core/gpu_thread.h" | ||
| 20 | |||
| 21 | using CacheAddr = std::uintptr_t; | ||
| 22 | [[nodiscard]] inline CacheAddr ToCacheAddr(const void* host_ptr) { | ||
| 23 | return reinterpret_cast<CacheAddr>(host_ptr); | ||
| 24 | } | ||
| 25 | |||
| 26 | [[nodiscard]] inline u8* FromCacheAddr(CacheAddr cache_addr) { | ||
| 27 | return reinterpret_cast<u8*>(cache_addr); | ||
| 28 | } | ||
| 29 | 13 | ||
| 30 | namespace Core { | 14 | namespace Core { |
| 31 | namespace Frontend { | 15 | namespace Frontend { |
| @@ -40,6 +24,9 @@ class ShaderNotify; | |||
| 40 | } // namespace VideoCore | 24 | } // namespace VideoCore |
| 41 | 25 | ||
| 42 | namespace Tegra { | 26 | namespace Tegra { |
| 27 | class DmaPusher; | ||
| 28 | class CDmaPusher; | ||
| 29 | struct CommandList; | ||
| 43 | 30 | ||
| 44 | enum class RenderTargetFormat : u32 { | 31 | enum class RenderTargetFormat : u32 { |
| 45 | NONE = 0x0, | 32 | NONE = 0x0, |
| @@ -138,7 +125,18 @@ public: | |||
| 138 | } | 125 | } |
| 139 | }; | 126 | }; |
| 140 | 127 | ||
| 141 | explicit GPU(Core::System& system_, bool is_async_, bool use_nvdec_); | 128 | enum class FenceOperation : u32 { |
| 129 | Acquire = 0, | ||
| 130 | Increment = 1, | ||
| 131 | }; | ||
| 132 | |||
| 133 | union FenceAction { | ||
| 134 | u32 raw; | ||
| 135 | BitField<0, 1, FenceOperation> op; | ||
| 136 | BitField<8, 24, u32> syncpoint_id; | ||
| 137 | }; | ||
| 138 | |||
| 139 | explicit GPU(Core::System& system, bool is_async, bool use_nvdec); | ||
| 142 | ~GPU(); | 140 | ~GPU(); |
| 143 | 141 | ||
| 144 | /// Binds a renderer to the GPU. | 142 | /// Binds a renderer to the GPU. |
| @@ -162,9 +160,7 @@ public: | |||
| 162 | [[nodiscard]] u64 RequestFlush(VAddr addr, std::size_t size); | 160 | [[nodiscard]] u64 RequestFlush(VAddr addr, std::size_t size); |
| 163 | 161 | ||
| 164 | /// Obtains current flush request fence id. | 162 | /// Obtains current flush request fence id. |
| 165 | [[nodiscard]] u64 CurrentFlushRequestFence() const { | 163 | [[nodiscard]] u64 CurrentFlushRequestFence() const; |
| 166 | return current_flush_fence.load(std::memory_order_relaxed); | ||
| 167 | } | ||
| 168 | 164 | ||
| 169 | /// Tick pending requests within the GPU. | 165 | /// Tick pending requests within the GPU. |
| 170 | void TickWork(); | 166 | void TickWork(); |
| @@ -200,24 +196,16 @@ public: | |||
| 200 | [[nodiscard]] const Tegra::CDmaPusher& CDmaPusher() const; | 196 | [[nodiscard]] const Tegra::CDmaPusher& CDmaPusher() const; |
| 201 | 197 | ||
| 202 | /// Returns a reference to the underlying renderer. | 198 | /// Returns a reference to the underlying renderer. |
| 203 | [[nodiscard]] VideoCore::RendererBase& Renderer() { | 199 | [[nodiscard]] VideoCore::RendererBase& Renderer(); |
| 204 | return *renderer; | ||
| 205 | } | ||
| 206 | 200 | ||
| 207 | /// Returns a const reference to the underlying renderer. | 201 | /// Returns a const reference to the underlying renderer. |
| 208 | [[nodiscard]] const VideoCore::RendererBase& Renderer() const { | 202 | [[nodiscard]] const VideoCore::RendererBase& Renderer() const; |
| 209 | return *renderer; | ||
| 210 | } | ||
| 211 | 203 | ||
| 212 | /// Returns a reference to the shader notifier. | 204 | /// Returns a reference to the shader notifier. |
| 213 | [[nodiscard]] VideoCore::ShaderNotify& ShaderNotify() { | 205 | [[nodiscard]] VideoCore::ShaderNotify& ShaderNotify(); |
| 214 | return *shader_notify; | ||
| 215 | } | ||
| 216 | 206 | ||
| 217 | /// Returns a const reference to the shader notifier. | 207 | /// Returns a const reference to the shader notifier. |
| 218 | [[nodiscard]] const VideoCore::ShaderNotify& ShaderNotify() const { | 208 | [[nodiscard]] const VideoCore::ShaderNotify& ShaderNotify() const; |
| 219 | return *shader_notify; | ||
| 220 | } | ||
| 221 | 209 | ||
| 222 | /// Allows the CPU/NvFlinger to wait on the GPU before presenting a frame. | 210 | /// Allows the CPU/NvFlinger to wait on the GPU before presenting a frame. |
| 223 | void WaitFence(u32 syncpoint_id, u32 value); | 211 | void WaitFence(u32 syncpoint_id, u32 value); |
| @@ -232,80 +220,12 @@ public: | |||
| 232 | 220 | ||
| 233 | [[nodiscard]] u64 GetTicks() const; | 221 | [[nodiscard]] u64 GetTicks() const; |
| 234 | 222 | ||
| 235 | [[nodiscard]] std::unique_lock<std::mutex> LockSync() { | 223 | [[nodiscard]] bool IsAsync() const; |
| 236 | return std::unique_lock{sync_mutex}; | ||
| 237 | } | ||
| 238 | |||
| 239 | [[nodiscard]] bool IsAsync() const { | ||
| 240 | return is_async; | ||
| 241 | } | ||
| 242 | 224 | ||
| 243 | [[nodiscard]] bool UseNvdec() const { | 225 | [[nodiscard]] bool UseNvdec() const; |
| 244 | return use_nvdec; | ||
| 245 | } | ||
| 246 | 226 | ||
| 247 | void RendererFrameEndNotify(); | 227 | void RendererFrameEndNotify(); |
| 248 | 228 | ||
| 249 | enum class FenceOperation : u32 { | ||
| 250 | Acquire = 0, | ||
| 251 | Increment = 1, | ||
| 252 | }; | ||
| 253 | |||
| 254 | union FenceAction { | ||
| 255 | u32 raw; | ||
| 256 | BitField<0, 1, FenceOperation> op; | ||
| 257 | BitField<8, 24, u32> syncpoint_id; | ||
| 258 | |||
| 259 | [[nodiscard]] static CommandHeader Build(FenceOperation op, u32 syncpoint_id) { | ||
| 260 | FenceAction result{}; | ||
| 261 | result.op.Assign(op); | ||
| 262 | result.syncpoint_id.Assign(syncpoint_id); | ||
| 263 | return {result.raw}; | ||
| 264 | } | ||
| 265 | }; | ||
| 266 | |||
| 267 | struct Regs { | ||
| 268 | static constexpr size_t NUM_REGS = 0x40; | ||
| 269 | |||
| 270 | union { | ||
| 271 | struct { | ||
| 272 | INSERT_PADDING_WORDS_NOINIT(0x4); | ||
| 273 | struct { | ||
| 274 | u32 address_high; | ||
| 275 | u32 address_low; | ||
| 276 | |||
| 277 | [[nodiscard]] GPUVAddr SemaphoreAddress() const { | ||
| 278 | return static_cast<GPUVAddr>((static_cast<GPUVAddr>(address_high) << 32) | | ||
| 279 | address_low); | ||
| 280 | } | ||
| 281 | } semaphore_address; | ||
| 282 | |||
| 283 | u32 semaphore_sequence; | ||
| 284 | u32 semaphore_trigger; | ||
| 285 | INSERT_PADDING_WORDS_NOINIT(0xC); | ||
| 286 | |||
| 287 | // The pusher and the puller share the reference counter, the pusher only has read | ||
| 288 | // access | ||
| 289 | u32 reference_count; | ||
| 290 | INSERT_PADDING_WORDS_NOINIT(0x5); | ||
| 291 | |||
| 292 | u32 semaphore_acquire; | ||
| 293 | u32 semaphore_release; | ||
| 294 | u32 fence_value; | ||
| 295 | FenceAction fence_action; | ||
| 296 | INSERT_PADDING_WORDS_NOINIT(0xE2); | ||
| 297 | |||
| 298 | // Puller state | ||
| 299 | u32 acquire_mode; | ||
| 300 | u32 acquire_source; | ||
| 301 | u32 acquire_active; | ||
| 302 | u32 acquire_timeout; | ||
| 303 | u32 acquire_value; | ||
| 304 | }; | ||
| 305 | std::array<u32, NUM_REGS> reg_array; | ||
| 306 | }; | ||
| 307 | } regs{}; | ||
| 308 | |||
| 309 | /// Performs any additional setup necessary in order to begin GPU emulation. | 229 | /// Performs any additional setup necessary in order to begin GPU emulation. |
| 310 | /// This can be used to launch any necessary threads and register any necessary | 230 | /// This can be used to launch any necessary threads and register any necessary |
| 311 | /// core timing events. | 231 | /// core timing events. |
| @@ -338,104 +258,9 @@ public: | |||
| 338 | /// Notify rasterizer that any caches of the specified region should be flushed and invalidated | 258 | /// Notify rasterizer that any caches of the specified region should be flushed and invalidated |
| 339 | void FlushAndInvalidateRegion(VAddr addr, u64 size); | 259 | void FlushAndInvalidateRegion(VAddr addr, u64 size); |
| 340 | 260 | ||
| 341 | protected: | ||
| 342 | void TriggerCpuInterrupt(u32 syncpoint_id, u32 value) const; | ||
| 343 | |||
| 344 | private: | 261 | private: |
| 345 | void ProcessBindMethod(const MethodCall& method_call); | 262 | struct Impl; |
| 346 | void ProcessFenceActionMethod(); | 263 | std::unique_ptr<Impl> impl; |
| 347 | void ProcessWaitForInterruptMethod(); | ||
| 348 | void ProcessSemaphoreTriggerMethod(); | ||
| 349 | void ProcessSemaphoreRelease(); | ||
| 350 | void ProcessSemaphoreAcquire(); | ||
| 351 | |||
| 352 | /// Calls a GPU puller method. | ||
| 353 | void CallPullerMethod(const MethodCall& method_call); | ||
| 354 | |||
| 355 | /// Calls a GPU engine method. | ||
| 356 | void CallEngineMethod(const MethodCall& method_call); | ||
| 357 | |||
| 358 | /// Calls a GPU engine multivalue method. | ||
| 359 | void CallEngineMultiMethod(u32 method, u32 subchannel, const u32* base_start, u32 amount, | ||
| 360 | u32 methods_pending); | ||
| 361 | |||
| 362 | /// Determines where the method should be executed. | ||
| 363 | [[nodiscard]] bool ExecuteMethodOnEngine(u32 method); | ||
| 364 | |||
| 365 | protected: | ||
| 366 | Core::System& system; | ||
| 367 | std::unique_ptr<Tegra::MemoryManager> memory_manager; | ||
| 368 | std::unique_ptr<Tegra::DmaPusher> dma_pusher; | ||
| 369 | std::unique_ptr<Tegra::CDmaPusher> cdma_pusher; | ||
| 370 | std::unique_ptr<VideoCore::RendererBase> renderer; | ||
| 371 | VideoCore::RasterizerInterface* rasterizer = nullptr; | ||
| 372 | const bool use_nvdec; | ||
| 373 | |||
| 374 | private: | ||
| 375 | /// Mapping of command subchannels to their bound engine ids | ||
| 376 | std::array<EngineID, 8> bound_engines = {}; | ||
| 377 | /// 3D engine | ||
| 378 | std::unique_ptr<Engines::Maxwell3D> maxwell_3d; | ||
| 379 | /// 2D engine | ||
| 380 | std::unique_ptr<Engines::Fermi2D> fermi_2d; | ||
| 381 | /// Compute engine | ||
| 382 | std::unique_ptr<Engines::KeplerCompute> kepler_compute; | ||
| 383 | /// DMA engine | ||
| 384 | std::unique_ptr<Engines::MaxwellDMA> maxwell_dma; | ||
| 385 | /// Inline memory engine | ||
| 386 | std::unique_ptr<Engines::KeplerMemory> kepler_memory; | ||
| 387 | /// Shader build notifier | ||
| 388 | std::unique_ptr<VideoCore::ShaderNotify> shader_notify; | ||
| 389 | /// When true, we are about to shut down emulation session, so terminate outstanding tasks | ||
| 390 | std::atomic_bool shutting_down{}; | ||
| 391 | |||
| 392 | std::array<std::atomic<u32>, Service::Nvidia::MaxSyncPoints> syncpoints{}; | ||
| 393 | |||
| 394 | std::array<std::list<u32>, Service::Nvidia::MaxSyncPoints> syncpt_interrupts; | ||
| 395 | |||
| 396 | std::mutex sync_mutex; | ||
| 397 | std::mutex device_mutex; | ||
| 398 | |||
| 399 | std::condition_variable sync_cv; | ||
| 400 | |||
| 401 | struct FlushRequest { | ||
| 402 | explicit FlushRequest(u64 fence_, VAddr addr_, std::size_t size_) | ||
| 403 | : fence{fence_}, addr{addr_}, size{size_} {} | ||
| 404 | u64 fence; | ||
| 405 | VAddr addr; | ||
| 406 | std::size_t size; | ||
| 407 | }; | ||
| 408 | |||
| 409 | std::list<FlushRequest> flush_requests; | ||
| 410 | std::atomic<u64> current_flush_fence{}; | ||
| 411 | u64 last_flush_fence{}; | ||
| 412 | std::mutex flush_request_mutex; | ||
| 413 | |||
| 414 | const bool is_async; | ||
| 415 | |||
| 416 | VideoCommon::GPUThread::ThreadManager gpu_thread; | ||
| 417 | std::unique_ptr<Core::Frontend::GraphicsContext> cpu_context; | ||
| 418 | }; | 264 | }; |
| 419 | 265 | ||
| 420 | #define ASSERT_REG_POSITION(field_name, position) \ | ||
| 421 | static_assert(offsetof(GPU::Regs, field_name) == position * 4, \ | ||
| 422 | "Field " #field_name " has invalid position") | ||
| 423 | |||
| 424 | ASSERT_REG_POSITION(semaphore_address, 0x4); | ||
| 425 | ASSERT_REG_POSITION(semaphore_sequence, 0x6); | ||
| 426 | ASSERT_REG_POSITION(semaphore_trigger, 0x7); | ||
| 427 | ASSERT_REG_POSITION(reference_count, 0x14); | ||
| 428 | ASSERT_REG_POSITION(semaphore_acquire, 0x1A); | ||
| 429 | ASSERT_REG_POSITION(semaphore_release, 0x1B); | ||
| 430 | ASSERT_REG_POSITION(fence_value, 0x1C); | ||
| 431 | ASSERT_REG_POSITION(fence_action, 0x1D); | ||
| 432 | |||
| 433 | ASSERT_REG_POSITION(acquire_mode, 0x100); | ||
| 434 | ASSERT_REG_POSITION(acquire_source, 0x101); | ||
| 435 | ASSERT_REG_POSITION(acquire_active, 0x102); | ||
| 436 | ASSERT_REG_POSITION(acquire_timeout, 0x103); | ||
| 437 | ASSERT_REG_POSITION(acquire_value, 0x104); | ||
| 438 | |||
| 439 | #undef ASSERT_REG_POSITION | ||
| 440 | |||
| 441 | } // namespace Tegra | 266 | } // namespace Tegra |
diff --git a/src/video_core/gpu_thread.h b/src/video_core/gpu_thread.h index 91bada925..00984188e 100644 --- a/src/video_core/gpu_thread.h +++ b/src/video_core/gpu_thread.h | |||
| @@ -130,9 +130,6 @@ public: | |||
| 130 | /// Notify rasterizer that any caches of the specified region should be flushed and invalidated | 130 | /// Notify rasterizer that any caches of the specified region should be flushed and invalidated |
| 131 | void FlushAndInvalidateRegion(VAddr addr, u64 size); | 131 | void FlushAndInvalidateRegion(VAddr addr, u64 size); |
| 132 | 132 | ||
| 133 | // Stops the GPU execution and waits for the GPU to finish working | ||
| 134 | void ShutDown(); | ||
| 135 | |||
| 136 | void OnCommandListEnd(); | 133 | void OnCommandListEnd(); |
| 137 | 134 | ||
| 138 | private: | 135 | private: |
diff --git a/src/video_core/host_shaders/CMakeLists.txt b/src/video_core/host_shaders/CMakeLists.txt index c9cff7450..20d748c12 100644 --- a/src/video_core/host_shaders/CMakeLists.txt +++ b/src/video_core/host_shaders/CMakeLists.txt | |||
| @@ -6,7 +6,6 @@ set(SHADER_FILES | |||
| 6 | convert_float_to_depth.frag | 6 | convert_float_to_depth.frag |
| 7 | full_screen_triangle.vert | 7 | full_screen_triangle.vert |
| 8 | opengl_copy_bc4.comp | 8 | opengl_copy_bc4.comp |
| 9 | opengl_copy_bgra.comp | ||
| 10 | opengl_present.frag | 9 | opengl_present.frag |
| 11 | opengl_present.vert | 10 | opengl_present.vert |
| 12 | pitch_unswizzle.comp | 11 | pitch_unswizzle.comp |
diff --git a/src/video_core/host_shaders/opengl_copy_bgra.comp b/src/video_core/host_shaders/opengl_copy_bgra.comp deleted file mode 100644 index 2571a4abf..000000000 --- a/src/video_core/host_shaders/opengl_copy_bgra.comp +++ /dev/null | |||
| @@ -1,15 +0,0 @@ | |||
| 1 | // Copyright 2021 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #version 430 core | ||
| 6 | |||
| 7 | layout (local_size_x = 4, local_size_y = 4) in; | ||
| 8 | |||
| 9 | layout(binding = 0, rgba8) readonly uniform image2DArray bgr_input; | ||
| 10 | layout(binding = 1, rgba8) writeonly uniform image2DArray bgr_output; | ||
| 11 | |||
| 12 | void main() { | ||
| 13 | vec4 color = imageLoad(bgr_input, ivec3(gl_GlobalInvocationID)); | ||
| 14 | imageStore(bgr_output, ivec3(gl_GlobalInvocationID), color.bgra); | ||
| 15 | } | ||
diff --git a/src/video_core/query_cache.h b/src/video_core/query_cache.h index aac851253..73231061a 100644 --- a/src/video_core/query_cache.h +++ b/src/video_core/query_cache.h | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include <array> | 8 | #include <array> |
| 9 | #include <cstring> | 9 | #include <cstring> |
| 10 | #include <iterator> | 10 | #include <iterator> |
| 11 | #include <list> | ||
| 11 | #include <memory> | 12 | #include <memory> |
| 12 | #include <mutex> | 13 | #include <mutex> |
| 13 | #include <optional> | 14 | #include <optional> |
diff --git a/src/video_core/renderer_opengl/gl_buffer_cache.cpp b/src/video_core/renderer_opengl/gl_buffer_cache.cpp index 07a995f7d..187a28e4d 100644 --- a/src/video_core/renderer_opengl/gl_buffer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_buffer_cache.cpp | |||
| @@ -147,8 +147,7 @@ void BufferCacheRuntime::CopyBuffer(Buffer& dst_buffer, Buffer& src_buffer, | |||
| 147 | 147 | ||
| 148 | void BufferCacheRuntime::ClearBuffer(Buffer& dest_buffer, u32 offset, size_t size, u32 value) { | 148 | void BufferCacheRuntime::ClearBuffer(Buffer& dest_buffer, u32 offset, size_t size, u32 value) { |
| 149 | glClearNamedBufferSubData(dest_buffer.Handle(), GL_R32UI, static_cast<GLintptr>(offset), | 149 | glClearNamedBufferSubData(dest_buffer.Handle(), GL_R32UI, static_cast<GLintptr>(offset), |
| 150 | static_cast<GLsizeiptr>(size / sizeof(u32)), GL_RED, GL_UNSIGNED_INT, | 150 | static_cast<GLsizeiptr>(size), GL_RED, GL_UNSIGNED_INT, &value); |
| 151 | &value); | ||
| 152 | } | 151 | } |
| 153 | 152 | ||
| 154 | void BufferCacheRuntime::BindIndexBuffer(Buffer& buffer, u32 offset, u32 size) { | 153 | void BufferCacheRuntime::BindIndexBuffer(Buffer& buffer, u32 offset, u32 size) { |
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp index b0aee6cc1..8c3ca3d82 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.cpp +++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #include "video_core/surface.h" | 20 | #include "video_core/surface.h" |
| 21 | #include "video_core/texture_cache/formatter.h" | 21 | #include "video_core/texture_cache/formatter.h" |
| 22 | #include "video_core/texture_cache/samples_helper.h" | 22 | #include "video_core/texture_cache/samples_helper.h" |
| 23 | #include "video_core/texture_cache/util.h" | ||
| 23 | 24 | ||
| 24 | namespace OpenGL { | 25 | namespace OpenGL { |
| 25 | namespace { | 26 | namespace { |
| @@ -461,7 +462,7 @@ bool TextureCacheRuntime::CanImageBeCopied(const Image& dst, const Image& src) { | |||
| 461 | if (dst.info.type == ImageType::e3D && dst.info.format == PixelFormat::BC4_UNORM) { | 462 | if (dst.info.type == ImageType::e3D && dst.info.format == PixelFormat::BC4_UNORM) { |
| 462 | return false; | 463 | return false; |
| 463 | } | 464 | } |
| 464 | if (IsPixelFormatBGR(dst.info.format) || IsPixelFormatBGR(src.info.format)) { | 465 | if (IsPixelFormatBGR(dst.info.format) != IsPixelFormatBGR(src.info.format)) { |
| 465 | return false; | 466 | return false; |
| 466 | } | 467 | } |
| 467 | return true; | 468 | return true; |
| @@ -473,7 +474,7 @@ void TextureCacheRuntime::EmulateCopyImage(Image& dst, Image& src, | |||
| 473 | ASSERT(src.info.type == ImageType::e3D); | 474 | ASSERT(src.info.type == ImageType::e3D); |
| 474 | util_shaders.CopyBC4(dst, src, copies); | 475 | util_shaders.CopyBC4(dst, src, copies); |
| 475 | } else if (IsPixelFormatBGR(dst.info.format) || IsPixelFormatBGR(src.info.format)) { | 476 | } else if (IsPixelFormatBGR(dst.info.format) || IsPixelFormatBGR(src.info.format)) { |
| 476 | util_shaders.CopyBGR(dst, src, copies); | 477 | bgr_copy_pass.CopyBGR(dst, src, copies); |
| 477 | } else { | 478 | } else { |
| 478 | UNREACHABLE(); | 479 | UNREACHABLE(); |
| 479 | } | 480 | } |
| @@ -1112,4 +1113,37 @@ Framebuffer::Framebuffer(TextureCacheRuntime& runtime, std::span<ImageView*, NUM | |||
| 1112 | framebuffer.handle = handle; | 1113 | framebuffer.handle = handle; |
| 1113 | } | 1114 | } |
| 1114 | 1115 | ||
| 1116 | void BGRCopyPass::CopyBGR(Image& dst_image, Image& src_image, | ||
| 1117 | std::span<const VideoCommon::ImageCopy> copies) { | ||
| 1118 | static constexpr VideoCommon::Offset3D zero_offset{0, 0, 0}; | ||
| 1119 | const u32 requested_pbo_size = | ||
| 1120 | std::max(src_image.unswizzled_size_bytes, dst_image.unswizzled_size_bytes); | ||
| 1121 | |||
| 1122 | if (bgr_pbo_size < requested_pbo_size) { | ||
| 1123 | bgr_pbo.Create(); | ||
| 1124 | bgr_pbo_size = requested_pbo_size; | ||
| 1125 | glNamedBufferData(bgr_pbo.handle, bgr_pbo_size, nullptr, GL_STREAM_COPY); | ||
| 1126 | } | ||
| 1127 | for (const ImageCopy& copy : copies) { | ||
| 1128 | ASSERT(copy.src_offset == zero_offset); | ||
| 1129 | ASSERT(copy.dst_offset == zero_offset); | ||
| 1130 | |||
| 1131 | // Copy from source to PBO | ||
| 1132 | glPixelStorei(GL_PACK_ALIGNMENT, 1); | ||
| 1133 | glPixelStorei(GL_PACK_ROW_LENGTH, copy.extent.width); | ||
| 1134 | glBindBuffer(GL_PIXEL_PACK_BUFFER, bgr_pbo.handle); | ||
| 1135 | glGetTextureSubImage(src_image.Handle(), 0, 0, 0, 0, copy.extent.width, copy.extent.height, | ||
| 1136 | copy.src_subresource.num_layers, src_image.GlFormat(), | ||
| 1137 | src_image.GlType(), static_cast<GLsizei>(bgr_pbo_size), nullptr); | ||
| 1138 | |||
| 1139 | // Copy from PBO to destination in desired GL format | ||
| 1140 | glPixelStorei(GL_UNPACK_ALIGNMENT, 1); | ||
| 1141 | glPixelStorei(GL_UNPACK_ROW_LENGTH, copy.extent.width); | ||
| 1142 | glBindBuffer(GL_PIXEL_UNPACK_BUFFER, bgr_pbo.handle); | ||
| 1143 | glTextureSubImage3D(dst_image.Handle(), 0, 0, 0, 0, copy.extent.width, copy.extent.height, | ||
| 1144 | copy.dst_subresource.num_layers, dst_image.GlFormat(), | ||
| 1145 | dst_image.GlType(), nullptr); | ||
| 1146 | } | ||
| 1147 | } | ||
| 1148 | |||
| 1115 | } // namespace OpenGL | 1149 | } // namespace OpenGL |
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.h b/src/video_core/renderer_opengl/gl_texture_cache.h index 4a4f6301c..1ca2c90be 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.h +++ b/src/video_core/renderer_opengl/gl_texture_cache.h | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | #include "shader_recompiler/shader_info.h" | 12 | #include "shader_recompiler/shader_info.h" |
| 13 | #include "video_core/renderer_opengl/gl_resource_manager.h" | 13 | #include "video_core/renderer_opengl/gl_resource_manager.h" |
| 14 | #include "video_core/renderer_opengl/util_shaders.h" | 14 | #include "video_core/renderer_opengl/util_shaders.h" |
| 15 | #include "video_core/texture_cache/image_view_base.h" | ||
| 15 | #include "video_core/texture_cache/texture_cache_base.h" | 16 | #include "video_core/texture_cache/texture_cache_base.h" |
| 16 | 17 | ||
| 17 | namespace OpenGL { | 18 | namespace OpenGL { |
| @@ -47,6 +48,19 @@ struct FormatProperties { | |||
| 47 | bool is_compressed; | 48 | bool is_compressed; |
| 48 | }; | 49 | }; |
| 49 | 50 | ||
| 51 | class BGRCopyPass { | ||
| 52 | public: | ||
| 53 | BGRCopyPass() = default; | ||
| 54 | ~BGRCopyPass() = default; | ||
| 55 | |||
| 56 | void CopyBGR(Image& dst_image, Image& src_image, | ||
| 57 | std::span<const VideoCommon::ImageCopy> copies); | ||
| 58 | |||
| 59 | private: | ||
| 60 | OGLBuffer bgr_pbo; | ||
| 61 | size_t bgr_pbo_size{}; | ||
| 62 | }; | ||
| 63 | |||
| 50 | class TextureCacheRuntime { | 64 | class TextureCacheRuntime { |
| 51 | friend Framebuffer; | 65 | friend Framebuffer; |
| 52 | friend Image; | 66 | friend Image; |
| @@ -118,6 +132,7 @@ private: | |||
| 118 | const Device& device; | 132 | const Device& device; |
| 119 | StateTracker& state_tracker; | 133 | StateTracker& state_tracker; |
| 120 | UtilShaders util_shaders; | 134 | UtilShaders util_shaders; |
| 135 | BGRCopyPass bgr_copy_pass; | ||
| 121 | 136 | ||
| 122 | std::array<std::unordered_map<GLenum, FormatProperties>, 3> format_properties; | 137 | std::array<std::unordered_map<GLenum, FormatProperties>, 3> format_properties; |
| 123 | bool has_broken_texture_view_formats = false; | 138 | bool has_broken_texture_view_formats = false; |
| @@ -162,6 +177,14 @@ public: | |||
| 162 | return texture.handle; | 177 | return texture.handle; |
| 163 | } | 178 | } |
| 164 | 179 | ||
| 180 | GLuint GlFormat() const noexcept { | ||
| 181 | return gl_format; | ||
| 182 | } | ||
| 183 | |||
| 184 | GLuint GlType() const noexcept { | ||
| 185 | return gl_type; | ||
| 186 | } | ||
| 187 | |||
| 165 | private: | 188 | private: |
| 166 | void CopyBufferToImage(const VideoCommon::BufferImageCopy& copy, size_t buffer_offset); | 189 | void CopyBufferToImage(const VideoCommon::BufferImageCopy& copy, size_t buffer_offset); |
| 167 | 190 | ||
diff --git a/src/video_core/renderer_opengl/maxwell_to_gl.h b/src/video_core/renderer_opengl/maxwell_to_gl.h index 672f94bfc..39158aa3e 100644 --- a/src/video_core/renderer_opengl/maxwell_to_gl.h +++ b/src/video_core/renderer_opengl/maxwell_to_gl.h | |||
| @@ -52,7 +52,7 @@ constexpr std::array<FormatTuple, VideoCore::Surface::MaxPixelFormat> FORMAT_TAB | |||
| 52 | {GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT}, // BC6H_UFLOAT | 52 | {GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT}, // BC6H_UFLOAT |
| 53 | {GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT}, // BC6H_SFLOAT | 53 | {GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT}, // BC6H_SFLOAT |
| 54 | {GL_COMPRESSED_RGBA_ASTC_4x4_KHR}, // ASTC_2D_4X4_UNORM | 54 | {GL_COMPRESSED_RGBA_ASTC_4x4_KHR}, // ASTC_2D_4X4_UNORM |
| 55 | {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE}, // B8G8R8A8_UNORM | 55 | {GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV}, // B8G8R8A8_UNORM |
| 56 | {GL_RGBA32F, GL_RGBA, GL_FLOAT}, // R32G32B32A32_FLOAT | 56 | {GL_RGBA32F, GL_RGBA, GL_FLOAT}, // R32G32B32A32_FLOAT |
| 57 | {GL_RGBA32I, GL_RGBA_INTEGER, GL_INT}, // R32G32B32A32_SINT | 57 | {GL_RGBA32I, GL_RGBA_INTEGER, GL_INT}, // R32G32B32A32_SINT |
| 58 | {GL_RG32F, GL_RG, GL_FLOAT}, // R32G32_FLOAT | 58 | {GL_RG32F, GL_RG, GL_FLOAT}, // R32G32_FLOAT |
| @@ -81,7 +81,7 @@ constexpr std::array<FormatTuple, VideoCore::Surface::MaxPixelFormat> FORMAT_TAB | |||
| 81 | {GL_COMPRESSED_RGBA_ASTC_8x8_KHR}, // ASTC_2D_8X8_UNORM | 81 | {GL_COMPRESSED_RGBA_ASTC_8x8_KHR}, // ASTC_2D_8X8_UNORM |
| 82 | {GL_COMPRESSED_RGBA_ASTC_8x5_KHR}, // ASTC_2D_8X5_UNORM | 82 | {GL_COMPRESSED_RGBA_ASTC_8x5_KHR}, // ASTC_2D_8X5_UNORM |
| 83 | {GL_COMPRESSED_RGBA_ASTC_5x4_KHR}, // ASTC_2D_5X4_UNORM | 83 | {GL_COMPRESSED_RGBA_ASTC_5x4_KHR}, // ASTC_2D_5X4_UNORM |
| 84 | {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE}, // B8G8R8A8_SRGB | 84 | {GL_SRGB8_ALPHA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV}, // B8G8R8A8_SRGB |
| 85 | {GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT}, // BC1_RGBA_SRGB | 85 | {GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT}, // BC1_RGBA_SRGB |
| 86 | {GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT}, // BC2_SRGB | 86 | {GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT}, // BC2_SRGB |
| 87 | {GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}, // BC3_SRGB | 87 | {GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}, // BC3_SRGB |
diff --git a/src/video_core/renderer_opengl/util_shaders.cpp b/src/video_core/renderer_opengl/util_shaders.cpp index 333f35a1c..897c380b3 100644 --- a/src/video_core/renderer_opengl/util_shaders.cpp +++ b/src/video_core/renderer_opengl/util_shaders.cpp | |||
| @@ -14,7 +14,6 @@ | |||
| 14 | #include "video_core/host_shaders/block_linear_unswizzle_2d_comp.h" | 14 | #include "video_core/host_shaders/block_linear_unswizzle_2d_comp.h" |
| 15 | #include "video_core/host_shaders/block_linear_unswizzle_3d_comp.h" | 15 | #include "video_core/host_shaders/block_linear_unswizzle_3d_comp.h" |
| 16 | #include "video_core/host_shaders/opengl_copy_bc4_comp.h" | 16 | #include "video_core/host_shaders/opengl_copy_bc4_comp.h" |
| 17 | #include "video_core/host_shaders/opengl_copy_bgra_comp.h" | ||
| 18 | #include "video_core/host_shaders/pitch_unswizzle_comp.h" | 17 | #include "video_core/host_shaders/pitch_unswizzle_comp.h" |
| 19 | #include "video_core/renderer_opengl/gl_shader_manager.h" | 18 | #include "video_core/renderer_opengl/gl_shader_manager.h" |
| 20 | #include "video_core/renderer_opengl/gl_shader_util.h" | 19 | #include "video_core/renderer_opengl/gl_shader_util.h" |
| @@ -44,11 +43,6 @@ namespace { | |||
| 44 | OGLProgram MakeProgram(std::string_view source) { | 43 | OGLProgram MakeProgram(std::string_view source) { |
| 45 | return CreateProgram(source, GL_COMPUTE_SHADER); | 44 | return CreateProgram(source, GL_COMPUTE_SHADER); |
| 46 | } | 45 | } |
| 47 | |||
| 48 | size_t NumPixelsInCopy(const VideoCommon::ImageCopy& copy) { | ||
| 49 | return static_cast<size_t>(copy.extent.width * copy.extent.height * | ||
| 50 | copy.src_subresource.num_layers); | ||
| 51 | } | ||
| 52 | } // Anonymous namespace | 46 | } // Anonymous namespace |
| 53 | 47 | ||
| 54 | UtilShaders::UtilShaders(ProgramManager& program_manager_) | 48 | UtilShaders::UtilShaders(ProgramManager& program_manager_) |
| @@ -56,7 +50,6 @@ UtilShaders::UtilShaders(ProgramManager& program_manager_) | |||
| 56 | block_linear_unswizzle_2d_program(MakeProgram(BLOCK_LINEAR_UNSWIZZLE_2D_COMP)), | 50 | block_linear_unswizzle_2d_program(MakeProgram(BLOCK_LINEAR_UNSWIZZLE_2D_COMP)), |
| 57 | block_linear_unswizzle_3d_program(MakeProgram(BLOCK_LINEAR_UNSWIZZLE_3D_COMP)), | 51 | block_linear_unswizzle_3d_program(MakeProgram(BLOCK_LINEAR_UNSWIZZLE_3D_COMP)), |
| 58 | pitch_unswizzle_program(MakeProgram(PITCH_UNSWIZZLE_COMP)), | 52 | pitch_unswizzle_program(MakeProgram(PITCH_UNSWIZZLE_COMP)), |
| 59 | copy_bgra_program(MakeProgram(OPENGL_COPY_BGRA_COMP)), | ||
| 60 | copy_bc4_program(MakeProgram(OPENGL_COPY_BC4_COMP)) { | 53 | copy_bc4_program(MakeProgram(OPENGL_COPY_BC4_COMP)) { |
| 61 | const auto swizzle_table = Tegra::Texture::MakeSwizzleTable(); | 54 | const auto swizzle_table = Tegra::Texture::MakeSwizzleTable(); |
| 62 | swizzle_table_buffer.Create(); | 55 | swizzle_table_buffer.Create(); |
| @@ -255,43 +248,6 @@ void UtilShaders::CopyBC4(Image& dst_image, Image& src_image, std::span<const Im | |||
| 255 | program_manager.RestoreGuestCompute(); | 248 | program_manager.RestoreGuestCompute(); |
| 256 | } | 249 | } |
| 257 | 250 | ||
| 258 | void UtilShaders::CopyBGR(Image& dst_image, Image& src_image, | ||
| 259 | std::span<const VideoCommon::ImageCopy> copies) { | ||
| 260 | static constexpr GLuint BINDING_INPUT_IMAGE = 0; | ||
| 261 | static constexpr GLuint BINDING_OUTPUT_IMAGE = 1; | ||
| 262 | static constexpr VideoCommon::Offset3D zero_offset{0, 0, 0}; | ||
| 263 | const u32 bytes_per_block = BytesPerBlock(dst_image.info.format); | ||
| 264 | switch (bytes_per_block) { | ||
| 265 | case 2: | ||
| 266 | // BGR565 copy | ||
| 267 | for (const ImageCopy& copy : copies) { | ||
| 268 | ASSERT(copy.src_offset == zero_offset); | ||
| 269 | ASSERT(copy.dst_offset == zero_offset); | ||
| 270 | bgr_copy_pass.Execute(dst_image, src_image, copy); | ||
| 271 | } | ||
| 272 | break; | ||
| 273 | case 4: { | ||
| 274 | // BGRA8 copy | ||
| 275 | program_manager.BindComputeProgram(copy_bgra_program.handle); | ||
| 276 | constexpr GLenum FORMAT = GL_RGBA8; | ||
| 277 | for (const ImageCopy& copy : copies) { | ||
| 278 | ASSERT(copy.src_offset == zero_offset); | ||
| 279 | ASSERT(copy.dst_offset == zero_offset); | ||
| 280 | glBindImageTexture(BINDING_INPUT_IMAGE, src_image.StorageHandle(), | ||
| 281 | copy.src_subresource.base_level, GL_FALSE, 0, GL_READ_ONLY, FORMAT); | ||
| 282 | glBindImageTexture(BINDING_OUTPUT_IMAGE, dst_image.StorageHandle(), | ||
| 283 | copy.dst_subresource.base_level, GL_FALSE, 0, GL_WRITE_ONLY, FORMAT); | ||
| 284 | glDispatchCompute(copy.extent.width, copy.extent.height, copy.extent.depth); | ||
| 285 | } | ||
| 286 | program_manager.RestoreGuestCompute(); | ||
| 287 | break; | ||
| 288 | } | ||
| 289 | default: | ||
| 290 | UNREACHABLE(); | ||
| 291 | break; | ||
| 292 | } | ||
| 293 | } | ||
| 294 | |||
| 295 | GLenum StoreFormat(u32 bytes_per_block) { | 251 | GLenum StoreFormat(u32 bytes_per_block) { |
| 296 | switch (bytes_per_block) { | 252 | switch (bytes_per_block) { |
| 297 | case 1: | 253 | case 1: |
| @@ -309,36 +265,4 @@ GLenum StoreFormat(u32 bytes_per_block) { | |||
| 309 | return GL_R8UI; | 265 | return GL_R8UI; |
| 310 | } | 266 | } |
| 311 | 267 | ||
| 312 | void Bgr565CopyPass::Execute(const Image& dst_image, const Image& src_image, | ||
| 313 | const ImageCopy& copy) { | ||
| 314 | if (CopyBufferCreationNeeded(copy)) { | ||
| 315 | CreateNewCopyBuffer(copy, GL_TEXTURE_2D_ARRAY, GL_RGB565); | ||
| 316 | } | ||
| 317 | // Copy from source to PBO | ||
| 318 | glPixelStorei(GL_PACK_ALIGNMENT, 1); | ||
| 319 | glPixelStorei(GL_PACK_ROW_LENGTH, copy.extent.width); | ||
| 320 | glBindBuffer(GL_PIXEL_PACK_BUFFER, bgr16_pbo.handle); | ||
| 321 | glGetTextureSubImage(src_image.Handle(), 0, 0, 0, 0, copy.extent.width, copy.extent.height, | ||
| 322 | copy.src_subresource.num_layers, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, | ||
| 323 | static_cast<GLsizei>(bgr16_pbo_size), nullptr); | ||
| 324 | |||
| 325 | // Copy from PBO to destination in reverse order | ||
| 326 | glPixelStorei(GL_UNPACK_ALIGNMENT, 1); | ||
| 327 | glPixelStorei(GL_UNPACK_ROW_LENGTH, copy.extent.width); | ||
| 328 | glBindBuffer(GL_PIXEL_UNPACK_BUFFER, bgr16_pbo.handle); | ||
| 329 | glTextureSubImage3D(dst_image.Handle(), 0, 0, 0, 0, copy.extent.width, copy.extent.height, | ||
| 330 | copy.dst_subresource.num_layers, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV, | ||
| 331 | nullptr); | ||
| 332 | } | ||
| 333 | |||
| 334 | bool Bgr565CopyPass::CopyBufferCreationNeeded(const ImageCopy& copy) { | ||
| 335 | return bgr16_pbo_size < NumPixelsInCopy(copy) * sizeof(u16); | ||
| 336 | } | ||
| 337 | |||
| 338 | void Bgr565CopyPass::CreateNewCopyBuffer(const ImageCopy& copy, GLenum target, GLuint format) { | ||
| 339 | bgr16_pbo.Create(); | ||
| 340 | bgr16_pbo_size = NumPixelsInCopy(copy) * sizeof(u16); | ||
| 341 | glNamedBufferData(bgr16_pbo.handle, bgr16_pbo_size, nullptr, GL_STREAM_COPY); | ||
| 342 | } | ||
| 343 | |||
| 344 | } // namespace OpenGL | 268 | } // namespace OpenGL |
diff --git a/src/video_core/renderer_opengl/util_shaders.h b/src/video_core/renderer_opengl/util_shaders.h index ef881e35f..5de95ea7a 100644 --- a/src/video_core/renderer_opengl/util_shaders.h +++ b/src/video_core/renderer_opengl/util_shaders.h | |||
| @@ -19,22 +19,6 @@ class ProgramManager; | |||
| 19 | 19 | ||
| 20 | struct ImageBufferMap; | 20 | struct ImageBufferMap; |
| 21 | 21 | ||
| 22 | class Bgr565CopyPass { | ||
| 23 | public: | ||
| 24 | Bgr565CopyPass() = default; | ||
| 25 | ~Bgr565CopyPass() = default; | ||
| 26 | |||
| 27 | void Execute(const Image& dst_image, const Image& src_image, | ||
| 28 | const VideoCommon::ImageCopy& copy); | ||
| 29 | |||
| 30 | private: | ||
| 31 | [[nodiscard]] bool CopyBufferCreationNeeded(const VideoCommon::ImageCopy& copy); | ||
| 32 | void CreateNewCopyBuffer(const VideoCommon::ImageCopy& copy, GLenum target, GLuint format); | ||
| 33 | |||
| 34 | OGLBuffer bgr16_pbo; | ||
| 35 | size_t bgr16_pbo_size{}; | ||
| 36 | }; | ||
| 37 | |||
| 38 | class UtilShaders { | 22 | class UtilShaders { |
| 39 | public: | 23 | public: |
| 40 | explicit UtilShaders(ProgramManager& program_manager); | 24 | explicit UtilShaders(ProgramManager& program_manager); |
| @@ -55,9 +39,6 @@ public: | |||
| 55 | void CopyBC4(Image& dst_image, Image& src_image, | 39 | void CopyBC4(Image& dst_image, Image& src_image, |
| 56 | std::span<const VideoCommon::ImageCopy> copies); | 40 | std::span<const VideoCommon::ImageCopy> copies); |
| 57 | 41 | ||
| 58 | void CopyBGR(Image& dst_image, Image& src_image, | ||
| 59 | std::span<const VideoCommon::ImageCopy> copies); | ||
| 60 | |||
| 61 | private: | 42 | private: |
| 62 | ProgramManager& program_manager; | 43 | ProgramManager& program_manager; |
| 63 | 44 | ||
| @@ -67,10 +48,7 @@ private: | |||
| 67 | OGLProgram block_linear_unswizzle_2d_program; | 48 | OGLProgram block_linear_unswizzle_2d_program; |
| 68 | OGLProgram block_linear_unswizzle_3d_program; | 49 | OGLProgram block_linear_unswizzle_3d_program; |
| 69 | OGLProgram pitch_unswizzle_program; | 50 | OGLProgram pitch_unswizzle_program; |
| 70 | OGLProgram copy_bgra_program; | ||
| 71 | OGLProgram copy_bc4_program; | 51 | OGLProgram copy_bc4_program; |
| 72 | |||
| 73 | Bgr565CopyPass bgr_copy_pass; | ||
| 74 | }; | 52 | }; |
| 75 | 53 | ||
| 76 | GLenum StoreFormat(u32 bytes_per_block); | 54 | GLenum StoreFormat(u32 bytes_per_block); |
diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.cpp b/src/video_core/renderer_vulkan/renderer_vulkan.cpp index adb6b7a3b..74822814d 100644 --- a/src/video_core/renderer_vulkan/renderer_vulkan.cpp +++ b/src/video_core/renderer_vulkan/renderer_vulkan.cpp | |||
| @@ -97,19 +97,14 @@ RendererVulkan::RendererVulkan(Core::TelemetrySession& telemetry_session_, | |||
| 97 | Core::Frontend::EmuWindow& emu_window, | 97 | Core::Frontend::EmuWindow& emu_window, |
| 98 | Core::Memory::Memory& cpu_memory_, Tegra::GPU& gpu_, | 98 | Core::Memory::Memory& cpu_memory_, Tegra::GPU& gpu_, |
| 99 | std::unique_ptr<Core::Frontend::GraphicsContext> context_) try | 99 | std::unique_ptr<Core::Frontend::GraphicsContext> context_) try |
| 100 | : RendererBase(emu_window, std::move(context_)), | 100 | : RendererBase(emu_window, std::move(context_)), telemetry_session(telemetry_session_), |
| 101 | telemetry_session(telemetry_session_), | 101 | cpu_memory(cpu_memory_), gpu(gpu_), library(OpenLibrary()), |
| 102 | cpu_memory(cpu_memory_), | ||
| 103 | gpu(gpu_), | ||
| 104 | library(OpenLibrary()), | ||
| 105 | instance(CreateInstance(library, dld, VK_API_VERSION_1_1, render_window.GetWindowInfo().type, | 102 | instance(CreateInstance(library, dld, VK_API_VERSION_1_1, render_window.GetWindowInfo().type, |
| 106 | true, Settings::values.renderer_debug.GetValue())), | 103 | true, Settings::values.renderer_debug.GetValue())), |
| 107 | debug_callback(Settings::values.renderer_debug ? CreateDebugCallback(instance) : nullptr), | 104 | debug_callback(Settings::values.renderer_debug ? CreateDebugCallback(instance) : nullptr), |
| 108 | surface(CreateSurface(instance, render_window)), | 105 | surface(CreateSurface(instance, render_window)), |
| 109 | device(CreateDevice(instance, dld, *surface)), | 106 | device(CreateDevice(instance, dld, *surface)), memory_allocator(device, false), |
| 110 | memory_allocator(device, false), | 107 | state_tracker(gpu), scheduler(device, state_tracker), |
| 111 | state_tracker(gpu), | ||
| 112 | scheduler(device, state_tracker), | ||
| 113 | swapchain(*surface, device, scheduler, render_window.GetFramebufferLayout().width, | 108 | swapchain(*surface, device, scheduler, render_window.GetFramebufferLayout().width, |
| 114 | render_window.GetFramebufferLayout().height, false), | 109 | render_window.GetFramebufferLayout().height, false), |
| 115 | blit_screen(cpu_memory, render_window, device, memory_allocator, swapchain, scheduler, | 110 | blit_screen(cpu_memory, render_window, device, memory_allocator, swapchain, scheduler, |
diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index 7c0f91007..8634c3316 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp | |||
| @@ -507,8 +507,9 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) { | |||
| 507 | vertex_attributes.push_back({ | 507 | vertex_attributes.push_back({ |
| 508 | .location = static_cast<u32>(index), | 508 | .location = static_cast<u32>(index), |
| 509 | .binding = 0, | 509 | .binding = 0, |
| 510 | .format = type == 1 ? VK_FORMAT_R32_SFLOAT | 510 | .format = type == 1 ? VK_FORMAT_R32_SFLOAT |
| 511 | : type == 2 ? VK_FORMAT_R32_SINT : VK_FORMAT_R32_UINT, | 511 | : type == 2 ? VK_FORMAT_R32_SINT |
| 512 | : VK_FORMAT_R32_UINT, | ||
| 512 | .offset = 0, | 513 | .offset = 0, |
| 513 | }); | 514 | }); |
| 514 | } | 515 | } |
| @@ -567,12 +568,21 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) { | |||
| 567 | if (!vertex_binding_divisors.empty()) { | 568 | if (!vertex_binding_divisors.empty()) { |
| 568 | vertex_input_ci.pNext = &input_divisor_ci; | 569 | vertex_input_ci.pNext = &input_divisor_ci; |
| 569 | } | 570 | } |
| 571 | const bool has_tess_stages = spv_modules[1] || spv_modules[2]; | ||
| 570 | auto input_assembly_topology = MaxwellToVK::PrimitiveTopology(device, key.state.topology); | 572 | auto input_assembly_topology = MaxwellToVK::PrimitiveTopology(device, key.state.topology); |
| 571 | if (input_assembly_topology == VK_PRIMITIVE_TOPOLOGY_PATCH_LIST) { | 573 | if (input_assembly_topology == VK_PRIMITIVE_TOPOLOGY_PATCH_LIST) { |
| 572 | if (!spv_modules[1] && !spv_modules[2]) { | 574 | if (!has_tess_stages) { |
| 573 | LOG_WARNING(Render_Vulkan, "Patch topology used without tessellation, using points"); | 575 | LOG_WARNING(Render_Vulkan, "Patch topology used without tessellation, using points"); |
| 574 | input_assembly_topology = VK_PRIMITIVE_TOPOLOGY_POINT_LIST; | 576 | input_assembly_topology = VK_PRIMITIVE_TOPOLOGY_POINT_LIST; |
| 575 | } | 577 | } |
| 578 | } else { | ||
| 579 | if (has_tess_stages) { | ||
| 580 | // The Vulkan spec requires patch list IA topology be used with tessellation | ||
| 581 | // shader stages. Forcing it fixes a crash on some drivers | ||
| 582 | LOG_WARNING(Render_Vulkan, | ||
| 583 | "Patch topology not used with tessellation, using patch list"); | ||
| 584 | input_assembly_topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; | ||
| 585 | } | ||
| 576 | } | 586 | } |
| 577 | const VkPipelineInputAssemblyStateCreateInfo input_assembly_ci{ | 587 | const VkPipelineInputAssemblyStateCreateInfo input_assembly_ci{ |
| 578 | .sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, | 588 | .sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
diff --git a/src/video_core/renderer_vulkan/vk_scheduler.h b/src/video_core/renderer_vulkan/vk_scheduler.h index bd22e4e83..85fc1712f 100644 --- a/src/video_core/renderer_vulkan/vk_scheduler.h +++ b/src/video_core/renderer_vulkan/vk_scheduler.h | |||
| @@ -212,7 +212,6 @@ private: | |||
| 212 | vk::CommandBuffer current_cmdbuf; | 212 | vk::CommandBuffer current_cmdbuf; |
| 213 | 213 | ||
| 214 | std::unique_ptr<CommandChunk> chunk; | 214 | std::unique_ptr<CommandChunk> chunk; |
| 215 | std::jthread worker_thread; | ||
| 216 | 215 | ||
| 217 | State state; | 216 | State state; |
| 218 | 217 | ||
| @@ -226,6 +225,7 @@ private: | |||
| 226 | std::mutex work_mutex; | 225 | std::mutex work_mutex; |
| 227 | std::condition_variable_any work_cv; | 226 | std::condition_variable_any work_cv; |
| 228 | std::condition_variable wait_cv; | 227 | std::condition_variable wait_cv; |
| 228 | std::jthread worker_thread; | ||
| 229 | }; | 229 | }; |
| 230 | 230 | ||
| 231 | } // namespace Vulkan | 231 | } // namespace Vulkan |
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index ff979a7ac..06c5fb867 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | #include "video_core/renderer_vulkan/vk_texture_cache.h" | 21 | #include "video_core/renderer_vulkan/vk_texture_cache.h" |
| 22 | #include "video_core/texture_cache/formatter.h" | 22 | #include "video_core/texture_cache/formatter.h" |
| 23 | #include "video_core/texture_cache/samples_helper.h" | 23 | #include "video_core/texture_cache/samples_helper.h" |
| 24 | #include "video_core/texture_cache/util.h" | ||
| 24 | #include "video_core/vulkan_common/vulkan_device.h" | 25 | #include "video_core/vulkan_common/vulkan_device.h" |
| 25 | #include "video_core/vulkan_common/vulkan_memory_allocator.h" | 26 | #include "video_core/vulkan_common/vulkan_memory_allocator.h" |
| 26 | #include "video_core/vulkan_common/vulkan_wrapper.h" | 27 | #include "video_core/vulkan_common/vulkan_wrapper.h" |
| @@ -127,7 +128,7 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) { | |||
| 127 | const auto format_info = MaxwellToVK::SurfaceFormat(device, FormatType::Optimal, false, format); | 128 | const auto format_info = MaxwellToVK::SurfaceFormat(device, FormatType::Optimal, false, format); |
| 128 | VkImageCreateFlags flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; | 129 | VkImageCreateFlags flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; |
| 129 | if (info.type == ImageType::e2D && info.resources.layers >= 6 && | 130 | if (info.type == ImageType::e2D && info.resources.layers >= 6 && |
| 130 | info.size.width == info.size.height) { | 131 | info.size.width == info.size.height && !device.HasBrokenCubeImageCompability()) { |
| 131 | flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT; | 132 | flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT; |
| 132 | } | 133 | } |
| 133 | if (info.type == ImageType::e3D) { | 134 | if (info.type == ImageType::e3D) { |
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.h b/src/video_core/renderer_vulkan/vk_texture_cache.h index 6d5a68bfe..b09c468e4 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.h +++ b/src/video_core/renderer_vulkan/vk_texture_cache.h | |||
| @@ -4,11 +4,11 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <compare> | ||
| 8 | #include <span> | 7 | #include <span> |
| 9 | 8 | ||
| 10 | #include "shader_recompiler/shader_info.h" | 9 | #include "shader_recompiler/shader_info.h" |
| 11 | #include "video_core/renderer_vulkan/vk_staging_buffer_pool.h" | 10 | #include "video_core/renderer_vulkan/vk_staging_buffer_pool.h" |
| 11 | #include "video_core/texture_cache/image_view_base.h" | ||
| 12 | #include "video_core/texture_cache/texture_cache_base.h" | 12 | #include "video_core/texture_cache/texture_cache_base.h" |
| 13 | #include "video_core/vulkan_common/vulkan_memory_allocator.h" | 13 | #include "video_core/vulkan_common/vulkan_memory_allocator.h" |
| 14 | #include "video_core/vulkan_common/vulkan_wrapper.h" | 14 | #include "video_core/vulkan_common/vulkan_wrapper.h" |
diff --git a/src/video_core/shader_environment.cpp b/src/video_core/shader_environment.cpp index 81a878bb2..05850afd0 100644 --- a/src/video_core/shader_environment.cpp +++ b/src/video_core/shader_environment.cpp | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | #include "common/fs/fs.h" | 16 | #include "common/fs/fs.h" |
| 17 | #include "common/logging/log.h" | 17 | #include "common/logging/log.h" |
| 18 | #include "shader_recompiler/environment.h" | 18 | #include "shader_recompiler/environment.h" |
| 19 | #include "video_core/engines/kepler_compute.h" | ||
| 19 | #include "video_core/memory_manager.h" | 20 | #include "video_core/memory_manager.h" |
| 20 | #include "video_core/shader_environment.h" | 21 | #include "video_core/shader_environment.h" |
| 21 | #include "video_core/textures/texture.h" | 22 | #include "video_core/textures/texture.h" |
diff --git a/src/video_core/shader_environment.h b/src/video_core/shader_environment.h index 2079979db..6640e53d0 100644 --- a/src/video_core/shader_environment.h +++ b/src/video_core/shader_environment.h | |||
| @@ -5,13 +5,13 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <atomic> | ||
| 9 | #include <filesystem> | 8 | #include <filesystem> |
| 10 | #include <iosfwd> | 9 | #include <iosfwd> |
| 11 | #include <limits> | 10 | #include <limits> |
| 12 | #include <memory> | 11 | #include <memory> |
| 13 | #include <optional> | 12 | #include <optional> |
| 14 | #include <span> | 13 | #include <span> |
| 14 | #include <stop_token> | ||
| 15 | #include <type_traits> | 15 | #include <type_traits> |
| 16 | #include <unordered_map> | 16 | #include <unordered_map> |
| 17 | #include <vector> | 17 | #include <vector> |
| @@ -19,9 +19,7 @@ | |||
| 19 | #include "common/common_types.h" | 19 | #include "common/common_types.h" |
| 20 | #include "common/unique_function.h" | 20 | #include "common/unique_function.h" |
| 21 | #include "shader_recompiler/environment.h" | 21 | #include "shader_recompiler/environment.h" |
| 22 | #include "video_core/engines/kepler_compute.h" | ||
| 23 | #include "video_core/engines/maxwell_3d.h" | 22 | #include "video_core/engines/maxwell_3d.h" |
| 24 | #include "video_core/textures/texture.h" | ||
| 25 | 23 | ||
| 26 | namespace Tegra { | 24 | namespace Tegra { |
| 27 | class Memorymanager; | 25 | class Memorymanager; |
diff --git a/src/video_core/texture_cache/image_view_info.cpp b/src/video_core/texture_cache/image_view_info.cpp index 6527e14c8..e751f26c7 100644 --- a/src/video_core/texture_cache/image_view_info.cpp +++ b/src/video_core/texture_cache/image_view_info.cpp | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include "video_core/texture_cache/image_view_info.h" | 8 | #include "video_core/texture_cache/image_view_info.h" |
| 9 | #include "video_core/texture_cache/texture_cache_base.h" | 9 | #include "video_core/texture_cache/texture_cache_base.h" |
| 10 | #include "video_core/texture_cache/types.h" | 10 | #include "video_core/texture_cache/types.h" |
| 11 | #include "video_core/texture_cache/util.h" | ||
| 11 | #include "video_core/textures/texture.h" | 12 | #include "video_core/textures/texture.h" |
| 12 | 13 | ||
| 13 | namespace VideoCommon { | 14 | namespace VideoCommon { |
diff --git a/src/video_core/texture_cache/slot_vector.h b/src/video_core/texture_cache/slot_vector.h index 74cd3c9d8..50df06409 100644 --- a/src/video_core/texture_cache/slot_vector.h +++ b/src/video_core/texture_cache/slot_vector.h | |||
| @@ -31,8 +31,8 @@ struct SlotId { | |||
| 31 | }; | 31 | }; |
| 32 | 32 | ||
| 33 | template <class T> | 33 | template <class T> |
| 34 | requires std::is_nothrow_move_assignable_v<T>&& | 34 | requires std::is_nothrow_move_assignable_v<T> && std::is_nothrow_move_constructible_v<T> |
| 35 | std::is_nothrow_move_constructible_v<T> class SlotVector { | 35 | class SlotVector { |
| 36 | public: | 36 | public: |
| 37 | class Iterator { | 37 | class Iterator { |
| 38 | friend SlotVector<T>; | 38 | friend SlotVector<T>; |
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 24b809242..329df2e49 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -4,10 +4,15 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <unordered_set> | ||
| 8 | |||
| 7 | #include "common/alignment.h" | 9 | #include "common/alignment.h" |
| 8 | #include "video_core/dirty_flags.h" | 10 | #include "video_core/dirty_flags.h" |
| 11 | #include "video_core/engines/kepler_compute.h" | ||
| 12 | #include "video_core/texture_cache/image_view_base.h" | ||
| 9 | #include "video_core/texture_cache/samples_helper.h" | 13 | #include "video_core/texture_cache/samples_helper.h" |
| 10 | #include "video_core/texture_cache/texture_cache_base.h" | 14 | #include "video_core/texture_cache/texture_cache_base.h" |
| 15 | #include "video_core/texture_cache/util.h" | ||
| 11 | 16 | ||
| 12 | namespace VideoCommon { | 17 | namespace VideoCommon { |
| 13 | 18 | ||
diff --git a/src/video_core/texture_cache/texture_cache_base.h b/src/video_core/texture_cache/texture_cache_base.h index d7528ed24..2d1893c1c 100644 --- a/src/video_core/texture_cache/texture_cache_base.h +++ b/src/video_core/texture_cache/texture_cache_base.h | |||
| @@ -4,13 +4,12 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | ||
| 8 | #include <mutex> | 7 | #include <mutex> |
| 9 | #include <span> | 8 | #include <span> |
| 10 | #include <type_traits> | 9 | #include <type_traits> |
| 11 | #include <unordered_map> | 10 | #include <unordered_map> |
| 12 | #include <unordered_set> | ||
| 13 | #include <vector> | 11 | #include <vector> |
| 12 | #include <queue> | ||
| 14 | 13 | ||
| 15 | #include "common/common_types.h" | 14 | #include "common/common_types.h" |
| 16 | #include "common/literals.h" | 15 | #include "common/literals.h" |
| @@ -18,10 +17,6 @@ | |||
| 18 | #include "video_core/compatible_formats.h" | 17 | #include "video_core/compatible_formats.h" |
| 19 | #include "video_core/delayed_destruction_ring.h" | 18 | #include "video_core/delayed_destruction_ring.h" |
| 20 | #include "video_core/engines/fermi_2d.h" | 19 | #include "video_core/engines/fermi_2d.h" |
| 21 | #include "video_core/engines/kepler_compute.h" | ||
| 22 | #include "video_core/engines/maxwell_3d.h" | ||
| 23 | #include "video_core/memory_manager.h" | ||
| 24 | #include "video_core/rasterizer_interface.h" | ||
| 25 | #include "video_core/surface.h" | 20 | #include "video_core/surface.h" |
| 26 | #include "video_core/texture_cache/descriptor_table.h" | 21 | #include "video_core/texture_cache/descriptor_table.h" |
| 27 | #include "video_core/texture_cache/image_base.h" | 22 | #include "video_core/texture_cache/image_base.h" |
| @@ -30,7 +25,6 @@ | |||
| 30 | #include "video_core/texture_cache/render_targets.h" | 25 | #include "video_core/texture_cache/render_targets.h" |
| 31 | #include "video_core/texture_cache/slot_vector.h" | 26 | #include "video_core/texture_cache/slot_vector.h" |
| 32 | #include "video_core/texture_cache/types.h" | 27 | #include "video_core/texture_cache/types.h" |
| 33 | #include "video_core/texture_cache/util.h" | ||
| 34 | #include "video_core/textures/texture.h" | 28 | #include "video_core/textures/texture.h" |
| 35 | 29 | ||
| 36 | namespace VideoCommon { | 30 | namespace VideoCommon { |
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index c2ec9f76a..6388ed2eb 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp | |||
| @@ -588,22 +588,27 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR | |||
| 588 | ext_extended_dynamic_state = false; | 588 | ext_extended_dynamic_state = false; |
| 589 | } | 589 | } |
| 590 | } | 590 | } |
| 591 | |||
| 592 | sets_per_pool = 64; | 591 | sets_per_pool = 64; |
| 593 | if (driver_id == VK_DRIVER_ID_AMD_PROPRIETARY || driver_id == VK_DRIVER_ID_AMD_OPEN_SOURCE) { | 592 | |
| 593 | const bool is_amd = | ||
| 594 | driver_id == VK_DRIVER_ID_AMD_PROPRIETARY || driver_id == VK_DRIVER_ID_AMD_OPEN_SOURCE; | ||
| 595 | if (is_amd) { | ||
| 594 | // AMD drivers need a higher amount of Sets per Pool in certain circunstances like in XC2. | 596 | // AMD drivers need a higher amount of Sets per Pool in certain circunstances like in XC2. |
| 595 | sets_per_pool = 96; | 597 | sets_per_pool = 96; |
| 596 | } | 598 | // Disable VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT on AMD GCN4 and lower as it is broken. |
| 597 | |||
| 598 | const bool is_amd = driver_id == VK_DRIVER_ID_AMD_PROPRIETARY || | ||
| 599 | driver_id == VK_DRIVER_ID_MESA_RADV || | ||
| 600 | driver_id == VK_DRIVER_ID_AMD_OPEN_SOURCE; | ||
| 601 | if (ext_sampler_filter_minmax && is_amd) { | ||
| 602 | // Disable ext_sampler_filter_minmax on AMD GCN4 and lower as it is broken. | ||
| 603 | if (!is_float16_supported) { | 599 | if (!is_float16_supported) { |
| 604 | LOG_WARNING( | 600 | LOG_WARNING( |
| 605 | Render_Vulkan, | 601 | Render_Vulkan, |
| 606 | "Blacklisting AMD GCN4 and lower for VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME"); | 602 | "AMD GCN4 and earlier do not properly support VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT"); |
| 603 | has_broken_cube_compatibility = true; | ||
| 604 | } | ||
| 605 | } | ||
| 606 | const bool is_amd_or_radv = is_amd || driver_id == VK_DRIVER_ID_MESA_RADV; | ||
| 607 | if (ext_sampler_filter_minmax && is_amd_or_radv) { | ||
| 608 | // Disable ext_sampler_filter_minmax on AMD GCN4 and lower as it is broken. | ||
| 609 | if (!is_float16_supported) { | ||
| 610 | LOG_WARNING(Render_Vulkan, | ||
| 611 | "Blacklisting AMD GCN4 and earlier for VK_EXT_sampler_filter_minmax"); | ||
| 607 | ext_sampler_filter_minmax = false; | 612 | ext_sampler_filter_minmax = false; |
| 608 | } | 613 | } |
| 609 | } | 614 | } |
diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h index bc180a32a..d9e74f1aa 100644 --- a/src/video_core/vulkan_common/vulkan_device.h +++ b/src/video_core/vulkan_common/vulkan_device.h | |||
| @@ -309,6 +309,11 @@ public: | |||
| 309 | return has_renderdoc || has_nsight_graphics; | 309 | return has_renderdoc || has_nsight_graphics; |
| 310 | } | 310 | } |
| 311 | 311 | ||
| 312 | /// Returns true when the device does not properly support cube compatibility. | ||
| 313 | bool HasBrokenCubeImageCompability() const { | ||
| 314 | return has_broken_cube_compatibility; | ||
| 315 | } | ||
| 316 | |||
| 312 | /// Returns the vendor name reported from Vulkan. | 317 | /// Returns the vendor name reported from Vulkan. |
| 313 | std::string_view GetVendorName() const { | 318 | std::string_view GetVendorName() const { |
| 314 | return vendor_name; | 319 | return vendor_name; |
| @@ -417,6 +422,7 @@ private: | |||
| 417 | bool ext_conservative_rasterization{}; ///< Support for VK_EXT_conservative_rasterization. | 422 | bool ext_conservative_rasterization{}; ///< Support for VK_EXT_conservative_rasterization. |
| 418 | bool ext_provoking_vertex{}; ///< Support for VK_EXT_provoking_vertex. | 423 | bool ext_provoking_vertex{}; ///< Support for VK_EXT_provoking_vertex. |
| 419 | bool nv_device_diagnostics_config{}; ///< Support for VK_NV_device_diagnostics_config. | 424 | bool nv_device_diagnostics_config{}; ///< Support for VK_NV_device_diagnostics_config. |
| 425 | bool has_broken_cube_compatibility{}; ///< Has broken cube compatiblity bit | ||
| 420 | bool has_renderdoc{}; ///< Has RenderDoc attached | 426 | bool has_renderdoc{}; ///< Has RenderDoc attached |
| 421 | bool has_nsight_graphics{}; ///< Has Nsight Graphics attached | 427 | bool has_nsight_graphics{}; ///< Has Nsight Graphics attached |
| 422 | 428 | ||
diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index b6dda283d..402be6a78 100644 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt | |||
| @@ -290,10 +290,6 @@ if (YUZU_USE_QT_WEB_ENGINE) | |||
| 290 | target_compile_definitions(yuzu PRIVATE -DYUZU_USE_QT_WEB_ENGINE) | 290 | target_compile_definitions(yuzu PRIVATE -DYUZU_USE_QT_WEB_ENGINE) |
| 291 | endif () | 291 | endif () |
| 292 | 292 | ||
| 293 | if (YUZU_ENABLE_BOXCAT) | ||
| 294 | target_compile_definitions(yuzu PRIVATE -DYUZU_ENABLE_BOXCAT) | ||
| 295 | endif () | ||
| 296 | |||
| 297 | if(UNIX AND NOT APPLE) | 293 | if(UNIX AND NOT APPLE) |
| 298 | install(TARGETS yuzu RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") | 294 | install(TARGETS yuzu RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") |
| 299 | endif() | 295 | endif() |
diff --git a/src/yuzu/applets/qt_web_browser.cpp b/src/yuzu/applets/qt_web_browser.cpp index 652d99570..7d433ca50 100644 --- a/src/yuzu/applets/qt_web_browser.cpp +++ b/src/yuzu/applets/qt_web_browser.cpp | |||
| @@ -54,6 +54,9 @@ QtNXWebEngineView::QtNXWebEngineView(QWidget* parent, Core::System& system, | |||
| 54 | input_interpreter(std::make_unique<InputInterpreter>(system)), | 54 | input_interpreter(std::make_unique<InputInterpreter>(system)), |
| 55 | default_profile{QWebEngineProfile::defaultProfile()}, | 55 | default_profile{QWebEngineProfile::defaultProfile()}, |
| 56 | global_settings{QWebEngineSettings::globalSettings()} { | 56 | global_settings{QWebEngineSettings::globalSettings()} { |
| 57 | default_profile->setPersistentStoragePath(QString::fromStdString(Common::FS::PathToUTF8String( | ||
| 58 | Common::FS::GetYuzuPath(Common::FS::YuzuPath::YuzuDir) / "qtwebengine"))); | ||
| 59 | |||
| 57 | QWebEngineScript gamepad; | 60 | QWebEngineScript gamepad; |
| 58 | QWebEngineScript window_nx; | 61 | QWebEngineScript window_nx; |
| 59 | 62 | ||
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 1519a46ed..8b9e186b0 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp | |||
| @@ -302,12 +302,17 @@ GRenderWindow::GRenderWindow(GMainWindow* parent, EmuThread* emu_thread_, | |||
| 302 | connect(this, &GRenderWindow::FirstFrameDisplayed, parent, &GMainWindow::OnLoadComplete); | 302 | connect(this, &GRenderWindow::FirstFrameDisplayed, parent, &GMainWindow::OnLoadComplete); |
| 303 | connect(this, &GRenderWindow::ExecuteProgramSignal, parent, &GMainWindow::OnExecuteProgram, | 303 | connect(this, &GRenderWindow::ExecuteProgramSignal, parent, &GMainWindow::OnExecuteProgram, |
| 304 | Qt::QueuedConnection); | 304 | Qt::QueuedConnection); |
| 305 | connect(this, &GRenderWindow::ExitSignal, parent, &GMainWindow::OnExit, Qt::QueuedConnection); | ||
| 305 | } | 306 | } |
| 306 | 307 | ||
| 307 | void GRenderWindow::ExecuteProgram(std::size_t program_index) { | 308 | void GRenderWindow::ExecuteProgram(std::size_t program_index) { |
| 308 | emit ExecuteProgramSignal(program_index); | 309 | emit ExecuteProgramSignal(program_index); |
| 309 | } | 310 | } |
| 310 | 311 | ||
| 312 | void GRenderWindow::Exit() { | ||
| 313 | emit ExitSignal(); | ||
| 314 | } | ||
| 315 | |||
| 311 | GRenderWindow::~GRenderWindow() { | 316 | GRenderWindow::~GRenderWindow() { |
| 312 | input_subsystem->Shutdown(); | 317 | input_subsystem->Shutdown(); |
| 313 | } | 318 | } |
diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h index 402dd2ee1..54c4e2142 100644 --- a/src/yuzu/bootmanager.h +++ b/src/yuzu/bootmanager.h | |||
| @@ -181,6 +181,9 @@ public: | |||
| 181 | */ | 181 | */ |
| 182 | void ExecuteProgram(std::size_t program_index); | 182 | void ExecuteProgram(std::size_t program_index); |
| 183 | 183 | ||
| 184 | /// Instructs the window to exit the application. | ||
| 185 | void Exit(); | ||
| 186 | |||
| 184 | public slots: | 187 | public slots: |
| 185 | void OnEmulationStarting(EmuThread* emu_thread); | 188 | void OnEmulationStarting(EmuThread* emu_thread); |
| 186 | void OnEmulationStopping(); | 189 | void OnEmulationStopping(); |
| @@ -191,6 +194,7 @@ signals: | |||
| 191 | void Closed(); | 194 | void Closed(); |
| 192 | void FirstFrameDisplayed(); | 195 | void FirstFrameDisplayed(); |
| 193 | void ExecuteProgramSignal(std::size_t program_index); | 196 | void ExecuteProgramSignal(std::size_t program_index); |
| 197 | void ExitSignal(); | ||
| 194 | void MouseActivity(); | 198 | void MouseActivity(); |
| 195 | 199 | ||
| 196 | private: | 200 | private: |
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 27b67fd9e..eb941ce02 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp | |||
| @@ -562,7 +562,11 @@ void Config::ReadControlValues() { | |||
| 562 | ReadTouchscreenValues(); | 562 | ReadTouchscreenValues(); |
| 563 | ReadMotionTouchValues(); | 563 | ReadMotionTouchValues(); |
| 564 | 564 | ||
| 565 | #ifdef _WIN32 | ||
| 565 | ReadBasicSetting(Settings::values.enable_raw_input); | 566 | ReadBasicSetting(Settings::values.enable_raw_input); |
| 567 | #else | ||
| 568 | Settings::values.enable_raw_input = false; | ||
| 569 | #endif | ||
| 566 | ReadBasicSetting(Settings::values.emulate_analog_keyboard); | 570 | ReadBasicSetting(Settings::values.emulate_analog_keyboard); |
| 567 | Settings::values.mouse_panning = false; | 571 | Settings::values.mouse_panning = false; |
| 568 | ReadBasicSetting(Settings::values.mouse_panning_sensitivity); | 572 | ReadBasicSetting(Settings::values.mouse_panning_sensitivity); |
| @@ -705,8 +709,6 @@ void Config::ReadDebuggingValues() { | |||
| 705 | 709 | ||
| 706 | void Config::ReadServiceValues() { | 710 | void Config::ReadServiceValues() { |
| 707 | qt_config->beginGroup(QStringLiteral("Services")); | 711 | qt_config->beginGroup(QStringLiteral("Services")); |
| 708 | ReadBasicSetting(Settings::values.bcat_backend); | ||
| 709 | ReadBasicSetting(Settings::values.bcat_boxcat_local); | ||
| 710 | ReadBasicSetting(Settings::values.network_interface); | 712 | ReadBasicSetting(Settings::values.network_interface); |
| 711 | qt_config->endGroup(); | 713 | qt_config->endGroup(); |
| 712 | } | 714 | } |
| @@ -1265,8 +1267,6 @@ void Config::SaveDebuggingValues() { | |||
| 1265 | void Config::SaveNetworkValues() { | 1267 | void Config::SaveNetworkValues() { |
| 1266 | qt_config->beginGroup(QStringLiteral("Services")); | 1268 | qt_config->beginGroup(QStringLiteral("Services")); |
| 1267 | 1269 | ||
| 1268 | WriteBasicSetting(Settings::values.bcat_backend); | ||
| 1269 | WriteBasicSetting(Settings::values.bcat_boxcat_local); | ||
| 1270 | WriteBasicSetting(Settings::values.network_interface); | 1270 | WriteBasicSetting(Settings::values.network_interface); |
| 1271 | 1271 | ||
| 1272 | qt_config->endGroup(); | 1272 | qt_config->endGroup(); |
diff --git a/src/yuzu/configuration/configure_input_advanced.cpp b/src/yuzu/configuration/configure_input_advanced.cpp index d20fd86b6..b30f09013 100644 --- a/src/yuzu/configuration/configure_input_advanced.cpp +++ b/src/yuzu/configuration/configure_input_advanced.cpp | |||
| @@ -88,6 +88,10 @@ ConfigureInputAdvanced::ConfigureInputAdvanced(QWidget* parent) | |||
| 88 | connect(ui->buttonMotionTouch, &QPushButton::clicked, this, | 88 | connect(ui->buttonMotionTouch, &QPushButton::clicked, this, |
| 89 | &ConfigureInputAdvanced::CallMotionTouchConfigDialog); | 89 | &ConfigureInputAdvanced::CallMotionTouchConfigDialog); |
| 90 | 90 | ||
| 91 | #ifndef _WIN32 | ||
| 92 | ui->enable_raw_input->setVisible(false); | ||
| 93 | #endif | ||
| 94 | |||
| 91 | LoadConfiguration(); | 95 | LoadConfiguration(); |
| 92 | } | 96 | } |
| 93 | 97 | ||
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp index da328d904..f31f86339 100644 --- a/src/yuzu/configuration/configure_input_player_widget.cpp +++ b/src/yuzu/configuration/configure_input_player_widget.cpp | |||
| @@ -1837,7 +1837,7 @@ void PlayerControlPreview::DrawLeftBody(QPainter& p, const QPointF center) { | |||
| 1837 | const float led_size = 5.0f; | 1837 | const float led_size = 5.0f; |
| 1838 | const QPointF led_position = sideview_center + QPointF(0, -36); | 1838 | const QPointF led_position = sideview_center + QPointF(0, -36); |
| 1839 | int led_count = 0; | 1839 | int led_count = 0; |
| 1840 | for (const auto color : led_color) { | 1840 | for (const auto& color : led_color) { |
| 1841 | p.setBrush(color); | 1841 | p.setBrush(color); |
| 1842 | DrawRectangle(p, led_position + QPointF(0, 12 * led_count++), led_size, led_size); | 1842 | DrawRectangle(p, led_position + QPointF(0, 12 * led_count++), led_size, led_size); |
| 1843 | } | 1843 | } |
| @@ -1933,7 +1933,7 @@ void PlayerControlPreview::DrawRightBody(QPainter& p, const QPointF center) { | |||
| 1933 | const float led_size = 5.0f; | 1933 | const float led_size = 5.0f; |
| 1934 | const QPointF led_position = sideview_center + QPointF(0, -36); | 1934 | const QPointF led_position = sideview_center + QPointF(0, -36); |
| 1935 | int led_count = 0; | 1935 | int led_count = 0; |
| 1936 | for (const auto color : led_color) { | 1936 | for (const auto& color : led_color) { |
| 1937 | p.setBrush(color); | 1937 | p.setBrush(color); |
| 1938 | DrawRectangle(p, led_position + QPointF(0, 12 * led_count++), led_size, led_size); | 1938 | DrawRectangle(p, led_position + QPointF(0, 12 * led_count++), led_size, led_size); |
| 1939 | } | 1939 | } |
diff --git a/src/yuzu/configuration/configure_network.cpp b/src/yuzu/configuration/configure_network.cpp index ae22f1018..cc15d36c2 100644 --- a/src/yuzu/configuration/configure_network.cpp +++ b/src/yuzu/configuration/configure_network.cpp | |||
| @@ -6,64 +6,25 @@ | |||
| 6 | #include <QtConcurrent/QtConcurrent> | 6 | #include <QtConcurrent/QtConcurrent> |
| 7 | #include "common/settings.h" | 7 | #include "common/settings.h" |
| 8 | #include "core/core.h" | 8 | #include "core/core.h" |
| 9 | #include "core/hle/service/bcat/backend/boxcat.h" | ||
| 10 | #include "core/network/network_interface.h" | 9 | #include "core/network/network_interface.h" |
| 11 | #include "ui_configure_network.h" | 10 | #include "ui_configure_network.h" |
| 12 | #include "yuzu/configuration/configure_network.h" | 11 | #include "yuzu/configuration/configure_network.h" |
| 13 | 12 | ||
| 14 | #ifdef YUZU_ENABLE_BOXCAT | ||
| 15 | namespace { | ||
| 16 | QString FormatEventStatusString(const Service::BCAT::EventStatus& status) { | ||
| 17 | QString out; | ||
| 18 | |||
| 19 | if (status.header.has_value()) { | ||
| 20 | out += QStringLiteral("<i>%1</i><br>").arg(QString::fromStdString(*status.header)); | ||
| 21 | } | ||
| 22 | |||
| 23 | if (status.events.size() == 1) { | ||
| 24 | out += QStringLiteral("%1<br>").arg(QString::fromStdString(status.events.front())); | ||
| 25 | } else { | ||
| 26 | for (const auto& event : status.events) { | ||
| 27 | out += QStringLiteral("- %1<br>").arg(QString::fromStdString(event)); | ||
| 28 | } | ||
| 29 | } | ||
| 30 | |||
| 31 | if (status.footer.has_value()) { | ||
| 32 | out += QStringLiteral("<i>%1</i><br>").arg(QString::fromStdString(*status.footer)); | ||
| 33 | } | ||
| 34 | |||
| 35 | return out; | ||
| 36 | } | ||
| 37 | } // Anonymous namespace | ||
| 38 | #endif | ||
| 39 | |||
| 40 | ConfigureNetwork::ConfigureNetwork(QWidget* parent) | 13 | ConfigureNetwork::ConfigureNetwork(QWidget* parent) |
| 41 | : QWidget(parent), ui(std::make_unique<Ui::ConfigureNetwork>()) { | 14 | : QWidget(parent), ui(std::make_unique<Ui::ConfigureNetwork>()) { |
| 42 | ui->setupUi(this); | 15 | ui->setupUi(this); |
| 43 | 16 | ||
| 44 | ui->bcat_source->addItem(QStringLiteral("None")); | ||
| 45 | ui->bcat_empty_label->setHidden(true); | ||
| 46 | ui->bcat_empty_header->setHidden(true); | ||
| 47 | |||
| 48 | #ifdef YUZU_ENABLE_BOXCAT | ||
| 49 | ui->bcat_source->addItem(QStringLiteral("Boxcat"), QStringLiteral("boxcat")); | ||
| 50 | #endif | ||
| 51 | |||
| 52 | ui->network_interface->addItem(tr("None")); | 17 | ui->network_interface->addItem(tr("None")); |
| 53 | for (const auto& iface : Network::GetAvailableNetworkInterfaces()) { | 18 | for (const auto& iface : Network::GetAvailableNetworkInterfaces()) { |
| 54 | ui->network_interface->addItem(QString::fromStdString(iface.name)); | 19 | ui->network_interface->addItem(QString::fromStdString(iface.name)); |
| 55 | } | 20 | } |
| 56 | 21 | ||
| 57 | connect(ui->bcat_source, QOverload<int>::of(&QComboBox::currentIndexChanged), this, | ||
| 58 | &ConfigureNetwork::OnBCATImplChanged); | ||
| 59 | |||
| 60 | this->SetConfiguration(); | 22 | this->SetConfiguration(); |
| 61 | } | 23 | } |
| 62 | 24 | ||
| 63 | ConfigureNetwork::~ConfigureNetwork() = default; | 25 | ConfigureNetwork::~ConfigureNetwork() = default; |
| 64 | 26 | ||
| 65 | void ConfigureNetwork::ApplyConfiguration() { | 27 | void ConfigureNetwork::ApplyConfiguration() { |
| 66 | Settings::values.bcat_backend = ui->bcat_source->currentText().toLower().toStdString(); | ||
| 67 | Settings::values.network_interface = ui->network_interface->currentText().toStdString(); | 28 | Settings::values.network_interface = ui->network_interface->currentText().toStdString(); |
| 68 | } | 29 | } |
| 69 | 30 | ||
| @@ -74,86 +35,8 @@ void ConfigureNetwork::RetranslateUi() { | |||
| 74 | void ConfigureNetwork::SetConfiguration() { | 35 | void ConfigureNetwork::SetConfiguration() { |
| 75 | const bool runtime_lock = !Core::System::GetInstance().IsPoweredOn(); | 36 | const bool runtime_lock = !Core::System::GetInstance().IsPoweredOn(); |
| 76 | 37 | ||
| 77 | const int index = | ||
| 78 | ui->bcat_source->findData(QString::fromStdString(Settings::values.bcat_backend.GetValue())); | ||
| 79 | ui->bcat_source->setCurrentIndex(index == -1 ? 0 : index); | ||
| 80 | |||
| 81 | const std::string& network_interface = Settings::values.network_interface.GetValue(); | 38 | const std::string& network_interface = Settings::values.network_interface.GetValue(); |
| 82 | 39 | ||
| 83 | ui->network_interface->setCurrentText(QString::fromStdString(network_interface)); | 40 | ui->network_interface->setCurrentText(QString::fromStdString(network_interface)); |
| 84 | ui->network_interface->setEnabled(runtime_lock); | 41 | ui->network_interface->setEnabled(runtime_lock); |
| 85 | } | 42 | } |
| 86 | |||
| 87 | std::pair<QString, QString> ConfigureNetwork::BCATDownloadEvents() { | ||
| 88 | #ifdef YUZU_ENABLE_BOXCAT | ||
| 89 | std::optional<std::string> global; | ||
| 90 | std::map<std::string, Service::BCAT::EventStatus> map; | ||
| 91 | const auto res = Service::BCAT::Boxcat::GetStatus(global, map); | ||
| 92 | |||
| 93 | switch (res) { | ||
| 94 | case Service::BCAT::Boxcat::StatusResult::Success: | ||
| 95 | break; | ||
| 96 | case Service::BCAT::Boxcat::StatusResult::Offline: | ||
| 97 | return {QString{}, | ||
| 98 | tr("The boxcat service is offline or you are not connected to the internet.")}; | ||
| 99 | case Service::BCAT::Boxcat::StatusResult::ParseError: | ||
| 100 | return {QString{}, | ||
| 101 | tr("There was an error while processing the boxcat event data. Contact the yuzu " | ||
| 102 | "developers.")}; | ||
| 103 | case Service::BCAT::Boxcat::StatusResult::BadClientVersion: | ||
| 104 | return {QString{}, | ||
| 105 | tr("The version of yuzu you are using is either too new or too old for the server. " | ||
| 106 | "Try updating to the latest official release of yuzu.")}; | ||
| 107 | } | ||
| 108 | |||
| 109 | if (map.empty()) { | ||
| 110 | return {QStringLiteral("Current Boxcat Events"), | ||
| 111 | tr("There are currently no events on boxcat.")}; | ||
| 112 | } | ||
| 113 | |||
| 114 | QString out; | ||
| 115 | |||
| 116 | if (global.has_value()) { | ||
| 117 | out += QStringLiteral("%1<br>").arg(QString::fromStdString(*global)); | ||
| 118 | } | ||
| 119 | |||
| 120 | for (const auto& [key, value] : map) { | ||
| 121 | out += QStringLiteral("%1<b>%2</b><br>%3") | ||
| 122 | .arg(out.isEmpty() ? QString{} : QStringLiteral("<br>")) | ||
| 123 | .arg(QString::fromStdString(key)) | ||
| 124 | .arg(FormatEventStatusString(value)); | ||
| 125 | } | ||
| 126 | return {tr("Current Boxcat Events"), std::move(out)}; | ||
| 127 | #else | ||
| 128 | return {tr("Current Boxcat Events"), tr("There are currently no events on boxcat.")}; | ||
| 129 | #endif | ||
| 130 | } | ||
| 131 | |||
| 132 | void ConfigureNetwork::OnBCATImplChanged() { | ||
| 133 | #ifdef YUZU_ENABLE_BOXCAT | ||
| 134 | const auto boxcat = ui->bcat_source->currentText() == QStringLiteral("Boxcat"); | ||
| 135 | ui->bcat_empty_header->setHidden(!boxcat); | ||
| 136 | ui->bcat_empty_label->setHidden(!boxcat); | ||
| 137 | ui->bcat_empty_header->setText(QString{}); | ||
| 138 | ui->bcat_empty_label->setText(tr("Yuzu is retrieving the latest boxcat status...")); | ||
| 139 | |||
| 140 | if (!boxcat) | ||
| 141 | return; | ||
| 142 | |||
| 143 | const auto future = QtConcurrent::run([this] { return BCATDownloadEvents(); }); | ||
| 144 | |||
| 145 | watcher.setFuture(future); | ||
| 146 | connect(&watcher, &QFutureWatcher<std::pair<QString, QString>>::finished, this, | ||
| 147 | [this] { OnUpdateBCATEmptyLabel(watcher.result()); }); | ||
| 148 | #endif | ||
| 149 | } | ||
| 150 | |||
| 151 | void ConfigureNetwork::OnUpdateBCATEmptyLabel(std::pair<QString, QString> string) { | ||
| 152 | #ifdef YUZU_ENABLE_BOXCAT | ||
| 153 | const auto boxcat = ui->bcat_source->currentText() == QStringLiteral("Boxcat"); | ||
| 154 | if (boxcat) { | ||
| 155 | ui->bcat_empty_header->setText(string.first); | ||
| 156 | ui->bcat_empty_label->setText(string.second); | ||
| 157 | } | ||
| 158 | #endif | ||
| 159 | } | ||
diff --git a/src/yuzu/configuration/configure_network.h b/src/yuzu/configuration/configure_network.h index 442b68e6b..028fd4acc 100644 --- a/src/yuzu/configuration/configure_network.h +++ b/src/yuzu/configuration/configure_network.h | |||
| @@ -25,10 +25,5 @@ public: | |||
| 25 | private: | 25 | private: |
| 26 | void SetConfiguration(); | 26 | void SetConfiguration(); |
| 27 | 27 | ||
| 28 | std::pair<QString, QString> BCATDownloadEvents(); | ||
| 29 | void OnBCATImplChanged(); | ||
| 30 | void OnUpdateBCATEmptyLabel(std::pair<QString, QString> string); | ||
| 31 | |||
| 32 | std::unique_ptr<Ui::ConfigureNetwork> ui; | 28 | std::unique_ptr<Ui::ConfigureNetwork> ui; |
| 33 | QFutureWatcher<std::pair<QString, QString>> watcher{this}; | ||
| 34 | }; | 29 | }; |
diff --git a/src/yuzu/configuration/configure_network.ui b/src/yuzu/configuration/configure_network.ui index 5f9b7e97b..9a79262f0 100644 --- a/src/yuzu/configuration/configure_network.ui +++ b/src/yuzu/configuration/configure_network.ui | |||
| @@ -35,92 +35,6 @@ | |||
| 35 | </layout> | 35 | </layout> |
| 36 | </widget> | 36 | </widget> |
| 37 | </item> | 37 | </item> |
| 38 | <item> | ||
| 39 | <widget class="QGroupBox" name="groupBox"> | ||
| 40 | <property name="title"> | ||
| 41 | <string>BCAT</string> | ||
| 42 | </property> | ||
| 43 | <layout class="QGridLayout" name="gridLayout"> | ||
| 44 | <item row="3" column="0"> | ||
| 45 | <widget class="QLabel" name="bcat_empty_header"> | ||
| 46 | <property name="text"> | ||
| 47 | <string/> | ||
| 48 | </property> | ||
| 49 | <property name="alignment"> | ||
| 50 | <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> | ||
| 51 | </property> | ||
| 52 | <property name="wordWrap"> | ||
| 53 | <bool>true</bool> | ||
| 54 | </property> | ||
| 55 | </widget> | ||
| 56 | </item> | ||
| 57 | <item row="0" column="0"> | ||
| 58 | <widget class="QLabel" name="label"> | ||
| 59 | <property name="maximumSize"> | ||
| 60 | <size> | ||
| 61 | <width>16777215</width> | ||
| 62 | <height>16777215</height> | ||
| 63 | </size> | ||
| 64 | </property> | ||
| 65 | <property name="text"> | ||
| 66 | <string>BCAT Backend</string> | ||
| 67 | </property> | ||
| 68 | </widget> | ||
| 69 | </item> | ||
| 70 | <item row="1" column="1" colspan="2"> | ||
| 71 | <widget class="QLabel" name="label_2"> | ||
| 72 | <property name="maximumSize"> | ||
| 73 | <size> | ||
| 74 | <width>260</width> | ||
| 75 | <height>16777215</height> | ||
| 76 | </size> | ||
| 77 | </property> | ||
| 78 | <property name="text"> | ||
| 79 | <string>BCAT is Nintendo's way of sending data to games to engage its community and unlock additional content.</string> | ||
| 80 | </property> | ||
| 81 | <property name="wordWrap"> | ||
| 82 | <bool>true</bool> | ||
| 83 | </property> | ||
| 84 | </widget> | ||
| 85 | </item> | ||
| 86 | <item row="2" column="1" colspan="2"> | ||
| 87 | <widget class="QLabel" name="label_3"> | ||
| 88 | <property name="text"> | ||
| 89 | <string><html><head/><body><p><a href="https://yuzu-emu.org/help/feature/boxcat"><span style=" text-decoration: underline; color:#0000ff;">Learn more about BCAT, Boxcat, and Current Events</span></a></p></body></html></string> | ||
| 90 | </property> | ||
| 91 | <property name="openExternalLinks"> | ||
| 92 | <bool>true</bool> | ||
| 93 | </property> | ||
| 94 | </widget> | ||
| 95 | </item> | ||
| 96 | <item row="0" column="1" colspan="2"> | ||
| 97 | <widget class="QComboBox" name="bcat_source"/> | ||
| 98 | </item> | ||
| 99 | <item row="3" column="1" colspan="2"> | ||
| 100 | <widget class="QLabel" name="bcat_empty_label"> | ||
| 101 | <property name="enabled"> | ||
| 102 | <bool>true</bool> | ||
| 103 | </property> | ||
| 104 | <property name="maximumSize"> | ||
| 105 | <size> | ||
| 106 | <width>260</width> | ||
| 107 | <height>16777215</height> | ||
| 108 | </size> | ||
| 109 | </property> | ||
| 110 | <property name="text"> | ||
| 111 | <string/> | ||
| 112 | </property> | ||
| 113 | <property name="alignment"> | ||
| 114 | <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> | ||
| 115 | </property> | ||
| 116 | <property name="wordWrap"> | ||
| 117 | <bool>true</bool> | ||
| 118 | </property> | ||
| 119 | </widget> | ||
| 120 | </item> | ||
| 121 | </layout> | ||
| 122 | </widget> | ||
| 123 | </item> | ||
| 124 | </layout> | 38 | </layout> |
| 125 | </item> | 39 | </item> |
| 126 | <item> | 40 | <item> |
diff --git a/src/yuzu/configuration/configure_profile_manager.cpp b/src/yuzu/configuration/configure_profile_manager.cpp index ac849b01d..136614bf8 100644 --- a/src/yuzu/configuration/configure_profile_manager.cpp +++ b/src/yuzu/configuration/configure_profile_manager.cpp | |||
| @@ -76,7 +76,7 @@ QString GetProfileUsernameFromUser(QWidget* parent, const QString& description_t | |||
| 76 | } | 76 | } |
| 77 | } // Anonymous namespace | 77 | } // Anonymous namespace |
| 78 | 78 | ||
| 79 | ConfigureProfileManager ::ConfigureProfileManager(QWidget* parent) | 79 | ConfigureProfileManager::ConfigureProfileManager(QWidget* parent) |
| 80 | : QWidget(parent), ui(new Ui::ConfigureProfileManager), | 80 | : QWidget(parent), ui(new Ui::ConfigureProfileManager), |
| 81 | profile_manager(std::make_unique<Service::Account::ProfileManager>()) { | 81 | profile_manager(std::make_unique<Service::Account::ProfileManager>()) { |
| 82 | ui->setupUi(this); | 82 | ui->setupUi(this); |
diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 99a5df241..24a67ad46 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | #include "common/assert.h" | 12 | #include "common/assert.h" |
| 13 | #include "common/settings.h" | 13 | #include "common/settings.h" |
| 14 | #include "core/core.h" | 14 | #include "core/core.h" |
| 15 | #include "core/hle/service/time/time.h" | 15 | #include "core/hle/service/time/time_manager.h" |
| 16 | #include "ui_configure_system.h" | 16 | #include "ui_configure_system.h" |
| 17 | #include "yuzu/configuration/configuration_shared.h" | 17 | #include "yuzu/configuration/configuration_shared.h" |
| 18 | #include "yuzu/configuration/configure_system.h" | 18 | #include "yuzu/configuration/configure_system.h" |
diff --git a/src/yuzu/configuration/configure_tas.cpp b/src/yuzu/configuration/configure_tas.cpp index b666b175a..8e5a4c72d 100644 --- a/src/yuzu/configuration/configure_tas.cpp +++ b/src/yuzu/configuration/configure_tas.cpp | |||
| @@ -18,6 +18,7 @@ ConfigureTasDialog::ConfigureTasDialog(QWidget* parent) | |||
| 18 | 18 | ||
| 19 | setFocusPolicy(Qt::ClickFocus); | 19 | setFocusPolicy(Qt::ClickFocus); |
| 20 | setWindowTitle(tr("TAS Configuration")); | 20 | setWindowTitle(tr("TAS Configuration")); |
| 21 | setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); | ||
| 21 | 22 | ||
| 22 | connect(ui->tas_path_button, &QToolButton::pressed, this, | 23 | connect(ui->tas_path_button, &QToolButton::pressed, this, |
| 23 | [this] { SetDirectory(DirectoryTarget::TAS, ui->tas_path_edit); }); | 24 | [this] { SetDirectory(DirectoryTarget::TAS, ui->tas_path_edit); }); |
diff --git a/src/yuzu/configuration/configure_tas.ui b/src/yuzu/configuration/configure_tas.ui index 95575ed9d..3972f9083 100644 --- a/src/yuzu/configuration/configure_tas.ui +++ b/src/yuzu/configuration/configure_tas.ui | |||
| @@ -1,153 +1,194 @@ | |||
| 1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | <ui version="4.0"> | 2 | <ui version="4.0"> |
| 3 | <class>ConfigureTas</class> | 3 | <class>ConfigureTas</class> |
| 4 | <widget class="QDialog" name="ConfigureTas"> | 4 | <widget class="QDialog" name="ConfigureTas"> |
| 5 | <layout class="QVBoxLayout" name="verticalLayout_1"> | 5 | <property name="geometry"> |
| 6 | <item> | 6 | <rect> |
| 7 | <layout class="QHBoxLayout" name="horizontalLayout_1"> | 7 | <x>0</x> |
| 8 | <item> | 8 | <y>0</y> |
| 9 | <widget class="QGroupBox" name="groupBox_1"> | 9 | <width>337</width> |
| 10 | <property name="title"> | 10 | <height>316</height> |
| 11 | <string>TAS</string> | 11 | </rect> |
| 12 | </property> | 12 | </property> |
| 13 | <layout class="QGridLayout" name="gridLayout_1"> | 13 | <layout class="QVBoxLayout" name="verticalLayout_1"> |
| 14 | <item row="0" column="0" colspan="4"> | 14 | <item> |
| 15 | <widget class="QLabel" name="label_1"> | 15 | <layout class="QHBoxLayout" name="horizontalLayout_1"> |
| 16 | <property name="text"> | 16 | <item> |
| 17 | <string>Reads controller input from scripts in the same format as TAS-nx scripts.<br/>For a more detailed explanation please consult the FAQ on the yuzu website.</string> | 17 | <widget class="QGroupBox" name="groupBox_1"> |
| 18 | </property> | 18 | <property name="title"> |
| 19 | </widget> | 19 | <string>TAS</string> |
| 20 | </item> | 20 | </property> |
| 21 | <item row="1" column="0" colspan="4"> | 21 | <layout class="QGridLayout" name="gridLayout_1"> |
| 22 | <widget class="QLabel" name="label_2"> | 22 | <item row="0" column="0" colspan="4"> |
| 23 | <property name="text"> | 23 | <widget class="QLabel" name="label_1"> |
| 24 | <string>To check which hotkeys control the playback/recording, please refer to the Hotkey settings (General -> Hotkeys).</string> | 24 | <property name="text"> |
| 25 | </property> | 25 | <string>Reads controller input from scripts in the same format as TAS-nx scripts.<br/>For a more detailed explanation please consult the FAQ on the yuzu website.</string> |
| 26 | <property name="wordWrap"> | ||
| 27 | <bool>true</bool> | ||
| 28 | </property> | ||
| 29 | </widget> | ||
| 30 | </item> | ||
| 31 | <item row="2" column="0" colspan="4"> | ||
| 32 | <widget class="QLabel" name="label_3"> | ||
| 33 | <property name="text"> | ||
| 34 | <string>WARNING: This is an experimental feature.<br/>It will not play back scripts frame perfectly with the current, imperfect syncing method.</string> | ||
| 35 | </property> | ||
| 36 | <property name="wordWrap"> | ||
| 37 | <bool>true</bool> | ||
| 38 | </property> | ||
| 39 | </widget> | ||
| 40 | </item> | ||
| 41 | </layout> | ||
| 42 | </widget> | ||
| 43 | </item> | ||
| 44 | </layout> | ||
| 45 | </item> | ||
| 46 | <item> | ||
| 47 | <layout class="QHBoxLayout" name="horizontalLayout_2"> | ||
| 48 | <item> | ||
| 49 | <widget class="QGroupBox" name="groupBox_2"> | ||
| 50 | <property name="title"> | ||
| 51 | <string>Settings</string> | ||
| 52 | </property> | ||
| 53 | <layout class="QGridLayout" name="gridLayout_2"> | ||
| 54 | <item row="0" column="0" colspan="4"> | ||
| 55 | <widget class="QCheckBox" name="tas_enable"> | ||
| 56 | <property name="text"> | ||
| 57 | <string>Enable TAS features</string> | ||
| 58 | </property> | ||
| 59 | </widget> | ||
| 60 | </item> | ||
| 61 | <item row="1" column="0" colspan="4"> | ||
| 62 | <widget class="QCheckBox" name="tas_control_swap"> | ||
| 63 | <property name="text"> | ||
| 64 | <string>Automatic controller profile swapping</string> | ||
| 65 | </property> | ||
| 66 | </widget> | ||
| 67 | </item> | ||
| 68 | <item row="2" column="0" colspan="4"> | ||
| 69 | <widget class="QCheckBox" name="tas_loop_script"> | ||
| 70 | <property name="text"> | ||
| 71 | <string>Loop script</string> | ||
| 72 | </property> | ||
| 73 | </widget> | ||
| 74 | </item> | ||
| 75 | <item row="3" column="0" colspan="4"> | ||
| 76 | <widget class="QCheckBox" name="tas_pause_on_load"> | ||
| 77 | <property name="enabled"> | ||
| 78 | <bool>false</bool> | ||
| 79 | </property> | ||
| 80 | <property name="text"> | ||
| 81 | <string>Pause execution during loads</string> | ||
| 82 | </property> | ||
| 83 | </widget> | ||
| 84 | </item> | ||
| 85 | </layout> | ||
| 86 | </widget> | ||
| 87 | </item> | ||
| 88 | </layout> | ||
| 89 | </item> | ||
| 90 | <item> | ||
| 91 | <layout class="QHBoxLayout" name="horizontalLayout_3"> | ||
| 92 | <item> | ||
| 93 | <widget class="QGroupBox" name="groupBox_3"> | ||
| 94 | <property name="title"> | ||
| 95 | <string>Script Directory</string> | ||
| 96 | </property> | ||
| 97 | <layout class="QGridLayout" name="gridLayout_3"> | ||
| 98 | <item row="0" column="0"> | ||
| 99 | <widget class="QLabel" name="label_4"> | ||
| 100 | <property name="text"> | ||
| 101 | <string>Path</string> | ||
| 102 | </property> | ||
| 103 | </widget> | ||
| 104 | </item> | ||
| 105 | <item row="0" column="3"> | ||
| 106 | <widget class="QToolButton" name="tas_path_button"> | ||
| 107 | <property name="text"> | ||
| 108 | <string>...</string> | ||
| 109 | </property> | ||
| 110 | </widget> | ||
| 111 | </item> | ||
| 112 | <item row="0" column="2"> | ||
| 113 | <widget class="QLineEdit" name="tas_path_edit"/> | ||
| 114 | </item> | ||
| 115 | </layout> | ||
| 116 | </widget> | ||
| 117 | </item> | ||
| 118 | </layout> | ||
| 119 | </item> | ||
| 120 | <item> | ||
| 121 | <widget class="QDialogButtonBox" name="buttonBox"> | ||
| 122 | <property name="sizePolicy"> | ||
| 123 | <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> | ||
| 124 | <horstretch>0</horstretch> | ||
| 125 | <verstretch>0</verstretch> | ||
| 126 | </sizepolicy> | ||
| 127 | </property> | 26 | </property> |
| 128 | <property name="orientation"> | 27 | </widget> |
| 129 | <enum>Qt::Horizontal</enum> | 28 | </item> |
| 29 | <item row="1" column="0" colspan="4"> | ||
| 30 | <widget class="QLabel" name="label_2"> | ||
| 31 | <property name="text"> | ||
| 32 | <string>To check which hotkeys control the playback/recording, please refer to the Hotkey settings (General -> Hotkeys).</string> | ||
| 130 | </property> | 33 | </property> |
| 131 | <property name="standardButtons"> | 34 | <property name="wordWrap"> |
| 132 | <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> | 35 | <bool>true</bool> |
| 133 | </property> | 36 | </property> |
| 134 | </widget> | 37 | </widget> |
| 135 | </item> | 38 | </item> |
| 39 | <item row="2" column="0" colspan="4"> | ||
| 40 | <widget class="QLabel" name="label_3"> | ||
| 41 | <property name="text"> | ||
| 42 | <string>WARNING: This is an experimental feature.<br/>It will not play back scripts frame perfectly with the current, imperfect syncing method.</string> | ||
| 43 | </property> | ||
| 44 | <property name="wordWrap"> | ||
| 45 | <bool>true</bool> | ||
| 46 | </property> | ||
| 47 | </widget> | ||
| 48 | </item> | ||
| 49 | </layout> | ||
| 50 | </widget> | ||
| 51 | </item> | ||
| 52 | </layout> | ||
| 53 | </item> | ||
| 54 | <item> | ||
| 55 | <layout class="QHBoxLayout" name="horizontalLayout_2"> | ||
| 56 | <item> | ||
| 57 | <widget class="QGroupBox" name="groupBox_2"> | ||
| 58 | <property name="title"> | ||
| 59 | <string>Settings</string> | ||
| 60 | </property> | ||
| 61 | <layout class="QGridLayout" name="gridLayout_2"> | ||
| 62 | <item row="0" column="0" colspan="4"> | ||
| 63 | <widget class="QCheckBox" name="tas_enable"> | ||
| 64 | <property name="text"> | ||
| 65 | <string>Enable TAS features</string> | ||
| 66 | </property> | ||
| 67 | </widget> | ||
| 68 | </item> | ||
| 69 | <item row="1" column="0" colspan="4"> | ||
| 70 | <widget class="QCheckBox" name="tas_control_swap"> | ||
| 71 | <property name="text"> | ||
| 72 | <string>Automatic controller profile swapping</string> | ||
| 73 | </property> | ||
| 74 | </widget> | ||
| 75 | </item> | ||
| 76 | <item row="2" column="0" colspan="4"> | ||
| 77 | <widget class="QCheckBox" name="tas_loop_script"> | ||
| 78 | <property name="text"> | ||
| 79 | <string>Loop script</string> | ||
| 80 | </property> | ||
| 81 | </widget> | ||
| 82 | </item> | ||
| 83 | <item row="3" column="0" colspan="4"> | ||
| 84 | <widget class="QCheckBox" name="tas_pause_on_load"> | ||
| 85 | <property name="enabled"> | ||
| 86 | <bool>false</bool> | ||
| 87 | </property> | ||
| 88 | <property name="text"> | ||
| 89 | <string>Pause execution during loads</string> | ||
| 90 | </property> | ||
| 91 | </widget> | ||
| 92 | </item> | ||
| 93 | </layout> | ||
| 94 | </widget> | ||
| 95 | </item> | ||
| 96 | </layout> | ||
| 97 | </item> | ||
| 98 | <item> | ||
| 99 | <layout class="QHBoxLayout" name="horizontalLayout_3"> | ||
| 100 | <item> | ||
| 101 | <widget class="QGroupBox" name="groupBox_3"> | ||
| 102 | <property name="title"> | ||
| 103 | <string>Script Directory</string> | ||
| 104 | </property> | ||
| 105 | <layout class="QGridLayout" name="gridLayout_3"> | ||
| 106 | <item row="0" column="0"> | ||
| 107 | <widget class="QLabel" name="label_4"> | ||
| 108 | <property name="text"> | ||
| 109 | <string>Path</string> | ||
| 110 | </property> | ||
| 111 | </widget> | ||
| 112 | </item> | ||
| 113 | <item row="0" column="3"> | ||
| 114 | <widget class="QToolButton" name="tas_path_button"> | ||
| 115 | <property name="text"> | ||
| 116 | <string>...</string> | ||
| 117 | </property> | ||
| 118 | </widget> | ||
| 119 | </item> | ||
| 120 | <item row="0" column="2"> | ||
| 121 | <widget class="QLineEdit" name="tas_path_edit"/> | ||
| 122 | </item> | ||
| 123 | </layout> | ||
| 124 | </widget> | ||
| 125 | </item> | ||
| 136 | </layout> | 126 | </layout> |
| 137 | </widget> | 127 | </item> |
| 138 | <resources/> | 128 | <item> |
| 139 | <connections> | 129 | <spacer name="verticalSpacer"> |
| 140 | <connection> | 130 | <property name="orientation"> |
| 141 | <sender>buttonBox</sender> | 131 | <enum>Qt::Vertical</enum> |
| 142 | <signal>accepted()</signal> | 132 | </property> |
| 143 | <receiver>ConfigureTas</receiver> | 133 | <property name="sizeHint" stdset="0"> |
| 144 | <slot>accept()</slot> | 134 | <size> |
| 145 | </connection> | 135 | <width>20</width> |
| 146 | <connection> | 136 | <height>40</height> |
| 147 | <sender>buttonBox</sender> | 137 | </size> |
| 148 | <signal>rejected()</signal> | 138 | </property> |
| 149 | <receiver>ConfigureTas</receiver> | 139 | </spacer> |
| 150 | <slot>reject()</slot> | 140 | </item> |
| 151 | </connection> | 141 | <item> |
| 152 | </connections> | 142 | <widget class="QDialogButtonBox" name="buttonBox"> |
| 143 | <property name="sizePolicy"> | ||
| 144 | <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> | ||
| 145 | <horstretch>0</horstretch> | ||
| 146 | <verstretch>0</verstretch> | ||
| 147 | </sizepolicy> | ||
| 148 | </property> | ||
| 149 | <property name="orientation"> | ||
| 150 | <enum>Qt::Horizontal</enum> | ||
| 151 | </property> | ||
| 152 | <property name="standardButtons"> | ||
| 153 | <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> | ||
| 154 | </property> | ||
| 155 | </widget> | ||
| 156 | </item> | ||
| 157 | </layout> | ||
| 158 | </widget> | ||
| 159 | <resources/> | ||
| 160 | <connections> | ||
| 161 | <connection> | ||
| 162 | <sender>buttonBox</sender> | ||
| 163 | <signal>accepted()</signal> | ||
| 164 | <receiver>ConfigureTas</receiver> | ||
| 165 | <slot>accept()</slot> | ||
| 166 | <hints> | ||
| 167 | <hint type="sourcelabel"> | ||
| 168 | <x>20</x> | ||
| 169 | <y>20</y> | ||
| 170 | </hint> | ||
| 171 | <hint type="destinationlabel"> | ||
| 172 | <x>20</x> | ||
| 173 | <y>20</y> | ||
| 174 | </hint> | ||
| 175 | </hints> | ||
| 176 | </connection> | ||
| 177 | <connection> | ||
| 178 | <sender>buttonBox</sender> | ||
| 179 | <signal>rejected()</signal> | ||
| 180 | <receiver>ConfigureTas</receiver> | ||
| 181 | <slot>reject()</slot> | ||
| 182 | <hints> | ||
| 183 | <hint type="sourcelabel"> | ||
| 184 | <x>20</x> | ||
| 185 | <y>20</y> | ||
| 186 | </hint> | ||
| 187 | <hint type="destinationlabel"> | ||
| 188 | <x>20</x> | ||
| 189 | <y>20</y> | ||
| 190 | </hint> | ||
| 191 | </hints> | ||
| 192 | </connection> | ||
| 193 | </connections> | ||
| 153 | </ui> | 194 | </ui> |
diff --git a/src/yuzu/debugger/profiler.cpp b/src/yuzu/debugger/profiler.cpp index 7a6f84d96..33110685a 100644 --- a/src/yuzu/debugger/profiler.cpp +++ b/src/yuzu/debugger/profiler.cpp | |||
| @@ -143,24 +143,28 @@ void MicroProfileWidget::hideEvent(QHideEvent* ev) { | |||
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | void MicroProfileWidget::mouseMoveEvent(QMouseEvent* ev) { | 145 | void MicroProfileWidget::mouseMoveEvent(QMouseEvent* ev) { |
| 146 | MicroProfileMousePosition(ev->pos().x() / x_scale, ev->pos().y() / y_scale, 0); | 146 | const auto mouse_position = ev->pos(); |
| 147 | MicroProfileMousePosition(mouse_position.x() / x_scale, mouse_position.y() / y_scale, 0); | ||
| 147 | ev->accept(); | 148 | ev->accept(); |
| 148 | } | 149 | } |
| 149 | 150 | ||
| 150 | void MicroProfileWidget::mousePressEvent(QMouseEvent* ev) { | 151 | void MicroProfileWidget::mousePressEvent(QMouseEvent* ev) { |
| 151 | MicroProfileMousePosition(ev->pos().x() / x_scale, ev->pos().y() / y_scale, 0); | 152 | const auto mouse_position = ev->pos(); |
| 153 | MicroProfileMousePosition(mouse_position.x() / x_scale, mouse_position.y() / y_scale, 0); | ||
| 152 | MicroProfileMouseButton(ev->buttons() & Qt::LeftButton, ev->buttons() & Qt::RightButton); | 154 | MicroProfileMouseButton(ev->buttons() & Qt::LeftButton, ev->buttons() & Qt::RightButton); |
| 153 | ev->accept(); | 155 | ev->accept(); |
| 154 | } | 156 | } |
| 155 | 157 | ||
| 156 | void MicroProfileWidget::mouseReleaseEvent(QMouseEvent* ev) { | 158 | void MicroProfileWidget::mouseReleaseEvent(QMouseEvent* ev) { |
| 157 | MicroProfileMousePosition(ev->pos().x() / x_scale, ev->pos().y() / y_scale, 0); | 159 | const auto mouse_position = ev->pos(); |
| 160 | MicroProfileMousePosition(mouse_position.x() / x_scale, mouse_position.y() / y_scale, 0); | ||
| 158 | MicroProfileMouseButton(ev->buttons() & Qt::LeftButton, ev->buttons() & Qt::RightButton); | 161 | MicroProfileMouseButton(ev->buttons() & Qt::LeftButton, ev->buttons() & Qt::RightButton); |
| 159 | ev->accept(); | 162 | ev->accept(); |
| 160 | } | 163 | } |
| 161 | 164 | ||
| 162 | void MicroProfileWidget::wheelEvent(QWheelEvent* ev) { | 165 | void MicroProfileWidget::wheelEvent(QWheelEvent* ev) { |
| 163 | MicroProfileMousePosition(ev->pos().x() / x_scale, ev->pos().y() / y_scale, | 166 | const auto wheel_position = ev->position().toPoint(); |
| 167 | MicroProfileMousePosition(wheel_position.x() / x_scale, wheel_position.y() / y_scale, | ||
| 164 | ev->angleDelta().y() / 120); | 168 | ev->angleDelta().y() / 120); |
| 165 | ev->accept(); | 169 | ev->accept(); |
| 166 | } | 170 | } |
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp index f9d949e75..ba54423ff 100644 --- a/src/yuzu/game_list.cpp +++ b/src/yuzu/game_list.cpp | |||
| @@ -159,8 +159,7 @@ GameListSearchField::GameListSearchField(GameList* parent) : QWidget{parent} { | |||
| 159 | * @return true if the haystack contains all words of userinput | 159 | * @return true if the haystack contains all words of userinput |
| 160 | */ | 160 | */ |
| 161 | static bool ContainsAllWords(const QString& haystack, const QString& userinput) { | 161 | static bool ContainsAllWords(const QString& haystack, const QString& userinput) { |
| 162 | const QStringList userinput_split = | 162 | const QStringList userinput_split = userinput.split(QLatin1Char{' '}, Qt::SkipEmptyParts); |
| 163 | userinput.split(QLatin1Char{' '}, QString::SplitBehavior::SkipEmptyParts); | ||
| 164 | 163 | ||
| 165 | return std::all_of(userinput_split.begin(), userinput_split.end(), | 164 | return std::all_of(userinput_split.begin(), userinput_split.end(), |
| 166 | [&haystack](const QString& s) { return haystack.contains(s); }); | 165 | [&haystack](const QString& s) { return haystack.contains(s); }); |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 3c2824362..552c2cc63 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -1384,6 +1384,9 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t | |||
| 1384 | system.RegisterExecuteProgramCallback( | 1384 | system.RegisterExecuteProgramCallback( |
| 1385 | [this](std::size_t program_index) { render_window->ExecuteProgram(program_index); }); | 1385 | [this](std::size_t program_index) { render_window->ExecuteProgram(program_index); }); |
| 1386 | 1386 | ||
| 1387 | // Register an Exit callback such that Core can exit the currently running application. | ||
| 1388 | system.RegisterExitCallback([this]() { render_window->Exit(); }); | ||
| 1389 | |||
| 1387 | connect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame); | 1390 | connect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame); |
| 1388 | connect(render_window, &GRenderWindow::MouseActivity, this, &GMainWindow::OnMouseActivity); | 1391 | connect(render_window, &GRenderWindow::MouseActivity, this, &GMainWindow::OnMouseActivity); |
| 1389 | // BlockingQueuedConnection is important here, it makes sure we've finished refreshing our views | 1392 | // BlockingQueuedConnection is important here, it makes sure we've finished refreshing our views |
| @@ -2469,6 +2472,10 @@ void GMainWindow::OnExecuteProgram(std::size_t program_index) { | |||
| 2469 | BootGame(last_filename_booted, 0, program_index); | 2472 | BootGame(last_filename_booted, 0, program_index); |
| 2470 | } | 2473 | } |
| 2471 | 2474 | ||
| 2475 | void GMainWindow::OnExit() { | ||
| 2476 | OnStopGame(); | ||
| 2477 | } | ||
| 2478 | |||
| 2472 | void GMainWindow::ErrorDisplayDisplayError(QString error_code, QString error_text) { | 2479 | void GMainWindow::ErrorDisplayDisplayError(QString error_code, QString error_text) { |
| 2473 | OverlayDialog dialog(render_window, Core::System::GetInstance(), error_code, error_text, | 2480 | OverlayDialog dialog(render_window, Core::System::GetInstance(), error_code, error_text, |
| 2474 | QString{}, tr("OK"), Qt::AlignLeft | Qt::AlignVCenter); | 2481 | QString{}, tr("OK"), Qt::AlignLeft | Qt::AlignVCenter); |
| @@ -2913,8 +2920,13 @@ void GMainWindow::UpdateWindowTitle(std::string_view title_name, std::string_vie | |||
| 2913 | if (title_name.empty()) { | 2920 | if (title_name.empty()) { |
| 2914 | setWindowTitle(QString::fromStdString(window_title)); | 2921 | setWindowTitle(QString::fromStdString(window_title)); |
| 2915 | } else { | 2922 | } else { |
| 2916 | const auto run_title = | 2923 | const auto run_title = [window_title, title_name, title_version, gpu_vendor]() { |
| 2917 | fmt::format("{} | {} | {} | {}", window_title, title_name, title_version, gpu_vendor); | 2924 | if (title_version.empty()) { |
| 2925 | return fmt::format("{} | {} | {}", window_title, title_name, gpu_vendor); | ||
| 2926 | } | ||
| 2927 | return fmt::format("{} | {} | {} | {}", window_title, title_name, title_version, | ||
| 2928 | gpu_vendor); | ||
| 2929 | }(); | ||
| 2918 | setWindowTitle(QString::fromStdString(run_title)); | 2930 | setWindowTitle(QString::fromStdString(run_title)); |
| 2919 | } | 2931 | } |
| 2920 | } | 2932 | } |
diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 36eed6103..60ce01471 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h | |||
| @@ -153,6 +153,7 @@ signals: | |||
| 153 | public slots: | 153 | public slots: |
| 154 | void OnLoadComplete(); | 154 | void OnLoadComplete(); |
| 155 | void OnExecuteProgram(std::size_t program_index); | 155 | void OnExecuteProgram(std::size_t program_index); |
| 156 | void OnExit(); | ||
| 156 | void ControllerSelectorReconfigureControllers( | 157 | void ControllerSelectorReconfigureControllers( |
| 157 | const Core::Frontend::ControllerParameters& parameters); | 158 | const Core::Frontend::ControllerParameters& parameters); |
| 158 | void SoftwareKeyboardInitialize( | 159 | void SoftwareKeyboardInitialize( |
diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp index d74eb7e2b..434518d53 100644 --- a/src/yuzu_cmd/config.cpp +++ b/src/yuzu_cmd/config.cpp | |||
| @@ -518,10 +518,6 @@ void Config::ReadValues() { | |||
| 518 | ReadSetting("WebService", Settings::values.web_api_url); | 518 | ReadSetting("WebService", Settings::values.web_api_url); |
| 519 | ReadSetting("WebService", Settings::values.yuzu_username); | 519 | ReadSetting("WebService", Settings::values.yuzu_username); |
| 520 | ReadSetting("WebService", Settings::values.yuzu_token); | 520 | ReadSetting("WebService", Settings::values.yuzu_token); |
| 521 | |||
| 522 | // Services | ||
| 523 | ReadSetting("Services", Settings::values.bcat_backend); | ||
| 524 | ReadSetting("Services", Settings::values.bcat_boxcat_local); | ||
| 525 | } | 521 | } |
| 526 | 522 | ||
| 527 | void Config::Reload() { | 523 | void Config::Reload() { |
diff --git a/src/yuzu_cmd/default_ini.h b/src/yuzu_cmd/default_ini.h index 72f3213fb..8119a50d8 100644 --- a/src/yuzu_cmd/default_ini.h +++ b/src/yuzu_cmd/default_ini.h | |||
| @@ -428,11 +428,6 @@ web_api_url = https://api.yuzu-emu.org | |||
| 428 | yuzu_username = | 428 | yuzu_username = |
| 429 | yuzu_token = | 429 | yuzu_token = |
| 430 | 430 | ||
| 431 | [Services] | ||
| 432 | # The name of the backend to use for BCAT | ||
| 433 | # If this is set to 'boxcat' boxcat will be used, otherwise a null implementation will be used | ||
| 434 | bcat_backend = | ||
| 435 | |||
| 436 | [AddOns] | 431 | [AddOns] |
| 437 | # Used to disable add-ons | 432 | # Used to disable add-ons |
| 438 | # List of title IDs of games that will have add-ons disabled (separated by '|'): | 433 | # List of title IDs of games that will have add-ons disabled (separated by '|'): |