Skip to content

Commit ea80c7d

Browse files
authored
hal/vulkan: Accurately map all formats except fp16 to use the non-linear sRGB color space (#8226)
1 parent 8cb94db commit ea80c7d

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ By @cwfitzgerald in [#8162](https://github.com/gfx-rs/wgpu/pull/8162).
222222

223223
- Fixed unwrap failed in context creation for some Android devices. By @uael in [#8024](https://github.com/gfx-rs/wgpu/pull/8024).
224224

225+
##### Vulkan
226+
227+
- Fixed wrong color format+space being reported versus what is hardcoded in `create_swapchain()`. By @MarijnS95 in [#8226](https://github.com/gfx-rs/wgpu/pull/8226).
228+
225229
#### naga
226230

227231
- [wgsl-in] Allow a trailing comma in `@blend_src(…)` attributes. By @ErichDonGubler in [#8137](https://github.com/gfx-rs/wgpu/pull/8137).

wgpu-hal/src/vulkan/conv.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,21 +161,22 @@ impl super::PrivateCapabilities {
161161
pub fn map_vk_surface_formats(sf: vk::SurfaceFormatKHR) -> Option<wgt::TextureFormat> {
162162
use ash::vk::Format as F;
163163
use wgt::TextureFormat as Tf;
164-
// List we care about pulled from https://vulkan.gpuinfo.org/listsurfaceformats.php
164+
// List we care about pulled from https://vulkan.gpuinfo.org/listsurfaceformats.php.
165+
// Device::create_swapchain() hardcodes linear scRGB for fp16, non-linear sRGB otherwise.
165166
Some(match sf.color_space {
166167
vk::ColorSpaceKHR::SRGB_NONLINEAR => match sf.format {
167168
F::B8G8R8A8_UNORM => Tf::Bgra8Unorm,
168169
F::B8G8R8A8_SRGB => Tf::Bgra8UnormSrgb,
169170
F::R8G8B8A8_SNORM => Tf::Rgba8Snorm,
170171
F::R8G8B8A8_UNORM => Tf::Rgba8Unorm,
171172
F::R8G8B8A8_SRGB => Tf::Rgba8UnormSrgb,
173+
F::R16G16B16A16_SNORM => Tf::Rgba16Snorm,
174+
F::R16G16B16A16_UNORM => Tf::Rgba16Unorm,
175+
F::A2B10G10R10_UNORM_PACK32 => Tf::Rgb10a2Unorm,
172176
_ => return None,
173177
},
174178
vk::ColorSpaceKHR::EXTENDED_SRGB_LINEAR_EXT => match sf.format {
175179
F::R16G16B16A16_SFLOAT => Tf::Rgba16Float,
176-
F::R16G16B16A16_SNORM => Tf::Rgba16Snorm,
177-
F::R16G16B16A16_UNORM => Tf::Rgba16Unorm,
178-
F::A2B10G10R10_UNORM_PACK32 => Tf::Rgb10a2Unorm,
179180
_ => return None,
180181
},
181182
_ => return None,

0 commit comments

Comments
 (0)