mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-04-10 03:18:55 +02:00
Compare commits
12 commits
53060c9a91
...
6843971104
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6843971104 | ||
|
|
2ec925d670 | ||
|
|
4c0916915f | ||
|
|
d646a57f75 | ||
|
|
e343ee9524 | ||
|
|
18ad42f996 | ||
|
|
cc553379d8 | ||
|
|
df113ea18b | ||
|
|
1d844296f4 | ||
|
|
fb53c236b2 | ||
|
|
6fa854001d | ||
|
|
ee124f3284 |
14 changed files with 199 additions and 293 deletions
|
|
@ -1,139 +0,0 @@
|
||||||
// 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
|
|
||||||
|
|
@ -109,12 +109,12 @@ public:
|
||||||
return static_cast<u32>(other_cpu_addr - cpu_addr);
|
return static_cast<u32>(other_cpu_addr - cpu_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t getLRUID() const noexcept {
|
u64 GetFrameTick() const noexcept {
|
||||||
return lru_id;
|
return frame_tick;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLRUID(size_t lru_id_) {
|
void SetFrameTick(u64 tick) noexcept {
|
||||||
lru_id = lru_id_;
|
frame_tick = tick;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SizeBytes() const {
|
size_t SizeBytes() const {
|
||||||
|
|
@ -125,7 +125,7 @@ private:
|
||||||
VAddr cpu_addr = 0;
|
VAddr cpu_addr = 0;
|
||||||
BufferFlagBits flags{};
|
BufferFlagBits flags{};
|
||||||
int stream_score = 0;
|
int stream_score = 0;
|
||||||
size_t lru_id = SIZE_MAX;
|
u64 frame_tick = 0;
|
||||||
size_t size_bytes = 0;
|
size_t size_bytes = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,17 +58,22 @@ void BufferCache<P>::RunGarbageCollector() {
|
||||||
const bool aggressive_gc = total_used_memory >= critical_memory;
|
const bool aggressive_gc = total_used_memory >= critical_memory;
|
||||||
const u64 ticks_to_destroy = aggressive_gc ? 60 : 120;
|
const u64 ticks_to_destroy = aggressive_gc ? 60 : 120;
|
||||||
int num_iterations = aggressive_gc ? 64 : 32;
|
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) {
|
if (num_iterations == 0) {
|
||||||
return true;
|
break;
|
||||||
}
|
}
|
||||||
--num_iterations;
|
--num_iterations;
|
||||||
auto& buffer = slot_buffers[buffer_id];
|
auto& buffer = slot_buffers[buffer_id];
|
||||||
DownloadBufferMemory(buffer);
|
DownloadBufferMemory(buffer);
|
||||||
DeleteBuffer(buffer_id);
|
DeleteBuffer(buffer_id);
|
||||||
return false;
|
}
|
||||||
};
|
|
||||||
lru_cache.ForEachItemBelow(frame_tick - ticks_to_destroy, clean_up);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
|
|
@ -1595,10 +1600,9 @@ void BufferCache<P>::ChangeRegister(BufferId buffer_id) {
|
||||||
const auto size = buffer.SizeBytes();
|
const auto size = buffer.SizeBytes();
|
||||||
if (insert) {
|
if (insert) {
|
||||||
total_used_memory += Common::AlignUp(size, 1024);
|
total_used_memory += Common::AlignUp(size, 1024);
|
||||||
buffer.setLRUID(lru_cache.Insert(buffer_id, frame_tick));
|
buffer.SetFrameTick(frame_tick);
|
||||||
} else {
|
} else {
|
||||||
total_used_memory -= Common::AlignUp(size, 1024);
|
total_used_memory -= Common::AlignUp(size, 1024);
|
||||||
lru_cache.Free(buffer.getLRUID());
|
|
||||||
}
|
}
|
||||||
const DAddr device_addr_begin = buffer.CpuAddr();
|
const DAddr device_addr_begin = buffer.CpuAddr();
|
||||||
const DAddr device_addr_end = device_addr_begin + size;
|
const DAddr device_addr_end = device_addr_begin + size;
|
||||||
|
|
@ -1616,7 +1620,7 @@ void BufferCache<P>::ChangeRegister(BufferId buffer_id) {
|
||||||
template <class P>
|
template <class P>
|
||||||
void BufferCache<P>::TouchBuffer(Buffer& buffer, BufferId buffer_id) noexcept {
|
void BufferCache<P>::TouchBuffer(Buffer& buffer, BufferId buffer_id) noexcept {
|
||||||
if (buffer_id != NULL_BUFFER_ID) {
|
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/common_types.h"
|
||||||
#include "common/div_ceil.h"
|
#include "common/div_ceil.h"
|
||||||
#include "common/literals.h"
|
#include "common/literals.h"
|
||||||
#include "common/lru_cache.h"
|
|
||||||
#include "common/range_sets.h"
|
#include "common/range_sets.h"
|
||||||
#include "common/scope_exit.h"
|
#include "common/scope_exit.h"
|
||||||
#include "common/settings.h"
|
#include "common/settings.h"
|
||||||
|
|
@ -506,11 +505,6 @@ private:
|
||||||
size_t immediate_buffer_capacity = 0;
|
size_t immediate_buffer_capacity = 0;
|
||||||
Common::ScratchBuffer<u8> immediate_buffer_alloc;
|
Common::ScratchBuffer<u8> immediate_buffer_alloc;
|
||||||
|
|
||||||
struct LRUItemParams {
|
|
||||||
using ObjectType = BufferId;
|
|
||||||
using TickType = u64;
|
|
||||||
};
|
|
||||||
Common::LeastRecentlyUsedCache<LRUItemParams> lru_cache;
|
|
||||||
u64 frame_tick = 0;
|
u64 frame_tick = 0;
|
||||||
u64 total_used_memory = 0;
|
u64 total_used_memory = 0;
|
||||||
u64 minimum_memory = 0;
|
u64 minimum_memory = 0;
|
||||||
|
|
|
||||||
|
|
@ -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-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||||
|
|
@ -122,7 +122,35 @@ void DmaPusher::ProcessCommands(std::span<const CommandHeader> commands) {
|
||||||
dma_state.is_last_call = true;
|
dma_state.is_last_call = true;
|
||||||
index += max_write;
|
index += max_write;
|
||||||
} else if (dma_state.method_count) {
|
} 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.dma_word_offset = u32(index * sizeof(u32));
|
||||||
dma_state.is_last_call = dma_state.method_count <= 1;
|
dma_state.is_last_call = dma_state.method_count <= 1;
|
||||||
CallMethod(command_header.argument);
|
CallMethod(command_header.argument);
|
||||||
|
|
@ -181,7 +209,11 @@ void DmaPusher::CallMethod(u32 argument) const {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
auto subchannel = subchannels[dma_state.subchannel];
|
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);
|
subchannel->method_sink.emplace_back(dma_state.method, argument);
|
||||||
} else {
|
} else {
|
||||||
subchannel->ConsumeSink();
|
subchannel->ConsumeSink();
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <bitset>
|
#include <array>
|
||||||
#include <limits>
|
|
||||||
#include <vector>
|
#include <boost/container/small_vector.hpp>
|
||||||
|
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
|
||||||
|
|
@ -41,8 +41,11 @@ public:
|
||||||
ConsumeSinkImpl();
|
ConsumeSinkImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::bitset<(std::numeric_limits<u16>::max)()> execution_mask{};
|
static constexpr size_t EXECUTION_MASK_TABLE_SIZE = 0xE00;
|
||||||
std::vector<std::pair<u32, u32>> method_sink{};
|
|
||||||
|
std::array<u8, EXECUTION_MASK_TABLE_SIZE> execution_mask{};
|
||||||
|
bool execution_mask_default{};
|
||||||
|
boost::container::small_vector<std::pair<u32, u32>, 64> method_sink{};
|
||||||
bool current_dirty{};
|
bool current_dirty{};
|
||||||
GPUVAddr current_dma_segment;
|
GPUVAddr current_dma_segment;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ Fermi2D::Fermi2D(MemoryManager& memory_manager_) : memory_manager{memory_manager
|
||||||
regs.src.depth = 1;
|
regs.src.depth = 1;
|
||||||
regs.dst.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;
|
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_)
|
KeplerCompute::KeplerCompute(Core::System& system_, MemoryManager& memory_manager_)
|
||||||
: system{system_}, memory_manager{memory_manager_}, upload_state{memory_manager, regs.upload} {
|
: system{system_}, 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(exec_upload)] = true;
|
||||||
execution_mask[KEPLER_COMPUTE_REG_INDEX(data_upload)] = true;
|
execution_mask[KEPLER_COMPUTE_REG_INDEX(data_upload)] = true;
|
||||||
execution_mask[KEPLER_COMPUTE_REG_INDEX(launch)] = true;
|
execution_mask[KEPLER_COMPUTE_REG_INDEX(launch)] = true;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ KeplerMemory::~KeplerMemory() = default;
|
||||||
void KeplerMemory::BindRasterizer(VideoCore::RasterizerInterface* rasterizer_) {
|
void KeplerMemory::BindRasterizer(VideoCore::RasterizerInterface* rasterizer_) {
|
||||||
upload_state.BindRasterizer(rasterizer_);
|
upload_state.BindRasterizer(rasterizer_);
|
||||||
|
|
||||||
execution_mask.reset();
|
execution_mask.fill(0);
|
||||||
execution_mask[KEPLERMEMORY_REG_INDEX(exec)] = true;
|
execution_mask[KEPLERMEMORY_REG_INDEX(exec)] = true;
|
||||||
execution_mask[KEPLERMEMORY_REG_INDEX(data)] = true;
|
execution_mask[KEPLERMEMORY_REG_INDEX(data)] = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,10 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/bit_util.h"
|
#include "common/bit_util.h"
|
||||||
#include "common/scope_exit.h"
|
#include "common/scope_exit.h"
|
||||||
|
|
@ -37,9 +39,10 @@ Maxwell3D::Maxwell3D(Core::System& system_, MemoryManager& memory_manager_)
|
||||||
{
|
{
|
||||||
dirty.flags.flip();
|
dirty.flags.flip();
|
||||||
InitializeRegisterDefaults();
|
InitializeRegisterDefaults();
|
||||||
execution_mask.reset();
|
execution_mask.fill(0);
|
||||||
for (size_t i = 0; i < execution_mask.size(); i++)
|
for (size_t i = 0; i < EXECUTION_MASK_TABLE_SIZE; i++)
|
||||||
execution_mask[i] = IsMethodExecutable(u32(i));
|
execution_mask[i] = IsMethodExecutable(u32(i));
|
||||||
|
execution_mask_default = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Maxwell3D::~Maxwell3D() = default;
|
Maxwell3D::~Maxwell3D() = default;
|
||||||
|
|
@ -298,18 +301,27 @@ u32 Maxwell3D::ProcessShadowRam(u32 method, u32 argument) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Maxwell3D::ConsumeSinkImpl() {
|
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;
|
const auto control = shadow_state.shadow_ram_control;
|
||||||
if (control == Regs::ShadowRamControl::Track || control == Regs::ShadowRamControl::TrackWithFilter) {
|
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];
|
||||||
shadow_state.reg_array[method] = value;
|
shadow_state.reg_array[method] = value;
|
||||||
ProcessDirtyRegisters(method, value);
|
ProcessDirtyRegisters(method, value);
|
||||||
}
|
}
|
||||||
} else if (control == Regs::ShadowRamControl::Replay) {
|
} 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];
|
||||||
ProcessDirtyRegisters(method, shadow_state.reg_array[method]);
|
ProcessDirtyRegisters(method, shadow_state.reg_array[method]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
for (auto [method, value] : method_sink)
|
for (size_t i = 0; i < sink_size; ++i) {
|
||||||
|
const auto [method, value] = method_sink[i];
|
||||||
ProcessDirtyRegisters(method, value);
|
ProcessDirtyRegisters(method, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
method_sink.clear();
|
method_sink.clear();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ using namespace Texture;
|
||||||
|
|
||||||
MaxwellDMA::MaxwellDMA(Core::System& system_, MemoryManager& memory_manager_)
|
MaxwellDMA::MaxwellDMA(Core::System& system_, MemoryManager& memory_manager_)
|
||||||
: system{system_}, memory_manager{memory_manager_} {
|
: system{system_}, memory_manager{memory_manager_} {
|
||||||
execution_mask.reset();
|
execution_mask.fill(0);
|
||||||
execution_mask[offsetof(Regs, launch_dma) / sizeof(u32)] = true;
|
execution_mask[offsetof(Regs, launch_dma) / sizeof(u32)] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
|
@ -102,7 +105,7 @@ struct ImageBase {
|
||||||
VAddr cpu_addr_end = 0;
|
VAddr cpu_addr_end = 0;
|
||||||
|
|
||||||
u64 modification_tick = 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{};
|
std::array<u32, MAX_MIP_LEVELS> mip_level_offsets{};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <bit>
|
#include <bit>
|
||||||
|
|
@ -70,14 +71,10 @@ TextureCache<P>::TextureCache(Runtime& runtime_, Tegra::MaxwellDeviceMemoryManag
|
||||||
(std::max)((std::min)(device_local_memory - min_vacancy_critical, min_spacing_critical),
|
(std::max)((std::min)(device_local_memory - min_vacancy_critical, min_spacing_critical),
|
||||||
DEFAULT_CRITICAL_MEMORY));
|
DEFAULT_CRITICAL_MEMORY));
|
||||||
minimum_memory = static_cast<u64>((device_local_memory - mem_threshold) / 2);
|
minimum_memory = static_cast<u64>((device_local_memory - mem_threshold) / 2);
|
||||||
|
|
||||||
lowmemorydevice = false;
|
|
||||||
} else {
|
} else {
|
||||||
expected_memory = DEFAULT_EXPECTED_MEMORY + 512_MiB;
|
expected_memory = DEFAULT_EXPECTED_MEMORY + 512_MiB;
|
||||||
critical_memory = DEFAULT_CRITICAL_MEMORY + 1_GiB;
|
critical_memory = DEFAULT_CRITICAL_MEMORY + 1_GiB;
|
||||||
minimum_memory = 0;
|
minimum_memory = 0;
|
||||||
|
|
||||||
lowmemorydevice = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool gpu_unswizzle_enabled = Settings::values.gpu_unswizzle_enabled.GetValue();
|
const bool gpu_unswizzle_enabled = Settings::values.gpu_unswizzle_enabled.GetValue();
|
||||||
|
|
@ -117,25 +114,66 @@ TextureCache<P>::TextureCache(Runtime& runtime_, Tegra::MaxwellDeviceMemoryManag
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
void TextureCache<P>::RunGarbageCollector() {
|
void TextureCache<P>::RunAllocationGarbageCollector(size_t requested_bytes) {
|
||||||
bool high_priority_mode = false;
|
if (requested_bytes == 0) {
|
||||||
bool aggressive_mode = false;
|
return;
|
||||||
u64 ticks_to_destroy = 0;
|
}
|
||||||
size_t num_iterations = 0;
|
|
||||||
|
|
||||||
const auto Configure = [&](bool allow_aggressive) {
|
if (allocation_gc_frame != frame_tick) {
|
||||||
high_priority_mode = total_used_memory >= expected_memory;
|
allocation_gc_frame = frame_tick;
|
||||||
aggressive_mode = allow_aggressive && total_used_memory >= critical_memory;
|
allocation_gc_passes = 0;
|
||||||
ticks_to_destroy = aggressive_mode ? 10ULL : high_priority_mode ? 25ULL : 50ULL;
|
}
|
||||||
num_iterations = aggressive_mode ? 40 : (high_priority_mode ? 20 : 10);
|
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 aggressive_mode = false;
|
||||||
|
u64 ticks_to_destroy = high_priority_mode ? 25ULL : 50ULL;
|
||||||
|
size_t num_iterations = high_priority_mode ? 20 : 10;
|
||||||
|
|
||||||
const auto Cleanup = [this, &num_iterations, &high_priority_mode,
|
const auto Cleanup = [this, &num_iterations, &high_priority_mode,
|
||||||
&aggressive_mode](ImageId image_id) {
|
&aggressive_mode](ImageId image_id) {
|
||||||
if (num_iterations == 0) {
|
if (num_iterations == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
--num_iterations;
|
|
||||||
auto& image = slot_images[image_id];
|
auto& image = slot_images[image_id];
|
||||||
|
|
||||||
// Never delete recently allocated sparse textures (within 3 frames)
|
// Never delete recently allocated sparse textures (within 3 frames)
|
||||||
|
|
@ -145,28 +183,22 @@ void TextureCache<P>::RunGarbageCollector() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (True(image.flags & ImageFlagBits::IsDecoding)) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prioritize large sparse textures for cleanup
|
if (!aggressive_mode && True(image.flags & ImageFlagBits::CostlyLoad)) {
|
||||||
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool must_download =
|
const bool must_download =
|
||||||
image.IsSafeDownload() && False(image.flags & ImageFlagBits::BadOverlap);
|
image.IsSafeDownload() && False(image.flags & ImageFlagBits::BadOverlap);
|
||||||
if (!high_priority_mode && !is_large_sparse && must_download) {
|
if (!high_priority_mode && must_download) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (must_download && !is_large_sparse) {
|
--num_iterations;
|
||||||
|
|
||||||
|
if (must_download) {
|
||||||
auto map = runtime.DownloadStagingBuffer(image.unswizzled_size_bytes);
|
auto map = runtime.DownloadStagingBuffer(image.unswizzled_size_bytes);
|
||||||
const auto copies = FixSmallVectorADL(FullDownloadCopies(image.info));
|
const auto copies = FixSmallVectorADL(FullDownloadCopies(image.info));
|
||||||
image.DownloadMemory(map, copies);
|
image.DownloadMemory(map, copies);
|
||||||
|
|
@ -183,7 +215,6 @@ void TextureCache<P>::RunGarbageCollector() {
|
||||||
|
|
||||||
if (total_used_memory < critical_memory) {
|
if (total_used_memory < critical_memory) {
|
||||||
if (aggressive_mode) {
|
if (aggressive_mode) {
|
||||||
// Sink the aggresiveness.
|
|
||||||
num_iterations >>= 2;
|
num_iterations >>= 2;
|
||||||
aggressive_mode = false;
|
aggressive_mode = false;
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -196,31 +227,49 @@ void TextureCache<P>::RunGarbageCollector() {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Aggressively clear massive sparse textures
|
const auto SortByAge = [this](auto& vec) {
|
||||||
if (total_used_memory >= expected_memory) {
|
std::sort(vec.begin(), vec.end(), [this](ImageId a, ImageId b) {
|
||||||
lru_cache.ForEachItemBelow(frame_tick, [&](ImageId image_id) {
|
return slot_images[a].last_use_tick < slot_images[b].last_use_tick;
|
||||||
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;
|
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Configure(false);
|
SortByAge(expired);
|
||||||
lru_cache.ForEachItemBelow(frame_tick - ticks_to_destroy, Cleanup);
|
SortByAge(aggressive_expired);
|
||||||
|
|
||||||
// If pressure is still too high, prune aggressively.
|
// 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) {
|
if (total_used_memory >= critical_memory) {
|
||||||
Configure(true);
|
aggressive_mode = true;
|
||||||
lru_cache.ForEachItemBelow(frame_tick - ticks_to_destroy, Cleanup);
|
num_iterations = 40;
|
||||||
|
for (const auto image_id : aggressive_expired) {
|
||||||
|
if (Cleanup(image_id)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1196,9 +1245,6 @@ void TextureCache<P>::RefreshContents(Image& image, ImageId image_id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
image.flags &= ~ImageFlagBits::CpuModified;
|
image.flags &= ~ImageFlagBits::CpuModified;
|
||||||
if( lowmemorydevice && image.info.format == PixelFormat::BC1_RGBA_UNORM && MapSizeBytes(image) >= 256_MiB ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
TrackImage(image, image_id);
|
TrackImage(image, image_id);
|
||||||
|
|
||||||
|
|
@ -1608,49 +1654,19 @@ bool TextureCache<P>::ScaleDown(Image& image) {
|
||||||
template <class P>
|
template <class P>
|
||||||
ImageId TextureCache<P>::InsertImage(const ImageInfo& info, GPUVAddr gpu_addr,
|
ImageId TextureCache<P>::InsertImage(const ImageInfo& info, GPUVAddr gpu_addr,
|
||||||
RelaxedOptions options) {
|
RelaxedOptions options) {
|
||||||
|
const size_t requested_size = CalculateGuestSizeInBytes(info);
|
||||||
std::optional<DAddr> cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr);
|
std::optional<DAddr> cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr);
|
||||||
if (!cpu_addr) {
|
if (!cpu_addr) {
|
||||||
const auto size = CalculateGuestSizeInBytes(info);
|
cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr, requested_size);
|
||||||
cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr, size);
|
|
||||||
if (!cpu_addr) {
|
if (!cpu_addr) {
|
||||||
const DAddr fake_addr = ~(1ULL << 40ULL) + virtual_invalid_space;
|
const DAddr fake_addr = ~(1ULL << 40ULL) + virtual_invalid_space;
|
||||||
virtual_invalid_space += Common::AlignUp(size, 32);
|
virtual_invalid_space += Common::AlignUp(requested_size, 32);
|
||||||
cpu_addr = std::optional<DAddr>(fake_addr);
|
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);
|
ASSERT_MSG(cpu_addr, "Tried to insert an image to an invalid gpu_addr=0x{:x}", gpu_addr);
|
||||||
|
|
||||||
// For large sparse textures, aggressively clean up old allocations at same address
|
RunAllocationGarbageCollector(requested_size);
|
||||||
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 ImageId image_id = JoinImages(info, gpu_addr, *cpu_addr);
|
||||||
const Image& image = slot_images[image_id];
|
const Image& image = slot_images[image_id];
|
||||||
|
|
@ -1668,25 +1684,7 @@ ImageId TextureCache<P>::JoinImages(const ImageInfo& info, GPUVAddr gpu_addr, DA
|
||||||
ImageInfo new_info = info;
|
ImageInfo new_info = info;
|
||||||
const size_t size_bytes = CalculateGuestSizeInBytes(new_info);
|
const size_t size_bytes = CalculateGuestSizeInBytes(new_info);
|
||||||
|
|
||||||
// Proactive cleanup for large sparse texture allocations
|
RunAllocationGarbageCollector(size_bytes);
|
||||||
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 broken_views = runtime.HasBrokenTextureViewFormats();
|
||||||
const bool native_bgr = runtime.HasNativeBgr();
|
const bool native_bgr = runtime.HasNativeBgr();
|
||||||
|
|
@ -2027,8 +2025,8 @@ std::pair<u32, u32> TextureCache<P>::PrepareDmaImage(ImageId dst_id, GPUVAddr ba
|
||||||
const auto& image = slot_images[dst_id];
|
const auto& image = slot_images[dst_id];
|
||||||
const auto base = image.TryFindBase(base_addr);
|
const auto base = image.TryFindBase(base_addr);
|
||||||
PrepareImage(dst_id, mark_as_modified, false);
|
PrepareImage(dst_id, mark_as_modified, false);
|
||||||
const auto& new_image = slot_images[dst_id];
|
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);
|
return std::make_pair(base->level, base->layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2377,7 +2375,7 @@ void TextureCache<P>::RegisterImage(ImageId image_id) {
|
||||||
tentative_size = TranscodedAstcSize(tentative_size, image.info.format);
|
tentative_size = TranscodedAstcSize(tentative_size, image.info.format);
|
||||||
}
|
}
|
||||||
total_used_memory += Common::AlignUp(tentative_size, 1024);
|
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) {
|
ForEachGPUPage(image.gpu_addr, image.guest_size_bytes, [this, image_id](u64 page) {
|
||||||
(*channel_state->gpu_page_table)[page].push_back(image_id);
|
(*channel_state->gpu_page_table)[page].push_back(image_id);
|
||||||
|
|
@ -2411,7 +2409,7 @@ void TextureCache<P>::UnregisterImage(ImageId image_id) {
|
||||||
"Trying to unregister an already registered image");
|
"Trying to unregister an already registered image");
|
||||||
image.flags &= ~ImageFlagBits::Registered;
|
image.flags &= ~ImageFlagBits::Registered;
|
||||||
image.flags &= ~ImageFlagBits::BadOverlap;
|
image.flags &= ~ImageFlagBits::BadOverlap;
|
||||||
lru_cache.Free(image.lru_index);
|
|
||||||
const auto& clear_page_table =
|
const auto& clear_page_table =
|
||||||
[image_id](u64 page, ankerl::unordered_dense::map<u64, std::vector<ImageId>, Common::IdentityHash<u64>>& selected_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);
|
const auto page_it = selected_page_table.find(page);
|
||||||
|
|
@ -2740,7 +2738,7 @@ void TextureCache<P>::PrepareImage(ImageId image_id, bool is_modification, bool
|
||||||
if (is_modification) {
|
if (is_modification) {
|
||||||
MarkModification(image);
|
MarkModification(image);
|
||||||
}
|
}
|
||||||
lru_cache.Touch(image.lru_index, frame_tick);
|
image.last_use_tick = frame_tick;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/hash.h"
|
#include "common/hash.h"
|
||||||
#include "common/literals.h"
|
#include "common/literals.h"
|
||||||
#include "common/lru_cache.h"
|
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
#include "common/scratch_buffer.h"
|
#include "common/scratch_buffer.h"
|
||||||
#include "common/slot_vector.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_EXPECTED_MEMORY = 1_GiB + 125_MiB;
|
||||||
static constexpr s64 DEFAULT_CRITICAL_MEMORY = 1_GiB + 625_MiB;
|
static constexpr s64 DEFAULT_CRITICAL_MEMORY = 1_GiB + 625_MiB;
|
||||||
static constexpr size_t GC_EMERGENCY_COUNTS = 2;
|
static constexpr u32 MAX_ALLOCATION_GC_PASSES_PER_FRAME = 2;
|
||||||
|
|
||||||
using Runtime = typename P::Runtime;
|
using Runtime = typename P::Runtime;
|
||||||
using Image = typename P::Image;
|
using Image = typename P::Image;
|
||||||
|
|
@ -310,6 +310,8 @@ private:
|
||||||
/// Runs the Garbage Collector.
|
/// Runs the Garbage Collector.
|
||||||
void RunGarbageCollector();
|
void RunGarbageCollector();
|
||||||
|
|
||||||
|
void RunAllocationGarbageCollector(size_t requested_bytes);
|
||||||
|
|
||||||
/// Fills image_view_ids in the image views in indices
|
/// Fills image_view_ids in the image views in indices
|
||||||
template <bool has_blacklists>
|
template <bool has_blacklists>
|
||||||
void FillImageViews(DescriptorTable<TICEntry>& table,
|
void FillImageViews(DescriptorTable<TICEntry>& table,
|
||||||
|
|
@ -478,7 +480,6 @@ private:
|
||||||
u64 minimum_memory;
|
u64 minimum_memory;
|
||||||
u64 expected_memory;
|
u64 expected_memory;
|
||||||
u64 critical_memory;
|
u64 critical_memory;
|
||||||
bool lowmemorydevice = false;
|
|
||||||
size_t gpu_unswizzle_maxsize = 0;
|
size_t gpu_unswizzle_maxsize = 0;
|
||||||
size_t swizzle_chunk_size = 0;
|
size_t swizzle_chunk_size = 0;
|
||||||
u32 swizzle_slices_per_batch = 0;
|
u32 swizzle_slices_per_batch = 0;
|
||||||
|
|
@ -510,11 +511,7 @@ private:
|
||||||
std::deque<std::vector<AsyncBuffer>> async_buffers;
|
std::deque<std::vector<AsyncBuffer>> async_buffers;
|
||||||
std::deque<AsyncBuffer> async_buffers_death_ring;
|
std::deque<AsyncBuffer> async_buffers_death_ring;
|
||||||
|
|
||||||
struct LRUItemParams {
|
|
||||||
using ObjectType = ImageId;
|
|
||||||
using TickType = u64;
|
|
||||||
};
|
|
||||||
Common::LeastRecentlyUsedCache<LRUItemParams> lru_cache;
|
|
||||||
|
|
||||||
#ifdef YUZU_LEGACY
|
#ifdef YUZU_LEGACY
|
||||||
static constexpr size_t TICKS_TO_DESTROY = 6;
|
static constexpr size_t TICKS_TO_DESTROY = 6;
|
||||||
|
|
@ -532,6 +529,8 @@ private:
|
||||||
|
|
||||||
u64 modification_tick = 0;
|
u64 modification_tick = 0;
|
||||||
u64 frame_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)();
|
u64 last_sampler_gc_frame = (std::numeric_limits<u64>::max)();
|
||||||
|
|
||||||
Common::ThreadWorker texture_decode_worker{1, "TextureDecoder"};
|
Common::ThreadWorker texture_decode_worker{1, "TextureDecoder"};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue