Merge branch 'lut3x1d' into 'master'

color_transform: Introduce COLOR_TRANSFORM_LUT_3x1D

See merge request wlroots/wlroots!4818
This commit is contained in:
Alexander Orzechowski 2025-02-16 02:12:15 +00:00
commit d6faa807b7
8 changed files with 450 additions and 232 deletions

View file

@ -7,6 +7,7 @@
enum wlr_color_transform_type {
COLOR_TRANSFORM_SRGB,
COLOR_TRANSFORM_LUT_3D,
COLOR_TRANSFORM_LUT_3x1D,
};
struct wlr_color_transform {
@ -37,6 +38,36 @@ struct wlr_color_transform_lut3d {
size_t dim_len;
};
/**
* This is a color transform that is specified by three seperate ramps that
* modify the RGB values individually. This means that this color transform type
* cannot be used to create a transform that can infruence color channels
* depending on the values of other color channels.
*
* This color transform is modeled off of the wlr-gamma-control-unstable-v1
* wayland protocol.
*
* The memory layout of this type requires that the r, g, b color channel ramps
* are inline in memory. A ramp value can be retrieved from memory:
*
* offset = dim_len * rgb_channel_index + ramp_index
*
* This is an offset into the `r` pointer and can be used to retrieve the ramps
* from the other channels as the ramps are linear in memory. The three pointers
* are given for convenience.
*
* Note that when freeing the color transform, only the `r` channel is freed as
* a it's expected that a single malloc will allocate all three channels at once.
*/
struct wlr_color_transform_lut3x1d {
struct wlr_color_transform base;
uint16_t *r;
uint16_t *g;
uint16_t *b;
size_t ramp_size;
};
/**
* Gets a wlr_color_transform_lut3d from a generic wlr_color_transform.
* Asserts that the base type is COLOR_TRANSFORM_LUT_3D
@ -44,4 +75,11 @@ struct wlr_color_transform_lut3d {
struct wlr_color_transform_lut3d *wlr_color_transform_lut3d_from_base(
struct wlr_color_transform *tr);
/**
* Gets a wlr_color_transform_lut3x1d from a generic wlr_color_transform.
* Asserts that the base type is COLOR_TRANSFORM_LUT_3x1D
*/
struct wlr_color_transform_lut3x1d *wlr_color_transform_lut3x1d_from_base(
struct wlr_color_transform *tr);
#endif

View file

@ -163,6 +163,7 @@ enum wlr_vk_shader_source {
enum wlr_vk_output_transform {
WLR_VK_OUTPUT_TRANSFORM_INVERSE_SRGB = 0,
WLR_VK_OUTPUT_TRANSFORM_LUT3D = 1,
WLR_VK_OUTPUT_TRANSFORM_LUT3x1D = 2,
};
struct wlr_vk_pipeline_key {
@ -193,6 +194,7 @@ struct wlr_vk_render_format_setup {
VkPipeline output_pipe_srgb;
VkPipeline output_pipe_lut3d;
VkPipeline output_pipe_lut3x1d;
struct wlr_vk_renderer *renderer;
struct wl_list pipelines; // struct wlr_vk_pipeline.link
@ -271,7 +273,9 @@ struct wlr_vk_renderer {
VkShaderModule vert_module;
VkShaderModule tex_frag_module;
VkShaderModule quad_frag_module;
VkShaderModule output_module;
VkShaderModule output_module_srgb;
VkShaderModule output_module_3d_lut;
VkShaderModule output_module_3x1d_lut;
struct wl_list pipeline_layouts; // struct wlr_vk_pipeline_layout.link
@ -280,19 +284,10 @@ struct wlr_vk_renderer {
VkDescriptorSetLayout output_ds_srgb_layout;
VkDescriptorSetLayout output_ds_lut3d_layout;
VkSampler output_sampler_lut3d;
// descriptor set indicating dummy 1x1x1 image, for use in the lut3d slot
VkDescriptorSet output_ds_lut3d_dummy;
struct wlr_vk_descriptor_pool *output_ds_lut3d_dummy_pool;
size_t last_output_pool_size;
struct wl_list output_descriptor_pools; // wlr_vk_descriptor_pool.link
// dummy sampler to bind when output shader is not using a lookup table
VkImage dummy3d_image;
VkDeviceMemory dummy3d_mem;
VkImageView dummy3d_image_view;
bool dummy3d_image_transitioned;
VkSemaphore timeline_semaphore;
uint64_t timeline_point;
@ -521,7 +516,7 @@ struct wlr_vk_color_transform {
VkDeviceMemory memory;
VkDescriptorSet ds;
struct wlr_vk_descriptor_pool *ds_pool;
} lut_3d;
} lut;
};
void vk_color_transform_destroy(struct wlr_addon *addon);