glframebuffer: check frame buffer status need use specific fbo target

https://bugzilla.gnome.org/show_bug.cgi?id=783065
This commit is contained in:
Haihua Hu 2017-05-25 10:09:04 +08:00 committed by Sebastian Dröge
parent 64ccac4bfb
commit 405d059a22
5 changed files with 17 additions and 10 deletions

View file

@ -217,7 +217,7 @@ QtGLWindow::afterRendering()
gl->BindFramebuffer (GL_READ_FRAMEBUFFER, this->source->renderTargetId()); gl->BindFramebuffer (GL_READ_FRAMEBUFFER, this->source->renderTargetId());
ret = gst_gl_context_check_framebuffer_status (context); ret = gst_gl_context_check_framebuffer_status (context, GL_READ_FRAMEBUFFER);
if (!ret) { if (!ret) {
GST_ERROR ("FBO errors"); GST_ERROR ("FBO errors");
goto errors; goto errors;
@ -233,7 +233,7 @@ QtGLWindow::afterRendering()
gl->FramebufferTexture2D (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, gl->FramebufferTexture2D (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, dst_tex, 0); GL_TEXTURE_2D, dst_tex, 0);
ret = gst_gl_context_check_framebuffer_status (context); ret = gst_gl_context_check_framebuffer_status (context, GL_DRAW_FRAMEBUFFER);
if (!ret) { if (!ret) {
GST_ERROR ("FBO errors"); GST_ERROR ("FBO errors");
goto errors; goto errors;

View file

@ -2513,7 +2513,7 @@ _do_convert_draw (GstGLContext * context, GstGLColorConvert * convert)
gl->Viewport (viewport_dim[0], viewport_dim[1], viewport_dim[2], gl->Viewport (viewport_dim[0], viewport_dim[1], viewport_dim[2],
viewport_dim[3]); viewport_dim[3]);
if (!gst_gl_context_check_framebuffer_status (context)) if (!gst_gl_context_check_framebuffer_status (context, GL_FRAMEBUFFER))
ret = FALSE; ret = FALSE;
gst_gl_context_clear_framebuffer (context); gst_gl_context_clear_framebuffer (context);

View file

@ -508,11 +508,17 @@ gst_gl_framebuffer_get_effective_dimensions (GstGLFramebuffer * fb,
* Since: 1.10 * Since: 1.10
*/ */
gboolean gboolean
gst_gl_context_check_framebuffer_status (GstGLContext * context) gst_gl_context_check_framebuffer_status (GstGLContext * context, GLenum fbo_target)
{ {
g_return_val_if_fail (GST_IS_GL_CONTEXT (context), FALSE); g_return_val_if_fail (GST_IS_GL_CONTEXT (context), FALSE);
switch (context->gl_vtable->CheckFramebufferStatus (GL_FRAMEBUFFER)) { if (fbo_target != GL_FRAMEBUFFER && fbo_target != GL_READ_FRAMEBUFFER
&& fbo_target != GL_DRAW_FRAMEBUFFER) {
GST_ERROR_OBJECT (context, "fbo target is invalid");
return FALSE;
}
switch (context->gl_vtable->CheckFramebufferStatus (fbo_target)) {
case GL_FRAMEBUFFER_COMPLETE: case GL_FRAMEBUFFER_COMPLETE:
return TRUE; return TRUE;
break; break;

View file

@ -103,7 +103,8 @@ void gst_gl_framebuffer_get_effective_dimensions (GstGLFrameb
guint * height); guint * height);
GST_EXPORT GST_EXPORT
gboolean gst_gl_context_check_framebuffer_status (GstGLContext * context); gboolean gst_gl_context_check_framebuffer_status (GstGLContext * context,
GLenum fbo_target);
GST_EXPORT GST_EXPORT
gboolean gst_gl_framebuffer_draw_to_texture (GstGLFramebuffer * fb, gboolean gst_gl_framebuffer_draw_to_texture (GstGLFramebuffer * fb,

View file

@ -373,7 +373,7 @@ gst_gl_memory_read_pixels (GstGLMemory * gl_mem, gpointer read_pointer)
gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
gst_gl_texture_target_to_gl (gl_mem->tex_target), gl_mem->tex_id, 0); gst_gl_texture_target_to_gl (gl_mem->tex_target), gl_mem->tex_id, 0);
if (!gst_gl_context_check_framebuffer_status (context)) { if (!gst_gl_context_check_framebuffer_status (context, GL_FRAMEBUFFER)) {
GST_CAT_WARNING (GST_CAT_GL_MEMORY, GST_CAT_WARNING (GST_CAT_GL_MEMORY,
"Could not create framebuffer to read pixels for memory %p", gl_mem); "Could not create framebuffer to read pixels for memory %p", gl_mem);
gl->DeleteFramebuffers (1, &fbo); gl->DeleteFramebuffers (1, &fbo);
@ -682,7 +682,7 @@ gst_gl_memory_copy_teximage (GstGLMemory * src, guint tex_id,
gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
gst_gl_texture_target_to_gl (src->tex_target), src_tex_id, 0); gst_gl_texture_target_to_gl (src->tex_target), src_tex_id, 0);
if (!gst_gl_context_check_framebuffer_status (src->mem.context)) if (!gst_gl_context_check_framebuffer_status (src->mem.context, GL_FRAMEBUFFER))
goto fbo_error; goto fbo_error;
gl->BindTexture (out_tex_target, tex_id); gl->BindTexture (out_tex_target, tex_id);
@ -711,7 +711,7 @@ gst_gl_memory_copy_teximage (GstGLMemory * src, guint tex_id,
gl->FramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, gl->FramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
gst_gl_texture_target_to_gl (src->tex_target), src_tex_id, 0); gst_gl_texture_target_to_gl (src->tex_target), src_tex_id, 0);
if (!gst_gl_context_check_framebuffer_status (src->mem.context)) if (!gst_gl_context_check_framebuffer_status (src->mem.context, GL_READ_FRAMEBUFFER))
goto fbo_error; goto fbo_error;
gl->BindFramebuffer (GL_DRAW_FRAMEBUFFER, fbo[1]); gl->BindFramebuffer (GL_DRAW_FRAMEBUFFER, fbo[1]);
@ -719,7 +719,7 @@ gst_gl_memory_copy_teximage (GstGLMemory * src, guint tex_id,
gl->FramebufferTexture2D (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, gl->FramebufferTexture2D (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
gst_gl_texture_target_to_gl (src->tex_target), tex_id, 0); gst_gl_texture_target_to_gl (src->tex_target), tex_id, 0);
if (!gst_gl_context_check_framebuffer_status (src->mem.context)) if (!gst_gl_context_check_framebuffer_status (src->mem.context, GL_DRAW_FRAMEBUFFER))
goto fbo_error; goto fbo_error;
gl->BindTexture (out_tex_target, tex_id); gl->BindTexture (out_tex_target, tex_id);