Commit bee130f6 authored by Thomas Guillem's avatar Thomas Guillem

opengl: move HasExtension to vlc_gl_HasExtension

In order to allow vlc_gl_t module to use it.
parent cd8a4fea
...@@ -118,4 +118,17 @@ VLC_API vlc_gl_t *vlc_gl_surface_Create(vlc_object_t *, ...@@ -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 bool vlc_gl_surface_CheckSize(vlc_gl_t *, unsigned *w, unsigned *h);
VLC_API void vlc_gl_surface_Destroy(vlc_gl_t *); 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 */ #endif /* VLC_GL_H */
...@@ -238,19 +238,6 @@ typedef struct { ...@@ -238,19 +238,6 @@ typedef struct {
PFNGLCLIENTWAITSYNCPROC ClientWaitSync; /* can be NULL */ PFNGLCLIENTWAITSYNCPROC ClientWaitSync; /* can be NULL */
} opengl_vtable_t; } 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_context;
struct pl_shader; struct pl_shader;
struct pl_shader_res; struct pl_shader_res;
......
...@@ -586,19 +586,19 @@ opengl_tex_converter_generic_init(opengl_tex_converter_t *tc, bool allow_dr) ...@@ -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 */ /* OpenGL or OpenGL ES2 with GL_EXT_unpack_subimage ext */
priv->has_unpack_subimage = 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) if (allow_dr && priv->has_unpack_subimage)
{ {
bool supports_map_persistent = false; bool supports_map_persistent = false;
const bool has_pbo = const bool has_pbo =
HasExtension(tc->glexts, "GL_ARB_pixel_buffer_object") || vlc_gl_HasExtension(tc->glexts, "GL_ARB_pixel_buffer_object") ||
HasExtension(tc->glexts, "GL_EXT_pixel_buffer_object"); vlc_gl_HasExtension(tc->glexts, "GL_EXT_pixel_buffer_object");
const bool has_bs = const bool has_bs =
HasExtension(tc->glexts, "GL_ARB_buffer_storage") || vlc_gl_HasExtension(tc->glexts, "GL_ARB_buffer_storage") ||
HasExtension(tc->glexts, "GL_EXT_buffer_storage"); vlc_gl_HasExtension(tc->glexts, "GL_EXT_buffer_storage");
/* Ensure we do direct rendering with OpenGL 3.0 or higher. Indeed, /* Ensure we do direct rendering with OpenGL 3.0 or higher. Indeed,
* persistent mapped buffers seems to be slow with OpenGL 2.1 drivers * persistent mapped buffers seems to be slow with OpenGL 2.1 drivers
......
...@@ -406,11 +406,11 @@ Open(vlc_object_t *obj) ...@@ -406,11 +406,11 @@ Open(vlc_object_t *obj)
|| tc->gl->egl.destroyImageKHR == NULL) || tc->gl->egl.destroyImageKHR == NULL)
return VLC_EGENERIC; return VLC_EGENERIC;
if (!HasExtension(tc->glexts, "GL_OES_EGL_image")) if (!vlc_gl_HasExtension(tc->glexts, "GL_OES_EGL_image"))
return VLC_EGENERIC; return VLC_EGENERIC;
const char *eglexts = tc->gl->egl.queryString(tc->gl, EGL_EXTENSIONS); 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; return VLC_EGENERIC;
struct priv *priv = tc->priv = calloc(1, sizeof(struct priv)); struct priv *priv = tc->priv = calloc(1, sizeof(struct priv));
......
...@@ -175,7 +175,7 @@ Open(vlc_object_t *obj) ...@@ -175,7 +175,7 @@ Open(vlc_object_t *obj)
if ((tc->fmt.i_chroma != VLC_CODEC_VDPAU_VIDEO_420 && 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_422 &&
tc->fmt.i_chroma != VLC_CODEC_VDPAU_VIDEO_444) || 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) tc->gl->surface->type != VOUT_WINDOW_TYPE_XID)
return VLC_EGENERIC; return VLC_EGENERIC;
......
...@@ -104,7 +104,7 @@ tc_yuv_base_init(opengl_tex_converter_t *tc, GLenum tex_target, ...@@ -104,7 +104,7 @@ tc_yuv_base_init(opengl_tex_converter_t *tc, GLenum tex_target,
GLint oneplane_texfmt, oneplane16_texfmt, GLint oneplane_texfmt, oneplane16_texfmt,
twoplanes_texfmt, twoplanes16_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; oneplane_texfmt = GL_RED;
oneplane16_texfmt = GL_R16; oneplane16_texfmt = GL_R16;
......
...@@ -871,8 +871,8 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt, ...@@ -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. */ * so checks for extensions are bound to fail. Check for OpenGL ES version instead. */
vgl->supports_npot = true; vgl->supports_npot = true;
#else #else
vgl->supports_npot = HasExtension(extensions, "GL_ARB_texture_non_power_of_two") || vgl->supports_npot = vlc_gl_HasExtension(extensions, "GL_ARB_texture_non_power_of_two") ||
HasExtension(extensions, "GL_APPLE_texture_2D_limited_npot"); vlc_gl_HasExtension(extensions, "GL_APPLE_texture_2D_limited_npot");
#endif #endif
bool b_dump_shaders = var_InheritInteger(gl, "verbose") >= 4; bool b_dump_shaders = var_InheritInteger(gl, "verbose") >= 4;
......
...@@ -1943,7 +1943,7 @@ GLConvOpen(vlc_object_t *obj) ...@@ -1943,7 +1943,7 @@ GLConvOpen(vlc_object_t *obj)
const char *wglExt = tc->gl->wgl.getExtensionsString(tc->gl); 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; return VLC_EGENERIC;
struct wgl_vt vt; struct wgl_vt vt;
......
...@@ -198,7 +198,7 @@ static int Open(vlc_object_t *object) ...@@ -198,7 +198,7 @@ static int Open(vlc_object_t *object)
#ifdef WGL_EXT_swap_control #ifdef WGL_EXT_swap_control
/* Create an GPU Affinity DC */ /* Create an GPU Affinity DC */
const char *extensions = (const char*)glGetString(GL_EXTENSIONS); 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"); PFNWGLSWAPINTERVALEXTPROC SwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
if (SwapIntervalEXT) if (SwapIntervalEXT)
SwapIntervalEXT(1); SwapIntervalEXT(1);
...@@ -220,6 +220,7 @@ static int Open(vlc_object_t *object) ...@@ -220,6 +220,7 @@ static int Open(vlc_object_t *object)
gl->resize = NULL; gl->resize = NULL;
gl->swap = Swap; gl->swap = Swap;
gl->getProcAddress = OurGetProcAddress; gl->getProcAddress = OurGetProcAddress;
gl->getCoreProcAddress = NULL;
if (sys->exts.GetExtensionsStringEXT || sys->exts.GetExtensionsStringARB) if (sys->exts.GetExtensionsStringEXT || sys->exts.GetExtensionsStringARB)
gl->wgl.getExtensionsString = GetExtensionsString; gl->wgl.getExtensionsString = GetExtensionsString;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment