summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/utils.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-05-23 17:31:07 +0200
committerwm4 <wm4@nowhere>2016-05-23 21:27:18 +0200
commitcc72a4e8c3889edf0c3880f166e3417be604ec19 (patch)
treeac07bc99676d99cfd95ea06e83a4e9498072b3a7 /video/out/opengl/utils.c
parentcc4a0571fa63420aa06f648dcc2c529b6da62672 (diff)
downloadmpv-cc72a4e8c3889edf0c3880f166e3417be604ec19.tar.bz2
mpv-cc72a4e8c3889edf0c3880f166e3417be604ec19.tar.xz
vo_opengl: support framebuffer invalidation
Not sure how much can be gained with this, as we can't use it properly yet. For now, this is used only before rendering, which probably does overwhelmingly nothing. In the future, this should be used after temporary passes, which could possibly reduce memory usage and even memory bandwidth usage, depending on the drivers.
Diffstat (limited to 'video/out/opengl/utils.c')
-rw-r--r--video/out/opengl/utils.c15
1 files changed, 15 insertions, 0 deletions
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,