Skip to content

Commit 2951826

Browse files
committed
vo_gpu_next: implement target_csp for wayland
This implements target_csp in terms of the preferred color description of the video surface.
1 parent 139591a commit 2951826

File tree

7 files changed

+168
-77
lines changed

7 files changed

+168
-77
lines changed

video/out/gpu/context.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ struct ra_ctx_fns {
6262
void (*uninit)(struct ra_ctx *ctx);
6363
};
6464

65+
typedef struct pl_color_space pl_color_space_t;
66+
6567
// These are a set of helpers for ra_ctx providers based on ra_gl.
6668
// The init function also initializes ctx->ra and ctx->swapchain, so the user
6769
// doesn't have to do this manually. (Similarly, the uninit function will
@@ -75,6 +77,9 @@ struct ra_ctx_params {
7577
// See ra_swapchain_fns.color_depth.
7678
int (*color_depth)(struct ra_ctx *ctx);
7779

80+
// Preferred device color space. Optional.
81+
pl_color_space_t (*preferred_csp)(struct ra_ctx *ctx);
82+
7883
// See ra_swapchain_fns.get_vsync.
7984
void (*get_vsync)(struct ra_ctx *ctx, struct vo_vsync_info *info);
8085

@@ -103,7 +108,7 @@ struct ra_fbo {
103108
struct pl_color_space color_space;
104109
};
105110

106-
typedef struct pl_color_space pl_color_space_t;
111+
#define DEFAULT_TARGET_CSP (pl_color_space_t){ .transfer = PL_COLOR_TRC_PQ }
107112

108113
struct ra_swapchain_fns {
109114
// Gets the current framebuffer depth in bits (0 if unknown). Optional.

video/out/opengl/context.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,17 @@ static void ra_gl_ctx_get_vsync(struct ra_swapchain *sw,
305305
p->params.get_vsync(sw->ctx, info);
306306
}
307307

308+
static pl_color_space_t ra_gl_ctx_target_csp(struct ra_swapchain *sw)
309+
{
310+
struct priv *p = sw->priv;
311+
if (p->params.preferred_csp)
312+
return p->params.preferred_csp(sw->ctx);
313+
return DEFAULT_TARGET_CSP;
314+
}
315+
308316
static const struct ra_swapchain_fns ra_gl_swapchain_fns = {
309317
.color_depth = ra_gl_ctx_color_depth,
318+
.target_csp = ra_gl_ctx_target_csp,
310319
.start_frame = ra_gl_ctx_start_frame,
311320
.submit_frame = ra_gl_ctx_submit_frame,
312321
.swap_buffers = ra_gl_ctx_swap_buffers,

video/out/vo_gpu_next.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ static bool draw_frame(struct vo *vo, struct vo_frame *frame)
989989
// TODO: Implement this for all backends
990990
target_csp = sw->fns->target_csp
991991
? sw->fns->target_csp(sw)
992-
: (struct pl_color_space){ .transfer = PL_COLOR_TRC_PQ };
992+
: DEFAULT_TARGET_CSP;
993993
if (!pl_color_transfer_is_hdr(target_csp.transfer)) {
994994
target_csp.hdr.max_luma = 0;
995995
target_csp.hdr.min_luma = 0;

video/out/vulkan/context.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,17 @@ static void get_vsync(struct ra_swapchain *sw,
375375
p->params.get_vsync(sw->ctx, info);
376376
}
377377

378+
static pl_color_space_t target_csp(struct ra_swapchain *sw)
379+
{
380+
struct priv *p = sw->priv;
381+
if (p->params.preferred_csp)
382+
return p->params.preferred_csp(sw->ctx);
383+
return DEFAULT_TARGET_CSP;
384+
}
385+
378386
static const struct ra_swapchain_fns vulkan_swapchain = {
379387
.color_depth = color_depth,
388+
.target_csp = target_csp,
380389
.start_frame = start_frame,
381390
.submit_frame = submit_frame,
382391
.swap_buffers = swap_buffers,

video/out/vulkan/context_wayland.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ static bool wayland_vk_check_visible(struct ra_ctx *ctx)
3333
return vo_wayland_check_visible(ctx->vo);
3434
}
3535

36+
static pl_color_space_t wayland_vk_preferred_csp(struct ra_ctx *ctx)
37+
{
38+
return vo_wayland_preferred_csp(ctx->vo);
39+
}
40+
3641
static void wayland_vk_swap_buffers(struct ra_ctx *ctx)
3742
{
3843
struct vo_wayland_state *wl = ctx->vo->wl;
@@ -81,6 +86,7 @@ static bool wayland_vk_init(struct ra_ctx *ctx)
8186

8287
struct ra_ctx_params params = {
8388
.check_visible = wayland_vk_check_visible,
89+
.preferred_csp = wayland_vk_preferred_csp,
8490
.swap_buffers = wayland_vk_swap_buffers,
8591
.get_vsync = wayland_vk_get_vsync,
8692
};

0 commit comments

Comments
 (0)