diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2021-07-07 20:56:06 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-07 20:56:06 -0300 |
| commit | 8b44eb1c981d7106be37107755c7c71c3c3c0ce4 (patch) | |
| tree | 70c3a8d7286d827941c41dee2ec3cb3273c1e6d7 /Ryujinx.Graphics.Device/DeviceState.cs | |
| parent | 31cbd09a75a9d5f4814c3907a060e0961eb2bb15 (diff) | |
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
Diffstat (limited to 'Ryujinx.Graphics.Device/DeviceState.cs')
| -rw-r--r-- | Ryujinx.Graphics.Device/DeviceState.cs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/Ryujinx.Graphics.Device/DeviceState.cs b/Ryujinx.Graphics.Device/DeviceState.cs index 740d8589..1001d295 100644 --- a/Ryujinx.Graphics.Device/DeviceState.cs +++ b/Ryujinx.Graphics.Device/DeviceState.cs @@ -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)) |
