[vlc-commits] opengl: api: drain error in case of error

Alexandre Janniaux git at videolan.org
Fri Jan 29 11:06:18 UTC 2021


vlc | branch: master | Alexandre Janniaux <ajanni at videolabs.io> | Wed Jan 27 18:13:45 2021 +0100| [41b34d1188acd469d5bc2d3e83112162fd36a570] | committer: Alexandre Janniaux

opengl: api: drain error in case of error

Otherwise, the error might be detected afterwards in an unrelated part
of the code, leading to potential failure or assertion depending on the
compilation options.

Indeed, an OpenGL call can lead to multiple errors and glGetError must
be called in loop, as mentioned by the documentation.

https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glGetError.xhtml

> To allow for distributed implementations, there may be several error
> flags. If any single error flag has recorded an error, the value of
> that flag is returned and that flag is reset to GL_NO_ERROR when
> glGetError is called. If more than one flag has recorded an error,
> glGetError returns and clears an arbitrary error flag value. Thus,
> glGetError should always be called in a loop, until it returns
> GL_NO_ERROR, if all error flags are to be reset.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=41b34d1188acd469d5bc2d3e83112162fd36a570
---

 modules/video_output/opengl/gl_api.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/modules/video_output/opengl/gl_api.c b/modules/video_output/opengl/gl_api.c
index 1264dde2a1..d990493832 100644
--- a/modules/video_output/opengl/gl_api.c
+++ b/modules/video_output/opengl/gl_api.c
@@ -163,6 +163,10 @@ vlc_gl_api_Init(struct vlc_gl_api *api, vlc_gl_t *gl)
      */
     api->supports_multisample = version >= 3 && error == GL_NO_ERROR;
 
+    /* Drain the errors before continuing. */
+    while (error != GL_NO_ERROR)
+        error = api->vt.GetError();
+
 #ifdef USE_OPENGL_ES2
     api->is_gles = true;
     /* OpenGL ES 2 includes support for non-power of 2 textures by specification



More information about the vlc-commits mailing list