This PR adds HDR support for Windows for `VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT` on `VK_FORMAT_R16G16B16A16_SFLOAT` swapchains . For nonlinear surface formats (sRGB and extended sRGB) the back buffer is blit into the swapchain, When VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT is used as surface format a compute shader is used to flip and invert the gamma. SDR white level is updated from a few window event changes, but actually none of them immediately respond to SDR white level changes in the system. That requires using the WinRT API, which we don't do so far. Current limitations: - Intel GPU support - Dual GPU support In the future we may add controls inside Blender for absolute HDR nits, across different platforms. But this makes behavior closer to macOS. See !144565 for details Co-authored-by: Brecht Van Lommel <brecht@blender.org> Pull Request: https://projects.blender.org/blender/blender/pulls/144717
26 lines
853 B
GLSL
26 lines
853 B
GLSL
/* SPDX-FileCopyrightText: 2025 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#include "vk_backbuffer_blit_info.hh"
|
|
|
|
COMPUTE_SHADER_CREATE_INFO(vk_backbuffer_blit)
|
|
|
|
void main()
|
|
{
|
|
ivec2 dst_texel = ivec2(gl_GlobalInvocationID.xy);
|
|
ivec2 src_size = ivec2(imageSize(src_img));
|
|
ivec2 src_texel = ivec2(dst_texel.x, src_size.y - dst_texel.y - 1);
|
|
vec4 color = imageLoad(src_img, ivec2(src_texel));
|
|
/*
|
|
* Convert from extended sRGB non-linear to linear.
|
|
*
|
|
* Preserves negative wide gamut values with sign/abs.
|
|
* Gamma 2.2 is used instead of the sRGB piecewise transfer function, because
|
|
* most SDR sRGB displays decode with gamma 2.2, and that's what we are trying
|
|
* to match.
|
|
*/
|
|
color.rgb = sign(color.rgb) * pow(abs(color.rgb), vec3(2.2f)) * sdr_scale;
|
|
imageStore(dst_img, ivec2(dst_texel), color);
|
|
}
|