Skip to content

Commit

Permalink
example-runner-wpgu: force sRGB, even on wasm->WebGPU.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Apr 18, 2023
1 parent 3eee6e3 commit 1c05177
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions examples/runners/wgpu/src/graphics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,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
Expand Down Expand Up @@ -180,7 +186,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,
);
Expand Down Expand Up @@ -261,9 +267,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 });
{
Expand Down

0 comments on commit 1c05177

Please sign in to comment.