[vlc-devel] [PATCH 6/8] opengl: move HasExtension to vlc_gl_HasExtension
Thomas Guillem
thomas at gllm.fr
Wed May 23 09:19:26 CEST 2018
In order to allow vlc_gl_t module to use it.
---
include/vlc_opengl.h | 13 +++++++++++++
modules/video_output/opengl/converter.h | 13 -------------
modules/video_output/opengl/converter_sw.c | 10 +++++-----
modules/video_output/opengl/converter_vaapi.c | 4 ++--
modules/video_output/opengl/converter_vdpau.c | 2 +-
modules/video_output/opengl/fragment_shaders.c | 2 +-
modules/video_output/opengl/vout_helper.c | 4 ++--
modules/video_output/win32/direct3d9.c | 2 +-
modules/video_output/win32/wgl.c | 3 ++-
9 files changed, 27 insertions(+), 26 deletions(-)
diff --git a/include/vlc_opengl.h b/include/vlc_opengl.h
index d446f0ac2f..178d1587da 100644
--- a/include/vlc_opengl.h
+++ b/include/vlc_opengl.h
@@ -118,4 +118,17 @@ VLC_API vlc_gl_t *vlc_gl_surface_Create(vlc_object_t *,
VLC_API bool vlc_gl_surface_CheckSize(vlc_gl_t *, unsigned *w, unsigned *h);
VLC_API void vlc_gl_surface_Destroy(vlc_gl_t *);
+static inline bool vlc_gl_HasExtension(const char *apis, const char *api)
+{
+ size_t apilen = strlen(api);
+ while (apis) {
+ while (*apis == ' ')
+ apis++;
+ if (!strncmp(apis, api, apilen) && memchr(" ", apis[apilen], 2))
+ return true;
+ apis = strchr(apis, ' ');
+ }
+ return false;
+}
+
#endif /* VLC_GL_H */
diff --git a/modules/video_output/opengl/converter.h b/modules/video_output/opengl/converter.h
index e7179fc8f9..229f2bd20b 100644
--- a/modules/video_output/opengl/converter.h
+++ b/modules/video_output/opengl/converter.h
@@ -238,19 +238,6 @@ typedef struct {
PFNGLCLIENTWAITSYNCPROC ClientWaitSync; /* can be NULL */
} opengl_vtable_t;
-static inline bool HasExtension(const char *apis, const char *api)
-{
- size_t apilen = strlen(api);
- while (apis) {
- while (*apis == ' ')
- apis++;
- if (!strncmp(apis, api, apilen) && memchr(" ", apis[apilen], 2))
- return true;
- apis = strchr(apis, ' ');
- }
- return false;
-}
-
struct pl_context;
struct pl_shader;
struct pl_shader_res;
diff --git a/modules/video_output/opengl/converter_sw.c b/modules/video_output/opengl/converter_sw.c
index 6676879a1d..2c31ffc43d 100644
--- a/modules/video_output/opengl/converter_sw.c
+++ b/modules/video_output/opengl/converter_sw.c
@@ -586,19 +586,19 @@ opengl_tex_converter_generic_init(opengl_tex_converter_t *tc, bool allow_dr)
/* OpenGL or OpenGL ES2 with GL_EXT_unpack_subimage ext */
priv->has_unpack_subimage =
- !tc->is_gles || HasExtension(tc->glexts, "GL_EXT_unpack_subimage");
+ !tc->is_gles || vlc_gl_HasExtension(tc->glexts, "GL_EXT_unpack_subimage");
if (allow_dr && priv->has_unpack_subimage)
{
bool supports_map_persistent = false;
const bool has_pbo =
- HasExtension(tc->glexts, "GL_ARB_pixel_buffer_object") ||
- HasExtension(tc->glexts, "GL_EXT_pixel_buffer_object");
+ vlc_gl_HasExtension(tc->glexts, "GL_ARB_pixel_buffer_object") ||
+ vlc_gl_HasExtension(tc->glexts, "GL_EXT_pixel_buffer_object");
const bool has_bs =
- HasExtension(tc->glexts, "GL_ARB_buffer_storage") ||
- HasExtension(tc->glexts, "GL_EXT_buffer_storage");
+ vlc_gl_HasExtension(tc->glexts, "GL_ARB_buffer_storage") ||
+ vlc_gl_HasExtension(tc->glexts, "GL_EXT_buffer_storage");
/* Ensure we do direct rendering with OpenGL 3.0 or higher. Indeed,
* persistent mapped buffers seems to be slow with OpenGL 2.1 drivers
diff --git a/modules/video_output/opengl/converter_vaapi.c b/modules/video_output/opengl/converter_vaapi.c
index 635819d9f9..322743f715 100644
--- a/modules/video_output/opengl/converter_vaapi.c
+++ b/modules/video_output/opengl/converter_vaapi.c
@@ -406,11 +406,11 @@ Open(vlc_object_t *obj)
|| tc->gl->egl.destroyImageKHR == NULL)
return VLC_EGENERIC;
- if (!HasExtension(tc->glexts, "GL_OES_EGL_image"))
+ if (!vlc_gl_HasExtension(tc->glexts, "GL_OES_EGL_image"))
return VLC_EGENERIC;
const char *eglexts = tc->gl->egl.queryString(tc->gl, EGL_EXTENSIONS);
- if (eglexts == NULL || !HasExtension(eglexts, "EGL_EXT_image_dma_buf_import"))
+ if (eglexts == NULL || !vlc_gl_HasExtension(eglexts, "EGL_EXT_image_dma_buf_import"))
return VLC_EGENERIC;
struct priv *priv = tc->priv = calloc(1, sizeof(struct priv));
diff --git a/modules/video_output/opengl/converter_vdpau.c b/modules/video_output/opengl/converter_vdpau.c
index bb77ae8d26..0e7e0e0701 100644
--- a/modules/video_output/opengl/converter_vdpau.c
+++ b/modules/video_output/opengl/converter_vdpau.c
@@ -175,7 +175,7 @@ Open(vlc_object_t *obj)
if ((tc->fmt.i_chroma != VLC_CODEC_VDPAU_VIDEO_420 &&
tc->fmt.i_chroma != VLC_CODEC_VDPAU_VIDEO_422 &&
tc->fmt.i_chroma != VLC_CODEC_VDPAU_VIDEO_444) ||
- !HasExtension(tc->glexts, "GL_NV_vdpau_interop") ||
+ !vlc_gl_HasExtension(tc->glexts, "GL_NV_vdpau_interop") ||
tc->gl->surface->type != VOUT_WINDOW_TYPE_XID)
return VLC_EGENERIC;
diff --git a/modules/video_output/opengl/fragment_shaders.c b/modules/video_output/opengl/fragment_shaders.c
index e24b080279..337a2c792c 100644
--- a/modules/video_output/opengl/fragment_shaders.c
+++ b/modules/video_output/opengl/fragment_shaders.c
@@ -104,7 +104,7 @@ tc_yuv_base_init(opengl_tex_converter_t *tc, GLenum tex_target,
GLint oneplane_texfmt, oneplane16_texfmt,
twoplanes_texfmt, twoplanes16_texfmt;
- if (HasExtension(tc->glexts, "GL_ARB_texture_rg"))
+ if (vlc_gl_HasExtension(tc->glexts, "GL_ARB_texture_rg"))
{
oneplane_texfmt = GL_RED;
oneplane16_texfmt = GL_R16;
diff --git a/modules/video_output/opengl/vout_helper.c b/modules/video_output/opengl/vout_helper.c
index 12c3ee8b86..cba43caf4d 100644
--- a/modules/video_output/opengl/vout_helper.c
+++ b/modules/video_output/opengl/vout_helper.c
@@ -871,8 +871,8 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
* so checks for extensions are bound to fail. Check for OpenGL ES version instead. */
vgl->supports_npot = true;
#else
- vgl->supports_npot = HasExtension(extensions, "GL_ARB_texture_non_power_of_two") ||
- HasExtension(extensions, "GL_APPLE_texture_2D_limited_npot");
+ vgl->supports_npot = vlc_gl_HasExtension(extensions, "GL_ARB_texture_non_power_of_two") ||
+ vlc_gl_HasExtension(extensions, "GL_APPLE_texture_2D_limited_npot");
#endif
bool b_dump_shaders = var_InheritInteger(gl, "verbose") >= 4;
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index 6dbc70afdb..5dea6d203f 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -1943,7 +1943,7 @@ GLConvOpen(vlc_object_t *obj)
const char *wglExt = tc->gl->wgl.getExtensionsString(tc->gl);
- if (wglExt == NULL || !HasExtension(wglExt, "WGL_NV_DX_interop"))
+ if (wglExt == NULL || !vlc_gl_HasExtension(wglExt, "WGL_NV_DX_interop"))
return VLC_EGENERIC;
struct wgl_vt vt;
diff --git a/modules/video_output/win32/wgl.c b/modules/video_output/win32/wgl.c
index 72a9cc4c51..8b6d291216 100644
--- a/modules/video_output/win32/wgl.c
+++ b/modules/video_output/win32/wgl.c
@@ -198,7 +198,7 @@ static int Open(vlc_object_t *object)
#ifdef WGL_EXT_swap_control
/* Create an GPU Affinity DC */
const char *extensions = (const char*)glGetString(GL_EXTENSIONS);
- if (HasExtension(extensions, "WGL_EXT_swap_control")) {
+ if (vlc_gl_HasExtension(extensions, "WGL_EXT_swap_control")) {
PFNWGLSWAPINTERVALEXTPROC SwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
if (SwapIntervalEXT)
SwapIntervalEXT(1);
@@ -220,6 +220,7 @@ static int Open(vlc_object_t *object)
gl->resize = NULL;
gl->swap = Swap;
gl->getProcAddress = OurGetProcAddress;
+ gl->getCoreProcAddress = NULL;
if (sys->exts.GetExtensionsStringEXT || sys->exts.GetExtensionsStringARB)
gl->wgl.getExtensionsString = GetExtensionsString;
--
2.17.0
More information about the vlc-devel
mailing list