Repository navigation
[mod:mafiade] HDR10 swap chain output option (fixes Intel XeFG frame generation) - #696
williamstosh wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
It alters the HDR-critical swap-chain output encoding path, which is correct by inspection but warrants a human HDR10/scRGB display check that cannot be performed in this automated review.
Review effort: Balanced
Findings: None
What changed in this PR
This PR adds an HDR10 swap chain output option to the Mafia: Definitive Edition (mafiade) mod. By default RenoDX upgrades this game's back buffer to FP16/scRGB, which Intel XeFG frame generation rejects (killing the swap chain). The change lets the mod output an HDR10 (PQ/BT.2020, r10g10b10a2_unorm) container while keeping scRGB as a fallback, and encodes in the shader for the format that actually exists rather than a requested setting.
Changes:
- Adds a global, advanced-only
Swap Chain Formattoggle (HDR10 default / scRGB) that drivesrenodx::mods::swapchain::SetUseHDR10, plus anOutput Dithertoggle for the 10-bit store. FinalizeOutputnow branches onswap_chain_output_preset: HDR10 doesbt2020::from::BT709+pq::EncodeSafe(color, 1.f)with optional ±0.5 LSB dither; scRGB keeps the priorcolor / 80path.OnInitSwapchainreads the real back-buffer format and setsswap_chain_output_preset(1 = HDR10, 2 = scRGB) so shaders never encode for a container that is not present yet.
| File | Description |
|---|---|
src/games/mafiade/addon.cpp |
Detects actual back-buffer format in OnInitSwapchain; adds Swap Chain Format and Output Dither global settings. |
src/games/mafiade/common.hlsl |
FinalizeOutput gains a position arg and a container-aware encode (HDR10 PQ/BT.2020 + dither, scRGB fallback). |
src/games/mafiade/shared.h |
Adds swap_chain_output_preset and swap_chain_output_dither_bits floats, keeping the cbuffer at 8 rows. |
src/games/mafiade/swap_chain_proxy_pixel_shader.ps_5_0.hlsl |
Passes vpos.xy into FinalizeOutput for dithering. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
805a28f to
fb04305
Compare
|
Rebased onto
Re-verified in game after the rebase: @voosh @clshortfuse — would appreciate a look when you have a moment. The build workflows (Clang/Ninja/VS, x64/x86) are all sitting in |
PR:
[mod:mafiade]HDR10 swap chain output option (fixes Intel XeFG frame generation)main@da608c4(fix(state): reduce tracking overhead) — verified still the tipfeat/mafiade-hdr10src/games/mafiade/{addon.cpp, shared.h, common.hlsl, swap_chain_proxy_pixel_shader.ps_5_0.hlsl})feat(mafiade): add HDR10 swap chain output optionWhat
Adds a Swap Chain Format option to the Mafia: Definitive Edition addon and lets the swap chain proxy
shaders encode for the format that is actually in use, instead of assuming scRGB.
Swap Chain FormatHDR10(default) /scRGBrenodx::mods::swapchain::SetUseHDR10()Output DitherOn(default) /OffWhy
Intel XeFG frame generation (OptiScaler
FGOutput=XeFG) rejects the FP16/scRGB back buffer RenoDXproduces by default, and the failure takes the whole swap chain — and the game — down with it:
With HDR10 the same stack comes up cleanly:
scRGB is kept as the alternative (and remains the mod's previous behaviour); HDR10 defaults on because
it is the only one of the two that frame generation accepts.
Implementation notes
OnInitSwapchainreads the createdback buffer's format into
shader_injection.swap_chain_output_preset(1= HDR10,2= scRGB), i.e.the same preset numbering used by
renodx::draw::SwapChainPass. ASwap Chain Formatchange onlyapplies once the swap chain is recreated, and this way the shaders can never encode for a container
that is not there yet.
FinalizeOutput(color, position)ends with the container encode, so it keeps a single call site andno extra single-use helper was introduced.
InvertFinalizeOutput()is untouched (scRGB convention);it is only used by the cosmetic fireworks pass.
bt2020::from::BT709()followed bypq::EncodeSafe(color, 1.f), matching theexisting HDR10 output paths in
src/shadersand other games.renodx::draw::SwapChainPass:exp2(bits) - 1quantisation withrenodx::random::Generate(position + injectedData.random)(the mod already bindsrandomfor itsfilm grain).
Upgrade_UseSCRGBis deliberately the same global key aswutheringwaves/unrealengine(identical labels and value meaning). Easy to change to a mod-specific key if you would rather not
share it.
boolis 1 byte in C++ but4 in HLSL, so adding two floats keeps the layout at 8 rows.
Manual verification
cmake --preset vs-x64thencmake --build --preset vs-x64-release --target mafiade(VS 2022, Windows 11) — builds clean.renodx-mafiade.addon64(RenoDX v0.2026.1004.717), loaded a save and played for 30-60 s, both formats:Output Ditheron.SwapchainProxyPass: no clonelines that the mod already tolerates.Reviewer question
The two new settings use
is_visible = []() { return settings[0]->GetValue() >= 2; }, matching theUpgrade_*precedent, so they only show up in the advanced settings mode.