diff --git a/video/out/opengl/common.c b/video/out/opengl/common.c index ed3acede1c..16a5018dfd 100644 --- a/video/out/opengl/common.c +++ b/video/out/opengl/common.c @@ -269,6 +269,14 @@ static const struct gl_functions gl_functions[] = { {0} }, }, + { + .ver_core = 430, + .ver_es_core = 300, + .functions = (const struct gl_function[]) { + DEF_FN(InvalidateFramebuffer), + {0} + }, + }, // Swap control, always an OS specific extension // The OSX code loads this manually. { diff --git a/video/out/opengl/common.h b/video/out/opengl/common.h index 4f21e25455..4ee61975f4 100644 --- a/video/out/opengl/common.h +++ b/video/out/opengl/common.h @@ -181,6 +181,8 @@ struct GL { void (GLAPIENTRY *UniformMatrix3fv)(GLint, GLsizei, GLboolean, const GLfloat *); + void (GLAPIENTRY *InvalidateFramebuffer)(GLenum, GLsizei, const GLenum *); + GLsync (GLAPIENTRY *FenceSync)(GLenum, GLbitfield); GLenum (GLAPIENTRY *ClientWaitSync)(GLsync, GLbitfield, GLuint64); void (GLAPIENTRY *DeleteSync)(GLsync sync); diff --git a/video/out/opengl/utils.c b/video/out/opengl/utils.c index 199895e4ec..f8ed6eebaf 100644 --- a/video/out/opengl/utils.c +++ b/video/out/opengl/utils.c @@ -293,6 +293,7 @@ bool fbotex_change(struct fbotex *fbo, GL *gl, struct mp_log *log, int w, int h, if (fbo->rw == cw && fbo->rh == ch && fbo->iformat == iformat) { fbo->lw = w; fbo->lh = h; + fbotex_invalidate(fbo); return true; } @@ -378,6 +379,20 @@ void fbotex_uninit(struct fbotex *fbo) } } +// Mark framebuffer contents as unneeded. +void fbotex_invalidate(struct fbotex *fbo) +{ + GL *gl = fbo->gl; + + if (!fbo->fbo || !gl->InvalidateFramebuffer) + return; + + gl->BindFramebuffer(GL_FRAMEBUFFER, fbo->fbo); + gl->InvalidateFramebuffer(GL_FRAMEBUFFER, 1, + (GLenum[]){GL_COLOR_ATTACHMENT0}); + gl->BindFramebuffer(GL_FRAMEBUFFER, 0); +} + // Standard parallel 2D projection, except y1 < y0 means that the coordinate // system is flipped, not the projection. void gl_transform_ortho(struct gl_transform *t, float x0, float x1, diff --git a/video/out/opengl/utils.h b/video/out/opengl/utils.h index c7a72969f6..569ec0f23c 100644 --- a/video/out/opengl/utils.h +++ b/video/out/opengl/utils.h @@ -84,6 +84,7 @@ bool fbotex_change(struct fbotex *fbo, GL *gl, struct mp_log *log, int w, int h, #define FBOTEX_FUZZY_H 2 #define FBOTEX_FUZZY (FBOTEX_FUZZY_W | FBOTEX_FUZZY_H) void fbotex_set_filter(struct fbotex *fbo, GLenum gl_filter); +void fbotex_invalidate(struct fbotex *fbo); // A 3x2 matrix, with the translation part separate. struct gl_transform {