Skip to content

Commit

Permalink
Add some Redrawing Debug UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ottermandias committed Nov 3, 2023
1 parent 79c43fe commit 7dabb3c
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 3 deletions.
16 changes: 14 additions & 2 deletions Penumbra/Interop/Services/RedrawService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string?> GPoseNames
=> _gPoseNames;

internal bool InGPose
=> _clientState.IsGPosing;

// VFuncs that disable and enable draw, used only for GPose actors.
Expand Down Expand Up @@ -108,6 +111,15 @@ public sealed unsafe partial class RedrawService : IDisposable
private readonly List<int> _afterGPoseQueue = new(GPoseSlots);
private int _target = -1;

internal IReadOnlyList<int> Queue
=> _queue;

internal IReadOnlyList<int> AfterGPoseQueue
=> _afterGPoseQueue;

internal int Target
=> _target;

public event GameObjectRedrawnDelegate? GameObjectRedrawn;

public RedrawService(IFramework framework, IObjectTable objects, ITargetManager targets, ICondition conditions, IClientState clientState)
Expand Down
46 changes: 45 additions & 1 deletion Penumbra/UI/Tabs/DebugTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,15 @@ 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,
DalamudServices dalamud, StainService stains, CharacterUtility characterUtility, ResidentResourceManager residentResources,
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;
Expand Down Expand Up @@ -107,6 +108,7 @@ public DebugTab(StartTracker timer, PerformanceTracker performance, Configuratio
_textureManager = textureManager;
_skinFixer = skinFixer;
_identifier = identifier;
_redraws = redraws;
}

public ReadOnlySpan<byte> Label
Expand Down Expand Up @@ -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<string>().WithIndex())
{
ImGuiUtil.DrawTableColumn($"GPose Name #{idx}");
ImGuiUtil.DrawTableColumn(name);
ImGui.TableNextColumn();
}

}
}
}
}

private void DrawPerformanceTab()
Expand Down

0 comments on commit 7dabb3c

Please sign in to comment.