Skip to content

D3D12: Fix HDR rendering pipeline, resource states, and overlay support#18692

Merged
LibretroAdmin merged 1 commit intolibretro:masterfrom
MajorPainTheCactus:d3d12-hdr-fixes
Feb 5, 2026
Merged

D3D12: Fix HDR rendering pipeline, resource states, and overlay support#18692
LibretroAdmin merged 1 commit intolibretro:masterfrom
MajorPainTheCactus:d3d12-hdr-fixes

Conversation

@MajorPainTheCactus
Copy link
Copy Markdown
Contributor

@MajorPainTheCactus MajorPainTheCactus commented Feb 4, 2026

Summary

  • Separate HDR pipeline states: Adds pipe_blend_hdr, pipe_noblend_hdr, and pipe_font_hdr for R10G10B10A2 render targets, with runtime pipeline selection based on the current render target format tracked via a new current_rt_format field
  • Resource state fixes: Creates render target textures in RENDER_TARGET state instead of PIXEL_SHADER_RESOURCE, adds mipmap generation with zero-size level guards, and moves resource transitions to correct positions in the frame loop with missing back buffer transitions added after HDR compositing
  • Mipmap generation restored: Restores the separate d3d12_generate_mipmaps function, proper mip level calculation, and MipLevels = 0 initialization for render targets to enable automatic mipmap generation (reverting the revert in revert mipmap changes from 66a7657 #18686)
  • HDR compositing fixes: Always uses R8G8B8A8_UNORM for the intermediate back buffer regardless of shader preset format, sets root signature before descriptor table binds, populates source/output size in the HDR UBO, and sets the blend pipeline after menu texture upload
  • Overlay support: Extends HDR back buffer compositing to handle overlays in addition to the menu (D3D12_ST_FLAG_OVERLAYS_ENABLE)
  • Descriptor heap fix: Only requests GPU descriptor handle for shader-visible heaps to avoid D3D12 validation errors

@MajorPainTheCactus
Copy link
Copy Markdown
Contributor Author

Hi @hizzlekizzle sorry we've been treading on each others feet a bit. I presume you reverted the mip map changes in an attempt to fix all the flashing issues? I've just hopefully fixed all those issues so shall we put the mipmap changes back in or was there another reason for reverting those changes?

@MajorPainTheCactus
Copy link
Copy Markdown
Contributor Author

@hizzlekizzle I just reverted your mip map changes revert (ie I brought the original changes back in) locally to fix my build so just let me know if it was just for test purposes and I can push them back into fix this PR.

@hizzlekizzle
Copy link
Copy Markdown
Collaborator

hey man, sorry, i never saw those notifications for some reason. If your changes fix everything even with the mip changes, go for it!

I only reverted them because it started happening with my changes, but I wasn’t able to determine what was actually wrong, so if your work fixes the root cause, I would love to have working mipmaps lol

@LibretroAdmin
Copy link
Copy Markdown
Contributor

@MajorPainTheCactus Can you look at the CI build errors?

@MajorPainTheCactus
Copy link
Copy Markdown
Contributor Author

MajorPainTheCactus commented Feb 5, 2026

Great stuff, thanks, Ill resubmit the mip map stuff and a few other fixes, sorry for causing the confusion. There were a lot of bugs I squished so dx12 should be a lot better. Ill submit the changes in a few hours.

Add separate HDR pipeline states (pipe_blend_hdr, pipe_noblend_hdr,
pipe_font_hdr) for R10G10B10A2 render targets and select the correct
pipeline based on the current render target format, tracked via a new
current_rt_format field.

Fix resource state management: create render target textures in
RENDER_TARGET state instead of PIXEL_SHADER_RESOURCE, add mipmap
generation with zero-size level guards, move resource transitions
to correct positions in the frame loop, and add missing back buffer
transitions after HDR compositing.

Fix HDR compositing: always use R8G8B8A8_UNORM for the intermediate
back buffer regardless of shader preset format, set root signature
before descriptor table binds, populate source/output size in the
HDR UBO, and set the blend pipeline after menu texture upload.

Extend HDR back buffer compositing to handle overlays in addition
to the menu (D3D12_ST_FLAG_OVERLAYS_ENABLE).

Only request GPU descriptor handle for shader-visible descriptor
heaps to avoid D3D12 validation errors.
@LibretroAdmin LibretroAdmin merged commit 7df941e into libretro:master Feb 5, 2026
35 checks passed
@sonninnos
Copy link
Copy Markdown
Collaborator

sonninnos commented Feb 6, 2026

RGUI flashing is indeed gone now, but Explore menu still crashes with Ozone and XMB..

@MajorPainTheCactus MajorPainTheCactus deleted the d3d12-hdr-fixes branch February 16, 2026 09:36
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