Separate GPU engines and make state follow official docs (part 1/2) (#2422)
* Use DeviceState for compute and i2m * Migrate 2D class, more comments * Migrate DMA copy engine * Remove now unused code * Replace GpuState by GpuAccessorState on GpuAcessor, since compute no longer has a GpuState * More comments * Add logging (disabled) * Add back i2m on 3D engine
This commit is contained in:
parent
31cbd09a75
commit
8b44eb1c98
30 changed files with 2599 additions and 460 deletions
|
@ -20,7 +20,10 @@ namespace Ryujinx.Graphics.Device
|
|||
private readonly Dictionary<int, Func<int>> _readCallbacks;
|
||||
private readonly Dictionary<int, Action<int>> _writeCallbacks;
|
||||
|
||||
public DeviceState(IReadOnlyDictionary<string, RwCallback> callbacks = null)
|
||||
private readonly Dictionary<int, string> _fieldNamesForDebug;
|
||||
private readonly Action<string> _debugLogCallback;
|
||||
|
||||
public DeviceState(IReadOnlyDictionary<string, RwCallback> callbacks = null, Action<string> debugLogCallback = null)
|
||||
{
|
||||
int size = (Unsafe.SizeOf<TState>() + RegisterSize - 1) / RegisterSize;
|
||||
|
||||
|
@ -30,6 +33,12 @@ namespace Ryujinx.Graphics.Device
|
|||
_readCallbacks = new Dictionary<int, Func<int>>();
|
||||
_writeCallbacks = new Dictionary<int, Action<int>>();
|
||||
|
||||
if (debugLogCallback != null)
|
||||
{
|
||||
_fieldNamesForDebug = new Dictionary<int, string>();
|
||||
_debugLogCallback = debugLogCallback;
|
||||
}
|
||||
|
||||
var fields = typeof(TState).GetFields();
|
||||
int offset = 0;
|
||||
|
||||
|
@ -59,6 +68,11 @@ namespace Ryujinx.Graphics.Device
|
|||
}
|
||||
}
|
||||
|
||||
if (debugLogCallback != null)
|
||||
{
|
||||
_fieldNamesForDebug.Add(offset, field.Name);
|
||||
}
|
||||
|
||||
offset += sizeOfField;
|
||||
}
|
||||
|
||||
|
@ -90,6 +104,11 @@ namespace Ryujinx.Graphics.Device
|
|||
{
|
||||
int alignedOffset = Align(offset);
|
||||
|
||||
if (_fieldNamesForDebug != null && _fieldNamesForDebug.TryGetValue(alignedOffset, out string fieldName))
|
||||
{
|
||||
_debugLogCallback($"{typeof(TState).Name}.{fieldName} = 0x{data:X}");
|
||||
}
|
||||
|
||||
GetRef<int>(alignedOffset) = data;
|
||||
|
||||
if (_writeCallbacks.TryGetValue(alignedOffset, out Action<int> write))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue