Fix screenshots on Wayland + Nvidia (#8701)

# Objective

Fix #8604

## Solution

Use `.add_srgb_suffix()` when creating the screenshot texture.
Allow converting `Bgra8Unorm` images.

Only a two line change for the fix, the `screenshot.rs` changes are just
a bit of cleanup.
This commit is contained in:
ira 2023-05-29 09:22:13 +02:00 committed by GitHub
parent d628ae808f
commit 5e3ae770ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 9 deletions

View file

@ -199,7 +199,7 @@ impl Image {
.map(DynamicImage::ImageRgba8),
// This format is commonly used as the format for the swapchain texture
// This conversion is added here to support screenshots
TextureFormat::Bgra8UnormSrgb => ImageBuffer::from_raw(
TextureFormat::Bgra8UnormSrgb | TextureFormat::Bgra8Unorm => ImageBuffer::from_raw(
self.texture_descriptor.size.width,
self.texture_descriptor.size.height,
{

View file

@ -377,7 +377,7 @@ pub fn prepare_windows(
mip_level_count: 1,
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: surface_configuration.format,
format: surface_configuration.format.add_srgb_suffix(),
usage: TextureUsages::RENDER_ATTACHMENT
| TextureUsages::COPY_SRC
| TextureUsages::TEXTURE_BINDING,

View file

@ -234,16 +234,11 @@ impl SpecializedRenderPipeline for ScreenshotToScreenPipeline {
shader: SCREENSHOT_SHADER_HANDLE.typed(),
},
primitive: wgpu::PrimitiveState {
topology: wgpu::PrimitiveTopology::TriangleList,
strip_index_format: None,
front_face: wgpu::FrontFace::Ccw,
cull_mode: Some(wgpu::Face::Back),
polygon_mode: wgpu::PolygonMode::Fill,
conservative: false,
unclipped_depth: false,
..Default::default()
},
depth_stencil: None,
multisample: wgpu::MultisampleState::default(),
multisample: Default::default(),
fragment: Some(FragmentState {
shader: SCREENSHOT_SHADER_HANDLE.typed(),
entry_point: Cow::Borrowed("fs_main"),