Skip to content

Commit

Permalink
gpu_ctx: add ngli_gpu_ctx_get_default_rendertarget_size()
Browse files Browse the repository at this point in the history
  • Loading branch information
mbouron committed Feb 12, 2024
1 parent f225d5c commit 9c5d35f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions libnopegl/src/backends/gl/gpu_ctx_gl.c
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,12 @@ static const struct rendertarget_layout *gl_get_default_rendertarget_layout(stru
return &s_priv->default_rt_layout;
}

static void gl_get_default_rendertarget_size(struct gpu_ctx *s, int32_t *width, int32_t *height)
{
*width = s->config.width;
*height = s->config.height;
}

static void gl_begin_render_pass(struct gpu_ctx *s, struct rendertarget *rt)
{
ngli_rendertarget_gl_begin_pass(rt);
Expand Down Expand Up @@ -1015,6 +1021,7 @@ const struct gpu_ctx_class ngli_gpu_ctx_##cls_suffix = {
\
.get_default_rendertarget = gl_get_default_rendertarget, \
.get_default_rendertarget_layout = gl_get_default_rendertarget_layout, \
.get_default_rendertarget_size = gl_get_default_rendertarget_size, \
\
.begin_render_pass = gl_begin_render_pass, \
.end_render_pass = gl_end_render_pass, \
Expand Down
8 changes: 8 additions & 0 deletions libnopegl/src/backends/vk/gpu_ctx_vk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1277,6 +1277,13 @@ static const struct rendertarget_layout *vk_get_default_rendertarget_layout(stru
return &s_priv->default_rt_layout;
}

static void vk_get_default_rendertarget_size(struct gpu_ctx *s, int32_t *width, int32_t *height)
{
struct gpu_ctx_vk *s_priv = (struct gpu_ctx_vk *)s;
*width = s_priv->width;
*height = s_priv->height;
}

static void vk_begin_render_pass(struct gpu_ctx *s, struct rendertarget *rt)
{
struct gpu_ctx_vk *s_priv = (struct gpu_ctx_vk *)s;
Expand Down Expand Up @@ -1470,6 +1477,7 @@ const struct gpu_ctx_class ngli_gpu_ctx_vk = {

.get_default_rendertarget = vk_get_default_rendertarget,
.get_default_rendertarget_layout = vk_get_default_rendertarget_layout,
.get_default_rendertarget_size = vk_get_default_rendertarget_size,

.begin_render_pass = vk_begin_render_pass,
.end_render_pass = vk_end_render_pass,
Expand Down
5 changes: 5 additions & 0 deletions libnopegl/src/gpu_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ const struct rendertarget_layout *ngli_gpu_ctx_get_default_rendertarget_layout(s
return s->cls->get_default_rendertarget_layout(s);
}

void ngli_gpu_ctx_get_default_rendertarget_size(struct gpu_ctx *s, int32_t *width, int32_t *height)
{
s->cls->get_default_rendertarget_size(s, width, height);
}

void ngli_gpu_ctx_set_viewport(struct gpu_ctx *s, const struct viewport *viewport)
{
s->viewport = *viewport;
Expand Down
2 changes: 2 additions & 0 deletions libnopegl/src/gpu_ctx.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ struct gpu_ctx_class {

struct rendertarget *(*get_default_rendertarget)(struct gpu_ctx *s, int load_op);
const struct rendertarget_layout *(*get_default_rendertarget_layout)(struct gpu_ctx *s);
void (*get_default_rendertarget_size)(struct gpu_ctx *s, int32_t *width, int32_t *height);

void (*begin_render_pass)(struct gpu_ctx *s, struct rendertarget *rt);
void (*end_render_pass)(struct gpu_ctx *s);
Expand Down Expand Up @@ -172,6 +173,7 @@ void ngli_gpu_ctx_get_rendertarget_uvcoord_matrix(struct gpu_ctx *s, float *dst)

struct rendertarget *ngli_gpu_ctx_get_default_rendertarget(struct gpu_ctx *s, int load_op);
const struct rendertarget_layout *ngli_gpu_ctx_get_default_rendertarget_layout(struct gpu_ctx *s);
void ngli_gpu_ctx_get_default_rendertarget_size(struct gpu_ctx *s, int32_t *width, int32_t *height);

void ngli_gpu_ctx_begin_render_pass(struct gpu_ctx *s, struct rendertarget *rt);
void ngli_gpu_ctx_end_render_pass(struct gpu_ctx *s);
Expand Down

0 comments on commit 9c5d35f

Please sign in to comment.