mirror of
https://github.com/mpv-player/mpv
synced 2025-01-04 14:12:10 +00:00
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
This commit is contained in:
parent
8209376468
commit
9ca5a2a5d8
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user