Merge branch 'rt-hdr'

This commit is contained in:
Ottermandias 2025-01-11 14:21:12 +01:00
commit aebd22ed64
9 changed files with 264 additions and 25 deletions

View file

@ -104,6 +104,7 @@ public class DebugTab : Window, ITab, IUiService
private readonly RsfService _rsfService;
private readonly SchedulerResourceManagementService _schedulerService;
private readonly ObjectIdentification _objectIdentification;
private readonly RenderTargetDrawer _renderTargetDrawer;
public DebugTab(PerformanceTracker performance, Configuration config, CollectionManager collectionManager, ObjectManager objects,
IClientState clientState, IDataManager dataManager,
@ -114,7 +115,7 @@ public class DebugTab : Window, ITab, IUiService
TextureManager textureManager, ShaderReplacementFixer shaderReplacementFixer, RedrawService redraws, DictEmote emotes,
Diagnostics diagnostics, IpcTester ipcTester, CrashHandlerPanel crashHandlerPanel, TexHeaderDrawer texHeaderDrawer,
HookOverrideDrawer hookOverrides, RsfService rsfService, GlobalVariablesDrawer globalVariablesDrawer,
SchedulerResourceManagementService schedulerService, ObjectIdentification objectIdentification)
SchedulerResourceManagementService schedulerService, ObjectIdentification objectIdentification, RenderTargetDrawer renderTargetDrawer)
: base("Penumbra Debug Window", ImGuiWindowFlags.NoCollapse)
{
IsOpen = true;
@ -154,6 +155,7 @@ public class DebugTab : Window, ITab, IUiService
_globalVariablesDrawer = globalVariablesDrawer;
_schedulerService = schedulerService;
_objectIdentification = objectIdentification;
_renderTargetDrawer = renderTargetDrawer;
_objects = objects;
_clientState = clientState;
_dataManager = dataManager;
@ -189,6 +191,7 @@ public class DebugTab : Window, ITab, IUiService
DrawData();
DrawCrcCache();
DrawResourceProblems();
_renderTargetDrawer.Draw();
_hookOverrides.Draw();
DrawPlayerModelInfo();
_globalVariablesDrawer.Draw();

View file

@ -0,0 +1,59 @@
using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel;
using FFXIVClientStructs.FFXIV.Client.Graphics.Render;
using ImGuiNET;
using OtterGui;
using OtterGui.Services;
using OtterGui.Text;
using Penumbra.Interop.Hooks.PostProcessing;
namespace Penumbra.UI.Tabs.Debug;
public class RenderTargetDrawer(RenderTargetHdrEnabler renderTargetHdrEnabler) : IUiService
{
/// <summary> Draw information about render targets. </summary>
public unsafe void Draw()
{
if (!ImUtf8.CollapsingHeader("Render Targets"u8))
return;
var report = renderTargetHdrEnabler.TextureReport;
if (report == null)
{
ImUtf8.Text("The RenderTargetManager report has not been gathered."u8);
ImUtf8.Text("Please restart the game with Debug Mode and Wait for Plugins on Startup enabled to fill this section."u8);
return;
}
using var table = ImUtf8.Table("##RenderTargetTable"u8, 5, ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingFixedFit);
if (!table)
return;
ImUtf8.TableSetupColumn("Offset"u8, ImGuiTableColumnFlags.WidthStretch, 0.15f);
ImUtf8.TableSetupColumn("Creation Order"u8, ImGuiTableColumnFlags.WidthStretch, 0.15f);
ImUtf8.TableSetupColumn("Original Texture Format"u8, ImGuiTableColumnFlags.WidthStretch, 0.2f);
ImUtf8.TableSetupColumn("Current Texture Format"u8, ImGuiTableColumnFlags.WidthStretch, 0.2f);
ImUtf8.TableSetupColumn("Comment"u8, ImGuiTableColumnFlags.WidthStretch, 0.3f);
ImGui.TableHeadersRow();
foreach (var record in report)
{
ImUtf8.DrawTableColumn($"0x{record.Offset:X}");
ImUtf8.DrawTableColumn($"{record.CreationOrder}");
ImUtf8.DrawTableColumn($"{record.OriginalTextureFormat}");
ImGui.TableNextColumn();
var texture = *(Texture**)((nint)RenderTargetManager.Instance()
+ record.Offset);
if (texture != null)
{
using var color = Dalamud.Interface.Utility.Raii.ImRaii.PushColor(ImGuiCol.Text, ImGuiUtil.HalfBlendText(0xFF),
texture->TextureFormat != record.OriginalTextureFormat);
ImUtf8.Text($"{texture->TextureFormat}");
}
ImGui.TableNextColumn();
var forcedConfig = RenderTargetHdrEnabler.GetForcedTextureConfig(record.CreationOrder);
if (forcedConfig.HasValue)
ImUtf8.Text(forcedConfig.Value.Comment);
}
}
}

View file

@ -10,6 +10,7 @@ using OtterGui.Compression;
using OtterGui.Custom;
using OtterGui.Raii;
using OtterGui.Services;
using OtterGui.Text;
using OtterGui.Widgets;
using Penumbra.Api;
using Penumbra.Collections;
@ -773,6 +774,7 @@ public class SettingsTab : ITab, IUiService
DrawCrashHandler();
DrawMinimumDimensionConfig();
DrawHdrRenderTargets();
Checkbox("Auto Deduplicate on Import",
"Automatically deduplicate mod files on import. This will make mod file sizes smaller, but deletes (binary identical) files.",
_config.AutoDeduplicateOnImport, v => _config.AutoDeduplicateOnImport = v);
@ -902,6 +904,33 @@ public class SettingsTab : ITab, IUiService
_config.Save();
}
private void DrawHdrRenderTargets()
{
ImGui.SetNextItemWidth(ImUtf8.CalcTextSize("M"u8).X * 5.0f + ImGui.GetFrameHeight());
using (var combo = ImUtf8.Combo("##hdrRenderTarget"u8, _config.HdrRenderTargets ? "HDR"u8 : "SDR"u8))
{
if (combo)
{
if (ImUtf8.Selectable("HDR"u8, _config.HdrRenderTargets) && !_config.HdrRenderTargets)
{
_config.HdrRenderTargets = true;
_config.Save();
}
if (ImUtf8.Selectable("SDR"u8, !_config.HdrRenderTargets) && _config.HdrRenderTargets)
{
_config.HdrRenderTargets = false;
_config.Save();
}
}
}
ImGui.SameLine();
ImUtf8.LabeledHelpMarker("Diffuse Dynamic Range"u8,
"Set the dynamic range that can be used for diffuse colors in materials without causing visual artifacts.\n"u8
+ "Changing this setting requires a game restart. It also only works if Wait for Plugins on Startup is enabled."u8);
}
/// <summary> Draw a checkbox for the HTTP API that creates and destroys the web server when toggled. </summary>
private void DrawEnableHttpApiBox()
{