Skip to content

Commit

Permalink
vo_opengl: make blitting an explicit capability
Browse files Browse the repository at this point in the history
Instead of merging it into render_dst. This is better for vulkan,
because blitting in vulkan both does not require a FBO *and* requires a
different image layout.

Also less "hacky" for OpenGL, since now the weird blit=FBO requirement
is an implementation detail of ra_gl
  • Loading branch information
haasn committed Aug 17, 2017
1 parent 8209376 commit 9ca5a2a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions video/out/opengl/ra.h
Expand Up @@ -90,7 +90,8 @@ struct ra_tex_params {
const struct ra_format *format;
bool render_src; // must be useable as source texture in a shader
bool render_dst; // must be useable as target texture in a shader
// this requires creation of a FBO
bool blit_src; // must be usable as a blit source
bool blit_dst; // must be usable as a blit destination
// When used as render source texture.
bool src_linear; // if false, use nearest sampling (whether this can
// be true depends on ra_format.linear_filter)
Expand Down Expand Up @@ -359,8 +360,7 @@ struct ra_fns {
// preserved. The formats of the textures must be losely compatible. The
// dst texture can be a swapchain framebuffer, but src can not. Only 2D
// textures are supported.
// Both textures must have tex->params.render_dst==true (even src, which is
// an odd GL requirement).
// The textures must have blit_src and blit_dst set, respectively.
// Rectangles with negative width/height lead to flipping, different src/dst
// sizes lead to point scaling. Coordinates are always in pixels.
// Optional. Only available if RA_CAP_BLIT is set (if it's not set, it must
Expand Down
9 changes: 6 additions & 3 deletions video/out/opengl/ra_gl.c
Expand Up @@ -308,7 +308,8 @@ static struct ra_tex *gl_tex_create(struct ra *ra,

gl_check_error(gl, ra->log, "after creating texture");

if (tex->params.render_dst) {
// Even blitting needs an FBO in OpenGL for strange reasons
if (tex->params.render_dst || tex->params.blit_src || tex->params.blit_dst) {
if (!tex->params.format->renderable) {
MP_ERR(ra, "Trying to create renderable texture with unsupported "
"format.\n");
Expand Down Expand Up @@ -378,6 +379,8 @@ struct ra_tex *ra_create_wrapped_fb(struct ra *ra, GLuint gl_fbo, int w, int h)
.w = w, .h = h, .d = 1,
.format = &fbo_dummy_format,
.render_dst = true,
.blit_src = true,
.blit_dst = true,
},
};

Expand Down Expand Up @@ -598,8 +601,8 @@ static void gl_blit(struct ra *ra, struct ra_tex *dst, struct ra_tex *src,
{
GL *gl = ra_gl_get(ra);

assert(dst->params.render_dst);
assert(src->params.render_dst); // even src must have a FBO
assert(src->params.blit_src);
assert(dst->params.blit_dst);

struct ra_tex_gl *src_gl = src->priv;
struct ra_tex_gl *dst_gl = dst->priv;
Expand Down
1 change: 1 addition & 0 deletions video/out/opengl/utils.c
Expand Up @@ -89,6 +89,7 @@ bool fbotex_change(struct fbotex *fbo, struct ra *ra, struct mp_log *log,
.src_linear = true,
.render_src = true,
.render_dst = true,
.blit_src = true,
};

fbo->tex = ra_tex_create(fbo->ra, &params);
Expand Down

0 comments on commit 9ca5a2a

Please sign in to comment.