mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-12-26 08:20:07 +00:00
GPU: Add Reactive flushing
This commit is contained in:
parent
e58090c9c7
commit
c6cac2ffaa
@ -612,6 +612,10 @@ void System::PrepareReschedule(const u32 core_index) {
|
|||||||
impl->kernel.PrepareReschedule(core_index);
|
impl->kernel.PrepareReschedule(core_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t System::GetCurrentHostThreadID() const {
|
||||||
|
return impl->kernel.GetCurrentHostThreadID();
|
||||||
|
}
|
||||||
|
|
||||||
PerfStatsResults System::GetAndResetPerfStats() {
|
PerfStatsResults System::GetAndResetPerfStats() {
|
||||||
return impl->GetAndResetPerfStats();
|
return impl->GetAndResetPerfStats();
|
||||||
}
|
}
|
||||||
|
@ -222,6 +222,8 @@ public:
|
|||||||
/// Prepare the core emulation for a reschedule
|
/// Prepare the core emulation for a reschedule
|
||||||
void PrepareReschedule(u32 core_index);
|
void PrepareReschedule(u32 core_index);
|
||||||
|
|
||||||
|
[[nodiscard]] size_t GetCurrentHostThreadID() const;
|
||||||
|
|
||||||
/// Gets and resets core performance statistics
|
/// Gets and resets core performance statistics
|
||||||
[[nodiscard]] PerfStatsResults GetAndResetPerfStats();
|
[[nodiscard]] PerfStatsResults GetAndResetPerfStats();
|
||||||
|
|
||||||
|
@ -13,10 +13,13 @@
|
|||||||
#include "common/swap.h"
|
#include "common/swap.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/device_memory.h"
|
#include "core/device_memory.h"
|
||||||
|
#include "core/hardware_properties.h"
|
||||||
#include "core/hle/kernel/k_page_table.h"
|
#include "core/hle/kernel/k_page_table.h"
|
||||||
#include "core/hle/kernel/k_process.h"
|
#include "core/hle/kernel/k_process.h"
|
||||||
#include "core/memory.h"
|
#include "core/memory.h"
|
||||||
#include "video_core/gpu.h"
|
#include "video_core/gpu.h"
|
||||||
|
#include "video_core/rasterizer_download_area.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Core::Memory {
|
namespace Core::Memory {
|
||||||
|
|
||||||
@ -243,7 +246,7 @@ struct Memory::Impl {
|
|||||||
[&](const Common::ProcessAddress current_vaddr, const std::size_t copy_amount,
|
[&](const Common::ProcessAddress current_vaddr, const std::size_t copy_amount,
|
||||||
const u8* const host_ptr) {
|
const u8* const host_ptr) {
|
||||||
if constexpr (!UNSAFE) {
|
if constexpr (!UNSAFE) {
|
||||||
system.GPU().FlushRegion(GetInteger(current_vaddr), copy_amount);
|
HandleRasterizerDownload(GetInteger(current_vaddr), copy_amount);
|
||||||
}
|
}
|
||||||
std::memcpy(dest_buffer, host_ptr, copy_amount);
|
std::memcpy(dest_buffer, host_ptr, copy_amount);
|
||||||
},
|
},
|
||||||
@ -334,7 +337,7 @@ struct Memory::Impl {
|
|||||||
},
|
},
|
||||||
[&](const Common::ProcessAddress current_vaddr, const std::size_t copy_amount,
|
[&](const Common::ProcessAddress current_vaddr, const std::size_t copy_amount,
|
||||||
u8* const host_ptr) {
|
u8* const host_ptr) {
|
||||||
system.GPU().FlushRegion(GetInteger(current_vaddr), copy_amount);
|
HandleRasterizerDownload(GetInteger(current_vaddr), copy_amount);
|
||||||
WriteBlockImpl<false>(process, dest_addr, host_ptr, copy_amount);
|
WriteBlockImpl<false>(process, dest_addr, host_ptr, copy_amount);
|
||||||
},
|
},
|
||||||
[&](const std::size_t copy_amount) {
|
[&](const std::size_t copy_amount) {
|
||||||
@ -373,7 +376,7 @@ struct Memory::Impl {
|
|||||||
const std::size_t block_size) {
|
const std::size_t block_size) {
|
||||||
// dc ivac: Invalidate to point of coherency
|
// dc ivac: Invalidate to point of coherency
|
||||||
// GPU flush -> CPU invalidate
|
// GPU flush -> CPU invalidate
|
||||||
system.GPU().FlushRegion(GetInteger(current_vaddr), block_size);
|
HandleRasterizerDownload(GetInteger(current_vaddr), block_size);
|
||||||
};
|
};
|
||||||
return PerformCacheOperation(process, dest_addr, size, on_rasterizer);
|
return PerformCacheOperation(process, dest_addr, size, on_rasterizer);
|
||||||
}
|
}
|
||||||
@ -462,8 +465,7 @@ struct Memory::Impl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Settings::IsFastmemEnabled()) {
|
if (Settings::IsFastmemEnabled()) {
|
||||||
const bool is_read_enable = !Settings::IsGPULevelExtreme() || !cached;
|
system.DeviceMemory().buffer.Protect(vaddr, size, !cached, !cached);
|
||||||
system.DeviceMemory().buffer.Protect(vaddr, size, is_read_enable, !cached);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterate over a contiguous CPU address space, which corresponds to the specified GPU
|
// Iterate over a contiguous CPU address space, which corresponds to the specified GPU
|
||||||
@ -651,7 +653,9 @@ struct Memory::Impl {
|
|||||||
LOG_ERROR(HW_Memory, "Unmapped Read{} @ 0x{:016X}", sizeof(T) * 8,
|
LOG_ERROR(HW_Memory, "Unmapped Read{} @ 0x{:016X}", sizeof(T) * 8,
|
||||||
GetInteger(vaddr));
|
GetInteger(vaddr));
|
||||||
},
|
},
|
||||||
[&]() { system.GPU().FlushRegion(GetInteger(vaddr), sizeof(T)); });
|
[&]() {
|
||||||
|
HandleRasterizerDownload(GetInteger(vaddr), sizeof(T));
|
||||||
|
});
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
std::memcpy(&result, ptr, sizeof(T));
|
std::memcpy(&result, ptr, sizeof(T));
|
||||||
}
|
}
|
||||||
@ -712,7 +716,18 @@ struct Memory::Impl {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HandleRasterizerDownload(VAddr address, size_t size) {
|
||||||
|
const size_t core = system.GetCurrentHostThreadID();
|
||||||
|
auto& current_area = rasterizer_areas[core];
|
||||||
|
const VAddr end_address = address + size;
|
||||||
|
if (current_area.start_address <= address && end_address <= current_area.end_address) [[likely]] {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
current_area = system.GPU().OnCPURead(address, size);
|
||||||
|
}
|
||||||
|
|
||||||
Common::PageTable* current_page_table = nullptr;
|
Common::PageTable* current_page_table = nullptr;
|
||||||
|
std::array<VideoCore::RasterizerDownloadArea, Core::Hardware::NUM_CPU_CORES> rasterizer_areas{};
|
||||||
Core::System& system;
|
Core::System& system;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ namespace VideoCommon {
|
|||||||
enum class BufferFlagBits {
|
enum class BufferFlagBits {
|
||||||
Picked = 1 << 0,
|
Picked = 1 << 0,
|
||||||
CachedWrites = 1 << 1,
|
CachedWrites = 1 << 1,
|
||||||
|
PreemtiveDownload = 1 << 2,
|
||||||
};
|
};
|
||||||
DECLARE_ENUM_FLAG_OPERATORS(BufferFlagBits)
|
DECLARE_ENUM_FLAG_OPERATORS(BufferFlagBits)
|
||||||
|
|
||||||
@ -54,6 +55,10 @@ public:
|
|||||||
flags |= BufferFlagBits::Picked;
|
flags |= BufferFlagBits::Picked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MarkPreemtiveDownload() noexcept {
|
||||||
|
flags |= BufferFlagBits::PreemtiveDownload;
|
||||||
|
}
|
||||||
|
|
||||||
/// Unmark buffer as picked
|
/// Unmark buffer as picked
|
||||||
void Unpick() noexcept {
|
void Unpick() noexcept {
|
||||||
flags &= ~BufferFlagBits::Picked;
|
flags &= ~BufferFlagBits::Picked;
|
||||||
@ -84,6 +89,10 @@ public:
|
|||||||
return True(flags & BufferFlagBits::CachedWrites);
|
return True(flags & BufferFlagBits::CachedWrites);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsPreemtiveDownload() const noexcept {
|
||||||
|
return True(flags & BufferFlagBits::PreemtiveDownload);
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the base CPU address of the buffer
|
/// Returns the base CPU address of the buffer
|
||||||
[[nodiscard]] VAddr CpuAddr() const noexcept {
|
[[nodiscard]] VAddr CpuAddr() const noexcept {
|
||||||
return cpu_addr;
|
return cpu_addr;
|
||||||
|
@ -111,9 +111,24 @@ void BufferCache<P>::WriteMemory(VAddr cpu_addr, u64 size) {
|
|||||||
template <class P>
|
template <class P>
|
||||||
void BufferCache<P>::CachedWriteMemory(VAddr cpu_addr, u64 size) {
|
void BufferCache<P>::CachedWriteMemory(VAddr cpu_addr, u64 size) {
|
||||||
memory_tracker.CachedCpuWrite(cpu_addr, size);
|
memory_tracker.CachedCpuWrite(cpu_addr, size);
|
||||||
const IntervalType add_interval{Common::AlignDown(cpu_addr, YUZU_PAGESIZE),
|
}
|
||||||
Common::AlignUp(cpu_addr + size, YUZU_PAGESIZE)};
|
|
||||||
cached_ranges.add(add_interval);
|
template <class P>
|
||||||
|
std::optional<VideoCore::RasterizerDownloadArea> BufferCache<P>::GetFlushArea(VAddr cpu_addr,
|
||||||
|
u64 size) {
|
||||||
|
std::optional<VideoCore::RasterizerDownloadArea> area{};
|
||||||
|
area.emplace();
|
||||||
|
VAddr cpu_addr_start_aligned = Common::AlignDown(cpu_addr, Core::Memory::YUZU_PAGESIZE);
|
||||||
|
VAddr cpu_addr_end_aligned = Common::AlignUp(cpu_addr + size, Core::Memory::YUZU_PAGESIZE);
|
||||||
|
area->start_address = cpu_addr_start_aligned;
|
||||||
|
area->end_address = cpu_addr_end_aligned;
|
||||||
|
if (memory_tracker.IsRegionPreflushable(cpu_addr, size)) {
|
||||||
|
area->preemtive = true;
|
||||||
|
return area;
|
||||||
|
};
|
||||||
|
memory_tracker.MarkRegionAsPreflushable(cpu_addr_start_aligned, cpu_addr_end_aligned - cpu_addr_start_aligned);
|
||||||
|
area->preemtive = !IsRegionGpuModified(cpu_addr, size);
|
||||||
|
return area;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
@ -191,8 +206,10 @@ bool BufferCache<P>::DMACopy(GPUVAddr src_address, GPUVAddr dest_address, u64 am
|
|||||||
const VAddr new_base_address = *cpu_dest_address + diff;
|
const VAddr new_base_address = *cpu_dest_address + diff;
|
||||||
const IntervalType add_interval{new_base_address, new_base_address + size};
|
const IntervalType add_interval{new_base_address, new_base_address + size};
|
||||||
tmp_intervals.push_back(add_interval);
|
tmp_intervals.push_back(add_interval);
|
||||||
|
if (memory_tracker.IsRegionPreflushable(new_base_address, new_base_address + size)) {
|
||||||
uncommitted_ranges.add(add_interval);
|
uncommitted_ranges.add(add_interval);
|
||||||
pending_ranges.add(add_interval);
|
pending_ranges.add(add_interval);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
ForEachInRangeSet(common_ranges, *cpu_src_address, amount, mirror);
|
ForEachInRangeSet(common_ranges, *cpu_src_address, amount, mirror);
|
||||||
// This subtraction in this order is important for overlapping copies.
|
// This subtraction in this order is important for overlapping copies.
|
||||||
@ -205,7 +222,7 @@ bool BufferCache<P>::DMACopy(GPUVAddr src_address, GPUVAddr dest_address, u64 am
|
|||||||
if (has_new_downloads) {
|
if (has_new_downloads) {
|
||||||
memory_tracker.MarkRegionAsGpuModified(*cpu_dest_address, amount);
|
memory_tracker.MarkRegionAsGpuModified(*cpu_dest_address, amount);
|
||||||
}
|
}
|
||||||
std::vector<u8> tmp_buffer(amount);
|
tmp_buffer.resize(amount);
|
||||||
cpu_memory.ReadBlockUnsafe(*cpu_src_address, tmp_buffer.data(), amount);
|
cpu_memory.ReadBlockUnsafe(*cpu_src_address, tmp_buffer.data(), amount);
|
||||||
cpu_memory.WriteBlockUnsafe(*cpu_dest_address, tmp_buffer.data(), amount);
|
cpu_memory.WriteBlockUnsafe(*cpu_dest_address, tmp_buffer.data(), amount);
|
||||||
return true;
|
return true;
|
||||||
@ -441,9 +458,7 @@ void BufferCache<P>::BindComputeTextureBuffer(size_t tbo_index, GPUVAddr gpu_add
|
|||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
void BufferCache<P>::FlushCachedWrites() {
|
void BufferCache<P>::FlushCachedWrites() {
|
||||||
cached_write_buffer_ids.clear();
|
|
||||||
memory_tracker.FlushCachedWrites();
|
memory_tracker.FlushCachedWrites();
|
||||||
cached_ranges.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
@ -1221,6 +1236,9 @@ void BufferCache<P>::MarkWrittenBuffer(BufferId buffer_id, VAddr cpu_addr, u32 s
|
|||||||
|
|
||||||
const IntervalType base_interval{cpu_addr, cpu_addr + size};
|
const IntervalType base_interval{cpu_addr, cpu_addr + size};
|
||||||
common_ranges.add(base_interval);
|
common_ranges.add(base_interval);
|
||||||
|
if (!memory_tracker.IsRegionPreflushable(cpu_addr, cpu_addr + size)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
uncommitted_ranges.add(base_interval);
|
uncommitted_ranges.add(base_interval);
|
||||||
pending_ranges.add(base_interval);
|
pending_ranges.add(base_interval);
|
||||||
}
|
}
|
||||||
@ -1629,7 +1647,6 @@ void BufferCache<P>::DeleteBuffer(BufferId buffer_id, bool do_not_mark) {
|
|||||||
replace(transform_feedback_buffers);
|
replace(transform_feedback_buffers);
|
||||||
replace(compute_uniform_buffers);
|
replace(compute_uniform_buffers);
|
||||||
replace(compute_storage_buffers);
|
replace(compute_storage_buffers);
|
||||||
std::erase(cached_write_buffer_ids, buffer_id);
|
|
||||||
|
|
||||||
// Mark the whole buffer as CPU written to stop tracking CPU writes
|
// Mark the whole buffer as CPU written to stop tracking CPU writes
|
||||||
if (!do_not_mark) {
|
if (!do_not_mark) {
|
||||||
|
@ -188,6 +188,8 @@ public:
|
|||||||
|
|
||||||
void DownloadMemory(VAddr cpu_addr, u64 size);
|
void DownloadMemory(VAddr cpu_addr, u64 size);
|
||||||
|
|
||||||
|
std::optional<VideoCore::RasterizerDownloadArea> GetFlushArea(VAddr cpu_addr, u64 size);
|
||||||
|
|
||||||
bool InlineMemory(VAddr dest_address, size_t copy_size, std::span<const u8> inlined_buffer);
|
bool InlineMemory(VAddr dest_address, size_t copy_size, std::span<const u8> inlined_buffer);
|
||||||
|
|
||||||
void BindGraphicsUniformBuffer(size_t stage, u32 index, GPUVAddr gpu_addr, u32 size);
|
void BindGraphicsUniformBuffer(size_t stage, u32 index, GPUVAddr gpu_addr, u32 size);
|
||||||
@ -541,8 +543,6 @@ private:
|
|||||||
std::array<std::array<u32, NUM_GRAPHICS_UNIFORM_BUFFERS>, NUM_STAGES>, Empty>
|
std::array<std::array<u32, NUM_GRAPHICS_UNIFORM_BUFFERS>, NUM_STAGES>, Empty>
|
||||||
uniform_buffer_binding_sizes{};
|
uniform_buffer_binding_sizes{};
|
||||||
|
|
||||||
std::vector<BufferId> cached_write_buffer_ids;
|
|
||||||
|
|
||||||
MemoryTracker memory_tracker;
|
MemoryTracker memory_tracker;
|
||||||
IntervalSet uncommitted_ranges;
|
IntervalSet uncommitted_ranges;
|
||||||
IntervalSet common_ranges;
|
IntervalSet common_ranges;
|
||||||
@ -575,6 +575,7 @@ private:
|
|||||||
bool active_async_buffers = false;
|
bool active_async_buffers = false;
|
||||||
|
|
||||||
std::array<BufferId, ((1ULL << 39) >> CACHING_PAGEBITS)> page_table;
|
std::array<BufferId, ((1ULL << 39) >> CACHING_PAGEBITS)> page_table;
|
||||||
|
std::vector<u8> tmp_buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace VideoCommon
|
} // namespace VideoCommon
|
||||||
|
@ -66,6 +66,14 @@ public:
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns true if a region has been marked as Preflushable
|
||||||
|
[[nodiscard]] bool IsRegionPreflushable(VAddr query_cpu_addr, u64 query_size) noexcept {
|
||||||
|
return IteratePages<false>(
|
||||||
|
query_cpu_addr, query_size, [](Manager* manager, u64 offset, size_t size) {
|
||||||
|
return manager->template IsRegionModified<Type::Preflushable>(offset, size);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/// Mark region as CPU modified, notifying the rasterizer about this change
|
/// Mark region as CPU modified, notifying the rasterizer about this change
|
||||||
void MarkRegionAsCpuModified(VAddr dirty_cpu_addr, u64 query_size) {
|
void MarkRegionAsCpuModified(VAddr dirty_cpu_addr, u64 query_size) {
|
||||||
IteratePages<true>(dirty_cpu_addr, query_size,
|
IteratePages<true>(dirty_cpu_addr, query_size,
|
||||||
@ -93,6 +101,15 @@ public:
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Mark region as modified from the host GPU
|
||||||
|
void MarkRegionAsPreflushable(VAddr dirty_cpu_addr, u64 query_size) noexcept {
|
||||||
|
IteratePages<true>(dirty_cpu_addr, query_size,
|
||||||
|
[](Manager* manager, u64 offset, size_t size) {
|
||||||
|
manager->template ChangeRegionState<Type::Preflushable, true>(
|
||||||
|
manager->GetCpuAddr() + offset, size);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/// Unmark region as modified from the host GPU
|
/// Unmark region as modified from the host GPU
|
||||||
void UnmarkRegionAsGpuModified(VAddr dirty_cpu_addr, u64 query_size) noexcept {
|
void UnmarkRegionAsGpuModified(VAddr dirty_cpu_addr, u64 query_size) noexcept {
|
||||||
IteratePages<true>(dirty_cpu_addr, query_size,
|
IteratePages<true>(dirty_cpu_addr, query_size,
|
||||||
@ -102,6 +119,15 @@ public:
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Unmark region as modified from the host GPU
|
||||||
|
void UnmarkRegionAsPreflushable(VAddr dirty_cpu_addr, u64 query_size) noexcept {
|
||||||
|
IteratePages<true>(dirty_cpu_addr, query_size,
|
||||||
|
[](Manager* manager, u64 offset, size_t size) {
|
||||||
|
manager->template ChangeRegionState<Type::Preflushable, false>(
|
||||||
|
manager->GetCpuAddr() + offset, size);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/// Mark region as modified from the CPU
|
/// Mark region as modified from the CPU
|
||||||
/// but don't mark it as modified until FlusHCachedWrites is called.
|
/// but don't mark it as modified until FlusHCachedWrites is called.
|
||||||
void CachedCpuWrite(VAddr dirty_cpu_addr, u64 query_size) {
|
void CachedCpuWrite(VAddr dirty_cpu_addr, u64 query_size) {
|
||||||
|
@ -26,6 +26,7 @@ enum class Type {
|
|||||||
GPU,
|
GPU,
|
||||||
CachedCPU,
|
CachedCPU,
|
||||||
Untracked,
|
Untracked,
|
||||||
|
Preflushable,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Vector tracking modified pages tightly packed with small vector optimization
|
/// Vector tracking modified pages tightly packed with small vector optimization
|
||||||
@ -55,17 +56,20 @@ struct Words {
|
|||||||
gpu.stack.fill(0);
|
gpu.stack.fill(0);
|
||||||
cached_cpu.stack.fill(0);
|
cached_cpu.stack.fill(0);
|
||||||
untracked.stack.fill(~u64{0});
|
untracked.stack.fill(~u64{0});
|
||||||
|
preflushable.stack.fill(0);
|
||||||
} else {
|
} else {
|
||||||
// Share allocation between CPU and GPU pages and set their default values
|
// Share allocation between CPU and GPU pages and set their default values
|
||||||
u64* const alloc = new u64[num_words * 4];
|
u64* const alloc = new u64[num_words * 5];
|
||||||
cpu.heap = alloc;
|
cpu.heap = alloc;
|
||||||
gpu.heap = alloc + num_words;
|
gpu.heap = alloc + num_words;
|
||||||
cached_cpu.heap = alloc + num_words * 2;
|
cached_cpu.heap = alloc + num_words * 2;
|
||||||
untracked.heap = alloc + num_words * 3;
|
untracked.heap = alloc + num_words * 3;
|
||||||
|
preflushable.heap = alloc + num_words * 4;
|
||||||
std::fill_n(cpu.heap, num_words, ~u64{0});
|
std::fill_n(cpu.heap, num_words, ~u64{0});
|
||||||
std::fill_n(gpu.heap, num_words, 0);
|
std::fill_n(gpu.heap, num_words, 0);
|
||||||
std::fill_n(cached_cpu.heap, num_words, 0);
|
std::fill_n(cached_cpu.heap, num_words, 0);
|
||||||
std::fill_n(untracked.heap, num_words, ~u64{0});
|
std::fill_n(untracked.heap, num_words, ~u64{0});
|
||||||
|
std::fill_n(preflushable.heap, num_words, 0);
|
||||||
}
|
}
|
||||||
// Clean up tailing bits
|
// Clean up tailing bits
|
||||||
const u64 last_word_size = size_bytes % BYTES_PER_WORD;
|
const u64 last_word_size = size_bytes % BYTES_PER_WORD;
|
||||||
@ -88,13 +92,14 @@ struct Words {
|
|||||||
gpu = rhs.gpu;
|
gpu = rhs.gpu;
|
||||||
cached_cpu = rhs.cached_cpu;
|
cached_cpu = rhs.cached_cpu;
|
||||||
untracked = rhs.untracked;
|
untracked = rhs.untracked;
|
||||||
|
preflushable = rhs.preflushable;
|
||||||
rhs.cpu.heap = nullptr;
|
rhs.cpu.heap = nullptr;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Words(Words&& rhs) noexcept
|
Words(Words&& rhs) noexcept
|
||||||
: size_bytes{rhs.size_bytes}, num_words{rhs.num_words}, cpu{rhs.cpu}, gpu{rhs.gpu},
|
: size_bytes{rhs.size_bytes}, num_words{rhs.num_words}, cpu{rhs.cpu}, gpu{rhs.gpu},
|
||||||
cached_cpu{rhs.cached_cpu}, untracked{rhs.untracked} {
|
cached_cpu{rhs.cached_cpu}, untracked{rhs.untracked}, preflushable{rhs.preflushable} {
|
||||||
rhs.cpu.heap = nullptr;
|
rhs.cpu.heap = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,6 +134,8 @@ struct Words {
|
|||||||
return std::span<u64>(cached_cpu.Pointer(IsShort()), num_words);
|
return std::span<u64>(cached_cpu.Pointer(IsShort()), num_words);
|
||||||
} else if constexpr (type == Type::Untracked) {
|
} else if constexpr (type == Type::Untracked) {
|
||||||
return std::span<u64>(untracked.Pointer(IsShort()), num_words);
|
return std::span<u64>(untracked.Pointer(IsShort()), num_words);
|
||||||
|
} else if constexpr (type == Type::Preflushable) {
|
||||||
|
return std::span<u64>(preflushable.Pointer(IsShort()), num_words);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,6 +149,8 @@ struct Words {
|
|||||||
return std::span<const u64>(cached_cpu.Pointer(IsShort()), num_words);
|
return std::span<const u64>(cached_cpu.Pointer(IsShort()), num_words);
|
||||||
} else if constexpr (type == Type::Untracked) {
|
} else if constexpr (type == Type::Untracked) {
|
||||||
return std::span<const u64>(untracked.Pointer(IsShort()), num_words);
|
return std::span<const u64>(untracked.Pointer(IsShort()), num_words);
|
||||||
|
} else if constexpr (type == Type::Preflushable) {
|
||||||
|
return std::span<const u64>(preflushable.Pointer(IsShort()), num_words);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,6 +160,7 @@ struct Words {
|
|||||||
WordsArray<stack_words> gpu;
|
WordsArray<stack_words> gpu;
|
||||||
WordsArray<stack_words> cached_cpu;
|
WordsArray<stack_words> cached_cpu;
|
||||||
WordsArray<stack_words> untracked;
|
WordsArray<stack_words> untracked;
|
||||||
|
WordsArray<stack_words> preflushable;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class RasterizerInterface, size_t stack_words = 1>
|
template <class RasterizerInterface, size_t stack_words = 1>
|
||||||
|
@ -223,7 +223,7 @@ void MaxwellDMA::CopyBlockLinearToPitch() {
|
|||||||
write_buffer.resize_destructive(dst_size);
|
write_buffer.resize_destructive(dst_size);
|
||||||
|
|
||||||
memory_manager.ReadBlock(src_operand.address, read_buffer.data(), src_size);
|
memory_manager.ReadBlock(src_operand.address, read_buffer.data(), src_size);
|
||||||
memory_manager.ReadBlockUnsafe(dst_operand.address, write_buffer.data(), dst_size);
|
memory_manager.ReadBlock(dst_operand.address, write_buffer.data(), dst_size);
|
||||||
|
|
||||||
UnswizzleSubrect(write_buffer, read_buffer, bytes_per_pixel, width, height, depth, x_offset,
|
UnswizzleSubrect(write_buffer, read_buffer, bytes_per_pixel, width, height, depth, x_offset,
|
||||||
src_params.origin.y, x_elements, regs.line_count, block_height, block_depth,
|
src_params.origin.y, x_elements, regs.line_count, block_height, block_depth,
|
||||||
@ -288,11 +288,7 @@ void MaxwellDMA::CopyPitchToBlockLinear() {
|
|||||||
write_buffer.resize_destructive(dst_size);
|
write_buffer.resize_destructive(dst_size);
|
||||||
|
|
||||||
memory_manager.ReadBlock(regs.offset_in, read_buffer.data(), src_size);
|
memory_manager.ReadBlock(regs.offset_in, read_buffer.data(), src_size);
|
||||||
if (Settings::IsGPULevelExtreme()) {
|
|
||||||
memory_manager.ReadBlock(regs.offset_out, write_buffer.data(), dst_size);
|
memory_manager.ReadBlock(regs.offset_out, write_buffer.data(), dst_size);
|
||||||
} else {
|
|
||||||
memory_manager.ReadBlockUnsafe(regs.offset_out, write_buffer.data(), dst_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the input is linear and the output is tiled, swizzle the input and copy it over.
|
// If the input is linear and the output is tiled, swizzle the input and copy it over.
|
||||||
SwizzleSubrect(write_buffer, read_buffer, bytes_per_pixel, width, height, depth, x_offset,
|
SwizzleSubrect(write_buffer, read_buffer, bytes_per_pixel, width, height, depth, x_offset,
|
||||||
|
@ -55,8 +55,8 @@ public:
|
|||||||
|
|
||||||
// Unlike other fences, this one doesn't
|
// Unlike other fences, this one doesn't
|
||||||
void SignalOrdering() {
|
void SignalOrdering() {
|
||||||
std::scoped_lock lock{buffer_cache.mutex};
|
std::function<void()> do_nothing([]{});
|
||||||
buffer_cache.AccumulateFlushes();
|
SignalFence(std::move(do_nothing));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SyncOperation(std::function<void()>&& func) {
|
void SyncOperation(std::function<void()>&& func) {
|
||||||
|
@ -283,6 +283,21 @@ struct GPU::Impl {
|
|||||||
gpu_thread.FlushRegion(addr, size);
|
gpu_thread.FlushRegion(addr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VideoCore::RasterizerDownloadArea OnCPURead(VAddr addr, u64 size) {
|
||||||
|
auto raster_area = rasterizer->GetFlushArea(addr, size);
|
||||||
|
if (raster_area.preemtive) {
|
||||||
|
return raster_area;
|
||||||
|
}
|
||||||
|
raster_area.preemtive = true;
|
||||||
|
const u64 fence = RequestSyncOperation([this, &raster_area]() {
|
||||||
|
rasterizer->FlushRegion(raster_area.start_address,
|
||||||
|
raster_area.end_address - raster_area.start_address);
|
||||||
|
});
|
||||||
|
gpu_thread.TickGPU();
|
||||||
|
WaitForSyncOperation(fence);
|
||||||
|
return raster_area;
|
||||||
|
}
|
||||||
|
|
||||||
/// Notify rasterizer that any caches of the specified region should be invalidated
|
/// Notify rasterizer that any caches of the specified region should be invalidated
|
||||||
void InvalidateRegion(VAddr addr, u64 size) {
|
void InvalidateRegion(VAddr addr, u64 size) {
|
||||||
gpu_thread.InvalidateRegion(addr, size);
|
gpu_thread.InvalidateRegion(addr, size);
|
||||||
@ -538,6 +553,10 @@ void GPU::SwapBuffers(const Tegra::FramebufferConfig* framebuffer) {
|
|||||||
impl->SwapBuffers(framebuffer);
|
impl->SwapBuffers(framebuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VideoCore::RasterizerDownloadArea GPU::OnCPURead(VAddr addr, u64 size) {
|
||||||
|
return impl->OnCPURead(addr, size);
|
||||||
|
}
|
||||||
|
|
||||||
void GPU::FlushRegion(VAddr addr, u64 size) {
|
void GPU::FlushRegion(VAddr addr, u64 size) {
|
||||||
impl->FlushRegion(addr, size);
|
impl->FlushRegion(addr, size);
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "core/hle/service/nvdrv/nvdata.h"
|
#include "core/hle/service/nvdrv/nvdata.h"
|
||||||
#include "video_core/cdma_pusher.h"
|
#include "video_core/cdma_pusher.h"
|
||||||
#include "video_core/framebuffer_config.h"
|
#include "video_core/framebuffer_config.h"
|
||||||
|
#include "video_core/rasterizer_download_area.h"
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class System;
|
class System;
|
||||||
@ -240,6 +241,9 @@ public:
|
|||||||
/// Swap buffers (render frame)
|
/// Swap buffers (render frame)
|
||||||
void SwapBuffers(const Tegra::FramebufferConfig* framebuffer);
|
void SwapBuffers(const Tegra::FramebufferConfig* framebuffer);
|
||||||
|
|
||||||
|
/// Notify rasterizer that any caches of the specified region should be flushed to Switch memory
|
||||||
|
[[nodiscard]] VideoCore::RasterizerDownloadArea OnCPURead(VAddr addr, u64 size);
|
||||||
|
|
||||||
/// Notify rasterizer that any caches of the specified region should be flushed to Switch memory
|
/// Notify rasterizer that any caches of the specified region should be flushed to Switch memory
|
||||||
void FlushRegion(VAddr addr, u64 size);
|
void FlushRegion(VAddr addr, u64 size);
|
||||||
|
|
||||||
|
13
src/video_core/rasterizer_download_area.h
Normal file
13
src/video_core/rasterizer_download_area.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/common_types.h"
|
||||||
|
|
||||||
|
namespace VideoCore {
|
||||||
|
|
||||||
|
struct RasterizerDownloadArea {
|
||||||
|
VAddr start_address;
|
||||||
|
VAddr end_address;
|
||||||
|
bool preemtive;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace VideoCore
|
@ -12,6 +12,7 @@
|
|||||||
#include "video_core/cache_types.h"
|
#include "video_core/cache_types.h"
|
||||||
#include "video_core/engines/fermi_2d.h"
|
#include "video_core/engines/fermi_2d.h"
|
||||||
#include "video_core/gpu.h"
|
#include "video_core/gpu.h"
|
||||||
|
#include "video_core/rasterizer_download_area.h"
|
||||||
|
|
||||||
namespace Tegra {
|
namespace Tegra {
|
||||||
class MemoryManager;
|
class MemoryManager;
|
||||||
@ -95,6 +96,8 @@ public:
|
|||||||
virtual bool MustFlushRegion(VAddr addr, u64 size,
|
virtual bool MustFlushRegion(VAddr addr, u64 size,
|
||||||
VideoCommon::CacheType which = VideoCommon::CacheType::All) = 0;
|
VideoCommon::CacheType which = VideoCommon::CacheType::All) = 0;
|
||||||
|
|
||||||
|
virtual RasterizerDownloadArea GetFlushArea(VAddr addr, u64 size) = 0;
|
||||||
|
|
||||||
/// Notify rasterizer that any caches of the specified region should be invalidated
|
/// Notify rasterizer that any caches of the specified region should be invalidated
|
||||||
virtual void InvalidateRegion(VAddr addr, u64 size,
|
virtual void InvalidateRegion(VAddr addr, u64 size,
|
||||||
VideoCommon::CacheType which = VideoCommon::CacheType::All) = 0;
|
VideoCommon::CacheType which = VideoCommon::CacheType::All) = 0;
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include "common/alignment.h"
|
||||||
|
#include "core/memory.h"
|
||||||
#include "video_core/host1x/host1x.h"
|
#include "video_core/host1x/host1x.h"
|
||||||
#include "video_core/memory_manager.h"
|
#include "video_core/memory_manager.h"
|
||||||
#include "video_core/renderer_null/null_rasterizer.h"
|
#include "video_core/renderer_null/null_rasterizer.h"
|
||||||
@ -46,6 +48,14 @@ bool RasterizerNull::MustFlushRegion(VAddr addr, u64 size, VideoCommon::CacheTyp
|
|||||||
}
|
}
|
||||||
void RasterizerNull::InvalidateRegion(VAddr addr, u64 size, VideoCommon::CacheType) {}
|
void RasterizerNull::InvalidateRegion(VAddr addr, u64 size, VideoCommon::CacheType) {}
|
||||||
void RasterizerNull::OnCPUWrite(VAddr addr, u64 size) {}
|
void RasterizerNull::OnCPUWrite(VAddr addr, u64 size) {}
|
||||||
|
VideoCore::RasterizerDownloadArea RasterizerNull::GetFlushArea(VAddr addr, u64 size) {
|
||||||
|
VideoCore::RasterizerDownloadArea new_area{
|
||||||
|
.start_address = Common::AlignDown(addr, Core::Memory::YUZU_PAGESIZE),
|
||||||
|
.end_address = Common::AlignUp(addr + size, Core::Memory::YUZU_PAGESIZE),
|
||||||
|
.preemtive = true,
|
||||||
|
};
|
||||||
|
return new_area;
|
||||||
|
}
|
||||||
void RasterizerNull::InvalidateGPUCache() {}
|
void RasterizerNull::InvalidateGPUCache() {}
|
||||||
void RasterizerNull::UnmapMemory(VAddr addr, u64 size) {}
|
void RasterizerNull::UnmapMemory(VAddr addr, u64 size) {}
|
||||||
void RasterizerNull::ModifyGPUMemory(size_t as_id, GPUVAddr addr, u64 size) {}
|
void RasterizerNull::ModifyGPUMemory(size_t as_id, GPUVAddr addr, u64 size) {}
|
||||||
|
@ -54,6 +54,7 @@ public:
|
|||||||
void InvalidateRegion(VAddr addr, u64 size,
|
void InvalidateRegion(VAddr addr, u64 size,
|
||||||
VideoCommon::CacheType which = VideoCommon::CacheType::All) override;
|
VideoCommon::CacheType which = VideoCommon::CacheType::All) override;
|
||||||
void OnCPUWrite(VAddr addr, u64 size) override;
|
void OnCPUWrite(VAddr addr, u64 size) override;
|
||||||
|
VideoCore::RasterizerDownloadArea GetFlushArea(VAddr addr, u64 size) override;
|
||||||
void InvalidateGPUCache() override;
|
void InvalidateGPUCache() override;
|
||||||
void UnmapMemory(VAddr addr, u64 size) override;
|
void UnmapMemory(VAddr addr, u64 size) override;
|
||||||
void ModifyGPUMemory(size_t as_id, GPUVAddr addr, u64 size) override;
|
void ModifyGPUMemory(size_t as_id, GPUVAddr addr, u64 size) override;
|
||||||
|
@ -433,6 +433,29 @@ bool RasterizerOpenGL::MustFlushRegion(VAddr addr, u64 size, VideoCommon::CacheT
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VideoCore::RasterizerDownloadArea RasterizerOpenGL::GetFlushArea(VAddr addr, u64 size) {
|
||||||
|
{
|
||||||
|
std::scoped_lock lock{texture_cache.mutex};
|
||||||
|
auto area = texture_cache.GetFlushArea(addr, size);
|
||||||
|
if (area) {
|
||||||
|
return *area;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::scoped_lock lock{buffer_cache.mutex};
|
||||||
|
auto area = buffer_cache.GetFlushArea(addr, size);
|
||||||
|
if (area) {
|
||||||
|
return *area;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
VideoCore::RasterizerDownloadArea new_area{
|
||||||
|
.start_address = Common::AlignDown(addr, Core::Memory::YUZU_PAGESIZE),
|
||||||
|
.end_address = Common::AlignUp(addr + size, Core::Memory::YUZU_PAGESIZE),
|
||||||
|
.preemtive = true,
|
||||||
|
};
|
||||||
|
return new_area;
|
||||||
|
}
|
||||||
|
|
||||||
void RasterizerOpenGL::InvalidateRegion(VAddr addr, u64 size, VideoCommon::CacheType which) {
|
void RasterizerOpenGL::InvalidateRegion(VAddr addr, u64 size, VideoCommon::CacheType which) {
|
||||||
MICROPROFILE_SCOPE(OpenGL_CacheManagement);
|
MICROPROFILE_SCOPE(OpenGL_CacheManagement);
|
||||||
if (addr == 0 || size == 0) {
|
if (addr == 0 || size == 0) {
|
||||||
|
@ -95,6 +95,7 @@ public:
|
|||||||
VideoCommon::CacheType which = VideoCommon::CacheType::All) override;
|
VideoCommon::CacheType which = VideoCommon::CacheType::All) override;
|
||||||
bool MustFlushRegion(VAddr addr, u64 size,
|
bool MustFlushRegion(VAddr addr, u64 size,
|
||||||
VideoCommon::CacheType which = VideoCommon::CacheType::All) override;
|
VideoCommon::CacheType which = VideoCommon::CacheType::All) override;
|
||||||
|
VideoCore::RasterizerDownloadArea GetFlushArea(VAddr addr, u64 size) override;
|
||||||
void InvalidateRegion(VAddr addr, u64 size,
|
void InvalidateRegion(VAddr addr, u64 size,
|
||||||
VideoCommon::CacheType which = VideoCommon::CacheType::All) override;
|
VideoCommon::CacheType which = VideoCommon::CacheType::All) override;
|
||||||
void OnCPUWrite(VAddr addr, u64 size) override;
|
void OnCPUWrite(VAddr addr, u64 size) override;
|
||||||
|
@ -502,6 +502,29 @@ bool RasterizerVulkan::MustFlushRegion(VAddr addr, u64 size, VideoCommon::CacheT
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VideoCore::RasterizerDownloadArea RasterizerVulkan::GetFlushArea(VAddr addr, u64 size) {
|
||||||
|
{
|
||||||
|
std::scoped_lock lock{texture_cache.mutex};
|
||||||
|
auto area = texture_cache.GetFlushArea(addr, size);
|
||||||
|
if (area) {
|
||||||
|
return *area;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::scoped_lock lock{buffer_cache.mutex};
|
||||||
|
auto area = buffer_cache.GetFlushArea(addr, size);
|
||||||
|
if (area) {
|
||||||
|
return *area;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
VideoCore::RasterizerDownloadArea new_area{
|
||||||
|
.start_address = Common::AlignDown(addr, Core::Memory::YUZU_PAGESIZE),
|
||||||
|
.end_address = Common::AlignUp(addr + size, Core::Memory::YUZU_PAGESIZE),
|
||||||
|
.preemtive = true,
|
||||||
|
};
|
||||||
|
return new_area;
|
||||||
|
}
|
||||||
|
|
||||||
void RasterizerVulkan::InvalidateRegion(VAddr addr, u64 size, VideoCommon::CacheType which) {
|
void RasterizerVulkan::InvalidateRegion(VAddr addr, u64 size, VideoCommon::CacheType which) {
|
||||||
if (addr == 0 || size == 0) {
|
if (addr == 0 || size == 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -92,6 +92,7 @@ public:
|
|||||||
VideoCommon::CacheType which = VideoCommon::CacheType::All) override;
|
VideoCommon::CacheType which = VideoCommon::CacheType::All) override;
|
||||||
bool MustFlushRegion(VAddr addr, u64 size,
|
bool MustFlushRegion(VAddr addr, u64 size,
|
||||||
VideoCommon::CacheType which = VideoCommon::CacheType::All) override;
|
VideoCommon::CacheType which = VideoCommon::CacheType::All) override;
|
||||||
|
VideoCore::RasterizerDownloadArea GetFlushArea(VAddr addr, u64 size) override;
|
||||||
void InvalidateRegion(VAddr addr, u64 size,
|
void InvalidateRegion(VAddr addr, u64 size,
|
||||||
VideoCommon::CacheType which = VideoCommon::CacheType::All) override;
|
VideoCommon::CacheType which = VideoCommon::CacheType::All) override;
|
||||||
void InnerInvalidation(std::span<const std::pair<VAddr, std::size_t>> sequences) override;
|
void InnerInvalidation(std::span<const std::pair<VAddr, std::size_t>> sequences) override;
|
||||||
|
@ -39,6 +39,7 @@ struct ImageInfo {
|
|||||||
u32 tile_width_spacing = 0;
|
u32 tile_width_spacing = 0;
|
||||||
bool rescaleable = false;
|
bool rescaleable = false;
|
||||||
bool downscaleable = false;
|
bool downscaleable = false;
|
||||||
|
bool forced_flushed = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace VideoCommon
|
} // namespace VideoCommon
|
||||||
|
@ -26,8 +26,7 @@ ImageViewBase::ImageViewBase(const ImageViewInfo& info, const ImageInfo& image_i
|
|||||||
ASSERT_MSG(VideoCore::Surface::IsViewCompatible(image_info.format, info.format, false, true),
|
ASSERT_MSG(VideoCore::Surface::IsViewCompatible(image_info.format, info.format, false, true),
|
||||||
"Image view format {} is incompatible with image format {}", info.format,
|
"Image view format {} is incompatible with image format {}", info.format,
|
||||||
image_info.format);
|
image_info.format);
|
||||||
const bool is_async = Settings::values.use_asynchronous_gpu_emulation.GetValue();
|
if (image_info.forced_flushed) {
|
||||||
if (image_info.type == ImageType::Linear && is_async) {
|
|
||||||
flags |= ImageViewFlagBits::PreemtiveDownload;
|
flags |= ImageViewFlagBits::PreemtiveDownload;
|
||||||
}
|
}
|
||||||
if (image_info.type == ImageType::e3D && info.type != ImageViewType::e3D) {
|
if (image_info.type == ImageType::e3D && info.type != ImageViewType::e3D) {
|
||||||
|
@ -490,6 +490,32 @@ void TextureCache<P>::DownloadMemory(VAddr cpu_addr, size_t size) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class P>
|
||||||
|
std::optional<VideoCore::RasterizerDownloadArea> TextureCache<P>::GetFlushArea(VAddr cpu_addr,
|
||||||
|
u64 size) {
|
||||||
|
std::optional<VideoCore::RasterizerDownloadArea> area{};
|
||||||
|
ForEachImageInRegion(cpu_addr, size, [&](ImageId, ImageBase& image) {
|
||||||
|
if (False(image.flags & ImageFlagBits::GpuModified)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!area) {
|
||||||
|
area.emplace();
|
||||||
|
area->start_address = cpu_addr;
|
||||||
|
area->end_address = cpu_addr + size;
|
||||||
|
area->preemtive = true;
|
||||||
|
}
|
||||||
|
area->start_address = std::min(area->start_address, image.cpu_addr);
|
||||||
|
area->end_address = std::max(area->end_address, image.cpu_addr_end);
|
||||||
|
for (auto image_view_id : image.image_view_ids) {
|
||||||
|
auto& image_view = slot_image_views[image_view_id];
|
||||||
|
image_view.flags |= ImageViewFlagBits::PreemtiveDownload;
|
||||||
|
}
|
||||||
|
area->preemtive &= image.info.forced_flushed;
|
||||||
|
image.info.forced_flushed = true;
|
||||||
|
});
|
||||||
|
return area;
|
||||||
|
}
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
void TextureCache<P>::UnmapMemory(VAddr cpu_addr, size_t size) {
|
void TextureCache<P>::UnmapMemory(VAddr cpu_addr, size_t size) {
|
||||||
std::vector<ImageId> deleted_images;
|
std::vector<ImageId> deleted_images;
|
||||||
@ -789,11 +815,15 @@ ImageId TextureCache<P>::DmaImageId(const Tegra::DMA::ImageOperand& operand) {
|
|||||||
if (!dst_id) {
|
if (!dst_id) {
|
||||||
return NULL_IMAGE_ID;
|
return NULL_IMAGE_ID;
|
||||||
}
|
}
|
||||||
const auto& image = slot_images[dst_id];
|
auto& image = slot_images[dst_id];
|
||||||
if (False(image.flags & ImageFlagBits::GpuModified)) {
|
if (False(image.flags & ImageFlagBits::GpuModified)) {
|
||||||
// No need to waste time on an image that's synced with guest
|
// No need to waste time on an image that's synced with guest
|
||||||
return NULL_IMAGE_ID;
|
return NULL_IMAGE_ID;
|
||||||
}
|
}
|
||||||
|
if (!image.info.forced_flushed) {
|
||||||
|
image.info.forced_flushed = true;
|
||||||
|
return NULL_IMAGE_ID;
|
||||||
|
}
|
||||||
const auto base = image.TryFindBase(operand.address);
|
const auto base = image.TryFindBase(operand.address);
|
||||||
if (!base) {
|
if (!base) {
|
||||||
return NULL_IMAGE_ID;
|
return NULL_IMAGE_ID;
|
||||||
|
@ -179,6 +179,8 @@ public:
|
|||||||
/// Download contents of host images to guest memory in a region
|
/// Download contents of host images to guest memory in a region
|
||||||
void DownloadMemory(VAddr cpu_addr, size_t size);
|
void DownloadMemory(VAddr cpu_addr, size_t size);
|
||||||
|
|
||||||
|
std::optional<VideoCore::RasterizerDownloadArea> GetFlushArea(VAddr cpu_addr, u64 size);
|
||||||
|
|
||||||
/// Remove images in a region
|
/// Remove images in a region
|
||||||
void UnmapMemory(VAddr cpu_addr, size_t size);
|
void UnmapMemory(VAddr cpu_addr, size_t size);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user