MemoryManager: Fix errors popping out.
This commit is contained in:
parent
3d02143476
commit
5a568b1655
3 changed files with 18 additions and 4 deletions
|
@ -551,6 +551,11 @@ struct Memory::Impl {
|
|||
[]() {});
|
||||
}
|
||||
|
||||
[[nodiscard]] u8* GetPointerSilent(const VAddr vaddr) const {
|
||||
return GetPointerImpl(
|
||||
vaddr, []() {}, []() {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a particular data type out of memory at the given virtual address.
|
||||
*
|
||||
|
@ -686,6 +691,10 @@ u8* Memory::GetPointer(VAddr vaddr) {
|
|||
return impl->GetPointer(vaddr);
|
||||
}
|
||||
|
||||
u8* Memory::GetPointerSilent(VAddr vaddr) {
|
||||
return impl->GetPointerSilent(vaddr);
|
||||
}
|
||||
|
||||
const u8* Memory::GetPointer(VAddr vaddr) const {
|
||||
return impl->GetPointer(vaddr);
|
||||
}
|
||||
|
|
|
@ -114,6 +114,7 @@ public:
|
|||
* If the address is not valid, nullptr will be returned.
|
||||
*/
|
||||
u8* GetPointer(VAddr vaddr);
|
||||
u8* GetPointerSilent(VAddr vaddr);
|
||||
|
||||
template <typename T>
|
||||
T* GetPointer(VAddr vaddr) {
|
||||
|
|
|
@ -134,11 +134,15 @@ GPUVAddr MemoryManager::BigPageTableOp(GPUVAddr gpu_addr, [[maybe_unused]] VAddr
|
|||
big_page_table_cpu[index] = sub_value;
|
||||
const bool is_continous = ([&] {
|
||||
uintptr_t base_ptr{
|
||||
reinterpret_cast<uintptr_t>(memory.GetPointer(current_cpu_addr))};
|
||||
reinterpret_cast<uintptr_t>(memory.GetPointerSilent(current_cpu_addr))};
|
||||
if (base_ptr == 0) {
|
||||
return false;
|
||||
}
|
||||
for (VAddr start_cpu = current_cpu_addr + page_size;
|
||||
start_cpu < current_cpu_addr + big_page_size; start_cpu += page_size) {
|
||||
base_ptr += page_size;
|
||||
if (base_ptr != reinterpret_cast<uintptr_t>(memory.GetPointer(start_cpu))) {
|
||||
auto next_ptr = reinterpret_cast<uintptr_t>(memory.GetPointerSilent(start_cpu));
|
||||
if (next_ptr == 0 || base_ptr != next_ptr) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -359,7 +363,7 @@ void MemoryManager::ReadBlockImpl(GPUVAddr gpu_src_addr, void* dest_buffer,
|
|||
if constexpr (is_safe) {
|
||||
rasterizer->FlushRegion(cpu_addr_base, copy_amount);
|
||||
}
|
||||
if (!IsBigPageContinous(page_index)) {
|
||||
if (!IsBigPageContinous(page_index)) [[unlikely]] {
|
||||
memory.ReadBlockUnsafe(cpu_addr_base, dest_buffer, copy_amount);
|
||||
} else {
|
||||
u8* physical = memory.GetPointer(cpu_addr_base);
|
||||
|
@ -407,7 +411,7 @@ void MemoryManager::WriteBlockImpl(GPUVAddr gpu_dest_addr, const void* src_buffe
|
|||
if constexpr (is_safe) {
|
||||
rasterizer->InvalidateRegion(cpu_addr_base, copy_amount);
|
||||
}
|
||||
if (!IsBigPageContinous(page_index)) {
|
||||
if (!IsBigPageContinous(page_index)) [[unlikely]] {
|
||||
memory.WriteBlockUnsafe(cpu_addr_base, src_buffer, copy_amount);
|
||||
} else {
|
||||
u8* physical = memory.GetPointer(cpu_addr_base);
|
||||
|
|
Loading…
Reference in a new issue