From 9ca5a2a5d839476d8a597fcc124cce41279928bc Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Sat, 12 Aug 2017 20:07:03 +0200 Subject: vo_opengl: make blitting an explicit capability 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 --- video/out/opengl/ra.h | 6 +++--- video/out/opengl/ra_gl.c | 9 ++++++--- video/out/opengl/utils.c | 1 + 3 files changed, 10 insertions(+), 6 deletions(-) (limited to 'video') diff --git a/video/out/opengl/ra.h b/video/out/opengl/ra.h index d7686bce5f..f722d2e8dd 100644 --- a/video/out/opengl/ra.h +++ b/video/out/opengl/ra.h @@ -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) @@ -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 diff --git a/video/out/opengl/ra_gl.c b/video/out/opengl/ra_gl.c index 0ad5d67c6e..6d27d5a285 100644 --- a/video/out/opengl/ra_gl.c +++ b/video/out/opengl/ra_gl.c @@ -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"); @@ -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, }, }; @@ -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; diff --git a/video/out/opengl/utils.c b/video/out/opengl/utils.c index 64421b73a8..522ce04c0a 100644 --- a/video/out/opengl/utils.c +++ b/video/out/opengl/utils.c @@ -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, ¶ms); -- cgit v1.2.3