From aa468606d1e9f17e71a48bcf4fedd8003088ef65 Mon Sep 17 00:00:00 2001 From: Jinlei Li Date: Wed, 9 Sep 2026 04:01:29 +0800 Subject: [PATCH] fix(metal): Disable framebuffer-only for alternate surface views (#10280) --- CHANGELOG.md | 1 + wgpu-hal/src/metal/surface.rs | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12b0ccfed..eceb51f88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -213,6 +213,7 @@ By @sagudev in [#10109](https://github.com/gfx-rs/wgpu/pull/10109). - Fix bind group resources for the task, mesh, fragment, and compute shader stages being bound from the wrong offsets whenever a bind group contained resources visible to the task or mesh stages, which could bind the wrong buffer, texture, or sampler to a shader slot. By @teoxoy in [#10043](https://github.com/gfx-rs/wgpu/issues/10043). - BREAKING: Advertise `CompositeAlphaMode::PreMultiplied` instead of `PostMultiplied`, matching the premultiplied alpha compositing that Core Animation actually performs for a non-opaque `CAMetalLayer`. By @nicoburns in [#9922](https://github.com/gfx-rs/wgpu/pull/9922). - If you previously hard-coded `PostMultiplied` to get a transparent macOS window, you will start receiving `UnsupportedAlphaMode` validation errors for this. Those affected should migrate to `PreMultiplied` instead. +- Fix a crash when creating a declared alternate sRGB view of a render-attachment-only surface with Metal API Validation enabled. By @jinleili in [#10280](https://github.com/gfx-rs/wgpu/pull/10280). #### GLES diff --git a/wgpu-hal/src/metal/surface.rs b/wgpu-hal/src/metal/surface.rs index 8846ea8dc..6365d9199 100644 --- a/wgpu-hal/src/metal/surface.rs +++ b/wgpu-hal/src/metal/surface.rs @@ -257,7 +257,12 @@ impl crate::Surface for super::Surface { *self.extent.write() = config.extent; let render_layer = self.render_layer.lock(); - let framebuffer_only = config.usage == wgt::TextureUses::COLOR_TARGET; + // Metal forbids creating alternate-format views of framebuffer-only textures. + let framebuffer_only = config.usage == wgt::TextureUses::COLOR_TARGET + && config + .view_formats + .iter() + .all(|format| *format == config.format); let display_sync = match config.present_mode { wgt::PresentMode::Fifo => true, wgt::PresentMode::Immediate => false,