mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-19 06:47:02 -04:00
render/vulkan: Support 3x1d color transforms
This commit is contained in:
parent
04563f88e1
commit
367c46e670
5 changed files with 236 additions and 1 deletions
|
|
@ -23,6 +23,7 @@ endforeach
|
|||
vulkan_shader_output_color_transforms = {
|
||||
'inverse_rgb': '0',
|
||||
'lut_3d': '1',
|
||||
'lut_3x1d': '2',
|
||||
}
|
||||
|
||||
foreach name, ident : vulkan_shader_output_color_transforms
|
||||
|
|
|
|||
|
|
@ -5,13 +5,20 @@ layout (input_attachment_index = 0, set = 0, binding = 0) uniform subpassInput i
|
|||
// Matches enum wlr_vk_output_transform
|
||||
#define OUTPUT_TRANSFORM_INVERSE_SRGB 0
|
||||
#define OUTPUT_TRANSFORM_LUT_3D 1
|
||||
#define OUTPUT_TRANSFORM_LUT_3x1D 2
|
||||
|
||||
layout(location = 0) in vec2 uv;
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
#if OUTPUT_TRANSFORM == OUTPUT_TRANSFORM_LUT_3x1D
|
||||
layout(set = 1, binding = 0) uniform sampler1D lut_3x1d;
|
||||
#endif
|
||||
|
||||
#if OUTPUT_TRANSFORM == OUTPUT_TRANSFORM_LUT_3D
|
||||
layout(set = 1, binding = 0) uniform sampler3D lut_3d;
|
||||
#endif
|
||||
|
||||
#if OUTPUT_TRANSFORM == OUTPUT_TRANSFORM_LUT_3D || OUTPUT_TRANSFORM == OUTPUT_TRANSFORM_LUT_3x1D
|
||||
/* struct wlr_vk_frag_output_pcr_data */
|
||||
layout(push_constant) uniform UBO {
|
||||
layout(offset = 80) float lut_3d_offset;
|
||||
|
|
@ -39,6 +46,15 @@ void main() {
|
|||
rgb = texture(lut_3d, pos).rgb;
|
||||
#endif
|
||||
|
||||
#if OUTPUT_TRANSFORM == OUTPUT_TRANSFORM_LUT_3x1D
|
||||
vec3 pos = data.lut_3d_offset + rgb * data.lut_3d_scale;
|
||||
rgb = vec3(
|
||||
texture(lut_3x1d, pos.r).r,
|
||||
texture(lut_3x1d, pos.g).g,
|
||||
texture(lut_3x1d, pos.b).b
|
||||
);
|
||||
#endif
|
||||
|
||||
#if OUTPUT_TRANSFORM == OUTPUT_TRANSFORM_INVERSE_SRGB
|
||||
rgb = vec3(
|
||||
linear_channel_to_srgb(rgb.r),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue