Add RenderTargetHdrEnabler

This commit is contained in:
Exter-N 2025-01-08 20:02:14 +01:00
parent 349241d0ab
commit f07780cf7b
8 changed files with 219 additions and 3 deletions

View file

@ -42,6 +42,7 @@ using Penumbra.Interop.Hooks.ResourceLoading;
using Penumbra.GameData.Files.StainMapStructs;
using Penumbra.String.Classes;
using Penumbra.UI.AdvancedWindow.Materials;
using CSGraphics = FFXIVClientStructs.FFXIV.Client.Graphics;
namespace Penumbra.UI.Tabs.Debug;
@ -104,6 +105,7 @@ public class DebugTab : Window, ITab, IUiService
private readonly RsfService _rsfService;
private readonly SchedulerResourceManagementService _schedulerService;
private readonly ObjectIdentification _objectIdentification;
private readonly RenderTargetHdrEnabler _renderTargetHdrEnabler;
public DebugTab(PerformanceTracker performance, Configuration config, CollectionManager collectionManager, ObjectManager objects,
IClientState clientState, IDataManager dataManager,
@ -114,7 +116,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, RenderTargetHdrEnabler renderTargetHdrEnabler)
: base("Penumbra Debug Window", ImGuiWindowFlags.NoCollapse)
{
IsOpen = true;
@ -154,6 +156,7 @@ public class DebugTab : Window, ITab, IUiService
_globalVariablesDrawer = globalVariablesDrawer;
_schedulerService = schedulerService;
_objectIdentification = objectIdentification;
_renderTargetHdrEnabler = renderTargetHdrEnabler;
_objects = objects;
_clientState = clientState;
_dataManager = dataManager;
@ -189,6 +192,7 @@ public class DebugTab : Window, ITab, IUiService
DrawData();
DrawCrcCache();
DrawResourceProblems();
DrawRenderTargets();
_hookOverrides.Draw();
DrawPlayerModelInfo();
_globalVariablesDrawer.Draw();
@ -1135,6 +1139,54 @@ public class DebugTab : Window, ITab, IUiService
}
/// <summary> Draw information about render targets. </summary>
private unsafe void DrawRenderTargets()
{
if (!ImGui.CollapsingHeader("Render Targets"))
return;
var report = _renderTargetHdrEnabler.TextureReport;
if (report == null)
{
ImGui.TextUnformatted("The RenderTargetManager report has not been gathered.");
ImGui.TextUnformatted("Please restart the game with Debug Mode and Wait for Plugins on Startup enabled to fill this section.");
return;
}
using var table = Table("##RenderTargetTable", 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)
{
ImGui.TableNextColumn();
ImUtf8.Text($"0x{record.Offset:X}");
ImGui.TableNextColumn();
ImUtf8.Text($"{record.CreationOrder}");
ImGui.TableNextColumn();
ImUtf8.Text($"{record.OriginalTextureFormat}");
ImGui.TableNextColumn();
var texture = *(CSGraphics.Kernel.Texture**)((nint)CSGraphics.Render.RenderTargetManager.Instance() + record.Offset);
if (texture != null)
{
using var color = 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)
ImGui.TextUnformatted(forcedConfig.Value.Comment);
}
}
/// <summary> Draw information about IPC options and availability. </summary>
private void DrawDebugTabIpc()
{

View file

@ -773,6 +773,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 +903,22 @@ public class SettingsTab : ITab, IUiService
_config.Save();
}
private void DrawHdrRenderTargets()
{
var item = _config.HdrRenderTargets ? 1 : 0;
ImGui.SetNextItemWidth(ImGui.CalcTextSize("M").X * 5.0f + ImGui.GetFrameHeight());
var edited = ImGui.Combo("##hdrRenderTarget", ref item, "SDR\0HDR\0");
ImGui.SameLine();
ImGuiUtil.LabeledHelpMarker("Diffuse Dynamic Range",
"Set the dynamic range that can be used for diffuse colors in materials without causing visual artifacts.\nChanging this setting requires a game restart. It also only works if Wait for Plugins on Startup is enabled.");
if (!edited)
return;
_config.HdrRenderTargets = item != 0;
_config.Save();
}
/// <summary> Draw a checkbox for the HTTP API that creates and destroys the web server when toggled. </summary>
private void DrawEnableHttpApiBox()
{