render/color, render/vulkan: add EXT_LINEAR to enum wlr_color_transfer_function

This commit is contained in:
Simon Ser 2025-02-23 14:57:04 +01:00
parent f5a0992686
commit 0ee0452af0
6 changed files with 22 additions and 7 deletions

View file

@ -237,6 +237,9 @@ static bool render_pass_submit(struct wlr_render_pass *wlr_pass) {
}
switch (tf) {
case WLR_COLOR_TRANSFER_FUNCTION_EXT_LINEAR:
pipeline = render_buffer->plain.render_setup->output_pipe_identity;
break;
case WLR_COLOR_TRANSFER_FUNCTION_SRGB:
pipeline = render_buffer->plain.render_setup->output_pipe_srgb;
break;

View file

@ -158,6 +158,7 @@ static void destroy_render_format_setup(struct wlr_vk_renderer *renderer,
VkDevice dev = renderer->dev->dev;
vkDestroyRenderPass(dev, setup->render_pass, NULL);
vkDestroyPipeline(dev, setup->output_pipe_identity, NULL);
vkDestroyPipeline(dev, setup->output_pipe_srgb, NULL);
vkDestroyPipeline(dev, setup->output_pipe_pq, NULL);
vkDestroyPipeline(dev, setup->output_pipe_lut3d, NULL);
@ -2294,6 +2295,11 @@ static struct wlr_vk_render_format_setup *find_or_create_render_setup(
}
// this is only well defined if render pass has a 2nd subpass
if (!init_blend_to_output_pipeline(
renderer, setup->render_pass, renderer->output_pipe_layout,
&setup->output_pipe_identity, WLR_VK_OUTPUT_TRANSFORM_IDENTITY)) {
goto error;
}
if (!init_blend_to_output_pipeline(
renderer, setup->render_pass, renderer->output_pipe_layout,
&setup->output_pipe_lut3d, WLR_VK_OUTPUT_TRANSFORM_LUT3D)) {

View file

@ -18,9 +18,10 @@ layout(push_constant, row_major) uniform UBO {
layout (constant_id = 0) const int OUTPUT_TRANSFORM = 0;
// Matches enum wlr_vk_output_transform
#define OUTPUT_TRANSFORM_INVERSE_SRGB 0
#define OUTPUT_TRANSFORM_INVERSE_ST2084_PQ 1
#define OUTPUT_TRANSFORM_LUT_3D 2
#define OUTPUT_TRANSFORM_IDENTITY 0
#define OUTPUT_TRANSFORM_INVERSE_SRGB 1
#define OUTPUT_TRANSFORM_INVERSE_ST2084_PQ 2
#define OUTPUT_TRANSFORM_LUT_3D 3
float linear_channel_to_srgb(float x) {
return max(min(x * 12.92, 0.04045), 1.055 * pow(x, 1. / 2.4) - 0.055);
@ -67,7 +68,7 @@ void main() {
rgb = texture(lut_3d, pos).rgb;
} else if (OUTPUT_TRANSFORM == OUTPUT_TRANSFORM_INVERSE_ST2084_PQ) {
rgb = linear_color_to_pq(rgb);
} else { // OUTPUT_TRANSFORM_INVERSE_SRGB
} else if (OUTPUT_TRANSFORM == OUTPUT_TRANSFORM_INVERSE_SRGB) {
// Produce sRGB encoded values
rgb = linear_color_to_srgb(rgb);
}