Skip to content

Commit 39c9d1a

Browse files
mahkohkasper93
authored andcommitted
video/out/vulkan/context_wayland: implement target_csp for wayland
This implements target_csp in terms of the preferred color description of the video surface.
1 parent e72bc1f commit 39c9d1a

File tree

6 files changed

+166
-77
lines changed

6 files changed

+166
-77
lines changed

video/out/gpu/context.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ struct ra_ctx_fns {
6363
void (*uninit)(struct ra_ctx *ctx);
6464
};
6565

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

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

@@ -104,8 +109,6 @@ struct ra_fbo {
104109
struct pl_color_space color_space;
105110
};
106111

107-
typedef struct pl_color_space pl_color_space_t;
108-
109112
struct ra_swapchain_fns {
110113
// Gets the current framebuffer depth in bits (0 if unknown). Optional.
111114
int (*color_depth)(struct ra_swapchain *sw);

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 (pl_color_space_t){0};
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/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 (pl_color_space_t){0};
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;
@@ -83,6 +88,7 @@ static bool wayland_vk_init(struct ra_ctx *ctx)
8388

8489
struct ra_ctx_params params = {
8590
.check_visible = wayland_vk_check_visible,
91+
.preferred_csp = wayland_vk_preferred_csp,
8692
.swap_buffers = wayland_vk_swap_buffers,
8793
.get_vsync = wayland_vk_get_vsync,
8894
};

0 commit comments

Comments
 (0)