Compare commits

..

16 Commits

Author SHA1 Message Date
lizzie 16b55f5802 bleh 2026-06-28 06:06:42 +00:00
lizzie 44f6229b26 sync with master (2/2) 2026-06-28 05:43:58 +00:00
lizzie bb66fbea51 wow, this is fuckery of abi breakage (1/2) 2026-06-28 05:41:31 +00:00
CamilleLaVey 97cc97b933 smol change 2026-06-28 00:16:56 -04:00
CamilleLaVey 5d6897edac [texture_cache] Replace LRU index with frame tick in ImageBase + update garbage collection logic 2026-06-27 23:58:02 -04:00
CamilleLaVey 8217304b60 I got meowed by Gidoly 2026-06-27 23:18:19 -04:00
CamilleLaVey 689f4d3214 [buffer_cache] Removal of LRU inside buffer cache and replaced with tick operations inside frames. 2026-06-27 23:16:14 -04:00
CamilleLaVey bdbdfe8e1d [maxwell] Refactor execution mask initialization to use fill() instead of reset() 2026-06-27 23:15:12 -04:00
CamilleLaVey d25d460116 Revert "small test to msaa copy texture behavior" 2026-06-28 05:07:54 +02:00
CamilleLaVey 06c8f9806b small test to msaa copy texture behavior 2026-06-28 05:07:54 +02:00
CamilleLaVey aa012961b8 Another test 2026-06-28 05:07:54 +02:00
CamilleLaVey d628737b48 [TEST] Review the concurrency of resolve compute + barriers operations 2026-06-28 05:07:54 +02:00
CamilleLaVey d5cc29a2f7 [query_cache] Reduction of synchronization within queries 2026-06-28 05:07:54 +02:00
lizzie 894add43f3 [vk] fix PR5R black screen on qcom driver (#4120)
Different approach proposed by gido.

Signed-off-by: lizzie <lizzie@eden-emu.dev>

Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4120
Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
2026-06-28 04:29:28 +02:00
Lizzie d142b5dd6a [android] Add Enable GPU Buffer Readback option to Android (#4132)
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4132
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
2026-06-28 03:37:23 +02:00
maufeat 0c2894eabf [hle] add: (re)winding application and revert option<Process> back to unique_ptr (#4134)
This add winding application function. Test this by opening qlaunch -> top left Profile -> edit profile picture -> go back (do not save if you are on fw21+, it corrupts the image)
And reverts in #3908 added `optional<Process>` to `unique_ptr<Process>`

Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4134
Reviewed-by: Lizzie <lizzie@eden-emu.dev>
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
2026-06-27 16:47:46 +02:00
49 changed files with 467 additions and 256 deletions
+30 -30
View File
@@ -9,7 +9,7 @@
"boost": {
"artifact": "%TAG%-cmake.tar.xz",
"find_args": "CONFIG OPTIONAL_COMPONENTS headers context system fiber filesystem",
"hash": "935b3d516e996f6d25948ba8a54c1b7f70f7f0e3f517e36481fdf0196c2c5cfc2841f86e891f3df9517746b7fb605db47cdded1b8ff78d9482ddaa621db43a34",
"hash": "6ae6e94664fe7f2fb01976b59b276ac5df8085c7503fa829d810fbfe495960cfec44fa2c36e2cb23480bc19c956ed199d4952b02639a00a6c07625d4e7130c2d",
"min_version": "1.57",
"package": "Boost",
"patches": [
@@ -17,17 +17,17 @@
],
"repo": "boostorg/boost",
"tag": "boost-%VERSION%",
"version": "1.91.0"
"version": "1.90.0"
},
"boost_headers": {
"bundled": true,
"hash": "c5fa2cd72f6e6666b7963b97bc359c75284b8fb540c30f3629a028b85270c9bc66c8a051383964f2bd4c1e005a4691593d15696e7ef39ea87cf6cff9e5691fb2",
"hash": "4ef845775e2277a8104ded6ddf749aa262ce52cf8438042869a048f9a0156dd772fbbcfa74efa1378fecef339b7286f6fe4b4feb5c45d49966b35d08e3e83507",
"repo": "boostorg/headers",
"tag": "boost-%VERSION%",
"version": "1.91.0"
"version": "1.90.0"
},
"catch2": {
"hash": "2e32d3d41e4ef84d927eaaaff0a75eba8fd1e47a5ddeb6007b73934f9d1ac747bf9818d02d2cdfb6343830b5091ba4f3d66efc281fc376a4f0716753dd7c9a97",
"hash": "7eea385d79d88a5690cde131fe7ccda97d5c54ea09d6f515000d7bf07c828809d61c1ac99912c1ee507cf933f61c1c47ecdcc45df7850ffa82714034b0fccf35",
"min_version": "3.0.1",
"package": "Catch2",
"patches": [
@@ -35,7 +35,7 @@
],
"repo": "catchorg/Catch2",
"tag": "v%VERSION%",
"version": "3.15.1"
"version": "3.13.0"
},
"cpp-jwt": {
"find_args": "CONFIG",
@@ -96,11 +96,11 @@
"version": "8.0.1-c7b5f1537d"
},
"fmt": {
"hash": "5ac2ba0f54a484999ed5407d82b77aad170cea49a267decd2c0eedadf3b14413e2a83fcc8e9ca9c16640595e019b8636e160f72314d8be50653324e82ac745eb",
"hash": "f0da82c545b01692e9fd30fdfb613dbb8dd9716983dcd0ff19ac2a8d36f74beb5540ef38072fdecc1e34191b3682a8542ecbf3a61ef287dbba0a2679d4e023f2",
"min_version": "8",
"repo": "fmtlib/fmt",
"tag": "%VERSION%",
"version": "12.2.0"
"version": "12.1.0"
},
"frozen": {
"hash": "b8dfe741c82bc178dfc9749d4ab5a130cee718d9ee7b71d9b547cf5f7f23027ed0152ad250012a8546399fcc1e12187efc68d89d6731256c4d2df7d04eef8d5c",
@@ -119,7 +119,7 @@
},
"httplib": {
"find_args": "MODULE GLOBAL",
"hash": "bc9474b0069b84b33f96790d48cee5b52eb1b9555ea6321ce878679c4469f1c56b87b34e74786e47d09cad5a00539cdd6726058bd0ffb2087255f02d7bdabe51",
"hash": "159ed94965018f2a371d45a3bfc1961e5fb1549e501ded70a6b4532d7fe99d0579c18b5195aff6e35f96f399b426cea2650ec9fb75ef80d4c9edeccb51f2e6c9",
"options": [
"HTTPLIB_REQUIRE_OPENSSL ON",
"HTTPLIB_DISABLE_MACOSX_AUTOMATIC_ROOT_CERTIFICATES ON"
@@ -129,7 +129,7 @@
],
"repo": "yhirose/cpp-httplib",
"tag": "v%VERSION%",
"version": "0.48.0"
"version": "0.46.0"
},
"lagoon": {
"hash": "b9380f99c6effaeccc6d8f81d4942e852c11ad28613df637e155451556ae5826f93765bee57a5c87a9740d2bd1db463ad0f55a947772fe9d57eeabae3efa373e",
@@ -148,13 +148,13 @@
},
"libusb": {
"find_args": "MODULE",
"hash": "3251c9f41e900efa13caf981483f46886c8434bf4c30f3fd3073921b06be9977cebcf4a18f7bc46db86e33d7f19752296377be9050abfb8d887ffeb377864647",
"hash": "98c5f7940ff06b25c9aa65aa98e23de4c79a4c1067595f4c73cc145af23a1c286639e1ba11185cd91bab702081f307b973f08a4c9746576dc8d01b3620a3aeb5",
"patches": [
"0001-netbsd-gettime.patch"
],
"repo": "libusb/libusb",
"tag": "v%VERSION%",
"version": "1.0.30"
"version": "1.0.29"
},
"llvm-mingw": {
"artifact": "clang-rt-builtins.tar.zst",
@@ -203,7 +203,7 @@
"version": "1.10.0"
},
"openssl": {
"hash": "2405891660b67e4cc01c7868e100f2766e1c6290120213ae62f775ef3d9610c3527bdc43d4c831260417450c74353b0693ae3e24cca3e99b02e4daa548b93904",
"hash": "29002ce50cb95a4f4f1d0e9d3f684401fbd4eac34203dc2eef3b6334af5d44aa46bf788b63a6f5c139c383eafb7269ae87a58a9a3ad5912903b9773e545ccc0a",
"min_version": "3.0.0",
"package": "OpenSSL",
"patches": [
@@ -211,7 +211,7 @@
],
"repo": "openssl/openssl",
"tag": "openssl-%VERSION%",
"version": "4.0.1"
"version": "3.6.2"
},
"openssl-ci": {
"ci": true,
@@ -223,7 +223,7 @@
},
"openssl-cmake": {
"bundled": true,
"hash": "bc73a6c035f299711bb90e20b16fa3521e8ffdab32d8d17f9e7f5cde1ff5def37ec6f9e03de25c3466d18885815c0874331f56e592b8a2f7deeb484c69c5c621",
"hash": "2cc185c924fd70e7d886257ca0caa42b3b8f7f712f2052b4f94dde74759e27022de76178460e18c9bdfc57c366583999e198fbb6052d4e7d91c099d15a0ca63e",
"options": [
"OPENSSL_CONFIGURE_OPTIONS threads"
],
@@ -235,7 +235,7 @@
],
"repo": "jimmy-park/openssl-cmake",
"tag": "%VERSION%",
"version": "4.0.1"
"version": "3.6.2"
},
"opus": {
"find_args": "MODULE",
@@ -268,12 +268,12 @@
"version": "1.5"
},
"sdl3": {
"hash": "10a9c1fa4d6891c7387fa694b786a168f86b6e5447c6c522f85b739e33720e106ee879dfa9e6e537d5521b983cfbd4908927c555c4d3412735129a4231e16fe6",
"hash": "df5a323af7ac366661a3c0e887969c72584d232f3cc211419d59b0487b620b6b2859d4549c9e8df002ee489290062e466fcfddf7edc0872a37b1f2845e81c0f3",
"min_version": "3.2.10",
"package": "SDL3",
"repo": "libsdl-org/SDL",
"tag": "release-%VERSION%",
"version": "3.4.10"
"version": "3.4.8"
},
"sdl3-ci": {
"ci": true,
@@ -285,11 +285,11 @@
},
"simpleini": {
"find_args": "MODULE",
"hash": "a62c5748efe2473aae5bddab96ba9114d981a72f5b0d1a44d563daa085d5c231ed8c447794691d9bd67e1e0c6bfb44e4a8736be75fee59967d0c67ce3a59bb6e",
"hash": "b937c18a7b6277d77ca7ebfb216af4984810f77af4c32d101b7685369a4bd5eb61406223f82698e167e6311a728d07415ab59639fdf19eff71ad6dc2abfda989",
"package": "SimpleIni",
"repo": "brofield/simpleini",
"tag": "v%VERSION%",
"version": "4.26"
"version": "4.25"
},
"sirit": {
"artifact": "sirit-source-%VERSION%.tar.zst",
@@ -340,42 +340,42 @@
"version": "4.8.1"
},
"vulkan-headers": {
"hash": "3dd6d95ff1916b0660d5d15882232da53f263e8da3bfd0818c719a24f8f63ea0228ed3f6575cc8473ed53d688f280b93ef8412dc8dddf20ae3ce495f5f653b6f",
"hash": "d2846ea228415772645eea4b52a9efd33e6a563043dd3de059e798be6391a8f0ca089f455ae420ff22574939ed0f48ed7c6ff3d5a9987d5231dbf3b3f89b484b",
"min_version": "1.4.317",
"package": "VulkanHeaders",
"repo": "KhronosGroup/Vulkan-Headers",
"tag": "v%VERSION%",
"version": "1.4.355"
"version": "1.4.345"
},
"vulkan-memory-allocator": {
"find_args": "CONFIG",
"hash": "563acbcd8912d10d92c23715eba7acf0e7c1683af36021f415b36f359c2cce065f3906e395c32282a8410ec5c8179fbcb6412935c6629a49357475d4b4410e2a",
"hash": "deb5902ef8db0e329fbd5f3f4385eb0e26bdd9f14f3a2334823fb3fe18f36bc5d235d620d6e5f6fe3551ec3ea7038638899db8778c09f6d5c278f5ff95c3344b",
"package": "VulkanMemoryAllocator",
"repo": "GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator",
"tag": "v%VERSION%",
"version": "3.4.0"
"version": "3.3.0"
},
"vulkan-utility-libraries": {
"hash": "50b1c820296c6798fe28f441691bbeeb9137940fc34c1f400aa1515de134d3990e76df674c290fd39c2b3206a089ca58190147b530db81c61a96cf5e18e495d9",
"hash": "114f6b237a6dcba923ccc576befb5dea3f1c9b3a30de7dc741f234a831d1c2d52d8a224afb37dd57dffca67ac0df461eaaab6a5ab5e503b393f91c166680c3e1",
"package": "VulkanUtilityLibraries",
"repo": "KhronosGroup/Vulkan-Utility-Libraries",
"tag": "v%VERSION%",
"version": "1.4.355"
"version": "1.4.345"
},
"vulkan-validation-layers": {
"artifact": "android-binaries-%VERSION%.zip",
"hash": "1888eaaa4f0ccd7f3d1f0c6485ae5508f39e7b402ea8486d8243756d63073def569ddee75ea40b403cbfcb2ead515c410d2ff16ae48d8a4d6b4fbacbd78e24e4",
"hash": "8812ae84cbe49e6a3418ade9c458d3be6d74a3dffd319d4502007b564d580998056e8190414368ec11b27bc83993c7a0dad713c31bcc3d9553b51243efee3753",
"package": "VVL",
"repo": "KhronosGroup/Vulkan-ValidationLayers",
"tag": "vulkan-sdk-%VERSION%",
"version": "1.4.350.1"
"version": "1.4.341.0"
},
"xbyak": {
"hash": "14a0a8e3a768e6256e220b5edfd783de5e89f36736ef62674c8532f2564df03719311db923a08d2c930491632f2f83e486c8264e9997b6394ef59d32cae3070b",
"hash": "b6475276b2faaeb315734ea8f4f8bd87ededcee768961b39679bee547e7f3e98884d8b7851e176d861dab30a80a76e6ea302f8c111483607dde969b4797ea95a",
"package": "xbyak",
"repo": "herumi/xbyak",
"tag": "v%VERSION%",
"version": "7.37.4"
"version": "7.35.2"
},
"zlib": {
"hash": "16fea4df307a68cf0035858abe2fd550250618a97590e202037acd18a666f57afc10f8836cbbd472d54a0e76539d0e558cb26f059d53de52ff90634bbf4f47d4",
@@ -31,6 +31,7 @@ enum class BooleanSetting(override val key: String) : AbstractBooleanSetting {
RENDERER_REACTIVE_FLUSHING("use_reactive_flushing"),
ENABLE_BUFFER_HISTORY("enable_buffer_history"),
USE_OPTIMIZED_VERTEX_BUFFERS("use_optimized_vertex_buffers"),
ENABLE_GPU_BUFFER_READBACK("enable_gpu_buffer_readback"),
SYNC_MEMORY_OPERATIONS("sync_memory_operations"),
BUFFER_REORDER_DISABLE("disable_buffer_reorder"),
RENDERER_DEBUG("debug"),
@@ -806,6 +806,13 @@ abstract class SettingsItem(
descriptionId = R.string.enable_buffer_history_description
)
)
put(
SwitchSetting(
BooleanSetting.ENABLE_GPU_BUFFER_READBACK,
titleId = R.string.enable_gpu_buffer_readback,
descriptionId = R.string.enable_gpu_buffer_readback_description
)
)
put(
SwitchSetting(
BooleanSetting.USE_OPTIMIZED_VERTEX_BUFFERS,
@@ -292,6 +292,7 @@ class SettingsFragmentPresenter(
add(BooleanSetting.RENDERER_FORCE_MAX_CLOCK.key)
add(BooleanSetting.RENDERER_REACTIVE_FLUSHING.key)
add(BooleanSetting.ENABLE_BUFFER_HISTORY.key)
add(BooleanSetting.ENABLE_GPU_BUFFER_READBACK.key)
add(BooleanSetting.USE_OPTIMIZED_VERTEX_BUFFERS.key)
add(HeaderSetting(R.string.hacks))
@@ -503,6 +503,8 @@
<string name="renderer_reactive_flushing_description">Improves rendering accuracy in some games at the cost of performance.</string>
<string name="enable_buffer_history">Enable buffer history</string>
<string name="enable_buffer_history_description">Enables access to previous buffer states. This option may improve rendering quality and performance consistency in some games.</string>
<string name="enable_gpu_buffer_readback">Enable GPU Buffer Readback</string>
<string name="enable_gpu_buffer_readback_description">Preserves GPU-modified buffer data by reading it back before uploads. Some games require this to render certain effects properly. May cause issues if the hardware cannot handle the additional workload.</string>
<string name="use_optimized_vertex_buffers">Optimized Vertex Buffers</string>
<string name="use_optimized_vertex_buffers_description">Enables optimized vertex buffer binding for improved performance. Requires Mesa 26.0+ Turnip drivers/ QCOM drivers. Will crash on older Turnip drivers (25.3 and below).</string>
-142
View File
@@ -1,142 +0,0 @@
// 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 <deque>
#include <memory>
#include <type_traits>
#include "common/common_types.h"
namespace Common {
template <class Traits>
class LeastRecentlyUsedCache {
using ObjectType = typename Traits::ObjectType;
using TickType = typename Traits::TickType;
struct Item {
ObjectType obj;
TickType tick;
Item* next{};
Item* prev{};
};
public:
LeastRecentlyUsedCache() : first_item{}, last_item{} {}
~LeastRecentlyUsedCache() = default;
size_t Insert(ObjectType obj, TickType tick) {
const auto new_id = Build();
auto& item = item_pool[new_id];
item.obj = obj;
item.tick = tick;
Attach(item);
return new_id;
}
void Touch(size_t id, TickType tick) {
auto& item = item_pool[id];
if (item.tick >= tick) {
return;
}
item.tick = tick;
if (&item == last_item) {
return;
}
Detach(item);
Attach(item);
}
void Free(size_t id) {
auto& item = item_pool[id];
Detach(item);
item.prev = nullptr;
item.next = nullptr;
free_items.push_back(id);
}
template <typename Func>
void ForEachItemBelow(TickType tick, Func&& func) {
static constexpr bool RETURNS_BOOL =
std::is_same_v<std::invoke_result_t<Func, ObjectType>, bool>;
Item* iterator = first_item;
while (iterator) {
if (static_cast<s64>(tick) - static_cast<s64>(iterator->tick) < 0) {
return;
}
Item* next = iterator->next;
if constexpr (RETURNS_BOOL) {
if (func(iterator->obj)) {
return;
}
} else {
func(iterator->obj);
}
iterator = next;
}
}
private:
size_t Build() {
if (free_items.empty()) {
const size_t item_id = item_pool.size();
auto& item = item_pool.emplace_back();
item.next = nullptr;
item.prev = nullptr;
return item_id;
}
const size_t item_id = free_items.front();
free_items.pop_front();
auto& item = item_pool[item_id];
item.next = nullptr;
item.prev = nullptr;
return item_id;
}
void Attach(Item& item) {
if (!first_item) {
first_item = &item;
}
if (!last_item) {
last_item = &item;
} else {
item.prev = last_item;
last_item->next = &item;
item.next = nullptr;
last_item = &item;
}
}
void Detach(Item& item) {
if (item.prev) {
item.prev->next = item.next;
}
if (item.next) {
item.next->prev = item.prev;
}
if (&item == first_item) {
first_item = item.next;
if (first_item) {
first_item->prev = nullptr;
}
}
if (&item == last_item) {
last_item = item.prev;
if (last_item) {
last_item->next = nullptr;
}
}
}
std::deque<Item> item_pool;
std::deque<size_t> free_items;
Item* first_item{};
Item* last_item{};
};
} // namespace Common
+1 -1
View File
@@ -350,7 +350,7 @@ struct System::Impl {
// Register with applet manager
// All threads are started, begin main process execution, now that we're in the clear
applet_manager.CreateAndInsertByFrontendAppletParameters(std::make_unique<Service::Process>(*std::move(process)), params);
applet_manager.CreateAndInsertByFrontendAppletParameters(std::move(process), params);
if (Settings::values.gamecard_inserted) {
if (Settings::values.gamecard_current_game) {
+4
View File
@@ -109,6 +109,10 @@ struct Applet {
std::list<std::shared_ptr<Applet>> child_applets{};
bool is_completed{};
std::shared_ptr<Applet> reserved_applet{};
bool unwind_after_reserved{};
bool is_winding{};
// Self state
bool exit_locked{};
s32 fatal_section_count{};
@@ -25,6 +25,13 @@ void AppletStorageChannel::Push(Kernel::KernelCore& kernel, std::shared_ptr<ISto
m_event.Signal(kernel);
}
void AppletStorageChannel::Unpop(Kernel::KernelCore& kernel, std::shared_ptr<IStorage> storage) {
std::scoped_lock lk{m_lock};
m_data.emplace_front(std::move(storage));
m_event.Signal(kernel);
}
Result AppletStorageChannel::Pop(Kernel::KernelCore& kernel, std::shared_ptr<IStorage>* out_storage) {
std::scoped_lock lk{m_lock};
@@ -26,6 +26,7 @@ public:
~AppletStorageChannel();
void Push(Kernel::KernelCore& kernel, std::shared_ptr<IStorage> storage);
void Unpop(Kernel::KernelCore& kernel, std::shared_ptr<IStorage> storage);
Result Pop(Kernel::KernelCore& kernel, std::shared_ptr<IStorage>* out_storage);
Kernel::KReadableEvent* GetEvent();
+1 -1
View File
@@ -267,7 +267,7 @@ void AppletManager::SetWindowSystem(WindowSystem* window_system) {
if (Settings::values.enable_overlay && m_window_system->GetOverlayDisplayApplet() == nullptr) {
if (auto overlay_process = CreateProcess(m_system, static_cast<u64>(AppletProgramId::OverlayDisplay), 0, 0)) {
auto overlay_applet = std::make_shared<Applet>(m_system, std::make_unique<Service::Process>(*std::move(overlay_process)), false);
auto overlay_applet = std::make_shared<Applet>(m_system, std::move(overlay_process), false);
overlay_applet->program_id = static_cast<u64>(AppletProgramId::OverlayDisplay);
overlay_applet->applet_id = AppletId::OverlayDisplay;
overlay_applet->type = AppletType::OverlayApplet;
@@ -1,3 +1,6 @@
// 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
@@ -12,7 +15,10 @@ namespace Service::AM {
HidRegistration::HidRegistration(Core::System& system, Process& process) : m_process(process) {
m_hid_server = system.ServiceManager().GetService<HID::IHidServer>("hid", true);
this->RegisterCurrentProcess();
}
void HidRegistration::RegisterCurrentProcess() {
if (m_process.IsInitialized()) {
m_hid_server->GetResourceManager()->RegisterAppletResourceUserId(m_process.GetProcessId(),
true);
@@ -1,3 +1,6 @@
// 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
@@ -24,6 +27,7 @@ public:
explicit HidRegistration(Core::System& system, Process& process);
~HidRegistration();
void RegisterCurrentProcess();
void EnableAppletToGetInput(bool enable);
private:
@@ -171,6 +171,18 @@ void LifecycleManager::SignalSystemEventIfNeeded(Kernel::KernelCore& kernel) {
}
}
void LifecycleManager::ResetForRelaunch() {
m_unordered_messages.clear();
m_activity_state = ActivityState::BackgroundVisible;
m_requested_focus_state = FocusState{};
m_acknowledged_focus_state = FocusState{};
m_has_focus_state_changed = true;
m_suspend_mode = SuspendMode::NoOverride;
m_forced_suspend = false;
}
bool LifecycleManager::PopMessage(Kernel::KernelCore& kernel, AppletMessage* out_message) {
const auto message = this->PopMessageInOrderOfPriority();
this->SignalSystemEventIfNeeded(kernel);
@@ -138,6 +138,8 @@ public:
void PushUnorderedMessage(Kernel::KernelCore& kernel, AppletMessage message);
bool PopMessage(Kernel::KernelCore& kernel, AppletMessage* out_message);
void ResetForRelaunch();
private:
FocusState GetFocusStateWhileForegroundObscured() const;
FocusState GetFocusStateWhileBackground(bool is_obscured) const;
+24 -8
View File
@@ -40,23 +40,23 @@ namespace {
}
}
[[nodiscard]] inline std::optional<Process> CreateProcessImpl(std::unique_ptr<Loader::AppLoader>& out_loader, Loader::ResultStatus& out_load_result, Core::System& system, FileSys::VirtualFile file, u64 program_id, u64 program_index) {
[[nodiscard]] inline std::unique_ptr<Process> CreateProcessImpl(std::unique_ptr<Loader::AppLoader>& out_loader, Loader::ResultStatus& out_load_result, Core::System& system, FileSys::VirtualFile file, u64 program_id, u64 program_index) {
// Get the appropriate loader to parse this NCA.
out_loader = Loader::GetLoader(system, file, program_id, program_index);
// Ensure we have a loader which can parse the NCA.
if (out_loader) {
// Try to load the process.
auto process = std::make_optional<Process>(system);
auto process = std::make_unique<Process>(system);
if (process->Initialize(*out_loader, out_load_result)) {
return process;
}
}
return std::nullopt;
return nullptr;
}
} // Anonymous namespace
std::optional<Process> CreateProcess(Core::System& system, u64 program_id, u8 minimum_key_generation, u8 maximum_key_generation) {
std::unique_ptr<Process> CreateProcess(Core::System& system, u64 program_id, u8 minimum_key_generation, u8 maximum_key_generation) {
// Attempt to load program NCA.
FileSys::VirtualFile nca_raw{};
@@ -66,7 +66,7 @@ std::optional<Process> CreateProcess(Core::System& system, u64 program_id, u8 mi
// Ensure we retrieved a program NCA.
if (!nca_raw) {
return std::nullopt;
return nullptr;
}
// Ensure we have a suitable version.
@@ -76,7 +76,7 @@ std::optional<Process> CreateProcess(Core::System& system, u64 program_id, u8 mi
(nca.GetKeyGeneration() < minimum_key_generation ||
nca.GetKeyGeneration() > maximum_key_generation)) {
LOG_WARNING(Service_LDR, "Skipping program {:016X} with generation {}", program_id, nca.GetKeyGeneration());
return std::nullopt;
return nullptr;
}
}
@@ -85,7 +85,7 @@ std::optional<Process> CreateProcess(Core::System& system, u64 program_id, u8 mi
return CreateProcessImpl(loader, status, system, nca_raw, program_id, 0);
}
std::optional<Process> CreateApplicationProcess(std::vector<u8>& out_control, std::unique_ptr<Loader::AppLoader>& out_loader, Loader::ResultStatus& out_load_result, Core::System& system, FileSys::VirtualFile file, u64 program_id, u64 program_index) {
std::unique_ptr<Process> CreateApplicationProcess(std::vector<u8>& out_control, std::unique_ptr<Loader::AppLoader>& out_loader, Loader::ResultStatus& out_load_result, Core::System& system, FileSys::VirtualFile file, u64 program_id, u64 program_index) {
if (auto process = CreateProcessImpl(out_loader, out_load_result, system, file, program_id, program_index); process) {
FileSys::NACP nacp;
if (out_loader->ReadControlData(nacp) == Loader::ResultStatus::Success) {
@@ -110,7 +110,23 @@ std::optional<Process> CreateApplicationProcess(std::vector<u8>& out_control, st
system.GetARPManager().Register(launch.title_id, launch, out_control);
return process;
}
return std::nullopt;
return nullptr;
}
bool ReinitializeProcess(Core::System& system, Process& process, u64 program_id) {
auto& storage = system.GetContentProviderUnion();
const auto nca_raw = storage.GetEntryRaw(program_id, FileSys::ContentRecordType::Program);
if (!nca_raw) {
return false;
}
auto loader = Loader::GetLoader(system, nca_raw, program_id, 0);
if (!loader) {
return false;
}
Loader::ResultStatus status{};
return process.Initialize(*loader, status);
}
} // namespace Service::AM
+4 -2
View File
@@ -27,7 +27,9 @@ class Process;
namespace Service::AM {
std::optional<Process> CreateProcess(Core::System& system, u64 program_id, u8 minimum_key_generation, u8 maximum_key_generation);
std::optional<Process> CreateApplicationProcess(std::vector<u8>& out_control, std::unique_ptr<Loader::AppLoader>& out_loader, Loader::ResultStatus& out_load_result, Core::System& system, FileSys::VirtualFile file, u64 program_id, u64 program_index);
std::unique_ptr<Process> CreateProcess(Core::System& system, u64 program_id, u8 minimum_key_generation, u8 maximum_key_generation);
std::unique_ptr<Process> CreateApplicationProcess(std::vector<u8>& out_control, std::unique_ptr<Loader::AppLoader>& out_loader, Loader::ResultStatus& out_load_result, Core::System& system, FileSys::VirtualFile file, u64 program_id, u64 program_index);
bool ReinitializeProcess(Core::System& system, Process& process, u64 program_id);
} // namespace Service::AM
@@ -35,9 +35,9 @@ Result CreateGuestApplication(SharedPointer<IApplicationAccessor>* out_applicati
std::unique_ptr<Loader::AppLoader> loader;
Loader::ResultStatus result;
auto process = CreateApplicationProcess(control, loader, result, system, nca_raw, program_id, 0);
R_UNLESS(process != std::nullopt, ResultUnknown);
R_UNLESS(process != nullptr, ResultUnknown);
const auto applet = std::make_shared<Applet>(system, std::make_unique<Service::Process>(*std::move(process)), true);
const auto applet = std::make_shared<Applet>(system, std::move(process), true);
applet->program_id = program_id;
applet->applet_id = AppletId::Application;
applet->type = AppletType::Application;
@@ -88,9 +88,9 @@ Result IApplicationCreator::CreateSystemApplication(
std::vector<u8> control;
std::unique_ptr<Loader::AppLoader> loader;
auto process = CreateProcess(system, application_id, 1, 22);
R_UNLESS(process != std::nullopt, ResultUnknown);
R_UNLESS(process != nullptr, ResultUnknown);
const auto applet = std::make_shared<Applet>(system, std::make_unique<Service::Process>(*std::move(process)), true);
const auto applet = std::make_shared<Applet>(system, std::move(process), true);
applet->program_id = application_id;
applet->applet_id = AppletId::Starter;
applet->type = AppletType::LibraryApplet;
@@ -75,7 +75,7 @@ ILibraryAppletAccessor::ILibraryAppletAccessor(Core::System& system_,
{105, D<&ILibraryAppletAccessor::GetPopOutDataEvent>, "GetPopOutDataEvent"},
{106, D<&ILibraryAppletAccessor::GetPopInteractiveOutDataEvent>, "GetPopInteractiveOutDataEvent"},
{110, nullptr, "NeedsToExitProcess"},
{120, nullptr, "GetLibraryAppletInfo"},
{120, D<&ILibraryAppletAccessor::GetLibraryAppletInfo>, "GetLibraryAppletInfo"},
{150, nullptr, "RequestForAppletToGetForeground"},
{160, D<&ILibraryAppletAccessor::GetIndirectLayerConsumerHandle>, "GetIndirectLayerConsumerHandle"}, //2.0.0+
{170, D<&ILibraryAppletAccessor::Unknown170>, "Unknown170"}, //22.0.0+
@@ -218,6 +218,16 @@ Result ILibraryAppletAccessor::GetIndirectLayerConsumerHandle(Out<u64> out_handl
R_SUCCEED();
}
Result ILibraryAppletAccessor::GetLibraryAppletInfo(
Out<LibraryAppletInfo> out_library_applet_info) {
LOG_INFO(Service_AM, "called");
*out_library_applet_info = {
.applet_id = m_applet->applet_id,
.library_applet_mode = m_applet->library_applet_mode,
};
R_SUCCEED();
}
Result ILibraryAppletAccessor::Unknown170(OutCopyHandle<Kernel::KReadableEvent> out_event) {
LOG_WARNING(Service_AM, "(STUBBED) called");
*out_event = m_applet->unknown_event.GetHandle();
@@ -6,6 +6,7 @@
#pragma once
#include "core/hle/service/am/service/library_applet_self_accessor.h"
#include "core/hle/service/cmif_types.h"
#include "core/hle/service/service.h"
@@ -21,6 +22,10 @@ public:
std::shared_ptr<Applet> applet);
~ILibraryAppletAccessor();
std::shared_ptr<Applet> GetApplet() const {
return m_applet;
}
private:
Result GetAppletStateChangedEvent(OutCopyHandle<Kernel::KReadableEvent> out_event);
Result IsCompleted(Out<bool> out_is_completed);
@@ -37,6 +42,7 @@ private:
Result GetPopOutDataEvent(OutCopyHandle<Kernel::KReadableEvent> out_event);
Result GetPopInteractiveOutDataEvent(OutCopyHandle<Kernel::KReadableEvent> out_event);
Result GetIndirectLayerConsumerHandle(Out<u64> out_handle);
Result GetLibraryAppletInfo(Out<LibraryAppletInfo> out_library_applet_info);
Result Unknown170(OutCopyHandle<Kernel::KReadableEvent> out_event);
void FrontendExecute();
@@ -123,7 +123,7 @@ std::shared_ptr<ILibraryAppletAccessor> CreateGuestApplet(Core::System& system,
auto process = CreateProcess(system, program_id, Firmware1400, Firmware2200);
if (process) {
const auto applet = std::make_shared<Applet>(system, std::make_unique<Service::Process>(*std::move(process)), false);
const auto applet = std::make_shared<Applet>(system, std::move(process), false);
applet->program_id = program_id;
applet->applet_id = applet_id;
applet->type = AppletType::LibraryApplet;
@@ -233,8 +233,9 @@ Result ILibraryAppletSelfAccessor::ReportVisibleErrorWithErrorContext(
R_SUCCEED();
}
Result ILibraryAppletSelfAccessor::UnpopInData() {
LOG_WARNING(Service_AM, "(STUBBED) called");
Result ILibraryAppletSelfAccessor::UnpopInData(SharedPointer<IStorage> storage) {
LOG_INFO(Service_AM, "called");
m_broker->GetInData().Unpop(system.Kernel(), storage);
R_SUCCEED();
}
@@ -72,7 +72,7 @@ private:
Result ReportVisibleError(ErrorCode error_code);
Result ReportVisibleErrorWithErrorContext(
ErrorCode error_code, InLargeData<ErrorContext, BufferAttr_HipcMapAlias> error_context);
Result UnpopInData();
Result UnpopInData(SharedPointer<IStorage> storage);
Result GetMainAppletApplicationDesiredLanguage(Out<u64> out_desired_language);
Result GetCurrentApplicationId(Out<u64> out_application_id);
Result GetMainAppletAvailableUsers(Out<bool> out_can_select_any_user, Out<s32> out_users_count,
@@ -1,9 +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 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/core.h"
#include "core/hle/service/am/applet.h"
#include "core/hle/service/am/frontend/applets.h"
#include "core/hle/service/am/service/library_applet_accessor.h"
#include "core/hle/service/am/service/process_winding_controller.h"
@@ -43,6 +45,18 @@ Result IProcessWindingController::OpenCallingLibraryApplet(
Out<SharedPointer<ILibraryAppletAccessor>> out_calling_library_applet) {
LOG_INFO(Service_AM, "called");
std::shared_ptr<Applet> reserved_applet;
{
std::scoped_lock lk{m_applet->lock};
reserved_applet = std::move(m_applet->reserved_applet);
}
if (reserved_applet != nullptr) {
*out_calling_library_applet = std::make_shared<ILibraryAppletAccessor>(
system, reserved_applet->caller_applet_broker, reserved_applet);
R_SUCCEED();
}
const auto caller_applet = m_applet->caller_applet.lock();
if (caller_applet == nullptr) {
LOG_ERROR(Service_AM, "No caller applet available");
@@ -74,22 +88,82 @@ Result IProcessWindingController::PopContext(Out<SharedPointer<IStorage>> out_co
}
Result IProcessWindingController::CancelWindingReservation() {
LOG_WARNING(Service_AM, "STUBBED");
LOG_INFO(Service_AM, "called");
std::scoped_lock lk{m_applet->lock};
m_applet->reserved_applet.reset();
m_applet->unwind_after_reserved = false;
R_SUCCEED();
}
Result IProcessWindingController::WindAndDoReserved() {
LOG_WARNING(Service_AM, "STUBBED");
LOG_INFO(Service_AM, "called");
std::shared_ptr<Applet> reserved_applet;
{
std::scoped_lock lk{m_applet->lock};
reserved_applet = m_applet->reserved_applet;
m_applet->display_layer_manager.SetWindowVisibility(false);
m_applet->exit_locked = false;
system.SetExitLocked(false);
}
if (reserved_applet) {
{
std::scoped_lock lk{m_applet->lock};
m_applet->is_winding = true;
}
{
std::scoped_lock lk{reserved_applet->lock};
reserved_applet->window_visible = true;
reserved_applet->process->Run();
}
if (reserved_applet->frontend) {
reserved_applet->frontend->Initialize();
reserved_applet->frontend->Execute();
}
} else {
LOG_WARNING(Service_AM, "called without a reserved applet to start");
}
m_applet->process->Terminate();
R_SUCCEED();
}
Result IProcessWindingController::ReserveToStartAndWaitAndUnwindThis() {
LOG_WARNING(Service_AM, "STUBBED");
Result IProcessWindingController::ReserveToStartAndWaitAndUnwindThis(
SharedPointer<ILibraryAppletAccessor> reserved_applet_accessor) {
LOG_INFO(Service_AM, "called");
if (reserved_applet_accessor == nullptr) {
LOG_ERROR(Service_AM, "No applet accessor provided");
R_THROW(ResultUnknown);
}
std::scoped_lock lk{m_applet->lock};
m_applet->reserved_applet = reserved_applet_accessor->GetApplet();
m_applet->unwind_after_reserved = true;
R_SUCCEED();
}
Result IProcessWindingController::ReserveToStartAndWait() {
LOG_WARNING(Service_AM, "STUBBED");
Result IProcessWindingController::ReserveToStartAndWait(
SharedPointer<ILibraryAppletAccessor> reserved_applet_accessor) {
LOG_INFO(Service_AM, "called");
if (reserved_applet_accessor == nullptr) {
LOG_ERROR(Service_AM, "No applet accessor provided");
R_THROW(ResultUnknown);
}
std::scoped_lock lk{m_applet->lock};
m_applet->reserved_applet = reserved_applet_accessor->GetApplet();
m_applet->unwind_after_reserved = false;
R_SUCCEED();
}
@@ -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
@@ -29,8 +29,9 @@ private:
Result PopContext(Out<SharedPointer<IStorage>> out_context);
Result CancelWindingReservation();
Result WindAndDoReserved();
Result ReserveToStartAndWaitAndUnwindThis();
Result ReserveToStartAndWait();
Result ReserveToStartAndWaitAndUnwindThis(
SharedPointer<ILibraryAppletAccessor> reserved_applet_accessor);
Result ReserveToStartAndWait(SharedPointer<ILibraryAppletAccessor> reserved_applet_accessor);
const std::shared_ptr<Applet> m_applet;
};
+57
View File
@@ -9,6 +9,7 @@
#include "core/hle/service/am/applet.h"
#include "core/hle/service/am/applet_manager.h"
#include "core/hle/service/am/event_observer.h"
#include "core/hle/service/am/process_creation.h"
#include "core/hle/service/am/window_system.h"
namespace Service::AM {
@@ -240,6 +241,37 @@ void WindowSystem::PruneTerminatedAppletsLocked() {
continue;
}
// A winding applet has had its own process killed but is kept alive as a transparent slot
// while the reserved applet running in its place finishes (see WindAndDoReserved()).
if (applet->is_winding) {
if (!applet->child_applets.empty()) {
it = std::next(it);
continue;
}
const bool unwind = applet->unwind_after_reserved;
applet->is_winding = false;
applet->unwind_after_reserved = false;
if (unwind && this->RestartAppletProcessLocked(applet.get())) {
const u64 new_aruid = applet->aruid.pid;
const auto next = std::next(it);
if (new_aruid != aruid) {
auto node = m_applets.extract(it);
node.key() = new_aruid;
m_applets.insert(std::move(node));
}
applet->process->Run();
m_event_observer->RequestUpdate();
it = next;
continue;
}
applet->reserved_applet.reset();
}
// Terminated, so ensure all child applets are terminated.
if (!applet->child_applets.empty()) {
this->TerminateChildAppletsLocked(applet.get());
@@ -301,6 +333,28 @@ void WindowSystem::PruneTerminatedAppletsLocked() {
}
}
bool WindowSystem::RestartAppletProcessLocked(Applet* applet) {
if (!ReinitializeProcess(m_system, *applet->process, applet->program_id)) {
LOG_ERROR(Service_AM, "Failed to restart winding applet_id={}",
static_cast<u32>(applet->applet_id));
return false;
}
applet->aruid.pid = applet->process->GetProcessId();
applet->is_process_running = false;
applet->is_completed = false;
applet->hid_registration.RegisterCurrentProcess();
applet->lifecycle_manager.ResetForRelaunch();
applet->is_activity_runnable = false;
applet->launch_reason.flag = 1;
m_event_observer->TrackAppletProcess(*applet);
return true;
}
bool WindowSystem::LockHomeMenuIntoForegroundLocked() {
// If the home menu is not locked into foreground, then there's nothing to do.
if (m_home_menu == nullptr || !m_home_menu_foreground_locked) {
@@ -352,6 +406,9 @@ void WindowSystem::UpdateAppletStateLocked(Applet* applet, bool is_foreground, b
const bool has_obscuring_child_applets = [&] {
for (const auto& child_applet : applet->child_applets) {
std::scoped_lock lk2{child_applet->lock};
if (child_applet->is_winding) {
return true;
}
const auto mode = child_applet->library_applet_mode;
if (child_applet->is_process_running && child_applet->window_visible &&
(mode == LibraryAppletMode::AllForeground ||
+1
View File
@@ -61,6 +61,7 @@ public:
private:
void PruneTerminatedAppletsLocked();
bool RestartAppletProcessLocked(Applet* applet);
bool LockHomeMenuIntoForegroundLocked();
void TerminateChildAppletsLocked(Applet* applet);
void UpdateAppletStateLocked(Applet* applet, bool is_foreground, bool overlay_blocking = false);
+5 -5
View File
@@ -109,12 +109,12 @@ public:
return static_cast<u32>(other_cpu_addr - cpu_addr);
}
size_t getLRUID() const noexcept {
return lru_id;
u64 GetFrameTick() const noexcept {
return frame_tick;
}
void setLRUID(size_t lru_id_) {
lru_id = lru_id_;
void SetFrameTick(u64 tick) noexcept {
frame_tick = tick;
}
size_t SizeBytes() const {
@@ -125,7 +125,7 @@ private:
VAddr cpu_addr = 0;
BufferFlagBits flags{};
int stream_score = 0;
size_t lru_id = SIZE_MAX;
u64 frame_tick = 0;
size_t size_bytes = 0;
};
+12 -8
View File
@@ -58,17 +58,22 @@ void BufferCache<P>::RunGarbageCollector() {
const bool aggressive_gc = total_used_memory >= critical_memory;
const u64 ticks_to_destroy = aggressive_gc ? 60 : 120;
int num_iterations = aggressive_gc ? 64 : 32;
const auto clean_up = [this, &num_iterations](BufferId buffer_id) {
const u64 threshold = frame_tick - ticks_to_destroy;
boost::container::small_vector<BufferId, 64> expired;
for (auto [id, buffer] : slot_buffers) {
if (buffer->GetFrameTick() < threshold) {
expired.push_back(id);
}
}
for (const auto buffer_id : expired) {
if (num_iterations == 0) {
return true;
break;
}
--num_iterations;
auto& buffer = slot_buffers[buffer_id];
DownloadBufferMemory(buffer);
DeleteBuffer(buffer_id);
return false;
};
lru_cache.ForEachItemBelow(frame_tick - ticks_to_destroy, clean_up);
}
}
template <class P>
@@ -1591,10 +1596,9 @@ void BufferCache<P>::ChangeRegister(BufferId buffer_id) {
const auto size = buffer.SizeBytes();
if (insert) {
total_used_memory += Common::AlignUp(size, 1024);
buffer.setLRUID(lru_cache.Insert(buffer_id, frame_tick));
buffer.SetFrameTick(frame_tick);
} else {
total_used_memory -= Common::AlignUp(size, 1024);
lru_cache.Free(buffer.getLRUID());
}
const DAddr device_addr_begin = buffer.CpuAddr();
const DAddr device_addr_end = device_addr_begin + size;
@@ -1612,7 +1616,7 @@ void BufferCache<P>::ChangeRegister(BufferId buffer_id) {
template <class P>
void BufferCache<P>::TouchBuffer(Buffer& buffer, BufferId buffer_id) noexcept {
if (buffer_id != NULL_BUFFER_ID) {
lru_cache.Touch(buffer.getLRUID(), frame_tick);
buffer.SetFrameTick(frame_tick);
}
}
@@ -23,7 +23,6 @@
#include "common/common_types.h"
#include "common/div_ceil.h"
#include "common/literals.h"
#include "common/lru_cache.h"
#include "common/range_sets.h"
#include "common/scope_exit.h"
#include "common/settings.h"
@@ -506,11 +505,6 @@ private:
size_t immediate_buffer_capacity = 0;
Common::ScratchBuffer<u8> immediate_buffer_alloc;
struct LRUItemParams {
using ObjectType = BufferId;
using TickType = u64;
};
Common::LeastRecentlyUsedCache<LRUItemParams> lru_cache;
u64 frame_tick = 0;
u64 total_used_memory = 0;
u64 minimum_memory = 0;
+34 -2
View File
@@ -117,7 +117,35 @@ void DmaPusher::ProcessCommands(std::span<const CommandHeader> commands) {
dma_state.is_last_call = true;
index += max_write;
} else if (dma_state.method_count) {
auto const command_header = commands[index]; //can copy
if (!dma_state.non_incrementing && !dma_increment_once &&
dma_state.method >= non_puller_methods) {
auto subchannel = subchannels[dma_state.subchannel];
const u32 available = u32(std::min<size_t>(
index + dma_state.method_count, commands.size()) - index);
u32 batch = 0;
u32 method = dma_state.method;
while (batch < available) {
const bool needs_exec =
(method < Engines::EngineInterface::EXECUTION_MASK_TABLE_SIZE)
? subchannel->execution_mask[method]
: subchannel->execution_mask_default;
if (needs_exec) break;
batch++;
method++;
}
if (batch > 0) {
auto& sink = subchannel->method_sink;
sink.reserve(sink.size() + batch);
for (u32 j = 0; j < batch; j++) {
sink.emplace_back(dma_state.method + j, commands[index + j].argument);
}
dma_state.method += batch;
dma_state.method_count -= batch;
index += batch;
continue;
}
}
auto const command_header = commands[index];
dma_state.dma_word_offset = u32(index * sizeof(u32));
dma_state.is_last_call = dma_state.method_count <= 1;
CallMethod(command_header.argument);
@@ -176,7 +204,11 @@ void DmaPusher::CallMethod(u32 argument) {
});
} else {
auto subchannel = subchannels[dma_state.subchannel];
if (!subchannel->execution_mask[dma_state.method]) {
const bool needs_execution =
(dma_state.method < Engines::EngineInterface::EXECUTION_MASK_TABLE_SIZE)
? subchannel->execution_mask[dma_state.method]
: subchannel->execution_mask_default;
if (!needs_execution) {
subchannel->method_sink.emplace_back(dma_state.method, argument);
} else {
subchannel->ConsumeSink(system);
+9 -5
View File
@@ -6,9 +6,8 @@
#pragma once
#include <bitset>
#include <limits>
#include <vector>
#include <array>
#include <boost/container/small_vector.hpp>
#include "common/common_types.h"
@@ -43,10 +42,15 @@ public:
}
}
std::bitset<(std::numeric_limits<u16>::max)()> execution_mask{};
std::vector<std::pair<u32, u32>> method_sink{};
static constexpr size_t EXECUTION_MASK_TABLE_SIZE = 0xE00;
std::array<u8, EXECUTION_MASK_TABLE_SIZE> execution_mask{};
bool execution_mask_default{};
boost::container::small_vector<std::pair<u32, u32>, 64> method_sink{};
GPUVAddr current_dma_segment;
/// @brief Indicates whether the current DMA segment is dirty.
bool current_dirty{};
protected:
virtual void ConsumeSinkImpl(Core::System& system) {
for (auto [method, value] : method_sink) {
+1 -1
View File
@@ -26,7 +26,7 @@ Fermi2D::Fermi2D(MemoryManager& memory_manager_) : memory_manager{memory_manager
regs.src.depth = 1;
regs.dst.depth = 1;
execution_mask.reset();
execution_mask.fill(0);
execution_mask[FERMI2D_REG_INDEX(pixels_from_memory.src_y0) + 1] = true;
}
+1 -1
View File
@@ -20,7 +20,7 @@ KeplerCompute::KeplerCompute(MemoryManager& memory_manager_)
: memory_manager{memory_manager_}
, upload_state{memory_manager, regs.upload}
{
execution_mask.reset();
execution_mask.fill(0);
execution_mask[KEPLER_COMPUTE_REG_INDEX(exec_upload)] = true;
execution_mask[KEPLER_COMPUTE_REG_INDEX(data_upload)] = true;
execution_mask[KEPLER_COMPUTE_REG_INDEX(launch)] = true;
+1 -1
View File
@@ -23,7 +23,7 @@ KeplerMemory::~KeplerMemory() = default;
void KeplerMemory::BindRasterizer(VideoCore::RasterizerInterface* rasterizer_) {
upload_state.BindRasterizer(rasterizer_);
execution_mask.reset();
execution_mask.fill(0);
execution_mask[KEPLERMEMORY_REG_INDEX(exec)] = true;
execution_mask[KEPLERMEMORY_REG_INDEX(data)] = true;
}
+48 -5
View File
@@ -4,8 +4,14 @@
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <algorithm>
#include <cstring>
#include <optional>
#if defined(_MSC_VER) && !defined(__clang__)
#include <intrin.h>
#endif
#include "common/assert.h"
#include "common/bit_util.h"
#include "common/scope_exit.h"
@@ -22,6 +28,16 @@
namespace Tegra::Engines {
namespace {
inline void PrefetchLine(const void* addr) {
#if defined(_MSC_VER) && !defined(__clang__)
_mm_prefetch(static_cast<const char*>(addr), _MM_HINT_T0);
#else
__builtin_prefetch(addr, 0, 1);
#endif
}
} // namespace
/// First register id that is actually a Macro call.
constexpr u32 MacroRegistersStart = 0xE00;
@@ -37,9 +53,10 @@ Maxwell3D::Maxwell3D(MemoryManager& memory_manager_)
{
dirty.flags.flip();
InitializeRegisterDefaults();
execution_mask.reset();
for (size_t i = 0; i < execution_mask.size(); i++)
execution_mask.fill(0);
for (size_t i = 0; i < EXECUTION_MASK_TABLE_SIZE; i++)
execution_mask[i] = IsMethodExecutable(u32(i));
execution_mask_default = true;
}
Maxwell3D::~Maxwell3D() = default;
@@ -282,18 +299,44 @@ u32 Maxwell3D::ProcessShadowRam(u32 method, u32 argument) {
}
void Maxwell3D::ConsumeSinkImpl(Core::System& system) {
std::stable_sort(method_sink.begin(), method_sink.end(),
[](const auto& a, const auto& b) { return a.first < b.first; });
const auto sink_size = method_sink.size();
const auto control = shadow_state.shadow_ram_control;
if (control == Regs::ShadowRamControl::Track || control == Regs::ShadowRamControl::TrackWithFilter) {
for (auto [method, value] : method_sink) {
for (size_t i = 0; i < sink_size; ++i) {
const auto [method, value] = method_sink[i];
if (i + 1 < sink_size) {
const u32 next = method_sink[i + 1].first;
PrefetchLine(&regs.reg_array[next]);
PrefetchLine(&shadow_state.reg_array[next]);
PrefetchLine(&dirty.tables[0][next]);
}
shadow_state.reg_array[method] = value;
ProcessDirtyRegisters(method, value);
}
} else if (control == Regs::ShadowRamControl::Replay) {
for (auto [method, value] : method_sink)
for (size_t i = 0; i < sink_size; ++i) {
const auto [method, value] = method_sink[i];
if (i + 1 < sink_size) {
const u32 next = method_sink[i + 1].first;
PrefetchLine(&regs.reg_array[next]);
PrefetchLine(&shadow_state.reg_array[next]);
PrefetchLine(&dirty.tables[0][next]);
}
ProcessDirtyRegisters(method, shadow_state.reg_array[method]);
}
} else {
for (auto [method, value] : method_sink)
for (size_t i = 0; i < sink_size; ++i) {
const auto [method, value] = method_sink[i];
if (i + 1 < sink_size) {
const u32 next = method_sink[i + 1].first;
PrefetchLine(&regs.reg_array[next]);
PrefetchLine(&dirty.tables[0][next]);
}
ProcessDirtyRegisters(method, value);
}
}
method_sink.clear();
}
+1 -1
View File
@@ -24,7 +24,7 @@ using namespace Texture;
MaxwellDMA::MaxwellDMA(MemoryManager& memory_manager_)
: memory_manager{memory_manager_}
{
execution_mask.reset();
execution_mask.fill(0);
execution_mask[offsetof(Regs, launch_dma) / sizeof(u32)] = true;
}
+3
View File
@@ -287,6 +287,7 @@ void QueryCacheBase<Traits>::CounterReport(GPUVAddr addr, QueryType counter_type
u32 value = static_cast<u32>(query_base->value);
std::memcpy(pointer, &value, sizeof(value));
}
query_base->flags |= QueryFlagBits::IsGuestSynced;
if (!is_synced) [[likely]] {
impl->pending_unregister.push_back(query_location);
}
@@ -569,10 +570,12 @@ bool QueryCacheBase<Traits>::SemiFlushQueryDirty(QueryCacheBase<Traits>::QueryLo
auto* ptr = impl->device_memory.template GetPointer<u8>(query_base->guest_address);
if (True(query_base->flags & QueryFlagBits::HasTimestamp)) {
std::memcpy(ptr, &query_base->value, sizeof(query_base->value));
query_base->flags |= QueryFlagBits::IsGuestSynced;
return false;
}
u32 value_l = static_cast<u32>(query_base->value);
std::memcpy(ptr, &value_l, sizeof(value_l));
query_base->flags |= QueryFlagBits::IsGuestSynced;
return false;
}
return True(query_base->flags & QueryFlagBits::IsHostManaged) &&
@@ -62,6 +62,7 @@ void FixedPipelineState::Refresh(Tegra::Engines::Maxwell3D& maxwell3d, DynamicFe
extended_dynamic_state_2_logic_op.Assign(features.has_extended_dynamic_state_2_logic_op ? 1 : 0);
extended_dynamic_state_3_blend.Assign(features.has_extended_dynamic_state_3_blend ? 1 : 0);
extended_dynamic_state_3_enables.Assign(features.has_extended_dynamic_state_3_enables ? 1 : 0);
dynamic_state3_depth_clamp_enable.Assign(features.has_dynamic_state3_depth_clamp_enable ? 1 : 0);
dynamic_vertex_input.Assign(features.has_dynamic_vertex_input ? 1 : 0);
xfb_enabled.Assign(regs.transform_feedback_enabled != 0);
ndc_minus_one_to_one.Assign(regs.depth_mode == Maxwell::DepthMode::MinusOneToOne ? 1 : 0);
@@ -208,6 +208,7 @@ struct FixedPipelineState {
BitField<12, 2, u32> tessellation_spacing;
BitField<14, 1, u32> tessellation_clockwise;
BitField<15, 5, u32> patch_control_points_minus_one;
BitField<20, 1, u32> dynamic_state3_depth_clamp_enable;
BitField<24, 4, Maxwell::PrimitiveTopology> topology;
BitField<28, 4, Tegra::Texture::MsaaMode> msaa_mode;
@@ -907,7 +907,7 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) {
// EDS3 - Enables (composite: per-feature)
if (key.state.extended_dynamic_state_3_enables) {
if (device.SupportsDynamicState3DepthClampEnable()) {
if (key.state.dynamic_state3_depth_clamp_enable != 0) {
dynamic_states.push_back(VK_DYNAMIC_STATE_DEPTH_CLAMP_ENABLE_EXT);
}
if (device.SupportsDynamicState3LogicOpEnable()) {
@@ -492,7 +492,9 @@ PipelineCache::PipelineCache(Tegra::MaxwellDeviceMemoryManager& device_memory_,
device.IsExtExtendedDynamicState3BlendingSupported();
dynamic_features.has_extended_dynamic_state_3_enables =
device.IsExtExtendedDynamicState3EnablesSupported();
dynamic_features.has_dynamic_state3_depth_clamp_enable = false;
dynamic_features.has_dynamic_state3_depth_clamp_enable =
dynamic_features.has_extended_dynamic_state_3_enables &&
device.SupportsDynamicState3DepthClampEnable();
dynamic_features.has_dynamic_state3_logic_op_enable =
device.SupportsDynamicState3LogicOpEnable();
dynamic_features.has_dynamic_state3_line_stipple_enable =
@@ -113,6 +113,10 @@ public:
[[nodiscard]] ComputePipeline* CurrentComputePipeline();
[[nodiscard]] bool SupportsDynamicState3DepthClampEnable() const {
return dynamic_features.has_dynamic_state3_depth_clamp_enable;
}
void LoadDiskResources(u64 title_id, std::stop_token stop_loading,
const VideoCore::DiskResourceLoadCallback& callback);
@@ -218,8 +218,7 @@ public:
}
PauseCounter();
const auto driver_id = device.GetDriverID();
if (driver_id == VK_DRIVER_ID_QUALCOMM_PROPRIETARY ||
driver_id == VK_DRIVER_ID_ARM_PROPRIETARY || driver_id == VK_DRIVER_ID_MESA_TURNIP) {
if (driver_id == VK_DRIVER_ID_ARM_PROPRIETARY || driver_id == VK_DRIVER_ID_MESA_TURNIP) {
pending_sync.clear();
sync_values_stash.clear();
return;
@@ -1578,7 +1578,7 @@ void RasterizerVulkan::UpdateDepthClampEnable(Tegra::Engines::Maxwell3D::Regs& r
if (!state_tracker.TouchDepthClampEnable()) {
return;
}
if (!device.SupportsDynamicState3DepthClampEnable()) {
if (!pipeline_cache.SupportsDynamicState3DepthClampEnable()) {
return;
}
bool is_enabled = !(regs.viewport_clip_control.geometry_clip ==
@@ -6,6 +6,7 @@
#pragma once
#include <atomic>
#include <condition_variable>
#include <cstddef>
#include <functional>
@@ -92,10 +93,12 @@ public:
requires std::is_invocable_v<T, vk::CommandBuffer, vk::CommandBuffer>
void RecordWithUploadBuffer(T&& command) {
if (chunk->Record(command)) {
record_serial.fetch_add(1, std::memory_order_relaxed);
return;
}
DispatchWork();
(void)chunk->Record(command);
record_serial.fetch_add(1, std::memory_order_relaxed);
}
template <typename T>
@@ -117,6 +120,11 @@ public:
return master_semaphore->IsFree(tick);
}
/// Returns a monotonic serial incremented for every recorded command callback.
[[nodiscard]] u64 CurrentRecordSerial() const noexcept {
return record_serial.load(std::memory_order_relaxed);
}
/// Waits for the given GPU tick, optionally pacing frames.
void Wait(u64 tick, double target_fps = 0.0) {
if (tick > 0) {
@@ -298,6 +306,7 @@ private:
u64 frame_counter{};
u64 last_submitted_tick = 0;
std::atomic<u64> record_serial{0};
};
} // namespace Vulkan
+4 -1
View File
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@@ -102,7 +105,7 @@ struct ImageBase {
VAddr cpu_addr_end = 0;
u64 modification_tick = 0;
size_t lru_index = SIZE_MAX;
u64 last_use_tick = 0;
std::array<u32, MAX_MIP_LEVELS> mip_level_offsets{};
+49 -6
View File
@@ -159,11 +159,54 @@ void TextureCache<P>::RunGarbageCollector() {
}
return false;
};
const auto CollectBelow = [this](u64 threshold) {
boost::container::small_vector<ImageId, 64> expired;
for (auto [id, image] : slot_images) {
if (image->last_use_tick < threshold) {
expired.push_back(id);
}
}
return expired;
};
// Aggressively clear massive sparse textures
if (total_used_memory >= expected_memory) {
auto candidates = CollectBelow(frame_tick);
for (const auto image_id : candidates) {
auto& image = slot_images[image_id];
if (image.info.is_sparse &&
image.guest_size_bytes >= 256_MiB &&
image.allocation_tick < frame_tick - 3) {
LOG_DEBUG(HW_GPU, "GC targeting old sparse texture at 0x{:X} ({} MiB, age: {} frames)",
image.gpu_addr, image.guest_size_bytes / (1024 * 1024),
frame_tick - image.allocation_tick);
if (Cleanup(image_id)) {
break;
}
}
}
}
Configure(false);
lru_cache.ForEachItemBelow(frame_tick - ticks_to_destroy, Cleanup);
{
auto expired = CollectBelow(frame_tick - ticks_to_destroy);
for (const auto image_id : expired) {
if (Cleanup(image_id)) {
break;
}
}
}
// If pressure is still too high, prune aggressively.
if (total_used_memory >= critical_memory) {
Configure(true);
lru_cache.ForEachItemBelow(frame_tick - ticks_to_destroy, Cleanup);
auto expired = CollectBelow(frame_tick - ticks_to_destroy);
for (const auto image_id : expired) {
if (Cleanup(image_id)) {
break;
}
}
}
}
@@ -1865,7 +1908,7 @@ std::pair<u32, u32> TextureCache<P>::PrepareDmaImage(ImageId dst_id, GPUVAddr ba
const auto base = image.TryFindBase(base_addr);
PrepareImage(dst_id, mark_as_modified, false);
const auto& new_image = slot_images[dst_id];
lru_cache.Touch(new_image.lru_index, frame_tick);
new_image.last_use_tick = frame_tick;
return std::make_pair(base->level, base->layer);
}
@@ -2192,7 +2235,7 @@ void TextureCache<P>::RegisterImage(ImageId image_id) {
tentative_size = TranscodedAstcSize(tentative_size, image.info.format);
}
total_used_memory += Common::AlignUp(tentative_size, 1024);
image.lru_index = lru_cache.Insert(image_id, frame_tick);
image.last_use_tick = frame_tick;
ForEachGPUPage(image.gpu_addr, image.guest_size_bytes, [this, image_id](u64 page) {
(*channel_state->gpu_page_table)[page].push_back(image_id);
@@ -2226,7 +2269,7 @@ void TextureCache<P>::UnregisterImage(ImageId image_id) {
"Trying to unregister an already registered image");
image.flags &= ~ImageFlagBits::Registered;
image.flags &= ~ImageFlagBits::BadOverlap;
lru_cache.Free(image.lru_index);
const auto& clear_page_table =
[image_id](u64 page, ankerl::unordered_dense::map<u64, std::vector<ImageId>, Common::IdentityHash<u64>>& selected_page_table) {
const auto page_it = selected_page_table.find(page);
@@ -2554,7 +2597,7 @@ void TextureCache<P>::PrepareImage(ImageId image_id, bool is_modification, bool
if (is_modification) {
MarkModification(image);
}
lru_cache.Touch(image.lru_index, frame_tick);
image.last_use_tick = frame_tick;
}
template <class P>
@@ -23,7 +23,7 @@
#include "common/common_types.h"
#include "common/hash.h"
#include "common/literals.h"
#include "common/lru_cache.h"
#include <ranges>
#include "common/scratch_buffer.h"
#include "common/slot_vector.h"
@@ -485,11 +485,7 @@ private:
std::deque<std::vector<AsyncBuffer>> async_buffers;
std::deque<AsyncBuffer> async_buffers_death_ring;
struct LRUItemParams {
using ObjectType = ImageId;
using TickType = u64;
};
Common::LeastRecentlyUsedCache<LRUItemParams> lru_cache;
#ifdef YUZU_LEGACY
static constexpr size_t TICKS_TO_DESTROY = 6;