Fix ImGui rendering on HDR swap chains - #73
Conversation
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
Looks good overall, thanks for the PR. Would you mind testing this on D3D11 as well?
|
Were you able to observe the game using Looking through RenderDoc, I can see that if |
|
Honest answer: I only tested HDR at 32-bit dynamic range ( |

Fixes ImGui rendering in HDR mode.
The D3D12 backend was using an
R8G8B8A8_UNORMpipeline even when thegame's back buffer was
R10G10B10A2_UNORM, which caused the UI to appearextremely 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.