aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2026-07-14 21:06:27 +0200
committerdec05eba <dec05eba@protonmail.com>2026-07-14 21:06:27 +0200
commit7a5785e4dfd023dc5e037ad535f5b7aa26278ff4 (patch)
tree579ca25730412d890210721ac09b9ba4c02b9ca2 /include
parent174192d5605c51b41f39bb8c5de1abc1edc8a106 (diff)
kms capture: implement hdr to sdr tonemapping
Diffstat (limited to 'include')
-rw-r--r--include/color_conversion.h16
-rw-r--r--include/defs.h6
-rw-r--r--include/egl.h1
-rw-r--r--include/window/window.h2
4 files changed, 24 insertions, 1 deletions
diff --git a/include/color_conversion.h b/include/color_conversion.h
index f1f1b29..7950472 100644
--- a/include/color_conversion.h
+++ b/include/color_conversion.h
@@ -6,7 +6,7 @@
#include "vec2.h"
#include <stdbool.h>
-#define GSR_COLOR_CONVERSION_MAX_GRAPHICS_SHADERS 12
+#define GSR_COLOR_CONVERSION_MAX_GRAPHICS_SHADERS 18
#define GSR_COLOR_CONVERSION_MAX_FRAMEBUFFERS 2
typedef enum {
@@ -37,6 +37,10 @@ typedef enum {
typedef struct {
int rotation_matrix;
int offset;
+ int hdr_source_max_pq;
+ int hdr_sdr_white_pq;
+ int hdr_sdr_white_scale;
+ int gamma_lut_enabled;
} gsr_color_graphics_uniforms;
typedef struct {
@@ -64,6 +68,13 @@ typedef struct {
unsigned int vertex_buffer_object_id;
bool schedule_clear;
+ float hdr_source_max_pq;
+ float hdr_sdr_white_pq;
+ float hdr_sdr_white_scale;
+ unsigned int gamma_lut_texture_id;
+ bool gamma_lut_apply;
+ bool hdr_shaders_loaded;
+ bool hdr_shaders_load_failed;
} gsr_color_conversion;
int gsr_color_conversion_init(gsr_color_conversion *self, const gsr_color_conversion_params *params);
@@ -71,6 +82,9 @@ void gsr_color_conversion_deinit(gsr_color_conversion *self);
void gsr_color_conversion_draw(gsr_color_conversion *self, unsigned int texture_id, vec2i destination_pos, vec2i destination_size, vec2i source_pos, vec2i source_size, vec2i texture_size, gsr_rotation rotation, gsr_flip flip, gsr_source_color source_color, bool external_texture);
void gsr_color_conversion_clear(gsr_color_conversion *self);
+void gsr_color_conversion_set_hdr_to_sdr_tone_mapping(gsr_color_conversion *self, bool enable, float hdr_peak_luminance, float sdr_white_luminance);
+void gsr_color_conversion_set_gamma_lut(gsr_color_conversion *self, const float *rgb_values, int num_entries);
+void gsr_color_conversion_enable_gamma_lut(gsr_color_conversion *self, bool enable);
void gsr_color_conversion_read_destination_texture(gsr_color_conversion *self, int destination_texture_index, int x, int y, int width, int height, unsigned int color_format, unsigned int data_format, void *pixels);
gsr_rotation gsr_monitor_rotation_to_rotation(gsr_monitor_rotation monitor_rotation);
diff --git a/include/defs.h b/include/defs.h
index d6de6d8..7aa9d32 100644
--- a/include/defs.h
+++ b/include/defs.h
@@ -26,6 +26,12 @@ typedef enum {
GSR_MONITOR_ROT_270,
} gsr_monitor_rotation;
+typedef struct {
+ bool hdr_enabled;
+ float sdr_white_luminance; /* cd/m² (nits) */
+ float max_peak_luminance; /* cd/m² (nits) */
+} gsr_monitor_hdr_info;
+
typedef enum {
GSR_CONNECTION_X11,
GSR_CONNECTION_WAYLAND,
diff --git a/include/egl.h b/include/egl.h
index 57fa7ff..c9c54e5 100644
--- a/include/egl.h
+++ b/include/egl.h
@@ -112,6 +112,7 @@ typedef void(*__GLXextFuncPtr)(void);
#define GL_RG16 0x822C
#define GL_RGB16 0x8054
#define GL_RGBA32F 0x8814
+#define GL_RGB32F 0x8815
#define GL_UNSIGNED_BYTE 0x1401
#define GL_COLOR_BUFFER_BIT 0x00004000
#define GL_TEXTURE_WRAP_S 0x2802
diff --git a/include/window/window.h b/include/window/window.h
index 7839f6a..959d325 100644
--- a/include/window/window.h
+++ b/include/window/window.h
@@ -21,6 +21,7 @@ struct gsr_window {
void* (*get_display)(gsr_window *self);
void* (*get_window)(gsr_window *self);
void (*for_each_active_monitor_output_cached)(const gsr_window *self, active_monitor_callback callback, void *userdata);
+ bool (*get_monitor_hdr_info)(const gsr_window *self, const char *monitor_name, gsr_monitor_hdr_info *hdr_info); /* can be NULL */
void *priv;
};
@@ -33,5 +34,6 @@ gsr_display_server gsr_window_get_display_server(const gsr_window *self);
void* gsr_window_get_display(gsr_window *self);
void* gsr_window_get_window(gsr_window *self);
void gsr_window_for_each_active_monitor_output_cached(const gsr_window *self, active_monitor_callback callback, void *userdata);
+bool gsr_window_get_monitor_hdr_info(const gsr_window *self, const char *monitor_name, gsr_monitor_hdr_info *hdr_info);
#endif /* GSR_WINDOW_H */