1
0
mirror of https://git.suyu.dev/suyu/suyu synced 2025-12-08 13:52:08 -06:00

15 Commits

Author SHA1 Message Date
chaphidoesstuff
fa80f8f9f8 Merge branch 'dev' into textureimage-void 2024-09-15 21:37:22 +02:00
Exverge
66993e2603 Comment out unimplemented check
In my testing on macOS, MK8 sometimes crashed at this function, giving a void type instead of u32.
I've temporarily commented this out until (if) this is implemented and added a check for if it is implemented
2024-09-15 21:37:12 +02:00
chaphidoesstuff
6be886d0ff audio_core: increment current revision, Courtesy of Sudachi Dev
Originally from 39effa1011/src/audio_core/common/feature_support.h# and my mirror
2024-09-15 17:50:09 +02:00
chaphidoesstuff
ae65020815 Re-added credit to OG devs 2024-09-15 17:40:10 +02:00
Herman Semenov
e886f27816 Using reserve() for optimization inserts, marked unused pair items and minor code refactor 2024-09-15 17:30:44 +02:00
chaphidoesstuff
9490b5264e Corrected Mistake 2024-09-15 17:18:09 +02:00
chaphidoesstuff
5f485a5863 Updated links 2024-09-15 16:41:53 +02:00
Crimson-Hawk
4eb41467f8 correct the false information in readme regarding rewrite 2024-07-04 12:22:04 +08:00
Crimson-Hawk
daf2c1f496 fix android build 2024-05-29 17:43:46 +08:00
Crimson-Hawk
5f351bf2b3 remove temp.sh 2024-05-29 17:30:20 +08:00
Crimson-Hawk
7b13512b41 fixed reference to gitlab in ci 2024-05-29 17:23:06 +08:00
Crimson-Hawk
e1f809079e fixed reference to gitlab in ci 2024-05-29 17:14:55 +08:00
Crimson-Hawk
b95cfe6483 fixed reference to gitlab in ci 2024-05-29 16:51:35 +08:00
Crimson Hawk
433bcabb72 make pipeline run on every branch 2024-05-29 08:53:17 +08:00
Exverge
89468f90a2 Comment out unimplemented check
In my testing on macOS, MK8 sometimes crashed at this function, giving a void type instead of u32.
I've temporarily commented this out until (if) this is implemented and added a check for if it is implemented
2024-04-01 20:55:40 -04:00
44 changed files with 245 additions and 2225 deletions

View File

@@ -7,6 +7,8 @@
export NDK_CCACHE="$(which ccache)"
ccache -s
git submodule update --init --recursive
BUILD_FLAVOR="mainline"
BUILD_TYPE="release"

View File

@@ -7,7 +7,9 @@
# Exit on error, rather than continuing with the rest of the script.
set -e
ccache -sv
ccache -s
git submodule update --init --recursive
mkdir build || true && cd build
cmake .. \

View File

@@ -6,7 +6,9 @@
# Exit on error, rather than continuing with the rest of the script.
set -e
ccache -sv
ccache -s
git submodule update --init --recursive
mkdir build || true && cd build
cmake .. \
@@ -52,9 +54,9 @@ DESTDIR="$PWD/AppDir" ninja install
rm -vf AppDir/usr/bin/suyu-cmd AppDir/usr/bin/suyu-tester
# Download tools needed to build an AppImage
wget -nc https://gitlab.com/suyu-emu/ext-linux-bin/-/raw/main/appimage/deploy-linux.sh
wget -nc https://gitlab.com/suyu-emu/ext-linux-bin/-/raw/main/appimage/exec-x86_64.so
wget -nc https://gitlab.com/suyu-emu/AppImageKit-checkrt/-/raw/old/AppRun.sh
wget -nc https://git.suyu.dev/suyu/ext-linux-bin/raw/branch/main/appimage/deploy-linux.sh
wget -nc https://git.suyu.dev/suyu/ext-linux-bin/raw/branch/main/appimage/exec-x86_64.so
wget -nc https://git.suyu.dev/suyu/AppImageKit-checkrt/raw/branch/gh-workflow/AppRun
# Set executable bit
chmod 755 \

View File

@@ -8,7 +8,9 @@ set -e
#cd /suyu
ccache -sv
ccache -s
git submodule update --init --recursive
rm -rf build
mkdir -p build && cd build

View File

@@ -8,7 +8,7 @@ name: 'suyu verify'
on:
pull_request:
branches: [ "dev" ]
# branches: [ "dev" ]
paths:
- 'src/**'
- 'CMakeModules/**'
@@ -19,7 +19,7 @@ on:
# paths-ignore:
# - 'src/android/**'
push:
branches: [ "dev" ]
# branches: [ "dev" ]
paths:
- 'src/**'
- 'CMakeModules/**'

5
.gitmodules vendored
View File

