From 8b44eb1c981d7106be37107755c7c71c3c3c0ce4 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Wed, 7 Jul 2021 20:56:06 -0300 Subject: 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 --- Ryujinx.Graphics.Device/DeviceState.cs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'Ryujinx.Graphics.Device/DeviceState.cs') 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> _readCallbacks; private readonly Dictionary> _writeCallbacks; - public DeviceState(IReadOnlyDictionary callbacks = null) + private readonly Dictionary _fieldNamesForDebug; + private readonly Action _debugLogCallback; + + public DeviceState(IReadOnlyDictionary callbacks = null, Action debugLogCallback = null) { int size = (Unsafe.SizeOf() + RegisterSize - 1) / RegisterSize; @@ -30,6 +33,12 @@ namespace Ryujinx.Graphics.Device _readCallbacks = new Dictionary>(); _writeCallbacks = new Dictionary>(); + if (debugLogCallback != null) + { + _fieldNamesForDebug = new Dictionary(); + _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(alignedOffset) = data; if (_writeCallbacks.TryGetValue(alignedOffset, out Action write)) -- cgit v1.2.3