summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.xyz>2017-08-12 20:07:03 +0200
committerNiklas Haas <git@haasn.xyz>2017-08-18 00:19:14 +0200
commit9ca5a2a5d839476d8a597fcc124cce41279928bc (patch)
tree6fcc70bcd5c219bdaeba3021b5a65ace014a6ce3 /video/out
parent82093764684a4c11f9ad0d8c12bf2e34758ea0fe (diff)
downloadmpv-9ca5a2a5d839476d8a597fcc124cce41279928bc.tar.bz2
mpv-9ca5a2a5d839476d8a597fcc124cce41279928bc.tar.xz
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
Diffstat (limited to 'video/out')
-rw-r--r--video/out/opengl/ra.h6
-rw-r--r--video/out/opengl/ra_gl.c9
-rw-r--r--video/out/opengl/utils.c1
3 files changed, 10 insertions, 6 deletions
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, &params);