Skip to content

Support surface view formats without VK_KHR_swapchain_mutable_format - #10357

Open
beicause wants to merge 7 commits into
gfx-rs:trunkfrom
beicause:fix/10340-swapchain-mutable-format
Open

beicause wants to merge 7 commits into
gfx-rs:trunkfrom
beicause:fix/10340-swapchain-mutable-format

Conversation

@beicause

Copy link
Copy Markdown
Contributor

Connections
Fixes #10340

Description

Solution:

  • Whether the swapchain images can carry view formats other than the surface format is now reported per surface by
    wgpu_hal::SurfaceCapabilities::native_view_formats.
  • Vulkan reports false when VK_KHR_swapchain_mutable_format is unavailable, Metal and DX12 always report true, and GLES reports false. When the capability is missing, wgpu-core emulates the differing view formats by handing out an intermediate texture that is copied into the swapchain image when presenting. So vulkan now always supports SURFACE_VIEW_FORMATS.

Testing
examples/bug-repro/02_present_bugs can now exercise both the native and the emulated path with --emulate-view-formats, draw a clear pass into the sRGB view of the non-sRGB surface format with --draw-before-present, and keep presenting until the window is closed with --manual-close.
To manually test it:

cargo run -p wgpu-bug-repro-02-present-bugs -- --draw-before-present --manual-close --emulate-view-formats

Squash or Rebase?
Squash

Checklist

  • I self-reviewed and fully understand this PR.
  • CHANGELOG.md entries for the user-facing effects of this change are present.
  • The PR is minimal, and doesn't make sense to land as multiple PRs.
  • Commits are logically scoped and individually reviewable.
  • The PR description has enough context to understand the motivation and solution implemented.
  • (If applicable) WebGPU implementations built with wgpu may be affected behaviorally.
  • (If applicable) Validation and feature gates are in place to confine behavioral changes.
  • (If applicable) Tests demonstrate the validation and altered logic works.

Whether the swapchain images can carry view formats other than the surface
format is now reported per surface by
`wgpu_hal::SurfaceCapabilities::native_view_formats`.

Vulkan reports `false` when `VK_KHR_swapchain_mutable_format` is unavailable,
Metal and DX12 always report `true`, and GLES reports `false`. When the
capability is missing, wgpu-core emulates the differing view formats by
handing out an intermediate texture that is copied into the swapchain image
when presenting.

`examples/bug-repro/02_present_bugs` can now exercise both the native and the
emulated path with `--emulate-view-formats`, draw a clear pass into the sRGB
view of the non-sRGB surface format with `--draw-before-present`, and keep
presenting until the window is closed with `--manual-close`.
@cwfitzgerald cwfitzgerald self-assigned this Sep 16, 2026
@cwfitzgerald cwfitzgerald moved this from To triage to Large in Triage Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Large

Development

Successfully merging this pull request may close these issues.

Do we need SURFACE_VIEW_FORMATS in DownlevelFlags::compliant or at least in STRICT_WEBGPU_COMPLIANCE

2 participants