Skip to content

Commit e29a49b

Browse files
committed
Srgb surface
1 parent a5fe119 commit e29a49b

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

crates/bevy_render/src/view/window.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,16 +190,17 @@ pub fn prepare_windows(
190190
.unwrap();
191191
let caps = surface.get_capabilities(&render_adapter);
192192
let formats = caps.formats;
193-
// Explicitally request a format, otherwise fallback to the first available format
193+
// Explicitally request an sRBG format, otherwise fallback to the first available format.
194194
// For future HDR output support, we'll need to request a format that supports HDR,
195195
// but as of wgpu 0.15 that is not yet supported.
196-
// TODO: This works if https://github.com/gfx-rs/wgpu/pull/3409 lands in time for wgpu 0.15
197-
// Otherwise, we'll need to use sRGB formats (which WebGPU doesn't support).
198-
let format = if formats.contains(&TextureFormat::Rgba8Unorm) {
199-
TextureFormat::Rgba8Unorm
200-
} else if formats.contains(&TextureFormat::Bgra8Unorm) {
201-
TextureFormat::Bgra8Unorm
196+
let format = if formats.contains(&TextureFormat::Rgba8UnormSrgb) {
197+
TextureFormat::Rgba8UnormSrgb
198+
} else if formats.contains(&TextureFormat::Bgra8UnormSrgb) {
199+
TextureFormat::Bgra8UnormSrgb
202200
} else {
201+
// TODO: If this isn't an sRGB surface (eg. on webgpu), use an sRGB view_format on the SurfaceConfiguration.
202+
// TODO: webgpu doesn't support sRGB surfaces, and requires an sRGB view_format, but that was causing issues on Vulkan
203+
// so it's getting skipped for now.
203204
formats[0]
204205
};
205206
SurfaceData { surface, format }
@@ -224,6 +225,8 @@ pub fn prepare_windows(
224225
CompositeAlphaMode::PostMultiplied => wgpu::CompositeAlphaMode::PostMultiplied,
225226
CompositeAlphaMode::Inherit => wgpu::CompositeAlphaMode::Inherit,
226227
},
228+
// TODO: Figure out why Vulkan is spitting out tons of validation errors when attempting to use an sRGB view_format on the surface.
229+
view_formats: vec![],
227230
};
228231

229232
// A recurring issue is hitting `wgpu::SurfaceError::Timeout` on certain Linux

0 commit comments

Comments
 (0)