mirror of
https://github.com/mpv-player/mpv
synced 2024-12-17 04:15:13 +00:00
vo_opengl: load certain EGL extensions needed for VAAPI EGL interop
These extensions use a bunch of EGL types, so we need to include the EGL headers in common.h to use our GL function loader with this. In the future, we should probably require presence of the EGL headers to reduce the hacks. This might be not so simple at least with OSX, so for now this has to do.
This commit is contained in:
parent
b81d9c79a8
commit
d47dff3faa
@ -690,6 +690,7 @@ fi
|
||||
check_yes_no $_gl GL
|
||||
check_yes_no $_gl_x11 GL_X11
|
||||
check_yes_no $_gl_x11_egl EGL_X11
|
||||
check_yes_no $_gl_x11_egl EGL
|
||||
check_yes_no $_gl_wayland GL_WAYLAND
|
||||
echores "$_gl"
|
||||
|
||||
|
@ -72,6 +72,7 @@ static bool check_ext(GL *gl, const char *name)
|
||||
#define FN_OFFS(name) offsetof(GL, name)
|
||||
|
||||
#define DEF_FN(name) {FN_OFFS(name), "gl" # name}
|
||||
#define DEF_FN_EGL(name) {FN_OFFS(name), "egl" # name}
|
||||
#define DEF_FN_NAME(name, str) {FN_OFFS(name), str}
|
||||
|
||||
struct gl_function {
|
||||
@ -278,6 +279,22 @@ static const struct gl_functions gl_functions[] = {
|
||||
.extension = "GL_APPLE_rgb_422",
|
||||
.provides = MPGL_CAP_APPLE_RGB_422,
|
||||
},
|
||||
// EGL extensions for vaapi EGL interop
|
||||
{
|
||||
.extension = "EGL_KHR_image_base",
|
||||
.functions = (const struct gl_function[]) {
|
||||
DEF_FN_EGL(CreateImageKHR),
|
||||
DEF_FN_EGL(DestroyImageKHR),
|
||||
{0}
|
||||
},
|
||||
},
|
||||
{
|
||||
.extension = "GL_OES_EGL_image",
|
||||
.functions = (const struct gl_function[]) {
|
||||
DEF_FN(EGLImageTargetTexture2DOES),
|
||||
{0}
|
||||
},
|
||||
},
|
||||
{
|
||||
.ver_core = 430,
|
||||
.extension = "GL_ARB_debug_output",
|
||||
|
@ -46,6 +46,11 @@
|
||||
#include <GL/glext.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_EGL
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
#endif
|
||||
|
||||
#define MP_GET_GL_WORKAROUNDS
|
||||
#include "header_fixes.h"
|
||||
|
||||
@ -268,6 +273,12 @@ struct GL {
|
||||
GLint (GLAPIENTRY *GetVideoSync)(GLuint *);
|
||||
GLint (GLAPIENTRY *WaitVideoSync)(GLint, GLint, unsigned int *);
|
||||
|
||||
EGLImageKHR (EGLAPIENTRY *CreateImageKHR)(EGLDisplay, EGLContext,
|
||||
EGLenum, EGLClientBuffer,
|
||||
const EGLint *);
|
||||
EGLBoolean (EGLAPIENTRY *DestroyImageKHR)(EGLDisplay, EGLImageKHR);
|
||||
void (EGLAPIENTRY *EGLImageTargetTexture2DOES)(GLenum, GLeglImageOES);
|
||||
|
||||
void (GLAPIENTRY *DebugMessageCallback)(MP_GLDEBUGPROC callback,
|
||||
const void *userParam);
|
||||
|
||||
|
@ -60,6 +60,25 @@
|
||||
#define GLvdpauSurfaceNV GLintptr
|
||||
#endif
|
||||
|
||||
typedef void *MP_voidptr;
|
||||
|
||||
#ifndef GL_OES_EGL_image
|
||||
#define GLeglImageOES MP_voidptr
|
||||
#endif
|
||||
#ifndef EGL_KHR_image
|
||||
#define EGLImageKHR MP_voidptr
|
||||
#endif
|
||||
|
||||
#if !HAVE_EGL
|
||||
#define EGLBoolean unsigned int
|
||||
#define EGLenum unsigned int
|
||||
#define EGLint int
|
||||
#define EGLContext MP_voidptr
|
||||
#define EGLDisplay MP_voidptr
|
||||
#define EGLClientBuffer MP_voidptr
|
||||
#define EGLAPIENTRY GLAPIENTRY
|
||||
#endif
|
||||
|
||||
#ifndef GL_DEBUG_SEVERITY_HIGH
|
||||
#define GL_DEBUG_SEVERITY_HIGH 0x9146
|
||||
#define GL_DEBUG_SEVERITY_MEDIUM 0x9147
|
||||
|
@ -134,8 +134,10 @@ static bool config_window_x11_egl(struct MPGLContext *ctx, int flags)
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *egl_exts = eglQueryString(p->egl_display, EGL_EXTENSIONS);
|
||||
|
||||
void *(*gpa)(const GLubyte*) = (void *(*)(const GLubyte*))eglGetProcAddress;
|
||||
mpgl_load_functions(ctx->gl, gpa, NULL, vo->log);
|
||||
mpgl_load_functions(ctx->gl, gpa, egl_exts, vo->log);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user