summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/ra_gl.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-08-04 13:48:37 +0200
committerwm4 <wm4@nowhere>2017-08-05 13:09:05 +0200
commita796745fd272701c9ed435337a161f643d34a26a (patch)
tree058da9d1be62c4a65e9881aa751897e19cae2f94 /video/out/opengl/ra_gl.c
parent90b53fede618772d39ff964b12e6403d71f7f235 (diff)
downloadmpv-a796745fd272701c9ed435337a161f643d34a26a.tar.bz2
mpv-a796745fd272701c9ed435337a161f643d34a26a.tar.xz
vo_opengl: make fbotex helper use ra
Further work removing GL dependencies from the actual video renderer, and moving them into ra backends. Use of glInvalidateFramebuffer() falls away. I'd like to keep this, but it's better to readd it once shader runs are in ra.
Diffstat (limited to 'video/out/opengl/ra_gl.c')
-rw-r--r--video/out/opengl/ra_gl.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/video/out/opengl/ra_gl.c b/video/out/opengl/ra_gl.c
index 46cbbda987..a52eeec94b 100644
--- a/video/out/opengl/ra_gl.c
+++ b/video/out/opengl/ra_gl.c
@@ -42,7 +42,8 @@ int ra_init_gl(struct ra *ra, GL *gl)
.pixel_size = gl_bytes_per_pixel(gl_fmt->format, gl_fmt->type),
.luminance_alpha = gl_fmt->format == GL_LUMINANCE_ALPHA,
.linear_filter = gl_fmt->flags & F_TF,
- .renderable = gl_fmt->flags & F_CR,
+ .renderable = (gl_fmt->flags & F_CR) &&
+ (gl->mpgl_caps & MPGL_CAP_FB),
};
int csize = gl_component_size(gl_fmt->type) * 8;
@@ -100,6 +101,9 @@ static void gl_tex_destroy(struct ra *ra, struct ra_tex *tex)
struct ra_gl *p = ra->priv;
struct ra_tex_gl *tex_gl = tex->priv;
+ if (tex_gl->fbo)
+ p->gl->DeleteFramebuffers(1, &tex_gl->fbo);
+
p->gl->DeleteTextures(1, &tex_gl->texture);
gl_pbo_upload_uninit(&tex_gl->pbo);
talloc_free(tex_gl);
@@ -167,6 +171,36 @@ static struct ra_tex *gl_tex_create(struct ra *ra,
tex->params.initial_data = NULL;
+ gl_check_error(gl, ra->log, "after creating texture");
+
+ if (tex->params.render_dst) {
+ if (!tex->params.format->renderable) {
+ MP_ERR(ra, "Trying to create renderable texture with unsupported "
+ "format.\n");
+ ra_tex_free(ra, &tex);
+ return NULL;
+ }
+
+ assert(gl->mpgl_caps & MPGL_CAP_FB);
+
+ gl->GenFramebuffers(1, &tex_gl->fbo);
+ gl->BindFramebuffer(GL_FRAMEBUFFER, tex_gl->fbo);
+ gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ GL_TEXTURE_2D, tex_gl->texture, 0);
+ GLenum err = gl->CheckFramebufferStatus(GL_FRAMEBUFFER);
+ gl->BindFramebuffer(GL_FRAMEBUFFER, 0);
+
+ if (err != GL_FRAMEBUFFER_COMPLETE) {
+ MP_ERR(ra, "Error: framebuffer completeness check failed (error=%d).\n",
+ (int)err);
+ ra_tex_free(ra, &tex);
+ return NULL;
+ }
+
+
+ gl_check_error(gl, ra->log, "after creating framebuffer");
+ }
+
return tex;
}
@@ -294,4 +328,3 @@ static struct ra_fns ra_fns_gl = {
.destroy_mapped_buffer = gl_destroy_mapped_buffer,
.poll_mapped_buffer = gl_poll_mapped_buffer,
};
-