Skip to content

Vulkan: Fix HDR render pass format mismatch on first frame#18743

Merged
warmenhoven merged 1 commit intolibretro:masterfrom
MajorPainTheCactus:fix-vulkan-hdr-first-frame-renderpass-mismatch
Feb 17, 2026
Merged

Vulkan: Fix HDR render pass format mismatch on first frame#18743
warmenhoven merged 1 commit intolibretro:masterfrom
MajorPainTheCactus:fix-vulkan-hdr-first-frame-renderpass-mismatch

Conversation

@MajorPainTheCactus
Copy link
Contributor

Summary

  • Fixes Vulkan validation errors when HDR is enabled on macOS (MoltenVK), where vkCmdDraw() reports incompatible render pass formats: VK_FORMAT_A2B10G10R10_UNORM_PACK32 vs VK_FORMAT_B8G8R8A8_UNORM
  • Root cause: vulkan_init() sets VK_FLAG_SHOULD_RESIZE but the HDR offscreen buffer isn't created until the end-of-frame resize handler runs, so the first frame draws menu/overlay with SDR-format pipelines inside the HDR-format render pass
  • Fix creates the offscreen buffers in vulkan_init() when VK_CTX_FLAG_HDR_ENABLE is already set, so they exist for the first frame. The end-of-frame resize handler safely destroys and recreates them as before

When HDR is enabled, the first frame after vulkan_init() causes
validation errors because the HDR offscreen buffer doesn't exist yet
(it's created in the end-of-frame resize handler). This means menu
drawing occurs inside the HDR render pass (A2B10G10R10) using
pipelines compiled for the SDR render pass (B8G8R8A8).

Create the offscreen buffers in vulkan_init() when HDR is already
enabled so they're ready for the first frame. The end-of-frame
resize handler will safely destroy and recreate them.
@MajorPainTheCactus
Copy link
Contributor Author

This is hopefully the fix for issue:

#18740

@warmenhoven I dont know if you can test this for me on MacOS when you get a chance?

I'm just going off your comment that happens when you swap over to HDR - feels like a first frame issue. Thanks

@warmenhoven
Copy link
Collaborator

Yep, this definitely seems to fix it, I don't see any more validation errors!

@MajorPainTheCactus
Copy link
Contributor Author

MajorPainTheCactus commented Feb 16, 2026

@warmenhoven Blinking heck you work quick - the PR hasn't even finished the checks lol! Great stuff well done we've cracked the nut, we can all go home and rest.

@warmenhoven warmenhoven merged commit bd36dae into libretro:master Feb 17, 2026
35 checks passed
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.

2 participants

Comments