GPU: Fix errors handling texture remapping (#4745)
* GPU: Fix errors handling texture remapping - Fixes an error where a pool entry and memory mapping changing at the same time could cause a texture to rebind its data from the wrong GPU VA (data swaps) - Fixes an error where the texture pool could act on a mapping change before the mapping has actually been changed ("Unmapped" event happens before change, we need to signal it changed _after_ it completes) TODO: remove textures from partially mapped list... if they aren't. * Add Remap actions for handling post-mapping behaviours * Remove unused code. * Address feedback * Nit
This commit is contained in:
parent
680e548022
commit
36f10df775
7 changed files with 135 additions and 19 deletions
|
@ -365,6 +365,22 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs remap actions that are added to an unmap event.
|
||||
/// These must run after the mapping completes.
|
||||
/// </summary>
|
||||
/// <param name="e">Event with remap actions</param>
|
||||
private void RunRemapActions(UnmapEventArgs e)
|
||||
{
|
||||
if (e.RemapActions != null)
|
||||
{
|
||||
foreach (Action action in e.RemapActions)
|
||||
{
|
||||
action();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Maps a given range of pages to the specified CPU virtual address.
|
||||
/// </summary>
|
||||
|
@ -379,12 +395,15 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||
{
|
||||
lock (_pageTable)
|
||||
{
|
||||
MemoryUnmapped?.Invoke(this, new UnmapEventArgs(va, size));
|
||||
UnmapEventArgs e = new(va, size);
|
||||
MemoryUnmapped?.Invoke(this, e);
|
||||
|
||||
for (ulong offset = 0; offset < size; offset += PageSize)
|
||||
{
|
||||
SetPte(va + offset, PackPte(pa + offset, kind));
|
||||
}
|
||||
|
||||
RunRemapActions(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -398,12 +417,15 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||
lock (_pageTable)
|
||||
{
|
||||
// Event handlers are not expected to be thread safe.
|
||||
MemoryUnmapped?.Invoke(this, new UnmapEventArgs(va, size));
|
||||
UnmapEventArgs e = new(va, size);
|
||||
MemoryUnmapped?.Invoke(this, e);
|
||||
|
||||
for (ulong offset = 0; offset < size; offset += PageSize)
|
||||
{
|
||||
SetPte(va + offset, PteUnmapped);
|
||||
}
|
||||
|
||||
RunRemapActions(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue