Skip to content

Fix ImGui rendering on HDR swap chains - #73

Merged
Fexty12573 merged 2 commits into
Fexty12573:masterfrom
UshioA:fix/imgui-hdr-rendering
Jul 22, 2026
Merged

Fix ImGui rendering on HDR swap chains#73
Fexty12573 merged 2 commits into
Fexty12573:masterfrom
UshioA:fix/imgui-hdr-rendering

Conversation

@UshioA

@UshioA UshioA commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Fixes ImGui rendering in HDR mode.

The D3D12 backend was using an R8G8B8A8_UNORM pipeline even when the
game's back buffer was R10G10B10A2_UNORM, which caused the UI to appear
extremely bright and blue (burnt my eyes when tinkering with World Tuning Tool).

This change uses the actual back-buffer format and converts ImGui's SDR
colors to HDR10/scRGB using a 203-nit graphics white. SDR rendering is unchanged.

Tested in DX12 HDR at 3840x2160. The UI now looks nearly identical
to SDR.

Copilot AI review requested due to automatic review settings July 19, 2026 15:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes incorrect ImGui rendering on HDR swap chains by selecting the actual back-buffer RTV format and applying appropriate SDR→HDR color conversion in the ImGui pixel shader (while leaving SDR output unchanged).

Changes:

  • Infer an ImGui “color space” from the swap chain back-buffer format and pass it into the ImGui D3D11/D3D12 backends.
  • Add an HDR-aware ImGui pixel shader (SDR/scRGB/HDR10 paths) and compile it with a define selected at runtime.
  • Wire the new header into the Visual Studio project so it’s included in the build.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
mhw-cs-plugin-loader/mhw-cs-plugin-loader.vcxproj.filters Adds the new ImGui HDR helper header to the VS filters.
mhw-cs-plugin-loader/mhw-cs-plugin-loader.vcxproj Adds the new ImGui HDR helper header to the project items.
mhw-cs-plugin-loader/D3DModule.cpp Detects back-buffer format and forwards RTV format + inferred color space into ImGui DX11/DX12 init.
dependencies/imgui/imgui_impl_dxgi_hdr.h Introduces a shared HDR-aware pixel shader and color-space enum/define helper.
dependencies/imgui/imgui_impl_dx12.h Extends DX12 init API to accept an optional color space parameter.
dependencies/imgui/imgui_impl_dx12.cpp Stores color space and compiles the shared pixel shader with the selected define.
dependencies/imgui/imgui_impl_dx11.h Extends DX11 init API to accept an optional color space parameter.
dependencies/imgui/imgui_impl_dx11.cpp Stores color space and compiles the shared pixel shader with the selected define.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Fexty12573 Fexty12573 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, thanks for the PR. Would you mind testing this on D3D11 as well?

@UshioA

UshioA commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

The UI looks normal on D3D11.
image

@Fexty12573
Fexty12573 merged commit 60335f4 into Fexty12573:master Jul 22, 2026
2 checks passed
@Pizzabelly

Copy link
Copy Markdown
Contributor

Were you able to observe the game using DXGI_FORMAT_R16G16B16A16_FLOAT for the swapchain? and if so, under what conditions. For me the game uses DXGI_FORMAT_R10G10B10A2_UNORM in HDR Mode. I'm not familiar with HDR so I don't know if there are other variables that could influence the games decision here.

Looking through RenderDoc, I can see that if Dynamic Range: 64-bit is selected the game uses DXGI_FORMAT_R16G16B16A16_FLOAT render targets for some internal passes. But by the time it gets to the swapchain, the output has already been reduced down to DXGI_FORMAT_R11G11B10_FLOAT.

@UshioA

UshioA commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Honest answer: I only tested HDR at 32-bit dynamic range (R10G10B10A2_UNORM on an HDR1000 display) — I never saw an FP16 swap chain, and I didn't test the 64-bit dynamic range option at all (I never used it and forgot about it completely). The scRGB branch was written from the general assumption that an FP16 swap chain implies scRGB output (with Codex ofc). If the game reduces to R11G11B10_FLOAT, that code path is probably wrong. I don't have an HDR display available for the next two weeks, so I can't verify on hardware right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants