From 8f1d75b81ae208f279c9dc3079e8c9c2a3c2f7c0 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Sat, 15 Apr 2023 12:46:51 +0300 Subject: [PATCH] example-runner-wpgu: force sRGB, even on wasm->WebGPU. --- examples/runners/wgpu/src/graphics.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/examples/runners/wgpu/src/graphics.rs b/examples/runners/wgpu/src/graphics.rs index a98e06d2e0..685c96cf58 100644 --- a/examples/runners/wgpu/src/graphics.rs +++ b/examples/runners/wgpu/src/graphics.rs @@ -146,6 +146,12 @@ async fn run( ) }); + // HACK(eddyb) this (alongside `.add_srgb_suffix()` calls elsewhere) + // forces sRGB output, even on WebGPU (which handles it differently). + surface_config + .view_formats + .push(surface_config.format.add_srgb_suffix()); + // FIXME(eddyb) should this be toggled by a CLI arg? // NOTE(eddyb) VSync was disabled in the past, but without VSync, // especially for simpler shaders, you can easily hit thousands @@ -175,7 +181,7 @@ async fn run( &pipeline_layout, surface_with_config.as_ref().map_or_else( |pending| pending.preferred_format, - |(_, surface_config)| surface_config.format, + |(_, surface_config)| surface_config.format.add_srgb_suffix(), ), shader_binary, ); @@ -256,9 +262,10 @@ async fn run( return; } }; - let output_view = output - .texture - .create_view(&wgpu::TextureViewDescriptor::default()); + let output_view = output.texture.create_view(&wgpu::TextureViewDescriptor { + format: Some(surface_config.format.add_srgb_suffix()), + ..wgpu::TextureViewDescriptor::default() + }); let mut encoder = device .create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None }); {