1
0
mirror of https://github.com/mpv-player/mpv synced 2025-04-01 23:00:41 +00:00

video: opengl: use gl_check_extension() instead of strstr()

Using a simple substring match for extension checks is considered bad practice
because it's incorrect when one extension is a prefix of another's name.
This will almost surely not make a difference in practice but do it for correctness anyway.
This commit is contained in:
sfan5 2021-11-15 21:28:56 +01:00
parent f5cc28a627
commit c3d78b0017
6 changed files with 8 additions and 9 deletions

View File

@ -148,7 +148,7 @@ static int os_ctx_create(struct ra_ctx *ctx)
}
const char *wgl_exts = wglGetExtensionsStringARB(p->os_dc);
if (!strstr(wgl_exts, "WGL_ARB_create_context")) {
if (!gl_check_extension(wgl_exts, "WGL_ARB_create_context")) {
MP_FATAL(ctx->vo, "The OpenGL driver does not support OpenGL 3.x\n");
goto fail;
}

View File

@ -99,7 +99,7 @@ static bool create_context_x11(struct ra_ctx *ctx, GL *gl, bool es)
if (es) {
profile_mask = GLX_CONTEXT_ES2_PROFILE_BIT_EXT;
if (!strstr(glxstr, "GLX_EXT_create_context_es2_profile"))
if (!gl_check_extension(glxstr, "GLX_EXT_create_context_es2_profile"))
return false;
}

View File

@ -155,7 +155,7 @@ static bool create_context_wgl_gl3(struct ra_ctx *ctx)
goto unsupported;
const char *wgl_exts = wglGetExtensionsStringARB(windc);
if (!strstr(wgl_exts, "WGL_ARB_create_context"))
if (!gl_check_extension(wgl_exts, "WGL_ARB_create_context"))
goto unsupported;
HGLRC (GLAPIENTRY *wglCreateContextAttribsARB)(HDC hDC, HGLRC hShareContext,

View File

@ -306,7 +306,7 @@ EGLDisplay mpegl_get_display(EGLenum platform, const char *platform_ext_name,
// If this is either EGL 1.5, or 1.4 with EGL_EXT_client_extensions, then
// this must return a valid extension string.
const char *exts = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
if (!exts || !gl_check_extension(exts, platform_ext_name))
if (!gl_check_extension(exts, platform_ext_name))
return EGL_NO_DISPLAY;
// Before we go through the EGL 1.4 BS, try if we can use native EGL 1.5

View File

@ -101,11 +101,11 @@ static int init(struct ra_hwdec *hw)
GL *gl = ra_gl_get(hw->ra);
const char *exts = eglQueryString(egl_display, EGL_EXTENSIONS);
if (!exts || !strstr(exts, "EGL_ANGLE_d3d_share_handle_client_buffer") ||
if (!gl_check_extension(exts, "EGL_ANGLE_d3d_share_handle_client_buffer") ||
!gl_check_extension(exts, "EGL_ANGLE_stream_producer_d3d_texture") ||
!(strstr(gl->extensions, "GL_OES_EGL_image_external_essl3") ||
!(gl_check_extension(gl->extensions, "GL_OES_EGL_image_external_essl3") ||
gl->es == 200) ||
!strstr(exts, "EGL_EXT_device_query") ||
!gl_check_extension(exts, "EGL_EXT_device_query") ||
!(gl->mpgl_caps & MPGL_CAP_TEX_RG))
return -1;

View File

@ -88,8 +88,7 @@ static int init(struct ra_hwdec *hw)
return -1;
const char *exts = eglQueryString(egl_display, EGL_EXTENSIONS);
if (!exts ||
!strstr(exts, "EGL_ANGLE_d3d_share_handle_client_buffer")) {
if (!gl_check_extension(exts, "EGL_ANGLE_d3d_share_handle_client_buffer")) {
return -1;
}