Commit 06a6a9b4 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

glmemory: Only use glDrawBuffer if available

Otherwise fall back to glDrawBuffers. Also check if glReadBuffer exists
before using it.

glDrawBuffer does not exist for GLES, only glDrawBuffers does.

https://bugzilla.gnome.org/show_bug.cgi?id=782376
parent c6610799
......@@ -672,7 +672,8 @@ gst_gl_memory_copy_teximage (GstGLMemory * src, guint tex_id,
"texture %i", src, src_tex_id, tex_id);
/* FIXME: try and avoid creating and destroying fbo's every copy... */
if (!gl->BlitFramebuffer) {
if (!gl->BlitFramebuffer || (!gl->DrawBuffer && !gl->DrawBuffers)
|| !gl->ReadBuffer) {
/* create a framebuffer object */
n_fbos = 1;
gl->GenFramebuffers (n_fbos, &fbo[0]);
......@@ -696,6 +697,12 @@ gst_gl_memory_copy_teximage (GstGLMemory * src, guint tex_id,
gl->DeleteFramebuffers (n_fbos, &fbo[0]);
} else {
GLenum multipleRT[] = {
GL_COLOR_ATTACHMENT0,
GL_COLOR_ATTACHMENT1,
GL_COLOR_ATTACHMENT2
};
/* create a framebuffer object */
n_fbos = 2;
gl->GenFramebuffers (n_fbos, &fbo[0]);
......@@ -719,7 +726,10 @@ gst_gl_memory_copy_teximage (GstGLMemory * src, guint tex_id,
gst_gl_query_start_log (GST_GL_BASE_MEMORY_CAST (src)->query,
GST_CAT_GL_MEMORY, GST_LEVEL_LOG, NULL, "%s", "BlitFramebuffer took");
gl->ReadBuffer (GL_COLOR_ATTACHMENT0);
gl->DrawBuffer (GL_COLOR_ATTACHMENT0);
if (gl->DrawBuffers)
gl->DrawBuffers (1, multipleRT);
else
gl->DrawBuffer (GL_COLOR_ATTACHMENT0);
gl->BlitFramebuffer (0, 0, out_width, out_height,
0, 0, out_width, out_height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
gst_gl_query_end (GST_GL_BASE_MEMORY_CAST (src)->query);
......@@ -729,6 +739,9 @@ gst_gl_memory_copy_teximage (GstGLMemory * src, guint tex_id,
gl->BindFramebuffer (GL_READ_FRAMEBUFFER, 0);
gl->DeleteFramebuffers (n_fbos, &fbo[0]);
if (gl->DrawBuffer)
gl->DrawBuffer (GL_NONE);
}
gst_memory_unmap (GST_MEMORY_CAST (src), &sinfo);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment