mirror of
https://github.com/mpv-player/mpv
synced 2024-12-27 01:22:30 +00:00
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.
This commit is contained in:
parent
cc4a0571fa
commit
cc72a4e8c3
@ -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.
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user