Skip to content

Commit 97357eb

Browse files
committed
example-runner-wpgu: force sRGB, even on wasm->WebGPU.
1 parent 7203a07 commit 97357eb

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

examples/runners/wgpu/src/graphics.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ async fn run(
155155
)
156156
});
157157

158+
// HACK(eddyb) this (alongside `.add_srgb_suffix()` calls elsewhere)
159+
// forces sRGB output, even on WebGPU (which handles it differently).
160+
surface_config
161+
.view_formats
162+
.push(surface_config.format.add_srgb_suffix());
163+
158164
// FIXME(eddyb) should this be toggled by a CLI arg?
159165
// NOTE(eddyb) VSync was disabled in the past, but without VSync,
160166
// especially for simpler shaders, you can easily hit thousands
@@ -185,7 +191,7 @@ async fn run(
185191
&pipeline_layout,
186192
surface_with_config.as_ref().map_or_else(
187193
|pending| pending.preferred_format,
188-
|(_, surface_config)| surface_config.format,
194+
|(_, surface_config)| surface_config.format.add_srgb_suffix(),
189195
),
190196
compiled_shader_modules,
191197
);
@@ -288,9 +294,10 @@ async fn run(
288294
return;
289295
}
290296
};
291-
let output_view = output
292-
.texture
293-
.create_view(&wgpu::TextureViewDescriptor::default());
297+
let output_view = output.texture.create_view(&wgpu::TextureViewDescriptor {
298+
format: Some(surface_config.format.add_srgb_suffix()),
299+
..wgpu::TextureViewDescriptor::default()
300+
});
294301
let mut encoder = device
295302
.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });
296303
{

0 commit comments

Comments
 (0)