@@ -1,6 +1,4 @@
# SPDX-FileCopyrightText: 2014 Citra Emulator Project
# SPDX-FileCopyrightText: 2024 suyu Emulator Project
# SPDX-FileCopyrightText: 2024 Torzu Emulator Project
# SPDX-License-Identifier: GPL-2.0-or-later
[submodule "enet"]
@@ -69,6 +67,3 @@
[submodule "Vulkan-Utility-Libraries"]
path = externals/Vulkan-Utility-Libraries
url = https://github.com/KhronosGroup/Vulkan-Utility-Libraries.git
[submodule "externals/boost-headers"]
path = externals/boost-headers
url = https://github.com/boostorg/headers.git

View File

@@ -1,6 +1,5 @@
# SPDX-FileCopyrightText: 2018 yuzu Emulator Project
# SPDX-FileCopyrightText: 2024 suyu Emulator Project
# SPDX-FileCopyrightText: 2024 Torzu Emulator Project
# SPDX-License-Identifier: GPL-2.0-or-later
cmake_minimum_required(VERSION 3.22)
@@ -277,8 +276,20 @@ if (ARCHITECTURE_arm64 AND (ANDROID OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux"))
add_definitions(-DHAS_NCE=1)
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Configure C++ standard
# ===========================
# boost asio's concept usage doesn't play nicely with some compilers yet.
add_definitions(-DBOOST_ASIO_DISABLE_CONCEPTS)
if (MSVC)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/std:c++20>)
# boost still makes use of deprecated result_of.
add_definitions(-D_HAS_DEPRECATED_RESULT_OF)
else()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
# Output binaries to bin/
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
@@ -287,6 +298,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
# =======================================================================
# Enforce the search mode of non-required packages for better and shorter failure messages
find_package(Boost 1.79.0 REQUIRED context)
find_package(enet 1.3 MODULE)
find_package(fmt 9 REQUIRED)
find_package(LLVM 17.0.2 MODULE COMPONENTS Demangle)
@@ -344,6 +356,11 @@ if (SUYU_TESTS)
find_package(Catch2 3.0.1 REQUIRED)
endif()
# boost:asio has functions that require AcceptEx et al
if (MINGW)
find_library(MSWSOCK_LIBRARY mswsock REQUIRED)
endif()
if(ENABLE_OPENSSL)
find_package(OpenSSL 1.1.1 REQUIRED)
endif()
@@ -670,6 +687,8 @@ function(create_target_directory_groups target_name)
endforeach()
endfunction()
# Prevent boost from linking against libs when building
target_link_libraries(Boost::headers INTERFACE Boost::disable_autolinking)
# Adjustments for MSVC + Ninja
if (MSVC AND CMAKE_GENERATOR STREQUAL "Ninja")
add_compile_options(

View File

@@ -6,8 +6,10 @@ SPDX-License-Identifier: GPL-3.0-or-later
**Note**: We do not support or condone piracy in any form. In order to use suyu, you'll need keys from your real Switch system, and games which you have legally obtained and paid for. We do not intend to make money or profit from this project.
We're in need of developers. Please join our chat below if you want to contribute!
This repo was based on Yuzu EA 4176 but the code is being rewritten from the ground up for legal and performance reasons.
We're in need of developers. Please join our chat below or DM a dev if you want to contribute!
This repo is currently based on Yuzu EA 4176 but the code will be rewritten for legal and performance reasons.
Support the original suyu developer team [here](https://discord.gg/79B6wqFPnc).
<hr />
@@ -22,12 +24,13 @@ This repo was based on Yuzu EA 4176 but the code is being rewritten from the gro
<h4 align="center"><b>suyu</b> was the continuation of the world's most popular, open-source Nintendo Switch emulator, yuzu, but is now something more.
<br>
It is written in C++ with portability in mind, and we actively provide builds for Windows, Linux, Android and iOS potentially coming soon.
It is written in C++ with portability in mind, and we actively provide builds for Windows, Linux and Android, iOS may come later.
</h4>
<p align="center">
<a href="https://chat.suyu.dev">Chat</a> |
<a href="https://www.reddit.com/r/suyu/">Reddit</a> |
<a href="#status">Status</a> |
<a href="#development">Development</a> |
<a href="#downloads">Downloads</a> |
@@ -54,7 +57,7 @@ We currently have builds over at the [Releases](https://git.suyu.dev/suyu/suyu/r
This project is completely free and open source, and anyone can contribute to help improve suyu.
Most of the development happens on the Git. For development discussion, please join us in our [Chat](https://chat.suyu.dev) or contact a developer.
Most of the development happens on Git. For development discussion, please join us in our [Chat](https://chat.suyu.dev) or [Subreddit](reddit.com/r/suyu/), you can also contact a developer.
If you want to contribute, please take a look at the [Contributor's Guide](https://git.suyu.dev/suyu/suyu/wiki/Contributing) and [Developer Information](https://git.suyu.dev/suyu/suyu/wiki/Developer-Information).
You can also contact any of the developers on the Chat to learn more about the current state of suyu.
@@ -65,25 +68,27 @@ You can also contact any of the developers on the Chat to learn more about the c
* __Linux__: [Releases](https://git.suyu.dev/suyu/suyu/releases)
* __macOS__: [Releases](https://git.suyu.dev/suyu/suyu/releases)
* __Android__: [Releases](https://git.suyu.dev/suyu/suyu/releases)
###### We currently do not provide builds for iOS, however if you would like, you could try the experimental [Sudachi](https://github.com/emuPlace/Sudachi/releases)/[Folium](https://github.com/jarrodnorwell/Folium/releases).
###### We currently do not provide builds for iOS, however if you would like, you could try the experimental Sudachi Emulator and it's bigger project: [Folium](https://apps.apple.com/us/app/folium/id6498623389).
If you want daily builds then [Click here](https://git.suyu.dev/suyu/suyu/actions).
If you don't know how to download the daily builds then [Click here](https://git.suyu.dev/suyu/suyu/raw/branch/dev/img/daily-builds.png)
We have official builds [here.](https://git.suyu.dev/suyu/suyu/releases)<br>If any website or person is claiming to have a build for suyu, take that with a grain of salt.
We have official builds [here.](https://git.suyu.dev/suyu/suyu/releases)<br>If any website or person is claiming to have a build for suyu, take that with a grain of salt and let us know.
For Multiplayer, we recommend using the "Yuzu Online" patch, install instructions can be found on Reddit and their Discord.
## Building
* __Windows__: [Windows Build](https://git.suyu.dev/suyu/suyu/wiki/Building-For-Windows)
* __Linux__: [Linux Build](https://git.suyu.dev/suyu/suyu/wiki/Building-For-Linux)
* __Android__: [Android Build](https://git.suyu.dev/suyu/suyu/wiki/Building-For-Android)
* __macOS__: [macOS Build](https://git.suyu.dev/suyu/suyu/wiki/Building-for-macOS)
* __MacOS__: [MacOS Build](https://git.suyu.dev/suyu/suyu/wiki/Building-for-macOS)
## Support
If you have any questions, don't hesitate to ask us in our [chat](https://chat.suyu.dev), make an issue or contact a developer. We don't bite!
If you have any questions, don't hesitate to ask us in our [Chat](https://chat.suyu.dev) or Subreddit, make an issue or contact a developer. We don't bite!
## License

View File

@@ -1,6 +1,4 @@
# SPDX-FileCopyrightText: 2016 Citra Emulator Project
# SPDX-FileCopyrightText: 2024 suyu Emulator Project
# SPDX-FileCopyrightText: 2024 Torzu Emulator Project
# SPDX-License-Identifier: GPL-2.0-or-later
# Dynarmic has cmake_minimum_required(3.12) and we may want to override
@@ -162,9 +160,6 @@ if (SUYU_USE_EXTERNAL_VULKAN_UTILITY_LIBRARIES)
add_subdirectory(Vulkan-Utility-Libraries)
endif()
# Boost headers
add_subdirectory(boost-headers)
# TZDB (Time Zone Database)
add_subdirectory(nx_tzdb)

Submodule externals/boost-headers deleted from 0456900fad

View File

@@ -13,7 +13,7 @@
#include "common/polyfill_ranges.h"
namespace AudioCore {
constexpr u32 CurrentRevision = 11;
constexpr u32 CurrentRevision = 12;
enum class SupportTags {
CommandProcessingTimeEstimatorVersion4,

View File

@@ -54,7 +54,8 @@ public:
const s32 to_register{std::min(std::min(appended_count, BufferAppendLimit),
BufferAppendLimit - registered_count)};
for (s32 i = 0; i < to_register; i++) {
out_buffers.reserve(to_register);
for (s32 i = 0; i < to_register; ++i) {
s32 index{appended_index - appended_count};
if (index < 0) {
index += N;
@@ -180,6 +181,7 @@ public:
return 0;
}
buffers_flushed.reserve(registered_count + appended_count);
while (registered_count > 0) {
auto index{registered_index - registered_count};
if (index < 0) {

View File

@@ -1,6 +1,5 @@
# SPDX-FileCopyrightText: 2018 yuzu Emulator Project
# SPDX-FileCopyrightText: 2024 suyu Emulator Project
# SPDX-FileCopyrightText: 2024 Torzu Emulator Project
# SPDX-License-Identifier: GPL-2.0-or-later
if (DEFINED ENV{AZURECIREPO})
@@ -263,7 +262,7 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
)
endif()
target_link_libraries(common PUBLIC Boost::headers fmt::fmt microprofile stb::headers Threads::Threads)
target_link_libraries(common PUBLIC Boost::context Boost::headers fmt::fmt microprofile stb::headers Threads::Threads)
target_link_libraries(common PRIVATE lz4::lz4 zstd::zstd LLVM::Demangle)
if (ANDROID)

View File

@@ -1,52 +1,91 @@
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
// SPDX-FileCopyrightText: Copyright 2024 suyu Emulator Project
// SPDX-FileCopyrightText: Copyright 2024 Torzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <mutex>
#include "common/assert.h"
#include "common/fiber.h"
#define MINICORO_IMPL
#include "common/minicoro.h"
#include "common/virtual_buffer.h"
#include <boost/context/detail/fcontext.hpp>
namespace Common {
constexpr std::size_t default_stack_size = 512 * 1024;
struct Fiber::FiberImpl {
FiberImpl() {}
FiberImpl() : stack{default_stack_size}, rewind_stack{default_stack_size} {}
VirtualBuffer<u8> stack;
VirtualBuffer<u8> rewind_stack;
std::mutex guard;
bool released{};
bool is_thread_fiber{};
Fiber* next_fiber{};
Fiber** next_fiber_ptr;
std::function<void()> entry_point;
std::function<void()> rewind_point;
std::shared_ptr<Fiber> previous_fiber;
bool is_thread_fiber{};
bool released{};
mco_coro* context;
u8* stack_limit{};
u8* rewind_stack_limit{};
boost::context::detail::fcontext_t context{};
boost::context::detail::fcontext_t rewind_context{};
};
Fiber::Fiber() : impl{std::make_unique<FiberImpl>()} {
impl->is_thread_fiber = true;
void Fiber::SetRewindPoint(std::function<void()>&& rewind_func) {
impl->rewind_point = std::move(rewind_func);
}
void Fiber::Start(boost::context::detail::transfer_t& transfer) {
ASSERT(impl->previous_fiber != nullptr);
impl->previous_fiber->impl->context = transfer.fctx;
impl->previous_fiber->impl->guard.unlock();
impl->previous_fiber.reset();
impl->entry_point();
UNREACHABLE();
}
void Fiber::OnRewind([[maybe_unused]] boost::context::detail::transfer_t& transfer) {
ASSERT(impl->context != nullptr);
impl->context = impl->rewind_context;
impl->rewind_context = nullptr;
u8* tmp = impl->stack_limit;
impl->stack_limit = impl->rewind_stack_limit;
impl->rewind_stack_limit = tmp;
impl->rewind_point();
UNREACHABLE();
}
void Fiber::FiberStartFunc(boost::context::detail::transfer_t transfer) {
auto* fiber = static_cast<Fiber*>(transfer.data);
fiber->Start(transfer);
}
void Fiber::RewindStartFunc(boost::context::detail::transfer_t transfer) {
auto* fiber = static_cast<Fiber*>(transfer.data);
fiber->OnRewind(transfer);
}
Fiber::Fiber(std::function<void()>&& entry_point_func) : impl{std::make_unique<FiberImpl>()} {
impl->entry_point = std::move(entry_point_func);
auto desc = mco_desc_init(
[](mco_coro* coro) { reinterpret_cast<Fiber*>(coro->user_data)->impl->entry_point(); }, 0);
desc.user_data = this;
mco_result res = mco_create(&impl->context, &desc);
ASSERT(res == MCO_SUCCESS);
impl->stack_limit = impl->stack.data();
impl->rewind_stack_limit = impl->rewind_stack.data();
u8* stack_base = impl->stack_limit + default_stack_size;
impl->context =
boost::context::detail::make_fcontext(stack_base, impl->stack.size(), FiberStartFunc);
}
Fiber::Fiber() : impl{std::make_unique<FiberImpl>()} {}
Fiber::~Fiber() {
if (impl->released) {
return;
}
DestroyPre();
if (impl->is_thread_fiber) {
DestroyThreadFiber();
} else {
DestroyWorkFiber();
// Make sure the Fiber is not being used
const bool locked = impl->guard.try_lock();
ASSERT_MSG(locked, "Destroying a fiber that's still running");
if (locked) {
impl->guard.unlock();
}
}
@@ -55,66 +94,42 @@ void Fiber::Exit() {
if (!impl->is_thread_fiber) {
return;
}
DestroyPre();
DestroyThreadFiber();
}
void Fiber::DestroyPre() {
// Make sure the Fiber is not being used
const bool locked = impl->guard.try_lock();
ASSERT_MSG(locked, "Destroying a fiber that's still running");
if (locked) {
impl->guard.unlock();
}
impl->guard.unlock();
impl->released = true;
}
void Fiber::DestroyWorkFiber() {
mco_result res = mco_destroy(impl->context);
ASSERT(res == MCO_SUCCESS);
}
void Fiber::DestroyThreadFiber() {
if (*impl->next_fiber_ptr) {
*impl->next_fiber_ptr = nullptr;
}
void Fiber::Rewind() {
ASSERT(impl->rewind_point);
ASSERT(impl->rewind_context == nullptr);
u8* stack_base = impl->rewind_stack_limit + default_stack_size;
impl->rewind_context =
boost::context::detail::make_fcontext(stack_base, impl->stack.size(), RewindStartFunc);
boost::context::detail::jump_fcontext(impl->rewind_context, this);
}
void Fiber::YieldTo(std::weak_ptr<Fiber> weak_from, Fiber& to) {
to.impl->guard.lock();
to.impl->previous_fiber = weak_from.lock();
auto transfer = boost::context::detail::jump_fcontext(to.impl->context, &to);
// "from" might no longer be valid if the thread was killed
if (auto from = weak_from.lock()) {
if (!from->impl->is_thread_fiber) {
// Set next fiber
from->impl->next_fiber = &to;
// Yield from thread
if (!from->impl->released) {
from->impl->guard.unlock();
mco_yield(from->impl->context);
}
} else {
from->impl->guard.lock();
// Keep running next fiber until they've ran out
auto& next_fiber_ptr = from->impl->next_fiber_ptr;
next_fiber_ptr = &from->impl->next_fiber;
*next_fiber_ptr = &to;
for ([[maybe_unused]] unsigned round = 0; *next_fiber_ptr; round++) {
auto next = *next_fiber_ptr;
*next_fiber_ptr = nullptr;
next_fiber_ptr = &next->impl->next_fiber;
// Stop if new thread is thread fiber
if (next->impl->is_thread_fiber)
break;
// Resume new thread
next->impl->guard.lock();
mco_result res = mco_resume(next->impl->context);
ASSERT(res == MCO_SUCCESS);
}
from->impl->guard.unlock();
if (from->impl->previous_fiber == nullptr) {
ASSERT_MSG(false, "previous_fiber is nullptr!");
return;
}
from->impl->previous_fiber->impl->context = transfer.fctx;
from->impl->previous_fiber->impl->guard.unlock();
from->impl->previous_fiber.reset();
}
}
std::shared_ptr<Fiber> Fiber::ThreadToFiber() {
return std::shared_ptr<Fiber>{new Fiber()};
std::shared_ptr<Fiber> fiber = std::shared_ptr<Fiber>{new Fiber()};
fiber->impl->guard.lock();
fiber->impl->is_thread_fiber = true;
return fiber;
}
} // namespace Common
} // namespace Common

View File

@@ -1,6 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
// SPDX-FileCopyrightText: Copyright 2024 suyu Emulator Project
// SPDX-FileCopyrightText: Copyright 2024 Torzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -8,7 +6,9 @@
#include <functional>
#include <memory>
#include "common/minicoro.h"
namespace boost::context::detail {
struct transfer_t;
}
namespace Common {
@@ -38,21 +38,28 @@ public:
Fiber(Fiber&&) = default;
Fiber& operator=(Fiber&&) = default;
/// Yields control from Fiber 'from' to Fiber 'to'
/// Fiber 'from' must be the currently running fiber.
static void YieldTo(std::weak_ptr<Fiber> weak_from, Fiber& to);
[[nodiscard]] static std::shared_ptr<Fiber> ThreadToFiber();
void SetRewindPoint(std::function<void()>&& rewind_func);
void Rewind();
/// Only call from main thread's fiber
void Exit();
private:
Fiber();
void DestroyPre();
void DestroyWorkFiber();
void DestroyThreadFiber();
void OnRewind(boost::context::detail::transfer_t& transfer);
void Start(boost::context::detail::transfer_t& transfer);
static void FiberStartFunc(boost::context::detail::transfer_t transfer);
static void RewindStartFunc(boost::context::detail::transfer_t transfer);
struct FiberImpl;
std::unique_ptr<FiberImpl> impl;
};
} // namespace Common
} // namespace Common

File diff suppressed because it is too large Load Diff

View File

@@ -80,6 +80,7 @@ FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs,
if (filename == "00") {
const auto dir = vfs->OpenDirectory(dir_name, FileSys::OpenMode::Read);
std::vector<FileSys::VirtualFile> concat;
concat.reserve(0x10);
for (u32 i = 0; i < 0x10; ++i) {
const auto file_name = fmt::format("{:02X}", i);

View File

@@ -481,6 +481,7 @@ void GDBStub::HandleQuery(std::string_view command) {
// beginning of list
const auto& threads = GetProcess()->GetThreadList();
std::vector<std::string> thread_ids;
thread_ids.reserve(threads.size());
for (const auto& thread : threads) {
thread_ids.push_back(fmt::format("{:x}", thread.GetThreadId()));
}

View File

@@ -261,7 +261,7 @@ std::vector<NcaID> PlaceholderCache::List() const {
std::vector<NcaID> out;
for (const auto& sdir : dir->GetSubdirectories()) {
for (const auto& file : sdir->GetFiles()) {
const auto name = file->GetName();
const auto& name = file->GetName();
if (name.length() == 36 && name.ends_with(".nca")) {
out.push_back(Common::HexStringToArray<0x10>(name.substr(0, 32)));
}

View File

@@ -117,7 +117,9 @@ std::vector<std::shared_ptr<NCA>> NSP::GetNCAsCollapsed() const {
if (extracted)
LOG_WARNING(Service_FS, "called on an NSP that is of type extracted.");
std::vector<std::shared_ptr<NCA>> out;
out.reserve(ncas.size());
for (const auto& map : ncas) {
out.reserve(map.second.size());
for (const auto& inner_map : map.second)
out.push_back(inner_map.second);
}

View File

@@ -24,7 +24,7 @@ constexpr std::array<u8, 30> WORD_TXT{
VirtualDir NgWord1() {
std::vector<VirtualFile> files;
files.reserve(NgWord1Data::NUMBER_WORD_TXT_FILES);
files.reserve(files.size() + 2);
for (std::size_t i = 0; i < files.size(); ++i) {
files.push_back(MakeArrayFile(NgWord1Data::WORD_TXT, fmt::format("{}.txt", i)));
@@ -54,7 +54,7 @@ constexpr std::array<u8, 0x2C> AC_NX_DATA{
VirtualDir NgWord2() {
std::vector<VirtualFile> files;
files.reserve(NgWord2Data::NUMBER_AC_NX_FILES * 3);
files.reserve(NgWord2Data::NUMBER_AC_NX_FILES + 4);
for (std::size_t i = 0; i < NgWord2Data::NUMBER_AC_NX_FILES; ++i) {
files.push_back(MakeArrayFile(NgWord2Data::AC_NX_DATA, fmt::format("ac_{}_b1_nx", i)));

View File

@@ -37,6 +37,7 @@ const static std::map<std::string, const std::map<const char*, const std::vector
static void GenerateFiles(std::vector<VirtualFile>& directory,
const std::map<const char*, const std::vector<u8>>& files) {
directory.reserve(files.size());
for (const auto& [filename, data] : files) {
const auto data_copy{data};
const std::string filename_copy{filename};
@@ -54,6 +55,7 @@ static std::vector<VirtualFile> GenerateZoneinfoFiles() {
VirtualDir TimeZoneBinary() {
std::vector<VirtualDir> america_sub_dirs;
america_sub_dirs.reserve(tzdb_america_dirs.size());
for (const auto& [dir_name, files] : tzdb_america_dirs) {
std::vector<VirtualFile> vfs_files;
GenerateFiles(vfs_files, files);
@@ -62,6 +64,7 @@ VirtualDir TimeZoneBinary() {
}
std::vector<VirtualDir> zoneinfo_sub_dirs;
zoneinfo_sub_dirs.reserve(tzdb_zoneinfo_dirs.size());
for (const auto& [dir_name, files] : tzdb_zoneinfo_dirs) {
std::vector<VirtualFile> vfs_files;
GenerateFiles(vfs_files, files);

View File

@@ -38,7 +38,8 @@ VirtualDir CachedVfsDirectory::GetSubdirectory(std::string_view dir_name) const
std::vector<VirtualFile> CachedVfsDirectory::GetFiles() const {
std::vector<VirtualFile> out;
for (auto& [file_name, file] : files) {
out.reserve(files.size());
for (const auto& [_, file] : files) {
out.push_back(file);
}
return out;
@@ -46,7 +47,8 @@ std::vector<VirtualFile> CachedVfsDirectory::GetFiles() const {
std::vector<VirtualDir> CachedVfsDirectory::GetSubdirectories() const {
std::vector<VirtualDir> out;
for (auto& [dir_name, dir] : dirs) {
out.reserve(dirs.size());
for (auto& [_, dir] : dirs) {
out.push_back(dir);
}
return out;

View File

@@ -121,7 +121,7 @@ void WindowSystem::RequestAppletVisibilityState(Applet& applet, bool visible) {
void WindowSystem::OnOperationModeChanged() {
std::scoped_lock lk{m_lock};
for (const auto& [aruid, applet] : m_applets) {
for (const auto& [_, applet] : m_applets) {
std::scoped_lock lk2{applet->lock};
applet->lifecycle_manager.OnOperationAndPerformanceModeChanged();
}
@@ -130,7 +130,7 @@ void WindowSystem::OnOperationModeChanged() {
void WindowSystem::OnExitRequested() {
std::scoped_lock lk{m_lock};
for (const auto& [aruid, applet] : m_applets) {
for (const auto& [_, applet] : m_applets) {
std::scoped_lock lk2{applet->lock};
applet->lifecycle_manager.RequestExit();
}
@@ -156,7 +156,7 @@ void WindowSystem::OnHomeButtonPressed(ButtonPressDuration type) {
void WindowSystem::PruneTerminatedAppletsLocked() {
for (auto it = m_applets.begin(); it != m_applets.end(); /* ... */) {
const auto& [aruid, applet] = *it;
const auto& [_, applet] = *it;
std::scoped_lock lk{applet->lock};

View File

@@ -119,7 +119,7 @@ Result LANDiscovery::Scan(std::span<NetworkInfo> out_networks, s16& out_count,
std::this_thread::sleep_for(std::chrono::seconds(1));
std::scoped_lock lock{packet_mutex};
for (const auto& [key, info] : scan_results) {
for (const auto& [_, info] : scan_results) {
if (out_count >= static_cast<s16>(out_networks.size())) {
break;
}

View File

@@ -348,7 +348,7 @@ Result IApplicationManagerInterface::ListApplicationRecord(
size_t i = 0;
u8 ii = 24;
for (const auto& [slot, game] : installed_games) {
for (const auto& [_, game] : installed_games) {
if (i >= limit) {
break;
}

View File

@@ -28,7 +28,7 @@ ServiceManager::ServiceManager(Kernel::KernelCore& kernel_) : kernel{kernel_} {
}
ServiceManager::~ServiceManager() {
for (auto& [name, port] : service_ports) {
for (auto& [_, port] : service_ports) {
port->Close();
}

View File

@@ -571,7 +571,7 @@ SDLDriver::~SDLDriver() {
std::vector<Common::ParamPackage> SDLDriver::GetInputDevices() const {
std::vector<Common::ParamPackage> devices;
std::unordered_map<int, std::shared_ptr<SDLJoystick>> joycon_pairs;
for (const auto& [key, value] : joystick_map) {
for (const auto& [_, value] : joystick_map) {
for (const auto& joystick : value) {
if (!joystick->GetSDLJoystick()) {
continue;
@@ -591,7 +591,7 @@ std::vector<Common::ParamPackage> SDLDriver::GetInputDevices() const {
}
// Add dual controllers
for (const auto& [key, value] : joystick_map) {
for (const auto& [_, value] : joystick_map) {
for (const auto& joystick : value) {
if (joystick->IsJoyconRight()) {
if (!joycon_pairs.contains(joystick->GetPort())) {

View File

@@ -196,8 +196,11 @@ Id Texture(EmitContext& ctx, IR::TextureInstInfo info, [[maybe_unused]] const IR
}
Id TextureImage(EmitContext& ctx, IR::TextureInstInfo info, const IR::Value& index) {
if (!index.IsImmediate() || index.U32() != 0) {
throw NotImplementedException("Indirect image indexing");
// if (!index.IsImmediate() || index.Type() != Shader::IR::Type::U32 || index.U32() != 0) {
// throw NotImplementedException("Indirect image indexing");
// }
if (index.Type() != Shader::IR::Type::U32) {
LOG_WARNING(Shader_SPIRV, "Non-U32 type provided as index: {}", index.Type());
}
if (info.type == TextureType::Buffer) {
const TextureBufferDefinition& def{ctx.texture_buffers.at(info.descriptor_index)};
@@ -215,8 +218,11 @@ Id TextureImage(EmitContext& ctx, IR::TextureInstInfo info, const IR::Value& ind
}
std::pair<Id, bool> Image(EmitContext& ctx, const IR::Value& index, IR::TextureInstInfo info) {
if (!index.IsImmediate() || index.U32() != 0) {
throw NotImplementedException("Indirect image indexing");
// if (!index.IsImmediate() || index.Type() != Shader::IR::Type::U32 || index.U32() != 0) {
// throw NotImplementedException("Indirect image indexing");
// }
if (index.Type() != Shader::IR::Type::U32) {
LOG_WARNING(Shader_SPIRV, "Non-U32 type provided as index: {}", index.Type());
}
if (info.type == TextureType::Buffer) {
const ImageBufferDefinition def{ctx.image_buffers.at(info.descriptor_index)};

View File

@@ -69,7 +69,7 @@ void ConfigureApplets::Setup(const ConfigurationShared::Builder& builder) {
applets_hold.emplace(setting->Id(), widget);
}
for (const auto& [label, widget] : applets_hold) {
for (const auto& [_, widget] : applets_hold) {
library_applets_layout.addWidget(widget);
}
}

View File

@@ -164,7 +164,7 @@ void ConfigureAudio::Setup(const ConfigurationShared::Builder& builder) {
}
}
for (const auto& [id, widget] : hold) {
for (const auto& [_, widget] : hold) {
layout.addWidget(widget);
}
}

View File

@@ -79,7 +79,7 @@ void ConfigureCpu::Setup(const ConfigurationShared::Builder& builder) {
}
}
for (const auto& [label, widget] : unsafe_hold) {
for (const auto& [_, widget] : unsafe_hold) {
unsafe_layout->addWidget(widget);
}

View File

@@ -81,10 +81,10 @@ void ConfigureGeneral::Setup(const ConfigurationShared::Builder& builder) {
}
}
for (const auto& [id, widget] : general_hold) {
for (const auto& [_, widget] : general_hold) {
general_layout.addWidget(widget);
}
for (const auto& [id, widget] : linux_hold) {
for (const auto& [_, widget] : linux_hold) {
linux_layout.addWidget(widget);
}
}

View File

@@ -358,7 +358,7 @@ void ConfigureGraphics::Setup(const ConfigurationShared::Builder& builder) {
}
}
for (const auto& [id, widget] : hold_graphics) {
for (const auto& [_, widget] : hold_graphics) {
graphics_layout.addWidget(widget);
}

View File

@@ -53,7 +53,7 @@ void ConfigureGraphicsAdvanced::Setup(const ConfigurationShared::Builder& builde
checkbox_enable_compute_pipelines = widget;
}
}
for (const auto& [id, widget] : hold) {
for (const auto& [_, widget] : hold) {
layout.addWidget(widget);
}
}

View File

@@ -50,7 +50,7 @@ void ConfigureLinuxTab::Setup(const ConfigurationShared::Builder& builder) {
linux_hold.insert({setting->Id(), widget});
}
for (const auto& [id, widget] : linux_hold) {
for (const auto& [_, widget] : linux_hold) {
linux_layout.addWidget(widget);
}
}

View File

@@ -174,10 +174,10 @@ void ConfigureSystem::Setup(const ConfigurationShared::Builder& builder) {
widget->deleteLater();
}
}
for (const auto& [label, widget] : core_hold) {
for (const auto& [_, widget] : core_hold) {
core_layout.addWidget(widget);
}
for (const auto& [id, widget] : system_hold) {
for (const auto& [_, widget] : system_hold) {
system_layout.addWidget(widget);
}
}

View File

@@ -83,7 +83,7 @@ static void PopulateResolutionComboBox(QComboBox* screenshot_height, QWidget* pa
const auto& enumeration =
Settings::EnumMetadata<Settings::ResolutionSetup>::Canonicalizations();
std::set<u32> resolutions{};
for (const auto& [name, value] : enumeration) {
for (const auto& [_, value] : enumeration) {
const float up_factor = GetUpFactor(value);
u32 height_undocked = Layout::ScreenUndocked::Height * up_factor;
u32 height_docked = Layout::ScreenDocked::Height * up_factor;

View File

@@ -61,7 +61,7 @@ std::vector<std::string> InputProfiles::GetInputProfileNames() {
auto it = map_profiles.cbegin();
while (it != map_profiles.cend()) {
const auto& [profile_name, config] = *it;
const auto& [profile_name, _] = *it;
if (!ProfileExistsInFilesystem(profile_name)) {
it = map_profiles.erase(it);
continue;

View File

@@ -135,7 +135,7 @@ QWidget* Widget::CreateCombobox(std::function<std::string()>& serializer,
const ComboboxTranslations* enumeration{nullptr};
if (combobox_enumerations.contains(type)) {
enumeration = &combobox_enumerations.at(type);
for (const auto& [id, name] : *enumeration) {
for (const auto& [_, name] : *enumeration) {
combobox->addItem(name);
}
} else {
@@ -223,7 +223,7 @@ QWidget* Widget::CreateRadioGroup(std::function<std::string()>& serializer,
};
if (!Settings::IsConfiguringGlobal()) {
for (const auto& [id, button] : radio_buttons) {
for (const auto& [_, button] : radio_buttons) {
QObject::connect(button, &QAbstractButton::clicked, [touch]() { touch(); });
}
}

View File

@@ -87,7 +87,7 @@ std::optional<std::filesystem::path> GetCurrentUserPlayTimePath(
std::vector<PlayTimeElement> elements;
elements.reserve(play_time_db.size());
for (auto& [program_id, play_time] : play_time_db) {
for (const auto& [program_id, play_time] : play_time_db) {
if (program_id != 0) {
elements.push_back(PlayTimeElement{program_id, play_time});
}

View File

@@ -1,5 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
// SPDX-FileCopyrightText: Copyright 2024 Torzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <atomic>
@@ -272,4 +271,43 @@ TEST_CASE("Fibers::StartRace", "[common]") {
REQUIRE(test_control.value3 == 1);
}
class TestControl4;
class TestControl4 {
public:
TestControl4() {
fiber1 = std::make_shared<Fiber>([this] { DoWork(); });
goal_reached = false;
rewinded = false;
}
void Execute() {
thread_fiber = Fiber::ThreadToFiber();
Fiber::YieldTo(thread_fiber, *fiber1);
thread_fiber->Exit();
}
void DoWork() {
fiber1->SetRewindPoint([this] { DoWork(); });
if (rewinded) {
goal_reached = true;
Fiber::YieldTo(fiber1, *thread_fiber);
}
rewinded = true;
fiber1->Rewind();
}
std::shared_ptr<Common::Fiber> fiber1;
std::shared_ptr<Common::Fiber> thread_fiber;
bool goal_reached;
bool rewinded;
};
TEST_CASE("Fibers::Rewind", "[common]") {
TestControl4 test_control{};
test_control.Execute();
REQUIRE(test_control.goal_reached);
REQUIRE(test_control.rewinded);
}
} // namespace Common

View File

@@ -45,7 +45,7 @@ public:
[[nodiscard]] unsigned Count() const noexcept {
unsigned count = 0;
for (const auto& [index, value] : page_table) {
for (const auto& [_, value] : page_table) {
count += value;
}
return count;

View File

@@ -45,7 +45,7 @@ public:
// Vic does not know which nvdec is producing frames for it, so search all the fds here for
// the given offset.
for (auto& map : m_presentation_order) {
for (auto& [offset, frame] : map.second) {
for (auto& [offset, _] : map.second) {
if (offset == search_offset) {
return map.first;
}
@@ -53,7 +53,7 @@ public:
}
for (auto& map : m_decode_order) {
for (auto& [offset, frame] : map.second) {
for (auto& [offset, _] : map.second) {
if (offset == search_offset) {
return map.first;
}