diff options
32 files changed, 209 insertions, 552 deletions
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 @@ jobs: - job: merge displayName: 'pull requests' + pool: + vmImage: 'ubuntu-latest' steps: - checkout: self submodules: recursive @@ -24,6 +26,8 @@ jobs: - job: upload_source displayName: 'upload' dependsOn: merge + pool: + vmImage: 'ubuntu-latest' steps: - template: ./sync-source.yml 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 @@ jobs: - job: merge displayName: 'pull requests' + pool: + vmImage: 'ubuntu-latest' steps: - checkout: self submodules: recursive @@ -23,6 +25,8 @@ jobs: - job: upload_source displayName: 'upload' dependsOn: merge + pool: + vmImage: 'ubuntu-latest' steps: - template: ./sync-source.yml parameters: 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: jobs: - job: github displayName: 'github' + pool: + vmImage: ubuntu-latest steps: - template: ./templates/release-github.yml 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: jobs: - job: release displayName: 'source' + pool: + vmImage: 'ubuntu-latest' steps: - template: ./templates/release-private-tag.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 93fda1dfa..000000000 --- a/.travis.yml +++ /dev/null @@ -1,59 +0,0 @@ -language: cpp -matrix: - include: - - os: linux - env: NAME="clang-format" - sudo: required - dist: trusty - services: docker - install: "./.travis/clang-format/deps.sh" - script: "./.travis/clang-format/build.sh" - - os: linux - env: NAME="linux build" - sudo: required - dist: trusty - services: docker - addons: - apt: - packages: - - p7zip-full - install: "./.travis/linux/deps.sh" - script: "./.travis/linux/build.sh" - after_success: "./.travis/linux/upload.sh" - cache: ccache - - os: osx - env: NAME="macos build" - sudo: false - osx_image: xcode10.2 - install: "./.travis/macos/deps.sh" - script: "./.travis/macos/build.sh" - after_success: "./.travis/macos/upload.sh" - cache: ccache - - os: linux - env: NAME="MinGW build" - sudo: required - dist: trusty - services: docker - addons: - apt: - packages: - - p7zip-full - install: "./.travis/linux-mingw/deps.sh" - script: "./.travis/linux-mingw/build.sh" - after_success: "./.travis/linux-mingw/upload.sh" - cache: ccache - -deploy: - provider: releases - api_key: - secure: ElsIAlbvVXBNKsP31nVPysh+mf0GQA4DiL/y5iJeQxKQYR6iRoNo+RfzOBmdswdo0bE/PGeBAlfzCkp15gjhWf6Je0N6dRpczmcmLq6SSQFn1Mpq00xMJB2AgQIlaHs6KFgoUA173EBKbPwgU/NubTFpJFm/Wa+NcSWAHQXKL9KT2M3qKpxNkPl3mKEVsbch4REP+T/46vsa+ikw0VE0kIs6V93LqUQZpI2F0Dhihx8Cxr5iedkE1QsNK+QSX9iItMHbfek9OH980gP7L3lkZltyAA1Pk0c37OAgz2PwczwNKwCT8jg9PMzdcKmWouvLyAkZFuA806ElzwHY3oEd91Zm6+Bk5n24yBKZ9027AZzw38NK2Z2m9Akb8+ar8PdsKU6N5pDutX9qSLayr0oMgJ0s7/xnGBGdL3gfkPCFc50xO/2DxlsOR+zAhPNM9Y76hhGy6A7/40+9uzrJvd4nAuDvIXRzi2Yl2L7mKBE4suMKbFLtk2LlgM0qY5JMVTQ8NliaEtqopfPur2KWFVJUpWDNLtNX8xGqhfwg7cLjIiGmnxSaJBTDuZI6dpEjkWkU0n1xYhGqEqit8DbehYzazozMJ+Vsr8hku7jGlUtlw+U6HG1e19O2y4aGeSwYPROcCNz+BLwmVM8oZE3Roy3qoaa2yiFf+sy6rUHznrhsfEM= - file_glob: true - file: "artifacts/*" - skip_cleanup: true - on: - tags: true - -notifications: - webhooks: - urls: - - 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 @@ -#!/bin/bash -ex - -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 @@ -#!/bin/sh -ex - -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 @@ -#!/bin/bash -ex - -# Run clang-format -cd /yuzu -./.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 @@ -#!/bin/bash -ex - -if grep -nrI '\s$' src *.yml *.txt *.md Doxyfile .gitignore .gitmodules .travis* dist/*.desktop \ - dist/*.svg dist/*.xml; then - echo Trailing whitespace found, aborting - exit 1 -fi - -# Default clang-format points to default 3.5 version one -CLANG_FORMAT=clang-format-10.0 -$CLANG_FORMAT --version - -if [ "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then - # Get list of every file modified in this pull request - files_to_lint="$(git diff --name-only --diff-filter=ACMRTUXB $TRAVIS_COMMIT_RANGE | grep '^src/[^.]*[.]\(cpp\|h\)$' || true)" -else - # Check everything for branch pushes - files_to_lint="$(find src/ -name '*.cpp' -or -name '*.h')" -fi - -# Turn off tracing for this because it's too verbose -set +x - -for f in $files_to_lint; do - d=$(diff -u "$f" <($CLANG_FORMAT "$f") || true) - if ! [ -z "$d" ]; then - echo "!!! $f not compliant to coding style, here is the fix:" - echo "$d" - fail=1 - fi -done - -set -x - -if [ "$fail" = 1 ]; then - exit 1 -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 @@ -#!/bin/bash -ex - -# Copy documentation -cp license.txt "$REV_NAME" -cp README.md "$REV_NAME" - -tar $COMPRESSION_FLAGS "$ARCHIVE_NAME" "$REV_NAME" - -# Find out what release we are building -if [ -z $TRAVIS_TAG ]; then - RELEASE_NAME=head -else - RELEASE_NAME=$(echo $TRAVIS_TAG | cut -d- -f1) - if [ "$NAME" = "MinGW build" ]; then - RELEASE_NAME="${RELEASE_NAME}-mingw" - fi -fi - -mv "$REV_NAME" $RELEASE_NAME - -7z a "$REV_NAME.7z" $RELEASE_NAME - -# move the compiled archive into the artifacts directory to be uploaded by travis releases -mv "$ARCHIVE_NAME" artifacts/ -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 @@ -#!/bin/bash -ex - -GITDATE="`git show -s --date=short --format='%ad' | sed 's/-//g'`" -GITREV="`git show -s --format='%h'`" - -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 @@ -# List of environment variables to be shared with Docker containers -CI -TRAVIS -CONTINUOUS_INTEGRATION -TRAVIS_BRANCH -TRAVIS_BUILD_ID -TRAVIS_BUILD_NUMBER -TRAVIS_COMMIT -TRAVIS_COMMIT_RANGE -TRAVIS_EVENT_TYPE -TRAVIS_JOB_ID -TRAVIS_JOB_NUMBER -TRAVIS_REPO_SLUG -TRAVIS_TAG - -# yuzu specific flags -ENABLE_COMPATIBILITY_REPORTING -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 @@ -#!/bin/bash -ex -mkdir "$HOME/.ccache" || true -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 @@ -#!/bin/sh -ex - -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 @@ -#!/bin/bash -ex - -cd /yuzu -# override Travis CI unreasonable ccache size -echo 'max_size = 3.0G' > "$HOME/.ccache/ccache.conf" - -mkdir build && cd build -cmake .. -G Ninja -DCMAKE_TOOLCHAIN_FILE="$(pwd)/../CMakeModules/MinGWCross.cmake" -DUSE_CCACHE=ON -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DCMAKE_BUILD_TYPE=Release -ninja - -# Clean up the dirty hacks -rm /bin/uname && mv /bin/uname1 /bin/uname -rm /bin/cmd - -ccache -s - -echo "Tests skipped" -#ctest -VV -C Release - -echo 'Prepare binaries...' -cd .. -mkdir package - -QT_PLATFORM_DLL_PATH='/usr/x86_64-w64-mingw32/lib/qt5/plugins/platforms/' -find build/ -name "yuzu*.exe" -exec cp {} 'package' \; - -# copy Qt plugins -mkdir package/platforms -cp "${QT_PLATFORM_DLL_PATH}/qwindows.dll" package/platforms/ -cp -rv "${QT_PLATFORM_DLL_PATH}/../mediaservice/" package/ -cp -rv "${QT_PLATFORM_DLL_PATH}/../imageformats/" package/ -rm -f package/mediaservice/*d.dll - -for i in package/*.exe; do - # we need to process pdb here, however, cv2pdb - # does not work here, so we just simply strip all the debug symbols - x86_64-w64-mingw32-strip "${i}" -done - -pip3 install pefile -python3 .travis/linux-mingw/scan_dll.py package/*.exe "package/" -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 @@ -import pefile -import sys -import re -import os -import queue -import shutil - -# constant definitions -KNOWN_SYS_DLLS = ['WINMM.DLL', 'MSVCRT.DLL', 'VERSION.DLL', 'MPR.DLL', - 'DWMAPI.DLL', 'UXTHEME.DLL', 'DNSAPI.DLL', 'IPHLPAPI.DLL'] -# below is for Ubuntu 18.04 with specified PPA enabled, if you are using -# other distro or different repositories, change the following accordingly -DLL_PATH = [ - '/usr/x86_64-w64-mingw32/bin/', - '/usr/x86_64-w64-mingw32/lib/', - '/usr/lib/gcc/x86_64-w64-mingw32/7.3-posix/' -] - -missing = [] - - -def parse_imports(file_name): - results = [] - pe = pefile.PE(file_name, fast_load=True) - pe.parse_data_directories() - - for entry in pe.DIRECTORY_ENTRY_IMPORT: - current = entry.dll.decode() - current_u = current.upper() # b/c Windows is often case insensitive - # here we filter out system dlls - # dll w/ names like *32.dll are likely to be system dlls - if current_u.upper() not in KNOWN_SYS_DLLS and not re.match(string=current_u, pattern=r'.*32\.DLL'): - results.append(current) - - return results - - -def parse_imports_recursive(file_name, path_list=[]): - q = queue.Queue() # create a FIFO queue - # file_name can be a string or a list for the convience - if isinstance(file_name, str): - q.put(file_name) - elif isinstance(file_name, list): - for i in file_name: - q.put(i) - full_list = [] - while q.qsize(): - current = q.get_nowait() - print('> %s' % current) - deps = parse_imports(current) - # if this dll does not have any import, ignore it - if not deps: - continue - for dep in deps: - # the dependency already included in the list, skip - if dep in full_list: - continue - # find the requested dll in the provided paths - full_path = find_dll(dep) - if not full_path: - missing.append(dep) - continue - full_list.append(dep) - q.put(full_path) - path_list.append(full_path) - return full_list - - -def find_dll(name): - for path in DLL_PATH: - for root, _, files in os.walk(path): - for f in files: - if name.lower() == f.lower(): - return os.path.join(root, f) - - -def deploy(name, dst, dry_run=False): - dlls_path = [] - parse_imports_recursive(name, dlls_path) - for dll_entry in dlls_path: - if not dry_run: - shutil.copy(dll_entry, dst) - else: - print('[Dry-Run] Copy %s to %s' % (dll_entry, dst)) - print('Deploy completed.') - return dlls_path - - -def main(): - if len(sys.argv) < 3: - print('Usage: %s [files to examine ...] [target deploy directory]') - return 1 - to_deploy = sys.argv[1:-1] - tgt_dir = sys.argv[-1] - if not os.path.isdir(tgt_dir): - print('%s is not a directory.' % tgt_dir) - return 1 - print('Scanning dependencies...') - deploy(to_deploy, tgt_dir) - if missing: - print('Following DLLs are not found: %s' % ('\n'.join(missing))) - return 0 - - -if __name__ == '__main__': - 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 @@ -#!/bin/bash -ex - -. .travis/common/pre-upload.sh - -REV_NAME="yuzu-windows-mingw-${GITDATE}-${GITREV}" -ARCHIVE_NAME="${REV_NAME}.tar.gz" -COMPRESSION_FLAGS="-czvf" - -mkdir "$REV_NAME" -# get around the permission issues -cp -r package/* "$REV_NAME" - -. .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 @@ -#!/bin/bash -ex - -mkdir -p "$HOME/.ccache" -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 @@ -#!/bin/sh -ex - -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 @@ -#!/bin/bash -ex - -cd /yuzu - -mkdir build && cd build -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 -ninja - -ccache -s - -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 @@ -#!/bin/bash -ex - -. .travis/common/pre-upload.sh - -REV_NAME="yuzu-linux-${GITDATE}-${GITREV}" -ARCHIVE_NAME="${REV_NAME}.tar.xz" -COMPRESSION_FLAGS="-cJvf" - -mkdir "$REV_NAME" - -cp build/bin/yuzu-cmd "$REV_NAME" -cp build/bin/yuzu "$REV_NAME" - -. .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 @@ -#!/bin/bash -ex - -set -o pipefail - -export MACOSX_DEPLOYMENT_TARGET=10.14 -export Qt5_DIR=$(brew --prefix)/opt/qt5 -export PATH="/usr/local/opt/ccache/libexec:$PATH" - -# TODO: Build using ninja instead of make -mkdir build && cd build -cmake --version -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 -make -j4 - -ccache -s - -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 @@ -#!/bin/sh -ex - -brew update -brew install p7zip qt5 sdl2 ccache -brew outdated cmake || brew upgrade cmake -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 @@ -#!/bin/bash -ex - -. .travis/common/pre-upload.sh - -REV_NAME="yuzu-osx-${GITDATE}-${GITREV}" -ARCHIVE_NAME="${REV_NAME}.tar.gz" -COMPRESSION_FLAGS="-czvf" - -mkdir "$REV_NAME" - -cp build/bin/yuzu-cmd "$REV_NAME" -cp -r build/bin/yuzu.app "$REV_NAME" - -# move libs into folder for deployment -macpack "${REV_NAME}/yuzu.app/Contents/MacOS/yuzu" -d "../Frameworks" -# move qt frameworks into app bundle for deployment -$(brew --prefix)/opt/qt5/bin/macdeployqt "${REV_NAME}/yuzu.app" -executable="${REV_NAME}/yuzu.app/Contents/MacOS/yuzu" - -# move libs into folder for deployment -macpack "${REV_NAME}/yuzu-cmd" -d "libs" - -# Make the launching script executable -chmod +x ${REV_NAME}/yuzu.app/Contents/MacOS/yuzu - -# Verify loader instructions -find "$REV_NAME" -exec otool -L {} \; - -. .travis/common/post-upload.sh 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: private: PathManagerImpl() { + fs::path yuzu_path; + fs::path yuzu_path_cache; + fs::path yuzu_path_config; + #ifdef _WIN32 - auto yuzu_path = GetExeDirectory() / PORTABLE_DIR; + yuzu_path = GetExeDirectory() / PORTABLE_DIR; if (!IsDir(yuzu_path)) { yuzu_path = GetAppDataRoamingDirectory() / YUZU_DIR; } - GenerateYuzuPath(YuzuPath::YuzuDir, yuzu_path); - GenerateYuzuPath(YuzuPath::CacheDir, yuzu_path / CACHE_DIR); - GenerateYuzuPath(YuzuPath::ConfigDir, yuzu_path / CONFIG_DIR); + yuzu_path_cache = yuzu_path / CACHE_DIR; + yuzu_path_config = yuzu_path / CONFIG_DIR; #else - auto yuzu_path = GetCurrentDir() / PORTABLE_DIR; + yuzu_path = GetCurrentDir() / PORTABLE_DIR; if (Exists(yuzu_path) && IsDir(yuzu_path)) { - GenerateYuzuPath(YuzuPath::YuzuDir, yuzu_path); - GenerateYuzuPath(YuzuPath::CacheDir, yuzu_path / CACHE_DIR); - GenerateYuzuPath(YuzuPath::ConfigDir, yuzu_path / CONFIG_DIR); + yuzu_path_cache = yuzu_path / CACHE_DIR; + yuzu_path_config = yuzu_path / CONFIG_DIR; } else { yuzu_path = GetDataDirectory("XDG_DATA_HOME") / YUZU_DIR; - - GenerateYuzuPath(YuzuPath::YuzuDir, yuzu_path); - GenerateYuzuPath(YuzuPath::CacheDir, GetDataDirectory("XDG_CACHE_HOME") / YUZU_DIR); - GenerateYuzuPath(YuzuPath::ConfigDir, GetDataDirectory("XDG_CONFIG_HOME") / YUZU_DIR); + yuzu_path_cache = GetDataDirectory("XDG_CACHE_HOME") / YUZU_DIR; + yuzu_path_config = GetDataDirectory("XDG_CONFIG_HOME") / YUZU_DIR; } #endif + GenerateYuzuPath(YuzuPath::YuzuDir, yuzu_path); + GenerateYuzuPath(YuzuPath::CacheDir, yuzu_path_cache); + GenerateYuzuPath(YuzuPath::ConfigDir, yuzu_path_config); GenerateYuzuPath(YuzuPath::DumpDir, yuzu_path / DUMP_DIR); GenerateYuzuPath(YuzuPath::KeysDir, yuzu_path / KEYS_DIR); GenerateYuzuPath(YuzuPath::LoadDir, yuzu_path / LOAD_DIR); 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 @@ #include "core/hle/service/am/applets/applet_web_browser.h" #include "core/hle/service/filesystem/filesystem.h" #include "core/hle/service/ns/pl_u.h" +#include "core/loader/loader.h" namespace Service::AM::Applets { @@ -122,6 +123,15 @@ FileSys::VirtualFile GetOfflineRomFS(Core::System& system, u64 title_id, const auto nca = system.GetContentProvider().GetEntry(title_id, nca_type); if (nca == nullptr) { + if (nca_type == FileSys::ContentRecordType::HtmlDocument) { + LOG_WARNING(Service_AM, "Falling back to AppLoader to get the RomFS."); + FileSys::VirtualFile romfs; + system.GetAppLoader().ReadManualRomFS(romfs); + if (romfs != nullptr) { + return romfs; + } + } + LOG_ERROR(Service_AM, "NCA of type={} with title_id={:016X} is not found in the ContentProvider!", nca_type, title_id); diff --git a/src/video_core/command_classes/codecs/h264.cpp b/src/video_core/command_classes/codecs/h264.cpp index 51ee14c13..5519c4705 100644 --- a/src/video_core/command_classes/codecs/h264.cpp +++ b/src/video_core/command_classes/codecs/h264.cpp @@ -20,6 +20,8 @@ #include <array> #include <bit> + +#include "common/settings.h" #include "video_core/command_classes/codecs/h264.h" #include "video_core/gpu.h" #include "video_core/memory_manager.h" @@ -96,7 +98,10 @@ const std::vector<u8>& H264::ComposeFrameHeader(const NvdecCommon::NvdecRegister (context.h264_parameter_set.frame_mbs_only_flag ? 1 : 2); // TODO (ameerj): Where do we get this number, it seems to be particular for each stream - writer.WriteUe(6); // Max number of reference frames + const auto nvdec_decoding = Settings::values.nvdec_emulation.GetValue(); + const bool uses_gpu_decoding = nvdec_decoding == Settings::NvdecEmulation::GPU; + const u32 max_num_ref_frames = uses_gpu_decoding ? 6u : 16u; + writer.WriteUe(max_num_ref_frames); writer.WriteBit(false); writer.WriteUe(context.h264_parameter_set.pic_width_in_mbs - 1); writer.WriteUe(pic_height - 1); 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" { } #include "common/assert.h" +#include "common/bit_field.h" #include "common/logging/log.h" #include "video_core/command_classes/nvdec.h" @@ -26,6 +27,25 @@ extern "C" { #include "video_core/textures/decoders.h" namespace Tegra { +namespace { +enum class VideoPixelFormat : u64_le { + RGBA8 = 0x1f, + BGRA8 = 0x20, + RGBX8 = 0x23, + Yuv420 = 0x44, +}; +} // Anonymous namespace + +union VicConfig { + u64_le raw{}; + BitField<0, 7, VideoPixelFormat> pixel_format; + BitField<7, 2, u64_le> chroma_loc_horiz; + BitField<9, 2, u64_le> chroma_loc_vert; + BitField<11, 4, u64_le> block_linear_kind; + BitField<15, 4, u64_le> block_linear_height_log2; + BitField<32, 14, u64_le> surface_width_minus1; + BitField<46, 14, u64_le> surface_height_minus1; +}; Vic::Vic(GPU& gpu_, std::shared_ptr<Nvdec> nvdec_processor_) : gpu(gpu_), @@ -65,134 +85,156 @@ void Vic::Execute() { if (!frame) { return; } - const auto pixel_format = static_cast<VideoPixelFormat>(config.pixel_format.Value()); - switch (pixel_format) { + const u64 surface_width = config.surface_width_minus1 + 1; + const u64 surface_height = config.surface_height_minus1 + 1; + if (static_cast<u64>(frame->width) != surface_width || + static_cast<u64>(frame->height) > surface_height) { + // TODO: Properly support multiple video streams with differing frame dimensions + LOG_WARNING(Debug, + "Frame dimensions {}x{} can't be safely decoded into surface dimensions {}x{}", + frame->width, frame->height, surface_width, surface_height); + return; + } + switch (config.pixel_format) { + case VideoPixelFormat::RGBA8: case VideoPixelFormat::BGRA8: - case VideoPixelFormat::RGBA8: { - LOG_TRACE(Service_NVDRV, "Writing RGB Frame"); + case VideoPixelFormat::RGBX8: + WriteRGBFrame(frame, config); + break; + case VideoPixelFormat::Yuv420: + WriteYUVFrame(frame, config); + break; + default: + UNIMPLEMENTED_MSG("Unknown video pixel format {:X}", config.pixel_format.Value()); + break; + } +} - if (scaler_ctx == nullptr || frame->width != scaler_width || - frame->height != scaler_height) { - const AVPixelFormat target_format = - (pixel_format == VideoPixelFormat::RGBA8) ? AV_PIX_FMT_RGBA : AV_PIX_FMT_BGRA; +void Vic::WriteRGBFrame(const AVFrame* frame, const VicConfig& config) { + LOG_TRACE(Service_NVDRV, "Writing RGB Frame"); + + if (!scaler_ctx || frame->width != scaler_width || frame->height != scaler_height) { + const AVPixelFormat target_format = [pixel_format = config.pixel_format]() { + switch (pixel_format) { + case VideoPixelFormat::RGBA8: + return AV_PIX_FMT_RGBA; + case VideoPixelFormat::BGRA8: + return AV_PIX_FMT_BGRA; + case VideoPixelFormat::RGBX8: + return AV_PIX_FMT_RGB0; + default: + return AV_PIX_FMT_RGBA; + } + }(); + + sws_freeContext(scaler_ctx); + // Frames are decoded into either YUV420 or NV12 formats. Convert to desired RGB format + scaler_ctx = sws_getContext(frame->width, frame->height, + static_cast<AVPixelFormat>(frame->format), frame->width, + frame->height, target_format, 0, nullptr, nullptr, nullptr); + scaler_width = frame->width; + scaler_height = frame->height; + converted_frame_buffer.reset(); + } + // Get Converted frame + const u32 width = static_cast<u32>(frame->width); + const u32 height = static_cast<u32>(frame->height); + const std::size_t linear_size = width * height * 4; + + // Only allocate frame_buffer once per stream, as the size is not expected to change + if (!converted_frame_buffer) { + converted_frame_buffer = AVMallocPtr{static_cast<u8*>(av_malloc(linear_size)), av_free}; + } + const std::array<int, 4> converted_stride{frame->width * 4, frame->height * 4, 0, 0}; + u8* const converted_frame_buf_addr{converted_frame_buffer.get()}; + + sws_scale(scaler_ctx, frame->data, frame->linesize, 0, frame->height, &converted_frame_buf_addr, + converted_stride.data()); + + const u32 blk_kind = static_cast<u32>(config.block_linear_kind); + if (blk_kind != 0) { + // swizzle pitch linear to block linear + const u32 block_height = static_cast<u32>(config.block_linear_height_log2); + const auto size = Texture::CalculateSize(true, 4, width, height, 1, block_height, 0); + luma_buffer.resize(size); + Texture::SwizzleSubrect(width, height, width * 4, width, 4, luma_buffer.data(), + converted_frame_buffer.get(), block_height, 0, 0); + + gpu.MemoryManager().WriteBlock(output_surface_luma_address, luma_buffer.data(), size); + } else { + // send pitch linear frame + gpu.MemoryManager().WriteBlock(output_surface_luma_address, converted_frame_buf_addr, + linear_size); + } +} - sws_freeContext(scaler_ctx); - scaler_ctx = nullptr; +void Vic::WriteYUVFrame(const AVFrame* frame, const VicConfig& config) { + LOG_TRACE(Service_NVDRV, "Writing YUV420 Frame"); - // Frames are decoded into either YUV420 or NV12 formats. Convert to desired format - scaler_ctx = sws_getContext(frame->width, frame->height, - static_cast<AVPixelFormat>(frame->format), frame->width, - frame->height, target_format, 0, nullptr, nullptr, nullptr); + const std::size_t surface_width = config.surface_width_minus1 + 1; + const std::size_t surface_height = config.surface_height_minus1 + 1; + const auto frame_width = std::min(surface_width, static_cast<size_t>(frame->width)); + const auto frame_height = std::min(surface_height, static_cast<size_t>(frame->height)); + const std::size_t aligned_width = (surface_width + 0xff) & ~0xffUL; - scaler_width = frame->width; - scaler_height = frame->height; - } - // Get Converted frame - const u32 width = static_cast<u32>(frame->width); - const u32 height = static_cast<u32>(frame->height); - const std::size_t linear_size = width * height * 4; - - // Only allocate frame_buffer once per stream, as the size is not expected to change - if (!converted_frame_buffer) { - converted_frame_buffer = AVMallocPtr{static_cast<u8*>(av_malloc(linear_size)), av_free}; + const auto stride = static_cast<size_t>(frame->linesize[0]); + + luma_buffer.resize(aligned_width * surface_height); + chroma_buffer.resize(aligned_width * surface_height / 2); + + // Populate luma buffer + const u8* luma_src = frame->data[0]; + for (std::size_t y = 0; y < frame_height; ++y) { + const std::size_t src = y * stride; + const std::size_t dst = y * aligned_width; + for (std::size_t x = 0; x < frame_width; ++x) { + luma_buffer[dst + x] = luma_src[src + x]; } - const std::array<int, 4> converted_stride{frame->width * 4, frame->height * 4, 0, 0}; - u8* const converted_frame_buf_addr{converted_frame_buffer.get()}; - - sws_scale(scaler_ctx, frame->data, frame->linesize, 0, frame->height, - &converted_frame_buf_addr, converted_stride.data()); - - const u32 blk_kind = static_cast<u32>(config.block_linear_kind); - if (blk_kind != 0) { - // swizzle pitch linear to block linear - const u32 block_height = static_cast<u32>(config.block_linear_height_log2); - const auto size = - Tegra::Texture::CalculateSize(true, 4, width, height, 1, block_height, 0); - luma_buffer.resize(size); - Tegra::Texture::SwizzleSubrect(width, height, width * 4, width, 4, luma_buffer.data(), - converted_frame_buffer.get(), block_height, 0, 0); - - gpu.MemoryManager().WriteBlock(output_surface_luma_address, luma_buffer.data(), size); - } else { - // send pitch linear frame - gpu.MemoryManager().WriteBlock(output_surface_luma_address, converted_frame_buf_addr, - linear_size); + } + gpu.MemoryManager().WriteBlock(output_surface_luma_address, luma_buffer.data(), + luma_buffer.size()); + + // Chroma + const std::size_t half_height = frame_height / 2; + const auto half_stride = static_cast<size_t>(frame->linesize[1]); + + switch (frame->format) { + case AV_PIX_FMT_YUV420P: { + // Frame from FFmpeg software + // Populate chroma buffer from both channels with interleaving. + const std::size_t half_width = frame_width / 2; + const u8* chroma_b_src = frame->data[1]; + const u8* chroma_r_src = frame->data[2]; + for (std::size_t y = 0; y < half_height; ++y) { + const std::size_t src = y * half_stride; + const std::size_t dst = y * aligned_width; + + for (std::size_t x = 0; x < half_width; ++x) { + chroma_buffer[dst + x * 2] = chroma_b_src[src + x]; + chroma_buffer[dst + x * 2 + 1] = chroma_r_src[src + x]; + } } break; } - case VideoPixelFormat::Yuv420: { - LOG_TRACE(Service_NVDRV, "Writing YUV420 Frame"); - - const std::size_t surface_width = config.surface_width_minus1 + 1; - const std::size_t surface_height = config.surface_height_minus1 + 1; - const auto frame_width = std::min(surface_width, static_cast<size_t>(frame->width)); - const auto frame_height = std::min(surface_height, static_cast<size_t>(frame->height)); - const std::size_t aligned_width = (surface_width + 0xff) & ~0xffUL; - - const auto stride = static_cast<size_t>(frame->linesize[0]); - - luma_buffer.resize(aligned_width * surface_height); - chroma_buffer.resize(aligned_width * surface_height / 2); - - // Populate luma buffer - const u8* luma_src = frame->data[0]; - for (std::size_t y = 0; y < frame_height; ++y) { + case AV_PIX_FMT_NV12: { + // Frame from VA-API hardware + // This is already interleaved so just copy + const u8* chroma_src = frame->data[1]; + for (std::size_t y = 0; y < half_height; ++y) { const std::size_t src = y * stride; const std::size_t dst = y * aligned_width; for (std::size_t x = 0; x < frame_width; ++x) { - luma_buffer[dst + x] = luma_src[src + x]; - } - } - gpu.MemoryManager().WriteBlock(output_surface_luma_address, luma_buffer.data(), - luma_buffer.size()); - - // Chroma - const std::size_t half_height = frame_height / 2; - const auto half_stride = static_cast<size_t>(frame->linesize[1]); - - switch (frame->format) { - case AV_PIX_FMT_YUV420P: { - // Frame from FFmpeg software - // Populate chroma buffer from both channels with interleaving. - const std::size_t half_width = frame_width / 2; - const u8* chroma_b_src = frame->data[1]; - const u8* chroma_r_src = frame->data[2]; - for (std::size_t y = 0; y < half_height; ++y) { - const std::size_t src = y * half_stride; - const std::size_t dst = y * aligned_width; - - for (std::size_t x = 0; x < half_width; ++x) { - chroma_buffer[dst + x * 2] = chroma_b_src[src + x]; - chroma_buffer[dst + x * 2 + 1] = chroma_r_src[src + x]; - } + chroma_buffer[dst + x] = chroma_src[src + x]; } - break; - } - case AV_PIX_FMT_NV12: { - // Frame from VA-API hardware - // This is already interleaved so just copy - const u8* chroma_src = frame->data[1]; - for (std::size_t y = 0; y < half_height; ++y) { - const std::size_t src = y * stride; - const std::size_t dst = y * aligned_width; - for (std::size_t x = 0; x < frame_width; ++x) { - chroma_buffer[dst + x] = chroma_src[src + x]; - } - } - break; - } - default: - UNREACHABLE(); - break; } - gpu.MemoryManager().WriteBlock(output_surface_chroma_address, chroma_buffer.data(), - chroma_buffer.size()); break; } default: - UNIMPLEMENTED_MSG("Unknown video pixel format {}", config.pixel_format.Value()); + UNREACHABLE(); break; } + gpu.MemoryManager().WriteBlock(output_surface_chroma_address, chroma_buffer.data(), + chroma_buffer.size()); } } // 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 @@ #include <memory> #include <vector> -#include "common/bit_field.h" #include "common/common_types.h" struct SwsContext; @@ -14,6 +13,7 @@ struct SwsContext; namespace Tegra { class GPU; class Nvdec; +union VicConfig; class Vic { public: @@ -27,6 +27,7 @@ public: }; explicit Vic(GPU& gpu, std::shared_ptr<Nvdec> nvdec_processor); + ~Vic(); /// Write to the device state. @@ -35,22 +36,9 @@ public: private: void Execute(); - enum class VideoPixelFormat : u64_le { - RGBA8 = 0x1f, - BGRA8 = 0x20, - Yuv420 = 0x44, - }; + void WriteRGBFrame(const AVFrame* frame, const VicConfig& config); - union VicConfig { - u64_le raw{}; - BitField<0, 7, u64_le> pixel_format; - BitField<7, 2, u64_le> chroma_loc_horiz; - BitField<9, 2, u64_le> chroma_loc_vert; - BitField<11, 4, u64_le> block_linear_kind; - BitField<15, 4, u64_le> block_linear_height_log2; - BitField<32, 14, u64_le> surface_width_minus1; - BitField<46, 14, u64_le> surface_height_minus1; - }; + void WriteYUVFrame(const AVFrame* frame, const VicConfig& config); GPU& gpu; std::shared_ptr<Tegra::Nvdec> nvdec_processor; 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) { const float led_size = 5.0f; const QPointF led_position = sideview_center + QPointF(0, -36); int led_count = 0; - for (const auto color : led_color) { + for (const auto& color : led_color) { p.setBrush(color); DrawRectangle(p, led_position + QPointF(0, 12 * led_count++), led_size, led_size); } @@ -1933,7 +1933,7 @@ void PlayerControlPreview::DrawRightBody(QPainter& p, const QPointF center) { const float led_size = 5.0f; const QPointF led_position = sideview_center + QPointF(0, -36); int led_count = 0; - for (const auto color : led_color) { + for (const auto& color : led_color) { p.setBrush(color); DrawRectangle(p, led_position + QPointF(0, 12 * led_count++), led_size, led_size); } 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) { } void MicroProfileWidget::mouseMoveEvent(QMouseEvent* ev) { - MicroProfileMousePosition(ev->pos().x() / x_scale, ev->pos().y() / y_scale, 0); + const auto mouse_position = ev->pos(); + MicroProfileMousePosition(mouse_position.x() / x_scale, mouse_position.y() / y_scale, 0); ev->accept(); } void MicroProfileWidget::mousePressEvent(QMouseEvent* ev) { - MicroProfileMousePosition(ev->pos().x() / x_scale, ev->pos().y() / y_scale, 0); + const auto mouse_position = ev->pos(); + MicroProfileMousePosition(mouse_position.x() / x_scale, mouse_position.y() / y_scale, 0); MicroProfileMouseButton(ev->buttons() & Qt::LeftButton, ev->buttons() & Qt::RightButton); ev->accept(); } void MicroProfileWidget::mouseReleaseEvent(QMouseEvent* ev) { - MicroProfileMousePosition(ev->pos().x() / x_scale, ev->pos().y() / y_scale, 0); + const auto mouse_position = ev->pos(); + MicroProfileMousePosition(mouse_position.x() / x_scale, mouse_position.y() / y_scale, 0); MicroProfileMouseButton(ev->buttons() & Qt::LeftButton, ev->buttons() & Qt::RightButton); ev->accept(); } void MicroProfileWidget::wheelEvent(QWheelEvent* ev) { - MicroProfileMousePosition(ev->pos().x() / x_scale, ev->pos().y() / y_scale, + const auto wheel_position = ev->position().toPoint(); + MicroProfileMousePosition(wheel_position.x() / x_scale, wheel_position.y() / y_scale, ev->angleDelta().y() / 120); ev->accept(); } 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} { * @return true if the haystack contains all words of userinput */ static bool ContainsAllWords(const QString& haystack, const QString& userinput) { - const QStringList userinput_split = - userinput.split(QLatin1Char{' '}, QString::SplitBehavior::SkipEmptyParts); + const QStringList userinput_split = userinput.split(QLatin1Char{' '}, Qt::SkipEmptyParts); return std::all_of(userinput_split.begin(), userinput_split.end(), [&haystack](const QString& s) { return haystack.contains(s); }); |