[vlc-devel] [PATCH] opengl: add debug callbacks
Romain Vimont
rom1v at videolabs.io
Tue Oct 1 08:49:16 CEST 2019
On Mon, Sep 30, 2019 at 10:43:52PM +0300, Rémi Denis-Courmont wrote:
> Le torstaina 26. syyskuuta 2019, 16.59.51 EEST Steve Lhomme a écrit :
> > From: Alexandre Janniaux <ajanni at videolabs.io>
> >
> > ---
> > modules/video_output/opengl/converter.h | 6 ++++
> > modules/video_output/opengl/vout_helper.c | 41 +++++++++++++++++++++--
> > 2 files changed, 45 insertions(+), 2 deletions(-)
> >
> > diff --git a/modules/video_output/opengl/converter.h
> > b/modules/video_output/opengl/converter.h index 73dfabeb713..66e2bb6d4c3
> > 100644
> > --- a/modules/video_output/opengl/converter.h
> > +++ b/modules/video_output/opengl/converter.h
> > @@ -93,6 +93,10 @@ typedef void (APIENTRY *PFNGLTEXPARAMETERFPROC) (GLenum
> > target, GLenum pname, GL typedef void (APIENTRY *PFNGLTEXPARAMETERIPROC)
> > (GLenum target, GLenum pname, GLint param); typedef void (APIENTRY
> > *PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint
> > yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const
> > void *pixels); typedef void (APIENTRY *PFNGLVIEWPORTPROC) (GLint x, GLint
> > y, GLsizei width, GLsizei height); +typedef void APIENTRY
> > PFNGLDEBUGCALLBACK(GLenum source, GLenum type, GLuint id, + GLenum
> > severity, GLsizei length, const GLchar* message, const void* userdata);
> > +typedef void (APIENTRY *PFNGLDEBUGMESSAGECALLBACK) (PFNGLDEBUGCALLBACK
> > callback, void * userdata); +
> >
> > /* The following are defined in glext.h but not for GLES2 or on Apple
> > systems */ #if defined(USE_OPENGL_ES2) || defined(__APPLE__)
> > @@ -175,6 +179,8 @@ typedef struct {
> > PFNGLTEXSUBIMAGE2DPROC TexSubImage2D;
> > PFNGLVIEWPORTPROC Viewport;
> >
> > + PFNGLDEBUGMESSAGECALLBACK DebugMessageCallback;
> > +
> > /* GL only core functions: NULL for GLES2 */
> > PFNGLGETTEXLEVELPARAMETERIVPROC GetTexLevelParameteriv; /* Can be NULL
> > */ PFNGLTEXENVFPROC TexEnvf; /* Can be NULL */
> > diff --git a/modules/video_output/opengl/vout_helper.c
> > b/modules/video_output/opengl/vout_helper.c index b37b6532572..b013b8e423b
> > 100644
> > --- a/modules/video_output/opengl/vout_helper.c
> > +++ b/modules/video_output/opengl/vout_helper.c
> > @@ -628,6 +628,33 @@ opengl_init_program(vout_display_opengl_t *vgl,
> > vlc_video_context *context, return VLC_SUCCESS;
> > }
> >
> > +#if !defined(USE_OPENGL_ES2)
> > +static void GLAPIENTRY
> > +OpenglMessageCallback(GLenum source,
> > + GLenum type,
> > + GLuint id,
> > + GLenum severity,
> > + GLsizei length,
> > + const GLchar* message,
> > + const void* userdata)
> > +{
> > + vout_display_opengl_t *vgl = userdata;
> > +
> > + const char *format = "OpenGL Debug callback: "
> > + "type = 0x%x, severity = 0x%x, message = %s";
>
> format[]
Why?
>
> > +
> > + if (type == GL_DEBUG_TYPE_ERROR)
> > + msg_Err(vgl->gl, format, type, severity, message);
> > + else
> > + msg_Dbg(vgl->gl, format, type, severity, message );
> > +
> > + VLC_UNUSED(source);
> > + VLC_UNUSED(id);
> > + VLC_UNUSED(length);
> > +}
> > +#endif
> > +
> > +
> > static void
> > ResizeFormatToGLMaxTexSize(video_format_t *fmt, unsigned int max_tex_size)
> > {
> > @@ -717,6 +744,8 @@ vout_display_opengl_t
> > *vout_display_opengl_New(video_format_t *fmt,
> > GET_PROC_ADDR_CORE_GL(GetTexLevelParameteriv);
> > GET_PROC_ADDR_CORE_GL(TexEnvf);
> >
> > + GET_PROC_ADDR_CORE_GL(DebugMessageCallback);
> > +
> > GET_PROC_ADDR(CreateShader);
> > GET_PROC_ADDR(ShaderSource);
> > GET_PROC_ADDR(CompileShader);
> > @@ -881,6 +910,12 @@ vout_display_opengl_t
> > *vout_display_opengl_New(video_format_t *fmt, vgl->vt.GenBuffers(1,
> > &vgl->index_buffer_object);
> > vgl->vt.GenBuffers(vgl->prgm->tc->tex_count,
> > vgl->texture_buffer_object);
> >
> > +#if !defined(USE_OPENGL_ES2)
> > + // During init, enable debug output
> > + vgl->vt.Enable(GL_DEBUG_OUTPUT);
> > + vgl->vt.DebugMessageCallback(OpenglMessageCallback, vgl);
> > +#endif
> > +
> > /* Initial number of allocated buffer objects for subpictures, will
> > grow dynamically. */ int subpicture_buffer_object_count = 8;
> > vgl->subpicture_buffer_object =
> > vlc_alloc(subpicture_buffer_object_count, sizeof(GLuint)); @@ -915,7 +950,6
> > @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt, void
> > vout_display_opengl_Delete(vout_display_opengl_t *vgl)
> > {
> > GL_ASSERT_NOERROR();
> > -
> > /* */
> > vgl->vt.Finish();
> > vgl->vt.Flush();
> > @@ -948,6 +982,10 @@ void vout_display_opengl_Delete(vout_display_opengl_t
> > *vgl) free(vgl->region);
> > GL_ASSERT_NOERROR();
> >
> > +#if !defined(USE_OPENGL_ES2)
> > + vgl->vt.Disable(GL_DEBUG_OUTPUT);
> > +#endif
> > +
> > free(vgl);
> > }
> >
> > @@ -1697,4 +1735,3 @@ int vout_display_opengl_Display(vout_display_opengl_t
> > *vgl,
> >
> > return VLC_SUCCESS;
> > }
> > -
>
>
> --
> レミ・デニ-クールモン
> http://www.remlab.net/
>
>
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list