Skip to content

Commit e4534ee

Browse files
committed
support HDR output
1 parent 56bd026 commit e4534ee

File tree

1 file changed

+14
-5
lines changed
  • crates/bevy_render/src/view/window

1 file changed

+14
-5
lines changed

crates/bevy_render/src/view/window/mod.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,15 +338,24 @@ pub fn create_surfaces(
338338
// For future HDR output support, we'll need to request a format that supports HDR,
339339
// but as of wgpu 0.15 that is not yet supported.
340340
// Prefer sRGB formats for surfaces, but fall back to first available format if no sRGB formats are available.
341-
let mut format = *formats.first().expect("No supported formats for surface");
341+
let mut sdr_format = None;
342+
let mut hdr_format = None;
342343
for available_format in formats {
343344
// Rgba8UnormSrgb and Bgra8UnormSrgb and the only sRGB formats wgpu exposes that we can use for surfaces.
344-
if available_format == TextureFormat::Rgba8UnormSrgb
345-
|| available_format == TextureFormat::Bgra8UnormSrgb
345+
if sdr_format.is_none() && (available_format == TextureFormat::Rgba8UnormSrgb
346+
|| available_format == TextureFormat::Bgra8UnormSrgb)
346347
{
347-
format = available_format;
348-
break;
348+
sdr_format = Some(available_format);
349349
}
350+
if hdr_format.is_none() && available_format == TextureFormat::Rgba16Float
351+
{
352+
hdr_format = Some(available_format);
353+
}
354+
355+
}
356+
let format = hdr_format.or(sdr_format).expect("No supported formats for surface");
357+
if format == TextureFormat::Rgba16Float {
358+
bevy_utils::tracing::info!("HDR ENABLED");
350359
}
351360

352361
let configuration = SurfaceConfiguration {

0 commit comments

Comments
 (0)