From 7dabb3c647b08848dfa99915f2e46e1e746a7b29 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 3 Nov 2023 15:23:48 +0100 Subject: [PATCH] Add some Redrawing Debug UI. --- Penumbra/Interop/Services/RedrawService.cs | 16 +++++++- Penumbra/UI/Tabs/DebugTab.cs | 46 +++++++++++++++++++++- 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/Penumbra/Interop/Services/RedrawService.cs b/Penumbra/Interop/Services/RedrawService.cs index 5cc493ad..ec858290 100644 --- a/Penumbra/Interop/Services/RedrawService.cs +++ b/Penumbra/Interop/Services/RedrawService.cs @@ -18,10 +18,13 @@ public unsafe partial class RedrawService public const int GPoseSlots = 42; public const int GPoseEndIdx = GPosePlayerIdx + GPoseSlots; - private readonly string?[] _gPoseNames = new string?[GPoseSlots]; + private readonly string?[] _gPoseNames = new string?[GPoseSlots]; private int _gPoseNameCounter; - private bool InGPose + internal IReadOnlyList GPoseNames + => _gPoseNames; + + internal bool InGPose => _clientState.IsGPosing; // VFuncs that disable and enable draw, used only for GPose actors. @@ -108,6 +111,15 @@ public sealed unsafe partial class RedrawService : IDisposable private readonly List _afterGPoseQueue = new(GPoseSlots); private int _target = -1; + internal IReadOnlyList Queue + => _queue; + + internal IReadOnlyList AfterGPoseQueue + => _afterGPoseQueue; + + internal int Target + => _target; + public event GameObjectRedrawnDelegate? GameObjectRedrawn; public RedrawService(IFramework framework, IObjectTable objects, ITargetManager targets, ICondition conditions, IClientState clientState) diff --git a/Penumbra/UI/Tabs/DebugTab.cs b/Penumbra/UI/Tabs/DebugTab.cs index 5abb3c2f..dc39707a 100644 --- a/Penumbra/UI/Tabs/DebugTab.cs +++ b/Penumbra/UI/Tabs/DebugTab.cs @@ -65,6 +65,7 @@ public class DebugTab : Window, ITab private readonly TextureManager _textureManager; private readonly SkinFixer _skinFixer; private readonly IdentifierService _identifier; + private readonly RedrawService _redraws; public DebugTab(StartTracker timer, PerformanceTracker performance, Configuration config, CollectionManager collectionManager, ValidityChecker validityChecker, ModManager modManager, HttpApi httpApi, ActorService actorService, @@ -72,7 +73,7 @@ public DebugTab(StartTracker timer, PerformanceTracker performance, Configuratio ResourceManagerService resourceManager, PenumbraIpcProviders ipc, CollectionResolver collectionResolver, DrawObjectState drawObjectState, PathState pathState, SubfileHelper subfileHelper, IdentifiedCollectionCache identifiedCollectionCache, CutsceneService cutsceneService, ModImportManager modImporter, ImportPopup importPopup, FrameworkManager framework, - TextureManager textureManager, SkinFixer skinFixer, IdentifierService identifier) + TextureManager textureManager, SkinFixer skinFixer, IdentifierService identifier, RedrawService redraws) : base("Penumbra Debug Window", ImGuiWindowFlags.NoCollapse) { IsOpen = true; @@ -107,6 +108,7 @@ public DebugTab(StartTracker timer, PerformanceTracker performance, Configuratio _textureManager = textureManager; _skinFixer = skinFixer; _identifier = identifier; + _redraws = redraws; } public ReadOnlySpan Label @@ -317,6 +319,48 @@ private void DrawDebugTabGeneral() } } } + + using (var tree = TreeNode("Redraw Service")) + { + if (tree) + { + using var table = Table("##redraws", 3, ImGuiTableFlags.RowBg); + if (table) + { + ImGuiUtil.DrawTableColumn("In GPose"); + ImGuiUtil.DrawTableColumn(_redraws.InGPose.ToString()); + ImGui.TableNextColumn(); + + ImGuiUtil.DrawTableColumn("Target"); + ImGuiUtil.DrawTableColumn(_redraws.Target.ToString()); + ImGui.TableNextColumn(); + + foreach (var (objectIdx, idx) in _redraws.Queue.WithIndex()) + { + var (actualIdx, state) = objectIdx < 0 ? (~objectIdx, "Queued") : (objectIdx, "Invisible"); + ImGuiUtil.DrawTableColumn($"Redraw Queue #{idx}"); + ImGuiUtil.DrawTableColumn(actualIdx.ToString()); + ImGuiUtil.DrawTableColumn(state); + } + + foreach (var (objectIdx, idx) in _redraws.AfterGPoseQueue.WithIndex()) + { + var (actualIdx, state) = objectIdx < 0 ? (~objectIdx, "Queued") : (objectIdx, "Invisible"); + ImGuiUtil.DrawTableColumn($"GPose Queue #{idx}"); + ImGuiUtil.DrawTableColumn(actualIdx.ToString()); + ImGuiUtil.DrawTableColumn(state); + } + + foreach (var (name, idx) in _redraws.GPoseNames.OfType().WithIndex()) + { + ImGuiUtil.DrawTableColumn($"GPose Name #{idx}"); + ImGuiUtil.DrawTableColumn(name); + ImGui.TableNextColumn(); + } + + } + } + } } private void DrawPerformanceTab()