[vlc-devel] [PATCH] [3.x] opengl: fix shader support check

Thomas Guillem thomas at gllm.fr
Thu Feb 20 09:50:32 CET 2020


Hello,

I don't think the check replacement is needed, you can just remove it like you did but not replace it.

Indeed, shader support is already implicitly checked with 
"GET_PROC_ADDR(CreateShader);" just above

#define GET_PROC_ADDR_EXT(name, critical) do { \
    vgl->vt.name = vlc_gl_GetProcAddress(gl, "gl"#name); \
    if (vgl->vt.name == NULL && critical) { \
        msg_Err(gl, "gl"#name" symbol not found, bailing out"); \
        free(vgl); \
        return NULL; \
    } \
} while(0)

So, it will fail nicely if the OS doesn't have shader support.

On Thu, Feb 20, 2020, at 00:06, Marvin Scholz wrote:
> Even with OpenGL versions lower than 2.0 GLSL can be supported,
> so fallback to checking the GLSL version.
> 
> Fix #21438
> ---
>  modules/video_output/opengl/vout_helper.c | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/modules/video_output/opengl/vout_helper.c 
> b/modules/video_output/opengl/vout_helper.c
> index 919560e603..80b71ac858 100644
> --- a/modules/video_output/opengl/vout_helper.c
> +++ b/modules/video_output/opengl/vout_helper.c
> @@ -855,13 +855,17 @@ vout_display_opengl_t 
> *vout_display_opengl_New(video_format_t *fmt,
>          return NULL;
>      }
>  #if !defined(USE_OPENGL_ES2)
> +    // Check for OpenGL < 2.0
>      const unsigned char *ogl_version = vgl->vt.GetString(GL_VERSION);
> -    bool supports_shaders = strverscmp((const char *)ogl_version, 
> "2.0") >= 0;
> -    if (!supports_shaders)
> -    {
> -        msg_Err(gl, "shaders not supported, bailing out\n");
> -        free(vgl);
> -        return NULL;
> +    if (strverscmp((const char *)ogl_version, "2.0") < 0) {
> +        // Even with OpenGL < 2.0 we might have GLSL support,
> +        // so check the GLSL version before finally giving up:
> +        const unsigned char *glsl_version = 
> vgl->vt.GetString(GL_SHADING_LANGUAGE_VERSION);
> +        if (!glsl_version || strverscmp((const char *)glsl_version, 
> "1.10") < 0) {
> +            msg_Err(gl, "shaders not supported, bailing out\n");
> +            free(vgl);
> +            return NULL;
> +        }
>      }
>  #endif
>  
> -- 
> 2.21.1 (Apple Git-122.3)
> 
> _______________________________________________
> 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