Change Cell->RSX map/unmap notifications

This allows for further flexibility on the RSX side, allowing us to fix
some bugs and crashes in later commits.
This commit is contained in:
Rui Pinheiro 2018-09-22 15:45:55 +01:00 committed by kd-11
parent a07cbaca8e
commit f3029b2b42
3 changed files with 33 additions and 14 deletions

View File

@ -292,6 +292,14 @@ namespace vm
}
}
// Notify rsx that range has become valid
// Note: This must be done *before* memory gets mapped while holding the vm lock, otherwise
// the RSX might try to invalidate memory that got unmapped and remapped
if (const auto rsxthr = fxm::check_unlocked<GSRender>())
{
rsxthr->on_notify_memory_mapped(addr, size);
}
if (!shm)
{
utils::memory_protect(g_base_addr + addr, size, utils::protection::rw);
@ -413,6 +421,15 @@ namespace vm
}
}
// Notify rsx to invalidate range
// Note: This must be done *before* memory gets unmapped while holding the vm lock, otherwise
// the RSX might try to call VirtualProtect on memory that is already unmapped
if (const auto rsxthr = fxm::check_unlocked<GSRender>())
{
rsxthr->on_notify_memory_unmapped(addr, size);
}
// Actually unmap memory
if (!shm)
{
utils::memory_protect(g_base_addr + addr, size, utils::protection::no);
@ -581,12 +598,6 @@ namespace vm
m_common->unmap_critical(vm::base(addr));
}
}
// Notify rsx to invalidate range (TODO)
if (const auto rsxthr = fxm::check_unlocked<GSRender>())
{
rsxthr->on_notify_memory_unmapped(addr, size);
}
}
u32 block_t::alloc(const u32 orig_size, u32 align, const std::shared_ptr<utils::shm>* src)
@ -718,12 +729,6 @@ namespace vm
m_map.erase(found);
}
// Notify rsx to invalidate range (TODO)
if (const auto rsxthr = fxm::check_unlocked<GSRender>())
{
rsxthr->on_notify_memory_unmapped(addr, result);
}
return result;
}

View File

@ -1,4 +1,4 @@
#include "stdafx.h"
#include "stdafx.h"
#include "Emu/Memory/vm.h"
#include "Emu/System.h"
#include "Emu/IdManager.h"
@ -1382,6 +1382,7 @@ namespace rsx
}
}
//std::future<void> thread::add_internal_task(std::function<bool()> callback)
//{
// std::lock_guard lock(m_mtx_task);
@ -2673,6 +2674,12 @@ namespace rsx
check_zcull_status(false);
}
void thread::on_notify_memory_mapped(u32 address, u32 size)
{
// TODO
}
void thread::on_notify_memory_unmapped(u32 base_address, u32 size)
{
if (!m_rsx_thread_exiting && base_address < 0xC0000000)

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <stack>
#include <deque>
@ -599,6 +599,13 @@ namespace rsx
*/
void write_inline_array_to_buffer(void *dst_buffer);
/**
* Notify that a section of memory has been mapped
* If there is a notify_memory_unmapped request on this range yet to be handled,
* handles it immediately.
*/
void on_notify_memory_mapped(u32 address_base, u32 size);
/**
* Notify that a section of memory has been unmapped
* Any data held in the defined range is discarded