summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2021-11-15 21:28:56 +0100
committersfan5 <sfan5@live.de>2021-11-17 22:38:34 +0100
commitc3d78b00173a37f715510761f4cd6d01b1e403a2 (patch)
treec791bb6c91bcb42eb3351b466c51f2e018d9c90c
parentf5cc28a627bc2adc3ce63e69384905a0c3fea66b (diff)
downloadmpv-c3d78b00173a37f715510761f4cd6d01b1e403a2.tar.bz2
mpv-c3d78b00173a37f715510761f4cd6d01b1e403a2.tar.xz
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.
-rw-r--r--video/out/opengl/context_dxinterop.c2
-rw-r--r--video/out/opengl/context_glx.c2
-rw-r--r--video/out/opengl/context_win.c2
-rw-r--r--video/out/opengl/egl_helpers.c2
-rw-r--r--video/out/opengl/hwdec_d3d11egl.c6
-rw-r--r--video/out/opengl/hwdec_dxva2egl.c3
6 files changed, 8 insertions, 9 deletions
diff --git a/video/out/opengl/context_dxinterop.c b/video/out/opengl/context_dxinterop.c
index d4d3b874d6..5764254cc1 100644
--- a/video/out/opengl/context_dxinterop.c
+++ b/video/out/opengl/context_dxinterop.c
@@ -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;
}
diff --git a/video/out/opengl/context_glx.c b/video/out/opengl/context_glx.c
index 1accd36db8..09d6d7cf7a 100644
--- a/video/out/opengl/context_glx.c
+++ b/video/out/opengl/context_glx.c
@@ -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;
}
diff --git a/video/out/opengl/context_win.c b/video/out/opengl/context_win.c
index 5a0042b3e9..6bf04547ad 100644
--- a/video/out/opengl/context_win.c
+++ b/video/out/opengl/context_win.c
@@ -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,
diff --git a/video/out/opengl/egl_helpers.c b/video/out/opengl/egl_helpers.c
index a81f9f4853..6c3604daa5 100644
--- a/video/out/opengl/egl_helpers.c
+++ b/video/out/opengl/egl_helpers.c
@@ -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
diff --git a/video/out/opengl/hwdec_d3d11egl.c b/video/out/opengl/hwdec_d3d11egl.c
index 762050359b..4a91267bbe 100644
--- a/video/out/opengl/hwdec_d3d11egl.c
+++ b/video/out/opengl/hwdec_d3d11egl.c
@@ -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;
diff --git a/video/out/opengl/hwdec_dxva2egl.c b/video/out/opengl/hwdec_dxva2egl.c
index 0f8a4adbb1..24f5c93b36 100644
--- a/video/out/opengl/hwdec_dxva2egl.c
+++ b/video/out/opengl/hwdec_dxva2egl.c
@@ -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;
}