diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ccff80c97..5cd51e0643 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,7 +75,6 @@ if (YUZU_STATIC_ROOM) set(OpenSSL_FORCE_SYSTEM ON) set(zstd_FORCE_BUNDLED ON) - set(fmt_FORCE_BUNDLED ON) endif() # qt stuff @@ -147,7 +146,6 @@ if (YUZU_STATIC_BUILD) set(YUZU_USE_BUNDLED_OPENSSL ON) # these libs do not properly provide static libs/let you do it with cmake - set(fmt_FORCE_BUNDLED ON) set(SPIRV-Headers_FORCE_BUNDLED ON) set(zstd_FORCE_BUNDLED ON) @@ -440,9 +438,6 @@ if (Boost_ADDED) endif() endif() -# fmt -AddJsonPackage(fmt) - # lz4 AddJsonPackage(lz4) diff --git a/cpmfile.json b/cpmfile.json index 22871ccb0c..17753281a9 100644 --- a/cpmfile.json +++ b/cpmfile.json @@ -78,12 +78,6 @@ "repo": "crueter-ci/FFmpeg", "version": "9.0.2-1790726865-946fcce07b" }, - "fmt": { - "hash": "f0da82c545b01692e9fd30fdfb613dbb8dd9716983dcd0ff19ac2a8d36f74beb5540ef38072fdecc1e34191b3682a8542ecbf3a61ef287dbba0a2679d4e023f2", - "min_version": "8", - "repo": "fmtlib/fmt", - "version": "12.1.0" - }, "frozen": { "hash": "b8dfe741c82bc178dfc9749d4ab5a130cee718d9ee7b71d9b547cf5f7f23027ed0152ad250012a8546399fcc1e12187efc68d89d6731256c4d2df7d04eef8d5c", "package": "frozen", diff --git a/docs/Deps.md b/docs/Deps.md index 15539187e4..ea79cbc55a 100644 --- a/docs/Deps.md +++ b/docs/Deps.md @@ -51,7 +51,6 @@ All other dependencies will be downloaded and built by CPM, but will always use - [Boost](https://www.boost.org/users/download/) 1.87.0+ - [Catch2](https://github.com/catchorg/Catch2) 3.0.1 if `YUZU_TESTS` or `DYNARMIC_TESTS` are on -- [fmt](https://fmt.dev/) 8.0.1+ - [lz4](http://www.lz4.org) - [OpenSSL](https://www.openssl.org/source/) 3+ - [ZLIB](https://www.zlib.net/) 1.2+ @@ -114,7 +113,7 @@ Now, install all deps: ```sh sudo emerge -a \ app-arch/lz4 app-arch/zstd app-arch/unzip \ - dev-libs/libfmt dev-libs/libusb dev-libs/mcl dev-libs/sirit \ + dev-libs/libusb dev-libs/mcl dev-libs/sirit \ dev-libs/boost dev-libs/openssl dev-libs/discord-rpc \ dev-util/spirv-tools dev-util/spirv-headers dev-util/vulkan-headers \ dev-util/vulkan-utility-libraries dev-util/glslang \ @@ -148,7 +147,7 @@ Required USE flags: Arch Linux ```sh -sudo pacman -Syu --needed base-devel boost catch2 cmake enet ffmpeg fmt git glslang libzip lz4 ninja openssl opus qt6-base qt6-multimedia qt6-charts sdl3 zlib zstd zip unzip vulkan-headers vulkan-utility-libraries libusb spirv-tools spirv-headers +sudo pacman -Syu --needed base-devel boost catch2 cmake enet ffmpeg git glslang libzip lz4 ninja openssl opus qt6-base qt6-multimedia qt6-charts sdl3 zlib zstd zip unzip vulkan-headers vulkan-utility-libraries libusb spirv-tools spirv-headers ``` - Building with QT Web Engine requires `qt6-webengine` as well. @@ -161,7 +160,7 @@ sudo pacman -Syu --needed base-devel boost catch2 cmake enet ffmpeg fmt git glsl Ubuntu, Debian, Mint Linux ```sh -sudo apt-get install autoconf cmake g++ gcc git glslang-tools libglu1-mesa-dev libhidapi-dev libpulse-dev libtool libudev-dev libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-render-util0 libxcb-xinerama0 libxcb-xkb1 libxext-dev libxkbcommon-x11-0 mesa-common-dev nasm ninja-build qt6-base-private-dev catch2 libfmt-dev liblz4-dev libzstd-dev libssl-dev libavfilter-dev libavcodec-dev libswscale-dev pkg-config zlib1g-dev libva-dev libvdpau-dev qt6-tools-dev qt6-charts-dev libvulkan-dev spirv-tools spirv-headers libusb-1.0-0-dev libxbyak-dev libboost-dev libboost-fiber-dev libboost-context-dev libsdl3-dev libopus-dev libasound2t64 vulkan-utility-libraries-dev +sudo apt-get install autoconf cmake g++ gcc git glslang-tools libglu1-mesa-dev libhidapi-dev libpulse-dev libtool libudev-dev libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-render-util0 libxcb-xinerama0 libxcb-xkb1 libxext-dev libxkbcommon-x11-0 mesa-common-dev nasm ninja-build qt6-base-private-dev catch2 liblz4-dev libzstd-dev libssl-dev libavfilter-dev libavcodec-dev libswscale-dev pkg-config zlib1g-dev libva-dev libvdpau-dev qt6-tools-dev qt6-charts-dev libvulkan-dev spirv-tools spirv-headers libusb-1.0-0-dev libxbyak-dev libboost-dev libboost-fiber-dev libboost-context-dev libsdl3-dev libopus-dev libasound2t64 vulkan-utility-libraries-dev ``` - Ubuntu 26.04, Linux Mint 22.3, or Debian 13 or later is required. @@ -175,7 +174,7 @@ sudo apt-get install autoconf cmake g++ gcc git glslang-tools libglu1-mesa-dev l Fedora: ```sh -sudo dnf install autoconf cmake fmt-devel gcc{,-c++} glslang hidapi-devel json-devel libtool libusb1-devel libzstd-devel lz4-devel nasm ninja-build openssl-devel pulseaudio-libs-devel qt6-linguist qt6-qtbase{-private,}-devel qt6-qtwebengine-devel qt6-qtmultimedia-devel qt6-charts-devel speexdsp-devel wayland-devel zlib-devel ffmpeg-devel libXext-devel boost jq +sudo dnf install autoconf cmake gcc{,-c++} glslang hidapi-devel json-devel libtool libusb1-devel libzstd-devel lz4-devel nasm ninja-build openssl-devel pulseaudio-libs-devel qt6-linguist qt6-qtbase{-private,}-devel qt6-qtwebengine-devel qt6-qtmultimedia-devel qt6-charts-devel speexdsp-devel wayland-devel zlib-devel ffmpeg-devel libXext-devel boost jq ``` AlmaLinux (use `YUZU_USE_CPM=ON`): @@ -191,7 +190,7 @@ sudo dnf config-manager --enable crb sudo dnf install qt6-qtbase-private-devel ``` -For systems like OpenEuler or derivates, don't forget to also install: `SDL3-devel pkg-config fmt-dev`. +For systems like OpenEuler or derivates, don't forget to also install: `SDL3-devel pkg-config`. - [RPM Fusion](https://rpmfusion.org/Configuration) is required for `ffmpeg-devel` - Fedora 42 or later is required. @@ -215,7 +214,7 @@ apk add g++ git cmake make mesa-dev qt6-qtbase-dev qt6-qtbase-private-dev libqua Void Linux ```sh -xbps-install -Su git make cmake clang pkg-config patch SPIRV-Tools-devel SPIRV-Headers lz4 liblz4-devel boost-devel ffmpeg6-devel catch2 Vulkan-Utility-Libraries Vulkan-Headers glslang openssl-devel SDL3-devel quazip-qt6-devel qt6-base-devel qt6-charts-devel fmt-devel libenet-devel libusb-devel +xbps-install -Su git make cmake clang pkg-config patch SPIRV-Tools-devel SPIRV-Headers lz4 liblz4-devel boost-devel ffmpeg6-devel catch2 Vulkan-Utility-Libraries Vulkan-Headers glslang openssl-devel SDL3-devel quazip-qt6-devel qt6-base-devel qt6-charts-devel libenet-devel libusb-devel ``` @@ -234,7 +233,7 @@ If you're going for a pure build (i.e no downloaded deps), use `-DYUZU_USE_CPM=O Install dependencies from **[Homebrew](https://brew.sh/)** ```sh -brew install autoconf automake boost ffmpeg fmt glslang hidapi libtool libusb lz4 ninja openssl pkg-config qt@6 sdl3 speexdsp zlib zstd cmake Catch2 molten-vk vulkan-loader spirv-tools +brew install autoconf automake boost ffmpeg glslang hidapi libtool libusb lz4 ninja openssl pkg-config qt@6 sdl3 speexdsp zlib zstd cmake Catch2 molten-vk vulkan-loader spirv-tools ``` If you are compiling on Intel Mac, or are using a Rosetta Homebrew installation, you must replace all references of `/opt/homebrew` with `/usr/local`. @@ -254,7 +253,7 @@ brew install molten-vk As root run: ```sh -pkg install devel/cmake devel/sdl3 devel/boost-libs devel/catch2 devel/libfmt devel/ninja devel/nasm devel/autoconf devel/pkgconf devel/qt6-base x11-toolkits/qt6-charts devel/simpleini net/enet multimedia/ffnvcodec-headers multimedia/ffmpeg audio/opus archivers/liblz4 lang/gcc16 graphics/glslang graphics/vulkan-utility-libraries graphics/spirv-tools graphics/vulkan-utility-libraries graphics/vulkan-headers graphics/spirv-headers quazip-qt6 +pkg install devel/cmake devel/sdl3 devel/boost-libs devel/catch2 devel/ninja devel/nasm devel/autoconf devel/pkgconf devel/qt6-base x11-toolkits/qt6-charts devel/simpleini net/enet multimedia/ffnvcodec-headers multimedia/ffmpeg audio/opus archivers/liblz4 lang/gcc16 graphics/glslang graphics/vulkan-utility-libraries graphics/spirv-tools graphics/vulkan-utility-libraries graphics/vulkan-headers graphics/spirv-headers quazip-qt6 ``` FreeBSD 15 or later is required. @@ -268,7 +267,7 @@ FreeBSD 15 or later is required. For NetBSD +10.1: ```sh -pkgin install git cmake boost fmtlib SDL3 catch2 libjwt spirv-headers spirv-tools ffmpeg7 libva jq libopus qt6-qtbase qt6-qtcharts qt6-qtmultimedia qt6-qttools lz4 vulkan-headers nasm autoconf enet pkg-config libusb1 libcxx frozen +pkgin install git cmake boost SDL3 catch2 libjwt spirv-headers spirv-tools ffmpeg7 libva jq libopus qt6-qtbase qt6-qtcharts qt6-qtmultimedia qt6-qttools lz4 vulkan-headers nasm autoconf enet pkg-config libusb1 libcxx frozen ``` [Caveats](./Caveats.md#netbsd). @@ -279,7 +278,7 @@ pkgin install git cmake boost fmtlib SDL3 catch2 libjwt spirv-headers spirv-tool ```sh pkg_add -u -pkg_add cmake nasm git boost unzip--iconv autoconf-2.72p0 bash ffmpeg glslang gmake qt6 jq fmt enet boost vulkan-utility-libraries vulkan-headers spirv-headers spirv-tools catch2 sdl3 libusb1-1.0.29 quazip-qt6 +pkg_add cmake nasm git boost unzip--iconv autoconf-2.72p0 bash ffmpeg glslang gmake qt6 jq enet boost vulkan-utility-libraries vulkan-headers spirv-headers spirv-tools catch2 sdl3 libusb1-1.0.29 quazip-qt6 ``` [Caveats](./Caveats.md#openbsd). @@ -289,7 +288,7 @@ pkg_add cmake nasm git boost unzip--iconv autoconf-2.72p0 bash ffmpeg glslang gm DragonFlyBSD ```sh -pkg install gcc16 git cmake unzip nasm autoconf bash pkgconf ffmpeg glslang gmake jq enet spirv-tools sdl3 vulkan-utility-libraries vulkan-headers catch2 libfmt openssl liblz4 boost-libs qt6-base qt6-charts quazip-qt6 libva-vdpau-driver libva-utils libva-intel-driver +pkg install gcc16 git cmake unzip nasm autoconf bash pkgconf ffmpeg glslang gmake jq enet spirv-tools sdl3 vulkan-utility-libraries vulkan-headers catch2 openssl liblz4 boost-libs qt6-base qt6-charts quazip-qt6 libva-vdpau-driver libva-utils libva-intel-driver ``` [Caveats](./Caveats.md#dragonflybsd). @@ -301,7 +300,7 @@ pkg install gcc16 git cmake unzip nasm autoconf bash pkgconf ffmpeg glslang gmak OpenIndiana is currently unsupported due to its GCC version being too old. When GCC 16 gets added to the main repositories: ```sh -sudo pkg install git cmake qt6 boost glslang libzip library/lz4 libusb-1 openssl opus sdl3 zlib compress/zstd unzip pkg-config nasm autoconf mesa library/libdrm header-drm developer/fmt gcc-16 +sudo pkg install git cmake qt6 boost glslang libzip library/lz4 libusb-1 openssl opus sdl3 zlib compress/zstd unzip pkg-config nasm autoconf mesa library/libdrm header-drm gcc-16 ``` [Caveats](./Caveats.md#openindiana). @@ -328,7 +327,7 @@ sudo pkgin install git cmake autoconf build-essential libusb-1 nasm gcc16 ```sh pacman -Syu pacman -S --needed git make autoconf libtool automake-wrapper jq patch pactoys -pacboy -S --needed qt6-base qt6-charts qt6-tools qt6-translations qt6-svg cmake toolchain clang python-pip openssl vulkan-memory-allocator vulkan-devel glslang boost fmt lz4 zlib zstd enet opus libusb openssl SDL3 +pacboy -S --needed qt6-base qt6-charts qt6-tools qt6-translations qt6-svg cmake toolchain clang python-pip openssl vulkan-memory-allocator vulkan-devel glslang boost lz4 zlib zstd enet opus libusb openssl SDL3 ``` - Notes: @@ -345,7 +344,7 @@ pacboy -S --needed qt6-base qt6-charts qt6-tools qt6-translations qt6-svg cmake HaikuOS ```sh -pkgman install git cmake patch libfmt_devel lz4_devel opus_devel boost1.90_devel vulkan_devel qt6_base_devel qt6_declarative_devel libsdl3_devel ffmpeg7_devel libx11_devel enet_devel catch2_devel quazip1_qt5_devel qt6_5compat_devel glslang qt6_devel qt6_charts_devel cubeb_devel simpleini quazip_qt6_devel +pkgman install git cmake patch lz4_devel opus_devel boost1.90_devel vulkan_devel qt6_base_devel qt6_declarative_devel libsdl3_devel ffmpeg7_devel libx11_devel enet_devel catch2_devel quazip1_qt5_devel qt6_5compat_devel glslang qt6_devel qt6_charts_devel cubeb_devel simpleini quazip_qt6_devel ``` [Caveats](./Caveats.md#haikuos). diff --git a/shell.nix b/shell.nix index dec27f3534..372c92eee4 100755 --- a/shell.nix +++ b/shell.nix @@ -11,7 +11,7 @@ pkgs.mkShellNoCC { # essential programs git cmake clang gnumake patch jq pkg-config # libraries - openssl boost fmt lz4 zlib zstd + openssl boost lz4 zlib zstd enet vulkan-headers vulkan-utility-libraries spirv-tools spirv-headers vulkan-loader unzip glslang python3 cpp-jwt ffmpeg-headless diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index 39a861c0e4..7abd719bc7 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -655,7 +656,7 @@ std::pair get_pretty_cpus() { const auto part = (midr >> 4) & 0xfff; if (!cpus.empty()) cpus += " + "; - cpus += fmt::format("{}x {}", count, find_cpu_name(vendor, part)); + cpus += std::format("{}x {}", count, find_cpu_name(vendor, part)); } } @@ -879,7 +880,7 @@ jobjectArray Java_org_yuzu_yuzu_1emu_utils_GpuDriverHelper_getSystemDriverInfo( auto driver_version = device.GetDriverVersion(); auto version_string = - fmt::format("{}.{}.{}", VK_API_VERSION_MAJOR(driver_version), + std::format("{}.{}.{}", VK_API_VERSION_MAJOR(driver_version), VK_API_VERSION_MINOR(driver_version), VK_API_VERSION_PATCH(driver_version)); auto driver_name = device.GetDriverName(); #else @@ -1075,7 +1076,7 @@ jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getCpuSummary(JNIEnv* env, jobject u32 threads = pretty_cpus.first; std::string cpus = pretty_cpus.second; - fmt::format_to(std::back_inserter(result), "CPUs: {}\n{} Threads", + std::format_to(std::back_inserter(result), "CPUs: {}\n{} Threads", cpus, threads); FILE* f = std::fopen(CPUINFO_PATH, "r"); @@ -1163,7 +1164,7 @@ jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getCpuSummary(JNIEnv* env, jobject } } - fmt::format_to(std::back_inserter(result), "\nLLVM CPU: {}", fallback_cpu_detection()); + std::format_to(std::back_inserter(result), "\nLLVM CPU: {}", fallback_cpu_detection()); return Common::Android::ToJString(env, result); } catch (...) { @@ -1247,7 +1248,7 @@ jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getVulkanDriverVersion(JNIEnv* env const u32 major = (driver_version >> 24) << 2; const u32 minor = (driver_version >> 12) & 0xFFF; const u32 patch = driver_version & 0xFFF; - version_str = fmt::format("{}.{}.{}", major, minor, patch); + version_str = std::format("{}.{}.{}", major, minor, patch); } else if (vendor_id == VENDOR_ARM) { u32 major = VK_API_VERSION_MAJOR(driver_version); @@ -1260,14 +1261,14 @@ jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getVulkanDriverVersion(JNIEnv* env minor = (driver_version >> 12) & 0x3FF; patch = driver_version & 0xFFF; } - version_str = fmt::format("{}.{}.{}", major, minor, patch); + version_str = std::format("{}.{}.{}", major, minor, patch); } // Standard Vulkan version encoding for other vendors else { const u32 major = VK_API_VERSION_MAJOR(driver_version); const u32 minor = VK_API_VERSION_MINOR(driver_version); const u32 patch = VK_API_VERSION_PATCH(driver_version); - version_str = fmt::format("{}.{}.{}", major, minor, patch); + version_str = std::format("{}.{}.{}", major, minor, patch); } return Common::Android::ToJString(env, version_str); @@ -1291,8 +1292,8 @@ jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getVulkanApiVersion(JNIEnv* env, j // Include variant if non-zero (rare on Android) const std::string version_str = variant > 0 - ? fmt::format("{}.{}.{}.{}", variant, major, minor, patch) - : fmt::format("{}.{}.{}", major, minor, patch); + ? std::format("{}.{}.{}.{}", variant, major, minor, patch) + : std::format("{}.{}.{}", major, minor, patch); return Common::Android::ToJString(env, version_str); } catch (...) { @@ -1382,7 +1383,7 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_run(JNIEnv* env, jobject jobj, jstrin } void Java_org_yuzu_yuzu_1emu_NativeLibrary_logDeviceInfo(JNIEnv* env, jclass clazz) { - LOG_INFO(Frontend, "eden Version: {}-{}", Common::g_scm_branch, Common::g_scm_desc); + LOG_INFO(Frontend, "eden Version: {}-{}", std::string_view{Common::g_scm_branch}, std::string_view{Common::g_scm_desc}); LOG_INFO(Frontend, "Host OS: Android API level {}", android_get_device_api_level()); } @@ -2161,7 +2162,7 @@ JNIEXPORT jstring JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_getUserImagePath const auto uuid = Common::UUID{uuid_string}; const auto path = Common::FS::GetEdenPath(Common::FS::EdenPath::NANDDir) / - fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString()); + std::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString()); jstring result = Common::Android::ToJString(env, Common::FS::PathToUTF8String(path)); return result ? result : env->NewStringUTF(""); @@ -2177,7 +2178,7 @@ JNIEXPORT jboolean JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_saveUserImage( const auto image_source = Common::Android::GetJString(env, jimagePath); const auto dest_path = Common::FS::GetEdenPath(Common::FS::EdenPath::NANDDir) / - fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString()); + std::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString()); const auto dest_dir = dest_path.parent_path(); if (!Common::FS::CreateDirs(dest_dir)) { diff --git a/src/android/app/src/main/jni/native_config.cpp b/src/android/app/src/main/jni/native_config.cpp index 1b8e343986..7bfe30e5a7 100644 --- a/src/android/app/src/main/jni/native_config.cpp +++ b/src/android/app/src/main/jni/native_config.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include +#include #include @@ -72,7 +73,7 @@ void Java_org_yuzu_yuzu_1emu_utils_NativeConfig_initializePerGameConfig(JNIEnv* jstring jfileName) { auto program_id = EmulationSession::GetProgramId(env, jprogramId); auto file_name = Common::Android::GetJString(env, jfileName); - const auto config_file_name = program_id == 0 ? file_name : fmt::format("{:016X}", program_id); + const auto config_file_name = program_id == 0 ? file_name : std::format("{:016X}", program_id); per_game_config = std::make_unique(config_file_name, Config::ConfigType::PerGameConfig); } diff --git a/src/android/app/src/main/jni/native_input.cpp b/src/android/app/src/main/jni/native_input.cpp index e05ab2f209..a8b4af0995 100644 --- a/src/android/app/src/main/jni/native_input.cpp +++ b/src/android/app/src/main/jni/native_input.cpp @@ -4,6 +4,8 @@ // SPDX-FileCopyrightText: 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include + #include #include #include @@ -48,7 +50,7 @@ bool IsProfileNameValid(std::string_view profile_name) { bool ProfileExistsInFilesystem(std::string_view profile_name) { return Common::FS::Exists(Common::FS::GetEdenPath(Common::FS::EdenPath::ConfigDir) / "input" / - fmt::format("{}.ini", profile_name)); + std::format("{}.ini", profile_name)); } bool ProfileExistsInMap(const std::string& profile_name) { diff --git a/src/audio_core/adsp/apps/audio_renderer/audio_renderer.cpp b/src/audio_core/adsp/apps/audio_renderer/audio_renderer.cpp index 45a69eca03..1dc6eb2875 100644 --- a/src/audio_core/adsp/apps/audio_renderer/audio_renderer.cpp +++ b/src/audio_core/adsp/apps/audio_renderer/audio_renderer.cpp @@ -122,7 +122,7 @@ u64 AudioRenderer::GetRenderingStartTick(s32 session_id) const noexcept { void AudioRenderer::CreateSinkStreams() { u32 channels{sink.GetDeviceChannels()}; for (u32 i = 0; i < MaxRendererSessions; i++) { - std::string name{fmt::format("ADSP_RenderStream-{}", i)}; + std::string name{std::format("ADSP_RenderStream-{}", i)}; streams[i] = sink.AcquireSinkStream(system, channels, name, ::AudioCore::Sink::StreamType::Render); streams[i]->SetRingSize(4); diff --git a/src/audio_core/adsp/apps/audio_renderer/command_list_processor.cpp b/src/audio_core/adsp/apps/audio_renderer/command_list_processor.cpp index eef2c0b89c..4e51f11afe 100644 --- a/src/audio_core/adsp/apps/audio_renderer/command_list_processor.cpp +++ b/src/audio_core/adsp/apps/audio_renderer/command_list_processor.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -53,7 +56,7 @@ u64 CommandListProcessor::Process(u32 session_id) { current_processing_time = 0; } - std::string dump{fmt::format("\nSession {}\n", session_id)}; + std::string dump{std::format("\nSession {}\n", session_id)}; for (u32 index = 0; index < command_count; index++) { auto& command{*reinterpret_cast(commands)}; @@ -85,7 +88,7 @@ u64 CommandListProcessor::Process(u32 session_id) { if (command.enabled) { command.Process(*this); } else { - dump += fmt::format("\tDisabled!\n"); + dump += std::format("\tDisabled!\n"); } processed_command_count++; diff --git a/src/audio_core/common/common.h b/src/audio_core/common/common.h index f1c35ad60f..04d98e5922 100644 --- a/src/audio_core/common/common.h +++ b/src/audio_core/common/common.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project diff --git a/src/audio_core/device/device_session.cpp b/src/audio_core/device/device_session.cpp index 2e9da7876f..ad80e3c51e 100644 --- a/src/audio_core/device/device_session.cpp +++ b/src/audio_core/device/device_session.cpp @@ -36,7 +36,7 @@ Result DeviceSession::Initialize(std::string_view name_, SampleFormat sample_for if (stream) { Finalize(); } - name = fmt::format("{}-{}", name_, session_id_); + name = std::format("{}-{}", name_, session_id_); type = type_; sample_format = sample_format_; channel_count = channel_count_; diff --git a/src/audio_core/renderer/command/data_source/adpcm.cpp b/src/audio_core/renderer/command/data_source/adpcm.cpp index e7f82d3b3e..4bc0694043 100644 --- a/src/audio_core/renderer/command/data_source/adpcm.cpp +++ b/src/audio_core/renderer/command/data_source/adpcm.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -11,7 +14,7 @@ namespace AudioCore::Renderer { void AdpcmDataSourceVersion1Command::Dump(const AudioRenderer::CommandListProcessor& processor, std::string& string) { - string += fmt::format("AdpcmDataSourceVersion1Command\n\toutput_index {:02X} source sample " + string += std::format("AdpcmDataSourceVersion1Command\n\toutput_index {:02X} source sample " "rate {} target sample rate {} src quality {}\n", output_index, sample_rate, processor.target_sample_rate, src_quality); } @@ -53,7 +56,7 @@ bool AdpcmDataSourceVersion1Command::Verify(const AudioRenderer::CommandListProc void AdpcmDataSourceVersion2Command::Dump(const AudioRenderer::CommandListProcessor& processor, std::string& string) { - string += fmt::format("AdpcmDataSourceVersion2Command\n\toutput_index {:02X} source sample " + string += std::format("AdpcmDataSourceVersion2Command\n\toutput_index {:02X} source sample " "rate {} target sample rate {} src quality {}\n", output_index, sample_rate, processor.target_sample_rate, src_quality); } diff --git a/src/audio_core/renderer/command/data_source/pcm_float.cpp b/src/audio_core/renderer/command/data_source/pcm_float.cpp index d1f6856569..b0997d2f45 100644 --- a/src/audio_core/renderer/command/data_source/pcm_float.cpp +++ b/src/audio_core/renderer/command/data_source/pcm_float.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -10,7 +13,7 @@ namespace AudioCore::Renderer { void PcmFloatDataSourceVersion1Command::Dump(const AudioRenderer::CommandListProcessor& processor, std::string& string) { string += - fmt::format("PcmFloatDataSourceVersion1Command\n\toutput_index {:02X} channel {} " + std::format("PcmFloatDataSourceVersion1Command\n\toutput_index {:02X} channel {} " "channel count {} source sample rate {} target sample rate {} src quality {}\n", output_index, channel_index, channel_count, sample_rate, processor.target_sample_rate, src_quality); @@ -56,7 +59,7 @@ bool PcmFloatDataSourceVersion1Command::Verify( void PcmFloatDataSourceVersion2Command::Dump(const AudioRenderer::CommandListProcessor& processor, std::string& string) { string += - fmt::format("PcmFloatDataSourceVersion2Command\n\toutput_index {:02X} channel {} " + std::format("PcmFloatDataSourceVersion2Command\n\toutput_index {:02X} channel {} " "channel count {} source sample rate {} target sample rate {} src quality {}\n", output_index, channel_index, channel_count, sample_rate, processor.target_sample_rate, src_quality); diff --git a/src/audio_core/renderer/command/data_source/pcm_int16.cpp b/src/audio_core/renderer/command/data_source/pcm_int16.cpp index c89a5aaac9..0003314246 100644 --- a/src/audio_core/renderer/command/data_source/pcm_int16.cpp +++ b/src/audio_core/renderer/command/data_source/pcm_int16.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -12,7 +15,7 @@ namespace AudioCore::Renderer { void PcmInt16DataSourceVersion1Command::Dump(const AudioRenderer::CommandListProcessor& processor, std::string& string) { string += - fmt::format("PcmInt16DataSourceVersion1Command\n\toutput_index {:02X} channel {} " + std::format("PcmInt16DataSourceVersion1Command\n\toutput_index {:02X} channel {} " "channel count {} source sample rate {} target sample rate {} src quality {}\n", output_index, channel_index, channel_count, sample_rate, processor.target_sample_rate, src_quality); @@ -58,7 +61,7 @@ bool PcmInt16DataSourceVersion1Command::Verify( void PcmInt16DataSourceVersion2Command::Dump(const AudioRenderer::CommandListProcessor& processor, std::string& string) { string += - fmt::format("PcmInt16DataSourceVersion2Command\n\toutput_index {:02X} channel {} " + std::format("PcmInt16DataSourceVersion2Command\n\toutput_index {:02X} channel {} " "channel count {} source sample rate {} target sample rate {} src quality {}\n", output_index, channel_index, channel_count, sample_rate, processor.target_sample_rate, src_quality); diff --git a/src/audio_core/renderer/command/effect/aux_.cpp b/src/audio_core/renderer/command/effect/aux_.cpp index 5cee02a55c..72be5276ef 100644 --- a/src/audio_core/renderer/command/effect/aux_.cpp +++ b/src/audio_core/renderer/command/effect/aux_.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project @@ -180,7 +180,7 @@ static u32 ReadAuxBufferDsp(Core::Memory::Memory& memory, CpuAddr return_info_, void AuxCommand::Dump([[maybe_unused]] const AudioRenderer::CommandListProcessor& processor, std::string& string) { - string += fmt::format("AuxCommand\n\tenabled {} input {:02X} output {:02X}\n", effect_enabled, + string += std::format("AuxCommand\n\tenabled {} input {:02X} output {:02X}\n", effect_enabled, input, output); } diff --git a/src/audio_core/renderer/command/effect/biquad_filter.cpp b/src/audio_core/renderer/command/effect/biquad_filter.cpp index 04e739d289..c3c2ab6e09 100644 --- a/src/audio_core/renderer/command/effect/biquad_filter.cpp +++ b/src/audio_core/renderer/command/effect/biquad_filter.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project @@ -116,7 +116,7 @@ static void ApplyBiquadFilterInt(std::span output, std::span inp void BiquadFilterCommand::Dump( [[maybe_unused]] const AudioRenderer::CommandListProcessor& processor, std::string& string) { - string += fmt::format( + string += std::format( "BiquadFilterCommand\n\tinput {:02X} output {:02X} needs_init {} use_float_processing {}\n", input, output, needs_init, use_float_processing); } diff --git a/src/audio_core/renderer/command/effect/capture.cpp b/src/audio_core/renderer/command/effect/capture.cpp index 4267580128..14364f5b2f 100644 --- a/src/audio_core/renderer/command/effect/capture.cpp +++ b/src/audio_core/renderer/command/effect/capture.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project @@ -123,7 +123,7 @@ static u32 WriteAuxBufferDsp(Core::Memory::Memory& memory, const CpuAddr send_in void CaptureCommand::Dump([[maybe_unused]] const AudioRenderer::CommandListProcessor& processor, std::string& string) { - string += fmt::format("CaptureCommand\n\tenabled {} input {:02X} output {:02X}", effect_enabled, + string += std::format("CaptureCommand\n\tenabled {} input {:02X} output {:02X}", effect_enabled, input, output); } diff --git a/src/audio_core/renderer/command/effect/compressor.cpp b/src/audio_core/renderer/command/effect/compressor.cpp index 7ff707f4e0..9c7a8d2f7c 100644 --- a/src/audio_core/renderer/command/effect/compressor.cpp +++ b/src/audio_core/renderer/command/effect/compressor.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -112,13 +115,13 @@ static void ApplyCompressorEffect(const CompressorInfo::ParameterVersion2& param void CompressorCommand::Dump([[maybe_unused]] const AudioRenderer::CommandListProcessor& processor, std::string& string) { - string += fmt::format("CompressorCommand\n\tenabled {} \n\tinputs: ", effect_enabled); + string += std::format("CompressorCommand\n\tenabled {} \n\tinputs: ", effect_enabled); for (s16 i = 0; i < parameter.channel_count; i++) { - string += fmt::format("{:02X}, ", inputs[i]); + string += std::format("{:02X}, ", inputs[i]); } string += "\n\toutputs: "; for (s16 i = 0; i < parameter.channel_count; i++) { - string += fmt::format("{:02X}, ", outputs[i]); + string += std::format("{:02X}, ", outputs[i]); } string += "\n"; } diff --git a/src/audio_core/renderer/command/effect/delay.cpp b/src/audio_core/renderer/command/effect/delay.cpp index ffb298c072..97f1d3e480 100644 --- a/src/audio_core/renderer/command/effect/delay.cpp +++ b/src/audio_core/renderer/command/effect/delay.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -196,13 +199,13 @@ static void ApplyDelayEffect(const DelayInfo::ParameterVersion1& params, DelayIn void DelayCommand::Dump([[maybe_unused]] const AudioRenderer::CommandListProcessor& processor, std::string& string) { - string += fmt::format("DelayCommand\n\tenabled {} \n\tinputs: ", effect_enabled); + string += std::format("DelayCommand\n\tenabled {} \n\tinputs: ", effect_enabled); for (u32 i = 0; i < MaxChannels; i++) { - string += fmt::format("{:02X}, ", inputs[i]); + string += std::format("{:02X}, ", inputs[i]); } string += "\n\toutputs: "; for (u32 i = 0; i < MaxChannels; i++) { - string += fmt::format("{:02X}, ", outputs[i]); + string += std::format("{:02X}, ", outputs[i]); } string += "\n"; } diff --git a/src/audio_core/renderer/command/effect/i3dl2_reverb.cpp b/src/audio_core/renderer/command/effect/i3dl2_reverb.cpp index be5e36d2ae..83244bfbcc 100644 --- a/src/audio_core/renderer/command/effect/i3dl2_reverb.cpp +++ b/src/audio_core/renderer/command/effect/i3dl2_reverb.cpp @@ -1,10 +1,11 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include +#include #include "audio_core/adsp/apps/audio_renderer/command_list_processor.h" #include "audio_core/renderer/command/effect/i3dl2_reverb.h" @@ -399,13 +400,13 @@ static void ApplyI3dl2ReverbEffect(const I3dl2ReverbInfo::ParameterVersion1& par void I3dl2ReverbCommand::Dump([[maybe_unused]] const AudioRenderer::CommandListProcessor& processor, std::string& string) { - string += fmt::format("I3dl2ReverbCommand\n\tenabled {} \n\tinputs: ", effect_enabled); + string += std::format("I3dl2ReverbCommand\n\tenabled {} \n\tinputs: ", effect_enabled); for (u32 i = 0; i < parameter.channel_count; i++) { - string += fmt::format("{:02X}, ", inputs[i]); + string += std::format("{:02X}, ", inputs[i]); } string += "\n\toutputs: "; for (u32 i = 0; i < parameter.channel_count; i++) { - string += fmt::format("{:02X}, ", outputs[i]); + string += std::format("{:02X}, ", outputs[i]); } string += "\n"; } diff --git a/src/audio_core/renderer/command/effect/light_limiter.cpp b/src/audio_core/renderer/command/effect/light_limiter.cpp index 7f0455461f..58fa664b8d 100644 --- a/src/audio_core/renderer/command/effect/light_limiter.cpp +++ b/src/audio_core/renderer/command/effect/light_limiter.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project @@ -138,13 +138,13 @@ static void ApplyLightLimiterEffect(const LightLimiterInfo::ParameterVersion2& p void LightLimiterVersion1Command::Dump( [[maybe_unused]] const AudioRenderer::CommandListProcessor& processor, std::string& string) { - string += fmt::format("LightLimiterVersion1Command\n\tinputs: "); + string += std::format("LightLimiterVersion1Command\n\tinputs: "); for (u32 i = 0; i < MaxChannels; i++) { - string += fmt::format("{:02X}, ", inputs[i]); + string += std::format("{:02X}, ", inputs[i]); } string += "\n\toutputs: "; for (u32 i = 0; i < MaxChannels; i++) { - string += fmt::format("{:02X}, ", outputs[i]); + string += std::format("{:02X}, ", outputs[i]); } string += "\n"; } @@ -181,13 +181,13 @@ bool LightLimiterVersion1Command::Verify(const AudioRenderer::CommandListProcess void LightLimiterVersion2Command::Dump( [[maybe_unused]] const AudioRenderer::CommandListProcessor& processor, std::string& string) { - string += fmt::format("LightLimiterVersion2Command\n\tinputs: \n"); + string += std::format("LightLimiterVersion2Command\n\tinputs: \n"); for (u32 i = 0; i < MaxChannels; i++) { - string += fmt::format("{:02X}, ", inputs[i]); + string += std::format("{:02X}, ", inputs[i]); } string += "\n\toutputs: "; for (u32 i = 0; i < MaxChannels; i++) { - string += fmt::format("{:02X}, ", outputs[i]); + string += std::format("{:02X}, ", outputs[i]); } string += "\n"; } diff --git a/src/audio_core/renderer/command/effect/multi_tap_biquad_filter.cpp b/src/audio_core/renderer/command/effect/multi_tap_biquad_filter.cpp index 2dfbcf6145..492f6b118f 100644 --- a/src/audio_core/renderer/command/effect/multi_tap_biquad_filter.cpp +++ b/src/audio_core/renderer/command/effect/multi_tap_biquad_filter.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project @@ -12,7 +12,7 @@ namespace AudioCore::Renderer { void MultiTapBiquadFilterCommand::Dump( [[maybe_unused]] const AudioRenderer::CommandListProcessor& processor, std::string& string) { - string += fmt::format( + string += std::format( "MultiTapBiquadFilterCommand\n\tinput {:02X}\n\toutput {:02X}\n\tneeds_init ({}, {})\n", input, output, needs_init[0], needs_init[1]); } diff --git a/src/audio_core/renderer/command/effect/reverb.cpp b/src/audio_core/renderer/command/effect/reverb.cpp index ec3a82802f..c3a23949e0 100644 --- a/src/audio_core/renderer/command/effect/reverb.cpp +++ b/src/audio_core/renderer/command/effect/reverb.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project @@ -6,6 +6,7 @@ #include #include +#include #include "audio_core/adsp/apps/audio_renderer/command_list_processor.h" #include "audio_core/renderer/command/effect/reverb.h" @@ -434,15 +435,15 @@ static void ApplyReverbEffect(const ReverbInfo::ParameterVersion2& params, Rever void ReverbCommand::Dump([[maybe_unused]] const AudioRenderer::CommandListProcessor& processor, std::string& string) { - string += fmt::format( + string += std::format( "ReverbCommand\n\tenabled {} long_size_pre_delay_supported {}\n\tinputs: ", effect_enabled, long_size_pre_delay_supported); for (u32 i = 0; i < MaxChannels; i++) { - string += fmt::format("{:02X}, ", inputs[i]); + string += std::format("{:02X}, ", inputs[i]); } string += "\n\toutputs: "; for (u32 i = 0; i < MaxChannels; i++) { - string += fmt::format("{:02X}, ", outputs[i]); + string += std::format("{:02X}, ", outputs[i]); } string += "\n"; } diff --git a/src/audio_core/renderer/command/mix/clear_mix.cpp b/src/audio_core/renderer/command/mix/clear_mix.cpp index 060d7cb28f..1a073df6f0 100644 --- a/src/audio_core/renderer/command/mix/clear_mix.cpp +++ b/src/audio_core/renderer/command/mix/clear_mix.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -10,7 +13,7 @@ namespace AudioCore::Renderer { void ClearMixBufferCommand::Dump( [[maybe_unused]] const AudioRenderer::CommandListProcessor& processor, std::string& string) { - string += fmt::format("ClearMixBufferCommand\n"); + string += std::format("ClearMixBufferCommand\n"); } void ClearMixBufferCommand::Process(const AudioRenderer::CommandListProcessor& processor) { diff --git a/src/audio_core/renderer/command/mix/copy_mix.cpp b/src/audio_core/renderer/command/mix/copy_mix.cpp index 5d386f95a4..1c99882d80 100644 --- a/src/audio_core/renderer/command/mix/copy_mix.cpp +++ b/src/audio_core/renderer/command/mix/copy_mix.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -8,7 +11,7 @@ namespace AudioCore::Renderer { void CopyMixBufferCommand::Dump( [[maybe_unused]] const AudioRenderer::CommandListProcessor& processor, std::string& string) { - string += fmt::format("CopyMixBufferCommand\n\tinput {:02X} output {:02X}\n", input_index, + string += std::format("CopyMixBufferCommand\n\tinput {:02X} output {:02X}\n", input_index, output_index); } diff --git a/src/audio_core/renderer/command/mix/depop_for_mix_buffers.cpp b/src/audio_core/renderer/command/mix/depop_for_mix_buffers.cpp index 5c062b2e9c..bc48d7f58d 100644 --- a/src/audio_core/renderer/command/mix/depop_for_mix_buffers.cpp +++ b/src/audio_core/renderer/command/mix/depop_for_mix_buffers.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project @@ -41,7 +41,7 @@ static s32 ApplyDepopMix(std::span output, const s32 depop_sample, void DepopForMixBuffersCommand::Dump( [[maybe_unused]] const AudioRenderer::CommandListProcessor& processor, std::string& string) { - string += fmt::format("DepopForMixBuffersCommand\n\tinput {:02X} count {} decay {}\n", input, + string += std::format("DepopForMixBuffersCommand\n\tinput {:02X} count {} decay {}\n", input, count, decay.to_float()); } diff --git a/src/audio_core/renderer/command/mix/depop_prepare.cpp b/src/audio_core/renderer/command/mix/depop_prepare.cpp index 2faf4681a9..ace2d5465d 100644 --- a/src/audio_core/renderer/command/mix/depop_prepare.cpp +++ b/src/audio_core/renderer/command/mix/depop_prepare.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -10,9 +13,9 @@ namespace AudioCore::Renderer { void DepopPrepareCommand::Dump( [[maybe_unused]] const AudioRenderer::CommandListProcessor& processor, std::string& string) { - string += fmt::format("DepopPrepareCommand\n\tinputs: "); + string += std::format("DepopPrepareCommand\n\tinputs: "); for (u32 i = 0; i < buffer_count; i++) { - string += fmt::format("{:02X}, ", inputs[i]); + string += std::format("{:02X}, ", inputs[i]); } string += "\n"; } diff --git a/src/audio_core/renderer/command/mix/mix.cpp b/src/audio_core/renderer/command/mix/mix.cpp index 8bd689b888..581f48b223 100644 --- a/src/audio_core/renderer/command/mix/mix.cpp +++ b/src/audio_core/renderer/command/mix/mix.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -30,10 +33,10 @@ static void ApplyMix(std::span output, std::span input, const f3 void MixCommand::Dump([[maybe_unused]] const AudioRenderer::CommandListProcessor& processor, std::string& string) { - string += fmt::format("MixCommand"); - string += fmt::format("\n\tinput {:02X}", input_index); - string += fmt::format("\n\toutput {:02X}", output_index); - string += fmt::format("\n\tvolume {:.8f}", volume); + string += std::format("MixCommand"); + string += std::format("\n\tinput {:02X}", input_index); + string += std::format("\n\toutput {:02X}", output_index); + string += std::format("\n\tvolume {:.8f}", volume); string += "\n"; } diff --git a/src/audio_core/renderer/command/mix/mix_ramp.cpp b/src/audio_core/renderer/command/mix/mix_ramp.cpp index 51c75b1b93..d977e2a1f9 100644 --- a/src/audio_core/renderer/command/mix/mix_ramp.cpp +++ b/src/audio_core/renderer/command/mix/mix_ramp.cpp @@ -39,12 +39,12 @@ template s32 ApplyMixRamp<23>(std::span, std::span, f32, f32, u3 void MixRampCommand::Dump(const AudioRenderer::CommandListProcessor& processor, std::string& string) { const auto ramp{(volume - prev_volume) / static_cast(processor.sample_count)}; - string += fmt::format("MixRampCommand"); - string += fmt::format("\n\tinput {:02X}", input_index); - string += fmt::format("\n\toutput {:02X}", output_index); - string += fmt::format("\n\tvolume {:.8f}", volume); - string += fmt::format("\n\tprev_volume {:.8f}", prev_volume); - string += fmt::format("\n\tramp {:.8f}", ramp); + string += std::format("MixRampCommand"); + string += std::format("\n\tinput {:02X}", input_index); + string += std::format("\n\toutput {:02X}", output_index); + string += std::format("\n\tvolume {:.8f}", volume); + string += std::format("\n\tprev_volume {:.8f}", prev_volume); + string += std::format("\n\tramp {:.8f}", ramp); string += "\n"; } diff --git a/src/audio_core/renderer/command/mix/mix_ramp_grouped.cpp b/src/audio_core/renderer/command/mix/mix_ramp_grouped.cpp index 64138a9bfc..b70ac07561 100644 --- a/src/audio_core/renderer/command/mix/mix_ramp_grouped.cpp +++ b/src/audio_core/renderer/command/mix/mix_ramp_grouped.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -11,13 +14,13 @@ void MixRampGroupedCommand::Dump(const AudioRenderer::CommandListProcessor& proc std::string& string) { string += "MixRampGroupedCommand"; for (u32 i = 0; i < buffer_count; i++) { - string += fmt::format("\n\t{}", i); + string += std::format("\n\t{}", i); const auto ramp{(volumes[i] - prev_volumes[i]) / static_cast(processor.sample_count)}; - string += fmt::format("\n\t\tinput {:02X}", inputs[i]); - string += fmt::format("\n\t\toutput {:02X}", outputs[i]); - string += fmt::format("\n\t\tvolume {:.8f}", volumes[i]); - string += fmt::format("\n\t\tprev_volume {:.8f}", prev_volumes[i]); - string += fmt::format("\n\t\tramp {:.8f}", ramp); + string += std::format("\n\t\tinput {:02X}", inputs[i]); + string += std::format("\n\t\toutput {:02X}", outputs[i]); + string += std::format("\n\t\tvolume {:.8f}", volumes[i]); + string += std::format("\n\t\tprev_volume {:.8f}", prev_volumes[i]); + string += std::format("\n\t\tramp {:.8f}", ramp); string += "\n"; } } diff --git a/src/audio_core/renderer/command/mix/volume.cpp b/src/audio_core/renderer/command/mix/volume.cpp index 1e3f28c409..46dec04ed7 100644 --- a/src/audio_core/renderer/command/mix/volume.cpp +++ b/src/audio_core/renderer/command/mix/volume.cpp @@ -34,10 +34,10 @@ static void ApplyUniformGain(std::span output, std::span input, void VolumeCommand::Dump([[maybe_unused]] const AudioRenderer::CommandListProcessor& processor, std::string& string) { - string += fmt::format("VolumeCommand"); - string += fmt::format("\n\tinput {:02X}", input_index); - string += fmt::format("\n\toutput {:02X}", output_index); - string += fmt::format("\n\tvolume {:.8f}", volume); + string += std::format("VolumeCommand"); + string += std::format("\n\tinput {:02X}", input_index); + string += std::format("\n\toutput {:02X}", output_index); + string += std::format("\n\tvolume {:.8f}", volume); string += "\n"; } diff --git a/src/audio_core/renderer/command/mix/volume_ramp.cpp b/src/audio_core/renderer/command/mix/volume_ramp.cpp index fdc7519575..6a585cc66d 100644 --- a/src/audio_core/renderer/command/mix/volume_ramp.cpp +++ b/src/audio_core/renderer/command/mix/volume_ramp.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -41,12 +44,12 @@ static void ApplyLinearEnvelopeGain(std::span output, std::span void VolumeRampCommand::Dump(const AudioRenderer::CommandListProcessor& processor, std::string& string) { const auto ramp{(volume - prev_volume) / static_cast(processor.sample_count)}; - string += fmt::format("VolumeRampCommand"); - string += fmt::format("\n\tinput {:02X}", input_index); - string += fmt::format("\n\toutput {:02X}", output_index); - string += fmt::format("\n\tvolume {:.8f}", volume); - string += fmt::format("\n\tprev_volume {:.8f}", prev_volume); - string += fmt::format("\n\tramp {:.8f}", ramp); + string += std::format("VolumeRampCommand"); + string += std::format("\n\tinput {:02X}", input_index); + string += std::format("\n\toutput {:02X}", output_index); + string += std::format("\n\tvolume {:.8f}", volume); + string += std::format("\n\tprev_volume {:.8f}", prev_volume); + string += std::format("\n\tramp {:.8f}", ramp); string += "\n"; } diff --git a/src/audio_core/renderer/command/performance/performance.cpp b/src/audio_core/renderer/command/performance/performance.cpp index f0cfcc9fd0..db56d17e24 100644 --- a/src/audio_core/renderer/command/performance/performance.cpp +++ b/src/audio_core/renderer/command/performance/performance.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -10,7 +13,7 @@ namespace AudioCore::Renderer { void PerformanceCommand::Dump([[maybe_unused]] const AudioRenderer::CommandListProcessor& processor, std::string& string) { - string += fmt::format("PerformanceCommand\n\tstate {}\n", static_cast(state)); + string += std::format("PerformanceCommand\n\tstate {}\n", static_cast(state)); } void PerformanceCommand::Process(const AudioRenderer::CommandListProcessor& processor) { diff --git a/src/audio_core/renderer/command/resample/downmix_6ch_to_2ch.cpp b/src/audio_core/renderer/command/resample/downmix_6ch_to_2ch.cpp index f9b2898874..dc0d176d8d 100644 --- a/src/audio_core/renderer/command/resample/downmix_6ch_to_2ch.cpp +++ b/src/audio_core/renderer/command/resample/downmix_6ch_to_2ch.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -8,13 +11,13 @@ namespace AudioCore::Renderer { void DownMix6chTo2chCommand::Dump( [[maybe_unused]] const AudioRenderer::CommandListProcessor& processor, std::string& string) { - string += fmt::format("DownMix6chTo2chCommand\n\tinputs: "); + string += std::format("DownMix6chTo2chCommand\n\tinputs: "); for (u32 i = 0; i < MaxChannels; i++) { - string += fmt::format("{:02X}, ", inputs[i]); + string += std::format("{:02X}, ", inputs[i]); } string += "\n\toutputs: "; for (u32 i = 0; i < MaxChannels; i++) { - string += fmt::format("{:02X}, ", outputs[i]); + string += std::format("{:02X}, ", outputs[i]); } string += "\n"; } diff --git a/src/audio_core/renderer/command/resample/upsample.cpp b/src/audio_core/renderer/command/resample/upsample.cpp index 71d865264a..0f763819be 100644 --- a/src/audio_core/renderer/command/resample/upsample.cpp +++ b/src/audio_core/renderer/command/resample/upsample.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project @@ -203,14 +203,14 @@ static void SrcProcessFrame(std::span output, std::span input, auto UpsampleCommand::Dump([[maybe_unused]] const AudioRenderer::CommandListProcessor& processor, std::string& string) -> void { - string += fmt::format("UpsampleCommand\n\tsource_sample_count {} source_sample_rate {}", + string += std::format("UpsampleCommand\n\tsource_sample_count {} source_sample_rate {}", source_sample_count, source_sample_rate); const auto upsampler{reinterpret_cast(upsampler_info)}; if (upsampler != nullptr) { - string += fmt::format("\n\tUpsampler\n\t\tenabled {} sample count {}\n\tinputs: ", + string += std::format("\n\tUpsampler\n\t\tenabled {} sample count {}\n\tinputs: ", upsampler->enabled, upsampler->sample_count); for (u32 i = 0; i < upsampler->input_count; i++) { - string += fmt::format("{:02X}, ", upsampler->inputs[i]); + string += std::format("{:02X}, ", upsampler->inputs[i]); } } string += "\n"; diff --git a/src/audio_core/renderer/command/sink/circular_buffer.cpp b/src/audio_core/renderer/command/sink/circular_buffer.cpp index b2d4ccfcd8..e074bc17a6 100644 --- a/src/audio_core/renderer/command/sink/circular_buffer.cpp +++ b/src/audio_core/renderer/command/sink/circular_buffer.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project @@ -14,11 +14,11 @@ namespace AudioCore::Renderer { void CircularBufferSinkCommand::Dump( [[maybe_unused]] const AudioRenderer::CommandListProcessor& processor, std::string& string) { - string += fmt::format( + string += std::format( "CircularBufferSinkCommand\n\tinput_count {} ring size {:04X} ring pos {:04X}\n\tinputs: ", input_count, size, pos); for (u32 i = 0; i < input_count; i++) { - string += fmt::format("{:02X}, ", inputs[i]); + string += std::format("{:02X}, ", inputs[i]); } string += "\n"; } diff --git a/src/audio_core/renderer/command/sink/device.cpp b/src/audio_core/renderer/command/sink/device.cpp index 16b1bd7467..586d4a985f 100644 --- a/src/audio_core/renderer/command/sink/device.cpp +++ b/src/audio_core/renderer/command/sink/device.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project @@ -14,10 +14,10 @@ namespace AudioCore::Renderer { void DeviceSinkCommand::Dump([[maybe_unused]] const AudioRenderer::CommandListProcessor& processor, std::string& string) { - string += fmt::format("DeviceSinkCommand\n\t{} session {} input_count {}\n\tinputs: ", + string += std::format("DeviceSinkCommand\n\t{} session {} input_count {}\n\tinputs: ", std::string_view(name), session_id, input_count); for (u32 i = 0; i < input_count; i++) { - string += fmt::format("{:02X}, ", inputs[i]); + string += std::format("{:02X}, ", inputs[i]); } string += "\n"; } diff --git a/src/audio_core/renderer/effect/light_limiter.h b/src/audio_core/renderer/effect/light_limiter.h index 7f2ede4052..6c38b59e3d 100644 --- a/src/audio_core/renderer/effect/light_limiter.h +++ b/src/audio_core/renderer/effect/light_limiter.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/audio_core/sink/sink_stream.cpp b/src/audio_core/sink/sink_stream.cpp index c70020e9da..dc8912eb65 100644 --- a/src/audio_core/sink/sink_stream.cpp +++ b/src/audio_core/sink/sink_stream.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include "audio_core/audio_core.h" #include "audio_core/common/common.h" diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 487b0ce4cf..0be32499d0 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -245,7 +245,7 @@ if (lz4_ADDED) target_include_directories(common PRIVATE ${lz4_SOURCE_DIR}/lib) endif() -target_link_libraries(common PUBLIC fmt::fmt stb::headers Threads::Threads) +target_link_libraries(common PUBLIC stb::headers Threads::Threads) target_link_libraries(common PRIVATE lz4::lz4 zstd::zstd) # Please refer to src/common/demangle.cpp diff --git a/src/common/bit_field.h b/src/common/bit_field.h index fbc71590d5..4402eae1bc 100644 --- a/src/common/bit_field.h +++ b/src/common/bit_field.h @@ -11,6 +11,8 @@ #include #include #include +#include + #include "common/swap.h" /* @@ -169,7 +171,12 @@ private: template using BitFieldBE = BitField; -template -inline auto format_as(BitField bitfield) { - return bitfield.Value(); -} +template +struct std::formatter> : std::formatter { + using std::formatter::parse; + template + auto format(const BitField& bitfield, FormatContext& ctx) const + -> decltype(ctx.out()) { + return std::formatter::format(bitfield.Value(), ctx); + } +}; \ No newline at end of file diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h index 18e83d3381..3faf555d04 100644 --- a/src/common/common_funcs.h +++ b/src/common/common_funcs.h @@ -12,17 +12,6 @@ #include // for exit #include "common/common_types.h" -#ifndef __cpp_lib_to_underlying -namespace std { -// https://en.cppreference.com/cpp/utility/to_underlying -template - requires std::is_enum_v -constexpr std::underlying_type_t to_underlying(T e) noexcept { - return std::underlying_type_t(e); -} -} -#endif - /// Textually concatenates two tokens. The double-expansion is required by the C preprocessor. #define CONCAT2(x, y) DO_CONCAT2(x, y) #define DO_CONCAT2(x, y) x##y diff --git a/src/common/dynamic_library.cpp b/src/common/dynamic_library.cpp index 462faa673d..9bf2c94c12 100644 --- a/src/common/dynamic_library.cpp +++ b/src/common/dynamic_library.cpp @@ -12,10 +12,10 @@ #include -#include - #include "common/dynamic_library.h" +#include + #ifdef _WIN32 #include #else @@ -58,27 +58,27 @@ std::string DynamicLibrary::GetUnprefixedFilename(const char* filename) { std::string DynamicLibrary::GetVersionedFilename(const char* libname, int major, int minor) { #if defined(_WIN32) if (major >= 0 && minor >= 0) - return fmt::format("{}-{}-{}.dll", libname, major, minor); + return std::format("{}-{}-{}.dll", libname, major, minor); else if (major >= 0) - return fmt::format("{}-{}.dll", libname, major); + return std::format("{}-{}.dll", libname, major); else - return fmt::format("{}.dll", libname); + return std::format("{}.dll", libname); #elif defined(__APPLE__) const char* prefix = std::strncmp(libname, "lib", 3) ? "lib" : ""; if (major >= 0 && minor >= 0) - return fmt::format("{}{}.{}.{}.dylib", prefix, libname, major, minor); + return std::format("{}{}.{}.{}.dylib", prefix, libname, major, minor); else if (major >= 0) - return fmt::format("{}{}.{}.dylib", prefix, libname, major); + return std::format("{}{}.{}.dylib", prefix, libname, major); else - return fmt::format("{}{}.dylib", prefix, libname); + return std::format("{}{}.dylib", prefix, libname); #else const char* prefix = std::strncmp(libname, "lib", 3) ? "lib" : ""; if (major >= 0 && minor >= 0) - return fmt::format("{}{}.so.{}.{}", prefix, libname, major, minor); + return std::format("{}{}.so.{}.{}", prefix, libname, major, minor); else if (major >= 0) - return fmt::format("{}{}.so.{}", prefix, libname, major); + return std::format("{}{}.so.{}", prefix, libname, major); else - return fmt::format("{}{}.so", prefix, libname); + return std::format("{}{}.so", prefix, libname); #endif } diff --git a/src/common/fs/file.cpp b/src/common/fs/file.cpp index 7a0f69a84d..9e9016e5e9 100644 --- a/src/common/fs/file.cpp +++ b/src/common/fs/file.cpp @@ -559,7 +559,7 @@ bool IOFile::Seek(s64 offset, SeekOrigin origin) const { if (!seek_result) { const auto ec = std::error_code{errno, std::generic_category()}; LOG_ERROR(Common_Filesystem, "Failed to seek the file at path={}, offset={}, origin={}, ec_message={}", - PathToUTF8String(file_path), offset, origin, ec.message()); + PathToUTF8String(file_path), offset, s64(origin), ec.message()); } return seek_result; } diff --git a/src/common/fs/fs.cpp b/src/common/fs/fs.cpp index 90cef15001..5dfec5354d 100644 --- a/src/common/fs/fs.cpp +++ b/src/common/fs/fs.cpp @@ -154,14 +154,14 @@ std::shared_ptr FileOpen(const fs::path& path, FileAccessMode mode, File LOG_ERROR(Common_Filesystem, "Failed to open the file at path={} with mode={}, type={}, flag={}", - PathToUTF8String(path), mode, type, flag); + PathToUTF8String(path), s64(mode), s64(type), s64(flag)); return nullptr; } LOG_DEBUG(Common_Filesystem, "Successfully opened the file at path={} with mode={}, type={}, flag={}", - PathToUTF8String(path), mode, type, flag); + PathToUTF8String(path), s64(mode), s64(type), s64(flag)); return io_file; } diff --git a/src/common/fs/ryujinx_compat.cpp b/src/common/fs/ryujinx_compat.cpp index bb6a633723..adaab273f8 100644 --- a/src/common/fs/ryujinx_compat.cpp +++ b/src/common/fs/ryujinx_compat.cpp @@ -1,11 +1,11 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later #include "ryujinx_compat.h" #include "common/fs/path_util.h" #include #include -#include +#include #include namespace Common::FS { @@ -33,7 +33,7 @@ fs::path GetRyuSavePath(const u64 &save_id) } std::filesystem::path GetRyuSavePath(const std::filesystem::path& path, const u64& save_id) { - std::string hex = fmt::format("{:016x}", save_id); + std::string hex = std::format("{:016x}", save_id); // TODO: what's the difference between 0 and 1? return path / "bis" / "user" / "save" / hex / "0"; diff --git a/src/common/fs/symlink.cpp b/src/common/fs/symlink.cpp index 01be5e180a..e8a27a1dfd 100644 --- a/src/common/fs/symlink.cpp +++ b/src/common/fs/symlink.cpp @@ -1,10 +1,10 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later #include "symlink.h" #ifdef _WIN32 -#include +#include #include #endif @@ -38,7 +38,7 @@ bool CreateSymlink(fs::path from, fs::path to) fs::create_directory_symlink(from, to, ec); #ifdef _WIN32 if (ec) { - const std::string command = fmt::format("mklink /J \"{}\" \"{}\"", + const std::string command = std::format("mklink /J \"{}\" \"{}\"", to.string(), from.string()); return system(command.c_str()) == 0; diff --git a/src/common/hex_util.h b/src/common/hex_util.h index 2f5417143c..c307d51e93 100644 --- a/src/common/hex_util.h +++ b/src/common/hex_util.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: 2013 Dolphin Emulator Project // SPDX-FileCopyrightText: 2014 Citra Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -6,9 +9,10 @@ #include #include +#include #include #include -#include +#include #include "common/assert.h" #include "common/common_types.h" @@ -55,9 +59,11 @@ template std::string out; out.reserve(std::size(data) * pad_width); - const auto format_str = fmt::runtime(upper ? "{:02X}" : "{:02x}"); for (const u8 c : data) { - out += fmt::format(format_str, c); + if (upper) + std::format_to(std::back_inserter(out), "{:02X}", c); + else + std::format_to(std::back_inserter(out), "{:02x}", c); } return out; diff --git a/src/common/logging.cpp b/src/common/logging.cpp index 88f92837de..768dc23591 100644 --- a/src/common/logging.cpp +++ b/src/common/logging.cpp @@ -7,7 +7,9 @@ #include #include #include +#include #include +#include #include #include @@ -22,7 +24,7 @@ #endif #include -#include +#include #include "common/fs/file.h" #include "common/fs/fs.h" @@ -86,11 +88,15 @@ const char* GetLevelName(Level log_level) { // Some IDEs prefer : instead, so let's just do that :) std::string FormatLogMessage(const Entry& entry) noexcept { if (!entry.filename) return ""; + auto const time_seconds = uint32_t(entry.timestamp.count() / 1000000); auto const time_fractional = uint32_t(entry.timestamp.count() % 1000000); auto const class_name = GetLogClassName(entry.log_class); auto const level_name = GetLevelName(entry.log_level); - return fmt::format("[{:4d}.{:06d}] {} <{}> {}:{}:{}: {}\n", time_seconds, time_fractional, class_name, level_name, entry.filename, entry.line_num, entry.function, entry.message); + return std::format("[{:4d}.{:06d}] {} <{}> {}:{}:{}: {}\n", time_seconds, time_fractional, + class_name, level_name, entry.filename, entry.line_num, + entry.function ? entry.function : "", + entry.message ? entry.message : ""); } template @@ -155,10 +161,10 @@ struct Backend { virtual void Flush() noexcept = 0; }; -/// @brief Formatting specifier (to use with printf) of the equivalent fmt::format() expression +/// @brief Formatting specifier (to use with printf) of the equivalent std::format() expression #define CCB_PRINTF_FMT "[%4d.%06d] %s <%s> %s:%u:%s: %s" -/// @brief Instead of using fmt::format() just use the system's formatting capabilities directly +/// @brief Instead of using std::format() just use the system's formatting capabilities directly struct DirectFormatArgs { const char *class_name; const char *level_name; @@ -199,7 +205,9 @@ struct ColorConsoleBackend final : public Backend { }()); SetConsoleTextAttribute(console_handle, color); auto const df = GetDirectFormatArgs(entry); - std::fprintf(stdout, CCB_PRINTF_FMT "\n", df.time_seconds, df.time_fractional, df.class_name, df.level_name, entry.filename, entry.line_num, entry.function, entry.message); + std::fprintf(stdout, CCB_PRINTF_FMT "\n", df.time_seconds, df.time_fractional, df.class_name, + df.level_name, entry.filename ? entry.filename : "", entry.line_num, + entry.function ? entry.function : "", entry.message ? entry.message : ""); } } void Flush() noexcept override {} @@ -224,10 +232,14 @@ struct ColorConsoleBackend final : public Backend { auto const df = GetDirectFormatArgs(entry); // more restrictive, because take for example this simple prelude: // [ 50.872256] Config common/settings.cpp:142:LogSettings: - char buffer[256]; - auto result = fmt::format_to_n(buffer, sizeof(buffer) - 1, "\x1b{}[{:4d}.{:06d}] {} <{}> {}:{}:{}: ", color_str, df.time_seconds, df.time_fractional, df.class_name, df.level_name, entry.filename, entry.line_num, entry.function, entry.message); - std::fwrite(buffer, 1, (std::min)(sizeof(buffer) - 1, result.size), stdout); - std::fwrite(entry.message, 1, entry.message_len, stdout); + + auto result = std::format("\x1b{}[{:4d}.{:06d}] {} <{}> {}:{}:{}: ", color_str, df.time_seconds, + df.time_fractional, df.class_name, df.level_name, + entry.filename ? entry.filename : "", entry.line_num, + entry.function ? entry.function : ""); + std::fwrite(result.data(), 1, result.size(), stdout); + if (entry.message && entry.message_len) + std::fwrite(entry.message, 1, entry.message_len, stdout); std::fwrite("\x1b[0m\n", 1, sizeof("\x1b[0m\n"), stdout); } } @@ -427,14 +439,15 @@ void SetColorConsoleBackendEnabled(bool enabled) { logging_instance->color_console_backend.enabled = enabled; } -void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename, unsigned int line_num, const char* function, fmt::string_view format, const fmt::format_args& args) { +void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename, unsigned int line_num, const char* function, std::string_view format, const std::format_args& args) { if (logging_instance && logging_instance->filter.CheckMessage(log_class, log_level)) { auto const flush = ::Settings::values.log_flush_line.GetValue(); - char buffer[BUFSIZ]; - auto result = fmt::vformat_to_n(buffer, sizeof(buffer) - 1, format, args); + + std::string msg = std::vformat(format, args); + Entry e{ - .message = nullptr, - .message_len = 0, + .message = msg.c_str(), + .message_len = msg.size(), .timestamp = std::chrono::duration_cast(std::chrono::steady_clock::now() - logging_instance->time_origin), .log_class = log_class, .log_level = log_level, @@ -442,23 +455,11 @@ void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename, u .function = function, .line_num = line_num, }; - if (result.size <= sizeof(buffer) - 1) { - buffer[(std::min)(result.size, sizeof(buffer) - 1)] = '\0'; - e.message = buffer; - e.message_len = (std::min)(result.size, sizeof(buffer) - 1); - logging_instance->ForEachBackend([=](Backend& backend) { - backend.Write(e); - if (flush) backend.Flush(); - }); - } else { - std::string s = fmt::vformat(format, args); - e.message = s.c_str(); - e.message_len = s.size(); - logging_instance->ForEachBackend([=](Backend& backend) { - backend.Write(e); - if (flush) backend.Flush(); - }); - } + + logging_instance->ForEachBackend([&](Backend& backend) { + backend.Write(e); + if (flush) backend.Flush(); + }); } } } // namespace Common::Log diff --git a/src/common/logging.h b/src/common/logging.h index 8ec1d8a3aa..dec6bd41de 100644 --- a/src/common/logging.h +++ b/src/common/logging.h @@ -9,31 +9,29 @@ #include #include #include -#include +#include #include "common/swap.h" // adapted from https://github.com/fmtlib/fmt/issues/2704 // a generic formatter for enum classes -#if FMT_VERSION >= 80100 template -struct fmt::formatter, char>> +struct std::formatter, char>> : formatter> { template auto format(const T& value, FormatContext& ctx) const -> decltype(ctx.out()) { - return fmt::formatter>::format( + return std::formatter>::format( static_cast>(value), ctx); } }; -#endif template -struct fmt::formatter> { +struct std::formatter> { constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } template auto format(const SwapStructT& reg, FormatContext& ctx) const { - return fmt::format_to(ctx.out(), "{}", T(reg)); + return std::format_to(ctx.out(), "{}", T(reg)); } }; @@ -85,11 +83,11 @@ enum class Class : u8 { }; /// Logs a message to the global logger, using fmt -void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename, unsigned int line_num, const char* function, fmt::string_view format, const fmt::format_args& args); +void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename, unsigned int line_num, const char* function, std::string_view format, const std::format_args& args); template -void FmtLogMessage(Class log_class, Level log_level, const char* filename, unsigned int line_num, const char* function, fmt::format_string format, const Args&... args) { - FmtLogMessageImpl(log_class, log_level, filename, line_num, function, format.get(), fmt::make_format_args(args...)); +void FmtLogMessage(Class log_class, Level log_level, const char* filename, unsigned int line_num, const char* function, std::format_string format, const Args&... args) { + FmtLogMessageImpl(log_class, log_level, filename, line_num, function, format.get(), std::make_format_args(args...)); } /// Implements a log message filter which allows different log classes to have different minimum diff --git a/src/common/net/net.cpp b/src/common/net/net.cpp index 8f08bcf7f0..22a757d473 100644 --- a/src/common/net/net.cpp +++ b/src/common/net/net.cpp @@ -117,7 +117,7 @@ std::optional MakeRequest(const std::string& url) { LOG_ERROR(Frontend, "Failed to download {}: {}", url, res.error()); return std::nullopt; } else if (res->status_code < hydro::Status::Ok || res->status_code >= hydro::Status::MultipleChoices) { - LOG_ERROR(Frontend, "Received status code {} for {}", std::to_underlying(res->status_code), url); + LOG_ERROR(Frontend, "Received status code {} for {}", res->status_code, url); return std::nullopt; } @@ -195,7 +195,7 @@ bool HeadRequest(const std::string& url) { LOG_ERROR(Frontend, "Failed to download {}: {}", url, res.error()); return false; } else if (res->status_code < hydro::Status::Ok || res->status_code >= hydro::Status::MultipleChoices) { - LOG_ERROR(Frontend, "Received status code {} for {}", std::to_underlying(res->status_code), url); + LOG_ERROR(Frontend, "Received status code {} for {}", res->status_code, url); return false; } diff --git a/src/common/ring_buffer.h b/src/common/ring_buffer.h index 10e53d3018..1876b818d0 100644 --- a/src/common/ring_buffer.h +++ b/src/common/ring_buffer.h @@ -23,7 +23,7 @@ namespace Common { /// @tparam T Element type /// @tparam capacity Number of slots in ring buffer template - requires std::is_trivial_v + requires std::is_trivially_default_constructible_v && std::is_trivially_copyable_v class RingBuffer { /// A "slot" is made of a single `T`. static constexpr std::size_t slot_size = sizeof(T); diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 3f5154026e..68e6b9146c 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include "common/settings_enums.h" #include "common/assert.h" @@ -120,15 +120,15 @@ void LogSettings() { // Hide the token secret, for security reasons. if (setting->Id() != values.eden_token.Id()) { auto const is_default = setting->ToString() == setting->DefaultToString(); - auto const name = fmt::format( + auto const name = std::format( "{:c}{:c} {}.{}", is_default ? '-' : 'M', setting->UsingGlobal() ? '-' : 'C', TranslateCategory(category), setting->GetLabel()); if (is_default) - settings_list.push_back(fmt::format("{}: {}", name, setting->Canonicalize())); + settings_list.push_back(std::format("{}: {}", name, setting->Canonicalize())); else - settings_list.push_front(fmt::format("{}: {}", name, setting->Canonicalize())); + settings_list.push_front(std::format("{}: {}", name, setting->Canonicalize())); } } } diff --git a/src/common/settings_setting.h b/src/common/settings_setting.h index 0a9243cc0d..3a7ee23ed9 100644 --- a/src/common/settings_setting.h +++ b/src/common/settings_setting.h @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include "common/common_types.h" #include "common/settings_common.h" #include "common/settings_enums.h" @@ -134,7 +134,7 @@ protected: } else if constexpr (std::is_same_v) { return value_ ? "true" : "false"; } else if constexpr (std::is_floating_point_v) { - return fmt::format("{:f}", value_); + return std::format("{:f}", value_); } else if constexpr (std::is_enum_v) { return std::to_string(std::underlying_type_t(value_)); } else { diff --git a/src/common/time_zone.cpp b/src/common/time_zone.cpp index 64f29251ca..86faa42c0b 100644 --- a/src/common/time_zone.cpp +++ b/src/common/time_zone.cpp @@ -10,8 +10,7 @@ #include #include #include -#include -#include +#include #include "common/logging.h" #include "common/time_zone.h" @@ -96,12 +95,12 @@ std::string FindSystemTimeZone() { // -6 hours instead of +6 hours, so these signs are purposefully reversed to fix it. std::string postfix{""}; if (hours > 0) { - postfix = fmt::format("-{:d}", std::abs(hours)); + postfix = std::format("-{:d}", std::abs(hours)); } else if (hours < 0) { - postfix = fmt::format("+{:d}", std::abs(hours)); + postfix = std::format("+{:d}", std::abs(hours)); } - return fmt::format("Etc/GMT{:s}", postfix); + return std::format("Etc/GMT{:s}", postfix); } } // namespace Common::TimeZone diff --git a/src/common/typed_address.h b/src/common/typed_address.h index f716accd03..8541a64d74 100644 --- a/src/common/typed_address.h +++ b/src/common/typed_address.h @@ -6,9 +6,8 @@ #pragma once -#include #include -#include +#include #include "common/common_types.h" @@ -260,35 +259,35 @@ constexpr inline uint64_t GetInteger(Common::TypedAddress address) { } template <> -struct fmt::formatter { - constexpr auto parse(fmt::format_parse_context& ctx) { +struct std::formatter { + constexpr auto parse(std::format_parse_context& ctx) { return ctx.begin(); } template auto format(const Common::PhysicalAddress& addr, FormatContext& ctx) const { - return fmt::format_to(ctx.out(), "{:#x}", static_cast(addr.GetValue())); + return std::format_to(ctx.out(), "{:#x}", static_cast(addr.GetValue())); } }; template <> -struct fmt::formatter { - constexpr auto parse(fmt::format_parse_context& ctx) { +struct std::formatter { + constexpr auto parse(std::format_parse_context& ctx) { return ctx.begin(); } template auto format(const Common::ProcessAddress& addr, FormatContext& ctx) const { - return fmt::format_to(ctx.out(), "{:#x}", static_cast(addr.GetValue())); + return std::format_to(ctx.out(), "{:#x}", static_cast(addr.GetValue())); } }; template <> -struct fmt::formatter { - constexpr auto parse(fmt::format_parse_context& ctx) { +struct std::formatter { + constexpr auto parse(std::format_parse_context& ctx) { return ctx.begin(); } template auto format(const Common::VirtualAddress& addr, FormatContext& ctx) const { - return fmt::format_to(ctx.out(), "{:#x}", static_cast(addr.GetValue())); + return std::format_to(ctx.out(), "{:#x}", static_cast(addr.GetValue())); } }; diff --git a/src/common/uuid.cpp b/src/common/uuid.cpp index 4b992c5df8..74c91b89a5 100644 --- a/src/common/uuid.cpp +++ b/src/common/uuid.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include "common/assert.h" #include "common/tiny_mt.h" @@ -146,7 +146,7 @@ std::array ConstructUUID(std::string_view uuid_string) { UUID::UUID(std::string_view uuid_string) : uuid{ConstructUUID(uuid_string)} {} std::string UUID::RawString() const { - return fmt::format("{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}" + return std::format("{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}" "{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}", uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5], uuid[6], uuid[7], uuid[8], uuid[9], uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], @@ -154,7 +154,7 @@ std::string UUID::RawString() const { } std::string UUID::FormattedString() const { - return fmt::format("{:02x}{:02x}{:02x}{:02x}" + return std::format("{:02x}{:02x}{:02x}{:02x}" "-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-" "{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}", uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5], uuid[6], uuid[7], diff --git a/src/common/uuid.h b/src/common/uuid.h index 465b5be58d..3f40980547 100644 --- a/src/common/uuid.h +++ b/src/common/uuid.h @@ -109,7 +109,7 @@ struct UUID { friend constexpr bool operator==(const UUID& lhs, const UUID& rhs) = default; }; static_assert(sizeof(UUID) == 0x10, "UUID has incorrect size."); -static_assert(std::is_trivial_v); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); /// An invalid UUID. This UUID has all its bytes set to 0. constexpr UUID InvalidUUID = {}; diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 39fb32a1ce..63f4fcd37d 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -1220,7 +1220,6 @@ endif() target_link_libraries(core PRIVATE OpenSSL::SSL OpenSSL::Crypto - fmt::fmt RenderDoc::API jacinth::jacinth ZLIB::ZLIB) diff --git a/src/core/arm/arm_interface.cpp b/src/core/arm/arm_interface.cpp index b7de9fc0f8..7bf392c54c 100644 --- a/src/core/arm/arm_interface.cpp +++ b/src/core/arm/arm_interface.cpp @@ -26,20 +26,20 @@ void ArmInterface::LogBacktrace(Kernel::KProcess* process) const { ctx.r[28], ctx.fp, ctx.lr, ctx.sp, }; - std::string msg = fmt::format("Backtrace @ PC={:016X}\n", ctx.pc); + std::string msg = std::format("Backtrace @ PC={:016X}\n", ctx.pc); for (size_t i = 0; i < 32; i += 4) - msg += fmt::format("R{:02}={:016X} R{:02}={:016X} R{:02}={:016X} R{:02}={:016X}\n", + msg += std::format("R{:02}={:016X} R{:02}={:016X} R{:02}={:016X} R{:02}={:016X}\n", i + 0, xreg[i + 0], i + 1, xreg[i + 1], i + 2, xreg[i + 2], i + 3, xreg[i + 3]); for (size_t i = 0; i < 32; i += 2) - msg += fmt::format("V{:02}={:016X}_{:016X} V{:02}={:016X}_{:016X}\n", + msg += std::format("V{:02}={:016X}_{:016X} V{:02}={:016X}_{:016X}\n", i + 0, ctx.v[i + 0][0], ctx.v[i + 0][1], i + 1, ctx.v[i + 1][0], ctx.v[i + 1][1]); - msg += fmt::format("PSTATE={:08X} FPCR={:08X} FPSR={:08X} TPIDR={:016X}\n", ctx.pstate, ctx.fpcr, ctx.fpsr, ctx.tpidr); - msg += fmt::format("{:20}{:20}{:20}{:20}{}\n", "Module", "Address", "Original Address", "Offset", "Symbol"); + msg += std::format("PSTATE={:08X} FPCR={:08X} FPSR={:08X} TPIDR={:016X}\n", ctx.pstate, ctx.fpcr, ctx.fpsr, ctx.tpidr); + msg += std::format("{:20}{:20}{:20}{:20}{}\n", "Module", "Address", "Original Address", "Offset", "Symbol"); auto const backtrace = GetBacktraceFromContext(process, ctx); for (auto const& entry : backtrace) - msg += fmt::format("{:20}{:016X} {:016X} {:016X} {}\n", entry.module, entry.address, entry.original_address, entry.offset, entry.name); + msg += std::format("{:20}{:016X} {:016X} {:016X} {}\n", entry.module, entry.address, entry.original_address, entry.offset, entry.name); LOG_ERROR(Core_ARM, "{}", msg); } diff --git a/src/core/arm/debug.cpp b/src/core/arm/debug.cpp index 3049ea0be1..79a3881607 100644 --- a/src/core/arm/debug.cpp +++ b/src/core/arm/debug.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project @@ -208,7 +208,7 @@ std::string GetThreadState(const Kernel::KThread* thread) { case Kernel::ThreadState::Initialized: return "Initialized"; case Kernel::ThreadState::Waiting: - return fmt::format("Waiting ({})", GetThreadWaitReason(thread)); + return std::format("Waiting ({})", GetThreadWaitReason(thread)); case Kernel::ThreadState::Runnable: return "Runnable"; case Kernel::ThreadState::Terminated: diff --git a/src/core/arm/dynarmic/dynarmic_cp15.cpp b/src/core/arm/dynarmic/dynarmic_cp15.cpp index 28695a1058..ed547919f3 100644 --- a/src/core/arm/dynarmic/dynarmic_cp15.cpp +++ b/src/core/arm/dynarmic/dynarmic_cp15.cpp @@ -4,7 +4,7 @@ // SPDX-FileCopyrightText: 2017 Citra Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include +#include #include "common/logging.h" #include "core/arm/dynarmic/arm_dynarmic_32.h" #include "core/arm/dynarmic/dynarmic_cp15.h" @@ -20,13 +20,13 @@ using CallbackOrAccessOneWord = Dynarmic::A32::Coprocessor::CallbackOrAccessOneW using CallbackOrAccessTwoWords = Dynarmic::A32::Coprocessor::CallbackOrAccessTwoWords; template <> -struct fmt::formatter { +struct std::formatter { constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } template auto format(const Dynarmic::A32::CoprocReg& reg, FormatContext& ctx) const { - return fmt::format_to(ctx.out(), "cp{}", static_cast(reg)); + return std::format_to(ctx.out(), "cp{}", static_cast(reg)); } }; diff --git a/src/core/core.cpp b/src/core/core.cpp index 06c7ee368e..1d4d8c4a14 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -80,7 +80,7 @@ FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs, std::vector concat; for (u32 i = 0; i < 0x10; ++i) { - const auto file_name = fmt::format("{:02X}", i); + const auto file_name = std::format("{:02X}", i); auto next = dir->GetFile(file_name); if (next != nullptr) { diff --git a/src/core/crypto/aes_util.cpp b/src/core/crypto/aes_util.cpp index 7eea665e6d..1affc70afc 100644 --- a/src/core/crypto/aes_util.cpp +++ b/src/core/crypto/aes_util.cpp @@ -52,7 +52,7 @@ static inline const std::string GetCipherName(Mode mode, u32 key_size) { default: UNREACHABLE(); } - return fmt::format("AES-{}-{}", effective_bits, cipher); + return std::format("AES-{}-{}", effective_bits, cipher); }; static EVP_CIPHER *GetCipher(Mode mode, u32 key_size) { diff --git a/src/core/crypto/key_manager.cpp b/src/core/crypto/key_manager.cpp index 4c5732a155..45a2287316 100644 --- a/src/core/crypto/key_manager.cpp +++ b/src/core/crypto/key_manager.cpp @@ -775,7 +775,7 @@ void KeyManager::WriteKeyToFile(KeyCategory category, std::string_view keyname, "# If you are experiencing issues involving keys, it may help to delete this file\n")); } - void(file.WriteString(fmt::format("\n{} = {}", keyname, Common::HexToString(key)))); + void(file.WriteString(std::format("\n{} = {}", keyname, Common::HexToString(key)))); LoadFromFile(path, category == KeyCategory::Title); } @@ -810,21 +810,21 @@ void KeyManager::SetKey(S128KeyType id, Key128 key, u64 field1, u64 field2) { "key_area_key_ocean_{:02X}", "key_area_key_system_{:02X}", }; - WriteKeyToFile(category, fmt::format(fmt::runtime(kak_names.at(field2)), field1), key); + WriteKeyToFile(category, std::vformat(kak_names.at(field2), std::make_format_args(field1)), key); } else if (id == S128KeyType::Master) { - WriteKeyToFile(category, fmt::format("master_key_{:02X}", field1), key); + WriteKeyToFile(category, std::format("master_key_{:02X}", field1), key); } else if (id == S128KeyType::Package1) { - WriteKeyToFile(category, fmt::format("package1_key_{:02X}", field1), key); + WriteKeyToFile(category, std::format("package1_key_{:02X}", field1), key); } else if (id == S128KeyType::Package2) { - WriteKeyToFile(category, fmt::format("package2_key_{:02X}", field1), key); + WriteKeyToFile(category, std::format("package2_key_{:02X}", field1), key); } else if (id == S128KeyType::Titlekek) { - WriteKeyToFile(category, fmt::format("titlekek_{:02X}", field1), key); + WriteKeyToFile(category, std::format("titlekek_{:02X}", field1), key); } else if (id == S128KeyType::Keyblob) { - WriteKeyToFile(category, fmt::format("keyblob_key_{:02X}", field1), key); + WriteKeyToFile(category, std::format("keyblob_key_{:02X}", field1), key); } else if (id == S128KeyType::KeyblobMAC) { - WriteKeyToFile(category, fmt::format("keyblob_mac_key_{:02X}", field1), key); + WriteKeyToFile(category, std::format("keyblob_mac_key_{:02X}", field1), key); } else if (id == S128KeyType::Source && field1 == u64(SourceKeyType::Keyblob)) { - WriteKeyToFile(category, fmt::format("keyblob_key_source_{:02X}", field2), key); + WriteKeyToFile(category, std::format("keyblob_key_source_{:02X}", field2), key); } s128_keys[{id, field1, field2}] = key; @@ -954,7 +954,7 @@ void KeyManager::DeriveBase() { // Decrypt keyblob if (keyblobs[i] == std::array{}) { keyblobs[i] = DecryptKeyblob(encrypted_keyblobs[i], key); - WriteKeyToFile<0x90>(KeyCategory::Console, fmt::format("keyblob_{:02X}", i), + WriteKeyToFile<0x90>(KeyCategory::Console, std::format("keyblob_{:02X}", i), keyblobs[i]); } @@ -1089,7 +1089,7 @@ void KeyManager::PopulateFromPartitionData(PartitionDataManager& data) { for (size_t i = 0; i < encrypted_keyblobs.size(); ++i) { if (encrypted_keyblobs[i] == std::array{}) { encrypted_keyblobs[i] = data.GetEncryptedKeyblob(i); - WriteKeyToFile<0xB0>(KeyCategory::Console, fmt::format("encrypted_keyblob_{:02X}", i), encrypted_keyblobs[i]); + WriteKeyToFile<0xB0>(KeyCategory::Console, std::format("encrypted_keyblob_{:02X}", i), encrypted_keyblobs[i]); } } diff --git a/src/core/crypto/key_manager.h b/src/core/crypto/key_manager.h index 4a892a27ed..68f33f3984 100644 --- a/src/core/crypto/key_manager.h +++ b/src/core/crypto/key_manager.h @@ -14,7 +14,7 @@ #include #include -#include +#include #include "common/common_funcs.h" #include "common/common_types.h" #include "core/crypto/partition_data_manager.h" @@ -241,7 +241,7 @@ struct KeyIndex { u8 key_size = 16; if constexpr (std::is_same_v) key_size = 32; - return fmt::format("key_size={:02X}, key={:02X}, field1={:016X}, field2={:016X}", key_size, + return std::format("key_size={:02X}, key={:02X}, field1={:016X}, field2={:016X}", key_size, static_cast(type), field1, field2); } }; diff --git a/src/core/debugger/debugger.cpp b/src/core/debugger/debugger.cpp index a9c1dcfb47..7c887adb05 100644 --- a/src/core/debugger/debugger.cpp +++ b/src/core/debugger/debugger.cpp @@ -32,7 +32,7 @@ template static void AsyncReceiveInto(Readable& r, Buffer& buffer, Callback&& c) { - static_assert(std::is_trivial_v); + static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); auto boost_buffer{boost::asio::buffer(&buffer, sizeof(Buffer))}; r.async_read_some( boost_buffer, [&, c](const boost::system::error_code& error, size_t bytes_read) { @@ -57,7 +57,7 @@ static void AsyncAccept(boost::asio::ip::tcp::acceptor& acceptor, Callback&& c) template static std::span ReceiveInto(Readable& r, Buffer& buffer) { - static_assert(std::is_trivial_v); + static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); auto boost_buffer{boost::asio::buffer(&buffer, sizeof(Buffer))}; size_t bytes_read = r.read_some(boost_buffer); const u8* buffer_start = reinterpret_cast(&buffer); diff --git a/src/core/debugger/gdbstub.cpp b/src/core/debugger/gdbstub.cpp index 44ddf11c39..61a5298cfc 100644 --- a/src/core/debugger/gdbstub.cpp +++ b/src/core/debugger/gdbstub.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include "common/hex_util.h" #include "common/logging.h" @@ -76,7 +77,7 @@ static std::string EscapeXML(std::string_view data) { case '>': escaped += ">"; break; default: if (c > 0x7f) { - escaped += fmt::format("&#{};", u32(c)); + escaped += std::format("&#{};", u32(c)); } else { escaped += char(c); } @@ -109,14 +110,14 @@ void GDBStub::Watchpoint(Kernel::KThread* thread, const Kernel::DebugWatchpoint& switch (watch.type) { case Kernel::DebugWatchpointType::Read: - SendReply(fmt::format("{}rwatch:{:x};", status, GetInteger(watch.start_address))); + SendReply(std::format("{}rwatch:{:x};", status, GetInteger(watch.start_address))); break; case Kernel::DebugWatchpointType::Write: - SendReply(fmt::format("{}watch:{:x};", status, GetInteger(watch.start_address))); + SendReply(std::format("{}watch:{:x};", status, GetInteger(watch.start_address))); break; case Kernel::DebugWatchpointType::ReadOrWrite: default: - SendReply(fmt::format("{}awatch:{:x};", status, GetInteger(watch.start_address))); + SendReply(std::format("{}awatch:{:x};", status, GetInteger(watch.start_address))); break; } } @@ -395,9 +396,9 @@ static std::string PaginateBuffer(std::string_view buffer, std::string_view requ const auto amount_val{static_cast(strtoll(amount.data(), nullptr, 16))}; if (offset_val + amount_val > buffer.size()) { - return fmt::format("l{}", buffer.substr(offset_val)); + return std::format("l{}", buffer.substr(offset_val)); } else { - return fmt::format("m{}", buffer.substr(offset_val, amount_val)); + return std::format("m{}", buffer.substr(offset_val, amount_val)); } } @@ -413,14 +414,14 @@ void GDBStub::HandleQuery(std::string_view sv) { SendReply(PaginateBuffer(target_xml, sv.substr(30))); } else if (sv.starts_with("Offsets")) { const auto main_offset = Core::FindMainModuleEntrypoint(debug_process); - SendReply(fmt::format("TextSeg={:x}", GetInteger(main_offset))); + SendReply(std::format("TextSeg={:x}", GetInteger(main_offset))); } else if (sv.starts_with("Xfer:libraries:read::")) { auto modules = Core::FindModules(debug_process); std::string buffer; buffer += R"()"; buffer += ""; for (const auto& [base, name] : modules) { - buffer += fmt::format(R"()", + buffer += std::format(R"()", EscapeXML(name), base); } buffer += ""; @@ -431,8 +432,18 @@ void GDBStub::HandleQuery(std::string_view sv) { const auto& threads = debug_process->GetThreadList(); std::vector thread_ids; for (const auto& thread : threads) - thread_ids.push_back(fmt::format("{:x}", thread.GetThreadId())); - SendReply(fmt::format("m{}", fmt::join(thread_ids, ","))); + thread_ids.push_back(std::format("{:x}", thread.GetThreadId())); + + std::string joined; + bool first = true; + for (const auto& id : thread_ids) { + if (!first) { + joined += ','; + } + joined += id; + first = false; + } + SendReply(std::format("m{}", joined)); } else if (sv.starts_with("sThreadInfo")) { // end of list SendReply("l"); @@ -445,10 +456,10 @@ void GDBStub::HandleQuery(std::string_view sv) { for (const auto& thread : threads) { auto thread_name{Core::GetThreadName(&thread)}; if (!thread_name) { - thread_name = fmt::format("Thread {:d}", thread.GetThreadId()); + thread_name = std::format("Thread {:d}", thread.GetThreadId()); } - buffer += fmt::format(R"({})", + buffer += std::format(R"({})", thread.GetThreadId(), thread.GetActiveCore(), EscapeXML(*thread_name), GetThreadState(&thread)); } @@ -664,7 +675,7 @@ void GDBStub::HandleRcmd(const std::vector& command) { const auto region_bits = impl.current_address_space_width_in_bits; const auto region_size = 1ULL << region_bits; - reply = fmt::format("Region bits: {}\n" + reply = std::format("Region bits: {}\n" "Host address: {:#x} - {:#x}\n", region_bits, region, region + region_size - 1); } else { @@ -673,12 +684,12 @@ void GDBStub::HandleRcmd(const std::vector& command) { } else if (command_str == "info" || command_str == "get info") { auto modules = Core::FindModules(debug_process); - reply = fmt::format("Process: {:#x} ({})\n" + reply = std::format("Process: {:#x} ({})\n" "Program Id: {:#018x}\n", debug_process->GetProcessId(), debug_process->GetName(), debug_process->GetProgramId()); - reply += fmt::format( + reply += std::format( "Layout:\n" " Alias: {:#012x} - {:#012x}\n" " Heap: {:#012x} - {:#012x}\n" @@ -695,7 +706,7 @@ void GDBStub::HandleRcmd(const std::vector& command) { GetInteger(page_table.GetStackRegionStart()) + page_table.GetStackRegionSize() - 1); for (const auto& [vaddr, name] : modules) - reply += fmt::format(" {:#012x} - {:#012x} {}\n", vaddr, GetInteger(Core::GetModuleEnd(debug_process, vaddr)), name); + reply += std::format(" {:#012x} - {:#012x} {}\n", vaddr, GetInteger(Core::GetModuleEnd(debug_process, vaddr)), name); } else if (command_str == "mappings" || command_str == "get mappings") { reply = "Mappings:\n"; VAddr cur_addr = 0; @@ -720,7 +731,7 @@ void GDBStub::HandleRcmd(const std::vector& command) { const char u = True(svc_mem_info.attribute & MemoryAttribute::Uncached) ? 'U' : '-'; const char p =True(svc_mem_info.attribute & MemoryAttribute::PermissionLocked) ? 'P' : '-'; - reply += fmt::format( + reply += std::format( " {:#012x} - {:#012x} {} {} {}{}{}{}{} [{}, {}]\n", svc_mem_info.base_address, svc_mem_info.base_address + svc_mem_info.size - 1, perm, state, l, i, d, u, p, svc_mem_info.ipc_count, svc_mem_info.device_count); @@ -784,7 +795,7 @@ std::optional GDBStub::DetachCommand() { void GDBStub::SendReply(std::string_view data) { const auto escaped = EscapeGDB(data); - const auto output = fmt::format("{}{}{}{:02x}", GDB_STUB_START, escaped, GDB_STUB_END, CalculateChecksum(escaped)); + const auto output = std::format("{}{}{}{:02x}", GDB_STUB_START, escaped, GDB_STUB_END, CalculateChecksum(escaped)); LOG_TRACE(Debug_GDBStub, "Writing reply: {}", output); // C++ string support is complete rubbish diff --git a/src/core/debugger/gdbstub_arch.cpp b/src/core/debugger/gdbstub_arch.cpp index 5c5f3e8704..cad4248f02 100644 --- a/src/core/debugger/gdbstub_arch.cpp +++ b/src/core/debugger/gdbstub_arch.cpp @@ -253,7 +253,7 @@ void GDBStubA64::WriteRegisters(Kernel::KThread* thread, std::string_view regist } std::string GDBStubA64::ThreadStatus(const Kernel::KThread* thread, u8 signal) const { - return fmt::format("T{:02x}{:02x}:{};{:02x}:{};{:02x}:{};thread:{:x};", signal, PC_REGISTER, + return std::format("T{:02x}{:02x}:{};{:02x}:{};{:02x}:{};thread:{:x};", signal, PC_REGISTER, RegRead(thread, PC_REGISTER), SP_REGISTER, RegRead(thread, SP_REGISTER), LR_REGISTER, RegRead(thread, LR_REGISTER), thread->GetThreadId()); } @@ -462,7 +462,7 @@ void GDBStubA32::WriteRegisters(Kernel::KThread* thread, std::string_view regist } std::string GDBStubA32::ThreadStatus(const Kernel::KThread* thread, u8 signal) const { - return fmt::format("T{:02x}{:02x}:{};{:02x}:{};{:02x}:{};thread:{:x};", signal, PC_REGISTER, + return std::format("T{:02x}{:02x}:{};{:02x}:{};{:02x}:{};thread:{:x};", signal, PC_REGISTER, RegRead(thread, PC_REGISTER), SP_REGISTER, RegRead(thread, SP_REGISTER), LR_REGISTER, RegRead(thread, LR_REGISTER), thread->GetThreadId()); } diff --git a/src/core/file_sys/bis_factory.cpp b/src/core/file_sys/bis_factory.cpp index 6facd03f6d..47ef130405 100644 --- a/src/core/file_sys/bis_factory.cpp +++ b/src/core/file_sys/bis_factory.cpp @@ -1,7 +1,10 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include +#include #include "common/fs/path_util.h" #include "core/file_sys/bis_factory.h" #include "core/file_sys/registered_cache.h" @@ -55,13 +58,13 @@ VirtualDir BISFactory::GetModificationLoadRoot(u64 title_id) const { // LayeredFS doesn't work on updates and title id-less homebrew if (title_id == 0 || (title_id & 0xFFF) == 0x800) return nullptr; - return GetOrCreateDirectoryRelative(load_root, fmt::format("/{:016X}", title_id)); + return GetOrCreateDirectoryRelative(load_root, std::format("/{:016X}", title_id)); } VirtualDir BISFactory::GetModificationDumpRoot(u64 title_id) const { if (title_id == 0) return nullptr; - return GetOrCreateDirectoryRelative(dump_root, fmt::format("/{:016X}", title_id)); + return GetOrCreateDirectoryRelative(dump_root, std::format("/{:016X}", title_id)); } VirtualDir BISFactory::OpenPartition(BisPartitionId id) const { @@ -138,7 +141,7 @@ u64 BISFactory::GetFullNANDTotalSpace() const { VirtualDir BISFactory::GetBCATDirectory(u64 title_id) const { return GetOrCreateDirectoryRelative(nand_root, - fmt::format("/system/save/bcat/{:016X}", title_id)); + std::format("/system/save/bcat/{:016X}", title_id)); } } // namespace FileSys diff --git a/src/core/file_sys/card_image.cpp b/src/core/file_sys/card_image.cpp index 593c561689..b5b868abce 100644 --- a/src/core/file_sys/card_image.cpp +++ b/src/core/file_sys/card_image.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include "common/logging.h" #include "core/crypto/key_manager.h" diff --git a/src/core/file_sys/fs_save_data_types.h b/src/core/file_sys/fs_save_data_types.h index cdefe908d5..0e47cbedd7 100644 --- a/src/core/file_sys/fs_save_data_types.h +++ b/src/core/file_sys/fs_save_data_types.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project @@ -7,7 +7,7 @@ #pragma once #include -#include +#include #include "common/common_funcs.h" #include "common/common_types.h" @@ -132,7 +132,7 @@ struct SaveDataAttribute { } std::string DebugInfo() const { - return fmt::format( + return std::format( "[title_id={:016X}, user_id={:016X}{:016X}, save_id={:016X}, type={:02X}, " "rank={}, index={}]", program_id, user_id[1], user_id[0], system_save_data_id, static_cast(type), diff --git a/src/core/file_sys/fssystem/fs_types.h b/src/core/file_sys/fssystem/fs_types.h index fb16697c8f..626a06a77e 100644 --- a/src/core/file_sys/fssystem/fs_types.h +++ b/src/core/file_sys/fssystem/fs_types.h @@ -39,7 +39,7 @@ struct HashSalt { std::array value; }; -static_assert(std::is_trivial_v); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); static_assert(sizeof(HashSalt) == HashSalt::Size); constexpr inline size_t IntegrityMinLayerCount = 2; diff --git a/src/core/file_sys/fssystem/fssystem_aes_ctr_counter_extended_storage.h b/src/core/file_sys/fssystem/fssystem_aes_ctr_counter_extended_storage.h index b409b3acf3..7e2c1daa16 100644 --- a/src/core/file_sys/fssystem/fssystem_aes_ctr_counter_extended_storage.h +++ b/src/core/file_sys/fssystem/fssystem_aes_ctr_counter_extended_storage.h @@ -57,7 +57,7 @@ public: }; static_assert(sizeof(Entry) == 0x10); static_assert(alignof(Entry) == 4); - static_assert(std::is_trivial_v); + static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); public: static constexpr s64 QueryHeaderStorageSize() { diff --git a/src/core/file_sys/fssystem/fssystem_bucket_tree.cpp b/src/core/file_sys/fssystem/fssystem_bucket_tree.cpp index e457f6b239..cdf8b23870 100644 --- a/src/core/file_sys/fssystem/fssystem_bucket_tree.cpp +++ b/src/core/file_sys/fssystem/fssystem_bucket_tree.cpp @@ -15,7 +15,7 @@ namespace { using Node = impl::BucketTreeNode; static_assert(sizeof(Node) == sizeof(BucketTree::NodeHeader)); -static_assert(std::is_trivial_v); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); constexpr inline s32 NodeHeaderSize = sizeof(BucketTree::NodeHeader); diff --git a/src/core/file_sys/fssystem/fssystem_bucket_tree.h b/src/core/file_sys/fssystem/fssystem_bucket_tree.h index 66b6a17bbc..27fc666782 100644 --- a/src/core/file_sys/fssystem/fssystem_bucket_tree.h +++ b/src/core/file_sys/fssystem/fssystem_bucket_tree.h @@ -44,7 +44,7 @@ public: void Format(s32 entry_count); Result Verify() const; }; - static_assert(std::is_trivial_v
); + static_assert(std::is_trivially_default_constructible_v
&& std::is_trivially_copyable_v
); static_assert(sizeof(Header) == 0x10); struct NodeHeader { @@ -54,7 +54,7 @@ public: Result Verify(s32 node_index, size_t node_size, size_t entry_size) const; }; - static_assert(std::is_trivial_v); + static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); static_assert(sizeof(NodeHeader) == 0x10); struct Offsets { @@ -69,7 +69,7 @@ public: return size > 0 && this->start_offset <= offset && size <= (this->end_offset - offset); } }; - static_assert(std::is_trivial_v); + static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); static_assert(sizeof(Offsets) == 0x10); struct OffsetCache { @@ -184,7 +184,7 @@ private: template T* Get() const { - static_assert(std::is_trivial_v); + static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); static_assert(sizeof(T) == sizeof(NodeHeader)); return reinterpret_cast(m_header); } @@ -405,9 +405,9 @@ private: s64 end; s64 start; } info; - static_assert(std::is_trivial_v); + static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); }; - static_assert(std::is_trivial_v); + static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); const BucketTree* m_tree; BucketTree::Offsets m_offsets; diff --git a/src/core/file_sys/fssystem/fssystem_bucket_tree_template_impl.h b/src/core/file_sys/fssystem/fssystem_bucket_tree_template_impl.h index 5e7402e71c..d63566294a 100644 --- a/src/core/file_sys/fssystem/fssystem_bucket_tree_template_impl.h +++ b/src/core/file_sys/fssystem/fssystem_bucket_tree_template_impl.h @@ -16,7 +16,7 @@ namespace FileSys { template Result BucketTree::ScanContinuousReading(ContinuousReadingInfo* out_info, const ContinuousReadingParam& param) const { - static_assert(std::is_trivial_v>); + static_assert(std::is_trivially_default_constructible_v> && std::is_trivially_copyable_v>); // Validate our preconditions. ASSERT(this->IsInitialized()); @@ -140,7 +140,7 @@ Result BucketTree::ScanContinuousReading(ContinuousReadingInfo* out_info, template Result BucketTree::Visitor::ScanContinuousReading(ContinuousReadingInfo* out_info, s64 offset, size_t size) const { - static_assert(std::is_trivial_v); + static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); ASSERT(this->IsValid()); // Create our parameters. diff --git a/src/core/file_sys/fssystem/fssystem_compressed_storage.h b/src/core/file_sys/fssystem/fssystem_compressed_storage.h index 97de0f0c9a..5c763ad02e 100644 --- a/src/core/file_sys/fssystem/fssystem_compressed_storage.h +++ b/src/core/file_sys/fssystem/fssystem_compressed_storage.h @@ -36,7 +36,7 @@ public: return this->phys_size; } }; - static_assert(std::is_trivial_v); + static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); static_assert(sizeof(Entry) == 0x18); public: @@ -679,7 +679,7 @@ private: return this->virtual_offset + this->virtual_size; } }; - static_assert(std::is_trivial_v); + static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); public: CacheManager() = default; diff --git a/src/core/file_sys/fssystem/fssystem_hierarchical_integrity_verification_storage.h b/src/core/file_sys/fssystem/fssystem_hierarchical_integrity_verification_storage.h index ada1656ef7..92409c3edb 100644 --- a/src/core/file_sys/fssystem/fssystem_hierarchical_integrity_verification_storage.h +++ b/src/core/file_sys/fssystem/fssystem_hierarchical_integrity_verification_storage.h @@ -22,7 +22,7 @@ struct HierarchicalIntegrityVerificationLevelInformation { s32 block_order; std::array reserved; }; -static_assert(std::is_trivial_v); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); static_assert(sizeof(HierarchicalIntegrityVerificationLevelInformation) == 0x18); static_assert(alignof(HierarchicalIntegrityVerificationLevelInformation) == 0x4); @@ -43,7 +43,7 @@ struct HierarchicalIntegrityVerificationInformation { return this->info[this->max_layers - 2].size; } }; -static_assert(std::is_trivial_v); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); struct HierarchicalIntegrityVerificationMetaInformation { u32 magic; @@ -51,14 +51,14 @@ struct HierarchicalIntegrityVerificationMetaInformation { u32 master_hash_size; HierarchicalIntegrityVerificationInformation level_hash_info; }; -static_assert(std::is_trivial_v); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); struct HierarchicalIntegrityVerificationSizeSet { s64 control_size; s64 master_hash_size; std::array layered_hash_sizes; }; -static_assert(std::is_trivial_v); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); class HierarchicalIntegrityVerificationStorage : public IReadOnlyStorage { YUZU_NON_COPYABLE(HierarchicalIntegrityVerificationStorage); diff --git a/src/core/file_sys/fssystem/fssystem_indirect_storage.h b/src/core/file_sys/fssystem/fssystem_indirect_storage.h index 728616b964..2b23fe7352 100644 --- a/src/core/file_sys/fssystem/fssystem_indirect_storage.h +++ b/src/core/file_sys/fssystem/fssystem_indirect_storage.h @@ -51,7 +51,7 @@ public: return offset; } }; - static_assert(std::is_trivial_v); + static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); static_assert(sizeof(Entry) == 0x14); struct EntryData { @@ -65,7 +65,7 @@ public: this->storage_index = entry.storage_index; } }; - static_assert(std::is_trivial_v); + static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); public: IndirectStorage() : m_table(), m_data_storage() {} @@ -158,7 +158,7 @@ private: return this->entry.storage_index != 0; } }; - static_assert(std::is_trivial_v); + static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); private: mutable BucketTree m_table; diff --git a/src/core/file_sys/fssystem/fssystem_integrity_verification_storage.h b/src/core/file_sys/fssystem/fssystem_integrity_verification_storage.h index b4259419dd..12e440a404 100644 --- a/src/core/file_sys/fssystem/fssystem_integrity_verification_storage.h +++ b/src/core/file_sys/fssystem/fssystem_integrity_verification_storage.h @@ -26,7 +26,7 @@ public: struct BlockHash { std::array hash; }; - static_assert(std::is_trivial_v); + static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); public: IntegrityVerificationStorage() diff --git a/src/core/file_sys/fssystem/fssystem_nca_file_system_driver.h b/src/core/file_sys/fssystem/fssystem_nca_file_system_driver.h index 74f969154f..3e68f8208d 100644 --- a/src/core/file_sys/fssystem/fssystem_nca_file_system_driver.h +++ b/src/core/file_sys/fssystem/fssystem_nca_file_system_driver.h @@ -54,12 +54,12 @@ struct NcaCryptoConfiguration { bool is_plaintext_header_available; bool is_available_sw_key; }; -static_assert(std::is_trivial_v); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); struct NcaCompressionConfiguration { GetDecompressorFunction get_decompressor; }; -static_assert(std::is_trivial_v); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); constexpr inline s32 KeyAreaEncryptionKeyCount = NcaCryptoConfiguration::KeyAreaEncryptionKeyIndexCount * diff --git a/src/core/file_sys/fssystem/fssystem_nca_header.h b/src/core/file_sys/fssystem/fssystem_nca_header.h index b10bb39e66..f13b717619 100644 --- a/src/core/file_sys/fssystem/fssystem_nca_header.h +++ b/src/core/file_sys/fssystem/fssystem_nca_header.h @@ -25,7 +25,7 @@ struct Hash { std::array value; }; static_assert(sizeof(Hash) == Hash::Size); -static_assert(std::is_trivial_v); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); using NcaDigest = Hash; @@ -72,7 +72,7 @@ struct NcaHeader { u32 reserved; }; static_assert(sizeof(FsInfo) == 0x10); - static_assert(std::is_trivial_v); + static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); static constexpr u32 Magic0 = Common::MakeMagic('N', 'C', 'A', '0'); static constexpr u32 Magic1 = Common::MakeMagic('N', 'C', 'A', '1'); @@ -126,7 +126,7 @@ struct NcaHeader { u8 GetProperKeyGeneration() const; }; static_assert(sizeof(NcaHeader) == NcaHeader::Size); -static_assert(std::is_trivial_v); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); struct NcaBucketInfo { static constexpr size_t HeaderSize = 0x10; @@ -134,7 +134,7 @@ struct NcaBucketInfo { Int64 size; std::array header; }; -static_assert(std::is_trivial_v); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); struct NcaPatchInfo { static constexpr size_t Size = 0x40; @@ -150,7 +150,7 @@ struct NcaPatchInfo { bool HasIndirectTable() const; bool HasAesCtrExTable() const; }; -static_assert(std::is_trivial_v); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); union NcaAesCtrUpperIv { u64 value; @@ -159,7 +159,7 @@ union NcaAesCtrUpperIv { u32 secure_value; } part; }; -static_assert(std::is_trivial_v); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); struct NcaSparseInfo { NcaBucketInfo bucket; @@ -181,20 +181,20 @@ struct NcaSparseInfo { return sparse_upper_iv; } }; -static_assert(std::is_trivial_v); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); struct NcaCompressionInfo { NcaBucketInfo bucket; std::array resreved; }; -static_assert(std::is_trivial_v); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); struct NcaMetaDataHashDataInfo { Int64 offset; Int64 size; Hash hash; }; -static_assert(std::is_trivial_v); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); struct NcaFsHeader { static constexpr size_t Size = 0x200; @@ -204,7 +204,7 @@ struct NcaFsHeader { Int64 offset; Int64 size; }; - static_assert(std::is_trivial_v); + static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); enum class FsType : u8 { RomFs = 0, @@ -246,7 +246,7 @@ struct NcaFsHeader { s32 hash_layer_count; std::array hash_layer_region; } hierarchical_sha256_data; - static_assert(std::is_trivial_v); + static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); struct IntegrityMetaInfo { static const size_t MasterHashOffset; @@ -279,7 +279,7 @@ struct NcaFsHeader { Hash master_hash; } integrity_meta_info; - static_assert(std::is_trivial_v); + static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); std::array padding; }; @@ -325,7 +325,7 @@ struct NcaFsHeader { } }; static_assert(sizeof(NcaFsHeader) == NcaFsHeader::Size); -static_assert(std::is_trivial_v); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); static_assert(offsetof(NcaFsHeader, patch_info) == NcaPatchInfo::Offset); inline constexpr const size_t NcaFsHeader::HashData::HierarchicalSha256Data::MasterHashOffset = @@ -339,6 +339,6 @@ struct NcaMetaDataHashData { }; static_assert(sizeof(NcaMetaDataHashData) == sizeof(NcaFsHeader::HashData::IntegrityMetaInfo) + sizeof(s64)); -static_assert(std::is_trivial_v); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); } // namespace FileSys diff --git a/src/core/file_sys/ips_layer.cpp b/src/core/file_sys/ips_layer.cpp index 32e9041017..d95ac53932 100644 --- a/src/core/file_sys/ips_layer.cpp +++ b/src/core/file_sys/ips_layer.cpp @@ -162,7 +162,7 @@ void IPSwitchCompiler::Parse(std::span bytes) { // yes, @nsobid too -- NSO Build ID Specifier case 'n': case 'N': - nso_build_id = Common::HexStringToArray<0x20>(fmt::format("{:0<64}", line.substr(8))); + nso_build_id = Common::HexStringToArray<0x20>(std::format("{:0<64}", line.substr(8))); break; // @stop case 's': diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index 75aff5af9d..33db847806 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp @@ -60,9 +60,9 @@ std::string FormatTitleVersion(u32 version, } if (format == TitleVersionFormat::FourElements) { - return fmt::format("v{}.{}.{}.{}", bytes[3], bytes[2], bytes[1], bytes[0]); + return std::format("v{}.{}.{}.{}", bytes[3], bytes[2], bytes[1], bytes[0]); } - return fmt::format("v{}.{}.{}", bytes[3], bytes[2], bytes[1]); + return std::format("v{}.{}.{}", bytes[3], bytes[2], bytes[1]); } // Returns a directory with name matching name case-insensitive. Returns nullptr if directory @@ -87,7 +87,7 @@ std::optional> ReadCheatFileFromFolder( u64 title_id, const PatchManager::BuildID& build_id_, const VirtualDir& base_path, bool upper) { const auto build_id_raw = Common::HexToString(build_id_, upper); const auto build_id = build_id_raw.substr(0, sizeof(u64) * 2); - const auto file = base_path->GetFile(fmt::format("{}.txt", build_id)); + const auto file = base_path->GetFile(std::format("{}.txt", build_id)); if (file == nullptr) { LOG_INFO(Common_Filesystem, "No cheats file found for title_id={:016X}, build_id={}", @@ -120,7 +120,7 @@ bool IsDirValidAndNonEmpty(const VirtualDir& dir) { } bool IsVersionedExternalUpdateDisabled(const std::vector& disabled, u32 version) { - const std::string disabled_key = fmt::format("Update@{}", version); + const std::string disabled_key = std::format("Update@{}", version); return std::find(disabled.cbegin(), disabled.cend(), disabled_key) != disabled.cend() || std::find(disabled.cbegin(), disabled.cend(), "Update") != disabled.cend(); } @@ -373,7 +373,7 @@ VirtualDir PatchManager::PatchExeFS(VirtualDir exefs) const { std::vector PatchManager::CollectPatches(const std::vector& patch_dirs, const std::string& build_id) const { const auto disabled = GetDisabledAddons(); - const auto nso_build_id = fmt::format("{:0<64}", build_id); + const auto nso_build_id = std::format("{:0<64}", build_id); std::vector out; out.reserve(patch_dirs.size()); @@ -386,7 +386,7 @@ std::vector PatchManager::CollectPatches(const std::vectorGetFiles()) { if (file->GetExtension() == "ips") { auto name = file->GetName(); - const auto this_build_id = fmt::format("{:0<64}", name.substr(0, name.find('.'))); + const auto this_build_id = std::format("{:0<64}", name.substr(0, name.find('.'))); if (nso_build_id == this_build_id) out.push_back(file); } else if (file->GetExtension() == "pchtxt") { @@ -422,7 +422,7 @@ std::vector PatchManager::PatchNSO(const std::vector& nso, const std::st const auto dump_dir = fs_controller.GetModificationDumpRoot(title_id); if (dump_dir != nullptr) { const auto nso_dir = GetOrCreateDirectoryRelative(dump_dir, "/nso"); - const auto file = nso_dir->CreateFile(fmt::format("{}-{}.nso", name, build_id)); + const auto file = nso_dir->CreateFile(std::format("{}-{}.nso", name, build_id)); file->Resize(nso.size()); file->WriteBytes(nso); @@ -605,7 +605,7 @@ void PatchManager::ApplyLayeredFS(VirtualFile& romfs, ContentRecordType type) co VirtualFile PatchManager::PatchRomFS(const NCA* base_nca, VirtualFile base_romfs, ContentRecordType type, VirtualFile packed_update_raw, bool apply_layeredfs) const { - const auto log_string = fmt::format("Patching RomFS for title_id={:016X}, type={:02X}", + const auto log_string = std::format("Patching RomFS for title_id={:016X}, type={:02X}", title_id, static_cast(type)); if (type == ContentRecordType::Program || type == ContentRecordType::Data) { LOG_INFO(Loader, "{}", log_string); @@ -1068,9 +1068,9 @@ std::vector PatchManager::GetPatches(VirtualFile update_raw) const { std::string list; for (size_t i = 0; i < dlc_match.size() - 1; ++i) - list += fmt::format("{}, ", dlc_match[i].title_id & 0x7FF); + list += std::format("{}, ", dlc_match[i].title_id & 0x7FF); - list += fmt::format("{}", dlc_match.back().title_id & 0x7FF); + list += std::format("{}", dlc_match.back().title_id & 0x7FF); const auto dlc_disabled = std::find(disabled.begin(), disabled.end(), "DLC") != disabled.end(); diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp index 26e73d260a..d76f60e16e 100644 --- a/src/core/file_sys/registered_cache.cpp +++ b/src/core/file_sys/registered_cache.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "common/assert.h" #include "common/fs/path_util.h" @@ -34,7 +35,7 @@ namespace FileSys { constexpr size_t VFS_RC_LARGE_COPY_BLOCK = 0x400000; std::string ContentProviderEntry::DebugInfo() const { - return fmt::format("title_id={:016X}, content_type={:02X}", title_id, static_cast(type)); + return std::format("title_id={:016X}, content_type={:02X}", title_id, static_cast(type)); } bool operator<(const ContentProviderEntry& lhs, const ContentProviderEntry& rhs) { @@ -69,20 +70,16 @@ static std::string GetRelativePathFromNcaID(const std::array& nca_id, bo const auto nca_str = Common::HexToString(nca_id, second_hex_upper); if (!within_two_digit) { - const auto format_str = fmt::runtime(cnmt_suffix ? "{}.cnmt.nca" : "/{}.nca"); - return fmt::format(format_str, nca_str); + return cnmt_suffix ? std::format("{}.cnmt.nca", nca_str) : std::format("/{}.nca", nca_str); } Core::Crypto::SHA256Hash hash{}; u32 hash_len = 0; EVP_Digest(nca_id.data(), nca_id.size(), hash.data(), &hash_len, EVP_sha256(), nullptr); - const auto format_str = - fmt::runtime(cnmt_suffix ? "/000000{:02X}/{}.cnmt.nca" : "/000000{:02X}/{}.nca"); - LOG_DEBUG(Loader, "Decoded {} bytes, nca id {}", hash_len, nca_str); - return fmt::format(format_str, hash[0], nca_str); + return cnmt_suffix ? std::format("/000000{:02X}/{}.cnmt.nca", hash[0], nca_str) : std::format("/000000{:02X}/{}.nca", hash[0], nca_str); } static std::string GetCNMTName(TitleType type, u64 title_id) { @@ -104,7 +101,7 @@ static std::string GetCNMTName(TitleType type, u64 title_id) { index -= static_cast(TitleType::Application) - static_cast(TitleType::FirmwarePackageB); } - return fmt::format("{}_{:016x}.cnmt", TITLE_TYPE_NAMES[index], title_id); + return std::format("{}_{:016x}.cnmt", TITLE_TYPE_NAMES[index], title_id); } static std::shared_ptr OpenContainerAsNsp(const VirtualFile& file, Loader::FileType type) { @@ -400,14 +397,14 @@ bool PlaceholderCache::Create(const NcaID& id, u64 size) const { LOG_DEBUG(Loader, "Decoded {} bytes, nca id {}", hash_len, id); - const auto dirname = fmt::format("000000{:02X}", hash[0]); + const auto dirname = std::format("000000{:02X}", hash[0]); const auto dir2 = GetOrCreateDirectoryRelative(dir, dirname); if (dir2 == nullptr) return false; - const auto file = dir2->CreateFile(fmt::format("{}.nca", Common::HexToString(id, false))); + const auto file = dir2->CreateFile(std::format("{}.nca", Common::HexToString(id, false))); if (file == nullptr) return false; @@ -428,11 +425,11 @@ bool PlaceholderCache::Delete(const NcaID& id) const { LOG_DEBUG(Loader, "Decoded {} bytes, nca id {}", hash_len, id); - const auto dirname = fmt::format("000000{:02X}", hash[0]); + const auto dirname = std::format("000000{:02X}", hash[0]); const auto dir2 = GetOrCreateDirectoryRelative(dir, dirname); - const auto res = dir2->DeleteFile(fmt::format("{}.nca", Common::HexToString(id, false))); + const auto res = dir2->DeleteFile(std::format("{}.nca", Common::HexToString(id, false))); return res; } @@ -561,11 +558,11 @@ VirtualFile RegisteredCache::OpenFileOrDirectoryConcat(const VirtualDir& open_di std::vector concat; // Since the files are a two-digit hex number, max is FF. for (std::size_t i = 0; i < 0x100; ++i) { - auto next = nca_dir->GetFile(fmt::format("{:02X}", i)); + auto next = nca_dir->GetFile(std::format("{:02X}", i)); if (next != nullptr) { concat.push_back(std::move(next)); } else { - next = nca_dir->GetFile(fmt::format("{:02x}", i)); + next = nca_dir->GetFile(std::format("{:02x}", i)); if (next != nullptr) { concat.push_back(std::move(next)); } else { @@ -832,11 +829,11 @@ std::vector RegisteredCache::ListEntriesFilter( static std::shared_ptr GetNCAFromNSPForID(const NSP& nsp, const NcaID& id) { const auto id_string = Common::HexToString(id, false); - auto file = nsp.GetFile(fmt::format("{}.nca", id_string)); + auto file = nsp.GetFile(std::format("{}.nca", id_string)); if (file == nullptr) { - if (auto ncz_file = nsp.GetFile(fmt::format("{}.ncz", id_string))) { + if (auto ncz_file = nsp.GetFile(std::format("{}.ncz", id_string))) { file = Core::Crypto::DecompressNCZForInstall( - ncz_file, fmt::format("{}.nca", id_string)); + ncz_file, std::format("{}.nca", id_string)); } } if (file == nullptr) { diff --git a/src/core/file_sys/savedata_factory.cpp b/src/core/file_sys/savedata_factory.cpp index c756734a43..514958a4aa 100644 --- a/src/core/file_sys/savedata_factory.cpp +++ b/src/core/file_sys/savedata_factory.cpp @@ -45,9 +45,9 @@ std::string GetFutureSaveDataPath(SaveDataSpaceId space_id, SaveDataType type, u // Only detect account/device saves from the future location. switch (type) { case SaveDataType::Account: - return fmt::format("{}/account/{}/{:016X}/0", space_id_path, uuid.RawString(), title_id); + return std::format("{}/account/{}/{:016X}/0", space_id_path, uuid.RawString(), title_id); case SaveDataType::Device: - return fmt::format("{}/device/{:016X}/0", space_id_path, title_id); + return std::format("{}/device/{:016X}/0", space_id_path, title_id); default: return ""; } @@ -127,19 +127,19 @@ std::string SaveDataFactory::GetFullPath(ProgramId program_id, VirtualDir dir, switch (type) { case SaveDataType::System: - return fmt::format("{}save/{:016X}/{:016X}{:016X}", out, save_id, user_id[1], user_id[0]); + return std::format("{}save/{:016X}/{:016X}{:016X}", out, save_id, user_id[1], user_id[0]); case SaveDataType::Account: case SaveDataType::Device: - return fmt::format("{}save/{:016X}/{:016X}{:016X}/{:016X}", out, 0, user_id[1], user_id[0], + return std::format("{}save/{:016X}/{:016X}{:016X}/{:016X}", out, 0, user_id[1], user_id[0], title_id); case SaveDataType::Temporary: - return fmt::format("{}{:016X}/{:016X}{:016X}/{:016X}", out, 0, user_id[1], user_id[0], + return std::format("{}{:016X}/{:016X}{:016X}/{:016X}", out, 0, user_id[1], user_id[0], title_id); case SaveDataType::Cache: - return fmt::format("{}save/cache/{:016X}", out, title_id); + return std::format("{}save/cache/{:016X}", out, title_id); default: ASSERT_MSG(false, "Unrecognized SaveDataType: {:02X}", static_cast(type)); - return fmt::format("{}save/unknown_{:X}/{:016X}", out, static_cast(type), title_id); + return std::format("{}save/unknown_{:X}/{:016X}", out, static_cast(type), title_id); } } @@ -147,9 +147,9 @@ std::string SaveDataFactory::GetUserGameSaveDataRoot(u128 user_id, bool future) if (future) { Common::UUID uuid; std::memcpy(uuid.uuid.data(), user_id.data(), sizeof(Common::UUID)); - return fmt::format("/user/save/account/{}", uuid.RawString()); + return std::format("/user/save/account/{}", uuid.RawString()); } - return fmt::format("/user/save/{:016X}/{:016X}{:016X}", 0, user_id[1], user_id[0]); + return std::format("/user/save/{:016X}/{:016X}{:016X}", 0, user_id[1], user_id[0]); } SaveDataSize SaveDataFactory::ReadSaveDataSize(SaveDataType type, u64 title_id, diff --git a/src/core/file_sys/sdmc_factory.cpp b/src/core/file_sys/sdmc_factory.cpp index a2903dbacf..46e4176800 100644 --- a/src/core/file_sys/sdmc_factory.cpp +++ b/src/core/file_sys/sdmc_factory.cpp @@ -35,7 +35,7 @@ VirtualDir SDMCFactory::GetSDMCModificationLoadRoot(u64 title_id) const { if (title_id == 0 || (title_id & 0xFFF) == 0x800) { return nullptr; } - return GetOrCreateDirectoryRelative(sd_mod_dir, fmt::format("/{:016X}", title_id)); + return GetOrCreateDirectoryRelative(sd_mod_dir, std::format("/{:016X}", title_id)); } VirtualDir SDMCFactory::GetSDMCContentDirectory() const { diff --git a/src/core/file_sys/submission_package.cpp b/src/core/file_sys/submission_package.cpp index 1a39d819f6..3000825304 100644 --- a/src/core/file_sys/submission_package.cpp +++ b/src/core/file_sys/submission_package.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include "common/hex_util.h" #include "common/logging.h" @@ -245,12 +245,12 @@ void NSP::ReadNCAs(const std::vector& files) { for (const auto& rec : cnmt.GetContentRecords()) { const auto id_string = Common::HexToString(rec.nca_id, false); - auto next_file = pfs->GetFile(fmt::format("{}.nca", id_string)); + auto next_file = pfs->GetFile(std::format("{}.nca", id_string)); if (next_file == nullptr) { - auto ncz_file = pfs->GetFile(fmt::format("{}.ncz", id_string)); + auto ncz_file = pfs->GetFile(std::format("{}.ncz", id_string)); if (ncz_file != nullptr) { - next_file = Core::Crypto::DecompressNCZ(ncz_file, fmt::format("{}.nca", id_string)); + next_file = Core::Crypto::DecompressNCZ(ncz_file, std::format("{}.nca", id_string)); if (next_file == nullptr) { LOG_DEBUG(Service_FS, "Skipping solid or unsupported NCZ content {}.ncz", id_string); continue; diff --git a/src/core/file_sys/system_archive/ng_word.cpp b/src/core/file_sys/system_archive/ng_word.cpp index a647e19eae..81c593fbde 100644 --- a/src/core/file_sys/system_archive/ng_word.cpp +++ b/src/core/file_sys/system_archive/ng_word.cpp @@ -1,7 +1,10 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include +#include #include "common/common_types.h" #include "core/file_sys/system_archive/ng_word.h" #include "core/file_sys/vfs/vfs_vector.h" @@ -27,7 +30,7 @@ VirtualDir NgWord1() { files.reserve(NgWord1Data::NUMBER_WORD_TXT_FILES); for (std::size_t i = 0; i < files.size(); ++i) { - files.push_back(MakeArrayFile(NgWord1Data::WORD_TXT, fmt::format("{}.txt", i))); + files.push_back(MakeArrayFile(NgWord1Data::WORD_TXT, std::format("{}.txt", i))); } files.push_back(MakeArrayFile(NgWord1Data::WORD_TXT, "common.txt")); @@ -57,9 +60,9 @@ VirtualDir NgWord2() { files.reserve(NgWord2Data::NUMBER_AC_NX_FILES * 3); 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))); - files.push_back(MakeArrayFile(NgWord2Data::AC_NX_DATA, fmt::format("ac_{}_b2_nx", i))); - files.push_back(MakeArrayFile(NgWord2Data::AC_NX_DATA, fmt::format("ac_{}_not_b_nx", i))); + files.push_back(MakeArrayFile(NgWord2Data::AC_NX_DATA, std::format("ac_{}_b1_nx", i))); + files.push_back(MakeArrayFile(NgWord2Data::AC_NX_DATA, std::format("ac_{}_b2_nx", i))); + files.push_back(MakeArrayFile(NgWord2Data::AC_NX_DATA, std::format("ac_{}_not_b_nx", i))); } files.push_back(MakeArrayFile(NgWord2Data::AC_NX_DATA, "ac_common_b1_nx")); diff --git a/src/core/file_sys/xts_archive.cpp b/src/core/file_sys/xts_archive.cpp index 7c5da5e7e3..108114325e 100644 --- a/src/core/file_sys/xts_archive.cpp +++ b/src/core/file_sys/xts_archive.cpp @@ -65,7 +65,7 @@ NAX::NAX(VirtualFile file_) const std::string two_dir = Common::ToUpper(std::string{match[1]}); const std::string nca_id = Common::ToLower(std::string{match[2]}); - status = Parse(fmt::format("/registered/{}/{}.nca", two_dir, nca_id)); + status = Parse(std::format("/registered/{}/{}.nca", two_dir, nca_id)); } NAX::NAX(VirtualFile file_, std::array nca_id) @@ -78,7 +78,7 @@ NAX::NAX(VirtualFile file_, std::array nca_id) LOG_DEBUG(Loader, "Decoded {} bytes, nca id {}", hash_len, nca_id); - status = Parse(fmt::format("/registered/000000{:02X}/{}.nca", hash[0], + status = Parse(std::format("/registered/000000{:02X}/{}.nca", hash[0], Common::HexToString(nca_id, false))); } diff --git a/src/core/frontend/applets/error.cpp b/src/core/frontend/applets/error.cpp index ff45a13510..f279434109 100644 --- a/src/core/frontend/applets/error.cpp +++ b/src/core/frontend/applets/error.cpp @@ -4,6 +4,7 @@ // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include #include "common/logging.h" #include "core/frontend/applets/error.h" diff --git a/src/core/hle/api_version.h b/src/core/hle/api_version.h index 0aff969296..953510b06d 100644 --- a/src/core/hle/api_version.h +++ b/src/core/hle/api_version.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include #include "common/common_types.h" // This file contains yuzu's HLE API version constants. diff --git a/src/core/hle/kernel/k_page_table_base.h b/src/core/hle/kernel/k_page_table_base.h index 0c222910fc..38536610a1 100644 --- a/src/core/hle/kernel/k_page_table_base.h +++ b/src/core/hle/kernel/k_page_table_base.h @@ -46,7 +46,7 @@ struct KPageProperties { bool uncached; DisableMergeAttribute disable_merge_attributes; }; -static_assert(std::is_trivial_v); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); static_assert(sizeof(KPageProperties) == sizeof(u32)); class KResourceLimit; @@ -121,7 +121,7 @@ protected: Node* m_next; std::array m_buffer; }; - static_assert(std::is_trivial_v); + static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); private: Node* m_root{}; diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 3542d5a3b6..c7141fdb6d 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -34,7 +34,7 @@ static void SetArg64(std::span args, int n, uint64_t result) { // Like bit_cast, but handles the case when the source and dest // are differently-sized. template - requires(std::is_trivial_v && std::is_trivially_copyable_v) + requires(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v && std::is_trivially_copyable_v) static To Convert(const From& from) { To to{}; if constexpr (sizeof(To) >= sizeof(From)) diff --git a/src/core/hle/kernel/svc/svc_exception.cpp b/src/core/hle/kernel/svc/svc_exception.cpp index 4f214c6142..a2023fe326 100644 --- a/src/core/hle/kernel/svc/svc_exception.cpp +++ b/src/core/hle/kernel/svc/svc_exception.cpp @@ -41,7 +41,7 @@ void Break(Core::System& system, BreakReason reason, u64 info1, u64 info2) { memory.ReadBlock(addr, debug_buffer.data(), sz); std::string hexdump; for (std::size_t i = 0; i < debug_buffer.size(); i++) { - hexdump += fmt::format("{:02X} ", debug_buffer[i]); + hexdump += std::format("{:02X} ", debug_buffer[i]); if ((i + 1) % 32 == 0) { hexdump += '\n'; } diff --git a/src/core/hle/result.h b/src/core/hle/result.h index da100ede90..98588861e4 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h @@ -258,7 +258,7 @@ union Result { return GetInnerValue() == result.GetInnerValue(); } }; -static_assert(std::is_trivial_v); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); [[nodiscard]] constexpr bool operator==(const Result& a, const Result& b) { return a.raw == b.raw; diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp index d68b6bde0d..90c0184f84 100644 --- a/src/core/hle/service/acc/acc.cpp +++ b/src/core/hle/service/acc/acc.cpp @@ -36,7 +36,7 @@ constexpr std::size_t THUMBNAIL_SIZE = 0x24000; static std::filesystem::path GetImagePath(const Common::UUID& uuid) { return Common::FS::GetEdenPath(Common::FS::EdenPath::NANDDir) / - fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString()); + std::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString()); } static void JPGToMemory(void* context, void* data, int len) { diff --git a/src/core/hle/service/acc/profile_manager.cpp b/src/core/hle/service/acc/profile_manager.cpp index aeceec1cac..8ad30edbfc 100644 --- a/src/core/hle/service/acc/profile_manager.cpp +++ b/src/core/hle/service/acc/profile_manager.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include "common/fs/file.h" #include "common/fs/fs.h" @@ -507,7 +507,7 @@ std::vector ProfileManager::FindExistingProfileStrings() for (const UUID &uuid : uuids) { auto user_id = uuid.AsU128(); - uuid_strings.emplace_back(fmt::format("{:016X}{:016X}", user_id[1], user_id[0])); + uuid_strings.emplace_back(std::format("{:016X}{:016X}", user_id[1], user_id[0])); } return uuid_strings; diff --git a/src/core/hle/service/am/frontend/applet_error.cpp b/src/core/hle/service/am/frontend/applet_error.cpp index 1a0786ea5a..9513eee23d 100644 --- a/src/core/hle/service/am/frontend/applet_error.cpp +++ b/src/core/hle/service/am/frontend/applet_error.cpp @@ -6,6 +6,7 @@ #include #include +#include #include "common/assert.h" #include "common/logging.h" #include "common/string_util.h" @@ -198,7 +199,7 @@ void Error::Execute() { case ErrorAppletMode::ShowErrorPctl: case ErrorAppletMode::ShowErrorRecord: reporter.SaveErrorReport(title_id, error_code, - fmt::format("{:016X}", args->error_record.posix_time)); + std::format("{:016X}", args->error_record.posix_time)); frontend.ShowErrorWithTimestamp( error_code, std::chrono::seconds{args->error_record.posix_time}, callback); break; diff --git a/src/core/hle/service/am/frontend/applet_general.cpp b/src/core/hle/service/am/frontend/applet_general.cpp index 22cad54b66..005fedb87d 100644 --- a/src/core/hle/service/am/frontend/applet_general.cpp +++ b/src/core/hle/service/am/frontend/applet_general.cpp @@ -194,7 +194,7 @@ void PhotoViewer::Execute() { frontend.ShowAllPhotos(callback); break; default: - UNIMPLEMENTED_MSG("Unimplemented PhotoViewer applet mode={:02X}!", mode); + UNIMPLEMENTED_MSG("Unimplemented PhotoViewer applet mode={:02X}!",mode); break; } } diff --git a/src/core/hle/service/am/frontend/applet_general.h b/src/core/hle/service/am/frontend/applet_general.h index ceb0537119..f15385ac67 100644 --- a/src/core/hle/service/am/frontend/applet_general.h +++ b/src/core/hle/service/am/frontend/applet_general.h @@ -44,6 +44,8 @@ private: u8 arg0 = 0; u8 arg1 = 0; u8 arg2 = 0; + + void unimplementedLog(); }; enum class PhotoViewerAppletMode : u8 { diff --git a/src/core/hle/service/am/frontend/applet_web_browser.cpp b/src/core/hle/service/am/frontend/applet_web_browser.cpp index 1ddb1ec2a3..dbc24a6345 100644 --- a/src/core/hle/service/am/frontend/applet_web_browser.cpp +++ b/src/core/hle/service/am/frontend/applet_web_browser.cpp @@ -528,11 +528,11 @@ void WebBrowser::InitializeOffline() { }; offline_cache_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::CacheDir) / - fmt::format("offline_web_applet_{}/{:016X}", + std::format("offline_web_applet_{}/{:016X}", RESOURCE_TYPES[static_cast(document_kind) - 1], title_id); offline_document = Common::FS::ConcatPathSafe( - offline_cache_dir, fmt::format("{}/{}", additional_paths, document_path)); + offline_cache_dir, std::format("{}/{}", additional_paths, document_path)); } void WebBrowser::InitializeShare() {} diff --git a/src/core/hle/service/audio/audio_device.cpp b/src/core/hle/service/audio/audio_device.cpp index e9f7e074a1..488c4bd336 100644 --- a/src/core/hle/service/audio/audio_device.cpp +++ b/src/core/hle/service/audio/audio_device.cpp @@ -16,7 +16,7 @@ IAudioDevice::IAudioDevice(Core::System& system_, u64 applet_resource_user_id, u u32 device_num) : ServiceFramework{system_, "IAudioDevice"}, service_context{system_, "IAudioDevice"}, impl{std::make_unique(system_, applet_resource_user_id, revision)}, - event{service_context.CreateEvent(fmt::format("IAudioDeviceEvent-{}", device_num))} { + event{service_context.CreateEvent(std::format("IAudioDeviceEvent-{}", device_num))} { static const FunctionInfo functions[] = { {0, D<&IAudioDevice::ListAudioDeviceName>, "ListAudioDeviceName"}, {1, D<&IAudioDevice::SetAudioDeviceOutputVolume>, "SetAudioDeviceOutputVolume"}, diff --git a/src/core/hle/service/audio/audio_renderer_manager.cpp b/src/core/hle/service/audio/audio_renderer_manager.cpp index 4756802eeb..02c59629d8 100644 --- a/src/core/hle/service/audio/audio_renderer_manager.cpp +++ b/src/core/hle/service/audio/audio_renderer_manager.cpp @@ -76,12 +76,12 @@ Result IAudioRendererManager::GetWorkBufferSize(Out out_size, R_TRY(impl->GetWorkBufferSize(params, *out_size)) std::string output_info{}; - output_info += fmt::format("\tRevision {}", AudioCore::GetRevisionNum(params.revision)); + output_info += std::format("\tRevision {}", AudioCore::GetRevisionNum(params.revision)); output_info += - fmt::format("\n\tSample Rate {}, Sample Count {}", params.sample_rate, params.sample_count); - output_info += fmt::format("\n\tExecution Mode {}, Voice Drop Enabled {}", + std::format("\n\tSample Rate {}, Sample Count {}", params.sample_rate, params.sample_count); + output_info += std::format("\n\tExecution Mode {}, Voice Drop Enabled {}", static_cast(params.execution_mode), params.voice_drop_enabled); - output_info += fmt::format( + output_info += std::format( "\n\tSizes: Effects {:04X}, Mixes {:04X}, Sinks {:04X}, Submixes {:04X}, Splitter Infos " "{:04X}, Splitter Destinations {:04X}, Voices {:04X}, Performance Frames {:04X} External " "Context {:04X}", diff --git a/src/core/hle/service/bcat/bcat_types.h b/src/core/hle/service/bcat/bcat_types.h index 303c243542..2173ac20bd 100644 --- a/src/core/hle/service/bcat/bcat_types.h +++ b/src/core/hle/service/bcat/bcat_types.h @@ -64,7 +64,7 @@ struct DeliveryCacheProgressImpl { }; static_assert(sizeof(DeliveryCacheProgressImpl) == 0x200, "DeliveryCacheProgressImpl has incorrect size."); -static_assert(std::is_trivial_v, +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v, "DeliveryCacheProgressImpl type must be trivially copyable."); } // namespace Service::BCAT diff --git a/src/core/hle/service/caps/caps_manager.cpp b/src/core/hle/service/caps/caps_manager.cpp index d3c4ab57d1..8f9c730b3e 100644 --- a/src/core/hle/service/caps/caps_manager.cpp +++ b/src/core/hle/service/caps/caps_manager.cpp @@ -424,10 +424,10 @@ Result AlbumManager::SaveImage(ApplicationAlbumEntry& out_entry, std::span, +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v, "ApplicationData type must be trivially copyable."); struct ScreenShotAttribute { @@ -167,7 +167,7 @@ struct ScreenShotAttribute { INSERT_PADDING_BYTES_NOINIT(0x30); }; static_assert(sizeof(ScreenShotAttribute) == 0x40, "ScreenShotAttribute is an invalid size"); -static_assert(std::is_trivial_v, +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v, "ScreenShotAttribute type must be trivially copyable."); struct ScreenShotDecodeOption { @@ -184,7 +184,7 @@ struct LoadAlbumScreenShotImageOutput { }; static_assert(sizeof(LoadAlbumScreenShotImageOutput) == 0x450, "LoadAlbumScreenShotImageOutput is an invalid size"); -static_assert(std::is_trivial_v, +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v, "LoadAlbumScreenShotImageOutput type must be trivially copyable."); struct LoadAlbumScreenShotImageOutputForApplication { diff --git a/src/core/hle/service/fatal/fatal.cpp b/src/core/hle/service/fatal/fatal.cpp index db48526614..a1f50dc655 100644 --- a/src/core/hle/service/fatal/fatal.cpp +++ b/src/core/hle/service/fatal/fatal.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include "common/logging.h" #include "common/scm_rev.h" #include "common/swap.h" @@ -68,37 +68,37 @@ enum class FatalType : u32 { static void GenerateErrorReport(Core::System& system, Result error_code, const FatalInfo& info) { const auto title_id = system.GetApplicationProcessProgramID(); - std::string crash_report = fmt::format( + std::string crash_report = std::format( "Eden {}-{} crash report\n" "Title ID: {:016x}\n" "Result: {:#x} ({:04}-{:04d})\n" "Set flags: {:#16X}\n" "Program entry point: {:#16X}\n" "\n", - Common::g_scm_branch, Common::g_scm_desc, title_id, error_code.raw, + std::string_view{Common::g_scm_branch}, std::string_view{Common::g_scm_desc}, title_id, error_code.raw, 2000 + static_cast(error_code.GetModule()), static_cast(error_code.GetDescription()), info.set_flags, info.program_entry_point); if (info.backtrace_size != 0x0) { crash_report += "Registers:\n"; for (size_t i = 0; i < info.registers.size(); i++) { crash_report += - fmt::format(" X[{:02d}]: {:016x}\n", i, info.registers[i]); + std::format(" X[{:02d}]: {:016x}\n", i, info.registers[i]); } - crash_report += fmt::format(" SP: {:016x}\n", info.sp); - crash_report += fmt::format(" PC: {:016x}\n", info.pc); - crash_report += fmt::format(" PSTATE: {:016x}\n", info.pstate); - crash_report += fmt::format(" AFSR0: {:016x}\n", info.afsr0); - crash_report += fmt::format(" AFSR1: {:016x}\n", info.afsr1); - crash_report += fmt::format(" ESR: {:016x}\n", info.esr); - crash_report += fmt::format(" FAR: {:016x}\n", info.far); + crash_report += std::format(" SP: {:016x}\n", info.sp); + crash_report += std::format(" PC: {:016x}\n", info.pc); + crash_report += std::format(" PSTATE: {:016x}\n", info.pstate); + crash_report += std::format(" AFSR0: {:016x}\n", info.afsr0); + crash_report += std::format(" AFSR1: {:016x}\n", info.afsr1); + crash_report += std::format(" ESR: {:016x}\n", info.esr); + crash_report += std::format(" FAR: {:016x}\n", info.far); crash_report += "\nBacktrace:\n"; for (u32 i = 0; i < std::min(info.backtrace_size, 32); i++) { crash_report += - fmt::format(" Backtrace[{:02d}]: {:016x}\n", i, info.backtrace[i]); + std::format(" Backtrace[{:02d}]: {:016x}\n", i, info.backtrace[i]); } - crash_report += fmt::format("Architecture: {}\n", info.ArchAsString()); - crash_report += fmt::format("Unknown 10: {:#016x}\n", info.unk10); + crash_report += std::format("Architecture: {}\n", info.ArchAsString()); + crash_report += std::format("Unknown 10: {:#016x}\n", info.unk10); } LOG_ERROR(Service_Fatal, "{}", crash_report); diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp index 925af7b371..9f0410e23c 100644 --- a/src/core/hle/service/filesystem/filesystem.cpp +++ b/src/core/hle/service/filesystem/filesystem.cpp @@ -118,7 +118,7 @@ Result VfsDirectoryServiceWrapper::CreateDirectory(const std::string& path_) con const auto components = Common::FS::SplitPathComponents(path); std::string relative_path; for (const auto& component : components) { - relative_path = Common::FS::SanitizePath(fmt::format("{}/{}", relative_path, component)); + relative_path = Common::FS::SanitizePath(std::format("{}/{}", relative_path, component)); auto new_dir = backing->CreateSubdirectory(relative_path); if (new_dir == nullptr) { // TODO(DarkLordZach): Find a better error code for this diff --git a/src/core/hle/service/glue/time/time_zone_binary.cpp b/src/core/hle/service/glue/time/time_zone_binary.cpp index eadad551e5..09610419b3 100644 --- a/src/core/hle/service/glue/time/time_zone_binary.cpp +++ b/src/core/hle/service/glue/time/time_zone_binary.cpp @@ -84,7 +84,7 @@ void TimeZoneBinary::GetListPath(std::string& out_path) { if (time_zone_binary_mount_result != ResultSuccess) { return; } - // out_path = fmt::format("{}:/binaryList.txt", "TimeZoneBinary"); + // out_path = std::format("{}:/binaryList.txt", "TimeZoneBinary"); out_path = "/binaryList.txt"; } @@ -92,7 +92,7 @@ void TimeZoneBinary::GetVersionPath(std::string& out_path) { if (time_zone_binary_mount_result != ResultSuccess) { return; } - // out_path = fmt::format("{}:/version.txt", "TimeZoneBinary"); + // out_path = std::format("{}:/version.txt", "TimeZoneBinary"); out_path = "/version.txt"; } @@ -101,8 +101,8 @@ void TimeZoneBinary::GetTimeZonePath(std::string& out_path, if (time_zone_binary_mount_result != ResultSuccess) { return; } - // out_path = fmt::format("{}:/zoneinfo/{}", "TimeZoneBinary", name); - out_path = fmt::format("/zoneinfo/{}", name.data()); + // out_path = std::format("{}:/zoneinfo/{}", "TimeZoneBinary", name); + out_path = std::format("/zoneinfo/{}", name.data()); } bool TimeZoneBinary::IsValid(const Service::PSC::Time::LocationName& name) { diff --git a/src/core/hle/service/ldn/ldn_types.h b/src/core/hle/service/ldn/ldn_types.h index 4107d579ab..61f63a667d 100644 --- a/src/core/hle/service/ldn/ldn_types.h +++ b/src/core/hle/service/ldn/ldn_types.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include #include "common/common_funcs.h" #include "common/common_types.h" @@ -267,7 +267,7 @@ struct NetworkInfo { LdnNetworkInfo ldn; }; static_assert(sizeof(NetworkInfo) == 0x480, "NetworkInfo is an invalid size"); -static_assert(std::is_trivial_v, "NetworkInfo type must be trivially copyable."); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v, "NetworkInfo type must be trivially copyable."); struct SecurityConfig { SecurityMode security_mode; diff --git a/src/core/hle/service/lm/lm.cpp b/src/core/hle/service/lm/lm.cpp index d631a6dd80..c9982a319f 100644 --- a/src/core/hle/service/lm/lm.cpp +++ b/src/core/hle/service/lm/lm.cpp @@ -262,25 +262,25 @@ private: std::string output_log{}; if (process_name) { - output_log += fmt::format("Process: {}\n", *process_name); + output_log += std::format("Process: {}\n", *process_name); } if (module_name) { - output_log += fmt::format("Module: {}\n", *module_name); + output_log += std::format("Module: {}\n", *module_name); } if (file_name) { - output_log += fmt::format("File: {}\n", *file_name); + output_log += std::format("File: {}\n", *file_name); } if (function_name) { - output_log += fmt::format("Function: {}\n", *function_name); + output_log += std::format("Function: {}\n", *function_name); } if (line_number && *line_number != 0) { - output_log += fmt::format("Line: {}\n", *line_number); + output_log += std::format("Line: {}\n", *line_number); } - output_log += fmt::format("ProcessID: {:X}\n", entry.pid); - output_log += fmt::format("ThreadID: {:X}\n", entry.tid); + output_log += std::format("ProcessID: {:X}\n", entry.pid); + output_log += std::format("ThreadID: {:X}\n", entry.tid); if (text_log) { - output_log += fmt::format("Log Text: {}\n", *text_log); + output_log += std::format("Log Text: {}\n", *text_log); } LOG_DEBUG(Service_LM, "LogManager {} ({}):\n{}", NameOf(entry.severity), DestinationToString(destination), output_log); diff --git a/src/core/hle/service/nfc/common/device.cpp b/src/core/hle/service/nfc/common/device.cpp index 2876c6f739..084c597274 100644 --- a/src/core/hle/service/nfc/common/device.cpp +++ b/src/core/hle/service/nfc/common/device.cpp @@ -17,7 +17,7 @@ #pragma warning(pop) #endif -#include +#include #include "common/fs/file.h" #include "common/fs/fs.h" @@ -1265,9 +1265,14 @@ Result NfcDevice::HasBackup(const UniqueSerialNumber& uid, std::size_t uuid_size ASSERT_MSG(uuid_size < sizeof(UniqueSerialNumber), "Invalid UUID size"); constexpr auto backup_dir = "backup"; const auto yuzu_amiibo_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::AmiiboDir); - const auto file_name = - fmt::format("{0:02x}.bin", fmt::join(uid.begin(), uid.begin() + uuid_size, "")); + std::string hex_uid; + hex_uid.reserve(uuid_size * 2); + for (std::size_t i = 0; i < uuid_size; ++i) { + std::format_to(std::back_inserter(hex_uid), "{:02x}", uid[i]); + } + + const auto file_name = std::format("{}.bin", hex_uid); if (!Common::FS::Exists(yuzu_amiibo_dir / backup_dir / file_name)) { return ResultUnableToAccessBackupFile; } @@ -1286,8 +1291,14 @@ Result NfcDevice::ReadBackupData(const UniqueSerialNumber& uid, std::size_t uuid ASSERT_MSG(uuid_size < sizeof(UniqueSerialNumber), "Invalid UUID size"); constexpr auto backup_dir = "backup"; const auto yuzu_amiibo_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::AmiiboDir); - const auto file_name = - fmt::format("{0:02x}.bin", fmt::join(uid.begin(), uid.begin() + uuid_size, "")); + + std::string hex_uid; + hex_uid.reserve(uuid_size * 2); + for (std::size_t i = 0; i < uuid_size; ++i) { + std::format_to(std::back_inserter(hex_uid), "{:02x}", uid[i]); + } + + const auto file_name = std::format("{}.bin", hex_uid); const Common::FS::IOFile keys_file{yuzu_amiibo_dir / backup_dir / file_name, Common::FS::FileAccessMode::Read, @@ -1317,8 +1328,14 @@ Result NfcDevice::WriteBackupData(const UniqueSerialNumber& uid, std::size_t uui ASSERT_MSG(uuid_size < sizeof(UniqueSerialNumber), "Invalid UUID size"); constexpr auto backup_dir = "backup"; const auto yuzu_amiibo_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::AmiiboDir); - const auto file_name = - fmt::format("{0:02x}.bin", fmt::join(uid.begin(), uid.begin() + uuid_size, "")); + + std::string hex_uid; + hex_uid.reserve(uuid_size * 2); + for (std::size_t i = 0; i < uuid_size; ++i) { + std::format_to(std::back_inserter(hex_uid), "{:02x}", uid[i]); + } + + const auto file_name = std::format("{}.bin", hex_uid); if (HasBackup(uid, uuid_size).IsError()) { if (!Common::FS::CreateDir(yuzu_amiibo_dir / backup_dir)) { diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp index 6ef32b890f..a3305cbe29 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include "common/assert.h" #include "common/logging.h" #include "common/scope_exit.h" @@ -332,7 +332,7 @@ void nvhost_ctrl::CreateNvEvent(u32 event_id) { ASSERT(!event.kevent); ASSERT(!event.registered); ASSERT(!event.IsBeingUsed()); - event.kevent = events_interface.CreateEvent(fmt::format("NVCTRL::NvEvent_{}", event_id)); + event.kevent = events_interface.CreateEvent(std::format("NVCTRL::NvEvent_{}", event_id)); event.status = EventState::Available; event.registered = true; const u64 mask = 1ULL << event_id; diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp index b252a2efa5..a934fdc87c 100644 --- a/src/core/hle/service/nvdrv/nvdrv.cpp +++ b/src/core/hle/service/nvdrv/nvdrv.cpp @@ -7,7 +7,7 @@ #include -#include +#include #include "core/core.h" #include "core/hle/kernel/k_event.h" #include "core/hle/service/ipc_helpers.h" diff --git a/src/core/hle/service/psc/ovln/sender.cpp b/src/core/hle/service/psc/ovln/sender.cpp index dffcd4bc36..2348117792 100644 --- a/src/core/hle/service/psc/ovln/sender.cpp +++ b/src/core/hle/service/psc/ovln/sender.cpp @@ -25,7 +25,7 @@ ISender::~ISender() = default; Result ISender::Send(const OverlayNotification& notification, MessageFlags flags) { std::string data; for (const auto m : notification) { - data += fmt::format("{:016X} ", m); + data += std::format("{:016X} ", m); } LOG_WARNING(Service_PSC, "(STUBBED) called, flags={} notification={}", flags.raw, data); diff --git a/src/core/hle/service/psc/time/common.h b/src/core/hle/service/psc/time/common.h index 2183fa72b8..116f4a69a8 100644 --- a/src/core/hle/service/psc/time/common.h +++ b/src/core/hle/service/psc/time/common.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include "common/common_types.h" #include "common/intrusive_list.h" @@ -42,7 +42,7 @@ struct SteadyClockTimePoint { ClockSourceId clock_source_id; }; static_assert(sizeof(SteadyClockTimePoint) == 0x18, "SteadyClockTimePoint has the wrong size!"); -static_assert(std::is_trivial_v); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); struct SystemClockContext { bool operator==(const SystemClockContext& other) const = default; @@ -51,7 +51,7 @@ struct SystemClockContext { SteadyClockTimePoint steady_time_point; }; static_assert(sizeof(SystemClockContext) == 0x20, "SystemClockContext has the wrong size!"); -static_assert(std::is_trivial_v); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); struct CalendarTime { s16 year; @@ -94,7 +94,7 @@ struct ClockSnapshot { u16 unk_CE; }; static_assert(sizeof(ClockSnapshot) == 0xD0, "ClockSnapshot has the wrong size!"); -static_assert(std::is_trivial_v); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); struct ContinuousAdjustmentTimePoint { s64 rtc_offset; @@ -106,7 +106,7 @@ struct ContinuousAdjustmentTimePoint { }; static_assert(sizeof(ContinuousAdjustmentTimePoint) == 0x38, "ContinuousAdjustmentTimePoint has the wrong size!"); -static_assert(std::is_trivial_v); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); struct AlarmInfo { s64 alert_time; @@ -169,7 +169,7 @@ constexpr inline Result GetSpanBetweenTimePoints(s64* out_seconds, const SteadyC } // namespace Service::PSC::Time template <> -struct fmt::formatter : fmt::formatter { +struct std::formatter : std::formatter { template auto format(Service::PSC::Time::TimeType type, FormatContext& ctx) const { const string_view name = [type] { @@ -189,66 +189,66 @@ struct fmt::formatter : fmt::formatter -struct fmt::formatter : fmt::formatter { +struct std::formatter : std::formatter { template auto format(const Service::PSC::Time::SteadyClockTimePoint& time_point, FormatContext& ctx) const { - return fmt::format_to(ctx.out(), "[time_point={}]", time_point.time_point); + return std::format_to(ctx.out(), "[time_point={}]", time_point.time_point); } }; template <> -struct fmt::formatter : fmt::formatter { +struct std::formatter : std::formatter { template auto format(const Service::PSC::Time::SystemClockContext& context, FormatContext& ctx) const { - return fmt::format_to(ctx.out(), "[offset={} steady_time_point={}]", context.offset, + return std::format_to(ctx.out(), "[offset={} steady_time_point={}]", context.offset, context.steady_time_point.time_point); } }; template <> -struct fmt::formatter : fmt::formatter { +struct std::formatter : std::formatter { template auto format(const Service::PSC::Time::CalendarTime& calendar, FormatContext& ctx) const { - return fmt::format_to(ctx.out(), "[{:02}/{:02}/{:04} {:02}:{:02}:{:02}]", u8(calendar.day), + return std::format_to(ctx.out(), "[{:02}/{:02}/{:04} {:02}:{:02}:{:02}]", u8(calendar.day), u8(calendar.month), u16(calendar.year), u8(calendar.hour), u8(calendar.minute), u8(calendar.second)); } }; template <> -struct fmt::formatter - : fmt::formatter { +struct std::formatter + : std::formatter { template auto format(const Service::PSC::Time::CalendarAdditionalInfo& additional, FormatContext& ctx) const { - return fmt::format_to(ctx.out(), "[weekday={} yearday={} name={} is_dst={} ut_offset={}]", + return std::format_to(ctx.out(), "[weekday={} yearday={} name={} is_dst={} ut_offset={}]", additional.day_of_week, additional.day_of_year, additional.name.data(), additional.is_dst, additional.ut_offset); } }; template <> -struct fmt::formatter : fmt::formatter { +struct std::formatter : std::formatter { template auto format(const Service::PSC::Time::LocationName& name, FormatContext& ctx) const { - return fmt::formatter::format(name.data(), ctx); + return std::formatter::format(name.data(), ctx); } }; template <> -struct fmt::formatter : fmt::formatter { +struct std::formatter : std::formatter { template auto format(const Service::PSC::Time::RuleVersion& version, FormatContext& ctx) const { - return fmt::formatter::format(version.data(), ctx); + return std::formatter::format(version.data(), ctx); } }; template <> -struct fmt::formatter : fmt::formatter { +struct std::formatter : std::formatter { template auto format(const Service::PSC::Time::ClockSnapshot& snapshot, FormatContext& ctx) const { - return fmt::format_to( + return std::format_to( ctx.out(), "[user_context={} network_context={} user_time={} network_time={} " "user_calendar_time={} " @@ -264,12 +264,12 @@ struct fmt::formatter : fmt::formatter -struct fmt::formatter - : fmt::formatter { +struct std::formatter + : std::formatter { template auto format(const Service::PSC::Time::ContinuousAdjustmentTimePoint& time_point, FormatContext& ctx) const { - return fmt::format_to(ctx.out(), + return std::format_to(ctx.out(), "[rtc_offset={} diff_scale={} shift_amount={} lower={} upper={}]", time_point.rtc_offset, time_point.diff_scale, time_point.shift_amount, time_point.lower, time_point.upper); diff --git a/src/core/hle/service/psc/time/shared_memory.h b/src/core/hle/service/psc/time/shared_memory.h index 58363bd698..3ad12a82de 100644 --- a/src/core/hle/service/psc/time/shared_memory.h +++ b/src/core/hle/service/psc/time/shared_memory.h @@ -47,7 +47,7 @@ static_assert(offsetof(SharedMemoryStruct, continuous_adjustment_time_points) == "continuous_adjustment_time_points are in the wrong place!"); static_assert(sizeof(SharedMemoryStruct) == 0x1000, "Time's SharedMemoryStruct has the wrong size!"); -static_assert(std::is_trivial_v); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v); class SharedMemory { public: diff --git a/src/core/hle/service/server_manager.cpp b/src/core/hle/service/server_manager.cpp index 4b3db04c76..f1dd7926a4 100644 --- a/src/core/hle/service/server_manager.cpp +++ b/src/core/hle/service/server_manager.cpp @@ -247,7 +247,7 @@ Result ServerManager::ManageDeferral(Kernel::KEvent** out_event) { void ServerManager::StartAdditionalHostThreads(const char* name, size_t num_threads) { for (size_t i = 0; i < num_threads; i++) { - auto thread_name = fmt::format("{}:{}", name, i + 1); + auto thread_name = std::format("{}:{}", name, i + 1); m_threads.emplace_back(m_system.Kernel().RunOnHostCoreThread( std::move(thread_name), [&] { this->LoopProcessImpl(); })); } diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index b4fe2b3ed5..3014780fbb 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -4,7 +4,7 @@ // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include +#include #include "common/assert.h" #include "common/logging.h" #include "common/settings.h" @@ -23,9 +23,9 @@ namespace Service { [[maybe_unused]] static std::string MakeFunctionString(std::string_view name, std::string_view port_name, const u32* cmd_buf) { // Number of params == bits 0-5 + bits 6-11 int num_params = (cmd_buf[0] & 0x3F) + ((cmd_buf[0] >> 6) & 0x3F); - std::string function_string = fmt::format("fn '{}': port={}", name, port_name); + std::string function_string = std::format("fn '{}': port={}", name, port_name); for (int i = 1; i <= num_params; ++i) - function_string += fmt::format(", cmd_buf[{}]={:#x}", i, cmd_buf[i]); + function_string += std::format(", cmd_buf[{}]={:#x}", i, cmd_buf[i]); return function_string; } @@ -61,14 +61,16 @@ void ServiceFrameworkBase::ReportUnimplementedFunction(HLERequestContext& ctx, auto cmd_buf = ctx.CommandBuffer(); std::string function_name = info == nullptr ? "" : info->name; - fmt::memory_buffer buf; - fmt::format_to(std::back_inserter(buf), "function '{}({})': port='{}' cmd_buf={{[0]={:#x}", ctx.GetCommand(), function_name, service_name, cmd_buf[0]); + std::string buf; + buf.reserve(256); + + std::format_to(std::back_inserter(buf), "function '{}({})': port='{}' cmd_buf={{[0]={:#x}", ctx.GetCommand(), function_name, service_name, cmd_buf[0]); for (int i = 1; i <= 8; ++i) - fmt::format_to(std::back_inserter(buf), ", [{}]={:#x}", i, cmd_buf[i]); + std::format_to(std::back_inserter(buf), ", [{}]={:#x}", i, cmd_buf[i]); buf.push_back('}'); system.GetReporter().SaveUnimplementedFunctionReport(ctx, ctx.GetCommand(), function_name, service_name); - UNIMPLEMENTED_MSG("Unknown / unimplemented {}", fmt::to_string(buf)); + UNIMPLEMENTED_MSG("Unknown / unimplemented {}", buf); if (Settings::values.use_auto_stub) { LOG_WARNING(Service, "Using auto stub fallback!"); IPC::ResponseBuilder rb{ctx, 2}; diff --git a/src/core/hle/service/set/settings_types.h b/src/core/hle/service/set/settings_types.h index acb54856e0..36a307d7b2 100644 --- a/src/core/hle/service/set/settings_types.h +++ b/src/core/hle/service/set/settings_types.h @@ -447,7 +447,7 @@ struct FirmwareVersionFormat { std::array display_title; }; static_assert(sizeof(FirmwareVersionFormat) == 0x100, "FirmwareVersionFormat is an invalid size"); -static_assert(std::is_trivial_v, +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v, "FirmwareVersionFormat type must be trivially copyable."); /// This is nn::settings::system::HomeMenuScheme diff --git a/src/core/hle/service/sockets/bsd.cpp b/src/core/hle/service/sockets/bsd.cpp index 0137a3be66..e8ab837f62 100644 --- a/src/core/hle/service/sockets/bsd.cpp +++ b/src/core/hle/service/sockets/bsd.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include "common/logging.h" #include "common/socket_types.h" diff --git a/src/core/launch_params.cpp b/src/core/launch_params.cpp index a0483226ec..8b611fa27d 100644 --- a/src/core/launch_params.cpp +++ b/src/core/launch_params.cpp @@ -181,7 +181,8 @@ void ApplyLaunchParams(LaunchParams const& lp) noexcept { } if (lp.print_version) { - LOG_INFO(Frontend, "Eden {} {}", Common::g_scm_branch, Common::g_scm_desc); + LOG_INFO(Frontend, "Eden {} {}", std::string_view{Common::g_scm_branch}, + std::string_view{Common::g_scm_desc}); } if (lp.print_help) { LOG_INFO(Frontend, diff --git a/src/core/memory/dmnt_cheat_vm.cpp b/src/core/memory/dmnt_cheat_vm.cpp index df6fe4b77f..e8c64f7b4d 100644 --- a/src/core/memory/dmnt_cheat_vm.cpp +++ b/src/core/memory/dmnt_cheat_vm.cpp @@ -23,155 +23,155 @@ void DmntCheatVm::DebugLog(u32 log_id, u64 value) { void DmntCheatVm::LogOpcode(const CheatVmOpcode& opcode) { if (auto store_static = std::get_if(&opcode.opcode)) { callbacks->CommandLog("Opcode: Store Static"); - callbacks->CommandLog(fmt::format("Bit Width: {:X}", store_static->bit_width)); + callbacks->CommandLog(std::format("Bit Width: {:X}", store_static->bit_width)); callbacks->CommandLog( - fmt::format("Mem Type: {:X}", static_cast(store_static->mem_type))); - callbacks->CommandLog(fmt::format("Reg Idx: {:X}", store_static->offset_register)); - callbacks->CommandLog(fmt::format("Rel Addr: {:X}", store_static->rel_address)); - callbacks->CommandLog(fmt::format("Value: {:X}", store_static->value.bit64)); + std::format("Mem Type: {:X}", static_cast(store_static->mem_type))); + callbacks->CommandLog(std::format("Reg Idx: {:X}", store_static->offset_register)); + callbacks->CommandLog(std::format("Rel Addr: {:X}", store_static->rel_address)); + callbacks->CommandLog(std::format("Value: {:X}", store_static->value.bit64)); } else if (auto begin_cond = std::get_if(&opcode.opcode)) { callbacks->CommandLog("Opcode: Begin Conditional"); - callbacks->CommandLog(fmt::format("Bit Width: {:X}", begin_cond->bit_width)); + callbacks->CommandLog(std::format("Bit Width: {:X}", begin_cond->bit_width)); callbacks->CommandLog( - fmt::format("Mem Type: {:X}", static_cast(begin_cond->mem_type))); + std::format("Mem Type: {:X}", static_cast(begin_cond->mem_type))); callbacks->CommandLog( - fmt::format("Cond Type: {:X}", static_cast(begin_cond->cond_type))); - callbacks->CommandLog(fmt::format("Rel Addr: {:X}", begin_cond->rel_address)); - callbacks->CommandLog(fmt::format("Value: {:X}", begin_cond->value.bit64)); + std::format("Cond Type: {:X}", static_cast(begin_cond->cond_type))); + callbacks->CommandLog(std::format("Rel Addr: {:X}", begin_cond->rel_address)); + callbacks->CommandLog(std::format("Value: {:X}", begin_cond->value.bit64)); } else if (std::holds_alternative(opcode.opcode)) { callbacks->CommandLog("Opcode: End Conditional"); } else if (auto ctrl_loop = std::get_if(&opcode.opcode)) { if (ctrl_loop->start_loop) { callbacks->CommandLog("Opcode: Start Loop"); - callbacks->CommandLog(fmt::format("Reg Idx: {:X}", ctrl_loop->reg_index)); - callbacks->CommandLog(fmt::format("Num Iters: {:X}", ctrl_loop->num_iters)); + callbacks->CommandLog(std::format("Reg Idx: {:X}", ctrl_loop->reg_index)); + callbacks->CommandLog(std::format("Num Iters: {:X}", ctrl_loop->num_iters)); } else { callbacks->CommandLog("Opcode: End Loop"); - callbacks->CommandLog(fmt::format("Reg Idx: {:X}", ctrl_loop->reg_index)); + callbacks->CommandLog(std::format("Reg Idx: {:X}", ctrl_loop->reg_index)); } } else if (auto ldr_static = std::get_if(&opcode.opcode)) { callbacks->CommandLog("Opcode: Load Register Static"); - callbacks->CommandLog(fmt::format("Reg Idx: {:X}", ldr_static->reg_index)); - callbacks->CommandLog(fmt::format("Value: {:X}", ldr_static->value)); + callbacks->CommandLog(std::format("Reg Idx: {:X}", ldr_static->reg_index)); + callbacks->CommandLog(std::format("Value: {:X}", ldr_static->value)); } else if (auto ldr_memory = std::get_if(&opcode.opcode)) { callbacks->CommandLog("Opcode: Load Register Memory"); - callbacks->CommandLog(fmt::format("Bit Width: {:X}", ldr_memory->bit_width)); - callbacks->CommandLog(fmt::format("Reg Idx: {:X}", ldr_memory->reg_index)); + callbacks->CommandLog(std::format("Bit Width: {:X}", ldr_memory->bit_width)); + callbacks->CommandLog(std::format("Reg Idx: {:X}", ldr_memory->reg_index)); callbacks->CommandLog( - fmt::format("Mem Type: {:X}", static_cast(ldr_memory->mem_type))); - callbacks->CommandLog(fmt::format("From Reg: {:d}", ldr_memory->load_from_reg)); - callbacks->CommandLog(fmt::format("Rel Addr: {:X}", ldr_memory->rel_address)); + std::format("Mem Type: {:X}", static_cast(ldr_memory->mem_type))); + callbacks->CommandLog(std::format("From Reg: {:d}", ldr_memory->load_from_reg)); + callbacks->CommandLog(std::format("Rel Addr: {:X}", ldr_memory->rel_address)); } else if (auto str_static = std::get_if(&opcode.opcode)) { callbacks->CommandLog("Opcode: Store Static to Address"); - callbacks->CommandLog(fmt::format("Bit Width: {:X}", str_static->bit_width)); - callbacks->CommandLog(fmt::format("Reg Idx: {:X}", str_static->reg_index)); + callbacks->CommandLog(std::format("Bit Width: {:X}", str_static->bit_width)); + callbacks->CommandLog(std::format("Reg Idx: {:X}", str_static->reg_index)); if (str_static->add_offset_reg) { - callbacks->CommandLog(fmt::format("O Reg Idx: {:X}", str_static->offset_reg_index)); + callbacks->CommandLog(std::format("O Reg Idx: {:X}", str_static->offset_reg_index)); } - callbacks->CommandLog(fmt::format("Incr Reg: {:d}", str_static->increment_reg)); - callbacks->CommandLog(fmt::format("Value: {:X}", str_static->value)); + callbacks->CommandLog(std::format("Incr Reg: {:d}", str_static->increment_reg)); + callbacks->CommandLog(std::format("Value: {:X}", str_static->value)); } else if (auto perform_math_static = std::get_if(&opcode.opcode)) { callbacks->CommandLog("Opcode: Perform Static Arithmetic"); - callbacks->CommandLog(fmt::format("Bit Width: {:X}", perform_math_static->bit_width)); - callbacks->CommandLog(fmt::format("Reg Idx: {:X}", perform_math_static->reg_index)); + callbacks->CommandLog(std::format("Bit Width: {:X}", perform_math_static->bit_width)); + callbacks->CommandLog(std::format("Reg Idx: {:X}", perform_math_static->reg_index)); callbacks->CommandLog( - fmt::format("Math Type: {:X}", static_cast(perform_math_static->math_type))); - callbacks->CommandLog(fmt::format("Value: {:X}", perform_math_static->value)); + std::format("Math Type: {:X}", static_cast(perform_math_static->math_type))); + callbacks->CommandLog(std::format("Value: {:X}", perform_math_static->value)); } else if (auto begin_keypress_cond = std::get_if(&opcode.opcode)) { callbacks->CommandLog("Opcode: Begin Keypress Conditional"); - callbacks->CommandLog(fmt::format("Key Mask: {:X}", begin_keypress_cond->key_mask)); + callbacks->CommandLog(std::format("Key Mask: {:X}", begin_keypress_cond->key_mask)); } else if (auto perform_math_reg = std::get_if(&opcode.opcode)) { callbacks->CommandLog("Opcode: Perform Register Arithmetic"); - callbacks->CommandLog(fmt::format("Bit Width: {:X}", perform_math_reg->bit_width)); - callbacks->CommandLog(fmt::format("Dst Idx: {:X}", perform_math_reg->dst_reg_index)); - callbacks->CommandLog(fmt::format("Src1 Idx: {:X}", perform_math_reg->src_reg_1_index)); + callbacks->CommandLog(std::format("Bit Width: {:X}", perform_math_reg->bit_width)); + callbacks->CommandLog(std::format("Dst Idx: {:X}", perform_math_reg->dst_reg_index)); + callbacks->CommandLog(std::format("Src1 Idx: {:X}", perform_math_reg->src_reg_1_index)); if (perform_math_reg->has_immediate) { - callbacks->CommandLog(fmt::format("Value: {:X}", perform_math_reg->value.bit64)); + callbacks->CommandLog(std::format("Value: {:X}", perform_math_reg->value.bit64)); } else { callbacks->CommandLog( - fmt::format("Src2 Idx: {:X}", perform_math_reg->src_reg_2_index)); + std::format("Src2 Idx: {:X}", perform_math_reg->src_reg_2_index)); } } else if (auto str_register = std::get_if(&opcode.opcode)) { callbacks->CommandLog("Opcode: Store Register to Address"); - callbacks->CommandLog(fmt::format("Bit Width: {:X}", str_register->bit_width)); - callbacks->CommandLog(fmt::format("S Reg Idx: {:X}", str_register->str_reg_index)); - callbacks->CommandLog(fmt::format("A Reg Idx: {:X}", str_register->addr_reg_index)); - callbacks->CommandLog(fmt::format("Incr Reg: {:d}", str_register->increment_reg)); + callbacks->CommandLog(std::format("Bit Width: {:X}", str_register->bit_width)); + callbacks->CommandLog(std::format("S Reg Idx: {:X}", str_register->str_reg_index)); + callbacks->CommandLog(std::format("A Reg Idx: {:X}", str_register->addr_reg_index)); + callbacks->CommandLog(std::format("Incr Reg: {:d}", str_register->increment_reg)); switch (str_register->ofs_type) { case StoreRegisterOffsetType::None: break; case StoreRegisterOffsetType::Reg: - callbacks->CommandLog(fmt::format("O Reg Idx: {:X}", str_register->ofs_reg_index)); + callbacks->CommandLog(std::format("O Reg Idx: {:X}", str_register->ofs_reg_index)); break; case StoreRegisterOffsetType::Imm: - callbacks->CommandLog(fmt::format("Rel Addr: {:X}", str_register->rel_address)); + callbacks->CommandLog(std::format("Rel Addr: {:X}", str_register->rel_address)); break; case StoreRegisterOffsetType::MemReg: callbacks->CommandLog( - fmt::format("Mem Type: {:X}", static_cast(str_register->mem_type))); + std::format("Mem Type: {:X}", static_cast(str_register->mem_type))); break; case StoreRegisterOffsetType::MemImm: case StoreRegisterOffsetType::MemImmReg: callbacks->CommandLog( - fmt::format("Mem Type: {:X}", static_cast(str_register->mem_type))); - callbacks->CommandLog(fmt::format("Rel Addr: {:X}", str_register->rel_address)); + std::format("Mem Type: {:X}", static_cast(str_register->mem_type))); + callbacks->CommandLog(std::format("Rel Addr: {:X}", str_register->rel_address)); break; } } else if (auto begin_reg_cond = std::get_if(&opcode.opcode)) { callbacks->CommandLog("Opcode: Begin Register Conditional"); - callbacks->CommandLog(fmt::format("Bit Width: {:X}", begin_reg_cond->bit_width)); + callbacks->CommandLog(std::format("Bit Width: {:X}", begin_reg_cond->bit_width)); callbacks->CommandLog( - fmt::format("Cond Type: {:X}", static_cast(begin_reg_cond->cond_type))); - callbacks->CommandLog(fmt::format("V Reg Idx: {:X}", begin_reg_cond->val_reg_index)); + std::format("Cond Type: {:X}", static_cast(begin_reg_cond->cond_type))); + callbacks->CommandLog(std::format("V Reg Idx: {:X}", begin_reg_cond->val_reg_index)); switch (begin_reg_cond->comp_type) { case CompareRegisterValueType::StaticValue: callbacks->CommandLog("Comp Type: Static Value"); - callbacks->CommandLog(fmt::format("Value: {:X}", begin_reg_cond->value.bit64)); + callbacks->CommandLog(std::format("Value: {:X}", begin_reg_cond->value.bit64)); break; case CompareRegisterValueType::OtherRegister: callbacks->CommandLog("Comp Type: Other Register"); - callbacks->CommandLog(fmt::format("X Reg Idx: {:X}", begin_reg_cond->other_reg_index)); + callbacks->CommandLog(std::format("X Reg Idx: {:X}", begin_reg_cond->other_reg_index)); break; case CompareRegisterValueType::MemoryRelAddr: callbacks->CommandLog("Comp Type: Memory Relative Address"); callbacks->CommandLog( - fmt::format("Mem Type: {:X}", static_cast(begin_reg_cond->mem_type))); - callbacks->CommandLog(fmt::format("Rel Addr: {:X}", begin_reg_cond->rel_address)); + std::format("Mem Type: {:X}", static_cast(begin_reg_cond->mem_type))); + callbacks->CommandLog(std::format("Rel Addr: {:X}", begin_reg_cond->rel_address)); break; case CompareRegisterValueType::MemoryOfsReg: callbacks->CommandLog("Comp Type: Memory Offset Register"); callbacks->CommandLog( - fmt::format("Mem Type: {:X}", static_cast(begin_reg_cond->mem_type))); - callbacks->CommandLog(fmt::format("O Reg Idx: {:X}", begin_reg_cond->ofs_reg_index)); + std::format("Mem Type: {:X}", static_cast(begin_reg_cond->mem_type))); + callbacks->CommandLog(std::format("O Reg Idx: {:X}", begin_reg_cond->ofs_reg_index)); break; case CompareRegisterValueType::RegisterRelAddr: callbacks->CommandLog("Comp Type: Register Relative Address"); - callbacks->CommandLog(fmt::format("A Reg Idx: {:X}", begin_reg_cond->addr_reg_index)); - callbacks->CommandLog(fmt::format("Rel Addr: {:X}", begin_reg_cond->rel_address)); + callbacks->CommandLog(std::format("A Reg Idx: {:X}", begin_reg_cond->addr_reg_index)); + callbacks->CommandLog(std::format("Rel Addr: {:X}", begin_reg_cond->rel_address)); break; case CompareRegisterValueType::RegisterOfsReg: callbacks->CommandLog("Comp Type: Register Offset Register"); - callbacks->CommandLog(fmt::format("A Reg Idx: {:X}", begin_reg_cond->addr_reg_index)); - callbacks->CommandLog(fmt::format("O Reg Idx: {:X}", begin_reg_cond->ofs_reg_index)); + callbacks->CommandLog(std::format("A Reg Idx: {:X}", begin_reg_cond->addr_reg_index)); + callbacks->CommandLog(std::format("O Reg Idx: {:X}", begin_reg_cond->ofs_reg_index)); break; } } else if (auto save_restore_reg = std::get_if(&opcode.opcode)) { callbacks->CommandLog("Opcode: Save or Restore Register"); - callbacks->CommandLog(fmt::format("Dst Idx: {:X}", save_restore_reg->dst_index)); - callbacks->CommandLog(fmt::format("Src Idx: {:X}", save_restore_reg->src_index)); + callbacks->CommandLog(std::format("Dst Idx: {:X}", save_restore_reg->dst_index)); + callbacks->CommandLog(std::format("Src Idx: {:X}", save_restore_reg->src_index)); callbacks->CommandLog( - fmt::format("Op Type: {:d}", static_cast(save_restore_reg->op_type))); + std::format("Op Type: {:d}", static_cast(save_restore_reg->op_type))); } else if (auto save_restore_regmask = std::get_if(&opcode.opcode)) { callbacks->CommandLog("Opcode: Save or Restore Register Mask"); callbacks->CommandLog( - fmt::format("Op Type: {:d}", static_cast(save_restore_regmask->op_type))); + std::format("Op Type: {:d}", static_cast(save_restore_regmask->op_type))); for (std::size_t i = 0; i < NumRegisters; i++) { callbacks->CommandLog( - fmt::format("Act[{:02X}]: {:d}", i, save_restore_regmask->should_operate[i])); + std::format("Act[{:02X}]: {:d}", i, save_restore_regmask->should_operate[i])); } } else if (auto rw_static_reg = std::get_if(&opcode.opcode)) { callbacks->CommandLog("Opcode: Read/Write Static Register"); @@ -180,44 +180,44 @@ void DmntCheatVm::LogOpcode(const CheatVmOpcode& opcode) { } else { callbacks->CommandLog("Op Type: WriteStaticRegister"); } - callbacks->CommandLog(fmt::format("Reg Idx {:X}", rw_static_reg->idx)); - callbacks->CommandLog(fmt::format("Stc Idx {:X}", rw_static_reg->static_idx)); + callbacks->CommandLog(std::format("Reg Idx {:X}", rw_static_reg->idx)); + callbacks->CommandLog(std::format("Stc Idx {:X}", rw_static_reg->static_idx)); } else if (auto debug_log = std::get_if(&opcode.opcode)) { callbacks->CommandLog("Opcode: Debug Log"); - callbacks->CommandLog(fmt::format("Bit Width: {:X}", debug_log->bit_width)); - callbacks->CommandLog(fmt::format("Log ID: {:X}", debug_log->log_id)); + callbacks->CommandLog(std::format("Bit Width: {:X}", debug_log->bit_width)); + callbacks->CommandLog(std::format("Log ID: {:X}", debug_log->log_id)); callbacks->CommandLog( - fmt::format("Val Type: {:X}", static_cast(debug_log->val_type))); + std::format("Val Type: {:X}", static_cast(debug_log->val_type))); switch (debug_log->val_type) { case DebugLogValueType::RegisterValue: callbacks->CommandLog("Val Type: Register Value"); - callbacks->CommandLog(fmt::format("X Reg Idx: {:X}", debug_log->val_reg_index)); + callbacks->CommandLog(std::format("X Reg Idx: {:X}", debug_log->val_reg_index)); break; case DebugLogValueType::MemoryRelAddr: callbacks->CommandLog("Val Type: Memory Relative Address"); callbacks->CommandLog( - fmt::format("Mem Type: {:X}", static_cast(debug_log->mem_type))); - callbacks->CommandLog(fmt::format("Rel Addr: {:X}", debug_log->rel_address)); + std::format("Mem Type: {:X}", static_cast(debug_log->mem_type))); + callbacks->CommandLog(std::format("Rel Addr: {:X}", debug_log->rel_address)); break; case DebugLogValueType::MemoryOfsReg: callbacks->CommandLog("Val Type: Memory Offset Register"); callbacks->CommandLog( - fmt::format("Mem Type: {:X}", static_cast(debug_log->mem_type))); - callbacks->CommandLog(fmt::format("O Reg Idx: {:X}", debug_log->ofs_reg_index)); + std::format("Mem Type: {:X}", static_cast(debug_log->mem_type))); + callbacks->CommandLog(std::format("O Reg Idx: {:X}", debug_log->ofs_reg_index)); break; case DebugLogValueType::RegisterRelAddr: callbacks->CommandLog("Val Type: Register Relative Address"); - callbacks->CommandLog(fmt::format("A Reg Idx: {:X}", debug_log->addr_reg_index)); - callbacks->CommandLog(fmt::format("Rel Addr: {:X}", debug_log->rel_address)); + callbacks->CommandLog(std::format("A Reg Idx: {:X}", debug_log->addr_reg_index)); + callbacks->CommandLog(std::format("Rel Addr: {:X}", debug_log->rel_address)); break; case DebugLogValueType::RegisterOfsReg: callbacks->CommandLog("Val Type: Register Offset Register"); - callbacks->CommandLog(fmt::format("A Reg Idx: {:X}", debug_log->addr_reg_index)); - callbacks->CommandLog(fmt::format("O Reg Idx: {:X}", debug_log->ofs_reg_index)); + callbacks->CommandLog(std::format("A Reg Idx: {:X}", debug_log->addr_reg_index)); + callbacks->CommandLog(std::format("O Reg Idx: {:X}", debug_log->ofs_reg_index)); break; } } else if (auto instr = std::get_if(&opcode.opcode)) { - callbacks->CommandLog(fmt::format("Unknown opcode: {:X}", static_cast(instr->opcode))); + callbacks->CommandLog(std::format("Unknown opcode: {:X}", static_cast(instr->opcode))); } } @@ -741,10 +741,10 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) { const bool command_log_enabled = callbacks->IsCommandLogEnabled(); if (command_log_enabled) { callbacks->CommandLog("Started VM execution."); - callbacks->CommandLog(fmt::format("Main NSO: {:012X}", metadata.main_nso_extents.base)); - callbacks->CommandLog(fmt::format("Heap: {:012X}", metadata.main_nso_extents.base)); + callbacks->CommandLog(std::format("Main NSO: {:012X}", metadata.main_nso_extents.base)); + callbacks->CommandLog(std::format("Heap: {:012X}", metadata.main_nso_extents.base)); callbacks->CommandLog( - fmt::format("Keys Down: {:08X}", static_cast(kDown & 0x0FFFFFFF))); + std::format("Keys Down: {:08X}", static_cast(kDown & 0x0FFFFFFF))); } // Clear VM state. @@ -754,15 +754,15 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) { while (DecodeNextOpcode(cur_opcode)) { if (command_log_enabled) { callbacks->CommandLog( - fmt::format("Instruction Ptr: {:04X}", static_cast(instruction_ptr))); + std::format("Instruction Ptr: {:04X}", static_cast(instruction_ptr))); for (std::size_t i = 0; i < NumRegisters; i++) { - callbacks->CommandLog(fmt::format("Registers[{:02X}]: {:016X}", i, + callbacks->CommandLog(std::format("Registers[{:02X}]: {:016X}", i, registers[i])); } for (std::size_t i = 0; i < NumRegisters; i++) { - callbacks->CommandLog(fmt::format("SavedRegs[{:02X}]: {:016X}", i, + callbacks->CommandLog(std::format("SavedRegs[{:02X}]: {:016X}", i, saved_values[i])); } LogOpcode(cur_opcode); diff --git a/src/core/memory/dmnt_cheat_vm.h b/src/core/memory/dmnt_cheat_vm.h index f7c10f9130..cb269e5908 100644 --- a/src/core/memory/dmnt_cheat_vm.h +++ b/src/core/memory/dmnt_cheat_vm.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include "common/common_types.h" #include "core/memory/dmnt_cheat_types.h" diff --git a/src/core/perf_stats.cpp b/src/core/perf_stats.cpp index 1ca3fe488c..77f14f9cd0 100644 --- a/src/core/perf_stats.cpp +++ b/src/core/perf_stats.cpp @@ -11,8 +11,7 @@ #include #include #include -#include -#include +#include #include "common/fs/file.h" #include "common/fs/fs.h" #include "common/fs/path_util.h" @@ -44,7 +43,7 @@ PerfStats::~PerfStats() { const auto path = Common::FS::GetEdenPath(Common::FS::EdenPath::LogDir); // %F Date format expanded is "%Y-%m-%d" - const auto filename = fmt::format("{}_{:016X}.csv", + const auto filename = std::format("{}_{:016X}.csv", [&] { std::ostringstream oss; oss << std::put_time(std::localtime(&t), "%F-%H-%M"); diff --git a/src/dedicated_room/yuzu_room.cpp b/src/dedicated_room/yuzu_room.cpp index 824fd0f26c..477156cfba 100644 --- a/src/dedicated_room/yuzu_room.cpp +++ b/src/dedicated_room/yuzu_room.cpp @@ -72,8 +72,9 @@ static void PrintHelp(const char* argv0) { } static void PrintVersion() { - LOG_INFO(Network, "Eden dedicated room {} {} Libnetwork: {}", Common::g_scm_branch, - Common::g_scm_desc, Network::network_version); + LOG_INFO(Network, "Eden dedicated room {} {} Libnetwork: {}", + std::string_view{Common::g_scm_branch}, std::string_view{Common::g_scm_desc}, + Network::network_version); } /// The magic text at the beginning of a yuzu-room ban list file. diff --git a/src/dynarmic/CMakeLists.txt b/src/dynarmic/CMakeLists.txt index 2436f9b7e3..537aeb3c90 100644 --- a/src/dynarmic/CMakeLists.txt +++ b/src/dynarmic/CMakeLists.txt @@ -22,7 +22,7 @@ option(DYNARMIC_HOST_FEATURE_OVERRIDE "Let DYNARMIC_HOST_FEATURES= hid CMAKE_DEPENDENT_OPTION(DYNARMIC_USE_LLVM "Support disassembly of jitted x86_64 code using LLVM" OFF "NOT YUZU_DISABLE_LLVM" OFF) # Set hard requirements for C++ -set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD 26) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) @@ -102,7 +102,6 @@ endif() if (NOT Boost_FOUND) find_package(Boost 1.57 REQUIRED) endif() -find_package(fmt 8 CONFIG) if (ARCHITECTURE_arm64) find_package(oaknut 2.0.1 CONFIG) diff --git a/src/dynarmic/src/dynarmic/CMakeLists.txt b/src/dynarmic/src/dynarmic/CMakeLists.txt index 1374aaa21e..72cc05e365 100644 --- a/src/dynarmic/src/dynarmic/CMakeLists.txt +++ b/src/dynarmic/src/dynarmic/CMakeLists.txt @@ -385,7 +385,7 @@ set_target_properties(dynarmic PROPERTIES target_compile_options(dynarmic PRIVATE ${DYNARMIC_CXX_FLAGS}) -target_link_libraries(dynarmic PUBLIC fmt::fmt common) +target_link_libraries(dynarmic PUBLIC common) if (BOOST_NO_HEADERS) target_link_libraries(dynarmic PRIVATE Boost::variant Boost::icl Boost::pool) @@ -404,7 +404,15 @@ endif() if (DYNARMIC_ENABLE_NO_EXECUTE_SUPPORT) target_compile_definitions(dynarmic PRIVATE DYNARMIC_ENABLE_NO_EXECUTE_SUPPORT=1) endif() -if (CMAKE_SYSTEM_NAME STREQUAL "Windows") - target_compile_definitions(dynarmic PRIVATE FMT_USE_WINDOWS_H=0) -endif() -target_compile_definitions(dynarmic PRIVATE FMT_USE_USER_DEFINED_LITERALS=1) + +# need to link to stdc++exp (on glibc++ only) for std::print on mingw +if (MINGW) + include(CheckCXXSymbolExists) + + check_cxx_symbol_exists(__GLIBCXX__ "version" HAS_LIBSTDCXX) + + if(HAS_LIBSTDCXX) + message(STATUS "[dynarmic] MinGW libstdc++ needs stdc++exp") + target_link_libraries(dynarmic PUBLIC stdc++exp) + endif() +endif() \ No newline at end of file diff --git a/src/dynarmic/src/dynarmic/backend/arm64/address_space.cpp b/src/dynarmic/src/dynarmic/backend/arm64/address_space.cpp index 9b2ae66c79..cab0ce4b5b 100644 --- a/src/dynarmic/src/dynarmic/backend/arm64/address_space.cpp +++ b/src/dynarmic/src/dynarmic/backend/arm64/address_space.cpp @@ -9,6 +9,7 @@ #include #include +#include #include "dynarmic/backend/arm64/a64_address_space.h" #include "dynarmic/backend/arm64/a64_jitstate.h" @@ -358,7 +359,7 @@ FakeCall AddressSpace::FastmemCallback(u64 host_pc) { } fail: - fmt::print("dynarmic: Segfault happened within JITted code at host_pc = {:016x}\n" + std::print("dynarmic: Segfault happened within JITted code at host_pc = {:016x}\n" "Segfault wasn't at a fastmem patch location!\n", host_pc); UNREACHABLE(); } diff --git a/src/dynarmic/src/dynarmic/backend/arm64/emit_arm64_data_processing.cpp b/src/dynarmic/src/dynarmic/backend/arm64/emit_arm64_data_processing.cpp index 98faf60716..f20ad71d49 100644 --- a/src/dynarmic/src/dynarmic/backend/arm64/emit_arm64_data_processing.cpp +++ b/src/dynarmic/src/dynarmic/backend/arm64/emit_arm64_data_processing.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include #include "dynarmic/backend/arm64/abi.h" diff --git a/src/dynarmic/src/dynarmic/backend/arm64/verbose_debugging_output.cpp b/src/dynarmic/src/dynarmic/backend/arm64/verbose_debugging_output.cpp index a024a212f7..3a31eaa125 100644 --- a/src/dynarmic/src/dynarmic/backend/arm64/verbose_debugging_output.cpp +++ b/src/dynarmic/src/dynarmic/backend/arm64/verbose_debugging_output.cpp @@ -8,7 +8,7 @@ #include "dynarmic/backend/arm64/verbose_debugging_output.h" -#include +#include #include #include "dynarmic/backend/arm64/emit_context.h" @@ -55,7 +55,7 @@ void EmitVerboseDebuggingOutput(oaknut::CodeGenerator& code, EmitContext& ctx) { } void PrintVerboseDebuggingOutputLine(RegisterData& reg_data, HostLocType reg_type, std::size_t reg_index, std::size_t inst_index, IR::Type inst_type) { - fmt::print("dynarmic debug: %{:05} = ", inst_index); + std::print("dynarmic debug: %{:05} = ", inst_index); Vector value = [&]() -> Vector { switch (reg_type) { @@ -68,27 +68,27 @@ void PrintVerboseDebuggingOutputLine(RegisterData& reg_data, HostLocType reg_typ case HostLocType::Spill: return (*reg_data.spill)[reg_index]; } - fmt::print("invalid reg_type! "); + std::print("invalid reg_type! "); return {0, 0}; }(); switch (inst_type) { case IR::Type::U1: case IR::Type::U8: - fmt::print("{:02x}", value[0] & 0xff); + std::print("{:02x}", value[0] & 0xff); break; case IR::Type::U16: - fmt::print("{:04x}", value[0] & 0xffff); + std::print("{:04x}", value[0] & 0xffff); break; case IR::Type::U32: case IR::Type::NZCVFlags: - fmt::print("{:08x}", value[0] & 0xffffffff); + std::print("{:08x}", value[0] & 0xffffffff); break; case IR::Type::U64: - fmt::print("{:016x}", value[0]); + std::print("{:016x}", value[0]); break; case IR::Type::U128: - fmt::print("{:016x}{:016x}", value[1], value[0]); + std::print("{:016x}{:016x}", value[1], value[0]); break; case IR::Type::A32Reg: case IR::Type::A32ExtReg: @@ -101,11 +101,11 @@ void PrintVerboseDebuggingOutputLine(RegisterData& reg_data, HostLocType reg_typ case IR::Type::AccType: case IR::Type::Opaque: default: - fmt::print("invalid inst_type!"); + std::print("invalid inst_type!"); break; } - fmt::print("\n"); + std::print("\n"); } } // namespace Dynarmic::Backend::Arm64 diff --git a/src/dynarmic/src/dynarmic/backend/exception_handler_macos.cpp b/src/dynarmic/src/dynarmic/backend/exception_handler_macos.cpp index fc627f60b2..e493281f31 100644 --- a/src/dynarmic/src/dynarmic/backend/exception_handler_macos.cpp +++ b/src/dynarmic/src/dynarmic/backend/exception_handler_macos.cpp @@ -18,7 +18,7 @@ #include #include -#include +#include #include "common/assert.h" #include "common/common_types.h" @@ -113,18 +113,18 @@ void MachHandler::MessagePump() { while (true) { mr = mach_msg(&request.head, MACH_RCV_MSG | MACH_RCV_LARGE, 0, sizeof(request), server_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (mr != MACH_MSG_SUCCESS) { - fmt::print(stderr, "dynarmic: macOS MachHandler: Failed to receive mach message. error: {:#08x} ({})\n", mr, mach_error_string(mr)); + std::print(stderr, "dynarmic: macOS MachHandler: Failed to receive mach message. error: {:#08x} ({})\n", mr, mach_error_string(mr)); return; } if (!mach_exc_server(&request.head, &reply.head)) { - fmt::print(stderr, "dynarmic: macOS MachHandler: Unexpected mach message\n"); + std::print(stderr, "dynarmic: macOS MachHandler: Unexpected mach message\n"); return; } mr = mach_msg(&reply.head, MACH_SEND_MSG, reply.head.msgh_size, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (mr != MACH_MSG_SUCCESS) { - fmt::print(stderr, "dynarmic: macOS MachHandler: Failed to send mach message. error: {:#08x} ({})\n", mr, mach_error_string(mr)); + std::print(stderr, "dynarmic: macOS MachHandler: Failed to send mach message. error: {:#08x} ({})\n", mr, mach_error_string(mr)); return; } } @@ -136,7 +136,7 @@ kern_return_t MachHandler::HandleRequest(x86_thread_state64_t* ts) { const auto iter = FindCodeBlockInfo(ts->__rip); if (iter == code_block_infos.end()) { - fmt::print(stderr, "Unhandled EXC_BAD_ACCESS at rip {:#016x}\n", ts->__rip); + std::print(stderr, "Unhandled EXC_BAD_ACCESS at rip {:#016x}\n", ts->__rip); return KERN_FAILURE; } @@ -154,7 +154,7 @@ kern_return_t MachHandler::HandleRequest(arm_thread_state64_t* ts) { const auto iter = FindCodeBlockInfo(ts->__pc); if (iter == code_block_infos.end()) { - fmt::print(stderr, "Unhandled EXC_BAD_ACCESS at pc {:#016x}\n", ts->__pc); + std::print(stderr, "Unhandled EXC_BAD_ACCESS at pc {:#016x}\n", ts->__pc); return KERN_FAILURE; } @@ -197,12 +197,12 @@ void RegisterHandler() { } // anonymous namespace mig_external kern_return_t catch_mach_exception_raise(mach_port_t, mach_port_t, mach_port_t, exception_type_t, mach_exception_data_t, mach_msg_type_number_t) { - fmt::print(stderr, "dynarmic: Unexpected mach message: mach_exception_raise\n"); + std::print(stderr, "dynarmic: Unexpected mach message: mach_exception_raise\n"); return KERN_FAILURE; } mig_external kern_return_t catch_mach_exception_raise_state_identity(mach_port_t, mach_port_t, mach_port_t, exception_type_t, mach_exception_data_t, mach_msg_type_number_t, int*, thread_state_t, mach_msg_type_number_t, thread_state_t, mach_msg_type_number_t*) { - fmt::print(stderr, "dynarmic: Unexpected mach message: mach_exception_raise_state_identity\n"); + std::print(stderr, "dynarmic: Unexpected mach message: mach_exception_raise_state_identity\n"); return KERN_FAILURE; } @@ -217,15 +217,15 @@ mig_external kern_return_t catch_mach_exception_raise_state( thread_state_t new_state, mach_msg_type_number_t* new_stateCnt) { if (!flavor || !new_stateCnt) { - fmt::print(stderr, "dynarmic: catch_mach_exception_raise_state: Invalid arguments.\n"); + std::print(stderr, "dynarmic: catch_mach_exception_raise_state: Invalid arguments.\n"); return KERN_INVALID_ARGUMENT; } if (*flavor != THREAD_STATE || old_stateCnt != THREAD_STATE_COUNT || *new_stateCnt < THREAD_STATE_COUNT) { - fmt::print(stderr, "dynarmic: catch_mach_exception_raise_state: Unexpected flavor.\n"); + std::print(stderr, "dynarmic: catch_mach_exception_raise_state: Unexpected flavor.\n"); return KERN_INVALID_ARGUMENT; } if (exception != EXC_BAD_ACCESS) { - fmt::print(stderr, "dynarmic: catch_mach_exception_raise_state: Unexpected exception type.\n"); + std::print(stderr, "dynarmic: catch_mach_exception_raise_state: Unexpected exception type.\n"); return KERN_FAILURE; } diff --git a/src/dynarmic/src/dynarmic/backend/exception_handler_posix.cpp b/src/dynarmic/src/dynarmic/backend/exception_handler_posix.cpp index 24a059aee2..4a77ddc13a 100644 --- a/src/dynarmic/src/dynarmic/backend/exception_handler_posix.cpp +++ b/src/dynarmic/src/dynarmic/backend/exception_handler_posix.cpp @@ -18,7 +18,8 @@ #include #include "common/container/unordered_map.h" -#include +#include +#include #include #include "common/assert.h" @@ -71,7 +72,7 @@ public: signal_stack.ss_size = stack_size; signal_stack.ss_flags = 0; if (sigaltstack(&signal_stack, nullptr) != 0) { - fmt::print(stderr, "dynarmic: POSIX SigHandler: init failure at sigaltstack\n"); + std::print(stderr, "dynarmic: POSIX SigHandler: init failure at sigaltstack\n"); supports_fast_mem = false; return; } @@ -82,13 +83,13 @@ public: sa.sa_flags = SA_SIGINFO | SA_ONSTACK | SA_RESTART; sigemptyset(&sa.sa_mask); if (sigaction(SIGSEGV, &sa, &old_sa_segv) != 0) { - fmt::print(stderr, "dynarmic: POSIX SigHandler: could not set SIGSEGV handler\n"); + std::print(stderr, "dynarmic: POSIX SigHandler: could not set SIGSEGV handler\n"); supports_fast_mem = false; return; } #if defined(__APPLE__) if (sigaction(SIGBUS, &sa, &old_sa_bus) != 0) { - fmt::print(stderr, "dynarmic: POSIX SigHandler: could not set SIGBUS handler\n"); + std::print(stderr, "dynarmic: POSIX SigHandler: could not set SIGBUS handler\n"); supports_fast_mem = false; return; } diff --git a/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64.cpp b/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64.cpp index 795ec4ca21..b2c0859233 100644 --- a/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64.cpp +++ b/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include "dynarmic/mcl/bit.hpp" #include "dynarmic/backend/riscv64/a32_jitstate.h" diff --git a/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_a32.cpp b/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_a32.cpp index 6504a006e6..d6b5993fdd 100644 --- a/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_a32.cpp +++ b/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_a32.cpp @@ -7,7 +7,7 @@ */ #include -#include +#include #include "dynarmic/backend/riscv64/a32_jitstate.h" #include "dynarmic/backend/riscv64/abi.h" diff --git a/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_a32_coprocessor.cpp b/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_a32_coprocessor.cpp index b6a41f71b2..10afc56596 100644 --- a/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_a32_coprocessor.cpp +++ b/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_a32_coprocessor.cpp @@ -7,7 +7,7 @@ */ #include -#include +#include #include "dynarmic/backend/riscv64/a32_jitstate.h" #include "dynarmic/backend/riscv64/abi.h" diff --git a/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_a32_memory.cpp b/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_a32_memory.cpp index fa96d52e6e..603397efed 100644 --- a/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_a32_memory.cpp +++ b/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_a32_memory.cpp @@ -7,7 +7,7 @@ */ #include -#include +#include #include "dynarmic/backend/riscv64/a32_jitstate.h" #include "dynarmic/backend/riscv64/abi.h" diff --git a/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_a64.cpp b/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_a64.cpp index eed51547c6..e4ef34281d 100644 --- a/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_a64.cpp +++ b/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_a64.cpp @@ -7,7 +7,7 @@ */ #include -#include +#include #include "dynarmic/backend/riscv64/a32_jitstate.h" #include "dynarmic/backend/riscv64/abi.h" diff --git a/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_a64_memory.cpp b/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_a64_memory.cpp index 84802837c5..6c294e52d5 100644 --- a/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_a64_memory.cpp +++ b/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_a64_memory.cpp @@ -7,7 +7,7 @@ */ #include -#include +#include #include "dynarmic/backend/riscv64/a32_jitstate.h" #include "dynarmic/backend/riscv64/abi.h" diff --git a/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_cryptography.cpp b/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_cryptography.cpp index 44ebc2e3fc..97961df6ad 100644 --- a/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_cryptography.cpp +++ b/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_cryptography.cpp @@ -7,7 +7,7 @@ */ #include -#include +#include #include "dynarmic/backend/riscv64/a32_jitstate.h" #include "dynarmic/backend/riscv64/abi.h" diff --git a/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_data_processing.cpp b/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_data_processing.cpp index d41433b12b..02202ebd0c 100644 --- a/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_data_processing.cpp +++ b/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_data_processing.cpp @@ -7,7 +7,7 @@ */ #include -#include +#include #include "dynarmic/backend/riscv64/a32_jitstate.h" #include "dynarmic/backend/riscv64/abi.h" diff --git a/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_floating_point.cpp b/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_floating_point.cpp index 0c5d5984bc..748d3c20b2 100644 --- a/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_floating_point.cpp +++ b/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_floating_point.cpp @@ -7,7 +7,7 @@ */ #include -#include +#include #include "dynarmic/backend/riscv64/a32_jitstate.h" #include "dynarmic/backend/riscv64/abi.h" diff --git a/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_packed.cpp b/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_packed.cpp index acd73e86a3..2f1e424727 100644 --- a/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_packed.cpp +++ b/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_packed.cpp @@ -7,7 +7,7 @@ */ #include -#include +#include #include "dynarmic/backend/riscv64/a32_jitstate.h" #include "dynarmic/backend/riscv64/abi.h" diff --git a/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_saturation.cpp b/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_saturation.cpp index 9fae6cda77..192618ebb0 100644 --- a/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_saturation.cpp +++ b/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_saturation.cpp @@ -7,7 +7,7 @@ */ #include -#include +#include #include "dynarmic/backend/riscv64/a32_jitstate.h" #include "dynarmic/backend/riscv64/abi.h" diff --git a/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_vector.cpp b/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_vector.cpp index 5e56a34f19..469307eef6 100644 --- a/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_vector.cpp +++ b/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_vector.cpp @@ -7,7 +7,7 @@ */ #include -#include +#include #include "dynarmic/backend/riscv64/a32_jitstate.h" #include "dynarmic/backend/riscv64/abi.h" diff --git a/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_vector_floating_point.cpp b/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_vector_floating_point.cpp index 661cfc5403..35b20be62a 100644 --- a/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_vector_floating_point.cpp +++ b/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_vector_floating_point.cpp @@ -7,7 +7,7 @@ */ #include -#include +#include #include "dynarmic/backend/riscv64/a32_jitstate.h" #include "dynarmic/backend/riscv64/abi.h" diff --git a/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_vector_saturation.cpp b/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_vector_saturation.cpp index 6662afcd69..92cda10d03 100644 --- a/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_vector_saturation.cpp +++ b/src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_vector_saturation.cpp @@ -7,7 +7,7 @@ */ #include -#include +#include #include "dynarmic/backend/riscv64/a32_jitstate.h" #include "dynarmic/backend/riscv64/abi.h" diff --git a/src/dynarmic/src/dynarmic/backend/x64/a32_emit_x64.cpp b/src/dynarmic/src/dynarmic/backend/x64/a32_emit_x64.cpp index 5c6a90e15a..96593ac4f9 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/a32_emit_x64.cpp +++ b/src/dynarmic/src/dynarmic/backend/x64/a32_emit_x64.cpp @@ -12,8 +12,7 @@ #include #include -#include -#include +#include #include "common/assert.h" #include "dynarmic/mcl/bit.hpp" #include "common/common_types.h" @@ -1131,7 +1130,7 @@ void A32EmitX64::EmitA32CoprocStoreWords(A32EmitContext& ctx, IR::Inst* inst) { std::string A32EmitX64::LocationDescriptorToFriendlyName(const IR::LocationDescriptor& ir_descriptor) const { const A32::LocationDescriptor descriptor{ir_descriptor}; - return fmt::format("a32_{}{:08X}_{}_fpcr{:08X}", + return std::format("a32_{}{:08X}_{}_fpcr{:08X}", descriptor.TFlag() ? "t" : "a", descriptor.PC(), descriptor.EFlag() ? "be" : "le", diff --git a/src/dynarmic/src/dynarmic/backend/x64/a32_emit_x64_memory.cpp b/src/dynarmic/src/dynarmic/backend/x64/a32_emit_x64_memory.cpp index e866b2acd6..e63f17f3d9 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/a32_emit_x64_memory.cpp +++ b/src/dynarmic/src/dynarmic/backend/x64/a32_emit_x64_memory.cpp @@ -10,9 +10,10 @@ #include #include #include +#include -#include -#include +#include +#include #include "dynarmic/mcl/integer_of_size.hpp" #include "dynarmic/backend/x64/xbyak.h" @@ -69,7 +70,7 @@ void A32EmitX64::GenFastmemFallbacks() { ABI_PopCallerSaveRegistersAndAdjustStackExcept(code, HostLocRegIdx(value_idx)); code.ZeroExtendFrom(bitsize, Xbyak::Reg64{value_idx}); code.ret(); - PerfMapRegister(read_fallbacks[std::make_tuple(ordered, bitsize, vaddr_idx, value_idx)], code.getCurr(), fmt::format("a32_read_fallback_{}", bitsize)); + PerfMapRegister(read_fallbacks[std::make_tuple(ordered, bitsize, vaddr_idx, value_idx)], code.getCurr(), std::format("a32_read_fallback_{}", bitsize)); } for (const auto& [bitsize, callback] : write_callbacks) { @@ -98,7 +99,7 @@ void A32EmitX64::GenFastmemFallbacks() { if (ordered) code.mfence(); ABI_PopCallerSaveRegistersAndAdjustStack(code); code.ret(); - PerfMapRegister(write_fallbacks[std::make_tuple(ordered, bitsize, vaddr_idx, value_idx)], code.getCurr(), fmt::format("a32_write_fallback_{}", bitsize)); + PerfMapRegister(write_fallbacks[std::make_tuple(ordered, bitsize, vaddr_idx, value_idx)], code.getCurr(), std::format("a32_write_fallback_{}", bitsize)); } for (const auto& [bitsize, callback] : exclusive_write_callbacks) { @@ -126,7 +127,7 @@ void A32EmitX64::GenFastmemFallbacks() { callback.EmitCall(code); ABI_PopCallerSaveRegistersAndAdjustStackExcept(code, HostLoc::RAX); code.ret(); - PerfMapRegister(exclusive_write_fallbacks[std::make_tuple(ordered, bitsize, vaddr_idx, value_idx)], code.getCurr(), fmt::format("a32_exclusive_write_fallback_{}", bitsize)); + PerfMapRegister(exclusive_write_fallbacks[std::make_tuple(ordered, bitsize, vaddr_idx, value_idx)], code.getCurr(), std::format("a32_exclusive_write_fallback_{}", bitsize)); } } } diff --git a/src/dynarmic/src/dynarmic/backend/x64/a32_interface.cpp b/src/dynarmic/src/dynarmic/backend/x64/a32_interface.cpp index 1faa882021..3e4e990d2f 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/a32_interface.cpp +++ b/src/dynarmic/src/dynarmic/backend/x64/a32_interface.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include "common/assert.h" #include #include "common/common_types.h" diff --git a/src/dynarmic/src/dynarmic/backend/x64/a64_emit_x64.cpp b/src/dynarmic/src/dynarmic/backend/x64/a64_emit_x64.cpp index 71e5e62cd9..b1e89b0789 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/a64_emit_x64.cpp +++ b/src/dynarmic/src/dynarmic/backend/x64/a64_emit_x64.cpp @@ -8,8 +8,7 @@ #include "dynarmic/backend/x64/a64_emit_x64.h" -#include -#include +#include #include "common/assert.h" #include "common/common_types.h" #include "dynarmic/ir/terminal.h" @@ -612,7 +611,7 @@ void A64EmitX64::EmitA64SetTPIDR(A64EmitContext& ctx, IR::Inst* inst) { std::string A64EmitX64::LocationDescriptorToFriendlyName(const IR::LocationDescriptor& ir_descriptor) const { const A64::LocationDescriptor descriptor{ir_descriptor}; - return fmt::format("a64_{:016X}_fpcr{:08X}", + return std::format("a64_{:016X}_fpcr{:08X}", descriptor.PC(), descriptor.FPCR().Value()); } diff --git a/src/dynarmic/src/dynarmic/backend/x64/a64_emit_x64_memory.cpp b/src/dynarmic/src/dynarmic/backend/x64/a64_emit_x64_memory.cpp index 8bb2fcfa59..34ffeae23a 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/a64_emit_x64_memory.cpp +++ b/src/dynarmic/src/dynarmic/backend/x64/a64_emit_x64_memory.cpp @@ -10,9 +10,10 @@ #include #include #include +#include -#include -#include +#include +#include #include "dynarmic/mcl/integer_of_size.hpp" #include "dynarmic/backend/x64/xbyak.h" @@ -217,7 +218,7 @@ void A64EmitX64::GenFastmemFallbacks() { ABI_PopCallerSaveRegistersAndAdjustStackExcept(code, HostLocRegIdx(value_idx)); code.ZeroExtendFrom(bitsize, Xbyak::Reg64{value_idx}); code.ret(); - PerfMapRegister(read_fallbacks[std::make_tuple(ordered, bitsize, vaddr_idx, value_idx)], code.getCurr(), fmt::format("a64_read_fallback_{}", bitsize)); + PerfMapRegister(read_fallbacks[std::make_tuple(ordered, bitsize, vaddr_idx, value_idx)], code.getCurr(), std::format("a64_read_fallback_{}", bitsize)); } for (const auto& [bitsize, callback] : write_callbacks) { @@ -246,7 +247,7 @@ void A64EmitX64::GenFastmemFallbacks() { if (ordered) code.mfence(); ABI_PopCallerSaveRegistersAndAdjustStack(code); code.ret(); - PerfMapRegister(write_fallbacks[std::make_tuple(ordered, bitsize, vaddr_idx, value_idx)], code.getCurr(), fmt::format("a64_write_fallback_{}", bitsize)); + PerfMapRegister(write_fallbacks[std::make_tuple(ordered, bitsize, vaddr_idx, value_idx)], code.getCurr(), std::format("a64_write_fallback_{}", bitsize)); } for (const auto& [bitsize, callback] : exclusive_write_callbacks) { @@ -274,7 +275,7 @@ void A64EmitX64::GenFastmemFallbacks() { callback.EmitCall(code); ABI_PopCallerSaveRegistersAndAdjustStackExcept(code, HostLoc::RAX); code.ret(); - PerfMapRegister(exclusive_write_fallbacks[std::make_tuple(ordered, bitsize, vaddr_idx, value_idx)], code.getCurr(), fmt::format("a64_exclusive_write_fallback_{}", bitsize)); + PerfMapRegister(exclusive_write_fallbacks[std::make_tuple(ordered, bitsize, vaddr_idx, value_idx)], code.getCurr(), std::format("a64_exclusive_write_fallback_{}", bitsize)); } } } diff --git a/src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp b/src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp index 28d1913a22..ab97da0c91 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp +++ b/src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp @@ -19,8 +19,8 @@ #ifdef __APPLE__ # include -# include # include +# include #endif #include @@ -135,7 +135,7 @@ bool IsUnderRosetta() { size_t result_size = sizeof(result); if (sysctlbyname("sysctl.proc_translated", &result, &result_size, nullptr, 0) == -1) { if (errno != ENOENT) - fmt::print("IsUnderRosetta: Failed to detect Rosetta state, assuming not under Rosetta"); + std::print("IsUnderRosetta: Failed to detect Rosetta state, assuming not under Rosetta"); return false; } return result != 0; diff --git a/src/dynarmic/src/dynarmic/backend/x64/devirtualize.h b/src/dynarmic/src/dynarmic/backend/x64/devirtualize.h index 9b618fe71b..6cacd749cc 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/devirtualize.h +++ b/src/dynarmic/src/dynarmic/backend/x64/devirtualize.h @@ -33,7 +33,7 @@ struct ThunkBuilder { }; template inline T bit_cast_pointee(const P source_ptr) noexcept { - std::aligned_storage_t dest; + alignas(T) unsigned char dest[sizeof(T)]; std::memcpy(&dest, std::bit_cast(source_ptr), sizeof(T)); return reinterpret_cast(dest); } diff --git a/src/dynarmic/src/dynarmic/backend/x64/emit_x64_memory.cpp.inc b/src/dynarmic/src/dynarmic/backend/x64/emit_x64_memory.cpp.inc index 8bb8be3d5b..0b6c2f3186 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/emit_x64_memory.cpp.inc +++ b/src/dynarmic/src/dynarmic/backend/x64/emit_x64_memory.cpp.inc @@ -44,8 +44,8 @@ FakeCall AxxEmitX64::FastmemCallback(u64 rip_) { } return result; } - fmt::print("dynarmic: Segfault happened within JITted code at rip = {:016x}\n" - "Segfault wasn't at a fastmem patch location!\n", rip_); + std::println(stderr, "dynarmic: Segfault happened within JITted code at rip = {:016x}\n" + "Segfault wasn't at a fastmem patch location!", rip_); UNREACHABLE(); //("iter != fastmem_patch_info.end()"); } diff --git a/src/dynarmic/src/dynarmic/backend/x64/perf_map.cpp b/src/dynarmic/src/dynarmic/backend/x64/perf_map.cpp index eaa6c9e2b8..8fe4221e52 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/perf_map.cpp +++ b/src/dynarmic/src/dynarmic/backend/x64/perf_map.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include "dynarmic/backend/x64/perf_map.h" #include "common/common_types.h" @@ -33,7 +33,7 @@ void OpenFile() { } const pid_t pid = getpid(); - const std::string filename = fmt::format("{:s}/perf-{:d}.map", perf_dir, pid); + const std::string filename = std::format("{:s}/perf-{:d}.map", perf_dir, pid); file = std::fopen(filename.c_str(), "w"); if (!file) { @@ -60,7 +60,7 @@ void PerfMapRegister(const void* start, const void* end, std::string_view friend } } - const std::string line = fmt::format("{:016x} {:016x} {:s}\n", reinterpret_cast(start), reinterpret_cast(end) - reinterpret_cast(start), friendly_name); + const std::string line = std::format("{:016x} {:016x} {:s}\n", reinterpret_cast(start), reinterpret_cast(end) - reinterpret_cast(start), friendly_name); std::fwrite(line.data(), sizeof *line.data(), line.size(), file); } } // namespace detail diff --git a/src/dynarmic/src/dynarmic/backend/x64/reg_alloc.cpp b/src/dynarmic/src/dynarmic/backend/x64/reg_alloc.cpp index 5a828839c1..0e8b02fc3f 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/reg_alloc.cpp +++ b/src/dynarmic/src/dynarmic/backend/x64/reg_alloc.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include "dynarmic/backend/x64/hostloc.h" #include "common/assert.h" #include diff --git a/src/dynarmic/src/dynarmic/backend/x64/verbose_debugging_output.cpp b/src/dynarmic/src/dynarmic/backend/x64/verbose_debugging_output.cpp index b3a02005eb..62f08cfa74 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/verbose_debugging_output.cpp +++ b/src/dynarmic/src/dynarmic/backend/x64/verbose_debugging_output.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + /* This file is part of the dynarmic project. * Copyright (c) 2023 MerryMage * SPDX-License-Identifier: 0BSD @@ -7,14 +10,15 @@ #include -#include +#include +#include #include "dynarmic/backend/x64/hostloc.h" namespace Dynarmic::Backend::X64 { void PrintVerboseDebuggingOutputLine(RegisterData& reg_data, HostLoc hostloc, size_t inst_index, size_t bitsize) { - fmt::print("dynarmic debug: %{:05} = ", inst_index); + std::print("dynarmic debug: %{:05} = ", inst_index); Vector value = [&]() -> Vector { if (HostLocIsGPR(hostloc)) { @@ -24,33 +28,33 @@ void PrintVerboseDebuggingOutputLine(RegisterData& reg_data, HostLoc hostloc, si } else if (HostLocIsSpill(hostloc)) { return (*reg_data.spill)[size_t(hostloc) - size_t(HostLoc::FirstSpill)]; } else { - fmt::print("invalid hostloc! "); + std::print("invalid hostloc! "); return {0, 0}; } }(); switch (bitsize) { case 8: - fmt::print("{:02x}", value[0] & 0xff); + std::print("{:02x}", value[0] & 0xff); break; case 16: - fmt::print("{:04x}", value[0] & 0xffff); + std::print("{:04x}", value[0] & 0xffff); break; case 32: - fmt::print("{:08x}", value[0] & 0xffffffff); + std::print("{:08x}", value[0] & 0xffffffff); break; case 64: - fmt::print("{:016x}", value[0]); + std::print("{:016x}", value[0]); break; case 128: - fmt::print("{:016x}{:016x}", value[1], value[0]); + std::print("{:016x}{:016x}", value[1], value[0]); break; default: - fmt::print("invalid bitsize!"); + std::print("invalid bitsize!"); break; } - fmt::print("\n"); + std::print("\n"); } } // namespace Dynarmic::Backend::X64 diff --git a/src/dynarmic/src/dynarmic/common/fp/op/FPToFixed.cpp b/src/dynarmic/src/dynarmic/common/fp/op/FPToFixed.cpp index 7c322050c3..445255a914 100644 --- a/src/dynarmic/src/dynarmic/common/fp/op/FPToFixed.cpp +++ b/src/dynarmic/src/dynarmic/common/fp/op/FPToFixed.cpp @@ -8,7 +8,7 @@ #include "dynarmic/common/fp/op/FPToFixed.h" -#include +#include #include "common/assert.h" #include "dynarmic/mcl/bit.hpp" #include "common/common_types.h" diff --git a/src/dynarmic/src/dynarmic/common/llvm_disassemble.cpp b/src/dynarmic/src/dynarmic/common/llvm_disassemble.cpp index 6896b43d62..397839db77 100644 --- a/src/dynarmic/src/dynarmic/common/llvm_disassemble.cpp +++ b/src/dynarmic/src/dynarmic/common/llvm_disassemble.cpp @@ -7,7 +7,7 @@ */ #include -#include +#include #ifdef DYNARMIC_USE_LLVM # include @@ -37,7 +37,7 @@ std::string DisassembleX64(const void* begin, const void* end) { size_t inst_size = LLVMDisasmInstruction(llvm_ctx, const_cast(pos), remaining, reinterpret_cast(pos), buffer, sizeof(buffer)); ASSERT(inst_size); for (const u8* i = pos; i < pos + inst_size; i++) - result += fmt::format("{:02x} ", *i); + result += std::format("{:02x} ", *i); for (size_t i = inst_size; i < 10; i++) result += " "; result += buffer; @@ -50,7 +50,7 @@ std::string DisassembleX64(const void* begin, const void* end) { LLVMDisasmDispose(llvm_ctx); return result; #else - return fmt::format( + return std::format( "(recompile with DYNARMIC_USE_LLVM=ON to disassemble the generated x86_64 code)\n" "start: {:016x}, end: {:016x}\n", std::bit_cast(begin), std::bit_cast(end)); #endif @@ -73,10 +73,10 @@ std::string DisassembleAArch32([[maybe_unused]] bool is_thumb, [[maybe_unused]] if (inst_size == 0) inst_size = is_thumb ? 2 : 4; - result += fmt::format("{:08x} ", pc); + result += std::format("{:08x} ", pc); for (size_t i = 0; i < 4; i++) { if (i < inst_size) { - result += fmt::format("{:02x}", instructions[inst_size - i - 1]); + result += std::format("{:02x}", instructions[inst_size - i - 1]); } else { result += " "; } @@ -95,7 +95,7 @@ std::string DisassembleAArch32([[maybe_unused]] bool is_thumb, [[maybe_unused]] LLVMDisasmDispose(llvm_ctx); return result; #else - return fmt::format("(disassembly disabled)\n"); + return std::format("(disassembly disabled)\n"); #endif } @@ -110,14 +110,14 @@ std::string DisassembleAArch64([[maybe_unused]] u32 instruction, [[maybe_unused] char buffer[80]; size_t inst_size = LLVMDisasmInstruction(llvm_ctx, (u8*)&instruction, sizeof(instruction), pc, buffer, sizeof(buffer)); - result = fmt::format("{:016x} {:08x} ", pc, instruction); + result = std::format("{:016x} {:08x} ", pc, instruction); result += inst_size > 0 ? buffer : ""; result += '\n'; LLVMDisasmDispose(llvm_ctx); return result; #else - return fmt::format("(disassembly disabled)\n"); + return std::format("(disassembly disabled)\n"); #endif } diff --git a/src/dynarmic/src/dynarmic/frontend/A32/a32_location_descriptor.cpp b/src/dynarmic/src/dynarmic/frontend/A32/a32_location_descriptor.cpp index ac3a374e0d..4daa5f7e81 100644 --- a/src/dynarmic/src/dynarmic/frontend/A32/a32_location_descriptor.cpp +++ b/src/dynarmic/src/dynarmic/frontend/A32/a32_location_descriptor.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + /* This file is part of the dynarmic project. * Copyright (c) 2016 MerryMage * SPDX-License-Identifier: 0BSD @@ -5,12 +8,12 @@ #include "dynarmic/frontend/A32/a32_location_descriptor.h" -#include +#include namespace Dynarmic::A32 { std::string ToString(const LocationDescriptor& descriptor) { - return fmt::format("{{{:08x},{},{},{:08x}{}}}", + return std::format("{{{:08x},{},{},{:08x}{}}}", descriptor.PC(), descriptor.TFlag() ? "T" : "!T", descriptor.EFlag() ? "E" : "!E", diff --git a/src/dynarmic/src/dynarmic/frontend/A32/a32_location_descriptor.h b/src/dynarmic/src/dynarmic/frontend/A32/a32_location_descriptor.h index 399a1681f3..4b967e3aee 100644 --- a/src/dynarmic/src/dynarmic/frontend/A32/a32_location_descriptor.h +++ b/src/dynarmic/src/dynarmic/frontend/A32/a32_location_descriptor.h @@ -12,7 +12,7 @@ #include #include -#include +#include #include "common/common_types.h" #include "dynarmic/frontend/A32/FPSCR.h" @@ -157,7 +157,7 @@ struct hash { } // namespace std template<> -struct fmt::formatter : fmt::formatter { +struct std::formatter : std::formatter { template auto format(Dynarmic::A32::LocationDescriptor descriptor, FormatContext& ctx) const { return formatter::format(Dynarmic::A32::ToString(descriptor), ctx); diff --git a/src/dynarmic/src/dynarmic/frontend/A32/a32_types.h b/src/dynarmic/src/dynarmic/frontend/A32/a32_types.h index 957c643f56..585e151051 100644 --- a/src/dynarmic/src/dynarmic/frontend/A32/a32_types.h +++ b/src/dynarmic/src/dynarmic/frontend/A32/a32_types.h @@ -9,7 +9,7 @@ #pragma once #include -#include +#include #include "common/assert.h" #include "common/common_types.h" #include "dynarmic/interface/A32/coprocessor_util.h" @@ -139,7 +139,7 @@ inline ExtReg ToVector(bool Q, size_t base, bool bit) { } // namespace Dynarmic::A32 template<> -struct fmt::formatter : fmt::formatter { +struct std::formatter : std::formatter { template auto format(Dynarmic::A32::Reg reg, FormatContext& ctx) const { return formatter::format(Dynarmic::A32::RegToString(reg), ctx); @@ -147,7 +147,7 @@ struct fmt::formatter : fmt::formatter { }; template<> -struct fmt::formatter : fmt::formatter { +struct std::formatter : std::formatter { template auto format(Dynarmic::A32::ExtReg reg, FormatContext& ctx) const { return formatter::format(Dynarmic::A32::ExtRegToString(reg), ctx); @@ -155,7 +155,7 @@ struct fmt::formatter : fmt::formatter { }; template<> -struct fmt::formatter : fmt::formatter { +struct std::formatter : std::formatter { template auto format(Dynarmic::A32::CoprocReg reg, FormatContext& ctx) const { return formatter::format(Dynarmic::A32::CoprocRegToString(reg), ctx); @@ -163,7 +163,7 @@ struct fmt::formatter : fmt::formatter { }; template<> -struct fmt::formatter : fmt::formatter { +struct std::formatter : std::formatter { template auto format(Dynarmic::A32::RegList reg_list, FormatContext& ctx) const { return formatter::format(Dynarmic::A32::RegListToString(reg_list), ctx); diff --git a/src/dynarmic/src/dynarmic/frontend/A64/a64_location_descriptor.cpp b/src/dynarmic/src/dynarmic/frontend/A64/a64_location_descriptor.cpp index 83a931ff40..611e22a616 100644 --- a/src/dynarmic/src/dynarmic/frontend/A64/a64_location_descriptor.cpp +++ b/src/dynarmic/src/dynarmic/frontend/A64/a64_location_descriptor.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + /* This file is part of the dynarmic project. * Copyright (c) 2016 MerryMage * SPDX-License-Identifier: 0BSD @@ -5,12 +8,12 @@ #include "dynarmic/frontend/A64/a64_location_descriptor.h" -#include +#include namespace Dynarmic::A64 { std::string ToString(const LocationDescriptor& descriptor) { - return fmt::format("{{{}, {}{}}}", descriptor.PC(), descriptor.FPCR().Value(), descriptor.SingleStepping() ? ", step" : ""); + return std::format("{{{}, {}{}}}", descriptor.PC(), descriptor.FPCR().Value(), descriptor.SingleStepping() ? ", step" : ""); } } // namespace Dynarmic::A64 diff --git a/src/dynarmic/src/dynarmic/frontend/A64/a64_location_descriptor.h b/src/dynarmic/src/dynarmic/frontend/A64/a64_location_descriptor.h index d0c6a9df3d..7cfc762b07 100644 --- a/src/dynarmic/src/dynarmic/frontend/A64/a64_location_descriptor.h +++ b/src/dynarmic/src/dynarmic/frontend/A64/a64_location_descriptor.h @@ -12,7 +12,7 @@ #include #include -#include +#include #include "dynarmic/mcl/bit.hpp" #include "common/common_types.h" @@ -110,7 +110,7 @@ struct hash { } // namespace std template<> -struct fmt::formatter : fmt::formatter { +struct std::formatter : std::formatter { template auto format(Dynarmic::A64::LocationDescriptor descriptor, FormatContext& ctx) const { return formatter::format(Dynarmic::A64::ToString(descriptor), ctx); diff --git a/src/dynarmic/src/dynarmic/frontend/A64/a64_types.cpp b/src/dynarmic/src/dynarmic/frontend/A64/a64_types.cpp index ca1c59ab36..339dee828b 100644 --- a/src/dynarmic/src/dynarmic/frontend/A64/a64_types.cpp +++ b/src/dynarmic/src/dynarmic/frontend/A64/a64_types.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + /* This file is part of the dynarmic project. * Copyright (c) 2018 MerryMage * SPDX-License-Identifier: 0BSD @@ -8,7 +11,7 @@ #include #include -#include +#include namespace Dynarmic::A64 { @@ -23,11 +26,11 @@ std::string RegToString(Reg reg) { if (reg == Reg::R31) { return "sp|zr"; } - return fmt::format("r{}", static_cast(reg)); + return std::format("r{}", static_cast(reg)); } std::string VecToString(Vec vec) { - return fmt::format("v{}", static_cast(vec)); + return std::format("v{}", static_cast(vec)); } } // namespace Dynarmic::A64 diff --git a/src/dynarmic/src/dynarmic/frontend/A64/a64_types.h b/src/dynarmic/src/dynarmic/frontend/A64/a64_types.h index 55d82a740a..c7c55f4bb5 100644 --- a/src/dynarmic/src/dynarmic/frontend/A64/a64_types.h +++ b/src/dynarmic/src/dynarmic/frontend/A64/a64_types.h @@ -10,7 +10,7 @@ #include -#include +#include #include "common/assert.h" #include "common/common_types.h" @@ -129,7 +129,7 @@ inline Vec operator+(Vec vec, size_t number) { } // namespace Dynarmic::A64 template<> -struct fmt::formatter : fmt::formatter { +struct std::formatter : std::formatter { template auto format(Dynarmic::A64::Reg reg, FormatContext& ctx) const { return formatter::format(Dynarmic::A64::RegToString(reg), ctx); @@ -137,7 +137,7 @@ struct fmt::formatter : fmt::formatter { }; template<> -struct fmt::formatter : fmt::formatter { +struct std::formatter : std::formatter { template auto format(Dynarmic::A64::Vec vec, FormatContext& ctx) const { return formatter::format(Dynarmic::A64::VecToString(vec), ctx); diff --git a/src/dynarmic/src/dynarmic/ir/basic_block.cpp b/src/dynarmic/src/dynarmic/ir/basic_block.cpp index 4a7b2bf261..f7a272a624 100644 --- a/src/dynarmic/src/dynarmic/ir/basic_block.cpp +++ b/src/dynarmic/src/dynarmic/ir/basic_block.cpp @@ -13,7 +13,7 @@ #include #include -#include +#include #include "common/assert.h" #include "dynarmic/frontend/A32/a32_types.h" #include "dynarmic/frontend/A64/a64_types.h" @@ -81,10 +81,10 @@ static std::string TerminalToString(const Term::Terminal& terminal_variant) noex // return "ReturnToDispatch{}"; // } // std::string operator()(const Term::LinkBlock& terminal) const { - // return fmt::format("LinkBlock{{{}}}", terminal.next); + // return std::format("LinkBlock{{{}}}", terminal.next); // } // std::string operator()(const Term::LinkBlockFast& terminal) const { - // return fmt::format("LinkBlockFast{{{}}}", terminal.next); + // return std::format("LinkBlockFast{{{}}}", terminal.next); // } // std::string operator()(const Term::PopRSBHint&) const { // return "PopRSBHint{}"; @@ -93,62 +93,62 @@ static std::string TerminalToString(const Term::Terminal& terminal_variant) noex // return "FastDispatchHint{}"; // } // std::string operator()(const Term::If& terminal) const { - // return fmt::format("If{{{}, {}, {}}}", A64::CondToString(terminal.if_), TerminalToString(terminal.then_), TerminalToString(terminal.else_)); + // return std::format("If{{{}, {}, {}}}", A64::CondToString(terminal.if_), TerminalToString(terminal.then_), TerminalToString(terminal.else_)); // } // std::string operator()(const Term::CheckBit& terminal) const { - // return fmt::format("CheckBit{{{}, {}}}", TerminalToString(terminal.then_), TerminalToString(terminal.else_)); + // return std::format("CheckBit{{{}, {}}}", TerminalToString(terminal.then_), TerminalToString(terminal.else_)); // } // std::string operator()(const Term::CheckHalt& terminal) const { - // return fmt::format("CheckHalt{{{}}}", TerminalToString(terminal.else_)); + // return std::format("CheckHalt{{{}}}", TerminalToString(terminal.else_)); // } // } visitor; // return boost::apply_visitor(visitor, terminal_variant); return ""; } -std::string DumpBlock(const IR::Block& block) noexcept { - std::string ret = fmt::format("Block: location={}-{}\n", block.Location(), block.EndLocation()) - + fmt::format("cycles={}", block.CycleCount()) - + fmt::format(", entry_cond={}", A64::CondToString(block.GetCondition())); - if (block.GetCondition() != Cond::AL) - ret += fmt::format(", cond_fail={}", block.ConditionFailedLocation()); - ret += '\n'; +static std::string ArgToString(const IR::Value& arg) { + if (arg.IsEmpty()) { + return ""; + } else if (!arg.IsImmediate()) { + if (auto const name = arg.GetInst()->GetName()) + return std::format("%{}", name); + return std::format("%", u64(arg.GetInst())); + } + switch (arg.GetType()) { + case Type::U1: return std::format("#{}", arg.GetU1() ? '1' : '0'); + case Type::U8: return std::format("#{}", arg.GetU8()); + case Type::U16: return std::format("#{:#x}", u32(arg.GetU16())); + case Type::U32: return std::format("#{:#x}", arg.GetU32()); + case Type::U64: return std::format("#{:#x}", arg.GetU64()); + case Type::U128: return std::format("#"); + case Type::A32Reg: return A32::RegToString(arg.GetA32RegRef()); + case Type::A32ExtReg: return A32::ExtRegToString(arg.GetA32ExtRegRef()); + case Type::A64Reg: return A64::RegToString(arg.GetA64RegRef()); + case Type::A64Vec: return A64::VecToString(arg.GetA64VecRef()); + case Type::CoprocInfo: return std::format("$coproc{}", arg.GetCoprocInfo()[0]); + case Type::NZCVFlags: return std::format("$nzcv"); + case Type::Cond: return std::format("$cond={}", A32::CondToString(arg.GetCond())); + case Type::Table: return std::format("$table"); + case Type::AccType: return std::format("$acc-type={}", u32(arg.GetAccType())); + default: return std::format("", arg.GetType()); + } +}; - const auto arg_to_string = [](const IR::Value& arg) -> std::string { - if (arg.IsEmpty()) { - return ""; - } else if (!arg.IsImmediate()) { - if (auto const name = arg.GetInst()->GetName()) - return fmt::format("%{}", name); - return fmt::format("%", u64(arg.GetInst())); - } - switch (arg.GetType()) { - case Type::U1: return fmt::format("#{}", arg.GetU1() ? '1' : '0'); - case Type::U8: return fmt::format("#{}", arg.GetU8()); - case Type::U16: return fmt::format("#{:#x}", arg.GetU16()); - case Type::U32: return fmt::format("#{:#x}", arg.GetU32()); - case Type::U64: return fmt::format("#{:#x}", arg.GetU64()); - case Type::U128: return fmt::format("#"); - case Type::A32Reg: return A32::RegToString(arg.GetA32RegRef()); - case Type::A32ExtReg: return A32::ExtRegToString(arg.GetA32ExtRegRef()); - case Type::A64Reg: return A64::RegToString(arg.GetA64RegRef()); - case Type::A64Vec: return A64::VecToString(arg.GetA64VecRef()); - case Type::CoprocInfo: return fmt::format("$coproc{}", arg.GetCoprocInfo()[0]); - case Type::NZCVFlags: return fmt::format("$nzcv"); - case Type::Cond: return fmt::format("$cond={}", A32::CondToString(arg.GetCond())); - case Type::Table: return fmt::format("$table"); - case Type::AccType: return fmt::format("$acc-type={}", u32(arg.GetAccType())); - default: return fmt::format("", arg.GetType()); - } - }; +std::string DumpBlock(const IR::Block& block) noexcept { + std::string ret = std::format("Block: location={}-{}\n", block.Location(), block.EndLocation()) + + std::format("cycles={}", block.CycleCount()) + + std::format(", entry_cond={}", A64::CondToString(block.GetCondition())); + if (block.GetCondition() != Cond::AL) + ret += std::format(", cond_fail={}", block.ConditionFailedLocation()); + ret += '\n'; for (const auto& inst : block.instructions) { const Opcode op = inst.GetOpcode(); - ret += fmt::format("[{:016x}] ", reinterpret_cast(&inst)); + ret += std::format("[{:016x}] ", reinterpret_cast(&inst)); if (GetTypeOf(op) != Type::Void) { if (inst.GetName()) { - ret += fmt::format("%{:<5} = ", inst.GetName()); + ret += std::format("%{:<5} = ", inst.GetName()); } else { ret += "noname = "; } @@ -163,16 +163,16 @@ std::string DumpBlock(const IR::Block& block) noexcept { const Value arg = inst.GetArg(arg_index); ret += arg_index != 0 ? ", " : " "; - ret += arg_to_string(arg); + ret += ArgToString(arg); Type actual_type = arg.GetType(); Type expected_type = GetArgTypeOf(op, arg_index); if (!AreTypesCompatible(actual_type, expected_type)) { - ret += fmt::format("", GetNameOf(actual_type), GetNameOf(expected_type)); + ret += std::format("", GetNameOf(actual_type), GetNameOf(expected_type)); } } - ret += fmt::format(" (uses: {})", inst.UseCount()) + '\n'; + ret += std::format(" (uses: {})", inst.UseCount()) + '\n'; } ret += "terminal = " + TerminalToString(block.GetTerminal()) + '\n'; return ret; diff --git a/src/dynarmic/src/dynarmic/ir/location_descriptor.cpp b/src/dynarmic/src/dynarmic/ir/location_descriptor.cpp index e7e640561d..ccbf1dff82 100644 --- a/src/dynarmic/src/dynarmic/ir/location_descriptor.cpp +++ b/src/dynarmic/src/dynarmic/ir/location_descriptor.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + /* This file is part of the dynarmic project. * Copyright (c) 2016 MerryMage * SPDX-License-Identifier: 0BSD @@ -5,12 +8,12 @@ #include "dynarmic/ir/location_descriptor.h" -#include +#include namespace Dynarmic::IR { std::string ToString(const LocationDescriptor& descriptor) { - return fmt::format("{{{:016x}}}", descriptor.Value()); + return std::format("{{{:016x}}}", descriptor.Value()); } } // namespace Dynarmic::IR diff --git a/src/dynarmic/src/dynarmic/ir/location_descriptor.h b/src/dynarmic/src/dynarmic/ir/location_descriptor.h index ca44c03306..8a6747c6ea 100644 --- a/src/dynarmic/src/dynarmic/ir/location_descriptor.h +++ b/src/dynarmic/src/dynarmic/ir/location_descriptor.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include "common/common_types.h" namespace Dynarmic::IR { @@ -59,7 +59,7 @@ struct hash { } // namespace std template<> -struct fmt::formatter : fmt::formatter { +struct std::formatter : std::formatter { template auto format(Dynarmic::IR::LocationDescriptor descriptor, FormatContext& ctx) const { return formatter::format(ToString(descriptor), ctx); diff --git a/src/dynarmic/src/dynarmic/ir/opcodes.h b/src/dynarmic/src/dynarmic/ir/opcodes.h index f975896a6b..c36d3d1375 100644 --- a/src/dynarmic/src/dynarmic/ir/opcodes.h +++ b/src/dynarmic/src/dynarmic/ir/opcodes.h @@ -10,7 +10,7 @@ #include -#include +#include #include "common/common_types.h" namespace Dynarmic::IR { @@ -656,7 +656,7 @@ constexpr bool MayGetNZCVFromOp(const Opcode op) noexcept { } // namespace Dynarmic::IR template<> -struct fmt::formatter : fmt::formatter { +struct std::formatter : std::formatter { template auto format(Dynarmic::IR::Opcode op, FormatContext& ctx) const { return formatter::format(GetNameOf(op), ctx); diff --git a/src/dynarmic/src/dynarmic/ir/type.h b/src/dynarmic/src/dynarmic/ir/type.h index 3344e26db1..c70dd0ea80 100644 --- a/src/dynarmic/src/dynarmic/ir/type.h +++ b/src/dynarmic/src/dynarmic/ir/type.h @@ -10,7 +10,7 @@ #include -#include +#include #include "common/common_types.h" namespace Dynarmic::IR { @@ -55,7 +55,7 @@ bool AreTypesCompatible(Type t1, Type t2); } // namespace Dynarmic::IR template<> -struct fmt::formatter : fmt::formatter { +struct std::formatter : std::formatter { template auto format(Dynarmic::IR::Type type, FormatContext& ctx) const { return formatter::format(Dynarmic::IR::GetNameOf(type), ctx); diff --git a/src/dynarmic/tests/A32/fuzz_arm.cpp b/src/dynarmic/tests/A32/fuzz_arm.cpp index abb9830372..b12967db31 100644 --- a/src/dynarmic/tests/A32/fuzz_arm.cpp +++ b/src/dynarmic/tests/A32/fuzz_arm.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include "dynarmic/mcl/bit.hpp" @@ -36,8 +37,7 @@ #include "dynarmic/ir/opcodes.h" // Must be declared last for all necessary operator<< to be declared prior to this. -#include -#include +#include namespace { using namespace Dynarmic; @@ -341,62 +341,62 @@ static void RunTestInstance(Dynarmic::A32::Jit& jit, uni.Run(); // SCOPE_FAIL { - // fmt::print("Instruction Listing:\n"); - // fmt::print("{}\n", Common::DisassembleAArch32(std::is_same_v, initial_pc, (const u8*)instructions.data(), instructions.size() * sizeof(instructions[0]))); + // std::print("Instruction Listing:\n"); + // std::print("{}\n", Common::DisassembleAArch32(std::is_same_v, initial_pc, (const u8*)instructions.data(), instructions.size() * sizeof(instructions[0]))); - // fmt::print("Initial register listing:\n"); + // std::print("Initial register listing:\n"); // for (size_t i = 0; i < regs.size(); ++i) { - // fmt::print("{:3s}: {:08x}\n", static_cast(i), regs[i]); + // std::print("{:3s}: {:08x}\n", static_cast(i), regs[i]); // } // for (size_t i = 0; i < vecs.size(); ++i) { - // fmt::print("{:3s}: {:08x}\n", static_cast(i), vecs[i]); + // std::print("{:3s}: {:08x}\n", static_cast(i), vecs[i]); // } - // fmt::print("cpsr {:08x}\n", cpsr); - // fmt::print("fpcr {:08x}\n", fpscr); - // fmt::print("fpcr.AHP {}\n", FP::FPCR{fpscr}.AHP()); - // fmt::print("fpcr.DN {}\n", FP::FPCR{fpscr}.DN()); - // fmt::print("fpcr.FZ {}\n", FP::FPCR{fpscr}.FZ()); - // fmt::print("fpcr.RMode {}\n", static_cast(FP::FPCR{fpscr}.RMode())); - // fmt::print("fpcr.FZ16 {}\n", FP::FPCR{fpscr}.FZ16()); - // fmt::print("\n"); + // std::print("cpsr {:08x}\n", cpsr); + // std::print("fpcr {:08x}\n", fpscr); + // std::print("fpcr.AHP {}\n", FP::FPCR{fpscr}.AHP()); + // std::print("fpcr.DN {}\n", FP::FPCR{fpscr}.DN()); + // std::print("fpcr.FZ {}\n", FP::FPCR{fpscr}.FZ()); + // std::print("fpcr.RMode {}\n", static_cast(FP::FPCR{fpscr}.RMode())); + // std::print("fpcr.FZ16 {}\n", FP::FPCR{fpscr}.FZ16()); + // std::print("\n"); - // fmt::print("Final register listing:\n"); - // fmt::print(" unicorn dynarmic\n"); + // std::print("Final register listing:\n"); + // std::print(" unicorn dynarmic\n"); // const auto uni_regs = uni.GetRegisters(); // for (size_t i = 0; i < regs.size(); ++i) { - // fmt::print("{:3s}: {:08x} {:08x} {}\n", static_cast(i), uni_regs[i], jit.Regs()[i], uni_regs[i] != jit.Regs()[i] ? "*" : ""); + // std::print("{:3s}: {:08x} {:08x} {}\n", static_cast(i), uni_regs[i], jit.Regs()[i], uni_regs[i] != jit.Regs()[i] ? "*" : ""); // } // const auto uni_ext_regs = uni.GetExtRegs(); // for (size_t i = 0; i < vecs.size(); ++i) { - // fmt::print("s{:2d}: {:08x} {:08x} {}\n", static_cast(i), uni_ext_regs[i], jit.ExtRegs()[i], uni_ext_regs[i] != jit.ExtRegs()[i] ? "*" : ""); + // std::print("s{:2d}: {:08x} {:08x} {}\n", static_cast(i), uni_ext_regs[i], jit.ExtRegs()[i], uni_ext_regs[i] != jit.ExtRegs()[i] ? "*" : ""); // } - // fmt::print("cpsr {:08x} {:08x} {}\n", uni.GetCpsr(), jit.Cpsr(), uni.GetCpsr() != jit.Cpsr() ? "*" : ""); - // fmt::print("fpsr {:08x} {:08x} {}\n", uni.GetFpscr(), jit.Fpscr(), (uni.GetFpscr() & 0xF0000000) != (jit.Fpscr() & 0xF0000000) ? "*" : ""); - // fmt::print("\n"); + // std::print("cpsr {:08x} {:08x} {}\n", uni.GetCpsr(), jit.Cpsr(), uni.GetCpsr() != jit.Cpsr() ? "*" : ""); + // std::print("fpsr {:08x} {:08x} {}\n", uni.GetFpscr(), jit.Fpscr(), (uni.GetFpscr() & 0xF0000000) != (jit.Fpscr() & 0xF0000000) ? "*" : ""); + // std::print("\n"); - // fmt::print("Modified memory:\n"); - // fmt::print(" uni dyn\n"); + // std::print("Modified memory:\n"); + // std::print(" uni dyn\n"); // auto uni_iter = uni_env.modified_memory.begin(); // auto jit_iter = jit_env.modified_memory.begin(); // while (uni_iter != uni_env.modified_memory.end() || jit_iter != jit_env.modified_memory.end()) { // if (uni_iter == uni_env.modified_memory.end() || (jit_iter != jit_env.modified_memory.end() && uni_iter->first > jit_iter->first)) { - // fmt::print("{:08x}: {:02x} *\n", jit_iter->first, jit_iter->second); + // std::print("{:08x}: {:02x} *\n", jit_iter->first, jit_iter->second); // jit_iter++; // } else if (jit_iter == jit_env.modified_memory.end() || jit_iter->first > uni_iter->first) { - // fmt::print("{:08x}: {:02x} *\n", uni_iter->first, uni_iter->second); + // std::print("{:08x}: {:02x} *\n", uni_iter->first, uni_iter->second); // uni_iter++; // } else if (uni_iter->first == jit_iter->first) { - // fmt::print("{:08x}: {:02x} {:02x} {}\n", uni_iter->first, uni_iter->second, jit_iter->second, uni_iter->second != jit_iter->second ? "*" : ""); + // std::print("{:08x}: {:02x} {:02x} {}\n", uni_iter->first, uni_iter->second, jit_iter->second, uni_iter->second != jit_iter->second ? "*" : ""); // uni_iter++; // jit_iter++; // } // } - // fmt::print("\n"); + // std::print("\n"); - // fmt::print("x86_64:\n"); - // fmt::print("{}", jit.Disassemble()); + // std::print("x86_64:\n"); + // std::print("{}", jit.Disassemble()); - // fmt::print("Interrupts:\n"); + // std::print("Interrupts:\n"); // for (const auto& i : uni_env.interrupts) { // std::puts(i.c_str()); // } @@ -418,7 +418,7 @@ static void RunTestInstance(Dynarmic::A32::Jit& jit, if (uni.GetRegisters()[15] > jit.Regs()[15]) { int trials = 0; while (jit.Regs()[15] >= initial_pc && jit.Regs()[15] < expected_end_pc && trials++ < 100 && uni.GetRegisters()[15] != jit.Regs()[15]) { - fmt::print("Warning: Possible unicorn overrrun, attempt recovery\n"); + std::print("Warning: Possible unicorn overrrun, attempt recovery\n"); jit.Step(); } } diff --git a/src/dynarmic/tests/A64/a64.cpp b/src/dynarmic/tests/A64/a64.cpp index ca1385a110..d79ebfb400 100644 --- a/src/dynarmic/tests/A64/a64.cpp +++ b/src/dynarmic/tests/A64/a64.cpp @@ -1795,7 +1795,7 @@ TEST_CASE("A64: rand3", "[a64]") { jit.SetPstate(0xb0000000); jit.SetFpcr(0x01000000); env.ticks_left = 110; - //fmt::print("{}", jit.Disassemble()); + //std::print("{}", jit.Disassemble()); CheckedRun([&]() { jit.Run(); }); } diff --git a/src/dynarmic/tests/A64/fuzz_with_unicorn.cpp b/src/dynarmic/tests/A64/fuzz_with_unicorn.cpp index 1e1e37d888..36d78555f8 100644 --- a/src/dynarmic/tests/A64/fuzz_with_unicorn.cpp +++ b/src/dynarmic/tests/A64/fuzz_with_unicorn.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "common/common_types.h" @@ -31,8 +32,7 @@ #include "dynarmic/ir/opt_passes.h" // Must be declared last for all necessary operator<< to be declared prior to this. -#include -#include +#include using namespace Dynarmic; @@ -203,77 +203,77 @@ static void RunTestInstance(Dynarmic::A64::Jit& jit, A64Unicorn& uni, A64TestEnv uni.Run(); // SCOPE_FAIL { - // fmt::print("Instruction Listing:\n"); + // std::print("Instruction Listing:\n"); // for (u32 instruction : instructions) { - // fmt::print("{:08x} {}\n", instruction, Common::DisassembleAArch64(instruction)); + // std::print("{:08x} {}\n", instruction, Common::DisassembleAArch64(instruction)); // } - // fmt::print("\n"); + // std::print("\n"); - // fmt::print("Initial register listing:\n"); + // std::print("Initial register listing:\n"); // for (size_t i = 0; i < regs.size(); ++i) { - // fmt::print("{:3s}: {:016x}\n", A64::RegToString(static_cast(i)), regs[i]); + // std::print("{:3s}: {:016x}\n", A64::RegToString(static_cast(i)), regs[i]); // } // for (size_t i = 0; i < vecs.size(); ++i) { - // fmt::print("{:3s}: {:016x}{:016x}\n", A64::VecToString(static_cast(i)), vecs[i][1], vecs[i][0]); + // std::print("{:3s}: {:016x}{:016x}\n", A64::VecToString(static_cast(i)), vecs[i][1], vecs[i][0]); // } - // fmt::print("sp : {:016x}\n", initial_sp); - // fmt::print("pc : {:016x}\n", instructions_start); - // fmt::print("p : {:08x}\n", pstate); - // fmt::print("fpcr {:08x}\n", fpcr); - // fmt::print("fpcr.AHP {}\n", FP::FPCR{fpcr}.AHP()); - // fmt::print("fpcr.DN {}\n", FP::FPCR{fpcr}.DN()); - // fmt::print("fpcr.FZ {}\n", FP::FPCR{fpcr}.FZ()); - // fmt::print("fpcr.RMode {}\n", static_cast(FP::FPCR{fpcr}.RMode())); - // fmt::print("fpcr.FZ16 {}\n", FP::FPCR{fpcr}.FZ16()); - // fmt::print("\n"); + // std::print("sp : {:016x}\n", initial_sp); + // std::print("pc : {:016x}\n", instructions_start); + // std::print("p : {:08x}\n", pstate); + // std::print("fpcr {:08x}\n", fpcr); + // std::print("fpcr.AHP {}\n", FP::FPCR{fpcr}.AHP()); + // std::print("fpcr.DN {}\n", FP::FPCR{fpcr}.DN()); + // std::print("fpcr.FZ {}\n", FP::FPCR{fpcr}.FZ()); + // std::print("fpcr.RMode {}\n", static_cast(FP::FPCR{fpcr}.RMode())); + // std::print("fpcr.FZ16 {}\n", FP::FPCR{fpcr}.FZ16()); + // std::print("\n"); - // fmt::print("Final register listing:\n"); - // fmt::print(" unicorn dynarmic\n"); + // std::print("Final register listing:\n"); + // std::print(" unicorn dynarmic\n"); // const auto uni_regs = uni.GetRegisters(); // for (size_t i = 0; i < regs.size(); ++i) { - // fmt::print("{:3s}: {:016x} {:016x} {}\n", A64::RegToString(static_cast(i)), uni_regs[i], jit.GetRegisters()[i], uni_regs[i] != jit.GetRegisters()[i] ? "*" : ""); + // std::print("{:3s}: {:016x} {:016x} {}\n", A64::RegToString(static_cast(i)), uni_regs[i], jit.GetRegisters()[i], uni_regs[i] != jit.GetRegisters()[i] ? "*" : ""); // } // const auto uni_vecs = uni.GetVectors(); // for (size_t i = 0; i < vecs.size(); ++i) { - // fmt::print("{:3s}: {:016x}{:016x} {:016x}{:016x} {}\n", A64::VecToString(static_cast(i)), + // std::print("{:3s}: {:016x}{:016x} {:016x}{:016x} {}\n", A64::VecToString(static_cast(i)), // uni_vecs[i][1], uni_vecs[i][0], // jit.GetVectors()[i][1], jit.GetVectors()[i][0], // uni_vecs[i] != jit.GetVectors()[i] ? "*" : ""); // } - // fmt::print("sp : {:016x} {:016x} {}\n", uni.GetSP(), jit.GetSP(), uni.GetSP() != jit.GetSP() ? "*" : ""); - // fmt::print("pc : {:016x} {:016x} {}\n", uni.GetPC(), jit.GetPC(), uni.GetPC() != jit.GetPC() ? "*" : ""); - // fmt::print("p : {:08x} {:08x} {}\n", uni.GetPstate(), jit.GetPstate(), (uni.GetPstate() & 0xF0000000) != (jit.GetPstate() & 0xF0000000) ? "*" : ""); - // fmt::print("qc : {:08x} {:08x} {}\n", uni.GetFpsr(), jit.GetFpsr(), FP::FPSR{uni.GetFpsr()}.QC() != FP::FPSR{jit.GetFpsr()}.QC() ? "*" : ""); - // fmt::print("\n"); + // std::print("sp : {:016x} {:016x} {}\n", uni.GetSP(), jit.GetSP(), uni.GetSP() != jit.GetSP() ? "*" : ""); + // std::print("pc : {:016x} {:016x} {}\n", uni.GetPC(), jit.GetPC(), uni.GetPC() != jit.GetPC() ? "*" : ""); + // std::print("p : {:08x} {:08x} {}\n", uni.GetPstate(), jit.GetPstate(), (uni.GetPstate() & 0xF0000000) != (jit.GetPstate() & 0xF0000000) ? "*" : ""); + // std::print("qc : {:08x} {:08x} {}\n", uni.GetFpsr(), jit.GetFpsr(), FP::FPSR{uni.GetFpsr()}.QC() != FP::FPSR{jit.GetFpsr()}.QC() ? "*" : ""); + // std::print("\n"); - // fmt::print("Modified memory:\n"); - // fmt::print(" uni dyn\n"); + // std::print("Modified memory:\n"); + // std::print(" uni dyn\n"); // auto uni_iter = uni_env.modified_memory.begin(); // auto jit_iter = jit_env.modified_memory.begin(); // while (uni_iter != uni_env.modified_memory.end() || jit_iter != jit_env.modified_memory.end()) { // if (uni_iter == uni_env.modified_memory.end() || (jit_iter != jit_env.modified_memory.end() && uni_iter->first > jit_iter->first)) { - // fmt::print("{:016x}: {:02x} *\n", jit_iter->first, jit_iter->second); + // std::print("{:016x}: {:02x} *\n", jit_iter->first, jit_iter->second); // jit_iter++; // } else if (jit_iter == jit_env.modified_memory.end() || jit_iter->first > uni_iter->first) { - // fmt::print("{:016x}: {:02x} *\n", uni_iter->first, uni_iter->second); + // std::print("{:016x}: {:02x} *\n", uni_iter->first, uni_iter->second); // uni_iter++; // } else if (uni_iter->first == jit_iter->first) { - // fmt::print("{:016x}: {:02x} {:02x} {}\n", uni_iter->first, uni_iter->second, jit_iter->second, uni_iter->second != jit_iter->second ? "*" : ""); + // std::print("{:016x}: {:02x} {:02x} {}\n", uni_iter->first, uni_iter->second, jit_iter->second, uni_iter->second != jit_iter->second ? "*" : ""); // uni_iter++; // jit_iter++; // } // } - // fmt::print("\n"); + // std::print("\n"); // const auto get_code = [&jit_env](u64 vaddr) { return jit_env.MemoryReadCode(vaddr); }; // const A64::LocationDescriptor location{instructions_start, FP::FPCR{fpcr}}; // IR::Block ir_block{location}; // A64::Translate(ir_block, location, config); - // fmt::print("IR:\n{}\n", IR::DumpBlock(ir_block)); + // std::print("IR:\n{}\n", IR::DumpBlock(ir_block)); // Optimization::Optimize(ir_block, conf, {}); - // fmt::print("Optimized IR:\n{}\n", IR::DumpBlock(ir_block)); - // fmt::print("x86_64:\n{}", jit.Disassemble()); - // fmt::print("Interrupts:\n"); + // std::print("Optimized IR:\n{}\n", IR::DumpBlock(ir_block)); + // std::print("x86_64:\n{}", jit.Disassemble()); + // std::print("Interrupts:\n"); // for (auto& i : uni_env.interrupts) { // puts(i.c_str()); // } diff --git a/src/dynarmic/tests/A64/testenv.h b/src/dynarmic/tests/A64/testenv.h index 11aa6389f8..a887a247dd 100644 --- a/src/dynarmic/tests/A64/testenv.h +++ b/src/dynarmic/tests/A64/testenv.h @@ -8,6 +8,8 @@ #pragma once +#include + #include "common/container/unordered_map.h" #include "common/assert.h" #include "common/common_types.h" @@ -20,6 +22,7 @@ class A64TestEnv : public Dynarmic::A64::UserCallbacks { public: ::Common::unordered_map modified_memory; std::vector code_mem; + std::vector interrupts; u64 ticks_left = 0; u64 code_mem_start_address = 0; bool code_mem_modified_by_guest = false; diff --git a/src/dynarmic/tests/CMakeLists.txt b/src/dynarmic/tests/CMakeLists.txt index d640489933..4e937f36e0 100644 --- a/src/dynarmic/tests/CMakeLists.txt +++ b/src/dynarmic/tests/CMakeLists.txt @@ -72,7 +72,7 @@ add_executable(dynarmic_print_info print_info.cpp ) create_target_directory_groups(dynarmic_print_info) -target_link_libraries(dynarmic_print_info PRIVATE dynarmic fmt::fmt) +target_link_libraries(dynarmic_print_info PRIVATE dynarmic) if (BOOST_NO_HEADERS) target_link_libraries(dynarmic_print_info PRIVATE Boost::variant Boost::icl Boost::pool) else() @@ -80,7 +80,6 @@ else() endif() target_include_directories(dynarmic_print_info PRIVATE . ../src) target_compile_options(dynarmic_print_info PRIVATE ${DYNARMIC_CXX_FLAGS}) -target_compile_definitions(dynarmic_print_info PRIVATE FMT_USE_USER_DEFINED_LITERALS=1) # # dynarmic_test_generator @@ -93,7 +92,7 @@ add_executable(dynarmic_test_generator create_target_directory_groups(dynarmic_test_generator) -target_link_libraries(dynarmic_test_generator PRIVATE dynarmic fmt::fmt) +target_link_libraries(dynarmic_test_generator PRIVATE dynarmic) if (BOOST_NO_HEADERS) target_link_libraries(dynarmic_test_generator PRIVATE Boost::variant Boost::icl Boost::pool) else() @@ -101,7 +100,6 @@ else() endif() target_include_directories(dynarmic_test_generator PRIVATE . ../src) target_compile_options(dynarmic_test_generator PRIVATE ${DYNARMIC_CXX_FLAGS}) -target_compile_definitions(dynarmic_test_generator PRIVATE FMT_USE_USER_DEFINED_LITERALS=1) # # dynarmic_test_reader @@ -110,7 +108,7 @@ add_executable(dynarmic_test_reader test_reader.cpp ) create_target_directory_groups(dynarmic_test_reader) -target_link_libraries(dynarmic_test_reader PRIVATE dynarmic fmt::fmt) +target_link_libraries(dynarmic_test_reader PRIVATE dynarmic) if (BOOST_NO_HEADERS) target_link_libraries(dynarmic_test_reader PRIVATE Boost::variant Boost::icl Boost::pool) else() @@ -118,12 +116,11 @@ else() endif() target_include_directories(dynarmic_test_reader PRIVATE . ../src) target_compile_options(dynarmic_test_reader PRIVATE ${DYNARMIC_CXX_FLAGS}) -target_compile_definitions(dynarmic_test_reader PRIVATE FMT_USE_USER_DEFINED_LITERALS=1) # create_target_directory_groups(dynarmic_tests) -target_link_libraries(dynarmic_tests PRIVATE dynarmic Catch2::Catch2WithMain fmt::fmt) +target_link_libraries(dynarmic_tests PRIVATE dynarmic Catch2::Catch2WithMain) if (BOOST_NO_HEADERS) target_link_libraries(dynarmic_tests PRIVATE Boost::variant Boost::icl Boost::pool) else() @@ -131,7 +128,6 @@ else() endif() target_include_directories(dynarmic_tests PRIVATE . ../src) target_compile_options(dynarmic_tests PRIVATE ${DYNARMIC_CXX_FLAGS}) -target_compile_definitions(dynarmic_tests PRIVATE FMT_USE_USER_DEFINED_LITERALS=1) add_test(NAME dynarmic_tests COMMAND dynarmic_tests --durations yes) if (DYNARMIC_HOST_FEATURE_OVERRIDE AND "x86_64" IN_LIST ARCHITECTURE) diff --git a/src/dynarmic/tests/fuzz_util.cpp b/src/dynarmic/tests/fuzz_util.cpp index 80fdd749ca..c7f5ada687 100644 --- a/src/dynarmic/tests/fuzz_util.cpp +++ b/src/dynarmic/tests/fuzz_util.cpp @@ -10,8 +10,7 @@ #include -#include -#include +#include #include "common/assert.h" #include "dynarmic/tests/rand_int.h" @@ -21,7 +20,7 @@ using namespace Dynarmic; std::ostream& operator<<(std::ostream& o, Vector vec) { - return o << fmt::format("{:016x}'{:016x}", vec[1], vec[0]); + return o << std::format("{:016x}'{:016x}", vec[1], vec[0]); } Vector RandomVector() { diff --git a/src/dynarmic/tests/print_info.cpp b/src/dynarmic/tests/print_info.cpp index 87f4438ad4..364c946006 100644 --- a/src/dynarmic/tests/print_info.cpp +++ b/src/dynarmic/tests/print_info.cpp @@ -13,11 +13,11 @@ #include #include #include +#include #include -#include -#include -#include +#include +#include #include "dynarmic/frontend/A32/translate/translate_callbacks.h" #include "dynarmic/mcl/bit.hpp" #include "common/common_types.h" @@ -58,39 +58,39 @@ std::string_view GetNameOfA64Instruction(u32 instruction) { } void PrintA32Instruction(u32 instruction) { - fmt::print("{:08x} {}\n", instruction, Dynarmic::Common::DisassembleAArch32(false, 0, (u8*)&instruction, sizeof(instruction))); - fmt::print("Name: {}\n", GetNameOfA32Instruction(instruction)); + std::print("{:08x} {}\n", instruction, Dynarmic::Common::DisassembleAArch32(false, 0, (u8*)&instruction, sizeof(instruction))); + std::print("Name: {}\n", GetNameOfA32Instruction(instruction)); const A32::LocationDescriptor location{0, {}, {}}; IR::Block ir_block{location}; const bool should_continue = A32::TranslateSingleInstruction(ir_block, location, instruction); - fmt::print("should_continue: {}\n\n", should_continue); - fmt::print("IR:\n"); - fmt::print("{}\n", IR::DumpBlock(ir_block)); + std::print("should_continue: {}\n\n", should_continue); + std::print("IR:\n"); + std::print("{}\n", IR::DumpBlock(ir_block)); ArmTestEnv jit_env{}; Dynarmic::A32::UserConfig jit_user_config{}; jit_user_config.callbacks = &jit_env; Optimization::Optimize(ir_block, jit_user_config, {}); - fmt::print("Optimized IR:\n"); - fmt::print("{}\n", IR::DumpBlock(ir_block)); + std::print("Optimized IR:\n"); + std::print("{}\n", IR::DumpBlock(ir_block)); } void PrintA64Instruction(u32 instruction) { - fmt::print("{:08x} {}\n", instruction, Dynarmic::Common::DisassembleAArch64(instruction)); - fmt::print("Name: {}\n", GetNameOfA64Instruction(instruction)); + std::print("{:08x} {}\n", instruction, Dynarmic::Common::DisassembleAArch64(instruction)); + std::print("Name: {}\n", GetNameOfA64Instruction(instruction)); const A64::LocationDescriptor location{0, {}}; IR::Block ir_block{location}; const bool should_continue = A64::TranslateSingleInstruction(ir_block, location, instruction); - fmt::print("should_continue: {}\n\n", should_continue); - fmt::print("IR:\n"); - fmt::print("{}\n", IR::DumpBlock(ir_block)); + std::print("should_continue: {}\n\n", should_continue); + std::print("IR:\n"); + std::print("{}\n", IR::DumpBlock(ir_block)); A64TestEnv jit_env{}; Dynarmic::A64::UserConfig jit_user_config{}; jit_user_config.callbacks = &jit_env; Optimization::Optimize(ir_block, jit_user_config, {}); - fmt::print("Optimized IR:\n"); - fmt::print("{}\n", IR::DumpBlock(ir_block)); + std::print("Optimized IR:\n"); + std::print("{}\n", IR::DumpBlock(ir_block)); } void PrintThumbInstruction(u32 instruction) { @@ -98,20 +98,20 @@ void PrintThumbInstruction(u32 instruction) { if (inst_size == 4) instruction = mcl::bit::swap_halves_32(instruction); - fmt::print("{:08x} {}\n", instruction, Dynarmic::Common::DisassembleAArch32(true, 0, (u8*)&instruction, inst_size)); + std::print("{:08x} {}\n", instruction, Dynarmic::Common::DisassembleAArch32(true, 0, (u8*)&instruction, inst_size)); const A32::LocationDescriptor location{0, A32::PSR{0x1F0}, {}}; IR::Block ir_block{location}; const bool should_continue = A32::TranslateSingleInstruction(ir_block, location, instruction); - fmt::print("should_continue: {}\n\n", should_continue); - fmt::print("IR:\n"); - fmt::print("{}\n", IR::DumpBlock(ir_block)); + std::print("should_continue: {}\n\n", should_continue); + std::print("IR:\n"); + std::print("{}\n", IR::DumpBlock(ir_block)); ThumbTestEnv jit_env{}; Dynarmic::A32::UserConfig jit_user_config{}; jit_user_config.callbacks = &jit_env; Optimization::Optimize(ir_block, jit_user_config, {}); - fmt::print("Optimized IR:\n"); - fmt::print("{}\n", IR::DumpBlock(ir_block)); + std::print("Optimized IR:\n"); + std::print("{}\n", IR::DumpBlock(ir_block)); } class ExecEnv final : public Dynarmic::A32::UserCallbacks { @@ -163,10 +163,10 @@ public: } void CallSVC(std::uint32_t swi) override { - fmt::print("> CallSVC({})\n", swi); + std::print("> CallSVC({})\n", swi); } void ExceptionRaised(u32 pc, Dynarmic::A32::Exception exception) override { - fmt::print("> ExceptionRaised({:08x}, {})", pc, static_cast(exception)); + std::print("> ExceptionRaised({:08x}, {})", pc, static_cast(exception)); } void AddTicks(std::uint64_t ticks) override { @@ -194,10 +194,10 @@ void ExecuteA32Instruction(u32 instruction) { const std::map name_map = [®s, &ext_regs, &cpsr, &fpscr] { std::map name_map; for (size_t i = 0; i < regs.size(); i++) { - name_map[fmt::format("r{}", i)] = ®s[i]; + name_map[std::format("r{}", i)] = ®s[i]; } for (size_t i = 0; i < ext_regs.size(); i++) { - name_map[fmt::format("s{}", i)] = &ext_regs[i]; + name_map[std::format("s{}", i)] = &ext_regs[i]; } name_map["sp"] = ®s[13]; name_map["lr"] = ®s[14]; @@ -230,28 +230,28 @@ void ExecuteA32Instruction(u32 instruction) { }; while (std::cin) { - fmt::print("register: "); + std::print("register: "); const std::string reg_name = get_line(); if (const auto iter = name_map.find(reg_name); iter != name_map.end()) { - fmt::print("value: "); + std::print("value: "); if (const auto value = get_value()) { *(iter->second) = *value; - fmt::print("> {} = {:#08x}\n", reg_name, *value); + std::print("> {} = {:#08x}\n", reg_name, *value); } } else if (reg_name.starts_with("m")) { - fmt::print("address: "); + std::print("address: "); if (const auto address = get_value()) { - fmt::print("value: "); + std::print("value: "); if (const auto value = get_value()) { env.MemoryWrite(*address, *value, sizeof(u32)); - fmt::print("> mem[{:#08x}] = {:#08x}\n", *address, *value); + std::print("> mem[{:#08x}] = {:#08x}\n", *address, *value); } } } else if (reg_name == "exit" || reg_name == "end" || reg_name.starts_with("q")) { break; } } - fmt::print("\n\n"); + std::print("\n\n"); cpu.Regs() = regs; cpu.ExtRegs() = ext_regs; @@ -263,34 +263,34 @@ void ExecuteA32Instruction(u32 instruction) { env.MemoryWrite(initial_pc + 4, 0xEAFFFFFE, sizeof(u32)); // B +0 cpu.Run(); - fmt::print("{}", fmt::join(cpu.Disassemble(), "\n")); + std::print("{}", cpu.Disassemble()); - fmt::print("Registers modified:\n"); + std::print("Registers modified:\n"); for (size_t i = 0; i < regs.size(); ++i) { if (regs[i] != cpu.Regs()[i]) { - fmt::print("{:3s}: {:08x}\n", static_cast(i), cpu.Regs()[i]); + std::print("{:3s}: {:08x}\n", static_cast(i), cpu.Regs()[i]); } } for (size_t i = 0; i < ext_regs.size(); ++i) { if (ext_regs[i] != cpu.ExtRegs()[i]) { - fmt::print("{:3s}: {:08x}\n", static_cast(i), cpu.Regs()[i]); + std::print("{:3s}: {:08x}\n", static_cast(i), cpu.Regs()[i]); } } if (cpsr != cpu.Cpsr()) { - fmt::print("cpsr {:08x}\n", cpu.Cpsr()); + std::print("cpsr {:08x}\n", cpu.Cpsr()); } if (fpscr != cpu.Fpscr()) { - fmt::print("fpscr{:08x}\n", cpu.Fpscr()); + std::print("fpscr{:08x}\n", cpu.Fpscr()); } - fmt::print("Modified memory:\n"); + std::print("Modified memory:\n"); for (auto iter = env.memory.begin(); iter != env.memory.end(); ++iter) { - fmt::print("{:08x} {:02x}\n", iter->first, iter->second); + std::print("{:08x} {:02x}\n", iter->first, iter->second); } } int main(int argc, char** argv) { if (argc < 3 || argc > 4) { - fmt::print("usage: {} [-exec]\n", argv[0]); + std::print("usage: {} [-exec]\n", argv[0]); return 1; } @@ -300,7 +300,7 @@ int main(int argc, char** argv) { return s; }(); if (strlen(hex_instruction) > 8) { - fmt::print("hex string too long\n"); + std::print("hex string too long\n"); return 1; } @@ -312,18 +312,18 @@ int main(int argc, char** argv) { } else if (strcmp(argv[1], "t32") == 0 || strcmp(argv[1], "t16") == 0 || strcmp(argv[1], "thumb") == 0) { PrintThumbInstruction(instruction); } else { - fmt::print("Invalid mode: {}\nValid values: a32, a64, thumb\n", argv[1]); + std::print("Invalid mode: {}\nValid values: a32, a64, thumb\n", argv[1]); return 1; } if (argc == 4) { if (strcmp(argv[3], "-exec") != 0) { - fmt::print("Invalid option {}\n", argv[3]); + std::print("Invalid option {}\n", argv[3]); return 1; } if (strcmp(argv[1], "a32") == 0) { ExecuteA32Instruction(instruction); } else { - fmt::print("Executing in this mode not currently supported\n"); + std::print("Executing in this mode not currently supported\n"); return 1; } } diff --git a/src/dynarmic/tests/rsqrt_test.cpp b/src/dynarmic/tests/rsqrt_test.cpp index 5dd52f26da..8ea24d247c 100644 --- a/src/dynarmic/tests/rsqrt_test.cpp +++ b/src/dynarmic/tests/rsqrt_test.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include "common/common_types.h" #include "dynarmic/common/fp/fpcr.h" @@ -46,7 +46,7 @@ void Test(u32 value) { const u32 hack = rsqrt_hack(value); if (expect != full || expect != full_gpr || expect != newton || expect != hack) { - fmt::print("{:08x} = {:08x} : {:08x} : {:08x} : {:08x} : {:08x}\n", value, expect, full, full_gpr, newton, hack); + std::print("{:08x} = {:08x} : {:08x} : {:08x} : {:08x} : {:08x}\n", value, expect, full, full_gpr, newton, hack); REQUIRE(expect == full); REQUIRE(expect == full_gpr); diff --git a/src/dynarmic/tests/test_generator.cpp b/src/dynarmic/tests/test_generator.cpp index 35163fffcf..0cb0a7145d 100644 --- a/src/dynarmic/tests/test_generator.cpp +++ b/src/dynarmic/tests/test_generator.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include "dynarmic/mcl/bit.hpp" #include "common/common_types.h" @@ -40,8 +41,7 @@ #include "dynarmic/ir/opcodes.h" // Must be declared last for all necessary operator<< to be declared prior to this. -#include -#include +#include constexpr bool mask_fpsr_cum_bits = true; @@ -410,27 +410,27 @@ void RunTestInstance(Dynarmic::A32::Jit& jit, const u32 code_mem_size = num_words + static_cast(instructions.size()); if (show_disas) { - fmt::print("instructions:\n"); + std::print("instructions:\n"); auto current_pc = initial_pc; for (auto instruction : instructions) { if constexpr (sizeof(decltype(instruction)) == 2) { - fmt::print("{:04x} ?\n", instruction); + std::print("{:04x} ?\n", static_cast(instruction)); } else { - fmt::print("{}", Dynarmic::Common::DisassembleAArch64(instruction, current_pc)); + std::print("{}", Dynarmic::Common::DisassembleAArch64(instruction, current_pc)); } current_pc += sizeof(decltype(instruction)); } - fmt::print("initial_regs:"); + std::print("initial_regs:"); for (u32 i : regs) - fmt::print(" {:08x}", i); - fmt::print("\n"); - fmt::print("initial_vecs:"); + std::print(" {:08x}", i); + std::print("\n"); + std::print("initial_vecs:"); for (u32 i : vecs) - fmt::print(" {:08x}", i); - fmt::print("\n"); - fmt::print("initial_cpsr: {:08x}\n", cpsr); - fmt::print("initial_fpcr: {:08x}\n", fpscr); + std::print(" {:08x}", i); + std::print("\n"); + std::print("initial_cpsr: {:08x}\n", cpsr); + std::print("initial_fpcr: {:08x}\n", fpscr); } jit.ClearCache(); @@ -453,29 +453,29 @@ void RunTestInstance(Dynarmic::A32::Jit& jit, } if (show_disas) { - fmt::print("final_regs:"); + std::print("final_regs:"); for (u32 i : jit.Regs()) { - fmt::print(" {:08x}", i); + std::print(" {:08x}", i); } - fmt::print("\n"); - fmt::print("final_vecs:"); + std::print("\n"); + std::print("final_vecs:"); for (u32 i : jit.ExtRegs()) { - fmt::print(" {:08x}", i); + std::print(" {:08x}", i); } - fmt::print("\n"); - fmt::print("final_cpsr: {:08x}\n", jit.Cpsr()); - fmt::print("final_fpsr: {:08x}\n", mask_fpsr_cum_bits ? jit.Fpscr() & 0xffffff00 : jit.Fpscr()); - fmt::print("mod_mem: "); + std::print("\n"); + std::print("final_cpsr: {:08x}\n", jit.Cpsr()); + std::print("final_fpsr: {:08x}\n", mask_fpsr_cum_bits ? jit.Fpscr() & 0xffffff00 : jit.Fpscr()); + std::print("mod_mem: "); for (auto [addr, value] : jit_env.modified_memory) { - fmt::print("{:08x}:{:02x} ", addr, value); + std::print("{:08x}:{:02x} ", addr, value); } - fmt::print("\n"); - fmt::print("interrupts:\n"); + std::print("\n"); + std::print("interrupts:\n"); for (const auto& i : jit_env.interrupts) { std::puts(i.c_str()); } - fmt::print("===\n"); - fmt::print("{}", jit.Disassemble()); + std::print("===\n"); + std::print("{}", jit.Disassemble()); } } @@ -526,23 +526,23 @@ void RunTestInstance(Dynarmic::A64::Jit& jit, } if (show_disas) { - fmt::print("instructions:\n"); + std::print("instructions:\n"); auto current_pc = start_address; for (u32 instruction : instructions) { - fmt::print("{}", Dynarmic::Common::DisassembleAArch64(instruction, current_pc)); + std::print("{}", Dynarmic::Common::DisassembleAArch64(instruction, current_pc)); current_pc += 4; } - fmt::print("initial_regs:"); + std::print("initial_regs:"); for (u64 i : regs) - fmt::print(" {:016x}", i); - fmt::print( + std::print(" {:016x}", i); + std::print( "\n" "initial_vecs:" ); for (auto i : vecs) - fmt::print(" {:016x}:{:016x}", i[0], i[1]); - fmt::print( + std::print(" {:016x}:{:016x}", i[0], i[1]); + std::print( "\n" "initial_sp: {:016x}\n" "initial_pstate: {:08x}\n" @@ -553,14 +553,14 @@ void RunTestInstance(Dynarmic::A64::Jit& jit, , fpcr ); for (u64 i : jit.GetRegisters()) - fmt::print(" {:016x}", i); - fmt::print( + std::print(" {:016x}", i); + std::print( "\n" "final_vecs:" ); for (auto i : jit.GetVectors()) - fmt::print(" {:016x}:{:016x}", i[0], i[1]); - fmt::print( + std::print(" {:016x}:{:016x}", i[0], i[1]); + std::print( "\n" "final_sp: {:016x}\n" "final_pc: {:016x}\n" @@ -575,8 +575,8 @@ void RunTestInstance(Dynarmic::A64::Jit& jit, , FP::FPSR{jit.GetFpsr()}.QC() ); for (auto [addr, value] : jit_env.modified_memory) - fmt::print(" {:08x}:{:02x}", addr, value); - fmt::print( + std::print(" {:08x}:{:02x}", addr, value); + std::print( "\n" "===\n" "{}" @@ -682,7 +682,7 @@ static std::optional str2sz(char const* s) { int main(int argc, char* argv[]) { if (argc < 5 || argc > 6) { - fmt::print("Usage: {} [noopt]\n", argv[0]); + std::print("Usage: {} [noopt]\n", argv[0]); return 1; } @@ -693,7 +693,7 @@ int main(int argc, char* argv[]) { const bool show_disas = argc == 6 && (strcmp(argv[5], "disas") == 0); if (!seed || !instruction_count || !iterator_count) { - fmt::print("invalid numeric arguments\n"); + std::print("invalid numeric arguments\n"); return 1; } @@ -706,7 +706,7 @@ int main(int argc, char* argv[]) { } else if (strcmp(argv[1], "a64") == 0) { TestA64(*instruction_count, *iterator_count, noopt, show_disas); } else { - fmt::print("unrecognized instruction class\n"); + std::print("unrecognized instruction class\n"); return 1; } diff --git a/src/dynarmic/tests/test_reader.cpp b/src/dynarmic/tests/test_reader.cpp index d44e698c27..1ebbbb4993 100644 --- a/src/dynarmic/tests/test_reader.cpp +++ b/src/dynarmic/tests/test_reader.cpp @@ -12,7 +12,7 @@ #include #include -#include +#include #include "common/common_types.h" #include "./A32/testenv.h" @@ -58,7 +58,7 @@ u64 ParseHex(std::string_view hex) { } else if (hex.front() == ':') { return result; } else { - fmt::print("Character {} is not a valid hex character\n", hex.front()); + std::print("Character {} is not a valid hex character\n", hex.front()); } hex.remove_prefix(1); } @@ -109,54 +109,54 @@ void RunTestInstance(Dynarmic::A32::Jit& jit, jit.Run(); } - fmt::print("instructions:"); + std::print("instructions:"); for (auto instruction : instructions) { if constexpr (sizeof(decltype(instruction)) == 2) { - fmt::print(" {:04x}", instruction); + std::print(" {:04x}", instruction); } else { - fmt::print(" {:08x}", instruction); + std::print(" {:08x}", instruction); } } - fmt::print("\n"); + std::print("\n"); - fmt::print("initial_regs:"); + std::print("initial_regs:"); for (u32 i : regs) { - fmt::print(" {:08x}", i); + std::print(" {:08x}", i); } - fmt::print("\n"); - fmt::print("initial_vecs:"); + std::print("\n"); + std::print("initial_vecs:"); for (u32 i : vecs) { - fmt::print(" {:08x}", i); + std::print(" {:08x}", i); } - fmt::print("\n"); - fmt::print("initial_cpsr: {:08x}\n", cpsr); - fmt::print("initial_fpcr: {:08x}\n", fpscr); + std::print("\n"); + std::print("initial_cpsr: {:08x}\n", cpsr); + std::print("initial_fpcr: {:08x}\n", fpscr); - fmt::print("final_regs:"); + std::print("final_regs:"); for (u32 i : jit.Regs()) { - fmt::print(" {:08x}", i); + std::print(" {:08x}", i); } - fmt::print("\n"); - fmt::print("final_vecs:"); + std::print("\n"); + std::print("final_vecs:"); for (u32 i : jit.ExtRegs()) { - fmt::print(" {:08x}", i); + std::print(" {:08x}", i); } - fmt::print("\n"); - fmt::print("final_cpsr: {:08x}\n", jit.Cpsr()); - fmt::print("final_fpsr: {:08x}\n", mask_fpsr_cum_bits ? jit.Fpscr() & 0xffffff00 : jit.Fpscr()); + std::print("\n"); + std::print("final_cpsr: {:08x}\n", jit.Cpsr()); + std::print("final_fpsr: {:08x}\n", mask_fpsr_cum_bits ? jit.Fpscr() & 0xffffff00 : jit.Fpscr()); - fmt::print("mod_mem: "); + std::print("mod_mem: "); for (auto [addr, value] : jit_env.modified_memory) { - fmt::print("{:08x}:{:02x} ", addr, value); + std::print("{:08x}:{:02x} ", addr, value); } - fmt::print("\n"); + std::print("\n"); - fmt::print("interrupts:\n"); + std::print("interrupts:\n"); for (const auto& i : jit_env.interrupts) { std::puts(i.c_str()); } - fmt::print("===\n"); + std::print("===\n"); } A64::UserConfig GetA64UserConfig(A64TestEnv& jit_env, bool noopt) { @@ -205,54 +205,54 @@ void RunTestInstance(A64::Jit& jit, jit.Run(); } - fmt::print("instructions:"); + std::print("instructions:"); for (u32 instruction : instructions) { - fmt::print(" {:08x}", instruction); + std::print(" {:08x}", instruction); } - fmt::print("\n"); + std::print("\n"); - fmt::print("initial_regs:"); + std::print("initial_regs:"); for (u64 i : regs) { - fmt::print(" {:016x}", i); + std::print(" {:016x}", i); } - fmt::print("\n"); - fmt::print("initial_vecs:"); + std::print("\n"); + std::print("initial_vecs:"); for (auto i : vecs) { - fmt::print(" {:016x}:{:016x}", i[0], i[1]); + std::print(" {:016x}:{:016x}", i[0], i[1]); } - fmt::print("\n"); - fmt::print("initial_sp: {:016x}\n", initial_sp); - fmt::print("initial_pstate: {:08x}\n", pstate); - fmt::print("initial_fpcr: {:08x}\n", fpcr); + std::print("\n"); + std::print("initial_sp: {:016x}\n", initial_sp); + std::print("initial_pstate: {:08x}\n", pstate); + std::print("initial_fpcr: {:08x}\n", fpcr); - fmt::print("final_regs:"); + std::print("final_regs:"); for (u64 i : jit.GetRegisters()) { - fmt::print(" {:016x}", i); + std::print(" {:016x}", i); } - fmt::print("\n"); - fmt::print("final_vecs:"); + std::print("\n"); + std::print("final_vecs:"); for (auto i : jit.GetVectors()) { - fmt::print(" {:016x}:{:016x}", i[0], i[1]); + std::print(" {:016x}:{:016x}", i[0], i[1]); } - fmt::print("\n"); - fmt::print("final_sp: {:016x}\n", jit.GetSP()); - fmt::print("final_pc: {:016x}\n", jit.GetPC()); - fmt::print("final_pstate: {:08x}\n", jit.GetPstate()); - fmt::print("final_fpcr: {:08x}\n", jit.GetFpcr()); - fmt::print("final_qc : {}\n", FP::FPSR{jit.GetFpsr()}.QC()); + std::print("\n"); + std::print("final_sp: {:016x}\n", jit.GetSP()); + std::print("final_pc: {:016x}\n", jit.GetPC()); + std::print("final_pstate: {:08x}\n", jit.GetPstate()); + std::print("final_fpcr: {:08x}\n", jit.GetFpcr()); + std::print("final_qc : {}\n", FP::FPSR{jit.GetFpsr()}.QC()); - fmt::print("mod_mem:"); + std::print("mod_mem:"); for (auto [addr, value] : jit_env.modified_memory) { - fmt::print(" {:08x}:{:02x}", addr, value); + std::print(" {:08x}:{:02x}", addr, value); } - fmt::print("\n"); + std::print("\n"); - fmt::print("interrupts:\n"); + std::print("interrupts:\n"); for (const auto& i : jit_env.interrupts) { std::puts(i.c_str()); } - fmt::print("===\n"); + std::print("===\n"); } void RunThumb(bool noopt) { @@ -408,7 +408,7 @@ void RunA64(bool noopt) { int main(int argc, char** argv) { if (argc < 2 || argc > 3) { - fmt::print("Usage: {} [noopt]\n", argv[0]); + std::print("Usage: {} [noopt]\n", argv[0]); return 1; } @@ -421,7 +421,7 @@ int main(int argc, char** argv) { } else if (strcmp(argv[1], "a64") == 0) { RunA64(noopt); } else { - fmt::print("unrecognized instruction class\n"); + std::print("unrecognized instruction class\n"); return 1; } diff --git a/src/dynarmic/tests/unicorn_emu/a32_unicorn.cpp b/src/dynarmic/tests/unicorn_emu/a32_unicorn.cpp index 1fe09cdef0..d4c8771f97 100644 --- a/src/dynarmic/tests/unicorn_emu/a32_unicorn.cpp +++ b/src/dynarmic/tests/unicorn_emu/a32_unicorn.cpp @@ -7,12 +7,14 @@ */ #include -#include +#include #include "dynarmic/mcl/bit.hpp" #include "dynarmic/tests/unicorn_emu/a32_unicorn.h" #include "common/assert.h" #include "dynarmic/tests/A32/testenv.h" +#include + #define CHECKED(expr) do if ((expr)) ASSERT(false && "Call " #expr " failed with error\n"); while (0) constexpr u32 BEGIN_ADDRESS = 0; @@ -47,7 +49,7 @@ void A32Unicorn::Run() { return; } if (auto cerr_ = uc_emu_start(uc, pc, END_ADDRESS, 0, 1)) { - fmt::print("uc_emu_start failed @ {:08x} (code = {:08x}) with error {} ({})", pc, *testenv.MemoryReadCode(pc), static_cast(cerr_), uc_strerror(cerr_)); + std::print("uc_emu_start failed @ {:08x} (code = {:08x}) with error {} ({})", pc, *testenv.MemoryReadCode(pc), static_cast(cerr_), uc_strerror(cerr_)); throw "A32Unicorn::Run() failure"; } testenv.ticks_left--; @@ -268,7 +270,7 @@ void A32Unicorn::InterruptHook(uc_engine* /*uc*/, u32 int_numbe this_->testenv.CallSVC(iss); break; default: - this_->testenv.interrupts.emplace_back(fmt::format("Unhandled interrupt: int_number: {:#x}, esr: {:#x} (ec: {:#x}, iss: {:#x})", int_number, esr, ec, iss)); + this_->testenv.interrupts.emplace_back(std::format("Unhandled interrupt: int_number: {:#x}, esr: {:#x} (ec: {:#x}, iss: {:#x})", int_number, esr, ec, iss)); break; } } diff --git a/src/dynarmic/tests/unicorn_emu/a64_unicorn.cpp b/src/dynarmic/tests/unicorn_emu/a64_unicorn.cpp index 4afb6a6859..9b8d4dc5d6 100644 --- a/src/dynarmic/tests/unicorn_emu/a64_unicorn.cpp +++ b/src/dynarmic/tests/unicorn_emu/a64_unicorn.cpp @@ -6,7 +6,7 @@ * SPDX-License-Identifier: 0BSD */ -#include +#include #include "dynarmic/tests/unicorn_emu/a64_unicorn.h" #include "common/assert.h" @@ -177,7 +177,7 @@ void A64Unicorn::InterruptHook(uc_engine* uc, u32 int_number, void* user_data) { this_->testenv.CallSVC(iss); break; default: - this_->testenv.interrupts.emplace_back(fmt::format("Unhandled interrupt: int_number: {:#x}, esr: {:#x} (ec: {:#x}, iss: {:#x})", int_number, esr, ec, iss)); + this_->testenv.interrupts.emplace_back(std::format("Unhandled interrupt: int_number: {:#x}, esr: {:#x} (ec: {:#x}, iss: {:#x})", int_number, esr, ec, iss)); break; } } diff --git a/src/frontend_common/config.cpp b/src/frontend_common/config.cpp index f61192dfae..90c98346f2 100644 --- a/src/frontend_common/config.cpp +++ b/src/frontend_common/config.cpp @@ -29,7 +29,7 @@ Config::Config(const ConfigType config_type) void Config::Initialize(const std::string& config_name) { const std::filesystem::path fs_config_loc = FS::GetEdenPath(FS::EdenPath::ConfigDir); - const auto config_file = fmt::format("{}.ini", config_name); + const auto config_file = std::format("{}.ini", config_name); switch (type) { case ConfigType::GlobalConfig: diff --git a/src/frontend_common/content_manager.h b/src/frontend_common/content_manager.h index 6d79098efa..b1f567723e 100644 --- a/src/frontend_common/content_manager.h +++ b/src/frontend_common/content_manager.h @@ -6,6 +6,8 @@ #pragma once +#include + #include #include "common/common_types.h" #include "common/literals.h" @@ -329,9 +331,9 @@ inline std::vector VerifyInstalledContents( if (title_id > 0) { failed.push_back( - fmt::format("{} ({:016X}) ({})", nca_file->GetName(), title_id, title_name)); + std::format("{} ({:016X}) ({})", nca_file->GetName(), title_id, title_name)); } else { - failed.push_back(fmt::format("{} (unknown)", nca_file->GetName())); + failed.push_back(std::format("{} (unknown)", nca_file->GetName())); } } diff --git a/src/frontend_common/data_manager.cpp b/src/frontend_common/data_manager.cpp index e4e9a32ce1..4d0f8aac88 100644 --- a/src/frontend_common/data_manager.cpp +++ b/src/frontend_common/data_manager.cpp @@ -5,7 +5,8 @@ #include "data_manager.h" #include "common/assert.h" #include "common/fs/path_util.h" -#include +#include +#include namespace FrontendCommon::DataManager { @@ -59,7 +60,7 @@ std::string ReadableBytesSize(u64 size) noexcept { if (size == 0) return "0 B"; auto const digit_groups = std::min(u64(std::log10(size) / std::log10(base)), u64(units.size())); - return fmt::format("{:.1f} {}", size / std::pow(base, digit_groups), units[digit_groups]); + return std::format("{:.1f} {}", size / std::pow(base, digit_groups), units[digit_groups]); } u64 DataDirSize(DataDir dir) diff --git a/src/frontend_common/mod_manager.cpp b/src/frontend_common/mod_manager.cpp index b1adaebf91..4794ac8163 100644 --- a/src/frontend_common/mod_manager.cpp +++ b/src/frontend_common/mod_manager.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include "common/fs/fs.h" #include "common/fs/fs_types.h" #include "common/logging.h" @@ -40,7 +40,7 @@ std::vector GetModFolder(const std::string& root) { } ModInstallResult InstallMod(const std::filesystem::path& path, const u64 program_id, const bool copy) { - const auto program_id_string = fmt::format("{:016X}", program_id); + const auto program_id_string = std::format("{:016X}", program_id); const auto mod_name = path.filename(); const auto mod_dir = DataManager::GetDataDir(DataManager::DataDir::Mods) / program_id_string / mod_name; diff --git a/src/frontend_common/play_time_manager.cpp b/src/frontend_common/play_time_manager.cpp index 3315cd713e..01dbb87336 100644 --- a/src/frontend_common/play_time_manager.cpp +++ b/src/frontend_common/play_time_manager.cpp @@ -13,7 +13,7 @@ #include "core/hle/service/acc/profile_manager.h" #include "play_time_manager.h" -#include +#include #include namespace PlayTime { @@ -167,20 +167,20 @@ void PlayTimeManager::ResetProgramPlayTime(u64 program_id) { } std::string PlayTimeManager::GetReadablePlayTime(u64 t) { - return t > 0 ? fmt::format("{:02}:{:02}:{:02}", t / 3600, (t / 60) % 60, t % 60) + return t > 0 ? std::format("{:02}:{:02}:{:02}", t / 3600, (t / 60) % 60, t % 60) : std::string{}; } std::string PlayTimeManager::GetPlayTimeHours(u64 time_seconds) { - return fmt::format("{}", time_seconds / 3600); + return std::format("{}", time_seconds / 3600); } std::string PlayTimeManager::GetPlayTimeMinutes(u64 time_seconds) { - return fmt::format("{}", (time_seconds % 3600) / 60); + return std::format("{}", (time_seconds % 3600) / 60); } std::string PlayTimeManager::GetPlayTimeSeconds(u64 time_seconds) { - return fmt::format("{}", time_seconds % 60); + return std::format("{}", time_seconds % 60); } } // namespace PlayTime diff --git a/src/hid_core/frontend/emulated_devices.cpp b/src/hid_core/frontend/emulated_devices.cpp index ae3ee31f3d..92bdcec04d 100644 --- a/src/hid_core/frontend/emulated_devices.cpp +++ b/src/hid_core/frontend/emulated_devices.cpp @@ -5,7 +5,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include -#include +#include #include "common/assert.h" #include "hid_core/frontend/emulated_devices.h" diff --git a/src/hid_core/hid_types.h b/src/hid_core/hid_types.h index ae12059a92..5cd7c9d4cc 100644 --- a/src/hid_core/hid_types.h +++ b/src/hid_core/hid_types.h @@ -576,7 +576,8 @@ struct SixAxisSensorCalibrationParameter { }; static_assert(sizeof(SixAxisSensorCalibrationParameter) == 0x744, "SixAxisSensorCalibrationParameter is an invalid size"); -static_assert(std::is_trivial_v, +static_assert(std::is_trivially_default_constructible_v && + std::is_trivially_copyable_v, "SixAxisSensorCalibrationParameter must be trivial."); // This is nn::hid::SixAxisSensorIcInformation @@ -592,7 +593,7 @@ struct SixAxisSensorIcInformation { }; static_assert(sizeof(SixAxisSensorIcInformation) == 0xC8, "SixAxisSensorIcInformation is an invalid size"); -static_assert(std::is_trivial_v, +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v, "SixAxisSensorIcInformation must be trivial."); // This is nn::hid::SixAxisSensorAttribute diff --git a/src/hid_core/irsensor/irs_types.h b/src/hid_core/irsensor/irs_types.h index d7354de21e..27662c8ab5 100644 --- a/src/hid_core/irsensor/irs_types.h +++ b/src/hid_core/irsensor/irs_types.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/input_common/drivers/android.cpp b/src/input_common/drivers/android.cpp index 966abbef94..6225ccbe34 100644 --- a/src/input_common/drivers/android.cpp +++ b/src/input_common/drivers/android.cpp @@ -4,6 +4,7 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later +#include #include #include #include @@ -97,7 +98,7 @@ std::vector Android::GetInputDevices() const { auto name_object = static_cast( env->CallObjectMethod(value, Common::Android::GetYuzuDeviceGetName())); const std::string name = - fmt::format("{} {}", Common::Android::GetJString(env, name_object), key.port); + std::format("{} {}", Common::Android::GetJString(env, name_object), key.port); devices.emplace_back(Common::ParamPackage{ {"engine", GetEngineName()}, {"display", std::move(name)}, diff --git a/src/input_common/drivers/camera.cpp b/src/input_common/drivers/camera.cpp index 11ca756406..94e47405d5 100644 --- a/src/input_common/drivers/camera.cpp +++ b/src/input_common/drivers/camera.cpp @@ -1,7 +1,10 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include +#include #include "common/param_package.h" #include "input_common/drivers/camera.h" diff --git a/src/input_common/drivers/gc_adapter.cpp b/src/input_common/drivers/gc_adapter.cpp index 25df839aa0..f11107130e 100644 --- a/src/input_common/drivers/gc_adapter.cpp +++ b/src/input_common/drivers/gc_adapter.cpp @@ -4,7 +4,7 @@ // SPDX-FileCopyrightText: 2014 Dolphin Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include +#include #include #include "common/logging.h" @@ -407,7 +407,7 @@ std::vector GCAdapter::GetInputDevices() const { } Common::ParamPackage identifier{}; identifier.Set("engine", GetEngineName()); - identifier.Set("display", fmt::format("Gamecube Controller {}", port + 1)); + identifier.Set("display", std::format("Gamecube Controller {}", port + 1)); identifier.Set("port", static_cast(port)); devices.emplace_back(identifier); } diff --git a/src/input_common/drivers/joycon.cpp b/src/input_common/drivers/joycon.cpp index ded92d3f1d..09abd502b0 100644 --- a/src/input_common/drivers/joycon.cpp +++ b/src/input_common/drivers/joycon.cpp @@ -4,7 +4,7 @@ // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include +#include #include "common/param_package.h" #include @@ -595,7 +595,7 @@ std::vector Joycons::GetInputDevices() const { return; } auto param = GetParamPackage(device->GetDevicePort(), device->GetHandleDeviceType()); - std::string name = fmt::format("{} {}", JoyconName(device->GetHandleDeviceType()), + std::string name = std::format("{} {}", JoyconName(device->GetHandleDeviceType()), device->GetDevicePort() + 1); param.Set("display", std::move(name)); devices.emplace_back(param); @@ -622,7 +622,7 @@ std::vector Joycons::GetInputDevices() const { auto main_param = GetParamPackage(i, left_joycons[i]->GetHandleDeviceType()); const auto second_param = GetParamPackage(i, right_joycons[i]->GetHandleDeviceType()); const auto type = Joycon::ControllerType::Dual; - std::string name = fmt::format("{} {}", JoyconName(type), i + 1); + std::string name = std::format("{} {}", JoyconName(type), i + 1); main_param.Set("display", std::move(name)); main_param.Set("guid2", second_param.Get("guid", "")); diff --git a/src/input_common/drivers/mouse.cpp b/src/input_common/drivers/mouse.cpp index 4ac259d03b..e4094e9395 100644 --- a/src/input_common/drivers/mouse.cpp +++ b/src/input_common/drivers/mouse.cpp @@ -5,7 +5,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include -#include +#include #include #include "common/param_package.h" diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp index 588d7fa8cd..cd32d865f5 100644 --- a/src/input_common/drivers/sdl_driver.cpp +++ b/src/input_common/drivers/sdl_driver.cpp @@ -754,7 +754,7 @@ void LogMotionHardware() { mount = read_line(dir / "in_accel_mount_matrix"); } const fs::path device = fs::canonical(dir / "device", ignored); - sensors += fmt::format("\n {} name={} gyro={} accel={} mount=[{}] at={}", + sensors += std::format("\n {} name={} gyro={} accel={} mount=[{}] at={}", dir.filename().string(), read_line(dir / "name"), gyro, accel, mount, ignored ? std::string{"?"} : device.string()); } @@ -775,13 +775,13 @@ void LogMotionHardware() { // bus:vendor:product, each zero-padded to 8 hex digits unsigned bus = 0, vendor = 0, product = 0; if (std::sscanf(line.c_str() + 7, "%x:%x:%x", &bus, &vendor, &product) == 3) { - id = fmt::format("{:04x}:{:04x} bus={}", vendor, product, bus); + id = std::format("{:04x}:{:04x} bus={}", vendor, product, bus); } } else if (line.starts_with("HID_NAME=")) { name = line.substr(9); } } - hid += fmt::format("\n {} {} name={}", entry.path().filename().string(), id, name); + hid += std::format("\n {} {} name={}", entry.path().filename().string(), id, name); } LOG_INFO(Input, "HID devices:{}", hid.empty() ? std::string{" none"} : hid); #endif @@ -959,7 +959,7 @@ std::vector SDLDriver::GetInputDevices() const { continue; } const std::string name = - fmt::format("{} {}{}", joystick->GetControllerName(), joystick->GetPort(), + std::format("{} {}{}", joystick->GetControllerName(), joystick->GetPort(), steam_virtual ? " (Steam)" : ""); devices.emplace_back(Common::ParamPackage{ {"engine", GetEngineName()}, @@ -984,7 +984,7 @@ std::vector SDLDriver::GetInputDevices() const { const auto joystick2 = joycon_pairs.at(joystick->GetPort()); const std::string name = - fmt::format("{} {}", "Nintendo Dual Joy-Con", joystick->GetPort()); + std::format("{} {}", "Nintendo Dual Joy-Con", joystick->GetPort()); devices.emplace_back(Common::ParamPackage{ {"engine", GetEngineName()}, {"display", std::move(name)}, diff --git a/src/input_common/drivers/tas_input.cpp b/src/input_common/drivers/tas_input.cpp index 32febc0839..9e150e6d40 100644 --- a/src/input_common/drivers/tas_input.cpp +++ b/src/input_common/drivers/tas_input.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include "common/fs/file.h" #include "common/fs/fs_types.h" @@ -86,7 +86,7 @@ void Tas::LoadTasFile(size_t player_index, size_t file_index) { std::string file = Common::FS::ReadStringFromFile( Common::FS::GetEdenPath(Common::FS::EdenPath::TASDir) / - fmt::format("script{}-{}.txt", file_index, player_index + 1), + std::format("script{}-{}.txt", file_index, player_index + 1), Common::FS::FileType::BinaryFile); std::istringstream command_line(file); std::string line; @@ -136,7 +136,7 @@ void Tas::WriteTasFile(std::u8string_view file_name) { std::string output_text; for (size_t frame = 0; frame < record_commands.size(); frame++) { const TASCommand& line = record_commands[frame]; - output_text += fmt::format("{} {} {} {}\n", frame, WriteCommandButtons(line.buttons), + output_text += std::format("{} {} {} {}\n", frame, WriteCommandButtons(line.buttons), WriteCommandAxis(line.l_axis), WriteCommandAxis(line.r_axis)); } @@ -285,14 +285,14 @@ std::string Tas::WriteCommandButtons(u64 buttons) const { std::string returns; for (const auto& [text_button, tas_button] : text_to_tas_button) { if ((buttons & static_cast(tas_button)) != 0) { - returns += fmt::format("{};", text_button); + returns += std::format("{};", text_button); } } return returns.empty() ? "NONE" : returns; } std::string Tas::WriteCommandAxis(TasAnalog analog) const { - return fmt::format("{};{}", analog.x * 32767, analog.y * 32767); + return std::format("{};{}", analog.x * 32767, analog.y * 32767); } void Tas::SetTasAxis(const PadIdentifier& identifier, TasAxis axis, f32 value) { diff --git a/src/input_common/drivers/udp_client.cpp b/src/input_common/drivers/udp_client.cpp index 620e0cf630..2e8cd1185c 100644 --- a/src/input_common/drivers/udp_client.cpp +++ b/src/input_common/drivers/udp_client.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include "common/logging.h" #include "common/param_package.h" @@ -365,7 +365,7 @@ Common::UUID UDPClient::GetHostUUID(const std::string& host) const { LOG_ERROR(Input, "Invalid IPv4 address \"{}\" provided", host); ip = boost::asio::ip::address_v4{}; } - auto const hex_host = fmt::format("00000000-0000-0000-0000-0000{:06x}", ip.to_uint()); + auto const hex_host = std::format("00000000-0000-0000-0000-0000{:06x}", ip.to_uint()); return Common::UUID{hex_host}; } @@ -396,7 +396,7 @@ std::vector UDPClient::GetInputDevices() const { const auto pad_identifier = GetPadIdentifier(pad_index); Common::ParamPackage identifier{}; identifier.Set("engine", GetEngineName()); - identifier.Set("display", fmt::format("UDP Controller {}", pad_identifier.pad)); + identifier.Set("display", std::format("UDP Controller {}", pad_identifier.pad)); identifier.Set("guid", pad_identifier.guid.RawString()); identifier.Set("port", static_cast(pad_identifier.port)); identifier.Set("pad", static_cast(pad_identifier.pad)); diff --git a/src/input_common/drivers/virtual_amiibo.cpp b/src/input_common/drivers/virtual_amiibo.cpp index ccb740d158..d5b9b62712 100644 --- a/src/input_common/drivers/virtual_amiibo.cpp +++ b/src/input_common/drivers/virtual_amiibo.cpp @@ -5,7 +5,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include -#include +#include #include "common/fs/file.h" #include "common/fs/fs.h" diff --git a/src/input_common/helpers/joycon_protocol/nfc.cpp b/src/input_common/helpers/joycon_protocol/nfc.cpp index b71d0e8148..8e995e6ab3 100644 --- a/src/input_common/helpers/joycon_protocol/nfc.cpp +++ b/src/input_common/helpers/joycon_protocol/nfc.cpp @@ -142,7 +142,7 @@ Common::Input::DriverResult NfcProtocol::GetTagInfo(Joycon::TagInfo& tag_info) { std::string uuid_string; for (auto& content : tag_data.uuid) { - uuid_string += fmt::format(" {:02x}", content); + uuid_string += std::format(" {:02x}", content); } LOG_INFO(Input, "Tag detected, type={}, uuid={}", tag_data.type, uuid_string); } diff --git a/src/network/room.cpp b/src/network/room.cpp index 66a9dba807..8afe4eb8e4 100644 --- a/src/network/room.cpp +++ b/src/network/room.cpp @@ -751,7 +751,7 @@ void Room::RoomImpl::SendStatusMessage(StatusMessageTypes type, const std::strin enet_host_flush(server); const std::string display_name = - username.empty() ? nickname : fmt::format("{} ({})", nickname, username); + username.empty() ? nickname : std::format("{} ({})", nickname, username); switch (type) { case IdMemberJoin: @@ -1000,7 +1000,7 @@ void Room::RoomImpl::HandleGameInfoPacket(const ENetEvent* event) { const std::string display_name = member->user_data.username.empty() ? member->nickname - : fmt::format("{} ({})", member->nickname, member->user_data.username); + : std::format("{} ({})", member->nickname, member->user_data.username); if (game_info.name.empty()) { LOG_INFO(Network, "{} is not playing", display_name); diff --git a/src/qt_common/game_list/game_list_p.h b/src/qt_common/game_list/game_list_p.h index d113f4ee75..22dcbd06fa 100644 --- a/src/qt_common/game_list/game_list_p.h +++ b/src/qt_common/game_list/game_list_p.h @@ -7,6 +7,7 @@ #pragma once #include +#include #include #include #include @@ -136,7 +137,7 @@ public: const std::array row_data{{ QString::fromStdString(filename), data(FileTypeRole).toString(), - QString::fromStdString(fmt::format("{:#016x}", data(ProgramIdRole).toULongLong())), + QString::fromStdString(std::format("{:#016x}", data(ProgramIdRole).toULongLong())), data(TitleRole).toString(), }}; diff --git a/src/qt_common/game_list/worker.cpp b/src/qt_common/game_list/worker.cpp index 6b6f93447d..ad935ecfcd 100644 --- a/src/qt_common/game_list/worker.cpp +++ b/src/qt_common/game_list/worker.cpp @@ -47,7 +47,7 @@ QString GetGameListCachedObject(const std::string& filename, const std::string& const auto path = Common::FS::PathToUTF8String(Common::FS::GetEdenPath(Common::FS::EdenPath::CacheDir) / - "game_list" / fmt::format("{}.{}", filename, ext)); + "game_list" / std::format("{}.{}", filename, ext)); void(Common::FS::CreateParentDirs(path)); @@ -79,8 +79,8 @@ std::pair, std::string> GetGameListCachedObject( const auto game_list_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::CacheDir) / "game_list"; - const auto jpeg_name = fmt::format("{}.jpeg", filename); - const auto app_name = fmt::format("{}.appname.txt", filename); + const auto jpeg_name = std::format("{}.jpeg", filename); + const auto app_name = std::format("{}.appname.txt", filename); const auto path1 = Common::FS::PathToUTF8String(game_list_dir / jpeg_name); const auto path2 = Common::FS::PathToUTF8String(game_list_dir / app_name); @@ -141,7 +141,7 @@ std::pair, std::string> GetGameListCachedObject( void GetMetadataFromControlNCA(const FileSys::PatchManager& patch_manager, const FileSys::NCA& nca, std::vector& icon, std::string& name) { std::tie(icon, name) = GetGameListCachedObject( - fmt::format("{:016X}", patch_manager.GetTitleID()), {}, [&patch_manager, &nca] { + std::format("{:016X}", patch_manager.GetTitleID()), {}, [&patch_manager, &nca] { const auto [nacp, icon_f] = patch_manager.ParseControlNCA(nca); return std::make_pair(icon_f->ReadAllBytes(), nacp->GetApplicationName()); }); @@ -208,7 +208,7 @@ QList MakeGameListEntry(const std::string& path, const std::stri auto const file_type_string = QString::fromStdString(Loader::GetFileTypeString(file_type)); QString patch_versions = GetGameListCachedObject( - fmt::format("{:016X}", patch.GetTitleID()), "pv.txt", [&patch, &loader] { + std::format("{:016X}", patch.GetTitleID()), "pv.txt", [&patch, &loader] { return FormatPatchNameVersions(patch, loader, loader.IsRomFSUpdatable()); }); diff --git a/src/qt_common/qt_common.cpp b/src/qt_common/qt_common.cpp index eff63a37d5..2854a9418e 100644 --- a/src/qt_common/qt_common.cpp +++ b/src/qt_common/qt_common.cpp @@ -26,6 +26,7 @@ #include +#include #include #include @@ -231,9 +232,9 @@ void Init(QWidget* root) { const auto description = std::string(Common::g_scm_desc); const auto build_id = std::string(Common::g_build_id); - const auto yuzu_build = fmt::format("Eden Development Build | {}-{}", branch_name, description); - const auto override_build = - fmt::format(fmt::runtime(std::string(Common::g_title_bar_format_idle)), build_id); + const auto yuzu_build = std::format("Eden Development Build | {}-{}", branch_name, description); + const auto override_build = std::vformat(std::string_view(Common::g_title_bar_format_idle), + std::make_format_args(build_id)); const auto yuzu_build_version = override_build.empty() ? yuzu_build : override_build; const auto processor_count = std::thread::hardware_concurrency(); diff --git a/src/qt_common/util/content.cpp b/src/qt_common/util/content.cpp index 2838cd854e..11e82bd743 100644 --- a/src/qt_common/util/content.cpp +++ b/src/qt_common/util/content.cpp @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later +#include #include "core/file_sys/card_image.h" #include "qt_common/util/content.h" #include "qt_common/util/game.h" @@ -158,12 +159,17 @@ void InstallFirmware(const QString& location, bool recursive) { VerifyFirmwareCallback, true); if (results.size() > 0) { - const auto failed_names = - QString::fromStdString(fmt::format("{}", fmt::join(results, "\n"))); + std::string failed_names; + for (const auto& r : results) { + if (!failed_names.empty()) { + failed_names += '\n'; + } + failed_names += r; + } progress->close(); QtCommon::Frontend::Critical( tr("Firmware integrity verification failed!"), - tr("Verification failed for the following files:\n\n%1").arg(failed_names)); + tr("Verification failed for the following files:\n\n%1").arg(QString::fromStdString(failed_names))); return; } @@ -281,11 +287,17 @@ void VerifyInstalledContents() { QtCommon::Frontend::Information(tr("Integrity verification succeeded!"), tr("The operation completed successfully.")); } else { - const auto failed_names = - QString::fromStdString(fmt::format("{}", fmt::join(result, "\n"))); + std::string failed_names; + for (const auto& r : result) { + if (!failed_names.empty()) { + failed_names += '\n'; + } + failed_names += r; + } + QtCommon::Frontend::Critical( tr("Integrity verification failed!"), - tr("Verification failed for the following files:\n\n%1").arg(failed_names)); + tr("Verification failed for the following files:\n\n%1").arg(QString::fromStdString(failed_names))); } } diff --git a/src/qt_common/util/game.cpp b/src/qt_common/util/game.cpp index ddbe979765..eb84ebfd40 100644 --- a/src/qt_common/util/game.cpp +++ b/src/qt_common/util/game.cpp @@ -16,6 +16,8 @@ #include #include +#include + #ifdef _WIN32 #include #include @@ -24,7 +26,6 @@ #include "common/fs/file.h" #else #include -#include "fmt/ostream.h" #endif namespace QtCommon::Game { @@ -105,24 +106,24 @@ bool CreateShortcutLink(const std::filesystem::path& shortcut_path, const std::s LOG_ERROR(Frontend, "Failed to create shortcut"); return false; } - // TODO: Migrate fmt::print to std::print in futures STD C++ 23. - fmt::print(shortcut_stream, "[Desktop Entry]\n"); - fmt::print(shortcut_stream, "Type=Application\n"); - fmt::print(shortcut_stream, "Version=1.0\n"); - fmt::print(shortcut_stream, "Name={}\n", name); + + std::print(shortcut_stream, "[Desktop Entry]\n"); + std::print(shortcut_stream, "Type=Application\n"); + std::print(shortcut_stream, "Version=1.0\n"); + std::print(shortcut_stream, "Name={}\n", name); if (!comment.empty()) { - fmt::print(shortcut_stream, "Comment={}\n", comment); + std::print(shortcut_stream, "Comment={}\n", comment); } if (std::filesystem::is_regular_file(icon_path)) { - fmt::print(shortcut_stream, "Icon={}\n", icon_path.string()); + std::print(shortcut_stream, "Icon={}\n", icon_path.string()); } - fmt::print(shortcut_stream, "TryExec={}\n", command.string()); - fmt::print(shortcut_stream, "Exec={} {}\n", command.string(), arguments); + std::print(shortcut_stream, "TryExec={}\n", command.string()); + std::print(shortcut_stream, "Exec={} {}\n", command.string(), arguments); if (!categories.empty()) { - fmt::print(shortcut_stream, "Categories={}\n", categories); + std::print(shortcut_stream, "Categories={}\n", categories); } if (!keywords.empty()) { - fmt::print(shortcut_stream, "Keywords={}\n", keywords); + std::print(shortcut_stream, "Keywords={}\n", keywords); } return true; #else // Unsupported platform @@ -150,8 +151,8 @@ bool MakeShortcutIcoPath(const u64 program_id, const std::string_view game_file_ } // Create icon file path - out_icon_path /= (program_id == 0 ? fmt::format("eden-{}.{}", game_file_name, ico_extension) - : fmt::format("eden-{:016X}.{}", program_id, ico_extension)); + out_icon_path /= (program_id == 0 ? std::format("eden-{}.{}", game_file_name, ico_extension) + : std::format("eden-{:016X}.{}", program_id, ico_extension)); return true; } @@ -251,7 +252,7 @@ void RemoveTransferableShaderCache(u64 program_id, GameListRemoveTarget target) } }(); const auto shader_cache_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::ShaderDir); - const auto shader_cache_folder_path = shader_cache_dir / fmt::format("{:016x}", program_id); + const auto shader_cache_folder_path = shader_cache_dir / std::format("{:016x}", program_id); const auto target_file = shader_cache_folder_path / target_file_name; if (!Common::FS::Exists(target_file)) { @@ -272,7 +273,7 @@ void RemoveVulkanDriverPipelineCache(u64 program_id) { static constexpr std::string_view target_file_name = "vulkan_pipelines.bin"; const auto shader_cache_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::ShaderDir); - const auto shader_cache_folder_path = shader_cache_dir / fmt::format("{:016x}", program_id); + const auto shader_cache_folder_path = shader_cache_dir / std::format("{:016x}", program_id); const auto target_file = shader_cache_folder_path / target_file_name; if (!Common::FS::Exists(target_file)) { @@ -286,7 +287,7 @@ void RemoveVulkanDriverPipelineCache(u64 program_id) { void RemoveAllTransferableShaderCaches(u64 program_id) { const auto shader_cache_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::ShaderDir); - const auto program_shader_cache_dir = shader_cache_dir / fmt::format("{:016x}", program_id); + const auto program_shader_cache_dir = shader_cache_dir / std::format("{:016x}", program_id); if (!Common::FS::Exists(program_shader_cache_dir)) { QtCommon::Frontend::Warning(tr("Error Removing Transferable Shader Caches"), @@ -308,7 +309,7 @@ void RemoveCustomConfiguration(u64 program_id, const std::string& game_path) { const auto file_path = std::filesystem::path(Common::FS::ToU8String(game_path)); const auto config_file_name = program_id == 0 ? Common::FS::PathToUTF8String(file_path.filename()).append(".ini") - : fmt::format("{:016X}.ini", program_id); + : std::format("{:016X}.ini", program_id); const auto custom_config_file_path = Common::FS::GetEdenPath(Common::FS::EdenPath::ConfigDir) / "custom" / config_file_name; @@ -427,7 +428,7 @@ void CreateShortcut(const std::string& game_path, const u64 program_id, // Delete illegal characters from title if (needs_title) { - game_title = fmt::format("{:016X}", program_id); + game_title = std::format("{:016X}", program_id); if (control.first != nullptr) { game_title = control.first->GetApplicationName(); } else { @@ -482,7 +483,7 @@ void CreateShortcut(const std::string& game_path, const u64 program_id, if (CreateShortcutMessagesGUI(ShortcutMessages::Fullscreen, qgame_title)) { arguments = "-f " + arguments; } - const std::string comment = fmt::format("Start {:s} with the Eden Emulator", game_title); + const std::string comment = std::format("Start {:s} with the Eden Emulator", game_title); const std::string categories = "Game;Emulator;Qt;"; const std::string keywords = "Switch;Nintendo;"; diff --git a/src/qt_common/util/path.cpp b/src/qt_common/util/path.cpp index a99d3b03ea..b798cc51df 100644 --- a/src/qt_common/util/path.cpp +++ b/src/qt_common/util/path.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include "common/fs/fs.h" #include "common/fs/path_util.h" #include "qt_common/abstract/frontend.h" @@ -14,7 +14,7 @@ namespace QtCommon::Path { bool OpenShaderCache(u64 program_id, QObject* parent) { const auto shader_cache_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::ShaderDir); - const auto shader_cache_folder_path{shader_cache_dir / fmt::format("{:016x}", program_id)}; + const auto shader_cache_folder_path{shader_cache_dir / std::format("{:016x}", program_id)}; if (!Common::FS::CreateDirs(shader_cache_folder_path)) { QtCommon::Frontend::Warning(tr("Error Opening Shader Cache"), tr("Failed to create or open shader cache for this title, " diff --git a/src/qt_common/util/vk.cpp b/src/qt_common/util/vk.cpp index 8ca7f4a665..deaa907fc0 100644 --- a/src/qt_common/util/vk.cpp +++ b/src/qt_common/util/vk.cpp @@ -70,7 +70,7 @@ void PopulateRecords(std::vector& records, QWindow* window) try { if (driver_string.empty()) driver_string = "Unknown"; - name = fmt::format("{} ({})", name, driver_string); + name = std::format("{} ({})", name, driver_string); records.push_back(VkDeviceInfo::Record(name, present_modes, has_broken_compute)); } diff --git a/src/shader_recompiler/CMakeLists.txt b/src/shader_recompiler/CMakeLists.txt index cc9ce95d92..95cb888f93 100644 --- a/src/shader_recompiler/CMakeLists.txt +++ b/src/shader_recompiler/CMakeLists.txt @@ -246,7 +246,7 @@ if (ENABLE_OPENGL) backend/glsl/var_alloc.h) endif() -target_link_libraries(shader_recompiler PUBLIC common fmt::fmt sirit::sirit) +target_link_libraries(shader_recompiler PUBLIC common sirit::sirit) if (MSVC) target_compile_options(shader_recompiler PRIVATE diff --git a/src/shader_recompiler/backend/glasm/emit_glasm.cpp b/src/shader_recompiler/backend/glasm/emit_glasm.cpp index b795c01797..9c029a2ba8 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm.cpp @@ -1,7 +1,11 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include +#include #include #include @@ -407,10 +411,10 @@ std::string EmitGLASM(const Profile& profile, const RuntimeInfo& runtime_info, I SetupOptions(program, profile, runtime_info, header); switch (program.stage) { case Stage::TessellationControl: - header += fmt::format("VERTICES_OUT {};", program.invocations); + header += std::format("VERTICES_OUT {};", program.invocations); break; case Stage::TessellationEval: - header += fmt::format("TESS_MODE {};" + header += std::format("TESS_MODE {};" "TESS_SPACING {};" "TESS_VERTEX_ORDER {};", GetTessMode(runtime_info.tess_primitive), @@ -418,12 +422,12 @@ std::string EmitGLASM(const Profile& profile, const RuntimeInfo& runtime_info, I runtime_info.tess_clockwise ? "CW" : "CCW"); break; case Stage::Geometry: - header += fmt::format("PRIMITIVE_IN {};", InputPrimitive(runtime_info.input_topology)); + header += std::format("PRIMITIVE_IN {};", InputPrimitive(runtime_info.input_topology)); if (program.is_geometry_passthrough) { if (profile.support_geometry_shader_passthrough) { for (size_t index = 0; index < IR::NUM_GENERICS; ++index) { if (program.info.passthrough.Generic(index)) { - header += fmt::format("PASSTHROUGH result.attrib[{}];", index); + header += std::format("PASSTHROUGH result.attrib[{}];", index); } } if (program.info.passthrough.AnyComponent(IR::Attribute::PositionX)) { @@ -434,21 +438,21 @@ std::string EmitGLASM(const Profile& profile, const RuntimeInfo& runtime_info, I } } else { header += - fmt::format("VERTICES_OUT {};" + std::format("VERTICES_OUT {};" "PRIMITIVE_OUT {};", program.output_vertices, OutputPrimitive(program.output_topology)); } break; case Stage::Compute: - header += fmt::format("GROUP_SIZE {} {} {};", program.workgroup_size[0], + header += std::format("GROUP_SIZE {} {} {};", program.workgroup_size[0], program.workgroup_size[1], program.workgroup_size[2]); break; default: break; } if (program.shared_memory_size > 0) { - header += fmt::format("SHARED_MEMORY {};", program.shared_memory_size); - header += fmt::format("SHARED shared_mem[]={{program.sharedmem}};"); + header += std::format("SHARED_MEMORY {};", program.shared_memory_size); + header += std::format("SHARED shared_mem[]={{program.sharedmem}};"); } if (program.info.uses_rescaling_uniform) { header += "PARAM scaling[1]={program.local[0..0]};"; @@ -458,22 +462,22 @@ std::string EmitGLASM(const Profile& profile, const RuntimeInfo& runtime_info, I } header += "TEMP "; for (size_t index = 0; index < ctx.reg_alloc.NumUsedRegisters(); ++index) { - header += fmt::format("R{},", index); + header += std::format("R{},", index); } if (program.local_memory_size > 0) { - header += fmt::format("lmem[{}],", Common::DivCeil(program.local_memory_size, 4U)); + header += std::format("lmem[{}],", Common::DivCeil(program.local_memory_size, 4U)); } if (program.info.uses_fswzadd) { header += "FSWZA[4],FSWZB[4],"; } const u32 num_safety_loop_vectors{Common::DivCeil(ctx.num_safety_loop_vars, 4u)}; for (u32 index = 0; index < num_safety_loop_vectors; ++index) { - header += fmt::format("loop{},", index); + header += std::format("loop{},", index); } header += "RC;" "LONG TEMP "; for (size_t index = 0; index < ctx.reg_alloc.NumUsedLongRegisters(); ++index) { - header += fmt::format("D{},", index); + header += std::format("D{},", index); } header += "DC;"; if (program.info.uses_fswzadd) { @@ -487,7 +491,7 @@ std::string EmitGLASM(const Profile& profile, const RuntimeInfo& runtime_info, I "MOV.F FSWZB[3],-1;"; } for (u32 index = 0; index < num_safety_loop_vectors; ++index) { - header += fmt::format("MOV.S loop{},{{0x2000,0x2000,0x2000,0x2000}};", index); + header += std::format("MOV.S loop{},{{0x2000,0x2000,0x2000,0x2000}};", index); } if (ctx.uses_y_direction) { header += "PARAM y_direction[1]={state.material.front.ambient};"; diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_composite.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_composite.cpp index 4e8ba4ae65..ead5c665f1 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_composite.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm_composite.cpp @@ -1,6 +1,10 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include #include "shader_recompiler/backend/glasm/emit_glasm_instructions.h" #include "shader_recompiler/backend/glasm/glasm_emit_context.h" #include "shader_recompiler/frontend/ir/value.h" @@ -14,8 +18,8 @@ void CompositeConstruct(EmitContext& ctx, IR::Inst& inst, Values&&... elements) [](const IR::Value& value) { return value.IsImmediate(); })) { using Type = std::invoke_result_t; const std::array values{(elements.IsImmediate() ? (elements.*read_imm)() : 0)...}; - ctx.Add("MOV.{} {},{{{},{},{},{}}};", type, ret, fmt::to_string(values[0]), - fmt::to_string(values[1]), fmt::to_string(values[2]), fmt::to_string(values[3])); + ctx.Add("MOV.{} {},{{{},{},{},{}}};", type, ret, std::format("{}", values[0]), + std::format("{}", values[1]), std::format("{}", values[2]), std::format("{}", values[3])); } size_t index{}; for (const IR::Value& element : {elements...}) { diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp index 47babcdc07..b3751b9fd6 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp @@ -1,6 +1,10 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include #include #include "shader_recompiler/backend/glasm/emit_glasm_instructions.h" @@ -51,7 +55,7 @@ bool IsInputArray(Stage stage) { } std::string VertexIndex(EmitContext& ctx, ScalarU32 vertex) { - return IsInputArray(ctx.stage) ? fmt::format("[{}]", vertex) : ""; + return IsInputArray(ctx.stage) ? std::format("[{}]", vertex) : ""; } u32 TexCoordIndex(IR::Attribute attr) { @@ -311,23 +315,23 @@ void EmitGetAttributeIndexed(EmitContext& ctx, IR::Inst& inst, ScalarS32 offset, compare_index, ret, values[0], ret, values[1], ret, values[2], ret, values[3]); }}; const auto read_swizzled{[&](u32 compare_index, std::string_view value) { - const std::array values{fmt::format("{}.x", value), fmt::format("{}.y", value), - fmt::format("{}.z", value), fmt::format("{}.w", value)}; + const std::array values{std::format("{}.x", value), std::format("{}.y", value), + std::format("{}.z", value), std::format("{}.w", value)}; read(compare_index, values); }}; if (ctx.info.loads.AnyComponent(IR::Attribute::PositionX)) { const u32 index{static_cast(IR::Attribute::PositionX)}; if (IsInputArray(ctx.stage)) { - read_swizzled(index, fmt::format("vertex_position{}", VertexIndex(ctx, vertex))); + read_swizzled(index, std::format("vertex_position{}", VertexIndex(ctx, vertex))); } else { - read_swizzled(index, fmt::format("{}.position", ctx.attrib_name)); + read_swizzled(index, std::format("{}.position", ctx.attrib_name)); } } for (u32 index = 0; index < static_cast(IR::NUM_GENERICS); ++index) { if (!ctx.info.loads.Generic(index)) { continue; } - read_swizzled(index, fmt::format("in_attr{}{}[0]", index, VertexIndex(ctx, vertex))); + read_swizzled(index, std::format("in_attr{}{}[0]", index, VertexIndex(ctx, vertex))); } for (u32 i = 0; i < num_endifs; ++i) { ctx.Add("ENDIF;"); diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp index 64e7bad75e..14550ff6d7 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm_image.cpp @@ -1,6 +1,10 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include #include #include "shader_recompiler/backend/glasm/emit_glasm_instructions.h" @@ -43,9 +47,9 @@ std::string Texture(EmitContext& ctx, IR::TextureInstInfo info, [[maybe_unused]] const IR::Value& index) { // FIXME: indexed reads if (info.type == TextureType::Buffer) { - return fmt::format("texture[{}]", ctx.texture_buffer_bindings.at(info.descriptor_index)); + return std::format("texture[{}]", ctx.texture_buffer_bindings.at(info.descriptor_index)); } else { - return fmt::format("texture[{}]", ctx.texture_bindings.at(info.descriptor_index)); + return std::format("texture[{}]", ctx.texture_bindings.at(info.descriptor_index)); } } @@ -53,9 +57,9 @@ std::string Image(EmitContext& ctx, IR::TextureInstInfo info, [[maybe_unused]] const IR::Value& index) { // FIXME: indexed reads if (info.type == TextureType::Buffer) { - return fmt::format("image[{}]", ctx.image_buffer_bindings.at(info.descriptor_index)); + return std::format("image[{}]", ctx.image_buffer_bindings.at(info.descriptor_index)); } else { - return fmt::format("image[{}]", ctx.image_bindings.at(info.descriptor_index)); + return std::format("image[{}]", ctx.image_bindings.at(info.descriptor_index)); } } @@ -115,7 +119,7 @@ std::string Offset(EmitContext& ctx, const IR::Value& offset) { if (offset.IsEmpty()) { return ""; } - return fmt::format(",offset({})", Register{ctx.reg_alloc.Consume(offset)}); + return std::format(",offset({})", Register{ctx.reg_alloc.Consume(offset)}); } std::pair AllocOffsetsRegs(EmitContext& ctx, @@ -157,9 +161,9 @@ std::string GradOffset(const IR::Value& offset) { } switch (vector->NumArgs()) { case 1: - return fmt::format(",({})", static_cast(vector->Arg(0).U32())); + return std::format(",({})", static_cast(vector->Arg(0).U32())); case 2: - return fmt::format(",({},{})", static_cast(vector->Arg(0).U32()), + return std::format(",({},{})", static_cast(vector->Arg(0).U32()), static_cast(vector->Arg(1).U32())); default: throw LogicError("Invalid number of gradient offsets {}", vector->NumArgs()); @@ -170,9 +174,9 @@ std::pair Coord(EmitContext& ctx, const IR::Value& if (coord.IsImmediate()) { ScopedRegister scoped_reg(ctx.reg_alloc); ctx.Add("MOV.U {}.x,{};", scoped_reg.reg, ScalarU32{ctx.reg_alloc.Consume(coord)}); - return {fmt::to_string(scoped_reg.reg), std::move(scoped_reg)}; + return {std::format("{}", scoped_reg.reg), std::move(scoped_reg)}; } - std::string coord_vec{fmt::to_string(Register{ctx.reg_alloc.Consume(coord)})}; + std::string coord_vec{std::format("{}", Register{ctx.reg_alloc.Consume(coord)})}; if (coord.InstRecursive()->HasUses()) { // Move non-dead coords to a separate register, although this should never happen because // vectors are only assembled for immediate texture instructions @@ -489,15 +493,15 @@ void EmitImageGatherDref(EmitContext& ctx, IR::Inst& inst, const IR::Value& inde switch (info.type) { case TextureType::Color2D: ctx.Add("MOV.F {}.z,{};", coord_vec, dref_value); - args = fmt::to_string(coord_vec); + args = std::format("{}", coord_vec); break; case TextureType::ColorArray2D: case TextureType::ColorCube: ctx.Add("MOV.F {}.w,{};", coord_vec, dref_value); - args = fmt::to_string(coord_vec); + args = std::format("{}", coord_vec); break; case TextureType::ColorArrayCube: - args = fmt::format("{},{}", coord_vec, dref_value); + args = std::format("{},{}", coord_vec, dref_value); break; default: throw NotImplementedException("Invalid type {}", info.type.Value()); diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_memory.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_memory.cpp index 9319ea007f..4e016fbe1a 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_memory.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm_memory.cpp @@ -1,6 +1,10 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include #include "shader_recompiler/backend/glasm/emit_glasm_instructions.h" #include "shader_recompiler/backend/glasm/glasm_emit_context.h" #include "shader_recompiler/frontend/ir/program.h" @@ -77,7 +81,7 @@ void Write(EmitContext& ctx, const IR::Value& binding, ScalarU32 offset, ValueTy if (ctx.runtime_info.glasm_use_storage_buffers) { ctx.Add("STB.{} {},ssbo{}[{}];", size, value, binding.U32(), offset); } else { - StorageOp(ctx, binding, offset, fmt::format("STORE.{} {},DC.x;", size, value)); + StorageOp(ctx, binding, offset, std::format("STORE.{} {},DC.x;", size, value)); } } @@ -87,27 +91,27 @@ void Load(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, ScalarU32 if (ctx.runtime_info.glasm_use_storage_buffers) { ctx.Add("LDB.{} {},ssbo{}[{}];", size, ret, binding.U32(), offset); } else { - StorageOp(ctx, binding, offset, fmt::format("LOAD.{} {},DC.x;", size, ret), - fmt::format("MOV.U {},{{0,0,0,0}};", ret)); + StorageOp(ctx, binding, offset, std::format("LOAD.{} {},DC.x;", size, ret), + std::format("MOV.U {},{{0,0,0,0}};", ret)); } } template void GlobalWrite(EmitContext& ctx, Register address, ValueType value, std::string_view size) { if (ctx.runtime_info.glasm_use_storage_buffers) { - GlobalStorageOp(ctx, address, false, fmt::format("STB.{} {}", size, value)); + GlobalStorageOp(ctx, address, false, std::format("STB.{} {}", size, value)); } else { - GlobalStorageOp(ctx, address, true, fmt::format("STORE.{} {},DC.x;", size, value)); + GlobalStorageOp(ctx, address, true, std::format("STORE.{} {},DC.x;", size, value)); } } void GlobalLoad(EmitContext& ctx, IR::Inst& inst, Register address, std::string_view size) { const Register ret{ctx.reg_alloc.Define(inst)}; if (ctx.runtime_info.glasm_use_storage_buffers) { - GlobalStorageOp(ctx, address, false, fmt::format("LDB.{} {}", size, ret)); + GlobalStorageOp(ctx, address, false, std::format("LDB.{} {}", size, ret)); } else { - GlobalStorageOp(ctx, address, true, fmt::format("LOAD.{} {},DC.x;", size, ret), - fmt::format("MOV.S {},0;", ret)); + GlobalStorageOp(ctx, address, true, std::format("LOAD.{} {},DC.x;", size, ret), + std::format("MOV.S {},0;", ret)); } } @@ -120,7 +124,7 @@ void Atom(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, ScalarU32 offset); } else { StorageOp(ctx, binding, offset, - fmt::format("ATOM.{}.{} {},{},DC.x;", operation, size, ret, value)); + std::format("ATOM.{}.{} {},{},DC.x;", operation, size, ret, value)); } } } // Anonymous namespace diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_warp.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_warp.cpp index 7c07ec3247..8fc44b2af7 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_warp.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm_warp.cpp @@ -60,7 +60,7 @@ static void Shuffle(EmitContext& ctx, IR::Inst& inst, ScalarU32 value, ScalarU32 } std::string mask; if (clamp.IsImmediate() && segmentation_mask.IsImmediate()) { - mask = fmt::to_string(clamp.U32() | (segmentation_mask.U32() << 8)); + mask = std::to_string(clamp.U32() | (segmentation_mask.U32() << 8)); } else { mask = "RC"; ctx.Add("BFI.U RC.x,{{5,8,0,0}},{},{};", diff --git a/src/shader_recompiler/backend/glasm/glasm_emit_context.h b/src/shader_recompiler/backend/glasm/glasm_emit_context.h index 4b8951ddb4..58c789ffc4 100644 --- a/src/shader_recompiler/backend/glasm/glasm_emit_context.h +++ b/src/shader_recompiler/backend/glasm/glasm_emit_context.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -7,7 +10,7 @@ #include #include -#include +#include #include "shader_recompiler/backend/glasm/reg_alloc.h" #include "shader_recompiler/stage.h" @@ -36,23 +39,23 @@ public: template void Add(const char* format_str, IR::Inst& inst, Args&&... args) { - code += fmt::format(fmt::runtime(format_str), reg_alloc.Define(inst), - std::forward(args)...); + const auto def = reg_alloc.Define(inst); + code += std::vformat(format_str, std::make_format_args(def, args...)); // TODO: Remove this code += '\n'; } template void LongAdd(const char* format_str, IR::Inst& inst, Args&&... args) { - code += fmt::format(fmt::runtime(format_str), reg_alloc.LongDefine(inst), - std::forward(args)...); + const auto def = reg_alloc.LongDefine(inst); + code += std::vformat(format_str, std::make_format_args(def, args...)); // TODO: Remove this code += '\n'; } template void Add(const char* format_str, Args&&... args) { - code += fmt::format(fmt::runtime(format_str), std::forward(args)...); + code += std::vformat(format_str, std::make_format_args(args...)); // TODO: Remove this code += '\n'; } diff --git a/src/shader_recompiler/backend/glasm/reg_alloc.cpp b/src/shader_recompiler/backend/glasm/reg_alloc.cpp index be6cab336b..66b620f3ae 100644 --- a/src/shader_recompiler/backend/glasm/reg_alloc.cpp +++ b/src/shader_recompiler/backend/glasm/reg_alloc.cpp @@ -1,10 +1,10 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include +#include #include #include "shader_recompiler/backend/glasm/reg_alloc.h" #include "shader_recompiler/exception.h" diff --git a/src/shader_recompiler/backend/glasm/reg_alloc.h b/src/shader_recompiler/backend/glasm/reg_alloc.h index 6fae03616c..95808e22c3 100644 --- a/src/shader_recompiler/backend/glasm/reg_alloc.h +++ b/src/shader_recompiler/backend/glasm/reg_alloc.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include "common/bit_field.h" @@ -160,21 +160,21 @@ auto FormatTo(FormatContext& ctx, Id id) { } if constexpr (scalar) { if (id.is_null != 0) { - return fmt::format_to(ctx.out(), "{}", id.is_long != 0 ? "DC.x" : "RC.x"); + return std::format_to(ctx.out(), "{}", id.is_long != 0 ? "DC.x" : "RC.x"); } if (id.is_long != 0) { - return fmt::format_to(ctx.out(), "D{}.x", id.index.Value()); + return std::format_to(ctx.out(), "D{}.x", id.index.Value()); } else { - return fmt::format_to(ctx.out(), "R{}.x", id.index.Value()); + return std::format_to(ctx.out(), "R{}.x", id.index.Value()); } } else { if (id.is_null != 0) { - return fmt::format_to(ctx.out(), "{}", id.is_long != 0 ? "DC" : "RC"); + return std::format_to(ctx.out(), "{}", id.is_long != 0 ? "DC" : "RC"); } if (id.is_long != 0) { - return fmt::format_to(ctx.out(), "D{}", id.index.Value()); + return std::format_to(ctx.out(), "D{}", id.index.Value()); } else { - return fmt::format_to(ctx.out(), "R{}", id.index.Value()); + return std::format_to(ctx.out(), "R{}", id.index.Value()); } } } @@ -182,7 +182,7 @@ auto FormatTo(FormatContext& ctx, Id id) { } // namespace Shader::Backend::GLASM template <> -struct fmt::formatter { +struct std::formatter { constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } @@ -193,7 +193,7 @@ struct fmt::formatter { }; template <> -struct fmt::formatter { +struct std::formatter { constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } @@ -207,7 +207,7 @@ struct fmt::formatter { }; template <> -struct fmt::formatter { +struct std::formatter { constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } @@ -221,7 +221,7 @@ struct fmt::formatter { }; template <> -struct fmt::formatter { +struct std::formatter { constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } @@ -233,7 +233,7 @@ struct fmt::formatter { case Shader::Backend::GLASM::Type::Register: return Shader::Backend::GLASM::FormatTo(ctx, value.id); case Shader::Backend::GLASM::Type::U32: - return fmt::format_to(ctx.out(), "{}", value.imm_u32); + return std::format_to(ctx.out(), "{}", value.imm_u32); case Shader::Backend::GLASM::Type::U64: break; } @@ -242,7 +242,7 @@ struct fmt::formatter { }; template <> -struct fmt::formatter { +struct std::formatter { constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } @@ -254,7 +254,7 @@ struct fmt::formatter { case Shader::Backend::GLASM::Type::Register: return Shader::Backend::GLASM::FormatTo(ctx, value.id); case Shader::Backend::GLASM::Type::U32: - return fmt::format_to(ctx.out(), "{}", static_cast(value.imm_u32)); + return std::format_to(ctx.out(), "{}", static_cast(value.imm_u32)); case Shader::Backend::GLASM::Type::U64: break; } @@ -263,7 +263,7 @@ struct fmt::formatter { }; template <> -struct fmt::formatter { +struct std::formatter { constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } @@ -275,7 +275,7 @@ struct fmt::formatter { case Shader::Backend::GLASM::Type::Register: return Shader::Backend::GLASM::FormatTo(ctx, value.id); case Shader::Backend::GLASM::Type::U32: - return fmt::format_to(ctx.out(), "{}", std::bit_cast(value.imm_u32)); + return std::format_to(ctx.out(), "{}", std::bit_cast(value.imm_u32)); case Shader::Backend::GLASM::Type::U64: break; } @@ -284,7 +284,7 @@ struct fmt::formatter { }; template <> -struct fmt::formatter { +struct std::formatter { constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } @@ -298,7 +298,7 @@ struct fmt::formatter { case Shader::Backend::GLASM::Type::U32: break; case Shader::Backend::GLASM::Type::U64: - return fmt::format_to(ctx.out(), "{}", std::bit_cast(value.imm_u64)); + return std::format_to(ctx.out(), "{}", std::bit_cast(value.imm_u64)); } throw Shader::InvalidArgument("Invalid value type {}", value.type); } diff --git a/src/shader_recompiler/backend/glsl/emit_glsl.cpp b/src/shader_recompiler/backend/glsl/emit_glsl.cpp index 8ec180bc42..70fc0255c7 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl.cpp @@ -5,6 +5,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include +#include #include #include #include @@ -187,16 +188,16 @@ void DefineVariables(const EmitContext& ctx, std::string& header) { const auto precise{!has_precise_bug && IsPreciseType(type) ? "precise " : ""}; // Temps/return types that are never used are stored at index 0 if (tracker.uses_temp) { - header += fmt::format("{}{} t{}={}(0);", precise, type_name, + header += std::format("{}{} t{}={}(0);", precise, type_name, ctx.var_alloc.Representation(0, type), type_name); } for (u32 index = 0; index < tracker.num_used; ++index) { - header += fmt::format("{}{} {}={}(0);", precise, type_name, + header += std::format("{}{} {}={}(0);", precise, type_name, ctx.var_alloc.Representation(index, type), type_name); } } for (u32 i = 0; i < ctx.num_safety_loop_vars; ++i) { - header += fmt::format("int loop{}=0x2000;", i); + header += std::format("int loop{}=0x2000;", i); } } } // Anonymous namespace @@ -206,7 +207,7 @@ std::string EmitGLSL(const Profile& profile, const RuntimeInfo& runtime_info, IR EmitContext ctx{program, bindings, profile, runtime_info}; Precolor(program); EmitCode(ctx, program); - const std::string version{fmt::format("#version 460{}\n", GlslVersionSpecifier(ctx))}; + const std::string version{std::format("#version 460{}\n", GlslVersionSpecifier(ctx))}; ctx.header.insert(0, version); if (program.shared_memory_size > 0) { const auto requested_size{program.shared_memory_size}; @@ -217,11 +218,11 @@ std::string EmitGLSL(const Profile& profile, const RuntimeInfo& runtime_info, IR requested_size, max_size); } const auto smem_size{needs_clamp ? max_size : requested_size}; - ctx.header += fmt::format("shared uint smem[{}];", Common::DivCeil(smem_size, 4U)); + ctx.header += std::format("shared uint smem[{}];", Common::DivCeil(smem_size, 4U)); } ctx.header += "void main(){\n"; if (program.local_memory_size > 0) { - ctx.header += fmt::format("uint lmem[{}];", Common::DivCeil(program.local_memory_size, 4U)); + ctx.header += std::format("uint lmem[{}];", Common::DivCeil(program.local_memory_size, 4U)); } DefineVariables(ctx, ctx.header); if (ctx.uses_cc_carry) { diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp index 376a058277..4950d4862a 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp @@ -1,6 +1,10 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include #include #include "shader_recompiler/backend/glsl/emit_glsl_instructions.h" @@ -15,14 +19,14 @@ constexpr char cas_loop[]{ void SharedCasFunction(EmitContext& ctx, IR::Inst& inst, std::string_view offset, std::string_view value, std::string_view function) { const auto ret{ctx.var_alloc.Define(inst, GlslVarType::U32)}; - const std::string smem{fmt::format("smem[{}>>2]", offset)}; + const std::string smem{std::format("smem[{}>>2]", offset)}; ctx.Add(cas_loop, smem, ret, smem, function, smem, value, ret); } void SsboCasFunction(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, const IR::Value& offset, std::string_view value, std::string_view function) { const auto ret{ctx.var_alloc.Define(inst, GlslVarType::U32)}; - const std::string ssbo{fmt::format("{}_ssbo{}[{}>>2]", ctx.stage_name, binding.U32(), + const std::string ssbo{std::format("{}_ssbo{}[{}>>2]", ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset))}; ctx.Add(cas_loop, ssbo, ret, ssbo, function, ssbo, value, ret); } @@ -30,7 +34,7 @@ void SsboCasFunction(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, void SsboCasFunctionF32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, const IR::Value& offset, std::string_view value, std::string_view function) { - const std::string ssbo{fmt::format("{}_ssbo{}[{}>>2]", ctx.stage_name, binding.U32(), + const std::string ssbo{std::format("{}_ssbo{}[{}>>2]", ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset))}; const auto ret{ctx.var_alloc.Define(inst, GlslVarType::U32)}; ctx.Add(cas_loop, ssbo, ret, ssbo, function, ssbo, value, ret); @@ -45,7 +49,7 @@ void EmitSharedAtomicIAdd32(EmitContext& ctx, IR::Inst& inst, std::string_view p void EmitSharedAtomicSMin32(EmitContext& ctx, IR::Inst& inst, std::string_view pointer_offset, std::string_view value) { - const std::string u32_value{fmt::format("uint({})", value)}; + const std::string u32_value{std::format("uint({})", value)}; SharedCasFunction(ctx, inst, pointer_offset, u32_value, "CasMinS32"); } @@ -56,7 +60,7 @@ void EmitSharedAtomicUMin32(EmitContext& ctx, IR::Inst& inst, std::string_view p void EmitSharedAtomicSMax32(EmitContext& ctx, IR::Inst& inst, std::string_view pointer_offset, std::string_view value) { - const std::string u32_value{fmt::format("uint({})", value)}; + const std::string u32_value{std::format("uint({})", value)}; SharedCasFunction(ctx, inst, pointer_offset, u32_value, "CasMaxS32"); } @@ -119,7 +123,7 @@ void EmitStorageAtomicIAdd32(EmitContext& ctx, IR::Inst& inst, const IR::Value& void EmitStorageAtomicSMin32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, const IR::Value& offset, std::string_view value) { - const std::string u32_value{fmt::format("uint({})", value)}; + const std::string u32_value{std::format("uint({})", value)}; SsboCasFunction(ctx, inst, binding, offset, u32_value, "CasMinS32"); } @@ -131,7 +135,7 @@ void EmitStorageAtomicUMin32(EmitContext& ctx, IR::Inst& inst, const IR::Value& void EmitStorageAtomicSMax32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, const IR::Value& offset, std::string_view value) { - const std::string u32_value{fmt::format("uint({})", value)}; + const std::string u32_value{std::format("uint({})", value)}; SsboCasFunction(ctx, inst, binding, offset, u32_value, "CasMaxS32"); } 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 ffe5cd116c..2e249c5f50 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 @@ -1,6 +1,10 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include #include #include "shader_recompiler/backend/glsl/emit_glsl_instructions.h" @@ -27,7 +31,7 @@ bool IsInputArray(Stage stage) { } std::string InputVertexIndex(EmitContext& ctx, std::string_view vertex) { - return IsInputArray(ctx.stage) ? fmt::format("[{}]", vertex) : ""; + return IsInputArray(ctx.stage) ? std::format("[{}]", vertex) : ""; } std::string_view OutputVertexIndex(EmitContext& ctx) { @@ -36,10 +40,10 @@ std::string_view OutputVertexIndex(EmitContext& ctx) { std::string ChooseCbuf(EmitContext& ctx, const IR::Value& binding, std::string_view index) { if (binding.IsImmediate()) { - return fmt::format("{}_cbuf{}[{}]", ctx.stage_name, binding.U32(), index); + return std::format("{}_cbuf{}[{}]", ctx.stage_name, binding.U32(), index); } else { const auto binding_var{ctx.var_alloc.Consume(binding)}; - return fmt::format("GetCbufIndirect({},{})", binding_var, index); + return std::format("GetCbufIndirect({},{})", binding_var, index); } } @@ -58,25 +62,25 @@ void GetCbuf(EmitContext& ctx, std::string_view ret, const IR::Value& binding, } } const auto offset_var{ctx.var_alloc.Consume(offset)}; - const auto index{is_immediate ? fmt::format("{}", offset.U32() / 16) - : fmt::format("{}>>4", offset_var)}; - const auto swizzle{is_immediate ? fmt::format(".{}", OffsetSwizzle(offset.U32())) - : fmt::format("[({}>>2)%4]", offset_var)}; + const auto index{is_immediate ? std::format("{}", offset.U32() / 16) + : std::format("{}>>4", offset_var)}; + const auto swizzle{is_immediate ? std::format(".{}", OffsetSwizzle(offset.U32())) + : std::format("[({}>>2)%4]", offset_var)}; const auto cbuf{ChooseCbuf(ctx, binding, index)}; - const auto cbuf_cast{fmt::format("{}({}{{}})", cast, cbuf)}; + const auto cbuf_cast{std::format("{}({}{{}})", cast, cbuf)}; const auto extraction{num_bits == 32 ? cbuf_cast - : fmt::format("bitfieldExtract({},int({}),{})", cbuf_cast, + : std::format("bitfieldExtract({},int({}),{})", cbuf_cast, bit_offset, num_bits)}; if (!component_indexing_bug) { - const auto result{fmt::format(fmt::runtime(extraction), swizzle)}; + const auto result{std::vformat(extraction, std::make_format_args(swizzle))}; ctx.Add("{}={};", ret, result); return; } - const auto cbuf_offset{fmt::format("{}>>2", offset_var)}; + const auto cbuf_offset{std::format("{}>>2", offset_var)}; for (u32 i = 0; i < 4; ++i) { - const auto swizzle_string{fmt::format(".{}", "xyzw"[i])}; - const auto result{fmt::format(fmt::runtime(extraction), swizzle_string)}; + const auto swizzle_string{std::format(".{}", "xyzw"[i])}; + const auto result{std::vformat(extraction, std::make_format_args(swizzle_string))}; ctx.Add("if(({}&3)=={}){}={};", cbuf_offset, i, ret, result); } } @@ -85,11 +89,11 @@ void GetCbuf8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, const std::string_view cast) { const auto ret{ctx.var_alloc.Define(inst, GlslVarType::U32)}; if (offset.IsImmediate()) { - const auto bit_offset{fmt::format("{}", (offset.U32() % 4) * 8)}; + const auto bit_offset{std::format("{}", (offset.U32() % 4) * 8)}; GetCbuf(ctx, ret, binding, offset, 8, cast, bit_offset); } else { const auto offset_var{ctx.var_alloc.Consume(offset)}; - const auto bit_offset{fmt::format("({}%4)*8", offset_var)}; + const auto bit_offset{std::format("({}%4)*8", offset_var)}; GetCbuf(ctx, ret, binding, offset, 8, cast, bit_offset); } } @@ -98,11 +102,11 @@ void GetCbuf16(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, const std::string_view cast) { const auto ret{ctx.var_alloc.Define(inst, GlslVarType::U32)}; if (offset.IsImmediate()) { - const auto bit_offset{fmt::format("{}", ((offset.U32() / 2) % 2) * 16)}; + const auto bit_offset{std::format("{}", ((offset.U32() / 2) % 2) * 16)}; GetCbuf(ctx, ret, binding, offset, 16, cast, bit_offset); } else { const auto offset_var{ctx.var_alloc.Consume(offset)}; - const auto bit_offset{fmt::format("(({}>>1)%2)*16", offset_var)}; + const auto bit_offset{std::format("(({}>>1)%2)*16", offset_var)}; GetCbuf(ctx, ret, binding, offset, 16, cast, bit_offset); } } @@ -150,7 +154,7 @@ void EmitGetCbufU32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding const IR::Value& offset) { const auto cast{ctx.profile.has_gl_cbuf_ftou_bug ? "" : "ftou"}; if (offset.IsImmediate()) { - const auto cbuf{fmt::format("{}_cbuf{}", ctx.stage_name, binding.U32())}; + const auto cbuf{std::format("{}_cbuf{}", ctx.stage_name, binding.U32())}; static constexpr u32 cbuf_size{0x10000}; const u32 u32_offset{offset.U32()}; const s32 signed_offset{static_cast(offset.U32())}; @@ -170,14 +174,14 @@ void EmitGetCbufU32x2(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding return; } const auto offset_var{ctx.var_alloc.Consume(offset)}; - const auto cbuf{ChooseCbuf(ctx, binding, fmt::format("{}>>4", offset_var))}; + const auto cbuf{ChooseCbuf(ctx, binding, std::format("{}>>4", offset_var))}; if (!ctx.profile.has_gl_component_indexing_bug) { ctx.AddU32x2("{}=uvec2({}({}[({}>>2)%4]),{}({}[(({}+4)>>2)%4]));", inst, cast, cbuf, offset_var, cast, cbuf, offset_var); return; } const auto ret{ctx.var_alloc.Define(inst, GlslVarType::U32x2)}; - const auto cbuf_offset{fmt::format("{}>>2", offset_var)}; + const auto cbuf_offset{std::format("{}>>2", offset_var)}; for (u32 swizzle = 0; swizzle < 4; ++swizzle) { ctx.Add("if(({}&3)=={}){}=uvec2({}({}.{}),{}({}.{}));", cbuf_offset, swizzle, ret, cast, cbuf, "xyzw"[swizzle], cast, cbuf, "xyzw"[(swizzle + 1) % 4]); @@ -213,7 +217,7 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, case IR::Attribute::PositionZ: case IR::Attribute::PositionW: { const bool is_array{IsInputArray(ctx.stage)}; - const auto input_decorator{is_array ? fmt::format("gl_in[{}].", vertex) : ""}; + const auto input_decorator{is_array ? std::format("gl_in[{}].", vertex) : ""}; ctx.AddF32("{}={}{}.{};", inst, input_decorator, ctx.position_name, swizzle); break; } @@ -347,7 +351,7 @@ void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, std::string_view val void EmitGetAttributeIndexed(EmitContext& ctx, IR::Inst& inst, std::string_view offset, std::string_view vertex) { const bool is_array{ctx.stage == Stage::Geometry}; - const auto vertex_arg{is_array ? fmt::format(",{}", vertex) : ""}; + const auto vertex_arg{is_array ? std::format(",{}", vertex) : ""}; ctx.AddF32("{}=IndexedAttrLoad(int({}){});", inst, offset, vertex_arg); } diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp index ad39f44c33..de45040d1c 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp @@ -1,6 +1,10 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include #include #include "shader_recompiler/backend/glsl/emit_glsl_instructions.h" @@ -14,15 +18,15 @@ namespace { std::string Texture(EmitContext& ctx, const IR::TextureInstInfo& info, const IR::Value& index) { const auto def{info.type == TextureType::Buffer ? ctx.texture_buffers.at(info.descriptor_index) : ctx.textures.at(info.descriptor_index)}; - const auto index_offset{def.count > 1 ? fmt::format("[{}]", ctx.var_alloc.Consume(index)) : ""}; - return fmt::format("tex{}{}", def.binding, index_offset); + const auto index_offset{def.count > 1 ? std::format("[{}]", ctx.var_alloc.Consume(index)) : ""}; + return std::format("tex{}{}", def.binding, index_offset); } std::string Image(EmitContext& ctx, const IR::TextureInstInfo& info, const IR::Value& index) { const auto def{info.type == TextureType::Buffer ? ctx.image_buffers.at(info.descriptor_index) : ctx.images.at(info.descriptor_index)}; - const auto index_offset{def.count > 1 ? fmt::format("[{}]", ctx.var_alloc.Consume(index)) : ""}; - return fmt::format("img{}{}", def.binding, index_offset); + const auto index_offset{def.count > 1 ? std::format("[{}]", ctx.var_alloc.Consume(index)) : ""}; + return std::format("img{}{}", def.binding, index_offset); } bool IsTextureMsaa(EmitContext& ctx, const IR::TextureInstInfo& info) { @@ -36,16 +40,16 @@ std::string CastToIntVec(std::string_view value, const IR::TextureInstInfo& info switch (info.type) { case TextureType::Color1D: case TextureType::Buffer: - return fmt::format("int({})", value); + return std::format("int({})", value); case TextureType::ColorArray1D: case TextureType::Color2D: case TextureType::ColorArray2D: - return fmt::format("ivec2({})", value); + return std::format("ivec2({})", value); case TextureType::Color3D: case TextureType::ColorCube: - return fmt::format("ivec3({})", value); + return std::format("ivec3({})", value); case TextureType::ColorArrayCube: - return fmt::format("ivec4({})", value); + return std::format("ivec4({})", value); default: throw NotImplementedException("Integer cast for TextureType {}", info.type.Value()); } @@ -55,16 +59,16 @@ std::string CoordsCastToInt(std::string_view value, const IR::TextureInstInfo& i switch (info.type) { case TextureType::Color1D: case TextureType::Buffer: - return fmt::format("int({})", value); + return std::format("int({})", value); case TextureType::ColorArray1D: case TextureType::Color2D: - return fmt::format("ivec2({})", value); + return std::format("ivec2({})", value); case TextureType::ColorArray2D: case TextureType::Color3D: case TextureType::ColorCube: - return fmt::format("ivec3({})", value); + return std::format("ivec3({})", value); case TextureType::ColorArrayCube: - return fmt::format("ivec4({})", value); + return std::format("ivec4({})", value); default: throw NotImplementedException("TexelFetchCast type {}", info.type.Value()); } @@ -83,18 +87,18 @@ bool NeedsShadowLodExt(TextureType type) { std::string GetOffsetVec(EmitContext& ctx, const IR::Value& offset) { if (offset.IsImmediate()) { - return fmt::format("int({})", offset.U32()); + return std::format("int({})", offset.U32()); } IR::Inst* const inst{offset.InstRecursive()}; if (inst->AreAllArgsImmediates()) { switch (inst->GetOpcode()) { case IR::Opcode::CompositeConstructU32x2: - return fmt::format("ivec2({},{})", inst->Arg(0).U32(), inst->Arg(1).U32()); + return std::format("ivec2({},{})", inst->Arg(0).U32(), inst->Arg(1).U32()); case IR::Opcode::CompositeConstructU32x3: - return fmt::format("ivec3({},{},{})", inst->Arg(0).U32(), inst->Arg(1).U32(), + return std::format("ivec3({},{},{})", inst->Arg(0).U32(), inst->Arg(1).U32(), inst->Arg(2).U32()); case IR::Opcode::CompositeConstructU32x4: - return fmt::format("ivec4({},{},{},{})", inst->Arg(0).U32(), inst->Arg(1).U32(), + return std::format("ivec4({},{},{},{})", inst->Arg(0).U32(), inst->Arg(1).U32(), inst->Arg(2).U32(), inst->Arg(3).U32()); default: break; @@ -107,13 +111,13 @@ std::string GetOffsetVec(EmitContext& ctx, const IR::Value& offset) { const auto offset_str{has_var_aoffi ? ctx.var_alloc.Consume(offset) : "0"}; switch (offset.Type()) { case IR::Type::U32: - return fmt::format("int({})", offset_str); + return std::format("int({})", offset_str); case IR::Type::U32x2: - return fmt::format("ivec2({})", offset_str); + return std::format("ivec2({})", offset_str); case IR::Type::U32x3: - return fmt::format("ivec3({})", offset_str); + return std::format("ivec3({})", offset_str); case IR::Type::U32x4: - return fmt::format("ivec4({})", offset_str); + return std::format("ivec4({})", offset_str); default: throw NotImplementedException("Offset type {}", offset.Type()); } @@ -131,7 +135,7 @@ std::string PtpOffsets(const IR::Value& offset, const IR::Value& offset2) { } auto read{[&](unsigned int a, unsigned int b) { return values[a]->Arg(b).U32(); }}; - return fmt::format("ivec2[](ivec2({},{}),ivec2({},{}),ivec2({},{}),ivec2({},{}))", read(0, 0), + return std::format("ivec2[](ivec2({},{}),ivec2({},{}),ivec2({},{}),ivec2({},{}))", read(0, 0), read(0, 1), read(0, 2), read(0, 3), read(1, 0), read(1, 1), read(1, 2), read(1, 3)); } @@ -149,10 +153,10 @@ std::string ImageGatherSubpixelOffset(const IR::TextureInstInfo& info, std::stri switch (info.type) { case TextureType::Color2D: case TextureType::Color2DRect: - return fmt::format("{}+vec2(0.001953125)/vec2(textureSize({}, 0))", coords, texture); + return std::format("{}+vec2(0.001953125)/vec2(textureSize({}, 0))", coords, texture); case TextureType::ColorArray2D: case TextureType::ColorCube: - return fmt::format("vec3({0}.xy+vec2(0.001953125)/vec2(textureSize({1}, 0)),{0}.z)", coords, + return std::format("vec3({0}.xy+vec2(0.001953125)/vec2(textureSize({1}, 0)),{0}.z)", coords, texture); default: return std::string{coords}; @@ -168,7 +172,7 @@ void EmitImageSampleImplicitLod(EmitContext& ctx, IR::Inst& inst, const IR::Valu throw NotImplementedException("EmitImageSampleImplicitLod Lod clamp samples"); } const auto texture{Texture(ctx, info, index)}; - const auto bias{info.has_bias ? fmt::format(",{}", bias_lc) : ""}; + const auto bias{info.has_bias ? std::format(",{}", bias_lc) : ""}; const auto texel{ctx.var_alloc.Define(inst, GlslVarType::F32x4)}; const auto sparse_inst{PrepareSparse(inst)}; const bool supports_sparse{ctx.profile.support_gl_sparse_textures}; @@ -254,7 +258,7 @@ void EmitImageSampleDrefImplicitLod(EmitContext& ctx, IR::Inst& inst, const IR:: throw NotImplementedException("EmitImageSampleDrefImplicitLod Lod clamp samples"); } const auto texture{Texture(ctx, info, index)}; - const auto bias{info.has_bias ? fmt::format(",{}", bias_lc) : ""}; + const auto bias{info.has_bias ? std::format(",{}", bias_lc) : ""}; const bool needs_shadow_ext{NeedsShadowLodExt(info.type)}; const auto cast{needs_shadow_ext ? "vec4" : "vec3"}; const bool use_grad{!ctx.profile.support_gl_texture_shadow_lod && @@ -501,7 +505,7 @@ void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value& const auto texture{Texture(ctx, info, index)}; const bool is_msaa{IsTextureMsaa(ctx, info)}; const bool skip_mips{skip_mips_val.U1()}; - const auto mips{skip_mips ? "0u" : fmt::format("uint(textureQueryLevels({}))", texture)}; + const auto mips{skip_mips ? "0u" : std::format("uint(textureQueryLevels({}))", texture)}; if (is_msaa && !skip_mips) { throw NotImplementedException("EmitImageQueryDimensions MSAA QueryLevels"); } @@ -509,7 +513,7 @@ void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value& throw NotImplementedException("EmitImageQueryDimensions TextureType::Buffer QueryLevels"); } const bool uses_lod{!is_msaa && info.type != TextureType::Buffer}; - const auto lod_str{uses_lod ? fmt::format(",int({})", lod) : ""}; + const auto lod_str{uses_lod ? std::format(",int({})", lod) : ""}; switch (info.type) { case TextureType::Color1D: return ctx.AddU32x4("{}=uvec4(uint(textureSize({}{})),0u,0u,{});", inst, texture, lod_str, diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp index c3f0e504f6..b2dcfe4292 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp @@ -1,9 +1,10 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include #include "shader_recompiler/backend/glsl/emit_glsl_instructions.h" #include "shader_recompiler/backend/glsl/glsl_emit_context.h" #include "shader_recompiler/frontend/ir/value.h" @@ -43,9 +44,9 @@ void EmitIAdd32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::strin if (IR::Inst * overflow{inst.GetAssociatedPseudoOperation(IR::Opcode::GetOverflowFromOp)}) { // https://stackoverflow.com/questions/55468823/how-to-detect-integer-overflow-in-c constexpr u32 s32_max{static_cast((std::numeric_limits::max)())}; - const auto sub_a{fmt::format("{}u-{}", s32_max, a)}; - const auto positive_result{fmt::format("int({})>int({})", b, sub_a)}; - const auto negative_result{fmt::format("int({})int({})", b, sub_a)}; + const auto negative_result{std::format("int({})=0?{}:{};", *overflow, a, positive_result, negative_result); overflow->Invalidate(); } diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_memory.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_memory.cpp index 28bd3f5b34..e146a328a4 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_memory.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_memory.cpp @@ -1,6 +1,10 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include #include #include "shader_recompiler/backend/glsl/emit_glsl_instructions.h" @@ -16,7 +20,7 @@ constexpr char cas_loop[]{"for(;;){{uint old_value={};uint " void SsboWriteCas(EmitContext& ctx, const IR::Value& binding, std::string_view offset_var, std::string_view value, std::string_view bit_offset, u32 num_bits) { - const auto ssbo{fmt::format("{}_ssbo{}[{}>>2]", ctx.stage_name, binding.U32(), offset_var)}; + const auto ssbo{std::format("{}_ssbo{}[{}>>2]", ctx.stage_name, binding.U32(), offset_var)}; ctx.Add(cas_loop, ssbo, ssbo, ssbo, value, bit_offset, num_bits); } } // Anonymous namespace @@ -152,28 +156,28 @@ void EmitLoadStorage128(EmitContext& ctx, IR::Inst& inst, const IR::Value& bindi void EmitWriteStorageU8(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, std::string_view value) { const auto offset_var{ctx.var_alloc.Consume(offset)}; - const auto bit_offset{fmt::format("int({}%4)*8", offset_var)}; + const auto bit_offset{std::format("int({}%4)*8", offset_var)}; SsboWriteCas(ctx, binding, offset_var, value, bit_offset, 8); } void EmitWriteStorageS8(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, std::string_view value) { const auto offset_var{ctx.var_alloc.Consume(offset)}; - const auto bit_offset{fmt::format("int({}%4)*8", offset_var)}; + const auto bit_offset{std::format("int({}%4)*8", offset_var)}; SsboWriteCas(ctx, binding, offset_var, value, bit_offset, 8); } void EmitWriteStorageU16(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, std::string_view value) { const auto offset_var{ctx.var_alloc.Consume(offset)}; - const auto bit_offset{fmt::format("int(({}>>1)%2)*16", offset_var)}; + const auto bit_offset{std::format("int(({}>>1)%2)*16", offset_var)}; SsboWriteCas(ctx, binding, offset_var, value, bit_offset, 16); } void EmitWriteStorageS16(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, std::string_view value) { const auto offset_var{ctx.var_alloc.Consume(offset)}; - const auto bit_offset{fmt::format("int(({}>>1)%2)*16", offset_var)}; + const auto bit_offset{std::format("int(({}>>1)%2)*16", offset_var)}; SsboWriteCas(ctx, binding, offset_var, value, bit_offset, 16); } diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_shared_memory.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_shared_memory.cpp index 5095f5a298..8f3e2025fe 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_shared_memory.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_shared_memory.cpp @@ -1,6 +1,10 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include #include "shader_recompiler/backend/glsl/emit_glsl_instructions.h" #include "shader_recompiler/backend/glsl/glsl_emit_context.h" #include "shader_recompiler/frontend/ir/value.h" @@ -13,7 +17,7 @@ constexpr char cas_loop[]{"for(;;){{uint old_value={};uint " void SharedWriteCas(EmitContext& ctx, std::string_view offset, std::string_view value, std::string_view bit_offset, u32 num_bits) { - const auto smem{fmt::format("smem[{}>>2]", offset)}; + const auto smem{std::format("smem[{}>>2]", offset)}; ctx.Add(cas_loop, smem, smem, smem, value, bit_offset, num_bits); } } // Anonymous namespace @@ -48,12 +52,12 @@ void EmitLoadSharedU128(EmitContext& ctx, IR::Inst& inst, std::string_view offse } void EmitWriteSharedU8(EmitContext& ctx, std::string_view offset, std::string_view value) { - const auto bit_offset{fmt::format("int({}%4)*8", offset)}; + const auto bit_offset{std::format("int({}%4)*8", offset)}; SharedWriteCas(ctx, offset, value, bit_offset, 8); } void EmitWriteSharedU16(EmitContext& ctx, std::string_view offset, std::string_view value) { - const auto bit_offset{fmt::format("int(({}>>1)%2)*16", offset)}; + const auto bit_offset{std::format("int(({}>>1)%2)*16", offset)}; SharedWriteCas(ctx, offset, value, bit_offset, 16); } diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_special.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_special.cpp index 67a54a84ff..3d6e14aac6 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_special.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_special.cpp @@ -1,6 +1,10 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include #include "shader_recompiler/backend/glsl/emit_glsl_instructions.h" #include "shader_recompiler/backend/glsl/glsl_emit_context.h" #include "shader_recompiler/frontend/ir/program.h" @@ -29,7 +33,7 @@ void InitializeOutputVaryings(EmitContext& ctx) { size_t element{}; while (element < info_array.size()) { const auto& info{info_array.at(element)}; - const auto varying_name{fmt::format("{}{}", info.name, output_decorator)}; + const auto varying_name{std::format("{}{}", info.name, output_decorator)}; switch (info.num_components) { case 1: { const char value{element == 3 ? '1' : '0'}; diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp index b2f65550fb..d4910aa315 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp @@ -4,6 +4,7 @@ // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include #include #include "shader_recompiler/backend/glsl/emit_glsl_instructions.h" @@ -25,17 +26,17 @@ void SetInBoundsFlag(EmitContext& ctx, IR::Inst& inst) { } std::string ComputeMinThreadId(std::string_view thread_id, std::string_view segmentation_mask) { - return fmt::format("({}&{})", thread_id, segmentation_mask); + return std::format("({}&{})", thread_id, segmentation_mask); } std::string ComputeMaxThreadId(std::string_view min_thread_id, std::string_view clamp, std::string_view not_seg_mask) { - return fmt::format("({})|({}&{})", min_thread_id, clamp, not_seg_mask); + return std::format("({})|({}&{})", min_thread_id, clamp, not_seg_mask); } std::string GetMaxThreadId(std::string_view thread_id, std::string_view clamp, std::string_view segmentation_mask) { - const auto not_seg_mask{fmt::format("(~{})", segmentation_mask)}; + const auto not_seg_mask{std::format("(~{})", segmentation_mask)}; const auto min_thread_id{ComputeMinThreadId(thread_id, segmentation_mask)}; return ComputeMaxThreadId(min_thread_id, clamp, not_seg_mask); } @@ -43,7 +44,7 @@ std::string GetMaxThreadId(std::string_view thread_id, std::string_view clamp, void UseShuffleNv(EmitContext& ctx, IR::Inst& inst, std::string_view shfl_op, std::string_view value, std::string_view index, [[maybe_unused]] std::string_view clamp, std::string_view segmentation_mask) { - const auto width{fmt::format("32u>>(bitCount({}&31u))", segmentation_mask)}; + const auto width{std::format("32u>>(bitCount({}&31u))", segmentation_mask)}; ctx.AddU32("{}={}({},{},{},shfl_in_bounds);", inst, shfl_op, value, index, width); SetInBoundsFlag(ctx, inst); } @@ -57,7 +58,7 @@ std::string_view BallotIndex(EmitContext& ctx) { std::string GetMask(EmitContext& ctx, std::string_view mask) { const auto ballot_index{BallotIndex(ctx)}; - return fmt::format("uint(uvec2({}){})", mask, ballot_index); + return std::format("uint(uvec2({}){})", mask, ballot_index); } } // Anonymous namespace @@ -71,8 +72,8 @@ void EmitVoteAll(EmitContext& ctx, IR::Inst& inst, std::string_view pred) { return; } const auto ballot_index{BallotIndex(ctx)}; - const auto active_mask{fmt::format("uvec2(ballotARB(true)){}", ballot_index)}; - const auto ballot{fmt::format("uvec2(ballotARB({})){}", pred, ballot_index)}; + const auto active_mask{std::format("uvec2(ballotARB(true)){}", ballot_index)}; + const auto ballot{std::format("uvec2(ballotARB({})){}", pred, ballot_index)}; ctx.AddU1("{}=({}&{})=={};", inst, ballot, active_mask, active_mask); } @@ -82,8 +83,8 @@ void EmitVoteAny(EmitContext& ctx, IR::Inst& inst, std::string_view pred) { return; } const auto ballot_index{BallotIndex(ctx)}; - const auto active_mask{fmt::format("uvec2(ballotARB(true)){}", ballot_index)}; - const auto ballot{fmt::format("uvec2(ballotARB({})){}", pred, ballot_index)}; + const auto active_mask{std::format("uvec2(ballotARB(true)){}", ballot_index)}; + const auto ballot{std::format("uvec2(ballotARB({})){}", pred, ballot_index)}; ctx.AddU1("{}=({}&{})!=0u;", inst, ballot, active_mask, active_mask); } @@ -93,9 +94,9 @@ void EmitVoteEqual(EmitContext& ctx, IR::Inst& inst, std::string_view pred) { return; } const auto ballot_index{BallotIndex(ctx)}; - const auto active_mask{fmt::format("uvec2(ballotARB(true)){}", ballot_index)}; - const auto ballot{fmt::format("uvec2(ballotARB({})){}", pred, ballot_index)}; - const auto value{fmt::format("({}^{})", ballot, active_mask)}; + const auto active_mask{std::format("uvec2(ballotARB(true)){}", ballot_index)}; + const auto ballot{std::format("uvec2(ballotARB({})){}", pred, ballot_index)}; + const auto value{std::format("({}^{})", ballot, active_mask)}; ctx.AddU1("{}=({}==0)||({}=={});", inst, value, value, active_mask); } @@ -132,16 +133,16 @@ void EmitShuffleIndex(EmitContext& ctx, IR::Inst& inst, std::string_view value, } const bool big_warp{ctx.profile.warp_size_potentially_larger_than_guest}; const auto is_upper_partition{"int(gl_SubGroupInvocationARB)>=32"}; - const auto upper_index{fmt::format("{}?{}+32:{}", is_upper_partition, index, index)}; - const auto upper_clamp{fmt::format("{}?{}+32:{}", is_upper_partition, clamp, clamp)}; + const auto upper_index{std::format("{}?{}+32:{}", is_upper_partition, index, index)}; + const auto upper_clamp{std::format("{}?{}+32:{}", is_upper_partition, clamp, clamp)}; - const auto not_seg_mask{fmt::format("(~{})", seg_mask)}; + const auto not_seg_mask{std::format("(~{})", seg_mask)}; const auto min_thread_id{ComputeMinThreadId(THREAD_ID, seg_mask)}; const auto max_thread_id{ ComputeMaxThreadId(min_thread_id, big_warp ? upper_clamp : clamp, not_seg_mask)}; - const auto lhs{fmt::format("({}&{})", big_warp ? upper_index : index, not_seg_mask)}; - const auto src_thread_id{fmt::format("({})|({})", lhs, min_thread_id)}; + const auto lhs{std::format("({}&{})", big_warp ? upper_index : index, not_seg_mask)}; + const auto src_thread_id{std::format("({})|({})", lhs, min_thread_id)}; ctx.Add("shfl_in_bounds=int({})<=int({});", src_thread_id, max_thread_id); SetInBoundsFlag(ctx, inst); ctx.Add("shfl_result=readInvocationARB({},{});", value, src_thread_id); @@ -156,10 +157,10 @@ void EmitShuffleUp(EmitContext& ctx, IR::Inst& inst, std::string_view value, std } const bool big_warp{ctx.profile.warp_size_potentially_larger_than_guest}; const auto is_upper_partition{"int(gl_SubGroupInvocationARB)>=32"}; - const auto upper_clamp{fmt::format("{}?{}+32:{}", is_upper_partition, clamp, clamp)}; + const auto upper_clamp{std::format("{}?{}+32:{}", is_upper_partition, clamp, clamp)}; const auto max_thread_id{GetMaxThreadId(THREAD_ID, big_warp ? upper_clamp : clamp, seg_mask)}; - const auto src_thread_id{fmt::format("({}-{})", THREAD_ID, index)}; + const auto src_thread_id{std::format("({}-{})", THREAD_ID, index)}; ctx.Add("shfl_in_bounds=int({})>=int({});", src_thread_id, max_thread_id); SetInBoundsFlag(ctx, inst); ctx.Add("shfl_result=readInvocationARB({},{});", value, src_thread_id); @@ -174,10 +175,10 @@ void EmitShuffleDown(EmitContext& ctx, IR::Inst& inst, std::string_view value, } const bool big_warp{ctx.profile.warp_size_potentially_larger_than_guest}; const auto is_upper_partition{"int(gl_SubGroupInvocationARB)>=32"}; - const auto upper_clamp{fmt::format("{}?{}+32:{}", is_upper_partition, clamp, clamp)}; + const auto upper_clamp{std::format("{}?{}+32:{}", is_upper_partition, clamp, clamp)}; const auto max_thread_id{GetMaxThreadId(THREAD_ID, big_warp ? upper_clamp : clamp, seg_mask)}; - const auto src_thread_id{fmt::format("({}+{})", THREAD_ID, index)}; + const auto src_thread_id{std::format("({}+{})", THREAD_ID, index)}; ctx.Add("shfl_in_bounds=int({})<=int({});", src_thread_id, max_thread_id); SetInBoundsFlag(ctx, inst); ctx.Add("shfl_result=readInvocationARB({},{});", value, src_thread_id); @@ -193,10 +194,10 @@ void EmitShuffleButterfly(EmitContext& ctx, IR::Inst& inst, std::string_view val } const bool big_warp{ctx.profile.warp_size_potentially_larger_than_guest}; const auto is_upper_partition{"int(gl_SubGroupInvocationARB)>=32"}; - const auto upper_clamp{fmt::format("{}?{}+32:{}", is_upper_partition, clamp, clamp)}; + const auto upper_clamp{std::format("{}?{}+32:{}", is_upper_partition, clamp, clamp)}; const auto max_thread_id{GetMaxThreadId(THREAD_ID, big_warp ? upper_clamp : clamp, seg_mask)}; - const auto src_thread_id{fmt::format("({}^{})", THREAD_ID, index)}; + const auto src_thread_id{std::format("({}^{})", THREAD_ID, index)}; ctx.Add("shfl_in_bounds=int({})<=int({});", src_thread_id, max_thread_id); SetInBoundsFlag(ctx, inst); ctx.Add("shfl_result=readInvocationARB({},{});", value, src_thread_id); @@ -205,21 +206,21 @@ void EmitShuffleButterfly(EmitContext& ctx, IR::Inst& inst, std::string_view val void EmitQuadBroadcast(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view lane) { - const auto src_thread_id{fmt::format("(({}&~3)|({}& 3))", THREAD_ID, lane)}; + const auto src_thread_id{std::format("(({}&~3)|({}& 3))", THREAD_ID, lane)}; ctx.AddU32("{}=readInvocationARB({},{});", inst, value, src_thread_id); } void EmitQuadSwap(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view direction) { - const auto src_thread_id{fmt::format("({}^({}+1))", THREAD_ID, direction)}; + const auto src_thread_id{std::format("({}^({}+1))", THREAD_ID, direction)}; ctx.AddU32("{}=readInvocationARB({},{});", inst, value, src_thread_id); } void EmitFSwizzleAdd(EmitContext& ctx, IR::Inst& inst, std::string_view op_a, std::string_view op_b, std::string_view swizzle) { - const auto mask{fmt::format("({}>>((gl_SubGroupInvocationARB&3)<<1))&3", swizzle)}; - const std::string modifier_a = fmt::format("FSWZ_A[{}]", mask); - const std::string modifier_b = fmt::format("FSWZ_B[{}]", mask); + const auto mask{std::format("({}>>((gl_SubGroupInvocationARB&3)<<1))&3", swizzle)}; + const std::string modifier_a = std::format("FSWZ_A[{}]", mask); + const std::string modifier_b = std::format("FSWZ_B[{}]", mask); ctx.AddF32("{}=({}*{})+({}*{});", inst, op_a, modifier_a, op_b, modifier_b); } diff --git a/src/shader_recompiler/backend/glsl/glsl_emit_context.cpp b/src/shader_recompiler/backend/glsl/glsl_emit_context.cpp index a2df6159fb..66d373cd9d 100644 --- a/src/shader_recompiler/backend/glsl/glsl_emit_context.cpp +++ b/src/shader_recompiler/backend/glsl/glsl_emit_context.cpp @@ -4,6 +4,7 @@ // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include #include "common/div_ceil.h" #include "shader_recompiler/backend/bindings.h" #include "shader_recompiler/backend/glsl/glsl_emit_context.h" @@ -59,7 +60,7 @@ bool StoresPerVertexAttributes(Stage stage) { std::string OutputDecorator(Stage stage, u32 size) { switch (stage) { case Stage::TessellationControl: - return fmt::format("[{}]", size); + return std::format("[{}]", size); default: return ""; } @@ -286,17 +287,17 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile break; case Stage::TessellationControl: stage_name = "tcs"; - header += fmt::format("layout(vertices={})out;", program.invocations); + header += std::format("layout(vertices={})out;", program.invocations); break; case Stage::TessellationEval: stage_name = "tes"; - header += fmt::format("layout({},{},{})in;", GetTessMode(runtime_info.tess_primitive), + header += std::format("layout({},{},{})in;", GetTessMode(runtime_info.tess_primitive), GetTessSpacing(runtime_info.tess_spacing), runtime_info.tess_clockwise ? "cw" : "ccw"); break; case Stage::Geometry: stage_name = "gs"; - header += fmt::format("layout({})in;", InputPrimitive(runtime_info.input_topology)); + header += std::format("layout({})in;", InputPrimitive(runtime_info.input_topology)); if (uses_geometry_passthrough) { // Passthru REQUIRES the layout to be defined with a corresponding name, for our sanity // we will just use `gl_in[]`, if you don't the driver will complain with: @@ -306,7 +307,7 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile } else if (program.is_geometry_passthrough && !profile.support_geometry_shader_passthrough) { LOG_WARNING(Shader_GLSL, "Passthrough geometry program used but not supported"); } - header += fmt::format( + header += std::format( "layout({},max_vertices={})out;in gl_PerVertex{{vec4 gl_Position;}}gl_in[];", OutputPrimitive(program.output_topology), program.output_vertices); break; @@ -322,7 +323,7 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile const u32 local_x{(std::max)(program.workgroup_size[0], 1u)}; const u32 local_y{(std::max)(program.workgroup_size[1], 1u)}; const u32 local_z{(std::max)(program.workgroup_size[2], 1u)}; - header += fmt::format("layout(local_size_x={},local_size_y={},local_size_z={}) in;", + header += std::format("layout(local_size_x={},local_size_y={},local_size_z={}) in;", local_x, local_y, local_z); break; } @@ -334,8 +335,8 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile continue; } const auto qualifier{uses_geometry_passthrough ? "passthrough" - : fmt::format("location={}", index)}; - header += fmt::format("layout({}){}in vec4 in_attr{}{};", qualifier, + : std::format("location={}", index)}; + header += std::format("layout({}){}in vec4 in_attr{}{};", qualifier, InterpDecorator(info.interpolation[index]), index, InputArrayDecorator(stage)); } @@ -344,14 +345,14 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile continue; } const auto qualifier{stage == Stage::TessellationControl ? "out" : "in"}; - header += fmt::format("layout(location={})patch {} vec4 patch{};", index, qualifier, index); + header += std::format("layout(location={})patch {} vec4 patch{};", index, qualifier, index); } if (stage == Stage::Fragment) { for (size_t index = 0; index < info.stores_frag_color.size(); ++index) { if (!info.stores_frag_color[index] && !profile.need_declared_frag_colors) { continue; } - header += fmt::format("layout(location={})out vec4 frag_color{};", index, index); + header += std::format("layout(location={})out vec4 frag_color{};", index, index); } } for (size_t index = 0; index < IR::NUM_GENERICS; ++index) { @@ -439,7 +440,7 @@ void EmitContext::DefineConstantBuffers(Bindings& bindings) { const auto cbuf_type{profile.has_gl_cbuf_ftou_bug ? "uvec4" : "vec4"}; const u32 cbuf_used_size{Common::DivCeil(info.constant_buffer_used_sizes[desc.index], 16U)}; const u32 cbuf_binding_size{info.uses_global_memory ? 0x1000U : cbuf_used_size}; - header += fmt::format("layout(std140,binding={}) uniform {}_cbuf_{}{{{} {}_cbuf{}[{}];}};", + header += std::format("layout(std140,binding={}) uniform {}_cbuf_{}{{{} {}_cbuf{}[{}];}};", bindings.uniform_buffer, stage_name, desc.index, cbuf_type, stage_name, desc.index, cbuf_binding_size); bindings.uniform_buffer += desc.count; @@ -458,7 +459,7 @@ void EmitContext::DefineConstantBufferIndirect() { for (const auto& desc : info.constant_buffer_descriptors) { header += - fmt::format("case {}:return {}_cbuf{}[offset];", desc.index, stage_name, desc.index); + std::format("case {}:return {}_cbuf{}[offset];", desc.index, stage_name, desc.index); } header += "}}"; @@ -470,7 +471,7 @@ void EmitContext::DefineStorageBuffers(Bindings& bindings) { } u32 index{}; for (const auto& desc : info.storage_buffers_descriptors) { - header += fmt::format("layout(std430,binding={}) buffer {}_ssbo_{}{{uint {}_ssbo{}[];}};", + header += std::format("layout(std430,binding={}) buffer {}_ssbo_{}{{uint {}_ssbo{}[];}};", bindings.storage_buffer, stage_name, bindings.storage_buffer, stage_name, index); bindings.storage_buffer += desc.count; @@ -483,7 +484,7 @@ void EmitContext::DefineGenericOutput(size_t index, u32 invocations) { const size_t base_index{static_cast(IR::Attribute::Generic0X) + index * 4}; u32 element{0}; while (element < 4) { - std::string definition{fmt::format("layout(location={}", index)}; + std::string definition{std::format("layout(location={}", index)}; const u32 remainder{4 - element}; const TransformFeedbackVarying* xfb_varying{}; const size_t xfb_varying_index{base_index + element}; @@ -493,19 +494,19 @@ void EmitContext::DefineGenericOutput(size_t index, u32 invocations) { } const u32 num_components{xfb_varying ? xfb_varying->components : remainder}; if (element > 0) { - definition += fmt::format(",component={}", element); + definition += std::format(",component={}", element); } if (xfb_varying) { definition += - fmt::format(",xfb_buffer={},xfb_stride={},xfb_offset={}", xfb_varying->buffer, + std::format(",xfb_buffer={},xfb_stride={},xfb_offset={}", xfb_varying->buffer, xfb_varying->stride, xfb_varying->offset); } - std::string name{fmt::format("out_attr{}", index)}; + std::string name{std::format("out_attr{}", index)}; if (num_components < 4 || element > 0) { - name += fmt::format("_{}", swizzle.substr(element, num_components)); + name += std::format("_{}", swizzle.substr(element, num_components)); } - const auto type{num_components == 1 ? "float" : fmt::format("vec{}", num_components)}; - definition += fmt::format(")out {} {}{};", type, name, OutputDecorator(stage, invocations)); + const auto type{num_components == 1 ? "float" : std::format("vec{}", num_components)}; + definition += std::format(")out {} {}{};", type, name, OutputDecorator(stage, invocations)); header += definition; const GenericElementInfo element_info{ @@ -569,12 +570,12 @@ void EmitContext::DefineHelperFunctions() { const bool is_array{stage == Stage::Geometry}; const auto vertex_arg{is_array ? ",uint vertex" : ""}; std::string func{ - fmt::format("float IndexedAttrLoad(int offset{}){{int base_index=offset>>2;uint " + std::format("float IndexedAttrLoad(int offset{}){{int base_index=offset>>2;uint " "masked_index=uint(base_index)&3u;switch(base_index>>2){{", vertex_arg)}; if (info.loads.AnyComponent(IR::Attribute::PositionX)) { const auto position_idx{is_array ? "gl_in[vertex]." : ""}; - func += fmt::format("case {}:return {}{}[masked_index];", + func += std::format("case {}:return {}{}[masked_index];", static_cast(IR::Attribute::PositionX) >> 2, position_idx, position_name); } @@ -584,7 +585,7 @@ void EmitContext::DefineHelperFunctions() { continue; } const auto vertex_idx{is_array ? "[vertex]" : ""}; - func += fmt::format("case {}:return in_attr{}{}[masked_index];", + func += std::format("case {}:return in_attr{}{}[masked_index];", base_attribute_value + index, index, vertex_idx); } func += "default: return 0.0;}}"; @@ -599,31 +600,31 @@ std::string EmitContext::DefineGlobalMemoryFunctions() { const auto define_body{[&](std::string& func, size_t index, std::string_view return_statement) { const auto& ssbo{info.storage_buffers_descriptors[index]}; const u32 size_cbuf_offset{ssbo.cbuf_offset + 8}; - const auto ssbo_addr{fmt::format("ssbo_addr{}", index)}; - const auto cbuf{fmt::format("{}_cbuf{}", stage_name, ssbo.cbuf_index)}; + const auto ssbo_addr{std::format("ssbo_addr{}", index)}; + const auto cbuf{std::format("{}_cbuf{}", stage_name, ssbo.cbuf_index)}; std::array addr_xy; std::array size_xy; for (size_t i = 0; i < addr_xy.size(); ++i) { const auto addr_loc{ssbo.cbuf_offset + 4 * i}; const auto size_loc{size_cbuf_offset + 4 * i}; - addr_xy[i] = fmt::format("ftou({}[{}].{})", cbuf, addr_loc / 16, Swizzle(addr_loc)); - size_xy[i] = fmt::format("ftou({}[{}].{})", cbuf, size_loc / 16, Swizzle(size_loc)); + addr_xy[i] = std::format("ftou({}[{}].{})", cbuf, addr_loc / 16, Swizzle(addr_loc)); + size_xy[i] = std::format("ftou({}[{}].{})", cbuf, size_loc / 16, Swizzle(size_loc)); } const u32 ssbo_align_mask{~(static_cast(profile.min_ssbo_alignment) - 1U)}; - const auto aligned_low_addr{fmt::format("{}&{}", addr_xy[0], ssbo_align_mask)}; - const auto aligned_addr{fmt::format("uvec2({},{})", aligned_low_addr, addr_xy[1])}; - const auto addr_pack{fmt::format("packUint2x32({})", aligned_addr)}; - const auto addr_statement{fmt::format("uint64_t {}={};", ssbo_addr, addr_pack)}; + const auto aligned_low_addr{std::format("{}&{}", addr_xy[0], ssbo_align_mask)}; + const auto aligned_addr{std::format("uvec2({},{})", aligned_low_addr, addr_xy[1])}; + const auto addr_pack{std::format("packUint2x32({})", aligned_addr)}; + const auto addr_statement{std::format("uint64_t {}={};", ssbo_addr, addr_pack)}; func += addr_statement; - const auto size_vec{fmt::format("uvec2({},{})", size_xy[0], size_xy[1])}; - const auto comp_lhs{fmt::format("(addr>={})", ssbo_addr)}; - const auto comp_rhs{fmt::format("(addr<({}+uint64_t({})))", ssbo_addr, size_vec)}; - const auto comparison{fmt::format("if({}&&{}){{", comp_lhs, comp_rhs)}; + const auto size_vec{std::format("uvec2({},{})", size_xy[0], size_xy[1])}; + const auto comp_lhs{std::format("(addr>={})", ssbo_addr)}; + const auto comp_rhs{std::format("(addr<({}+uint64_t({})))", ssbo_addr, size_vec)}; + const auto comparison{std::format("if({}&&{}){{", comp_lhs, comp_rhs)}; func += comparison; - const auto ssbo_name{fmt::format("{}_ssbo{}", stage_name, index)}; - func += fmt::format(fmt::runtime(return_statement), ssbo_name, ssbo_addr); + const auto ssbo_name{std::format("{}_ssbo{}", stage_name, index)}; + func += std::vformat(return_statement, std::make_format_args(ssbo_name, ssbo_addr)); }}; std::string write_func{"void WriteGlobal32(uint64_t addr,uint data){"}; std::string write_func_64{"void WriteGlobal64(uint64_t addr,uvec2 data){"}; @@ -664,8 +665,8 @@ void EmitContext::SetupImages(Bindings& bindings) { image_buffers.push_back({bindings.image, desc.count}); const auto format{ImageFormatString(desc.format)}; const auto qualifier{ImageAccessQualifier(desc.is_written, desc.is_read)}; - const auto array_decorator{desc.count > 1 ? fmt::format("[{}]", desc.count) : ""}; - header += fmt::format("layout(binding={}{}) uniform {}uimageBuffer img{}{};", + const auto array_decorator{desc.count > 1 ? std::format("[{}]", desc.count) : ""}; + header += std::format("layout(binding={}{}) uniform {}uimageBuffer img{}{};", bindings.image, format, qualifier, bindings.image, array_decorator); bindings.image += desc.count; } @@ -675,8 +676,8 @@ void EmitContext::SetupImages(Bindings& bindings) { const auto format{ImageFormatString(desc.format)}; const auto image_type{ImageType(desc.type)}; const auto qualifier{ImageAccessQualifier(desc.is_written, desc.is_read)}; - const auto array_decorator{desc.count > 1 ? fmt::format("[{}]", desc.count) : ""}; - header += fmt::format("layout(binding={}{})uniform {}{} img{}{};", bindings.image, format, + const auto array_decorator{desc.count > 1 ? std::format("[{}]", desc.count) : ""}; + header += std::format("layout(binding={}{})uniform {}{} img{}{};", bindings.image, format, qualifier, image_type, bindings.image, array_decorator); bindings.image += desc.count; } @@ -687,8 +688,8 @@ void EmitContext::SetupTextures(Bindings& bindings) { for (const auto& desc : info.texture_buffer_descriptors) { texture_buffers.push_back({bindings.texture, desc.count}); const auto sampler_type{ColorSamplerType(TextureType::Buffer)}; - const auto array_decorator{desc.count > 1 ? fmt::format("[{}]", desc.count) : ""}; - header += fmt::format("layout(binding={}) uniform {} tex{}{};", bindings.texture, + const auto array_decorator{desc.count > 1 ? std::format("[{}]", desc.count) : ""}; + header += std::format("layout(binding={}) uniform {} tex{}{};", bindings.texture, sampler_type, bindings.texture, array_decorator); bindings.texture += desc.count; } @@ -697,8 +698,8 @@ void EmitContext::SetupTextures(Bindings& bindings) { textures.push_back({bindings.texture, desc.count}); const auto sampler_type{desc.is_depth ? DepthSamplerType(desc.type) : ColorSamplerType(desc.type, desc.is_multisample)}; - const auto array_decorator{desc.count > 1 ? fmt::format("[{}]", desc.count) : ""}; - header += fmt::format("layout(binding={}) uniform {} tex{}{};", bindings.texture, + const auto array_decorator{desc.count > 1 ? std::format("[{}]", desc.count) : ""}; + header += std::format("layout(binding={}) uniform {} tex{}{};", bindings.texture, sampler_type, bindings.texture, array_decorator); bindings.texture += desc.count; } diff --git a/src/shader_recompiler/backend/glsl/glsl_emit_context.h b/src/shader_recompiler/backend/glsl/glsl_emit_context.h index 331c0588e3..d51533c052 100644 --- a/src/shader_recompiler/backend/glsl/glsl_emit_context.h +++ b/src/shader_recompiler/backend/glsl/glsl_emit_context.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -7,7 +10,7 @@ #include #include -#include +#include #include "shader_recompiler/backend/glsl/var_alloc.h" #include "shader_recompiler/stage.h" @@ -50,9 +53,9 @@ public: const auto var_def{var_alloc.AddDefine(inst, type)}; if (var_def.empty()) { // skip assignment. - code += fmt::format(fmt::runtime(format_str + 3), std::forward(args)...); + code += std::vformat(format_str + 3, std::make_format_args(args...)); } else { - code += fmt::format(fmt::runtime(format_str), var_def, std::forward(args)...); + code += std::vformat(format_str, std::make_format_args(var_def, args...)); } // TODO: Remove this code += '\n'; @@ -130,7 +133,7 @@ public: template void Add(const char* format_str, Args&&... args) { - code += fmt::format(fmt::runtime(format_str), std::forward(args)...); + code += std::vformat(format_str, std::make_format_args(args...)); // TODO: Remove this code += '\n'; } diff --git a/src/shader_recompiler/backend/glsl/var_alloc.cpp b/src/shader_recompiler/backend/glsl/var_alloc.cpp index 3bb84ad32a..0956ff3cf5 100644 --- a/src/shader_recompiler/backend/glsl/var_alloc.cpp +++ b/src/shader_recompiler/backend/glsl/var_alloc.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project @@ -7,7 +7,7 @@ #include #include -#include +#include #include "shader_recompiler/backend/glsl/var_alloc.h" #include "shader_recompiler/exception.h" @@ -68,26 +68,26 @@ std::string FormatFloat(std::string_view value, IR::Type type) { if (value.find_first_of('e') != std::string_view::npos) { // scientific notation const auto cast{type == IR::Type::F32 ? "float" : "double"}; - return fmt::format("{}({})", cast, value); + return std::format("{}({})", cast, value); } const bool needs_dot{value.find_first_of('.') == std::string_view::npos}; const bool needs_suffix{!value.ends_with('f')}; const auto suffix{type == IR::Type::F32 ? "f" : "lf"}; - return fmt::format("{}{}{}", value, needs_dot ? "." : "", needs_suffix ? suffix : ""); + return std::format("{}{}{}", value, needs_dot ? "." : "", needs_suffix ? suffix : ""); } std::string MakeImm(const IR::Value& value) { switch (value.Type()) { case IR::Type::U1: - return fmt::format("{}", value.U1() ? "true" : "false"); + return std::format("{}", value.U1() ? "true" : "false"); case IR::Type::U32: - return fmt::format("{}u", value.U32()); + return std::format("{}u", value.U32()); case IR::Type::F32: - return FormatFloat(fmt::format("{}", value.F32()), IR::Type::F32); + return FormatFloat(std::format("{}", value.F32()), IR::Type::F32); case IR::Type::U64: - return fmt::format("{}ul", value.U64()); + return std::format("{}ul", value.U64()); case IR::Type::F64: - return FormatFloat(fmt::format("{}", value.F64()), IR::Type::F64); + return FormatFloat(std::format("{}", value.F64()), IR::Type::F64); case IR::Type::Void: return ""; default: @@ -98,7 +98,7 @@ std::string MakeImm(const IR::Value& value) { std::string VarAlloc::Representation(u32 index, GlslVarType type) const { const auto prefix{TypePrefix(type)}; - return fmt::format("{}{}", prefix, index); + return std::format("{}{}", prefix, index); } std::string VarAlloc::Representation(Id id) const { diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp index b562e82983..c5ca201f69 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp @@ -11,7 +11,7 @@ #include -#include +#include #include "common/common_types.h" #include "common/div_ceil.h" @@ -184,9 +184,9 @@ void DefineGenericOutput(EmitContext& ctx, size_t index, std::optional invo } if (num_components < 4 || element > 0) { const std::string_view subswizzle{swizzle.substr(element, num_components)}; - ctx.Name(id, fmt::format("out_attr{}_{}", index, subswizzle)); + ctx.Name(id, std::format("out_attr{}_{}", index, subswizzle)); } else { - ctx.Name(id, fmt::format("out_attr{}", index)); + ctx.Name(id, std::format("out_attr{}", index)); } const GenericElementInfo info{ .id = id, @@ -263,9 +263,10 @@ std::string_view StageName(Stage stage) { template void Name(EmitContext& ctx, Id object, std::string_view format_str, Args&&... args) { - ctx.Name(object, fmt::format(fmt::runtime(format_str), StageName(ctx.stage), - std::forward(args)...) - .c_str()); + const auto stage_name = StageName(ctx.stage); + const auto name = std::vformat(format_str, std::make_format_args(stage_name, args...)); + + ctx.Name(object, name); } void DefineConstBuffers(EmitContext& ctx, const Info& info, Id UniformDefinitions::*member_type, @@ -287,7 +288,7 @@ void DefineConstBuffers(EmitContext& ctx, const Info& info, Id UniformDefinition const Id id{ctx.AddGlobalVariable(struct_pointer_type, spv::StorageClass::Uniform)}; ctx.Decorate(id, spv::Decoration::Binding, binding); ctx.Decorate(id, spv::Decoration::DescriptorSet, 0U); - ctx.Name(id, fmt::format("c{}", desc.index)); + ctx.Name(id, std::format("c{}", desc.index)); for (size_t i = 0; i < desc.count; ++i) { ctx.cbufs[desc.index + i].*member_type = id; } @@ -317,7 +318,7 @@ void DefineSsbos(EmitContext& ctx, StorageTypeDefinition& type_def, const Id id{ctx.AddGlobalVariable(struct_pointer, spv::StorageClass::StorageBuffer)}; ctx.Decorate(id, spv::Decoration::Binding, binding); ctx.Decorate(id, spv::Decoration::DescriptorSet, 0U); - ctx.Name(id, fmt::format("ssbo{}", index)); + ctx.Name(id, std::format("ssbo{}", index)); if (ctx.profile.supported_spirv >= 0x00010400) { ctx.interfaces.push_back(id); } @@ -430,10 +431,10 @@ Id CasLoop(EmitContext& ctx, Operation operation, Id array_pointer, Id element_p template std::string NameOf(Stage stage, const Desc& desc, std::string_view prefix) { if (desc.count > 1) { - return fmt::format("{}_{}{}_{:02x}x{}", StageName(stage), prefix, desc.cbuf_index, + return std::format("{}_{}{}_{:02x}x{}", StageName(stage), prefix, desc.cbuf_index, desc.cbuf_offset, desc.count); } else { - return fmt::format("{}_{}{}_{:02x}", StageName(stage), prefix, desc.cbuf_index, + return std::format("{}_{}{}_{:02x}", StageName(stage), prefix, desc.cbuf_index, desc.cbuf_offset); } } @@ -455,8 +456,8 @@ void VectorTypes::Define(Sirit::Module& sirit_ctx, Id base_type, std::string_vie for (int i = 1; i < 4; ++i) { const std::string_view def_name_view( def_name.data(), - fmt::format_to_n(def_name.data(), def_name.size(), "{}x{}", name, i + 1).size); - defs[static_cast(i)] = + std::size_t(std::format_to_n(def_name.data(), def_name.size(), "{}x{}", name, i + 1).size)); + defs[std::size_t(i)] = sirit_ctx.Name(sirit_ctx.TypeVector(base_type, i + 1), def_name_view); } } @@ -1575,7 +1576,7 @@ void EmitContext::DefineInputs(const IR::Program& program) { const Id type{GetAttributeType(*this, input_type)}; const Id id{DefineInput(*this, type, true)}; Decorate(id, spv::Decoration::Location, static_cast(index)); - Name(id, fmt::format("in_attr{}", index)); + Name(id, std::format("in_attr{}", index)); input_generics[index] = GetAttributeInfo(*this, input_type, id); if (info.passthrough.Generic(index) && profile.support_geometry_shader_passthrough) { @@ -1705,7 +1706,7 @@ void EmitContext::DefineOutputs(const IR::Program& program) { Name(frag_color[index], index == 0 ? "frag_color0" : "frag_color0_secondary"); } else { Decorate(frag_color[index], spv::Decoration::Location, index); - Name(frag_color[index], fmt::format("frag_color{}", index)); + Name(frag_color[index], std::format("frag_color{}", index)); } } if (info.stores_frag_depth) { diff --git a/src/shader_recompiler/exception.h b/src/shader_recompiler/exception.h index b97b68a3b6..b01917126d 100644 --- a/src/shader_recompiler/exception.h +++ b/src/shader_recompiler/exception.h @@ -7,6 +7,7 @@ #pragma once #include +#include #include #include @@ -38,21 +39,21 @@ class LogicError : public Exception { public: template explicit LogicError(const char* message, Args&&... args) - : Exception{fmt::format(fmt::runtime(message), std::forward(args)...)} {} + : Exception{std::vformat(message, std::make_format_args(args...))} {} }; class RuntimeError : public Exception { public: template explicit RuntimeError(const char* message, Args&&... args) - : Exception{fmt::format(fmt::runtime(message), std::forward(args)...)} {} + : Exception{std::vformat(message, std::make_format_args(args...))} {} }; class NotImplementedException : public Exception { public: template explicit NotImplementedException(const char* message, Args&&... args) - : Exception{fmt::format(fmt::runtime(message), std::forward(args)...)} { + : Exception{std::vformat(message, std::make_format_args(args...))} { Append(" is not implemented"); } }; @@ -61,7 +62,7 @@ class InvalidArgument : public Exception { public: template explicit InvalidArgument(const char* message, Args&&... args) - : Exception{fmt::format(fmt::runtime(message), std::forward(args)...)} {} + : Exception{std::vformat(message, std::make_format_args(args...))} {} }; -} // namespace Shader +} // namespace Shader \ No newline at end of file diff --git a/src/shader_recompiler/frontend/ir/attribute.h b/src/shader_recompiler/frontend/ir/attribute.h index 4adf980949..0c5c5d7c15 100644 --- a/src/shader_recompiler/frontend/ir/attribute.h +++ b/src/shader_recompiler/frontend/ir/attribute.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include "common/common_types.h" #include "shader_recompiler/exception.h" @@ -266,7 +266,7 @@ constexpr size_t NUM_FIXEDFNCTEXTURE = 10; SRIR_ATTRIBUTE_LIST #undef SRIR_ATTRIBUTE_ELEM default: - return fmt::format("", int(attribute)); + return std::format("", int(attribute)); } } @@ -277,12 +277,12 @@ constexpr size_t NUM_FIXEDFNCTEXTURE = 10; } // namespace Shader::IR template <> -struct fmt::formatter { +struct std::formatter { constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } template auto format(const Shader::IR::Attribute& attribute, FormatContext& ctx) const { - return fmt::format_to(ctx.out(), "{}", Shader::IR::NameOf(attribute)); + return std::format_to(ctx.out(), "{}", Shader::IR::NameOf(attribute)); } }; diff --git a/src/shader_recompiler/frontend/ir/basic_block.cpp b/src/shader_recompiler/frontend/ir/basic_block.cpp index 68fab72b36..db07dd0860 100644 --- a/src/shader_recompiler/frontend/ir/basic_block.cpp +++ b/src/shader_recompiler/frontend/ir/basic_block.cpp @@ -5,6 +5,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include +#include #include #include @@ -56,9 +57,9 @@ void Block::AddBranch(Block* block) { static std::string BlockToIndex(const std::map& block_to_index, Block* block) { if (const auto it{block_to_index.find(block)}; it != block_to_index.end()) { - return fmt::format("{{Block ${}}}", it->second); + return std::format("{{Block ${}}}", it->second); } - return fmt::format("$", reinterpret_cast(block)); + return std::format("$", reinterpret_cast(block)); } static size_t InstIndex(std::map& inst_to_index, size_t& inst_index, @@ -76,27 +77,27 @@ static std::string ArgToIndex(std::map& inst_to_index, size return ""; } if (!arg.IsImmediate() || arg.IsIdentity()) { - return fmt::format("%{}", InstIndex(inst_to_index, inst_index, arg.Inst())); + return std::format("%{}", InstIndex(inst_to_index, inst_index, arg.Inst())); } switch (arg.Type()) { case Type::U1: - return fmt::format("#{}", arg.U1() ? "true" : "false"); + return std::format("#{}", arg.U1() ? "true" : "false"); case Type::U8: - return fmt::format("#{}", arg.U8()); + return std::format("#{}", arg.U8()); case Type::U16: - return fmt::format("#{}", arg.U16()); + return std::format("#{}", arg.U16()); case Type::U32: - return fmt::format("#{}", arg.U32()); + return std::format("#{}", arg.U32()); case Type::U64: - return fmt::format("#{}", arg.U64()); + return std::format("#{}", arg.U64()); case Type::F32: - return fmt::format("#{}", arg.F32()); + return std::format("#{}", arg.F32()); case Type::Reg: - return fmt::format("{}", arg.Reg()); + return std::format("{}", arg.Reg()); case Type::Pred: - return fmt::format("{}", arg.Pred()); + return std::format("{}", arg.Pred()); case Type::Attribute: - return fmt::format("{}", arg.Attribute()); + return std::format("{}", arg.Attribute()); default: return ""; } @@ -112,16 +113,16 @@ std::string DumpBlock(const Block& block, const std::map& std::map& inst_to_index, size_t& inst_index) { std::string ret{"Block"}; if (const auto it{block_to_index.find(&block)}; it != block_to_index.end()) { - ret += fmt::format(" ${}", it->second); + ret += std::format(" ${}", it->second); } ret += '\n'; for (const Inst& inst : block) { const Opcode op{inst.GetOpcode()}; - ret += fmt::format("[{:016x}] ", reinterpret_cast(&inst)); + ret += std::format("[{:016x}] ", reinterpret_cast(&inst)); if (TypeOf(op) != Type::Void) { - ret += fmt::format("%{:<5} = {}", InstIndex(inst_to_index, inst_index, &inst), op); + ret += std::format("%{:<5} = {}", InstIndex(inst_to_index, inst_index, &inst), op); } else { - ret += fmt::format(" {}", op); // '%00000 = ' -> 1 + 5 + 3 = 9 spaces + ret += std::format(" {}", op); // '%00000 = ' -> 1 + 5 + 3 = 9 spaces } const size_t arg_count{inst.NumArgs()}; for (size_t arg_index = 0; arg_index < arg_count; ++arg_index) { @@ -129,7 +130,7 @@ std::string DumpBlock(const Block& block, const std::map& const std::string arg_str{ArgToIndex(inst_to_index, inst_index, arg)}; ret += arg_index != 0 ? ", " : " "; if (op == Opcode::Phi) { - ret += fmt::format("[ {}, {} ]", arg_str, + ret += std::format("[ {}, {} ]", arg_str, BlockToIndex(block_to_index, inst.PhiBlock(arg_index))); } else { ret += arg_str; @@ -138,12 +139,12 @@ std::string DumpBlock(const Block& block, const std::map& const Type actual_type{arg.Type()}; const Type expected_type{ArgTypeOf(op, arg_index)}; if (!AreTypesCompatible(actual_type, expected_type)) { - ret += fmt::format("", actual_type, expected_type); + ret += std::format("", actual_type, expected_type); } } } if (TypeOf(op) != Type::Void) { - ret += fmt::format(" (uses: {})\n", inst.UseCount()); + ret += std::format(" (uses: {})\n", inst.UseCount()); } else { ret += '\n'; } diff --git a/src/shader_recompiler/frontend/ir/condition.cpp b/src/shader_recompiler/frontend/ir/condition.cpp index 4db0c164f0..fdfb97a598 100644 --- a/src/shader_recompiler/frontend/ir/condition.cpp +++ b/src/shader_recompiler/frontend/ir/condition.cpp @@ -1,10 +1,13 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include #include -#include - +#include "common/logging.h" #include "shader_recompiler/frontend/ir/condition.h" namespace Shader::IR { @@ -12,7 +15,7 @@ namespace Shader::IR { std::string NameOf(Condition condition) { std::string ret; if (condition.GetFlowTest() != FlowTest::T) { - ret = fmt::to_string(condition.GetFlowTest()); + ret = std::format("{}", condition.GetFlowTest()); } const auto [pred, negated]{condition.GetPred()}; if (!ret.empty()) { @@ -21,7 +24,7 @@ std::string NameOf(Condition condition) { if (negated) { ret += '!'; } - ret += fmt::to_string(pred); + ret += std::format("{}", pred); return ret; } diff --git a/src/shader_recompiler/frontend/ir/condition.h b/src/shader_recompiler/frontend/ir/condition.h index 89ac42dbe0..1c2bb934d0 100644 --- a/src/shader_recompiler/frontend/ir/condition.h +++ b/src/shader_recompiler/frontend/ir/condition.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -5,7 +8,7 @@ #include -#include +#include #include "common/common_types.h" #include "shader_recompiler/frontend/ir/flow_test.h" @@ -47,12 +50,12 @@ std::string NameOf(Condition condition); } // namespace Shader::IR template <> -struct fmt::formatter { +struct std::formatter { constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } template auto format(const Shader::IR::Condition& cond, FormatContext& ctx) const { - return fmt::format_to(ctx.out(), "{}", Shader::IR::NameOf(cond)); + return std::format_to(ctx.out(), "{}", Shader::IR::NameOf(cond)); } }; diff --git a/src/shader_recompiler/frontend/ir/flow_test.h b/src/shader_recompiler/frontend/ir/flow_test.h index 0bb9666538..7b4c1d42f0 100644 --- a/src/shader_recompiler/frontend/ir/flow_test.h +++ b/src/shader_recompiler/frontend/ir/flow_test.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project @@ -7,7 +7,7 @@ #pragma once #include -#include +#include #include "common/common_types.h" #include "shader_recompiler/exception.h" @@ -59,19 +59,19 @@ enum class FlowTest : u64 { SRIR_FLOW_TEST_LIST #undef SRIR_FLOW_TEST_ELEM default: - return fmt::format("", int(flow_test)); + return std::format("", int(flow_test)); } } } // namespace Shader::IR template <> -struct fmt::formatter { +struct std::formatter { constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } template auto format(const Shader::IR::FlowTest& flow_test, FormatContext& ctx) const { - return fmt::format_to(ctx.out(), "{}", Shader::IR::NameOf(flow_test)); + return std::format_to(ctx.out(), "{}", Shader::IR::NameOf(flow_test)); } }; diff --git a/src/shader_recompiler/frontend/ir/opcodes.h b/src/shader_recompiler/frontend/ir/opcodes.h index 50f9d7b155..a32b2f6045 100644 --- a/src/shader_recompiler/frontend/ir/opcodes.h +++ b/src/shader_recompiler/frontend/ir/opcodes.h @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include "shader_recompiler/frontend/ir/type.h" @@ -86,12 +86,12 @@ extern u8 NUM_ARGS[534]; } // namespace Shader::IR template <> -struct fmt::formatter { +struct std::formatter { constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } template auto format(const Shader::IR::Opcode& op, FormatContext& ctx) const { - return fmt::format_to(ctx.out(), "{}", Shader::IR::NameOf(op)); + return std::format_to(ctx.out(), "{}", Shader::IR::NameOf(op)); } }; diff --git a/src/shader_recompiler/frontend/ir/patch.h b/src/shader_recompiler/frontend/ir/patch.h index 5077e56c2c..686ff34c9e 100644 --- a/src/shader_recompiler/frontend/ir/patch.h +++ b/src/shader_recompiler/frontend/ir/patch.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/shader_recompiler/frontend/ir/pred.h b/src/shader_recompiler/frontend/ir/pred.h index 4c9e8b6bdf..52f8b5667a 100644 --- a/src/shader_recompiler/frontend/ir/pred.h +++ b/src/shader_recompiler/frontend/ir/pred.h @@ -1,9 +1,12 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once -#include +#include namespace Shader::IR { @@ -28,16 +31,16 @@ constexpr size_t NUM_PREDS = 8; } // namespace Shader::IR template <> -struct fmt::formatter { +struct std::formatter { constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } template auto format(const Shader::IR::Pred& pred, FormatContext& ctx) const { if (pred == Shader::IR::Pred::PT) { - return fmt::format_to(ctx.out(), "PT"); + return std::format_to(ctx.out(), "PT"); } else { - return fmt::format_to(ctx.out(), "P{}", static_cast(pred)); + return std::format_to(ctx.out(), "P{}", static_cast(pred)); } } }; diff --git a/src/shader_recompiler/frontend/ir/program.cpp b/src/shader_recompiler/frontend/ir/program.cpp index 39ff92ce75..8f4a0c446f 100644 --- a/src/shader_recompiler/frontend/ir/program.cpp +++ b/src/shader_recompiler/frontend/ir/program.cpp @@ -1,10 +1,13 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include #include -#include +#include #include "shader_recompiler/frontend/ir/basic_block.h" #include "shader_recompiler/frontend/ir/program.h" diff --git a/src/shader_recompiler/frontend/ir/reg.h b/src/shader_recompiler/frontend/ir/reg.h index 97c97420b8..10f8042855 100644 --- a/src/shader_recompiler/frontend/ir/reg.h +++ b/src/shader_recompiler/frontend/ir/reg.h @@ -1,9 +1,12 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once -#include +#include #include "common/common_types.h" #include "shader_recompiler/exception.h" @@ -314,16 +317,16 @@ constexpr Reg operator++(Reg& reg, int) { } // namespace Shader::IR template <> -struct fmt::formatter { +struct std::formatter { constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } template auto format(const Shader::IR::Reg& reg, FormatContext& ctx) const { if (reg == Shader::IR::Reg::RZ) { - return fmt::format_to(ctx.out(), "RZ"); + return std::format_to(ctx.out(), "RZ"); } else if (static_cast(reg) >= 0 && static_cast(reg) < 255) { - return fmt::format_to(ctx.out(), "R{}", static_cast(reg)); + return std::format_to(ctx.out(), "R{}", static_cast(reg)); } else { throw Shader::LogicError("Invalid register with raw value {}", static_cast(reg)); } diff --git a/src/shader_recompiler/frontend/ir/type.h b/src/shader_recompiler/frontend/ir/type.h index 91fabdcf3e..5253713793 100644 --- a/src/shader_recompiler/frontend/ir/type.h +++ b/src/shader_recompiler/frontend/ir/type.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -5,7 +8,7 @@ #include -#include +#include #include "common/common_funcs.h" #include "shader_recompiler/exception.h" @@ -49,12 +52,12 @@ DECLARE_ENUM_FLAG_OPERATORS(Type) } // namespace Shader::IR template <> -struct fmt::formatter { +struct std::formatter { constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } template auto format(const Shader::IR::Type& type, FormatContext& ctx) const { - return fmt::format_to(ctx.out(), "{}", NameOf(type)); + return std::format_to(ctx.out(), "{}", NameOf(type)); } }; diff --git a/src/shader_recompiler/frontend/maxwell/control_flow.cpp b/src/shader_recompiler/frontend/maxwell/control_flow.cpp index 7dabfbf16e..940c4866e7 100644 --- a/src/shader_recompiler/frontend/maxwell/control_flow.cpp +++ b/src/shader_recompiler/frontend/maxwell/control_flow.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include "shader_recompiler/exception.h" @@ -130,9 +130,9 @@ bool HasFlowTest(Opcode opcode) { std::string NameOf(const Block& block) { if (block.begin.IsVirtual()) { - return fmt::format("\"Virtual {}\"", block.begin); + return std::format("\"Virtual {}\"", block.begin); } else { - return fmt::format("\"{}\"", block.begin); + return std::format("\"{}\"", block.begin); } } } // Anonymous namespace @@ -567,19 +567,19 @@ std::string CFG::Dot() const { std::string dot{"digraph shader {\n"}; for (const Function& function : functions) { - dot += fmt::format("\tsubgraph cluster_{} {{\n", function.entrypoint); - dot += fmt::format("\t\tnode [style=filled];\n"); + dot += std::format("\tsubgraph cluster_{} {{\n", function.entrypoint); + dot += std::format("\t\tnode [style=filled];\n"); for (const Block& block : function.blocks) { const std::string name{NameOf(block)}; const auto add_branch = [&](Block* branch, bool add_label) { - dot += fmt::format("\t\t{}->{}", name, NameOf(*branch)); + dot += std::format("\t\t{}->{}", name, NameOf(*branch)); if (add_label && block.cond != IR::Condition{true} && block.cond != IR::Condition{false}) { - dot += fmt::format(" [label=\"{}\"]", block.cond); + dot += std::format(" [label=\"{}\"]", block.cond); } dot += '\n'; }; - dot += fmt::format("\t\t{};\n", name); + dot += std::format("\t\t{};\n", name); switch (block.end_class) { case EndClass::Branch: if (block.cond != IR::Condition{false}) { @@ -595,37 +595,37 @@ std::string CFG::Dot() const { } break; case EndClass::Call: - dot += fmt::format("\t\t{}->N{};\n", name, node_uid); - dot += fmt::format("\t\tN{}->{};\n", node_uid, NameOf(*block.return_block)); - dot += fmt::format("\t\tN{} [label=\"Call {}\"][shape=square][style=stripped];\n", + dot += std::format("\t\t{}->N{};\n", name, node_uid); + dot += std::format("\t\tN{}->{};\n", node_uid, NameOf(*block.return_block)); + dot += std::format("\t\tN{} [label=\"Call {}\"][shape=square][style=stripped];\n", node_uid, block.function_call); dot += '\n'; ++node_uid; break; case EndClass::Exit: - dot += fmt::format("\t\t{}->N{};\n", name, node_uid); - dot += fmt::format("\t\tN{} [label=\"Exit\"][shape=square][style=stripped];\n", + dot += std::format("\t\t{}->N{};\n", name, node_uid); + dot += std::format("\t\tN{} [label=\"Exit\"][shape=square][style=stripped];\n", node_uid); ++node_uid; break; case EndClass::Return: - dot += fmt::format("\t\t{}->N{};\n", name, node_uid); - dot += fmt::format("\t\tN{} [label=\"Return\"][shape=square][style=stripped];\n", + dot += std::format("\t\t{}->N{};\n", name, node_uid); + dot += std::format("\t\tN{} [label=\"Return\"][shape=square][style=stripped];\n", node_uid); ++node_uid; break; case EndClass::Kill: - dot += fmt::format("\t\t{}->N{};\n", name, node_uid); - dot += fmt::format("\t\tN{} [label=\"Kill\"][shape=square][style=stripped];\n", + dot += std::format("\t\t{}->N{};\n", name, node_uid); + dot += std::format("\t\tN{} [label=\"Kill\"][shape=square][style=stripped];\n", node_uid); ++node_uid; break; } } if (function.entrypoint == 8) { - dot += fmt::format("\t\tlabel = \"main\";\n"); + dot += std::format("\t\tlabel = \"main\";\n"); } else { - dot += fmt::format("\t\tlabel = \"Function {}\";\n", function.entrypoint); + dot += std::format("\t\tlabel = \"Function {}\";\n", function.entrypoint); } dot += "\t}\n"; } @@ -634,9 +634,9 @@ std::string CFG::Dot() const { if (function.blocks.empty()) { dot += "Start;\n"; } else { - dot += fmt::format("\tStart -> {};\n", NameOf(*function.blocks.begin())); + dot += std::format("\tStart -> {};\n", NameOf(*function.blocks.begin())); } - dot += fmt::format("\tStart [shape=diamond];\n"); + dot += std::format("\tStart [shape=diamond];\n"); } dot += "}\n"; return dot; diff --git a/src/shader_recompiler/frontend/maxwell/location.h b/src/shader_recompiler/frontend/maxwell/location.h index 3093c7a8ee..4a7ac1bef8 100644 --- a/src/shader_recompiler/frontend/maxwell/location.h +++ b/src/shader_recompiler/frontend/maxwell/location.h @@ -1,9 +1,12 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once -#include +#include #include "common/common_types.h" #include "shader_recompiler/exception.h" @@ -97,12 +100,12 @@ private: } // namespace Shader::Maxwell template <> -struct fmt::formatter { +struct std::formatter { constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } template auto format(const Shader::Maxwell::Location& location, FormatContext& ctx) const { - return fmt::format_to(ctx.out(), "{:04x}", location.Offset()); + return std::format_to(ctx.out(), "{:04x}", location.Offset()); } }; diff --git a/src/shader_recompiler/frontend/maxwell/opcodes.h b/src/shader_recompiler/frontend/maxwell/opcodes.h index 18ed4f6e1a..0bf113f71e 100644 --- a/src/shader_recompiler/frontend/maxwell/opcodes.h +++ b/src/shader_recompiler/frontend/maxwell/opcodes.h @@ -1,9 +1,12 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once -#include +#include namespace Shader::Maxwell { @@ -18,12 +21,12 @@ const char* NameOf(Opcode opcode); } // namespace Shader::Maxwell template <> -struct fmt::formatter { +struct std::formatter { constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } template auto format(const Shader::Maxwell::Opcode& opcode, FormatContext& ctx) const { - return fmt::format_to(ctx.out(), "{}", NameOf(opcode)); + return std::format_to(ctx.out(), "{}", NameOf(opcode)); } }; diff --git a/src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp b/src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp index 329d44443e..b9719751cb 100644 --- a/src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp +++ b/src/shader_recompiler/frontend/maxwell/structured_control_flow.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include @@ -154,15 +154,15 @@ struct Statement : ListBaseHook { std::string DumpExpr(const Statement* stmt) { switch (stmt->type) { case StatementType::Identity: - return fmt::format("{}", stmt->guest_cond); + return std::format("{}", stmt->guest_cond); case StatementType::Not: - return fmt::format("!{}", DumpExpr(stmt->op)); + return std::format("!{}", DumpExpr(stmt->op)); case StatementType::Or: - return fmt::format("{} || {}", DumpExpr(stmt->op_a), DumpExpr(stmt->op_b)); + return std::format("{} || {}", DumpExpr(stmt->op_a), DumpExpr(stmt->op_b)); case StatementType::Variable: - return fmt::format("goto_L{}", stmt->id); + return std::format("goto_L{}", stmt->id); case StatementType::IndirectBranchCond: - return fmt::format("(indirect_branch == {:x})", stmt->location); + return std::format("(indirect_branch == {:x})", stmt->location); default: return ""; } @@ -174,44 +174,44 @@ std::string DumpExpr(const Statement* stmt) { for (auto stmt = tree.begin(); stmt != tree.end(); ++stmt) { switch (stmt->type) { case StatementType::Code: - ret += fmt::format("{} Block {:04x} -> {:04x} ({:#016x});\n", indent, + ret += std::format("{} Block {:04x} -> {:04x} ({:#016x});\n", indent, stmt->block->begin.Offset(), stmt->block->end.Offset(), reinterpret_cast(stmt->block)); break; case StatementType::Goto: - ret += fmt::format("{} if ({}) goto L{};\n", indent, DumpExpr(stmt->cond), + ret += std::format("{} if ({}) goto L{};\n", indent, DumpExpr(stmt->cond), stmt->label->id); break; case StatementType::Label: - ret += fmt::format("{}L{}:\n", indent, stmt->id); + ret += std::format("{}L{}:\n", indent, stmt->id); break; case StatementType::If: - ret += fmt::format("{} if ({}) {{\n", indent, DumpExpr(stmt->cond)); + ret += std::format("{} if ({}) {{\n", indent, DumpExpr(stmt->cond)); ret += DumpTree(stmt->children, indentation + 4); - ret += fmt::format("{} }}\n", indent); + ret += std::format("{} }}\n", indent); break; case StatementType::Loop: - ret += fmt::format("{} do {{\n", indent); + ret += std::format("{} do {{\n", indent); ret += DumpTree(stmt->children, indentation + 4); - ret += fmt::format("{} }} while ({});\n", indent, DumpExpr(stmt->cond)); + ret += std::format("{} }} while ({});\n", indent, DumpExpr(stmt->cond)); break; case StatementType::Break: - ret += fmt::format("{} if ({}) break;\n", indent, DumpExpr(stmt->cond)); + ret += std::format("{} if ({}) break;\n", indent, DumpExpr(stmt->cond)); break; case StatementType::Return: - ret += fmt::format("{} return;\n", indent); + ret += std::format("{} return;\n", indent); break; case StatementType::Kill: - ret += fmt::format("{} kill;\n", indent); + ret += std::format("{} kill;\n", indent); break; case StatementType::Unreachable: - ret += fmt::format("{} unreachable;\n", indent); + ret += std::format("{} unreachable;\n", indent); break; case StatementType::SetVariable: - ret += fmt::format("{} goto_L{} = {};\n", indent, stmt->id, DumpExpr(stmt->op)); + ret += std::format("{} goto_L{} = {};\n", indent, stmt->id, DumpExpr(stmt->op)); break; case StatementType::SetIndirectBranchVariable: - ret += fmt::format("{} indirect_branch = {} + {};\n", indent, stmt->branch_reg, + ret += std::format("{} indirect_branch = {} + {};\n", indent, stmt->branch_reg, stmt->branch_offset); break; case StatementType::Function: diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/integer_floating_point_conversion.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/integer_floating_point_conversion.cpp index 9685b7e43e..4930a8d17e 100644 --- a/src/shader_recompiler/frontend/maxwell/translate/impl/integer_floating_point_conversion.cpp +++ b/src/shader_recompiler/frontend/maxwell/translate/impl/integer_floating_point_conversion.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project diff --git a/src/shader_recompiler/stage.h b/src/shader_recompiler/stage.h index 9af0a1b720..b5d1868aa1 100644 --- a/src/shader_recompiler/stage.h +++ b/src/shader_recompiler/stage.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/video_core/engines/nv01_timer.h b/src/video_core/engines/nv01_timer.h index 9e7d1a1acf..4ec08fde8a 100644 --- a/src/video_core/engines/nv01_timer.h +++ b/src/video_core/engines/nv01_timer.h @@ -36,7 +36,7 @@ public: /// Write multiple values to the register identified by method. void CallMultiMethod(Core::System& system, u32 method, const u32* base_start, u32 amount, u32 methods_pending) override { - LOG_DEBUG(HW_GPU, "method={}, base_start={}, amount={}, pending={}", method, fmt::ptr(base_start), amount, methods_pending); + LOG_DEBUG(HW_GPU, "method={}, base_start={:P}, amount={}, pending={}", method, (const void*) base_start, amount, methods_pending); } struct Regs { diff --git a/src/video_core/engines/puller.cpp b/src/video_core/engines/puller.cpp index 0b05d31718..c7667dd418 100644 --- a/src/video_core/engines/puller.cpp +++ b/src/video_core/engines/puller.cpp @@ -4,6 +4,7 @@ // SPDX-FileCopyrightText: 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later +#include #include "common/assert.h" #include "common/logging.h" #include "common/settings.h" @@ -36,7 +37,7 @@ void Puller::ProcessBindMethod(DmaPusher& dma_pusher, const MethodCall& method_c engine &= Gf100BindClassMask; } - const auto engine_id = static_cast(engine); + const auto engine_id = EngineID(engine); bound_engines[method_call.subchannel] = engine_id; switch (engine_id) { case EngineID::FERMI_TWOD_A: @@ -140,7 +141,7 @@ void Puller::ProcessSemaphoreAcquire(DmaPusher& dma_pusher) { /// Calls a GPU puller method. void Puller::CallPullerMethod(DmaPusher& dma_pusher, const MethodCall& method_call) { regs.reg_array[method_call.method] = method_call.argument; - const auto method = static_cast(method_call.method); + const auto method = BufferMethods(method_call.method); switch (method) { case BufferMethods::BindObject: { diff --git a/src/video_core/gpu_logging/gpu_logging.cpp b/src/video_core/gpu_logging/gpu_logging.cpp index c7c3c4137f..18cf3a8d03 100644 --- a/src/video_core/gpu_logging/gpu_logging.cpp +++ b/src/video_core/gpu_logging/gpu_logging.cpp @@ -3,7 +3,7 @@ #include "video_core/gpu_logging/gpu_logging.h" -#include +#include #include #include @@ -107,7 +107,7 @@ void GPULogger::Initialize(LogLevel level, DriverType driver) { break; } - const auto header = fmt::format( + const auto header = std::format( "=== Eden GPU Logging Started ===\n" "Timestamp: {}\n" "Log Level: {}\n" @@ -134,7 +134,7 @@ void GPULogger::Shutdown() { } // Write statistics - const auto stats = fmt::format( + const auto stats = std::format( "\n=== GPU Logging Statistics ===\n" "Total Vulkan Calls: {}\n" "Total Memory Allocations: {}\n" @@ -203,7 +203,7 @@ void GPULogger::LogVulkanCall(const std::string& call_name, const std::string& p // Log to file const auto log_entry = - fmt::format("[{}] [Vulkan] [Thread:{}] {}({}) -> {}\n", FormatTimestamp(timestamp), + std::format("[{}] [Vulkan] [Thread:{}] {}({}) -> {}\n", FormatTimestamp(timestamp), thread_id, call_name, params, result); WriteToLog(log_entry); } @@ -241,7 +241,7 @@ void GPULogger::LogMemoryAllocation(uintptr_t memory, u64 size, u32 memory_flags } } - const auto log_entry = fmt::format( + const auto log_entry = std::format( "[{}] [Memory] Allocated {} at {:#x} (Device:{}, Host:{})\n", FormatTimestamp(timestamp), FormatMemorySize(size), memory, is_device_local ? "Yes" : "No", is_host_visible ? "Yes" : "No"); @@ -274,7 +274,7 @@ void GPULogger::LogMemoryDeallocation(uintptr_t memory) { if (size > 0) { const auto log_entry = - fmt::format("[{}] [Memory] Deallocated {} at {:#x}\n", FormatTimestamp(timestamp), + std::format("[{}] [Memory] Deallocated {} at {:#x}\n", FormatTimestamp(timestamp), FormatMemorySize(size), memory); WriteToLog(log_entry); } @@ -293,7 +293,7 @@ void GPULogger::LogShaderCompilation(const std::string& shader_name, const auto timestamp = std::chrono::duration_cast( std::chrono::steady_clock::now().time_since_epoch()); - const auto log_entry = fmt::format("[{}] [Shader] Compiled: {} ({})\n", + const auto log_entry = std::format("[{}] [Shader] Compiled: {} ({})\n", FormatTimestamp(timestamp), shader_name, shader_info); WriteToLog(log_entry); } @@ -316,7 +316,7 @@ void DumpSpirvShader(u64 shader_hash, std::span spirv_code) { [[maybe_unused]] const bool created = CreateDir(dump_dir); }); - const auto shader_path = dump_dir / fmt::format("{:016x}_{:016x}.spv", + const auto shader_path = dump_dir / std::format("{:016x}_{:016x}.spv", Settings::GetCurrentProgramID(), shader_hash); Common::FS::IOFile shader_file(shader_path, FileAccessMode::Write, FileType::BinaryFile); if (!shader_file.IsOpen()) { @@ -345,7 +345,7 @@ void GPULogger::LogPipelineStateChange(const std::string& state_info) { std::chrono::steady_clock::now().time_since_epoch()); const auto log_entry = - fmt::format("[{}] [Pipeline] State change: {}\n", FormatTimestamp(timestamp), state_info); + std::format("[{}] [Pipeline] State change: {}\n", FormatTimestamp(timestamp), state_info); WriteToLog(log_entry); } @@ -368,7 +368,7 @@ void GPULogger::LogDriverDebugInfo(const std::string& debug_info) { std::chrono::steady_clock::now().time_since_epoch()); const auto log_entry = - fmt::format("[{}] [Driver] {}\n", FormatTimestamp(timestamp), debug_info); + std::format("[{}] [Driver] {}\n", FormatTimestamp(timestamp), debug_info); WriteToLog(log_entry); } @@ -388,13 +388,13 @@ void GPULogger::LogExtensionUsage(const std::string& extension_name, const std:: } if (is_first_use) { - const auto log_entry = fmt::format("[{}] [Extension] First use of {} in {}\n", + const auto log_entry = std::format("[{}] [Extension] First use of {} in {}\n", FormatTimestamp(timestamp), extension_name, function_name); WriteToLog(log_entry); LOG_INFO(Render_Vulkan, "[GPU Logging] First use of extension {} in {}", extension_name, function_name); } else if (current_level >= LogLevel::Verbose) { - const auto log_entry = fmt::format("[{}] [Extension] {} used in {}\n", + const auto log_entry = std::format("[{}] [Extension] {} used in {}\n", FormatTimestamp(timestamp), extension_name, function_name); WriteToLog(log_entry); } @@ -412,7 +412,7 @@ void GPULogger::LogRenderPassBegin(const std::string& render_pass_info) { const auto timestamp = std::chrono::duration_cast( std::chrono::steady_clock::now().time_since_epoch()); - const auto log_entry = fmt::format("[{}] [RenderPass] Begin: {}\n", + const auto log_entry = std::format("[{}] [RenderPass] Begin: {}\n", FormatTimestamp(timestamp), render_pass_info); WriteToLog(log_entry); } @@ -429,7 +429,7 @@ void GPULogger::LogRenderPassEnd() { const auto timestamp = std::chrono::duration_cast( std::chrono::steady_clock::now().time_since_epoch()); - const auto log_entry = fmt::format("[{}] [RenderPass] End\n", FormatTimestamp(timestamp)); + const auto log_entry = std::format("[{}] [RenderPass] End\n", FormatTimestamp(timestamp)); WriteToLog(log_entry); } @@ -446,7 +446,7 @@ void GPULogger::LogPipelineBind(bool is_compute, const std::string& pipeline_inf std::chrono::steady_clock::now().time_since_epoch()); const char* pipeline_type = is_compute ? "Compute" : "Graphics"; - const auto log_entry = fmt::format("[{}] [Pipeline] Bind {} pipeline: {}\n", + const auto log_entry = std::format("[{}] [Pipeline] Bind {} pipeline: {}\n", FormatTimestamp(timestamp), pipeline_type, pipeline_info); WriteToLog(log_entry); } @@ -463,7 +463,7 @@ void GPULogger::LogDescriptorSetBind(const std::string& descriptor_info) { const auto timestamp = std::chrono::duration_cast( std::chrono::steady_clock::now().time_since_epoch()); - const auto log_entry = fmt::format("[{}] [Descriptor] Bind: {}\n", + const auto log_entry = std::format("[{}] [Descriptor] Bind: {}\n", FormatTimestamp(timestamp), descriptor_info); WriteToLog(log_entry); } @@ -480,7 +480,7 @@ void GPULogger::LogPipelineBarrier(const std::string& barrier_info) { const auto timestamp = std::chrono::duration_cast( std::chrono::steady_clock::now().time_since_epoch()); - const auto log_entry = fmt::format("[{}] [Barrier] {}\n", + const auto log_entry = std::format("[{}] [Barrier] {}\n", FormatTimestamp(timestamp), barrier_info); WriteToLog(log_entry); } @@ -497,7 +497,7 @@ void GPULogger::LogImageOperation(const std::string& operation, const std::strin const auto timestamp = std::chrono::duration_cast( std::chrono::steady_clock::now().time_since_epoch()); - const auto log_entry = fmt::format("[{}] [Image] {}: {}\n", + const auto log_entry = std::format("[{}] [Image] {}: {}\n", FormatTimestamp(timestamp), operation, image_info); WriteToLog(log_entry); } @@ -514,7 +514,7 @@ void GPULogger::LogClearOperation(const std::string& clear_info) { const auto timestamp = std::chrono::duration_cast( std::chrono::steady_clock::now().time_since_epoch()); - const auto log_entry = fmt::format("[{}] [Clear] {}\n", + const auto log_entry = std::format("[{}] [Clear] {}\n", FormatTimestamp(timestamp), clear_info); WriteToLog(log_entry); } @@ -548,7 +548,7 @@ GPUStateSnapshot GPULogger::GetCurrentSnapshot() { // Capture memory status { std::lock_guard lock(memory_mutex); - snapshot.memory_status = fmt::format( + snapshot.memory_status = std::format( "Total Allocations: {}\n" "Current Usage: {}\n" "Peak Usage: {}\n" @@ -579,7 +579,7 @@ void GPULogger::DumpStateToFile(const std::string& crash_reason) { const auto now = std::chrono::system_clock::now(); const auto timestamp = std::chrono::duration_cast( now.time_since_epoch()).count(); - const auto crash_dump_path = crashes_dir / fmt::format("crash_{}.gpu-dump", timestamp); + const auto crash_dump_path = crashes_dir / std::format("crash_{}.gpu-dump", timestamp); auto crash_file = std::make_unique(crash_dump_path, FileAccessMode::Write, FileType::TextFile); @@ -605,7 +605,7 @@ void GPULogger::DumpStateToFile(const std::string& crash_reason) { } // Write crash dump header - const auto header = fmt::format( + const auto header = std::format( "=== GPU CRASH DUMP ===\n" "Timestamp: {}\n" "Reason: {}\n" @@ -615,11 +615,11 @@ void GPULogger::DumpStateToFile(const std::string& crash_reason) { static_cast(crash_file->WriteString(header)); // Write recent Vulkan calls - static_cast(crash_file->WriteString(fmt::format("=== RECENT VULKAN API CALLS (Last {}) ===\n", + static_cast(crash_file->WriteString(std::format("=== RECENT VULKAN API CALLS (Last {}) ===\n", snapshot.recent_calls.size()))); for (const auto& call : snapshot.recent_calls) { const auto call_str = - fmt::format("[{}] [Thread:{}] {}({}) -> {}\n", FormatTimestamp(call.timestamp), + std::format("[{}] [Thread:{}] {}({}) -> {}\n", FormatTimestamp(call.timestamp), call.thread_id, call.call_name, call.parameters, call.result); static_cast(crash_file->WriteString(call_str)); } @@ -680,7 +680,7 @@ DriverType GPULogger::GetDriverType() const { std::string GPULogger::GetStatistics() const { std::lock_guard lock(memory_mutex); - return fmt::format( + return std::format( "Vulkan Calls: {}, Allocations: {}, Deallocations: {}, " "Current Memory: {}, Peak Memory: {}", total_vulkan_calls, total_allocations, total_deallocations, @@ -709,19 +709,19 @@ void GPULogger::WriteToLog(const std::string& message) { std::string GPULogger::FormatTimestamp(std::chrono::microseconds timestamp) const { const auto seconds = timestamp.count() / 1000000; const auto microseconds = timestamp.count() % 1000000; - return fmt::format("{:4d}.{:06d}", seconds, microseconds); + return std::format("{:4d}.{:06d}", seconds, microseconds); } std::string GPULogger::FormatMemorySize(u64 bytes) const { using namespace Common::Literals; if (bytes >= 1_GiB) { - return fmt::format("{:.2f} GiB", static_cast(bytes) / (1_GiB)); + return std::format("{:.2f} GiB", static_cast(bytes) / (1_GiB)); } else if (bytes >= 1_MiB) { - return fmt::format("{:.2f} MiB", static_cast(bytes) / (1_MiB)); + return std::format("{:.2f} MiB", static_cast(bytes) / (1_MiB)); } else if (bytes >= 1_KiB) { - return fmt::format("{:.2f} KiB", static_cast(bytes) / (1_KiB)); + return std::format("{:.2f} KiB", static_cast(bytes) / (1_KiB)); } else { - return fmt::format("{} B", bytes); + return std::format("{} B", bytes); } } diff --git a/src/video_core/gpu_logging/gpu_state_capture.cpp b/src/video_core/gpu_logging/gpu_state_capture.cpp index 19e655a71b..8ed61249c6 100644 --- a/src/video_core/gpu_logging/gpu_state_capture.cpp +++ b/src/video_core/gpu_logging/gpu_state_capture.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "video_core/gpu_logging/gpu_state_capture.h" -#include +#include namespace GPU::Logging { @@ -15,12 +15,12 @@ std::string GPUStateCapture::SerializeState(const GPUStateSnapshot& snapshot) { result += "=== GPU STATE SNAPSHOT ===\n\n"; - result += fmt::format("Driver: {}\n", static_cast(snapshot.driver_type)); - result += fmt::format("Recent Calls: {}\n\n", snapshot.recent_calls.size()); + result += std::format("Driver: {}\n", static_cast(snapshot.driver_type)); + result += std::format("Recent Calls: {}\n\n", snapshot.recent_calls.size()); result += "=== RECENT VULKAN CALLS ===\n"; for (const auto& call : snapshot.recent_calls) { - result += fmt::format("{}: {}({}) -> {}\n", call.timestamp.count(), call.call_name, + result += std::format("{}: {}({}) -> {}\n", call.timestamp.count(), call.call_name, call.parameters, call.result); } diff --git a/src/video_core/host1x/codec_types.h b/src/video_core/host1x/codec_types.h index da9b713b26..d7800081d8 100644 --- a/src/video_core/host1x/codec_types.h +++ b/src/video_core/host1x/codec_types.h @@ -26,7 +26,7 @@ struct Offset { private: u32 offset; }; -static_assert(std::is_trivial_v, "Offset must be trivial"); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v, "Offset must be trivial"); static_assert(sizeof(Offset) == 0x4, "Offset has the wrong size!"); struct H264ParameterSet { diff --git a/src/video_core/host1x/ffmpeg.cpp b/src/video_core/host1x/ffmpeg.cpp index 676e5820a5..54adcd8d1e 100644 --- a/src/video_core/host1x/ffmpeg.cpp +++ b/src/video_core/host1x/ffmpeg.cpp @@ -154,20 +154,22 @@ Frame::~Frame() { av_frame_free(&m_frame); } +static AVCodecID GetAVCodec(Tegra::Host1x::NvdecCommon::VideoCodec codec) { + switch (codec) { + case Tegra::Host1x::NvdecCommon::VideoCodec::H264: + return AV_CODEC_ID_H264; + case Tegra::Host1x::NvdecCommon::VideoCodec::VP8: + return AV_CODEC_ID_VP8; + case Tegra::Host1x::NvdecCommon::VideoCodec::VP9: + return AV_CODEC_ID_VP9; + default: + UNIMPLEMENTED_MSG("Unknown codec {}", codec); + return AV_CODEC_ID_NONE; + } +} + Decoder::Decoder(Tegra::Host1x::NvdecCommon::VideoCodec codec) { - const AVCodecID av_codec = [&] { - switch (codec) { - case Tegra::Host1x::NvdecCommon::VideoCodec::H264: - return AV_CODEC_ID_H264; - case Tegra::Host1x::NvdecCommon::VideoCodec::VP8: - return AV_CODEC_ID_VP8; - case Tegra::Host1x::NvdecCommon::VideoCodec::VP9: - return AV_CODEC_ID_VP9; - default: - UNIMPLEMENTED_MSG("Unknown codec {}", codec); - return AV_CODEC_ID_NONE; - } - }(); + const AVCodecID av_codec = GetAVCodec(codec); #if defined(__ANDROID__) if (Settings::values.nvdec_emulation.GetValue() == Settings::NvdecEmulation::Gpu) { diff --git a/src/video_core/host1x/nvdec_common.h b/src/video_core/host1x/nvdec_common.h index 0857a9f95c..2fd1a00bf9 100644 --- a/src/video_core/host1x/nvdec_common.h +++ b/src/video_core/host1x/nvdec_common.h @@ -32,7 +32,7 @@ struct Offset { private: u64 offset; }; -static_assert(std::is_trivial_v, "Offset must be trivial"); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v, "Offset must be trivial"); static_assert(sizeof(Offset) == 0x8, "Offset has the wrong size!"); // NVDEC should use a 32-bit address space, but is mapped to 64-bit, diff --git a/src/video_core/host1x/vic.h b/src/video_core/host1x/vic.h index 1a580474b5..4a94b0c6fb 100644 --- a/src/video_core/host1x/vic.h +++ b/src/video_core/host1x/vic.h @@ -114,7 +114,7 @@ struct Offset { private: u32 offset; }; -static_assert(std::is_trivial_v, "Offset must be trivial"); +static_assert(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v, "Offset must be trivial"); static_assert(sizeof(Offset) == 0x4, "Offset has the wrong size!"); struct PlaneOffsets { diff --git a/src/video_core/macro.cpp b/src/video_core/macro.cpp index 86f528af15..82a23eb3c7 100644 --- a/src/video_core/macro.cpp +++ b/src/video_core/macro.cpp @@ -1326,7 +1326,7 @@ static void Dump(u64 hash, std::span code, bool decompiled = false) { return; } const char* const variant_suffix = decompiled ? "jit" : "raw"; - const auto name{dump_dir / fmt::format("{:016x}_{:016x}_{}.macro", + const auto name{dump_dir / std::format("{:016x}_{:016x}_{}.macro", Settings::GetCurrentProgramID(), hash, variant_suffix)}; std::fstream macro_file(name, std::ios::out | std::ios::binary); diff --git a/src/video_core/post_processing/fx_chain.cpp b/src/video_core/post_processing/fx_chain.cpp index 882fdaf726..15022416f0 100644 --- a/src/video_core/post_processing/fx_chain.cpp +++ b/src/video_core/post_processing/fx_chain.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include #include "common/settings.h" #include "video_core/post_processing/fx_chain.h" @@ -94,7 +94,7 @@ std::string SerializeFxChain(std::span entries) { if (!out.empty()) { out += ';'; } - out += fmt::format("{}|{}|", entry.file, entry.technique); + out += std::format("{}|{}|", entry.file, entry.technique); bool first = true; for (const auto& [name, value] : entry.values) { @@ -111,7 +111,7 @@ std::string SerializeFxChain(std::span entries) { if (i > 0) { out += '/'; } - out += fmt::format("{}", value[i]); + out += std::format("{}", value[i]); } } } diff --git a/src/video_core/query_cache/types.h b/src/video_core/query_cache/types.h index 0c6a882e2c..e026b7fa55 100644 --- a/src/video_core/query_cache/types.h +++ b/src/video_core/query_cache/types.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/video_core/renderer_opengl/gl_buffer_cache.cpp b/src/video_core/renderer_opengl/gl_buffer_cache.cpp index fb65a132d0..399045fa55 100644 --- a/src/video_core/renderer_opengl/gl_buffer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_buffer_cache.cpp @@ -56,7 +56,7 @@ Buffer::Buffer(BufferCacheRuntime& runtime, DAddr cpu_addr_, u64 size_bytes_, bo : VideoCommon::BufferBase(cpu_addr_, size_bytes_) { buffer.Create(); if (runtime.device.HasDebuggingToolAttached()) { - const std::string name = fmt::format("Buffer {:#x}", CpuAddr()); + const std::string name = std::format("Buffer {:#x}", CpuAddr()); glObjectLabel(GL_BUFFER, buffer.handle, static_cast(name.size()), name.data()); } glNamedBufferData(buffer.handle, SizeBytes(), nullptr, GL_DYNAMIC_DRAW); diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp index 277cf222fa..05c00506c9 100644 --- a/src/video_core/renderer_opengl/gl_shader_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp @@ -284,7 +284,7 @@ void ShaderCache::LoadDiskResources(u64 title_id, std::stop_token stop_loading, return; } const auto shader_dir{Common::FS::GetEdenPath(Common::FS::EdenPath::ShaderDir)}; - const auto base_dir{shader_dir / fmt::format("{:016x}", title_id)}; + const auto base_dir{shader_dir / std::format("{:016x}", title_id)}; if (!Common::FS::CreateDir(shader_dir) || !Common::FS::CreateDir(base_dir)) { LOG_ERROR(Common_Filesystem, "Failed to create shader cache directories"); return; diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp index 680cb2179f..a1efb4f340 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.cpp +++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp @@ -521,7 +521,7 @@ TextureCacheRuntime::TextureCacheRuntime(const Device& device_, ProgramManager& } const auto set_view = [this](Shader::TextureType type, GLuint handle) { if (device.HasDebuggingToolAttached()) { - const std::string name = fmt::format("NullImage {}", type); + const std::string name = std::format("NullImage {}", type); glObjectLabel(GL_TEXTURE, handle, static_cast(name.size()), name.data()); } null_image_views[static_cast(type)] = handle; diff --git a/src/video_core/renderer_opengl/present/filters.cpp b/src/video_core/renderer_opengl/present/filters.cpp index e47593fc80..a04227e8c6 100644 --- a/src/video_core/renderer_opengl/present/filters.cpp +++ b/src/video_core/renderer_opengl/present/filters.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2024 Torzu Emulator Project @@ -71,7 +71,7 @@ std::unique_ptr MakeLanczos(const Device& device) { std::unique_ptr MakeScaleForce(const Device& device) { return std::make_unique( device, CreateBilinearSampler(), - fmt::format("#version 460\n{}", HostShaders::OPENGL_PRESENT_SCALEFORCE_FRAG)); + std::format("#version 460\n{}", HostShaders::OPENGL_PRESENT_SCALEFORCE_FRAG)); } std::unique_ptr MakeArea(const Device& device) { diff --git a/src/video_core/renderer_opengl/present/util.h b/src/video_core/renderer_opengl/present/util.h index 67f03aa275..0a3f864f0c 100644 --- a/src/video_core/renderer_opengl/present/util.h +++ b/src/video_core/renderer_opengl/present/util.h @@ -1,8 +1,12 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once +#include #include #include "common/assert.h" @@ -12,7 +16,7 @@ namespace OpenGL { static inline void ReplaceInclude(std::string& shader_source, std::string_view include_name, std::string_view include_content) { - const std::string include_string = fmt::format("#include \"{}\"", include_name); + const std::string include_string = std::format("#include \"{}\"", include_name); const std::size_t pos = shader_source.find(include_string); ASSERT(pos != std::string::npos); shader_source.replace(pos, include_string.size(), include_content); diff --git a/src/video_core/renderer_vulkan/pipeline_statistics.cpp b/src/video_core/renderer_vulkan/pipeline_statistics.cpp index 04f42c71a6..8a4b7c84f7 100644 --- a/src/video_core/renderer_vulkan/pipeline_statistics.cpp +++ b/src/video_core/renderer_vulkan/pipeline_statistics.cpp @@ -6,7 +6,7 @@ #include -#include +#include #include "common/common_types.h" #include "common/logging.h" @@ -81,7 +81,8 @@ void PipelineStatistics::Report() const { std::string report; const auto add = [&](const char* fmt, u64 value) { if (value > 0) { - report += fmt::format(fmt::runtime(fmt), static_cast(value) / num); + auto rep_num = double(value) / num; + report += std::vformat(fmt, std::make_format_args(rep_num)); } }; add("Code size: {:9.03f}\n", total.code_size); diff --git a/src/video_core/renderer_vulkan/present/window_adapt_pass.cpp b/src/video_core/renderer_vulkan/present/window_adapt_pass.cpp index 024d31adc7..4754ce2a72 100644 --- a/src/video_core/renderer_vulkan/present/window_adapt_pass.cpp +++ b/src/video_core/renderer_vulkan/present/window_adapt_pass.cpp @@ -207,7 +207,7 @@ void WindowAdaptPass::Draw(const Device& device, RasterizerVulkan& rasterizer, S } } - scheduler.Record([=](vk::CommandBuffer cmdbuf) { + scheduler.Record([=, this](vk::CommandBuffer cmdbuf) { const f32 bg_red = Settings::values.bg_red.GetValue() / 255.0f; const f32 bg_green = Settings::values.bg_green.GetValue() / 255.0f; const f32 bg_blue = Settings::values.bg_blue.GetValue() / 255.0f; diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.cpp b/src/video_core/renderer_vulkan/renderer_vulkan.cpp index a1c6c4d907..888c49d765 100644 --- a/src/video_core/renderer_vulkan/renderer_vulkan.cpp +++ b/src/video_core/renderer_vulkan/renderer_vulkan.cpp @@ -12,7 +12,7 @@ #include #include -#include +#include #include "common/logging.h" #include @@ -78,7 +78,7 @@ constexpr VkExtent3D CaptureImageExtent{ constexpr VkFormat CaptureFormat = VK_FORMAT_A8B8G8R8_UNORM_PACK32; std::string GetReadableVersion(u32 version) { - return fmt::format("{}.{}.{}", VK_VERSION_MAJOR(version), VK_VERSION_MINOR(version), + return std::format("{}.{}.{}", VK_VERSION_MAJOR(version), VK_VERSION_MINOR(version), VK_VERSION_PATCH(version)); } @@ -92,19 +92,28 @@ std::string GetDriverVersion(const Device& device) { const u32 minor = (version >> 14) & 0x0ff; const u32 secondary = (version >> 6) & 0x0ff; const u32 tertiary = version & 0x003f; - return fmt::format("{}.{}.{}.{}", major, minor, secondary, tertiary); + return std::format("{}.{}.{}.{}", major, minor, secondary, tertiary); } if (device.GetDriverID() == VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS) { const u32 major = version >> 14; const u32 minor = version & 0x3fff; - return fmt::format("{}.{}", major, minor); + return std::format("{}.{}", major, minor); } return GetReadableVersion(version); } std::string BuildCommaSeparatedExtensions( const std::set>& available_extensions) { - return fmt::format("{}", fmt::join(available_extensions, ",")); + std::string joined; + + for (const auto &s : available_extensions) { + if (joined.empty()) + joined += ','; + + joined += s; + } + + return joined; } } // Anonymous namespace @@ -195,7 +204,7 @@ try Report(); } catch (const vk::Exception& exception) { LOG_ERROR(Render_Vulkan, "Vulkan initialization failed with error: {}", exception.what()); - throw std::runtime_error{fmt::format("Vulkan initialization error {}", exception.what())}; + throw std::runtime_error{std::format("Vulkan initialization error {}", exception.what())}; } RendererVulkan::~RendererVulkan() { @@ -255,7 +264,7 @@ void RendererVulkan::Report() const { const std::string vendor_name{device.GetVendorName()}; const std::string model_name{device.GetModelName()}; const std::string driver_version = GetDriverVersion(device); - const std::string driver_name = fmt::format("{} {}", vendor_name, driver_version); + const std::string driver_name = std::format("{} {}", vendor_name, driver_version); const std::string api_version = GetReadableVersion(device.ApiVersion()); diff --git a/src/video_core/renderer_vulkan/vk_buffer_cache.cpp b/src/video_core/renderer_vulkan/vk_buffer_cache.cpp index 493de2cc20..488213b95a 100644 --- a/src/video_core/renderer_vulkan/vk_buffer_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_buffer_cache.cpp @@ -112,7 +112,7 @@ Buffer::Buffer(BufferCacheRuntime& runtime, DAddr cpu_addr_, u64 size_bytes_, tracker{SizeBytes()} { sparse_compatible = sparse_compatible_; if (runtime.device.HasDebuggingToolAttached()) { - buffer.SetObjectNameEXT(fmt::format("Buffer {:#x}", CpuAddr()).c_str()); + buffer.SetObjectNameEXT(std::format("Buffer {:#x}", CpuAddr()).c_str()); } if (device->IsBufferDeviceAddressSupported()) { device_address = device->GetLogical().GetBufferDeviceAddress(*buffer); diff --git a/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp b/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp index 29356cfcec..a521e94a94 100644 --- a/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include "video_core/renderer_vulkan/pipeline_helper.h" #include "video_core/renderer_vulkan/pipeline_statistics.h" diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index c9e4f939b1..3c1867a19d 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include "video_core/renderer_vulkan/pipeline_helper.h" @@ -619,7 +619,7 @@ bool GraphicsPipeline::ConfigureDraw(const RescalingPushConstant& rescaling, // Log graphics pipeline binding if (bind_pipeline && GPU::Logging::IsActive() && Settings::values.gpu_log_vulkan_calls.GetValue()) { - const std::string pipeline_info = fmt::format("hash={:#016x}", key.Hash()); + const std::string pipeline_info = std::format("hash={:#016x}", key.Hash()); GPU::Logging::GPULogger::GetInstance().LogPipelineBind(false, pipeline_info); } @@ -1103,7 +1103,7 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) { // Log graphics pipeline creation if (GPU::Logging::IsActive()) { - const std::string pipeline_info = fmt::format( + const std::string pipeline_info = std::format( "GraphicsPipeline created: stages={}, attachments={}", shader_stages.size(), color_blend_ci.attachmentCount diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index 228c2c41f8..b840357733 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp @@ -618,7 +618,7 @@ void PipelineCache::LoadDiskResources(u64 title_id, std::stop_token stop_loading } const auto shader_dir{Common::FS::GetEdenPath(Common::FS::EdenPath::ShaderDir)}; - const auto base_dir{shader_dir / fmt::format("{:016x}", title_id)}; + const auto base_dir{shader_dir / std::format("{:016x}", title_id)}; if (!Common::FS::CreateDir(shader_dir) || !Common::FS::CreateDir(base_dir)) { LOG_ERROR(Common_Filesystem, "Failed to create pipeline cache directories"); return; @@ -889,9 +889,9 @@ std::unique_ptr PipelineCache::CreateGraphicsPipeline( const bool should_dump = Settings::values.gpu_log_shader_dumps.GetValue(); if (should_log || should_dump) { static constexpr std::array stage_names{"vertex", "tess_control", "tess_eval", "geometry", "fragment"}; - const std::string shader_name = fmt::format("shader_{:016x}_{}", key.unique_hashes[index], stage_names[stage_index]); + const std::string shader_name = std::format("shader_{:016x}_{}", key.unique_hashes[index], stage_names[stage_index]); if (should_log) { - const std::string shader_info = fmt::format("SPIR-V size: {} bytes, hash: {:016x}", + const std::string shader_info = std::format("SPIR-V size: {} bytes, hash: {:016x}", code.size() * sizeof(u32), key.unique_hashes[index]); GPU::Logging::GPULogger::GetInstance().LogShaderCompilation(shader_name, shader_info); } @@ -902,7 +902,7 @@ std::unique_ptr PipelineCache::CreateGraphicsPipeline( } if (device.HasDebuggingToolAttached()) { - const std::string name{fmt::format("Shader {:016x}", key.unique_hashes[index])}; + const std::string name{std::format("Shader {:016x}", key.unique_hashes[index])}; modules[stage_index].SetObjectNameEXT(name.c_str()); } previous_stage = &program; @@ -1015,9 +1015,9 @@ std::unique_ptr PipelineCache::CreateComputePipeline( const bool should_log = GPU::Logging::IsActive(); const bool should_dump = Settings::values.gpu_log_shader_dumps.GetValue(); if (should_log || should_dump) { - const std::string shader_name = fmt::format("shader_{:016x}_compute", key.unique_hash); + const std::string shader_name = std::format("shader_{:016x}_compute", key.unique_hash); if (should_log) { - const std::string shader_info = fmt::format("SPIR-V size: {} bytes, hash: {:016x}", + const std::string shader_info = std::format("SPIR-V size: {} bytes, hash: {:016x}", code.size() * sizeof(u32), key.unique_hash); GPU::Logging::GPULogger::GetInstance().LogShaderCompilation(shader_name, shader_info); } @@ -1028,7 +1028,7 @@ std::unique_ptr PipelineCache::CreateComputePipeline( } if (device.HasDebuggingToolAttached()) { - const auto name{fmt::format("Shader {:016x}", key.unique_hash)}; + const auto name{std::format("Shader {:016x}", key.unique_hash)}; spv_module.SetObjectNameEXT(name.c_str()); } Common::ThreadWorker* const thread_worker{build_in_parallel ? &workers : nullptr}; diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 1483d37355..2b95d9acf6 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include "video_core/renderer_vulkan/renderer_vulkan.h" @@ -382,10 +382,10 @@ void RasterizerVulkan::Draw(bool is_indexed, u32 instance_count) { if (GPU::Logging::IsActive() && Settings::values.gpu_log_vulkan_calls.GetValue()) { const std::string params = is_indexed ? - fmt::format("vertices={}, instances={}, firstIndex={}, baseVertex={}, baseInstance={}", + std::format("vertices={}, instances={}, firstIndex={}, baseVertex={}, baseInstance={}", draw_params.num_vertices, draw_params.num_instances, draw_params.first_index, draw_params.base_vertex, draw_params.base_instance) : - fmt::format("vertices={}, instances={}, firstVertex={}, firstInstance={}", + std::format("vertices={}, instances={}, firstVertex={}, firstInstance={}", draw_params.num_vertices, draw_params.num_instances, draw_params.base_vertex, draw_params.base_instance); GPU::Logging::GPULogger::GetInstance().LogVulkanCall( @@ -442,7 +442,7 @@ void RasterizerVulkan::DrawIndirect() { // Log indirect draw call if (GPU::Logging::IsActive() && Settings::values.gpu_log_vulkan_calls.GetValue()) { - const std::string log_params = fmt::format("drawCount={}, stride={}", + const std::string log_params = std::format("drawCount={}, stride={}", params.max_draw_counts, params.stride); GPU::Logging::GPULogger::GetInstance().LogVulkanCall( params.is_indexed ? "vkCmdDrawIndexedIndirect" : "vkCmdDrawIndirect", @@ -740,7 +740,7 @@ void RasterizerVulkan::DispatchCompute() { // Log compute dispatch if (GPU::Logging::IsActive() && Settings::values.gpu_log_vulkan_calls.GetValue()) { - const std::string params = fmt::format("groupCountX={}, groupCountY={}, groupCountZ={}", + const std::string params = std::format("groupCountX={}, groupCountY={}, groupCountZ={}", dim[0], dim[1], dim[2]); GPU::Logging::GPULogger::GetInstance().LogVulkanCall( "vkCmdDispatch", params, VK_SUCCESS); diff --git a/src/video_core/renderer_vulkan/vk_scheduler.cpp b/src/video_core/renderer_vulkan/vk_scheduler.cpp index 4a7a7d5e78..fafa5cc4cc 100644 --- a/src/video_core/renderer_vulkan/vk_scheduler.cpp +++ b/src/video_core/renderer_vulkan/vk_scheduler.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include "video_core/renderer_vulkan/vk_query_cache.h" @@ -103,7 +103,7 @@ void Scheduler::BeginRenderPassImpl(const Framebuffer* framebuffer, VkRenderPass if (GPU::Logging::IsActive() && Settings::values.gpu_log_vulkan_calls.GetValue()) { const std::string render_pass_info = - fmt::format("renderArea={}x{}, numImages={}", render_area.width, render_area.height, + std::format("renderArea={}x{}, numImages={}", render_area.width, render_area.height, framebuffer->NumImages()); GPU::Logging::GPULogger::GetInstance().LogRenderPassBegin(render_pass_info); } diff --git a/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp b/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp index 7b6571d33d..f4e8a9a53d 100644 --- a/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp +++ b/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include "common/alignment.h" #include "common/assert.h" @@ -225,7 +225,7 @@ StagingBufferRef StagingBufferPool::CreateStagingBuffer(size_t size, MemoryUsage vk::Buffer buffer = memory_allocator.CreateBuffer(buffer_ci, usage); if (device.HasDebuggingToolAttached()) { ++buffer_index; - buffer.SetObjectNameEXT(fmt::format("Staging Buffer {}", buffer_index).c_str()); + buffer.SetObjectNameEXT(std::format("Staging Buffer {}", buffer_index).c_str()); } const std::span mapped_span = buffer.Mapped(); const VkDeviceAddress buffer_address = diff --git a/src/video_core/shader_environment.cpp b/src/video_core/shader_environment.cpp index 4d5db7e511..1c5e69695f 100644 --- a/src/video_core/shader_environment.cpp +++ b/src/video_core/shader_environment.cpp @@ -102,7 +102,7 @@ static void DumpImpl(u64 /*pipeline_hash*/, u64 shader_hash, std::span>= samples_x; height >>= samples_y; - resource += fmt::format(":{}xMSAA", image.info.num_samples); + resource += std::format(":{}xMSAA", image.info.num_samples); } if (num_layers > 1) { - resource += fmt::format(":L{}", num_layers); + resource += std::format(":L{}", num_layers); } if (num_levels > 1) { - resource += fmt::format(":M{}", num_levels); + resource += std::format(":M{}", num_levels); } switch (image.info.type) { case ImageType::e1D: - return fmt::format("Image 1D {:#x} {}{}", gpu_addr, width, resource); + return std::format("Image 1D {:#x} {}{}", gpu_addr, width, resource); case ImageType::e2D: - return fmt::format("Image 2D {:#x} {}x{}{}", gpu_addr, width, height, resource); + return std::format("Image 2D {:#x} {}x{}{}", gpu_addr, width, height, resource); case ImageType::e3D: - return fmt::format("Image 2D {:#x} {}x{}x{}{}", gpu_addr, width, height, depth, resource); + return std::format("Image 2D {:#x} {}x{}x{}{}", gpu_addr, width, height, depth, resource); case ImageType::Linear: - return fmt::format("Image Linear {:#x} {}x{}", gpu_addr, width, height); + return std::format("Image Linear {:#x} {}x{}", gpu_addr, width, height); case ImageType::Buffer: - return fmt::format("Buffer {:#x} {}", image.gpu_addr, image.info.size.width); + return std::format("Buffer {:#x} {}", image.gpu_addr, image.info.size.width); } return "Invalid"; } @@ -60,28 +60,28 @@ std::string Name(const ImageViewBase& image_view, GPUVAddr addr) { const u32 num_levels = image_view.range.extent.levels; const u32 num_layers = image_view.range.extent.layers; - const std::string level = num_levels > 1 ? fmt::format(":{}", num_levels) : ""; + const std::string level = num_levels > 1 ? std::format(":{}", num_levels) : ""; switch (image_view.type) { case ImageViewType::e1D: - return fmt::format("ImageView 1D {:#x} {}{}", addr, width, level); + return std::format("ImageView 1D {:#x} {}{}", addr, width, level); case ImageViewType::e2D: - return fmt::format("ImageView 2D {:#x} {}x{}{}", addr, width, height, level); + return std::format("ImageView 2D {:#x} {}x{}{}", addr, width, height, level); case ImageViewType::Cube: - return fmt::format("ImageView Cube {:#x} {}x{}{}", addr, width, height, level); + return std::format("ImageView Cube {:#x} {}x{}{}", addr, width, height, level); case ImageViewType::e3D: - return fmt::format("ImageView 3D {:#x} {}x{}x{}{}", addr, width, height, depth, level); + return std::format("ImageView 3D {:#x} {}x{}x{}{}", addr, width, height, depth, level); case ImageViewType::e1DArray: - return fmt::format("ImageView 1DArray {:#x} {}{}|{}", addr, width, level, num_layers); + return std::format("ImageView 1DArray {:#x} {}{}|{}", addr, width, level, num_layers); case ImageViewType::e2DArray: - return fmt::format("ImageView 2DArray {:#x} {}x{}{}|{}", addr, width, height, level, + return std::format("ImageView 2DArray {:#x} {}x{}{}|{}", addr, width, height, level, num_layers); case ImageViewType::CubeArray: - return fmt::format("ImageView CubeArray {:#x} {}x{}{}|{}", addr, width, height, level, + return std::format("ImageView CubeArray {:#x} {}x{}{}|{}", addr, width, height, level, num_layers); case ImageViewType::Rect: - return fmt::format("ImageView Rect {:#x} {}x{}{}", addr, width, height, level); + return std::format("ImageView Rect {:#x} {}x{}{}", addr, width, height, level); case ImageViewType::Buffer: - return fmt::format("BufferView {:#x} {}", addr, width); + return std::format("BufferView {:#x} {}", addr, width); } return "Invalid"; } @@ -97,10 +97,10 @@ std::string Name(const RenderTargets& render_targets) { } const Extent2D size = render_targets.size; if (num_color > 0) { - return fmt::format("Framebuffer {}{} {}x{}", debug_prefix, num_color, size.width, + return std::format("Framebuffer {}{} {}x{}", debug_prefix, num_color, size.width, size.height); } else { - return fmt::format("Framebuffer {} {}x{}", debug_prefix, size.width, size.height); + return std::format("Framebuffer {} {}x{}", debug_prefix, size.width, size.height); } } diff --git a/src/video_core/texture_cache/formatter.h b/src/video_core/texture_cache/formatter.h index 3e2e749274..60228e5276 100644 --- a/src/video_core/texture_cache/formatter.h +++ b/src/video_core/texture_cache/formatter.h @@ -8,13 +8,13 @@ #include -#include +#include #include "video_core/surface.h" #include "video_core/texture_cache/types.h" template <> -struct fmt::formatter : fmt::formatter { +struct std::formatter : std::formatter { template auto format(VideoCore::Surface::PixelFormat format, FormatContext& ctx) const { using VideoCore::Surface::PixelFormat; @@ -34,7 +34,7 @@ struct fmt::formatter : fmt::formatter -struct fmt::formatter : fmt::formatter { +struct std::formatter : std::formatter { template auto format(VideoCommon::ImageType type, FormatContext& ctx) const { const string_view name = [type] { @@ -58,14 +58,14 @@ struct fmt::formatter : fmt::formatter }; template <> -struct fmt::formatter { - constexpr auto parse(fmt::format_parse_context& ctx) { +struct std::formatter { + constexpr auto parse(std::format_parse_context& ctx) { return ctx.begin(); } template auto format(const VideoCommon::Extent3D& extent, FormatContext& ctx) const { - return fmt::format_to(ctx.out(), "{{{}, {}, {}}}", extent.width, extent.height, + return std::format_to(ctx.out(), "{{{}, {}, {}}}", extent.width, extent.height, extent.depth); } }; diff --git a/src/video_core/texture_cache/image_info.cpp b/src/video_core/texture_cache/image_info.cpp index 8b59eb6841..5df18efd7e 100644 --- a/src/video_core/texture_cache/image_info.cpp +++ b/src/video_core/texture_cache/image_info.cpp @@ -4,7 +4,7 @@ // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include +#include #include "common/assert.h" #include "common/settings.h" diff --git a/src/video_core/vulkan_common/nsight_aftermath_tracker.cpp b/src/video_core/vulkan_common/nsight_aftermath_tracker.cpp index 3bfb7d4bdc..27b072b048 100644 --- a/src/video_core/vulkan_common/nsight_aftermath_tracker.cpp +++ b/src/video_core/vulkan_common/nsight_aftermath_tracker.cpp @@ -13,7 +13,7 @@ #include #include -#include +#include #include "common/common_types.h" #include "common/fs/file.h" @@ -93,7 +93,7 @@ void NsightAftermathTracker::SaveShader(std::span spirv) const { return; } - const auto shader_file = dump_dir / fmt::format("source_{:016x}.spv", hash.hash); + const auto shader_file = dump_dir / std::format("source_{:016x}.spv", hash.hash); Common::FS::IOFile file{shader_file, Common::FS::FileAccessMode::Write, Common::FS::FileType::BinaryFile}; @@ -143,7 +143,7 @@ void NsightAftermathTracker::OnGpuCrashDumpCallback(const void* gpu_crash_dump, if (id == 0) { return dump_dir / "crash.nv-gpudmp"; } else { - return dump_dir / fmt::format("crash_{}.nv-gpudmp", id); + return dump_dir / std::format("crash_{}.nv-gpudmp", id); } }(); @@ -173,7 +173,7 @@ void NsightAftermathTracker::OnShaderDebugInfoCallback(const void* shader_debug_ } const auto path = - dump_dir / fmt::format("shader_{:016x}{:016x}.nvdbg", identifier.id[0], identifier.id[1]); + dump_dir / std::format("shader_{:016x}{:016x}.nvdbg", identifier.id[0], identifier.id[1]); Common::FS::IOFile file{path, Common::FS::FileAccessMode::Write, Common::FS::FileType::BinaryFile}; if (!file.IsOpen()) { diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index be09bca8d3..cfe34de411 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include "common/assert.h" #include "common/fs/fs.h" @@ -1735,26 +1735,26 @@ void Device::InitializeGPULogging() { // Device information const auto& props = properties.properties; - driver_info += fmt::format("Device: {}\n", props.deviceName); - driver_info += fmt::format("Driver Name: {}\n", properties.driver.driverName); - driver_info += fmt::format("Driver Info: {}\n", properties.driver.driverInfo); + driver_info += std::format("Device: {}\n", props.deviceName); + driver_info += std::format("Driver Name: {}\n", properties.driver.driverName); + driver_info += std::format("Driver Info: {}\n", properties.driver.driverInfo); // Version information const u32 driver_version = props.driverVersion; const u32 api_version = props.apiVersion; - driver_info += fmt::format("Driver Version: {}.{}.{}\n", + driver_info += std::format("Driver Version: {}.{}.{}\n", VK_API_VERSION_MAJOR(driver_version), VK_API_VERSION_MINOR(driver_version), VK_API_VERSION_PATCH(driver_version)); - driver_info += fmt::format("Vulkan API Version: {}.{}.{}\n", + driver_info += std::format("Vulkan API Version: {}.{}.{}\n", VK_API_VERSION_MAJOR(api_version), VK_API_VERSION_MINOR(api_version), VK_API_VERSION_PATCH(api_version)); - driver_info += fmt::format("Driver ID: {}\n", static_cast(driver_id)); + driver_info += std::format("Driver ID: {}\n", static_cast(driver_id)); // Vendor and device IDs - driver_info += fmt::format("Vendor ID: {:#04x}\n", props.vendorID); - driver_info += fmt::format("Device ID: {:#04x}\n", props.deviceID); + driver_info += std::format("Vendor ID: {:#04x}\n", props.vendorID); + driver_info += std::format("Device ID: {:#04x}\n", props.deviceID); // Extensions - separate QCOM extensions from others driver_info += "\n=== Loaded Vulkan Extensions ===\n"; @@ -1773,7 +1773,7 @@ void Device::InitializeGPULogging() { if (!qcom_exts.empty()) { driver_info += "\nQualcomm Proprietary Extensions:\n"; for (const auto& ext : qcom_exts) { - driver_info += fmt::format(" - {}\n", ext); + driver_info += std::format(" - {}\n", ext); } } @@ -1781,11 +1781,11 @@ void Device::InitializeGPULogging() { if (!other_exts.empty()) { driver_info += "\nStandard Extensions:\n"; for (const auto& ext : other_exts) { - driver_info += fmt::format(" - {}\n", ext); + driver_info += std::format(" - {}\n", ext); } } - driver_info += fmt::format("\nTotal Extensions Loaded: {}\n", loaded_extensions.size()); + driver_info += std::format("\nTotal Extensions Loaded: {}\n", loaded_extensions.size()); GPU::Logging::GPULogger::GetInstance().LogDriverDebugInfo(driver_info); } diff --git a/src/web_service/announce_room_json.cpp b/src/web_service/announce_room_json.cpp index 219b93f74e..bb84093de9 100644 --- a/src/web_service/announce_room_json.cpp +++ b/src/web_service/announce_room_json.cpp @@ -83,7 +83,7 @@ WebService::WebResult RoomJson::Update() { } jacinth::json json; json["players"] = room.members; - return client.PostJson(fmt::format("/lobby/{}", room_id), json.dump(), false); + return client.PostJson(std::format("/lobby/{}", room_id), json.dump(), false); } WebService::WebResult RoomJson::Register() { @@ -120,7 +120,7 @@ void RoomJson::Delete() { // Once the thread finishes it will stay resident on the vector -- destroyed and freed by dtor() // this is still valid while in dtor, so... yeah detached_tasks.emplace_back([this](std::stop_token stop_token) { - client.DeleteJson(fmt::format("/lobby/{}", room_id), "", false); + client.DeleteJson(std::format("/lobby/{}", room_id), "", false); }); } } diff --git a/src/web_service/verify_user_jwt.cpp b/src/web_service/verify_user_jwt.cpp index f9b310e235..88552e0518 100644 --- a/src/web_service/verify_user_jwt.cpp +++ b/src/web_service/verify_user_jwt.cpp @@ -40,7 +40,7 @@ VerifyUserJWT::VerifyUserJWT(const std::string& host) : pub_key(GetPublicKey(hos Network::VerifyUser::UserData VerifyUserJWT::LoadUserData(const std::string& verify_uid, const std::string& token) { - const std::string audience = fmt::format("external-{}", verify_uid); + const std::string audience = std::format("external-{}", verify_uid); using namespace jwt::params; std::error_code error; diff --git a/src/web_service/verify_user_jwt.h b/src/web_service/verify_user_jwt.h index 5be7c87ebb..d5e60bf24a 100644 --- a/src/web_service/verify_user_jwt.h +++ b/src/web_service/verify_user_jwt.h @@ -1,9 +1,12 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2018 Citra Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once -#include +#include #include "network/verify_user.h" #include "web_service/web_backend.h" diff --git a/src/web_service/web_backend.cpp b/src/web_service/web_backend.cpp index 029319bc5f..8702121a7d 100644 --- a/src/web_service/web_backend.cpp +++ b/src/web_service/web_backend.cpp @@ -102,8 +102,8 @@ struct Client::Impl { if (res->status_code >= hydro::Status::BadRequest) { LOG_ERROR(WebService, "{} to {} returned error status code: {}", method, host + path, - std::to_underlying(res->status_code)); - return WebResult{WebResult::Code::HttpError, std::to_string(std::to_underlying(res->status_code)), ""}; + res->status_code); + return WebResult{WebResult::Code::HttpError, std::format("{}", res->status_code), ""}; } auto content_type = res->headers.get("content-type"); diff --git a/src/yuzu/about_dialog.cpp b/src/yuzu/about_dialog.cpp index 2694f421cb..4f0374075e 100644 --- a/src/yuzu/about_dialog.cpp +++ b/src/yuzu/about_dialog.cpp @@ -5,7 +5,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include -#include +#include #include "common/scm_rev.h" #include "ui_aboutdialog.h" #include "yuzu/about_dialog.h" @@ -14,11 +14,11 @@ AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent), ui{std::make_unique()} { static const std::string build_id = std::string{Common::g_build_id}; static const std::string yuzu_build = - fmt::format("{} | {} | {}", std::string{Common::g_build_name}, + std::format("{} | {} | {}", std::string{Common::g_build_name}, std::string{Common::g_build_version}, std::string{Common::g_compiler_id}); - const auto override_build = - fmt::format(fmt::runtime(std::string(Common::g_title_bar_format_idle)), build_id); + const auto override_build = std::vformat(std::string_view(Common::g_title_bar_format_idle), + std::make_format_args(build_id)); const auto yuzu_build_version = override_build.empty() ? yuzu_build : override_build; ui->setupUi(this); diff --git a/src/yuzu/applets/qt_profile_select.cpp b/src/yuzu/applets/qt_profile_select.cpp index ace6be4d3e..067bd01b6a 100644 --- a/src/yuzu/applets/qt_profile_select.cpp +++ b/src/yuzu/applets/qt_profile_select.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project @@ -34,7 +34,7 @@ QString FormatUserEntryText(const QString& username, Common::UUID uuid) { QString GetImagePath(Common::UUID uuid) { const auto path = Common::FS::GetEdenPath(Common::FS::EdenPath::NANDDir) / - fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString()); + std::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString()); return QString::fromStdString(Common::FS::PathToUTF8String(path)); } diff --git a/src/yuzu/configuration/configure_per_game.cpp b/src/yuzu/configuration/configure_per_game.cpp index 692db5ab48..13e3e5e0da 100644 --- a/src/yuzu/configuration/configure_per_game.cpp +++ b/src/yuzu/configuration/configure_per_game.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include @@ -57,7 +57,7 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::st tab_group{std::make_shared>()} { const auto file_path = std::filesystem::path(Common::FS::ToU8String(file_name)); const auto config_file_name = title_id == 0 ? Common::FS::PathToUTF8String(file_path.filename()) - : fmt::format("{:016X}", title_id); + : std::format("{:016X}", title_id); game_config = std::make_unique(config_file_name, Config::ConfigType::PerGameConfig); addons_tab = std::make_unique(system_, this); audio_tab = std::make_unique(system_, tab_group, *builder, this); diff --git a/src/yuzu/configuration/configure_per_game_addons.cpp b/src/yuzu/configuration/configure_per_game_addons.cpp index bc21c70a7c..561d530126 100644 --- a/src/yuzu/configuration/configure_per_game_addons.cpp +++ b/src/yuzu/configuration/configure_per_game_addons.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include @@ -113,7 +113,7 @@ void ConfigurePerGameAddons::ApplyConfiguration() { if (userData.isValid() && userData.canConvert() && item.front()->text() == QStringLiteral("Update")) { quint32 numeric_version = userData.toUInt(); - disabled_addons.push_back(fmt::format("Update@{}", numeric_version)); + disabled_addons.push_back(std::format("Update@{}", numeric_version)); } else { disabled_addons.push_back(item.front()->text().toStdString()); } @@ -125,7 +125,7 @@ void ConfigurePerGameAddons::ApplyConfiguration() { std::sort(current.begin(), current.end()); if (disabled_addons != current) { Common::FS::RemoveFile(Common::FS::GetEdenPath(Common::FS::EdenPath::CacheDir) / - "game_list" / fmt::format("{:016X}.pv.txt", title_id)); + "game_list" / std::format("{:016X}.pv.txt", title_id)); } Settings::values.disabled_addons[title_id] = disabled_addons; @@ -335,7 +335,7 @@ void ConfigurePerGameAddons::LoadConfiguration() { bool patch_disabled = false; if (is_external_update) { - std::string disabled_key = fmt::format("Update@{}", patch.numeric_version); + std::string disabled_key = std::format("Update@{}", patch.numeric_version); patch_disabled = std::find(disabled.begin(), disabled.end(), disabled_key) != disabled.end(); } else { diff --git a/src/yuzu/configuration/configure_profile_manager.cpp b/src/yuzu/configuration/configure_profile_manager.cpp index 0d86fb5ef9..e192afe204 100644 --- a/src/yuzu/configuration/configure_profile_manager.cpp +++ b/src/yuzu/configuration/configure_profile_manager.cpp @@ -39,7 +39,7 @@ namespace { QString GetImagePath(const Common::UUID& uuid) { const auto path = Common::FS::GetEdenPath(Common::FS::EdenPath::NANDDir) / - fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString()); + std::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString()); return QString::fromStdString(Common::FS::PathToUTF8String(path)); } diff --git a/src/yuzu/configuration/configure_ringcon.cpp b/src/yuzu/configuration/configure_ringcon.cpp index d722eba07b..c18b97965a 100644 --- a/src/yuzu/configuration/configure_ringcon.cpp +++ b/src/yuzu/configuration/configure_ringcon.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include "hid_core/frontend/emulated_controller.h" #include "hid_core/hid_core.h" @@ -329,7 +329,7 @@ void ConfigureRingController::ControllerUpdate(Core::HID::ControllerTriggerType } const auto value = emulated_controller->GetRingSensorValues(); - const auto tex_value = QString::fromStdString(fmt::format("{:.3f}", value.raw_value)); + const auto tex_value = QString::fromStdString(std::format("{:.3f}", value.raw_value)); ui->ring_controller_sensor_value->setText(tex_value); } diff --git a/src/yuzu/configuration/input_profiles.cpp b/src/yuzu/configuration/input_profiles.cpp index 15437e0233..fe7833094c 100644 --- a/src/yuzu/configuration/input_profiles.cpp +++ b/src/yuzu/configuration/input_profiles.cpp @@ -4,7 +4,7 @@ // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include +#include #include "common/fs/fs.h" #include "common/fs/path_util.h" @@ -17,7 +17,7 @@ namespace FS = Common::FS; namespace { std::filesystem::path ProfilePath(std::string_view profile_name) { - return FS::GetEdenPath(FS::EdenPath::ConfigDir) / "input" / fmt::format("{}.ini", profile_name); + return FS::GetEdenPath(FS::EdenPath::ConfigDir) / "input" / std::format("{}.ini", profile_name); } bool ProfileExistsInFilesystem(std::string_view profile_name) { diff --git a/src/yuzu/configuration/shared_widget.cpp b/src/yuzu/configuration/shared_widget.cpp index 9410988bdb..7d4cbcf4c9 100644 --- a/src/yuzu/configuration/shared_widget.cpp +++ b/src/yuzu/configuration/shared_widget.cpp @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include @@ -64,7 +64,7 @@ static QString DefaultSuffix(QWidget* parent, Settings::BasicSetting& setting) { if ((setting.Specialization() & Settings::SpecializationAttributeMask) == Settings::Specialization::Percentage) { - std::string context{fmt::format("{} percentage (e.g. 50%)", setting.GetLabel())}; + std::string context{std::format("{} percentage (e.g. 50%)", setting.GetLabel())}; return tr("%", context.c_str()); } @@ -438,7 +438,7 @@ QWidget* Widget::CreateDoubleSpinBox(const QString& given_suffix, double_spinbox->setSuffix(suffix); double_spinbox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - serializer = [this]() { return fmt::format("{:f}", double_spinbox->value()); }; + serializer = [this]() { return std::format("{:f}", double_spinbox->value()); }; restore_func = [this]() { auto value{std::strtod(RelevantDefault(setting).c_str(), nullptr)}; @@ -468,7 +468,7 @@ QWidget* Widget::CreateHexEdit(std::function& serializer, auto to_hex = [=](const std::string& input) { return QString::fromStdString( - fmt::format("{:08x}", std::strtoul(input.c_str(), nullptr, 0))); + std::format("{:08x}", std::strtoul(input.c_str(), nullptr, 0))); }; QRegularExpressionValidator* regex = new QRegularExpressionValidator( diff --git a/src/yuzu/configuration/system/new_user_dialog.cpp b/src/yuzu/configuration/system/new_user_dialog.cpp index 1bbb3b0612..aba40f4306 100644 --- a/src/yuzu/configuration/system/new_user_dialog.cpp +++ b/src/yuzu/configuration/system/new_user_dialog.cpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include #include @@ -36,7 +36,7 @@ QPixmap NewUserDialog::DefaultAvatar() { QString NewUserDialog::GetImagePath(const Common::UUID& uuid) { const auto path = Common::FS::GetEdenPath(Common::FS::EdenPath::NANDDir) / - fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString()); + std::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormattedString()); return QString::fromStdString(Common::FS::PathToUTF8String(path)); } diff --git a/src/yuzu/deps_dialog.cpp b/src/yuzu/deps_dialog.cpp index e490bfc163..bfbfbd6b92 100644 --- a/src/yuzu/deps_dialog.cpp +++ b/src/yuzu/deps_dialog.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include "dep_hashes.h" #include "ui_deps_dialog.h" #include "yuzu/deps_dialog.h" @@ -31,7 +31,7 @@ DepsDialog::DepsDialog(QWidget* parent) : QDialog(parent), ui{std::make_unique{}", url, name); + std::string dependency = std::format("{}", url, name); QTableWidgetItem* nameItem = new QTableWidgetItem(QString::fromStdString(dependency)); QTableWidgetItem* shaItem = new QTableWidgetItem(QString::fromStdString(sha)); diff --git a/src/yuzu/main_window.cpp b/src/yuzu/main_window.cpp index 3bf345e62b..d471443802 100644 --- a/src/yuzu/main_window.cpp +++ b/src/yuzu/main_window.cpp @@ -234,7 +234,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual #include #include -#include +#include #include #ifdef _MSC_VER #pragma comment(lib, "Dwmapi.lib") @@ -2928,16 +2928,16 @@ Uint64 PadSteamHandle(SDL_JoystickID id) { /// controller between virtual pads), else the connection instance std::string BluetoothKey(SDL_JoystickID id) { if (const Uint64 handle = PadSteamHandle(id)) { - return fmt::format("steamhandle:{:#x}", handle); + return std::format("steamhandle:{:#x}", handle); } - return fmt::format("inst:{}", id); + return std::format("inst:{}", id); } /// How a pad is stored as the handheld's: Steam handle under Steam, else its identity std::string PadKey(SDL_JoystickID id, const std::string& ident) { if (Common::SteamPadsInUse()) { if (const Uint64 handle = PadSteamHandle(id)) { - return fmt::format("steamhandle:{:#x}", handle); + return std::format("steamhandle:{:#x}", handle); } } return ident; @@ -3122,7 +3122,7 @@ std::string BindingMapping(const std::string& raw) { char* end = nullptr; const float number = std::strtof(value.c_str(), &end); if (!value.empty() && end && *end == '\0') { - field = field.substr(0, colon + 1) + fmt::format("{}", number); + field = field.substr(0, colon + 1) + std::format("{}", number); } } fields.push_back(field); @@ -3424,7 +3424,7 @@ void MainWindow::MergeConsoleProfileEdits(const std::array P{}{}", pad, from >= 0 ? from + 1 : 0, i + 1, holder - ? fmt::format(", inst={} P{} -> P{}", holder, i + 1, from >= 0 ? from + 1 : 0) + ? std::format(", inst={} P{} -> P{}", holder, i + 1, from >= 0 ? from + 1 : 0) : std::string{}); } } @@ -4425,7 +4425,7 @@ void MainWindow::LearnBluetoothPads() { last_many = now_steady; std::string which; for (const auto& [id, key] : pressed_pads) { - which += fmt::format(" inst={}({})", id, key); + which += std::format(" inst={}({})", id, key); } LOG_INFO(Frontend, "console-mode: {} pads of model {:04x}:{:04x} pressed at once, " @@ -4444,7 +4444,7 @@ void MainWindow::LearnBluetoothPads() { last = now; std::string nodes; for (const auto& controller : controllers) { - nodes += fmt::format(" {}[{}]", controller.address, + nodes += std::format(" {}[{}]", controller.address, controller.events.empty() ? std::string{"no input node"} : controller.events.front().toStdString()); @@ -4892,7 +4892,7 @@ void MainWindow::ApplyConsoleControllerMode() { if (ids[k] != id && IsSteamVirtualPad(ids[k]) && PadVendor(ids[k]) == vendor && PadProduct(ids[k]) == product) { - twins += fmt::format("{} ", ids[k]); + twins += std::format("{} ", ids[k]); } } if (Common::ControllerProbes()) { @@ -4908,7 +4908,7 @@ void MainWindow::ApplyConsoleControllerMode() { std::string ident = PadIdentity(id); if (Common::SteamPadsInUse() && IsSteamVirtualPad(id)) { if (const Uint64 handle = PadSteamHandle(id)) { - ident = fmt::format("steamhandle:{:#x}", handle); + ident = std::format("steamhandle:{:#x}", handle); } else if (now - first_seen[id] < std::chrono::seconds{3}) { continue; } @@ -5080,7 +5080,7 @@ void MainWindow::ApplyConsoleControllerMode() { // Under Steam the entries carry the Steam handle (every pad shares one GUID) const Uint64 handle = Common::SteamPadsInUse() ? PadSteamHandle(id) : 0; auto entry = std::pair{PadName(id).toStdString(), - handle ? fmt::format("steamhandle:{:#x}", handle) : ident}; + handle ? std::format("steamhandle:{:#x}", handle) : ident}; if (IsPlainlyStandalone(id)) { standalone.push_back(std::move(entry)); } else { @@ -5113,7 +5113,7 @@ void MainWindow::ApplyConsoleControllerMode() { if (Common::SteamPadsInUse()) { if (handle) { Settings::values.builtin_pad_steam_handle.SetValue( - fmt::format("{:#x}", handle)); + std::format("{:#x}", handle)); Settings::values.builtin_pad_steam_manual.SetValue(true); } } else { @@ -5138,7 +5138,7 @@ void MainWindow::ApplyConsoleControllerMode() { if (declared.starts_with(prefix)) { const std::string handle = declared.substr(prefix.size()); for (const auto& [id, ident] : live) { - if (fmt::format("{:#x}", PadSteamHandle(id)) == handle) { + if (std::format("{:#x}", PadSteamHandle(id)) == handle) { builtin_pad_id = id; break; } @@ -5287,7 +5287,7 @@ void MainWindow::ApplyConsoleControllerMode() { std::string trace; for (const auto& [id, ident] : live) { const auto it = pad_slots.find(id); - trace += fmt::format("\n pad inst={} slot={} idx={} name={} path={} ident={}", id, + trace += std::format("\n pad inst={} slot={} idx={} name={} path={} ident={}", id, it == pad_slots.end() ? -1 : static_cast(it->second), PadPlayerIndex(id), PadName(id).toStdString(), PadPath(id).toStdString(), ident); @@ -5300,7 +5300,7 @@ void MainWindow::ApplyConsoleControllerMode() { // Steam fills a virtual pad's handle, type and name a moment after it appears: traced static std::map traced_steam; for (const auto& [id, ident] : live) { - const std::string desc = fmt::format( + const std::string desc = std::format( "steam_handle={:#x} type={} name={}", PadSteamHandle(id), static_cast(PadType(id)), PadName(id).toStdString()); auto& last = traced_steam[id]; @@ -5443,7 +5443,7 @@ void MainWindow::ApplyConsoleControllerMode() { u32 holder = 0; if (!want.empty()) { for (const auto& [id, ident] : live) { - if (fmt::format("{:#x}", PadSteamHandle(id)) != want || is_blocked(id)) { + if (std::format("{:#x}", PadSteamHandle(id)) != want || is_blocked(id)) { continue; } if (!Settings::values.builtin_pad_steam_manual.GetValue() && @@ -5490,7 +5490,7 @@ void MainWindow::ApplyConsoleControllerMode() { } } if (adopted) { - const std::string handle = fmt::format("{:#x}", PadSteamHandle(holder)); + const std::string handle = std::format("{:#x}", PadSteamHandle(holder)); if (handle != want) { Settings::values.builtin_pad_steam_handle.SetValue(handle); Settings::values.builtin_pad_steam_manual.SetValue(false); @@ -5502,7 +5502,7 @@ void MainWindow::ApplyConsoleControllerMode() { } static std::string last_resolved; const std::string resolved = - count == 1 ? fmt::format("inst={}", holder) : fmt::format("{} matches", count); + count == 1 ? std::format("inst={}", holder) : std::format("{} matches", count); if (resolved != last_resolved) { last_resolved = resolved; if (Common::ControllerProbes()) { @@ -5544,7 +5544,7 @@ void MainWindow::ApplyConsoleControllerMode() { Settings::values.builtin_pad_steam_handle.GetValue().empty()) { // Latch the handheld's Steam handle as soon as Steam has filled it in if (const Uint64 handle = PadSteamHandle(builtin_match_id)) { - Settings::values.builtin_pad_steam_handle.SetValue(fmt::format("{:#x}", handle)); + Settings::values.builtin_pad_steam_handle.SetValue(std::format("{:#x}", handle)); LOG_INFO(Frontend, "console-mode: builtin Steam handle latched {:#x} inst={}", handle, builtin_match_id); } @@ -6773,7 +6773,7 @@ void MainWindow::ApplyConsoleControllerMode() { const auto style = controller->GetNpadStyleIndex(); const bool taken = StyleSupported(style, supported); const std::string what = taken ? std::string{} - : fmt::format("{}/{:#x}", static_cast(style), + : std::format("{}/{:#x}", static_cast(style), static_cast(supported.raw)); auto& logged = refused_logged[static_cast(i)]; if (what != logged) { @@ -6926,7 +6926,7 @@ void MainWindow::ApplyConsoleControllerMode() { std::any_of(live.begin(), live.end(), [&](const auto& entry) { return entry.first != pad && entry.second == live[pad]; })) { - history_key += fmt::format("#{}", pad); + history_key += std::format("#{}", pad); } overlay_row_history[i] = std::move(history_key); } else if (since != 0 && gone == 0) { @@ -7523,7 +7523,7 @@ bool MainWindow::LoadROM(const QString& filename, Service::AM::FrontendAppletPar if (result > Core::SystemResultStatus::ErrorLoader) { const u16 loader_id = static_cast(Core::SystemResultStatus::ErrorLoader); const u16 error_id = static_cast(result) - loader_id; - const std::string error_code = fmt::format("({:04X}-{:04X})", loader_id, error_id); + const std::string error_code = std::format("({:04X}-{:04X})", loader_id, error_id); LOG_CRITICAL(Frontend, "Failed to load ROM! {}", error_code); const auto title = @@ -7595,7 +7595,7 @@ void MainWindow::BootGame(const QString& filename, Service::AM::FrontendAppletPa std::filesystem::path{Common::U16StringFromBuffer(filename.utf16(), filename.size())}; const auto config_file_name = title_id == 0 ? Common::FS::PathToUTF8String(file_path.filename()) - : fmt::format("{:016X}", title_id); + : std::format("{:016X}", title_id); QtConfig per_game_config(config_file_name, Config::ConfigType::PerGameConfig); QtCommon::system->HIDCore().ReloadInputDevices(); QtCommon::system->ApplySettings(); @@ -7991,7 +7991,7 @@ void MainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target, case GameListOpenTarget::ModData: { open_target = tr("Mod Data"); path = Common::FS::GetEdenPath(Common::FS::EdenPath::LoadDir) / - fmt::format("{:016X}", program_id); + std::format("{:016X}", program_id); break; } default: @@ -8228,7 +8228,7 @@ void MainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pat target == DumpRomFSTarget::Normal ? Common::FS::GetEdenPath(Common::FS::EdenPath::DumpDir) : Common::FS::GetEdenPath(Common::FS::EdenPath::SDMCDir) / "atmosphere" / "contents"; - const auto romfs_dir = fmt::format("{:016X}/romfs", title_id); + const auto romfs_dir = std::format("{:016X}/romfs", title_id); const auto path = Common::FS::PathToUTF8String(dump_dir / romfs_dir); @@ -8305,13 +8305,13 @@ void MainWindow::OnGameListVerifyIntegrity(const std::string& game_path) { void MainWindow::OnGameListCopyTID(u64 program_id) { QClipboard* clipboard = QGuiApplication::clipboard(); - clipboard->setText(QString::fromStdString(fmt::format("{:016X}", program_id))); + clipboard->setText(QString::fromStdString(std::format("{:016X}", program_id))); } void MainWindow::OnGameListCreateShortcut(u64 program_id, const std::string& game_path, const QtCommon::Game::ShortcutTarget target) { // Create shortcu - std::string arguments = fmt::format("-g \"{:s}\"", game_path); + std::string arguments = std::format("-g \"{:s}\"", game_path); QtCommon::Game::CreateShortcut(game_path, program_id, "", target, arguments, true); } @@ -8403,7 +8403,7 @@ void MainWindow::OnLinkToRyujinx(const u64& program_id) { if (user_id.empty()) return; - const std::string hex_program = fmt::format("{:016X}", program_id); + const std::string hex_program = std::format("{:016X}", program_id); const fs::path eden_dir = FrontendCommon::DataManager::GetDataDir( FrontendCommon::DataManager::DataDir::Saves, user_id) / @@ -9783,7 +9783,7 @@ void MainWindow::OnApplicationChanged(u64 program_id) { title_name = metadata.first->GetApplicationName(); } if (title_name.empty()) { - title_name = fmt::format("{:016X}", program_id); + title_name = std::format("{:016X}", program_id); } if (const auto* process = QtCommon::system->Kernel().ApplicationProcess(); process != nullptr) { @@ -9808,21 +9808,21 @@ void MainWindow::UpdateWindowTitle(std::string_view title_name, std::string_view std::string_view gpu_vendor) { static const std::string build_id = std::string{Common::g_build_id}; static const std::string yuzu_title = - fmt::format("{} | {} | {}", std::string{Common::g_build_name}, + std::format("{} | {} | {}", std::string{Common::g_build_name}, std::string{Common::g_build_version}, std::string{Common::g_compiler_id}); - const auto override_title = - fmt::format(fmt::runtime(std::string(Common::g_title_bar_format_idle)), build_id); - const auto window_title = override_title.empty() ? yuzu_title : override_title; + const auto override_build = std::vformat(std::string_view(Common::g_title_bar_format_idle), + std::make_format_args(build_id)); + const auto window_title = override_build.empty() ? yuzu_title : override_build; if (title_name.empty()) { setWindowTitle(QString::fromStdString(window_title)); } else { const auto run_title = [window_title, title_name, title_version, gpu_vendor]() { if (title_version.empty()) { - return fmt::format("{} | {} | {}", window_title, title_name, gpu_vendor); + return std::format("{} | {} | {}", window_title, title_name, gpu_vendor); } - return fmt::format("{} | {} | {} | {}", window_title, title_name, title_version, + return std::format("{} | {} | {} | {}", window_title, title_name, title_version, gpu_vendor); }(); setWindowTitle(QString::fromStdString(run_title)); @@ -10148,7 +10148,7 @@ bool MainWindow::SelectRomFSDumpTarget(const FileSys::ContentProvider& installed if (available_title_ids.size() > 1) { QStringList list; for (auto& [title_id, title_type, record_type] : available_title_ids) { - const auto hex_title_id = QString::fromStdString(fmt::format("{:X}", title_id)); + const auto hex_title_id = QString::fromStdString(std::format("{:X}", title_id)); if (record_type == FileSys::ContentRecordType::Program) { list.push_back(QStringLiteral("Program [%1]").arg(hex_title_id)); } else if (record_type == FileSys::ContentRecordType::HtmlDocument) { @@ -10200,7 +10200,7 @@ void MainWindow::closeEvent(QCloseEvent* event) { if (Common::ControllerProbes() && !overlay_rows.empty()) { std::string players_now; for (const auto& row : overlay_rows) { - players_now += fmt::format("\n P{} {} ident={} profile=\"{}\"{}", row.player + 1, + players_now += std::format("\n P{} {} ident={} profile=\"{}\"{}", row.player + 1, overlay_row_name[row.player].toStdString(), overlay_row_ident[row.player], ConsoleBindingSets()[slot_set[row.player]].profile_name, diff --git a/src/yuzu/startup_checks.cpp b/src/yuzu/startup_checks.cpp index f54992d19a..dc2489f1a6 100644 --- a/src/yuzu/startup_checks.cpp +++ b/src/yuzu/startup_checks.cpp @@ -20,7 +20,7 @@ #include #endif -#include +#include #include "video_core/vulkan_common/vulkan_instance.h" #include "video_core/vulkan_common/vulkan_library.h" #include "yuzu/startup_checks.h" @@ -34,7 +34,7 @@ void CheckVulkan() { Vulkan::CreateInstance(*library, dld, VK_API_VERSION_1_1); } catch (const Vulkan::vk::Exception& exception) { - fmt::print(stderr, "Failed to initialize Vulkan: {}\n", exception.what()); + std::print(stderr, "Failed to initialize Vulkan: {}\n", exception.what()); } } @@ -56,7 +56,7 @@ bool CheckEnvVars(bool* is_child) { *is_child = true; return false; } else if (!SetEnvironmentVariableA(IS_CHILD_ENV_VAR, ENV_VAR_ENABLED_TEXT)) { - fmt::print(stderr, "SetEnvironmentVariableA failed to set {} with error {}\n", + std::print(stderr, "SetEnvironmentVariableA failed to set {} with error {}\n", IS_CHILD_ENV_VAR, GetLastError()); return true; } @@ -76,7 +76,7 @@ bool StartupChecks(const char* arg0, bool* has_broken_vulkan, bool perform_vulka // Set the startup variable for child processes const bool env_var_set = SetEnvironmentVariableA(STARTUP_CHECK_ENV_VAR, ENV_VAR_ENABLED_TEXT); if (!env_var_set) { - fmt::print(stderr, "SetEnvironmentVariableA failed to set {} with error {}\n", + std::print(stderr, "SetEnvironmentVariableA failed to set {} with error {}\n", STARTUP_CHECK_ENV_VAR, GetLastError()); return false; } @@ -95,22 +95,22 @@ bool StartupChecks(const char* arg0, bool* has_broken_vulkan, bool perform_vulka DWORD exit_code = STILL_ACTIVE; const int err = GetExitCodeProcess(process_info.hProcess, &exit_code); if (err == 0) { - fmt::print(stderr, "GetExitCodeProcess failed with error {}\n", GetLastError()); + std::print(stderr, "GetExitCodeProcess failed with error {}\n", GetLastError()); } // Vulkan is broken if the child crashed (return value is not zero) *has_broken_vulkan = (exit_code != 0); if (CloseHandle(process_info.hProcess) == 0) { - fmt::print(stderr, "CloseHandle failed with error {}\n", GetLastError()); + std::print(stderr, "CloseHandle failed with error {}\n", GetLastError()); } if (CloseHandle(process_info.hThread) == 0) { - fmt::print(stderr, "CloseHandle failed with error {}\n", GetLastError()); + std::print(stderr, "CloseHandle failed with error {}\n", GetLastError()); } } if (!SetEnvironmentVariableA(STARTUP_CHECK_ENV_VAR, nullptr)) { - fmt::print(stderr, "SetEnvironmentVariableA failed to clear {} with error {}\n", + std::print(stderr, "SetEnvironmentVariableA failed to clear {} with error {}\n", STARTUP_CHECK_ENV_VAR, GetLastError()); } @@ -118,7 +118,7 @@ bool StartupChecks(const char* arg0, bool* has_broken_vulkan, bool perform_vulka const int env_var_set = setenv(STARTUP_CHECK_ENV_VAR, ENV_VAR_ENABLED_TEXT, 1); if (env_var_set == -1) { const int err = errno; - fmt::print(stderr, "setenv failed to set {} with error {}\n", STARTUP_CHECK_ENV_VAR, err); + std::print(stderr, "setenv failed to set {} with error {}\n", STARTUP_CHECK_ENV_VAR, err); return false; } @@ -133,7 +133,7 @@ bool StartupChecks(const char* arg0, bool* has_broken_vulkan, bool perform_vulka const int r_val = waitpid(pid, &status, 0); if (r_val == -1) { const int err = errno; - fmt::print(stderr, "wait failed with error {}\n", err); + std::print(stderr, "wait failed with error {}\n", err); return false; } // Vulkan is broken if the child crashed (return value is not zero) @@ -143,7 +143,7 @@ bool StartupChecks(const char* arg0, bool* has_broken_vulkan, bool perform_vulka const int env_var_cleared = unsetenv(STARTUP_CHECK_ENV_VAR); if (env_var_cleared == -1) { const int err = errno; - fmt::print(stderr, "unsetenv failed to clear {} with error {}\n", STARTUP_CHECK_ENV_VAR, + std::print(stderr, "unsetenv failed to clear {} with error {}\n", STARTUP_CHECK_ENV_VAR, err); } #endif @@ -173,7 +173,7 @@ bool SpawnChild(const char* arg0, PROCESS_INFORMATION* pi, int flags) { pi // lpProcessInformation ); if (!process_created) { - fmt::print(stderr, "CreateProcessA failed with error {}\n", GetLastError()); + std::print(stderr, "CreateProcessA failed with error {}\n", GetLastError()); return false; } @@ -186,13 +186,13 @@ pid_t SpawnChild(const char* arg0) { if (pid == -1) { // error const int err = errno; - fmt::print(stderr, "fork failed with error {}\n", err); + std::print(stderr, "fork failed with error {}\n", err); return pid; } else if (pid == 0) { // child execlp(arg0, arg0, nullptr); const int err = errno; - fmt::print(stderr, "execl failed with error {}\n", err); + std::print(stderr, "execl failed with error {}\n", err); _exit(0); } diff --git a/src/yuzu/updater/update_dialog.cpp b/src/yuzu/updater/update_dialog.cpp index 21de9af2e2..3cf8d8ce0c 100644 --- a/src/yuzu/updater/update_dialog.cpp +++ b/src/yuzu/updater/update_dialog.cpp @@ -414,12 +414,12 @@ bool UpdateDialog::downloadFile( .arg(QString::fromStdString(url), QString::fromStdString(std::format("{}", res.error())))); return false; } else if (res->status_code < hydro::Status::Ok || res->status_code >= hydro::Status::MultipleChoices) { - LOG_ERROR(Frontend, "URL {} returned status {}", url, std::to_underlying(res->status_code)); + LOG_ERROR(Frontend, "URL {} returned status {}", url, res->status_code); QtCommon::Frontend::Critical( tr("Failed to download file"), tr("URL %1 returned status code %2.") - .arg(QString::fromStdString(url), QString::number(std::to_underlying(res->status_code)))); + .arg(QString::fromStdString(url), QString::fromStdString(std::format("{}", res->status_code)))); return false; } diff --git a/src/yuzu/util/util.cpp b/src/yuzu/util/util.cpp index eb6583b358..101578ef61 100644 --- a/src/yuzu/util/util.cpp +++ b/src/yuzu/util/util.cpp @@ -69,5 +69,5 @@ std::string GetProfileIDString() { auto user_id = uuid->AsU128(); - return fmt::format("{:016X}{:016X}", user_id[1], user_id[0]); + return std::format("{:016X}{:016X}", user_id[1], user_id[0]); } diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl3.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl3.cpp index 950e001f81..1925b7eacf 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl3.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl3.cpp @@ -33,7 +33,7 @@ EmuWindow_SDL3::EmuWindow_SDL3(InputCommon::InputSubsystem* input_subsystem_, Co titlebar_timer = SDL_AddTimer(2000, [](void *userdata, SDL_TimerID, Uint32) -> Uint32 { auto* this_ = (EmuWindow_SDL3*)userdata; auto const results = this_->system.GetAndResetPerfStats(); - auto const title = fmt::format("{} | {}-{} | FPS: {:.0f} ({:.0f}%)", Common::g_build_fullname, Common::g_scm_branch, Common::g_scm_desc, results.average_game_fps, results.emulation_speed * 100.0f); + auto const title = std::format("{} | {}-{} | FPS: {:.0f} ({:.0f}%)", std::string_view{Common::g_build_fullname}, std::string_view{Common::g_scm_branch}, std::string_view{Common::g_scm_desc}, results.average_game_fps, results.emulation_speed * 100.0f); SDL_SetWindowTitle(this_->render_window, title.c_str()); return 2000; }, this); diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl3_gl.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl3_gl.cpp index e86858a232..25111a6b28 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl3_gl.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl3_gl.cpp @@ -11,7 +11,7 @@ #define SDL_MAIN_HANDLED #include -#include +#include #include #include "common/logging.h" #include "common/scm_rev.h" @@ -95,8 +95,9 @@ EmuWindow_SDL3_GL::EmuWindow_SDL3_GL(InputCommon::InputSubsystem* input_subsyste } SDL_GL_SetSwapInterval(0); - std::string window_title = fmt::format("{} | {}-{}", Common::g_build_fullname, - Common::g_scm_branch, Common::g_scm_desc); + std::string window_title = + std::format("{} | {}-{}", std::string_view{Common::g_build_fullname}, + std::string_view{Common::g_scm_branch}, std::string_view{Common::g_scm_desc}); render_window = SDL_CreateWindow(window_title.c_str(), Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height, @@ -142,8 +143,8 @@ EmuWindow_SDL3_GL::EmuWindow_SDL3_GL(InputCommon::InputSubsystem* input_subsyste OnResize(); OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size); SDL_PumpEvents(); - LOG_INFO(Frontend, "Build string: {} | {}-{}", Common::g_build_fullname, Common::g_scm_branch, - Common::g_scm_desc); + LOG_INFO(Frontend, "Build string: {} | {}-{}", std::string_view{Common::g_build_fullname}, + std::string_view{Common::g_scm_branch}, std::string_view{Common::g_scm_desc}); Settings::LogSettings(); } diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl3_null.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl3_null.cpp index f5e4e19a30..52c1c5b4a4 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl3_null.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl3_null.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include "common/logging.h" #include "common/scm_rev.h" @@ -26,8 +26,9 @@ EmuWindow_SDL3_Null::EmuWindow_SDL3_Null(InputCommon::InputSubsystem* input_subsystem_, Core::System& system_, bool fullscreen) : EmuWindow_SDL3{input_subsystem_, system_} { - const std::string window_title = fmt::format("Eden {} | {}-{} (Vulkan)", Common::g_build_name, - Common::g_scm_branch, Common::g_scm_desc); + const std::string window_title = + std::format("Eden {} | {}-{} (Vulkan)", std::string_view{Common::g_build_name}, + std::string_view{Common::g_scm_branch}, std::string_view{Common::g_scm_desc}); render_window = SDL_CreateWindow(window_title.c_str(), Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height, @@ -43,8 +44,8 @@ EmuWindow_SDL3_Null::EmuWindow_SDL3_Null(InputCommon::InputSubsystem* input_subs OnResize(); OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size); SDL_PumpEvents(); - LOG_INFO(Frontend, "Eden Version: {} | {}-{} (Null)", Common::g_build_name, - Common::g_scm_branch, Common::g_scm_desc); + LOG_INFO(Frontend, "Eden Version: {} | {}-{} (Null)", std::string_view{Common::g_build_name}, + std::string_view{Common::g_scm_branch}, std::string_view{Common::g_scm_desc}); } EmuWindow_SDL3_Null::~EmuWindow_SDL3_Null() = default; diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl3_vk.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl3_vk.cpp index 9019cbbba0..e2fe8bbb51 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl3_vk.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl3_vk.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include "common/logging.h" #include "common/scm_rev.h" @@ -22,10 +22,10 @@ EmuWindow_SDL3_VK::EmuWindow_SDL3_VK(InputCommon::InputSubsystem* input_subsystem_, Core::System& system_, bool fullscreen) : EmuWindow_SDL3{input_subsystem_, system_} { - const std::string window_title = fmt::format("Eden {} | {}-{} (Vulkan)", - Common::g_build_name, - Common::g_scm_branch, - Common::g_scm_desc); + const std::string window_title = std::format("Eden {} | {}-{} (Vulkan)", + std::string_view{Common::g_build_name}, + std::string_view{Common::g_scm_branch}, + std::string_view{Common::g_scm_desc}); render_window = SDL_CreateWindow(window_title.c_str(), Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height, @@ -88,8 +88,8 @@ EmuWindow_SDL3_VK::EmuWindow_SDL3_VK(InputCommon::InputSubsystem* input_subsyste OnResize(); OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size); SDL_PumpEvents(); - LOG_INFO(Frontend, "Eden Version: {} | {}-{} (Vulkan)", Common::g_build_name, - Common::g_scm_branch, Common::g_scm_desc); + LOG_INFO(Frontend, "Eden Version: {} | {}-{} (Vulkan)", std::string_view{Common::g_build_name}, + std::string_view{Common::g_scm_branch}, std::string_view{Common::g_scm_desc}); } EmuWindow_SDL3_VK::~EmuWindow_SDL3_VK() = default; diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index 473a5b1014..12a3461169 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -17,7 +17,7 @@ #define SDL_MAIN_USE_CALLBACKS 1 #include -#include +#include #include "common/logging.h" #include "common/scm_rev.h" @@ -140,15 +140,15 @@ static void OnStatusMessageReceived(const Network::StatusMessageEntry& msg) { std::string message = [&]() { switch (msg.type) { case Network::IdMemberJoin: - return fmt::format("{} has joined", msg.nickname); + return std::format("{} has joined", msg.nickname); case Network::IdMemberLeave: - return fmt::format("{} has left", msg.nickname); + return std::format("{} has left", msg.nickname); case Network::IdMemberKicked: - return fmt::format("{} has been kicked", msg.nickname); + return std::format("{} has been kicked", msg.nickname); case Network::IdMemberBanned: - return fmt::format("{} has been banned", msg.nickname); + return std::format("{} has been banned", msg.nickname); case Network::IdAddressUnbanned: - return fmt::format("{} has been unbanned", msg.nickname); + return std::format("{} has been unbanned", msg.nickname); default: return std::string{}; } diff --git a/tools/svc_generator.py b/tools/svc_generator.py index 9a99c3ba51..12d25de071 100755 --- a/tools/svc_generator.py +++ b/tools/svc_generator.py @@ -552,7 +552,7 @@ static void SetArg64(std::span args, int n, uint64_t result) { // Like bit_cast, but handles the case when the source and dest // are differently-sized. template - requires(std::is_trivial_v && std::is_trivially_copyable_v) + requires(std::is_trivially_default_constructible_v && std::is_trivially_copyable_v && std::is_trivially_copyable_v) static To Convert(const From& from) { To to{}; if constexpr (sizeof(To) >= sizeof(From))