Skip to content

Commit

Permalink
implement add_srgb_suffix for TextureFormat (#3419)
Browse files Browse the repository at this point in the history
  • Loading branch information
Elabajaba authored Jan 24, 2023
1 parent c039a74 commit 5da2b8a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ let texture = device.create_texture(&wgpu::TextureDescriptor {
- Implemented correleation between user timestamps and platform specific presentation timestamps via [`Adapter::get_presentation_timestamp`]. By @cwfitzgerald in [#3240](https://github.com/gfx-rs/wgpu/pull/3240)
- Added support for `Features::SHADER_PRIMITIVE_INDEX` on all backends. By @cwfitzgerald in [#3272](https://github.com/gfx-rs/wgpu/pull/3272)
- Implemented `TextureFormat::Stencil8`, allowing for stencil testing without depth components. By @Dinnerbone in [#3343](https://github.com/gfx-rs/wgpu/pull/3343)
- Implemented `add_srgb_suffix()` for `TextureFormat` for converting linear formats to sRGB. By @Elabajaba in [#3419](https://github.com/gfx-rs/wgpu/pull/3419)

#### GLES

Expand Down
23 changes: 23 additions & 0 deletions wgpu-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2580,6 +2580,29 @@ impl TextureFormat {
_ => *self,
}
}

/// Adds an `Srgb` suffix to the given texture format, if the format supports it.
pub fn add_srgb_suffix(&self) -> TextureFormat {
match *self {
Self::Rgba8Unorm => Self::Rgba8UnormSrgb,
Self::Bgra8Unorm => Self::Bgra8UnormSrgb,
Self::Bc1RgbaUnorm => Self::Bc1RgbaUnormSrgb,
Self::Bc2RgbaUnorm => Self::Bc2RgbaUnormSrgb,
Self::Bc3RgbaUnorm => Self::Bc3RgbaUnormSrgb,
Self::Bc7RgbaUnorm => Self::Bc7RgbaUnormSrgb,
Self::Etc2Rgb8Unorm => Self::Etc2Rgb8UnormSrgb,
Self::Etc2Rgb8A1Unorm => Self::Etc2Rgb8A1UnormSrgb,
Self::Etc2Rgba8Unorm => Self::Etc2Rgba8UnormSrgb,
Self::Astc {
block,
channel: AstcChannel::Unorm,
} => Self::Astc {
block,
channel: AstcChannel::UnormSrgb,
},
_ => *self,
}
}
}

#[test]
Expand Down

0 comments on commit 5da2b8a

Please sign in to comment.