From cc72a4e8c3889edf0c3880f166e3417be604ec19 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 23 May 2016 17:31:07 +0200 Subject: 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. --- video/out/opengl/utils.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'video/out/opengl/utils.c') 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, -- cgit v1.2.3