mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-08-17 21:57:52 +00:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 710d1a3b04 | |||
| 3f15be0d22 | |||
| dca2803d56 | |||
| 7fb80fdff7 | |||
| f6c2c0e75a | |||
| 052d2fe828 | |||
| f9d20c14e3 | |||
| 421838a417 | |||
| a7ef19e028 | |||
| 2c1eff2e60 | |||
| abb616c357 | |||
| c95cb8f8ec |
File diff suppressed because it is too large
Load Diff
Vendored
+242
-242
File diff suppressed because it is too large
Load Diff
Vendored
+233
-233
File diff suppressed because it is too large
Load Diff
Vendored
+233
-233
File diff suppressed because it is too large
Load Diff
Vendored
+233
-233
File diff suppressed because it is too large
Load Diff
Vendored
+233
-233
File diff suppressed because it is too large
Load Diff
Vendored
+233
-233
File diff suppressed because it is too large
Load Diff
Vendored
+241
-241
File diff suppressed because it is too large
Load Diff
Vendored
+233
-233
File diff suppressed because it is too large
Load Diff
Vendored
+233
-233
File diff suppressed because it is too large
Load Diff
Vendored
+233
-233
File diff suppressed because it is too large
Load Diff
Vendored
+233
-233
File diff suppressed because it is too large
Load Diff
Vendored
+233
-233
File diff suppressed because it is too large
Load Diff
Vendored
+233
-233
File diff suppressed because it is too large
Load Diff
Vendored
+233
-233
File diff suppressed because it is too large
Load Diff
Vendored
+233
-233
File diff suppressed because it is too large
Load Diff
Vendored
+233
-233
File diff suppressed because it is too large
Load Diff
Vendored
+233
-233
File diff suppressed because it is too large
Load Diff
Vendored
+407
-379
File diff suppressed because it is too large
Load Diff
Vendored
+233
-233
File diff suppressed because it is too large
Load Diff
Vendored
+233
-233
File diff suppressed because it is too large
Load Diff
Vendored
+233
-233
File diff suppressed because it is too large
Load Diff
Vendored
+233
-233
File diff suppressed because it is too large
Load Diff
Vendored
+233
-233
File diff suppressed because it is too large
Load Diff
Vendored
+233
-233
File diff suppressed because it is too large
Load Diff
Vendored
+233
-233
File diff suppressed because it is too large
Load Diff
Vendored
+233
-233
File diff suppressed because it is too large
Load Diff
Vendored
+233
-233
File diff suppressed because it is too large
Load Diff
+3
-2
@@ -79,7 +79,7 @@ Certain other dependencies will be fetched by CPM regardless. System packages *c
|
||||
|
||||
On amd64:
|
||||
|
||||
* [xbyak](https://github.com/herumi/xbyak) - 7.22 or earlier is recommended
|
||||
* [xbyak](https://github.com/herumi/xbyak) - 7.35.2+
|
||||
|
||||
On aarch64 OR if `DYNARMIC_TESTS` is on:
|
||||
|
||||
@@ -161,11 +161,12 @@ sudo pacman -Syu --needed base-devel boost catch2 cmake enet ffmpeg fmt git glsl
|
||||
<summary>Ubuntu, Debian, Mint Linux</summary>
|
||||
|
||||
```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 nlohmann-json3-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 libsdl2-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 libfmt-dev liblz4-dev nlohmann-json3-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 libboost-dev libboost-fiber-dev libboost-context-dev libsdl2-dev libopus-dev libasound2t64 vulkan-utility-libraries-dev
|
||||
```
|
||||
|
||||
* Ubuntu 22.04, Linux Mint 20, or Debian 12 or later is required.
|
||||
* To enable QT Web Engine, add `-DYUZU_USE_QT_WEB_ENGINE=ON` when running CMake.
|
||||
* `libxbyak-dev` is optional for x86_64 targets
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
Vendored
+7
-2
@@ -58,8 +58,13 @@
|
||||
"package": "xbyak",
|
||||
"repo": "herumi/xbyak",
|
||||
"tag": "v%VERSION%",
|
||||
"hash": "b6475276b2faaeb315734ea8f4f8bd87ededcee768961b39679bee547e7f3e98884d8b7851e176d861dab30a80a76e6ea302f8c111483607dde969b4797ea95a",
|
||||
"git_version": "7.35.2"
|
||||
"hash": "d93971cc8f17f20818e36099aa862d15d30b60f17c7dff0cc8b7ac89ad6dc6453256dd47a454904666a85cea6ca27f9867f782c7b2c6d0c16039af8e3e28e6cc",
|
||||
"git_version": "7.35.4",
|
||||
"bundled": true,
|
||||
"skip_updates": true,
|
||||
"patches": [
|
||||
"0001-rvalue-optimize.patch"
|
||||
]
|
||||
},
|
||||
"oaknut": {
|
||||
"repo": "eden-emulator/oaknut",
|
||||
|
||||
@@ -287,7 +287,7 @@
|
||||
<string name="install_amiibo_keys">تثبيت مفاتيح أميبو</string>
|
||||
<string name="install_amiibo_keys_description">مطلوب لاستخدام أميبو في اللعبة</string>
|
||||
<string name="gpu_driver_fetcher">أداة جلب برامج تشغيل وحدة المعالجة الرسومية</string>
|
||||
<string name="gpu_driver_manager">مدير برامج تشغيل وحدة معالجة الرسومات</string>
|
||||
<string name="gpu_driver_manager">إدارة برامج تشغيل وحدة معالجة الرسومات</string>
|
||||
<string name="install_gpu_driver_description">تثبيت برامج تشغيل بديلة لأداء أو دقة أفضل</string>
|
||||
<string name="advanced_settings">الإعدادات المتقدمة</string>
|
||||
<string name="settings_description">ضبط إعدادات المحاكي</string>
|
||||
@@ -486,6 +486,10 @@
|
||||
<string name="use_disk_shader_cache_description">يقلل من التأتأة عن طريق تخزين وتحميل التظليلات التي تم إنشاؤها محليًا.</string>
|
||||
<string name="renderer_force_max_clock">إجبار السرعة القصوى (لأجهزة Adreno فقط)</string>
|
||||
<string name="renderer_force_max_clock_description">يجبر وحدة معالجة الرسومات على العمل بأقصى سرعة ممكنة (سيظل يتم تطبيق القيود الحرارية).</string>
|
||||
<string name="renderer_asynchronous_gpu_emulation">محاكاة غير متزامنة لوحدة معالجة الرسومات</string>
|
||||
<string name="renderer_asynchronous_gpu_emulation_description">يُشغّل هذا الخيار محاكاة وحدة معالجة الرسومات بشكل غير متزامن لتقليل توقف وحدة المعالجة المركزية وتحسين الإنتاجية. عطّل هذا الخيار فقط في حال واجهت مشاكل متعلقة بالتوقيت.</string>
|
||||
<string name="renderer_async_presentation">عرض غير متزامن</string>
|
||||
<string name="renderer_async_presentation_description">يحسّن الأداء بشكل طفيف عن طريق نقل عملية العرض إلى خيط معالجة منفصل لوحدة المعالجة المركزية.</string>
|
||||
<string name="renderer_reactive_flushing">استخدم التنظيف التفاعلي</string>
|
||||
<string name="renderer_reactive_flushing_description">يحسن دقة العرض في بعض الألعاب على حساب الأداء.</string>
|
||||
<string name="enable_buffer_history">تمكين سجل التخزين المؤقت</string>
|
||||
@@ -682,8 +686,8 @@
|
||||
<string name="import_success">تم الاستيراد بنجاح</string>
|
||||
<string name="export_success">تم التصدير بنجاح</string>
|
||||
<string name="start">بدء</string>
|
||||
<string name="global">المتغيرات العامة</string>
|
||||
<string name="custom">مخصص</string>
|
||||
<string name="global">الإعدادات العامة</string>
|
||||
<string name="custom">الإعدادات المخصصة للعبة</string>
|
||||
<string name="import_complete">اكتمل الاستيراد</string>
|
||||
<string name="use_global_setting">استخدام الإعداد العام</string>
|
||||
<string name="operation_completed_successfully">اكتملت العملية بنجاح</string>
|
||||
@@ -762,7 +766,7 @@
|
||||
<string name="info_description">معرف العنوان، المطور، الإصدار</string>
|
||||
<string name="per_game_settings">الإعدادات الخاصة للعبة</string>
|
||||
<string name="per_game_settings_description">تعديل الإعدادات الخاصة بهذه اللعبة</string>
|
||||
<string name="launch_options">تشغيل الإعدادات</string>
|
||||
<string name="launch_options">إعدادات التشغيل</string>
|
||||
<string name="path">المسار</string>
|
||||
<string name="program_id">معرف العنوان</string>
|
||||
<string name="developer">المطور</string>
|
||||
@@ -1122,7 +1126,7 @@
|
||||
<string name="enable_overlay_description">تمكين التطبيق الصغير المدمج في Horizon. اضغط مع الاستمرار على زر الشاشة الرئيسية لمدة 1 ثانية لإظهاره.</string>
|
||||
|
||||
<!-- Profile Management -->
|
||||
<string name="profile_manager">مدير الملف الشخصي</string>
|
||||
<string name="profile_manager">إدارة ملف التعريف</string>
|
||||
<string name="profile_manager_description">إدارة ملفات تعريف المستخدمين</string>
|
||||
<string name="profile_add_user">إضافة مستخدم</string>
|
||||
<string name="profile_new_user">مستخدم جديد</string>
|
||||
|
||||
@@ -351,7 +351,7 @@
|
||||
<item quantity="other">%d archivos de guardado importados con éxito.</item>
|
||||
</plurals>
|
||||
<string name="no_save_data_found">No se encontraron datos de guardado</string>
|
||||
<string name="verify_installed_content">Verificar contenido instalado</string>
|
||||
<string name="verify_installed_content">Verificar los contenidos instalados</string>
|
||||
<string name="verify_installed_content_description">Comprueba todo el contenido instalado por si hubiese alguno corrupto</string>
|
||||
|
||||
<string name="keys_missing">Faltan las claves de encriptación</string>
|
||||
@@ -480,6 +480,10 @@
|
||||
<string name="use_disk_shader_cache_description">Reduce los tirones almacenando y cargando los sombreadores generados.</string>
|
||||
<string name="renderer_force_max_clock">Forzar velocidad al máximo (solo Adreno)</string>
|
||||
<string name="renderer_force_max_clock_description">Fuerza a la GPU a ejecutarse a la velocidad máxima de reloj posible (se seguirán aplicando restricciones térmicas).</string>
|
||||
<string name="renderer_asynchronous_gpu_emulation">Emulación de GPU asíncrona</string>
|
||||
<string name="renderer_asynchronous_gpu_emulation_description">Ejecuta la emulación de la GPU de forma asíncrona para reducir los bloqueos de la CPU y mejorar el rendimiento. Desactiva esta opción solo si experimentas problemas de sincronización.</string>
|
||||
<string name="renderer_async_presentation">Presentación asíncrona</string>
|
||||
<string name="renderer_async_presentation_description">Mejora ligeramente el rendimiento al mover la presentación a un hilo independiente de la CPU.</string>
|
||||
<string name="renderer_reactive_flushing">Usar limpieza reactiva</string>
|
||||
<string name="renderer_reactive_flushing_description">Mejora la precisión de renderizado en algunos juegos, pero reduce el rendimiento.</string>
|
||||
<string name="enable_buffer_history">Activar el historial del búfer</string>
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
<string name="stats_overlay_options_description">配置性能统计叠加层中显示的信息</string>
|
||||
<string name="show_fps">显示帧率</string>
|
||||
<string name="show_fps_description">显示当前帧率</string>
|
||||
<string name="show_frametime">显示帧时间</string>
|
||||
<string name="show_frametime">显示 Frametime</string>
|
||||
<string name="show_app_ram_usage">显示应用内存使用情况</string>
|
||||
<string name="show_app_ram_usage_description">显示模拟器内存用量</string>
|
||||
<string name="show_system_ram_usage">显示系统内存使用情况</string>
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
// 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<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
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <stop_token>
|
||||
#include <thread>
|
||||
|
||||
#include "core/core.h"
|
||||
@@ -18,59 +20,53 @@ namespace Kernel::Svc {
|
||||
constexpr auto MAX_MSG_TIME = std::chrono::milliseconds(250);
|
||||
const auto MAX_MSG_SIZE = 0x1000;
|
||||
|
||||
static std::string msg_buffer;
|
||||
static std::mutex msg_mutex;
|
||||
static std::condition_variable msg_cv;
|
||||
static std::chrono::steady_clock::time_point last_msg_time;
|
||||
static bool worker_running = true;
|
||||
static std::unique_ptr<std::thread> flush_thread;
|
||||
static std::once_flag start_flag;
|
||||
|
||||
static void FlushDbgLoop() {
|
||||
while (true) {
|
||||
std::unique_lock lock(msg_mutex);
|
||||
|
||||
msg_cv.wait(lock, [] { return !msg_buffer.empty() || !worker_running; });
|
||||
if (!worker_running && msg_buffer.empty()) break;
|
||||
|
||||
auto timeout = last_msg_time + MAX_MSG_TIME;
|
||||
bool woke_early = msg_cv.wait_until(lock, timeout, [] {
|
||||
return msg_buffer.size() >= MAX_MSG_SIZE || !worker_running;
|
||||
});
|
||||
|
||||
if (!woke_early || msg_buffer.size() >= MAX_MSG_SIZE || !worker_running) {
|
||||
if (!msg_buffer.empty()) {
|
||||
// Remove trailing newline as LOG_INFO adds that anyways
|
||||
if (msg_buffer.back() == '\n')
|
||||
msg_buffer.pop_back();
|
||||
|
||||
LOG_INFO(Debug_Emulated, "\n{}", msg_buffer);
|
||||
msg_buffer.clear();
|
||||
}
|
||||
if (!worker_running) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Used to output a message on a debug hardware unit - does nothing on a retail unit
|
||||
Result OutputDebugString(Core::System& system, u64 address, u64 len) {
|
||||
static struct DebugFlusher {
|
||||
std::string msg_buffer;
|
||||
std::mutex msg_mutex;
|
||||
std::condition_variable msg_cv;
|
||||
std::chrono::steady_clock::time_point last_msg_time;
|
||||
std::optional<std::jthread> thread;
|
||||
} flusher_data;
|
||||
R_SUCCEED_IF(len == 0);
|
||||
|
||||
// Only start the thread the very first time this function is called
|
||||
std::call_once(start_flag, [] {
|
||||
flush_thread = std::make_unique<std::thread>(FlushDbgLoop);
|
||||
});
|
||||
if (!flusher_data.thread) {
|
||||
flusher_data.thread.emplace([](std::stop_token stop_token) {
|
||||
while (!stop_token.stop_requested()) {
|
||||
std::unique_lock lock(flusher_data.msg_mutex);
|
||||
flusher_data.msg_cv.wait(lock, [&stop_token] {
|
||||
return !flusher_data.msg_buffer.empty() || stop_token.stop_requested();
|
||||
});
|
||||
if (stop_token.stop_requested() && flusher_data.msg_buffer.empty())
|
||||
break;
|
||||
auto timeout = flusher_data.last_msg_time + MAX_MSG_TIME;
|
||||
bool woke_early = flusher_data.msg_cv.wait_until(lock, timeout, [&stop_token] {
|
||||
return flusher_data.msg_buffer.size() >= MAX_MSG_SIZE || stop_token.stop_requested();
|
||||
});
|
||||
if (!woke_early || flusher_data.msg_buffer.size() >= MAX_MSG_SIZE || stop_token.stop_requested()) {
|
||||
if (!flusher_data.msg_buffer.empty()) {
|
||||
// Remove trailing newline as LOG_INFO adds that anyways
|
||||
if (flusher_data.msg_buffer.back() == '\n')
|
||||
flusher_data.msg_buffer.pop_back();
|
||||
|
||||
{
|
||||
std::lock_guard lock(msg_mutex);
|
||||
const auto old_size = msg_buffer.size();
|
||||
msg_buffer.resize(old_size + len);
|
||||
GetCurrentMemory(system.Kernel()).ReadBlock(address, msg_buffer.data() + old_size, len);
|
||||
|
||||
last_msg_time = std::chrono::steady_clock::now();
|
||||
LOG_INFO(Debug_Emulated, "\n{}", flusher_data.msg_buffer);
|
||||
flusher_data.msg_buffer.clear();
|
||||
}
|
||||
if (stop_token.stop_requested()) break;
|
||||
}
|
||||
}
|
||||
flusher_data.msg_cv.notify_all();
|
||||
});
|
||||
}
|
||||
|
||||
msg_cv.notify_one();
|
||||
{
|
||||
std::lock_guard lock(flusher_data.msg_mutex);
|
||||
const auto old_size = flusher_data.msg_buffer.size();
|
||||
flusher_data.msg_buffer.resize(old_size + len);
|
||||
GetCurrentMemory(system.Kernel()).ReadBlock(address, flusher_data.msg_buffer.data() + old_size, len);
|
||||
flusher_data.last_msg_time = std::chrono::steady_clock::now();
|
||||
}
|
||||
flusher_data.msg_cv.notify_one();
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
@@ -82,16 +78,4 @@ Result OutputDebugString64From32(Core::System& system, uint32_t debug_str, uint3
|
||||
R_RETURN(OutputDebugString(system, debug_str, len));
|
||||
}
|
||||
|
||||
struct BufferAutoFlush {
|
||||
~BufferAutoFlush() {
|
||||
{
|
||||
std::lock_guard lock(msg_mutex);
|
||||
worker_running = false;
|
||||
}
|
||||
msg_cv.notify_all();
|
||||
if (flush_thread && flush_thread->joinable()) flush_thread->join();
|
||||
}
|
||||
};
|
||||
static BufferAutoFlush auto_flusher;
|
||||
|
||||
} // namespace Kernel::Svc
|
||||
|
||||
@@ -367,7 +367,6 @@ if (BOOST_NO_HEADERS)
|
||||
else()
|
||||
target_link_libraries(dynarmic PRIVATE Boost::headers)
|
||||
endif()
|
||||
|
||||
if (DYNARMIC_USE_LLVM)
|
||||
target_include_directories(dynarmic PRIVATE ${LLVM_INCLUDE_DIRS})
|
||||
target_compile_definitions(dynarmic PRIVATE DYNARMIC_USE_LLVM=1 ${LLVM_DEFINITIONS})
|
||||
@@ -385,4 +384,7 @@ endif()
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
target_compile_definitions(dynarmic PRIVATE FMT_USE_WINDOWS_H=0)
|
||||
endif()
|
||||
if (NOT DEFINED xbyak_ADDED)
|
||||
target_compile_definitions(dynarmic PRIVATE XBYAK_BUNDLED=1)
|
||||
endif()
|
||||
target_compile_definitions(dynarmic PRIVATE FMT_USE_USER_DEFINED_LITERALS=1)
|
||||
|
||||
@@ -519,10 +519,6 @@ void BlockOfCode::LoadRequiredFlagsForCondFromRax(IR::Cond cond) {
|
||||
}
|
||||
}
|
||||
|
||||
Xbyak::Address BlockOfCode::Const(const Xbyak::AddressFrame& frame, u64 lower, u64 upper) {
|
||||
return constant_pool.GetConstant(frame, lower, upper);
|
||||
}
|
||||
|
||||
CodePtr BlockOfCode::GetCodeBegin() const {
|
||||
return code_begin;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "dynarmic/common/cast_util.h"
|
||||
#include "dynarmic/interface/halt_reason.h"
|
||||
#include "dynarmic/ir/cond.h"
|
||||
#include "xbyak/xbyak.h"
|
||||
|
||||
namespace Dynarmic::Backend::X64 {
|
||||
|
||||
@@ -101,8 +102,8 @@ public:
|
||||
}
|
||||
|
||||
/// Code emitter: Calls the lambda. Lambda must not have any captures.
|
||||
template<typename Lambda>
|
||||
void CallLambda(Lambda l) {
|
||||
template<typename F>
|
||||
void CallLambda(F l) {
|
||||
CallFunction(Common::FptrCast(l));
|
||||
}
|
||||
|
||||
@@ -124,22 +125,35 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
Xbyak::Address Const(const Xbyak::AddressFrame& frame, u64 lower, u64 upper = 0);
|
||||
|
||||
template<size_t esize>
|
||||
Xbyak::Address BConst(const Xbyak::AddressFrame& frame, u64 value) {
|
||||
return Const(frame, mcl::bit::replicate_element<u64>(esize, value),
|
||||
mcl::bit::replicate_element<u64>(esize, value));
|
||||
// Xbyak benefits slightly from not having & references on some of its ctors, however one main
|
||||
// disadvantage is that this breaks ABI slightly because we need to hijack the main privated ctor, hence
|
||||
// we define two paths, one for gentoo (non bundled) and one for our custom bundled set with patch
|
||||
#ifdef XBYAK_BUNDLED
|
||||
[[nodiscard]] Xbyak::Address Const(const Xbyak::AddressFrame frame, u64 lower, u64 upper = 0) {
|
||||
return constant_pool.GetConstant(Xbyak::AddressFrame(frame.bit_, frame.broadcast_), lower, upper);
|
||||
}
|
||||
template<size_t esize>
|
||||
[[nodiscard]] Xbyak::Address BConst(const Xbyak::AddressFrame frame, u64 value) {
|
||||
return Const(Xbyak::AddressFrame(frame.bit_, frame.broadcast_), mcl::bit::replicate_element<u64>(esize, value), mcl::bit::replicate_element<u64>(esize, value));
|
||||
}
|
||||
#else
|
||||
[[nodiscard]] Xbyak::Address Const(const Xbyak::AddressFrame& frame, u64 lower, u64 upper = 0) {
|
||||
return constant_pool.GetConstant(frame, lower, upper);
|
||||
}
|
||||
template<size_t esize>
|
||||
[[nodiscard]] Xbyak::Address BConst(const Xbyak::AddressFrame& frame, u64 value) {
|
||||
return Const(frame, mcl::bit::replicate_element<u64>(esize, value), mcl::bit::replicate_element<u64>(esize, value));
|
||||
}
|
||||
#endif
|
||||
|
||||
CodePtr GetCodeBegin() const;
|
||||
size_t GetTotalCodeSize() const;
|
||||
|
||||
const void* GetReturnFromRunCodeAddress() const {
|
||||
[[nodiscard]] const void* GetReturnFromRunCodeAddress() const {
|
||||
return return_from_run_code[0];
|
||||
}
|
||||
|
||||
const void* GetForceReturnFromRunCodeAddress() const {
|
||||
[[nodiscard]] const void* GetForceReturnFromRunCodeAddress() const {
|
||||
return return_from_run_code[FORCE_RETURN];
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,11 @@ ConstantPool::ConstantPool(BlockOfCode& code, size_t size)
|
||||
reinterpret_cast<ConstantT*>(code.AllocateFromCodeSpace(size)), size / align_size);
|
||||
}
|
||||
|
||||
#ifdef XBYAK_BUNDLED
|
||||
Xbyak::Address ConstantPool::GetConstant(const Xbyak::AddressFrame frame, u64 lower, u64 upper) {
|
||||
#else
|
||||
Xbyak::Address ConstantPool::GetConstant(const Xbyak::AddressFrame& frame, u64 lower, u64 upper) {
|
||||
#endif
|
||||
const auto constant = ConstantT(lower, upper);
|
||||
auto iter = constant_info.find(constant);
|
||||
if (iter == constant_info.end()) {
|
||||
|
||||
@@ -29,7 +29,11 @@ class ConstantPool final {
|
||||
public:
|
||||
ConstantPool(BlockOfCode& code, size_t size);
|
||||
|
||||
#ifdef XBYAK_BUNDLED
|
||||
Xbyak::Address GetConstant(const Xbyak::AddressFrame frame, u64 lower, u64 upper = 0);
|
||||
#else
|
||||
Xbyak::Address GetConstant(const Xbyak::AddressFrame& frame, u64 lower, u64 upper = 0);
|
||||
#endif
|
||||
|
||||
private:
|
||||
static constexpr size_t align_size = 16; // bytes
|
||||
|
||||
@@ -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
|
||||
|
||||
/* This file is part of the dynarmic project.
|
||||
@@ -595,7 +595,8 @@ void EmitX64::EmitPackedHalvingSubAddS16(EmitContext& ctx, IR::Inst* inst) {
|
||||
EmitPackedSubAdd(code, ctx, inst, false, true, true);
|
||||
}
|
||||
|
||||
static void EmitPackedOperation(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst, void (Xbyak::CodeGenerator::*fn)(const Xbyak::Mmx& mmx, const Xbyak::Operand&)) {
|
||||
template<typename F>
|
||||
static void EmitPackedOperation(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst, F&& fn) {
|
||||
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
|
||||
|
||||
const Xbyak::Xmm xmm_a = ctx.reg_alloc.UseScratchXmm(code, args[0]);
|
||||
|
||||
@@ -23,7 +23,8 @@ using namespace Xbyak::util;
|
||||
|
||||
namespace {
|
||||
|
||||
void EmitVectorSaturatedNative(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst, void (Xbyak::CodeGenerator::*saturated_fn)(const Xbyak::Mmx& mmx, const Xbyak::Operand&), void (Xbyak::CodeGenerator::*unsaturated_fn)(const Xbyak::Mmx& mmx, const Xbyak::Operand&), void (Xbyak::CodeGenerator::*sub_fn)(const Xbyak::Mmx& mmx, const Xbyak::Operand&)) {
|
||||
template<typename F1, typename F2, typename F3>
|
||||
static void EmitVectorSaturatedNative(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst, F1&& saturated_fn, F2&& unsaturated_fn, F3&& sub_fn) {
|
||||
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
|
||||
|
||||
const Xbyak::Xmm result = ctx.reg_alloc.UseScratchXmm(code, args[0]);
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <bitset>
|
||||
#include <xbyak/xbyak.h>
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/common_types.h"
|
||||
#include "dynarmic/backend/x64/xbyak.h"
|
||||
|
||||
@@ -169,6 +169,8 @@ std::unique_ptr<TranslationMap> InitializeTranslations(QObject* parent) {
|
||||
tr("Runs an additional optimization pass over generated SPIRV shaders.\n"
|
||||
"Will increase time required for shader compilation.\nMay slightly improve "
|
||||
"performance.\nThis feature is experimental."));
|
||||
INSERT(Settings, use_asynchronous_gpu_emulation, tr("Use asynchronous GPU emulation"),
|
||||
tr("Uses an extra CPU thread for rendering.\nThis option should always remain enabled."));
|
||||
INSERT(Settings, nvdec_emulation, tr("NVDEC emulation:"),
|
||||
tr("Specifies how videos should be decoded.\nIt can either use the CPU or the GPU for "
|
||||
"decoding, or perform no decoding at all (black screen on videos).\n"
|
||||
|
||||
@@ -109,12 +109,12 @@ public:
|
||||
return static_cast<u32>(other_cpu_addr - cpu_addr);
|
||||
}
|
||||
|
||||
u64 GetFrameTick() const noexcept {
|
||||
return frame_tick;
|
||||
size_t getLRUID() const noexcept {
|
||||
return lru_id;
|
||||
}
|
||||
|
||||
void SetFrameTick(u64 tick) noexcept {
|
||||
frame_tick = tick;
|
||||
void setLRUID(size_t lru_id_) {
|
||||
lru_id = lru_id_;
|
||||
}
|
||||
|
||||
size_t SizeBytes() const {
|
||||
@@ -125,7 +125,7 @@ private:
|
||||
VAddr cpu_addr = 0;
|
||||
BufferFlagBits flags{};
|
||||
int stream_score = 0;
|
||||
u64 frame_tick = 0;
|
||||
size_t lru_id = SIZE_MAX;
|
||||
size_t size_bytes = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -58,22 +58,17 @@ 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 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) {
|
||||
const auto clean_up = [this, &num_iterations](BufferId buffer_id) {
|
||||
if (num_iterations == 0) {
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
--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>
|
||||
@@ -1600,9 +1595,10 @@ void BufferCache<P>::ChangeRegister(BufferId buffer_id) {
|
||||
const auto size = buffer.SizeBytes();
|
||||
if (insert) {
|
||||
total_used_memory += Common::AlignUp(size, 1024);
|
||||
buffer.SetFrameTick(frame_tick);
|
||||
buffer.setLRUID(lru_cache.Insert(buffer_id, 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;
|
||||
@@ -1620,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) {
|
||||
buffer.SetFrameTick(frame_tick);
|
||||
lru_cache.Touch(buffer.getLRUID(), frame_tick);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#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"
|
||||
@@ -505,6 +506,11 @@ 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;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||
@@ -122,35 +122,7 @@ void DmaPusher::ProcessCommands(std::span<const CommandHeader> commands) {
|
||||
dma_state.is_last_call = true;
|
||||
index += max_write;
|
||||
} else if (dma_state.method_count) {
|
||||
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];
|
||||
auto const command_header = commands[index]; //can copy
|
||||
dma_state.dma_word_offset = u32(index * sizeof(u32));
|
||||
dma_state.is_last_call = dma_state.method_count <= 1;
|
||||
CallMethod(command_header.argument);
|
||||
@@ -209,11 +181,7 @@ void DmaPusher::CallMethod(u32 argument) const {
|
||||
});
|
||||
} else {
|
||||
auto subchannel = subchannels[dma_state.subchannel];
|
||||
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) {
|
||||
if (!subchannel->execution_mask[dma_state.method]) {
|
||||
subchannel->method_sink.emplace_back(dma_state.method, argument);
|
||||
} else {
|
||||
subchannel->ConsumeSink();
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
|
||||
#include <boost/container/small_vector.hpp>
|
||||
#include <bitset>
|
||||
#include <limits>
|
||||
#include <vector>
|
||||
|
||||
#include "common/common_types.h"
|
||||
|
||||
@@ -41,11 +41,8 @@ public:
|
||||
ConsumeSinkImpl();
|
||||
}
|
||||
|
||||
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{};
|
||||
std::bitset<(std::numeric_limits<u16>::max)()> execution_mask{};
|
||||
std::vector<std::pair<u32, u32>> method_sink{};
|
||||
bool current_dirty{};
|
||||
GPUVAddr current_dma_segment;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ Fermi2D::Fermi2D(MemoryManager& memory_manager_) : memory_manager{memory_manager
|
||||
regs.src.depth = 1;
|
||||
regs.dst.depth = 1;
|
||||
|
||||
execution_mask.fill(0);
|
||||
execution_mask.reset();
|
||||
execution_mask[FERMI2D_REG_INDEX(pixels_from_memory.src_y0) + 1] = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Tegra::Engines {
|
||||
|
||||
KeplerCompute::KeplerCompute(Core::System& system_, MemoryManager& memory_manager_)
|
||||
: system{system_}, memory_manager{memory_manager_}, upload_state{memory_manager, regs.upload} {
|
||||
execution_mask.fill(0);
|
||||
execution_mask.reset();
|
||||
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;
|
||||
|
||||
@@ -22,7 +22,7 @@ KeplerMemory::~KeplerMemory() = default;
|
||||
void KeplerMemory::BindRasterizer(VideoCore::RasterizerInterface* rasterizer_) {
|
||||
upload_state.BindRasterizer(rasterizer_);
|
||||
|
||||
execution_mask.fill(0);
|
||||
execution_mask.reset();
|
||||
execution_mask[KEPLERMEMORY_REG_INDEX(exec)] = true;
|
||||
execution_mask[KEPLERMEMORY_REG_INDEX(data)] = true;
|
||||
}
|
||||
|
||||
@@ -4,10 +4,8 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <optional>
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/bit_util.h"
|
||||
#include "common/scope_exit.h"
|
||||
@@ -39,10 +37,9 @@ Maxwell3D::Maxwell3D(Core::System& system_, MemoryManager& memory_manager_)
|
||||
{
|
||||
dirty.flags.flip();
|
||||
InitializeRegisterDefaults();
|
||||
execution_mask.fill(0);
|
||||
for (size_t i = 0; i < EXECUTION_MASK_TABLE_SIZE; i++)
|
||||
execution_mask.reset();
|
||||
for (size_t i = 0; i < execution_mask.size(); i++)
|
||||
execution_mask[i] = IsMethodExecutable(u32(i));
|
||||
execution_mask_default = true;
|
||||
}
|
||||
|
||||
Maxwell3D::~Maxwell3D() = default;
|
||||
@@ -301,27 +298,18 @@ u32 Maxwell3D::ProcessShadowRam(u32 method, u32 argument) {
|
||||
}
|
||||
|
||||
void Maxwell3D::ConsumeSinkImpl() {
|
||||
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 (size_t i = 0; i < sink_size; ++i) {
|
||||
const auto [method, value] = method_sink[i];
|
||||
for (auto [method, value] : method_sink) {
|
||||
shadow_state.reg_array[method] = value;
|
||||
ProcessDirtyRegisters(method, value);
|
||||
}
|
||||
} else if (control == Regs::ShadowRamControl::Replay) {
|
||||
for (size_t i = 0; i < sink_size; ++i) {
|
||||
const auto [method, value] = method_sink[i];
|
||||
for (auto [method, value] : method_sink)
|
||||
ProcessDirtyRegisters(method, shadow_state.reg_array[method]);
|
||||
}
|
||||
} else {
|
||||
for (size_t i = 0; i < sink_size; ++i) {
|
||||
const auto [method, value] = method_sink[i];
|
||||
for (auto [method, value] : method_sink)
|
||||
ProcessDirtyRegisters(method, value);
|
||||
}
|
||||
}
|
||||
method_sink.clear();
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace Texture;
|
||||
|
||||
MaxwellDMA::MaxwellDMA(Core::System& system_, MemoryManager& memory_manager_)
|
||||
: system{system_}, memory_manager{memory_manager_} {
|
||||
execution_mask.fill(0);
|
||||
execution_mask.reset();
|
||||
execution_mask[offsetof(Regs, launch_dma) / sizeof(u32)] = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,8 +65,10 @@ static VkPresentModeKHR ChooseSwapPresentMode(bool has_imm, bool has_mailbox,
|
||||
return mode;
|
||||
}
|
||||
}();
|
||||
if (setting == Settings::VSyncMode::Immediate && !has_imm) {
|
||||
setting = Settings::VSyncMode::Mailbox;
|
||||
}
|
||||
if ((setting == Settings::VSyncMode::Mailbox && !has_mailbox) ||
|
||||
(setting == Settings::VSyncMode::Immediate && !has_imm) ||
|
||||
(setting == Settings::VSyncMode::FifoRelaxed && !has_fifo_relaxed)) {
|
||||
setting = Settings::VSyncMode::Fifo;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
// 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
|
||||
|
||||
@@ -105,7 +102,7 @@ struct ImageBase {
|
||||
VAddr cpu_addr_end = 0;
|
||||
|
||||
u64 modification_tick = 0;
|
||||
u64 last_use_tick = 0;
|
||||
size_t lru_index = SIZE_MAX;
|
||||
|
||||
std::array<u32, MAX_MIP_LEVELS> mip_level_offsets{};
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <optional>
|
||||
#include <bit>
|
||||
@@ -71,10 +70,14 @@ TextureCache<P>::TextureCache(Runtime& runtime_, Tegra::MaxwellDeviceMemoryManag
|
||||
(std::max)((std::min)(device_local_memory - min_vacancy_critical, min_spacing_critical),
|
||||
DEFAULT_CRITICAL_MEMORY));
|
||||
minimum_memory = static_cast<u64>((device_local_memory - mem_threshold) / 2);
|
||||
|
||||
lowmemorydevice = false;
|
||||
} else {
|
||||
expected_memory = DEFAULT_EXPECTED_MEMORY + 512_MiB;
|
||||
critical_memory = DEFAULT_CRITICAL_MEMORY + 1_GiB;
|
||||
minimum_memory = 0;
|
||||
|
||||
lowmemorydevice = true;
|
||||
}
|
||||
|
||||
const bool gpu_unswizzle_enabled = Settings::values.gpu_unswizzle_enabled.GetValue();
|
||||
@@ -113,67 +116,26 @@ TextureCache<P>::TextureCache(Runtime& runtime_, Tegra::MaxwellDeviceMemoryManag
|
||||
}
|
||||
}
|
||||
|
||||
template <class P>
|
||||
void TextureCache<P>::RunAllocationGarbageCollector(size_t requested_bytes) {
|
||||
if (requested_bytes == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (allocation_gc_frame != frame_tick) {
|
||||
allocation_gc_frame = frame_tick;
|
||||
allocation_gc_passes = 0;
|
||||
}
|
||||
if (allocation_gc_passes >= MAX_ALLOCATION_GC_PASSES_PER_FRAME) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (runtime.CanReportMemoryUsage()) {
|
||||
total_used_memory = runtime.GetDeviceMemoryUsage();
|
||||
}
|
||||
|
||||
const u64 request = static_cast<u64>(requested_bytes);
|
||||
const u64 max_u64 = (std::numeric_limits<u64>::max)();
|
||||
const u64 projected_usage = request > (max_u64 - total_used_memory)
|
||||
? max_u64
|
||||
: total_used_memory + request;
|
||||
if (projected_usage < expected_memory) {
|
||||
return;
|
||||
}
|
||||
|
||||
RunGarbageCollector();
|
||||
++allocation_gc_passes;
|
||||
|
||||
if (runtime.CanReportMemoryUsage()) {
|
||||
total_used_memory = runtime.GetDeviceMemoryUsage();
|
||||
}
|
||||
|
||||
const u64 projected_after_gc = request > (max_u64 - total_used_memory)
|
||||
? max_u64
|
||||
: total_used_memory + request;
|
||||
if (projected_after_gc >= critical_memory &&
|
||||
allocation_gc_passes < MAX_ALLOCATION_GC_PASSES_PER_FRAME) {
|
||||
RunGarbageCollector();
|
||||
++allocation_gc_passes;
|
||||
|
||||
if (runtime.CanReportMemoryUsage()) {
|
||||
total_used_memory = runtime.GetDeviceMemoryUsage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class P>
|
||||
void TextureCache<P>::RunGarbageCollector() {
|
||||
bool high_priority_mode = total_used_memory >= expected_memory;
|
||||
bool high_priority_mode = false;
|
||||
bool aggressive_mode = false;
|
||||
u64 ticks_to_destroy = high_priority_mode ? 25ULL : 50ULL;
|
||||
size_t num_iterations = high_priority_mode ? 20 : 10;
|
||||
u64 ticks_to_destroy = 0;
|
||||
size_t num_iterations = 0;
|
||||
|
||||
const auto Configure = [&](bool allow_aggressive) {
|
||||
high_priority_mode = total_used_memory >= expected_memory;
|
||||
aggressive_mode = allow_aggressive && total_used_memory >= critical_memory;
|
||||
ticks_to_destroy = aggressive_mode ? 10ULL : high_priority_mode ? 25ULL : 50ULL;
|
||||
num_iterations = aggressive_mode ? 40 : (high_priority_mode ? 20 : 10);
|
||||
};
|
||||
|
||||
const auto Cleanup = [this, &num_iterations, &high_priority_mode,
|
||||
&aggressive_mode](ImageId image_id) {
|
||||
if (num_iterations == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
--num_iterations;
|
||||
auto& image = slot_images[image_id];
|
||||
|
||||
// Never delete recently allocated sparse textures (within 3 frames)
|
||||
@@ -183,22 +145,28 @@ void TextureCache<P>::RunGarbageCollector() {
|
||||
}
|
||||
|
||||
if (True(image.flags & ImageFlagBits::IsDecoding)) {
|
||||
// This image is still being decoded, deleting it will invalidate the slot
|
||||
// used by the async decoder thread.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!aggressive_mode && True(image.flags & ImageFlagBits::CostlyLoad)) {
|
||||
// Prioritize large sparse textures for cleanup
|
||||
const bool is_large_sparse = lowmemorydevice &&
|
||||
image.info.is_sparse &&
|
||||
image.guest_size_bytes >= 256_MiB;
|
||||
|
||||
if (!aggressive_mode && !is_large_sparse &&
|
||||
True(image.flags & ImageFlagBits::CostlyLoad)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const bool must_download =
|
||||
image.IsSafeDownload() && False(image.flags & ImageFlagBits::BadOverlap);
|
||||
if (!high_priority_mode && must_download) {
|
||||
if (!high_priority_mode && !is_large_sparse && must_download) {
|
||||
return false;
|
||||
}
|
||||
|
||||
--num_iterations;
|
||||
|
||||
if (must_download) {
|
||||
if (must_download && !is_large_sparse) {
|
||||
auto map = runtime.DownloadStagingBuffer(image.unswizzled_size_bytes);
|
||||
const auto copies = FixSmallVectorADL(FullDownloadCopies(image.info));
|
||||
image.DownloadMemory(map, copies);
|
||||
@@ -215,6 +183,7 @@ void TextureCache<P>::RunGarbageCollector() {
|
||||
|
||||
if (total_used_memory < critical_memory) {
|
||||
if (aggressive_mode) {
|
||||
// Sink the aggresiveness.
|
||||
num_iterations >>= 2;
|
||||
aggressive_mode = false;
|
||||
return false;
|
||||
@@ -227,49 +196,31 @@ void TextureCache<P>::RunGarbageCollector() {
|
||||
return false;
|
||||
};
|
||||
|
||||
const auto SortByAge = [this](auto& vec) {
|
||||
std::sort(vec.begin(), vec.end(), [this](ImageId a, ImageId b) {
|
||||
return slot_images[a].last_use_tick < slot_images[b].last_use_tick;
|
||||
});
|
||||
};
|
||||
|
||||
// Single pass: collect all candidates, classified by tier
|
||||
const u64 normal_threshold = frame_tick > ticks_to_destroy ? frame_tick - ticks_to_destroy : 0;
|
||||
const u64 aggressive_threshold = frame_tick > 10 ? frame_tick - 10 : 0;
|
||||
boost::container::small_vector<ImageId, 64> expired;
|
||||
boost::container::small_vector<ImageId, 64> aggressive_expired;
|
||||
|
||||
for (auto [id, image] : slot_images) {
|
||||
if (False(image->flags & ImageFlagBits::Registered)) {
|
||||
continue;
|
||||
}
|
||||
const u64 tick = image->last_use_tick;
|
||||
if (tick < normal_threshold) {
|
||||
expired.push_back(id);
|
||||
} else if (tick < aggressive_threshold) {
|
||||
aggressive_expired.push_back(id);
|
||||
}
|
||||
}
|
||||
|
||||
SortByAge(expired);
|
||||
SortByAge(aggressive_expired);
|
||||
|
||||
// Tier 1: normal expiration
|
||||
for (const auto image_id : expired) {
|
||||
if (Cleanup(image_id)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Tier 2: if still critical, use aggressive threshold with more iterations
|
||||
if (total_used_memory >= critical_memory) {
|
||||
aggressive_mode = true;
|
||||
num_iterations = 40;
|
||||
for (const auto image_id : aggressive_expired) {
|
||||
if (Cleanup(image_id)) {
|
||||
break;
|
||||
// Aggressively clear massive sparse textures
|
||||
if (total_used_memory >= expected_memory) {
|
||||
lru_cache.ForEachItemBelow(frame_tick, [&](ImageId image_id) {
|
||||
auto& image = slot_images[image_id];
|
||||
// Only target sparse textures that are old enough
|
||||
if (lowmemorydevice &&
|
||||
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);
|
||||
return Cleanup(image_id);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
Configure(false);
|
||||
lru_cache.ForEachItemBelow(frame_tick - ticks_to_destroy, Cleanup);
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1245,6 +1196,9 @@ void TextureCache<P>::RefreshContents(Image& image, ImageId image_id) {
|
||||
}
|
||||
|
||||
image.flags &= ~ImageFlagBits::CpuModified;
|
||||
if( lowmemorydevice && image.info.format == PixelFormat::BC1_RGBA_UNORM && MapSizeBytes(image) >= 256_MiB ) {
|
||||
return;
|
||||
}
|
||||
|
||||
TrackImage(image, image_id);
|
||||
|
||||
@@ -1654,19 +1608,49 @@ bool TextureCache<P>::ScaleDown(Image& image) {
|
||||
template <class P>
|
||||
ImageId TextureCache<P>::InsertImage(const ImageInfo& info, GPUVAddr gpu_addr,
|
||||
RelaxedOptions options) {
|
||||
const size_t requested_size = CalculateGuestSizeInBytes(info);
|
||||
std::optional<DAddr> cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr);
|
||||
if (!cpu_addr) {
|
||||
cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr, requested_size);
|
||||
const auto size = CalculateGuestSizeInBytes(info);
|
||||
cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr, size);
|
||||
if (!cpu_addr) {
|
||||
const DAddr fake_addr = ~(1ULL << 40ULL) + virtual_invalid_space;
|
||||
virtual_invalid_space += Common::AlignUp(requested_size, 32);
|
||||
virtual_invalid_space += Common::AlignUp(size, 32);
|
||||
cpu_addr = std::optional<DAddr>(fake_addr);
|
||||
}
|
||||
}
|
||||
ASSERT_MSG(cpu_addr, "Tried to insert an image to an invalid gpu_addr=0x{:x}", gpu_addr);
|
||||
|
||||
RunAllocationGarbageCollector(requested_size);
|
||||
// For large sparse textures, aggressively clean up old allocations at same address
|
||||
if (lowmemorydevice && info.is_sparse && CalculateGuestSizeInBytes(info) >= 256_MiB) {
|
||||
const auto alloc_it = image_allocs_table.find(gpu_addr);
|
||||
if (alloc_it != image_allocs_table.end()) {
|
||||
const ImageAllocId alloc_id = alloc_it->second;
|
||||
auto& alloc_images = slot_image_allocs[alloc_id].images;
|
||||
|
||||
// Collect old images at this address that were created more than 2 frames ago
|
||||
boost::container::small_vector<ImageId, 4> to_delete;
|
||||
for (ImageId old_image_id : alloc_images) {
|
||||
Image& old_image = slot_images[old_image_id];
|
||||
if (old_image.info.is_sparse &&
|
||||
old_image.gpu_addr == gpu_addr &&
|
||||
old_image.allocation_tick < frame_tick - 2) { // Try not to delete fresh textures
|
||||
to_delete.push_back(old_image_id);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete old images immediately
|
||||
for (ImageId old_id : to_delete) {
|
||||
Image& old_image = slot_images[old_id];
|
||||
LOG_DEBUG(HW_GPU, "Immediately deleting old sparse texture at 0x{:X} ({} MiB)",
|
||||
gpu_addr, old_image.guest_size_bytes / (1024 * 1024));
|
||||
if (True(old_image.flags & ImageFlagBits::Tracked)) {
|
||||
UntrackImage(old_image, old_id);
|
||||
}
|
||||
UnregisterImage(old_id);
|
||||
DeleteImage(old_id, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const ImageId image_id = JoinImages(info, gpu_addr, *cpu_addr);
|
||||
const Image& image = slot_images[image_id];
|
||||
@@ -1684,7 +1668,25 @@ ImageId TextureCache<P>::JoinImages(const ImageInfo& info, GPUVAddr gpu_addr, DA
|
||||
ImageInfo new_info = info;
|
||||
const size_t size_bytes = CalculateGuestSizeInBytes(new_info);
|
||||
|
||||
RunAllocationGarbageCollector(size_bytes);
|
||||
// Proactive cleanup for large sparse texture allocations
|
||||
if (lowmemorydevice && new_info.is_sparse && size_bytes >= 256_MiB) {
|
||||
const u64 estimated_alloc_size = size_bytes;
|
||||
|
||||
if (total_used_memory + estimated_alloc_size >= critical_memory) {
|
||||
LOG_DEBUG(HW_GPU, "Large sparse texture allocation ({} MiB) - running aggressive GC. "
|
||||
"Current memory: {} MiB, Critical: {} MiB",
|
||||
size_bytes / (1024 * 1024),
|
||||
total_used_memory / (1024 * 1024),
|
||||
critical_memory / (1024 * 1024));
|
||||
RunGarbageCollector();
|
||||
|
||||
// If still over threshold after GC, try one more aggressive pass
|
||||
if (total_used_memory + estimated_alloc_size >= critical_memory) {
|
||||
LOG_DEBUG(HW_GPU, "Still critically low on memory, running second GC pass");
|
||||
RunGarbageCollector();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const bool broken_views = runtime.HasBrokenTextureViewFormats();
|
||||
const bool native_bgr = runtime.HasNativeBgr();
|
||||
@@ -2025,8 +2027,8 @@ std::pair<u32, u32> TextureCache<P>::PrepareDmaImage(ImageId dst_id, GPUVAddr ba
|
||||
const auto& image = slot_images[dst_id];
|
||||
const auto base = image.TryFindBase(base_addr);
|
||||
PrepareImage(dst_id, mark_as_modified, false);
|
||||
auto& new_image = slot_images[dst_id];
|
||||
new_image.last_use_tick = frame_tick;
|
||||
const auto& new_image = slot_images[dst_id];
|
||||
lru_cache.Touch(new_image.lru_index, frame_tick);
|
||||
return std::make_pair(base->level, base->layer);
|
||||
}
|
||||
|
||||
@@ -2375,7 +2377,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.last_use_tick = frame_tick;
|
||||
image.lru_index = lru_cache.Insert(image_id, 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);
|
||||
@@ -2409,7 +2411,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);
|
||||
@@ -2738,7 +2740,7 @@ void TextureCache<P>::PrepareImage(ImageId image_id, bool is_modification, bool
|
||||
if (is_modification) {
|
||||
MarkModification(image);
|
||||
}
|
||||
image.last_use_tick = frame_tick;
|
||||
lru_cache.Touch(image.lru_index, frame_tick);
|
||||
}
|
||||
|
||||
template <class P>
|
||||
|
||||
@@ -22,7 +22,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"
|
||||
@@ -120,7 +120,7 @@ class TextureCache : public VideoCommon::ChannelSetupCaches<TextureCacheChannelI
|
||||
|
||||
static constexpr s64 DEFAULT_EXPECTED_MEMORY = 1_GiB + 125_MiB;
|
||||
static constexpr s64 DEFAULT_CRITICAL_MEMORY = 1_GiB + 625_MiB;
|
||||
static constexpr u32 MAX_ALLOCATION_GC_PASSES_PER_FRAME = 2;
|
||||
static constexpr size_t GC_EMERGENCY_COUNTS = 2;
|
||||
|
||||
using Runtime = typename P::Runtime;
|
||||
using Image = typename P::Image;
|
||||
@@ -310,8 +310,6 @@ private:
|
||||
/// Runs the Garbage Collector.
|
||||
void RunGarbageCollector();
|
||||
|
||||
void RunAllocationGarbageCollector(size_t requested_bytes);
|
||||
|
||||
/// Fills image_view_ids in the image views in indices
|
||||
template <bool has_blacklists>
|
||||
void FillImageViews(DescriptorTable<TICEntry>& table,
|
||||
@@ -480,6 +478,7 @@ private:
|
||||
u64 minimum_memory;
|
||||
u64 expected_memory;
|
||||
u64 critical_memory;
|
||||
bool lowmemorydevice = false;
|
||||
size_t gpu_unswizzle_maxsize = 0;
|
||||
size_t swizzle_chunk_size = 0;
|
||||
u32 swizzle_slices_per_batch = 0;
|
||||
@@ -511,7 +510,11 @@ 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;
|
||||
@@ -529,8 +532,6 @@ private:
|
||||
|
||||
u64 modification_tick = 0;
|
||||
u64 frame_tick = 0;
|
||||
u64 allocation_gc_frame = (std::numeric_limits<u64>::max)();
|
||||
u32 allocation_gc_passes = 0;
|
||||
u64 last_sampler_gc_frame = (std::numeric_limits<u64>::max)();
|
||||
|
||||
Common::ThreadWorker texture_decode_worker{1, "TextureDecoder"};
|
||||
|
||||
Reference in New Issue
Block a user