2010-03-25 17:28:49 +00:00
|
|
|
/*
|
|
|
|
* gstvaapiutils_glx.h - GLX utilties
|
|
|
|
*
|
2012-01-16 09:41:10 +00:00
|
|
|
* Copyright (C) 2010-2011 Splitted-Desktop Systems
|
2013-11-22 04:57:18 +00:00
|
|
|
* Author: Gwenole Beauchesne <gwenole.beauchesne@splitted-desktop.com>
|
2013-01-29 13:00:04 +00:00
|
|
|
* Copyright (C) 2012 Intel Corporation
|
2013-11-22 04:57:18 +00:00
|
|
|
* Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
|
2010-03-25 17:28:49 +00:00
|
|
|
*
|
2010-05-03 07:07:27 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2.1
|
|
|
|
* of the License, or (at your option) any later version.
|
2010-03-25 17:28:49 +00:00
|
|
|
*
|
2010-05-03 07:07:27 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2010-03-25 17:28:49 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2010-05-03 07:07:27 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2010-03-25 17:28:49 +00:00
|
|
|
*
|
2010-05-03 07:07:27 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free
|
|
|
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301 USA
|
2010-03-25 17:28:49 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GST_VAAPI_UTILS_GLX_H
|
|
|
|
#define GST_VAAPI_UTILS_GLX_H
|
|
|
|
|
|
|
|
#include "config.h"
|
2014-01-23 09:20:40 +00:00
|
|
|
#include "libgstvaapi_priv_check.h"
|
2010-03-25 17:28:49 +00:00
|
|
|
#include <GL/gl.h>
|
|
|
|
#include <GL/glx.h>
|
2012-02-07 09:01:01 +00:00
|
|
|
#include <glib.h>
|
2010-03-25 17:28:49 +00:00
|
|
|
|
2010-03-30 12:59:15 +00:00
|
|
|
#if GLX_GLXEXT_VERSION < 18
|
2014-01-23 16:41:02 +00:00
|
|
|
typedef void (*PFNGLXBINDTEXIMAGEEXTPROC) (Display *, GLXDrawable, int,
|
|
|
|
const int *);
|
|
|
|
typedef void (*PFNGLXRELEASETEXIMAGEEXTPROC) (Display *, GLXDrawable, int);
|
2010-03-30 12:59:15 +00:00
|
|
|
#endif
|
|
|
|
|
2010-07-01 11:38:28 +00:00
|
|
|
#if GLX_GLXEXT_VERSION < 27
|
|
|
|
/* XXX: this is not exactly that version but this is the only means to
|
|
|
|
make sure we have the correct <GL/glx.h> with those signatures */
|
2014-01-23 16:41:02 +00:00
|
|
|
typedef GLXPixmap (*PFNGLXCREATEPIXMAPPROC) (Display *, GLXFBConfig, Pixmap,
|
|
|
|
const int *);
|
|
|
|
typedef void (*PFNGLXDESTROYPIXMAPPROC) (Display *, GLXPixmap);
|
2010-07-01 11:38:28 +00:00
|
|
|
#endif
|
|
|
|
|
2010-03-30 12:59:15 +00:00
|
|
|
#ifndef GL_FRAMEBUFFER_BINDING
|
|
|
|
#define GL_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING_EXT
|
|
|
|
#endif
|
|
|
|
|
2012-07-19 15:55:00 +00:00
|
|
|
G_GNUC_INTERNAL
|
2014-01-23 16:41:02 +00:00
|
|
|
const gchar *
|
|
|
|
gl_get_error_string (GLenum error);
|
2010-03-25 17:28:49 +00:00
|
|
|
|
2012-07-19 15:55:00 +00:00
|
|
|
G_GNUC_INTERNAL
|
2010-03-25 17:28:49 +00:00
|
|
|
void
|
2014-01-23 16:41:02 +00:00
|
|
|
gl_purge_errors (void);
|
2010-03-25 17:28:49 +00:00
|
|
|
|
2012-07-19 15:55:00 +00:00
|
|
|
G_GNUC_INTERNAL
|
2010-03-25 17:28:49 +00:00
|
|
|
gboolean
|
2014-01-23 16:41:02 +00:00
|
|
|
gl_check_error (void);
|
2010-03-25 17:28:49 +00:00
|
|
|
|
2012-07-19 15:55:00 +00:00
|
|
|
G_GNUC_INTERNAL
|
2010-03-25 17:28:49 +00:00
|
|
|
gboolean
|
2014-01-23 16:41:02 +00:00
|
|
|
gl_get_param (GLenum param, guint * pval);
|
2010-03-25 17:28:49 +00:00
|
|
|
|
2012-07-19 15:55:00 +00:00
|
|
|
G_GNUC_INTERNAL
|
2010-03-25 17:28:49 +00:00
|
|
|
gboolean
|
2014-01-23 16:41:02 +00:00
|
|
|
gl_get_texture_param (GLenum target, GLenum param, guint * pval);
|
2010-03-25 17:28:49 +00:00
|
|
|
|
2012-07-19 15:55:00 +00:00
|
|
|
G_GNUC_INTERNAL
|
2010-03-25 17:28:49 +00:00
|
|
|
void
|
2014-01-23 16:41:02 +00:00
|
|
|
gl_set_bgcolor (guint32 color);
|
2010-03-25 17:28:49 +00:00
|
|
|
|
2012-07-19 15:55:00 +00:00
|
|
|
G_GNUC_INTERNAL
|
2010-03-25 17:28:49 +00:00
|
|
|
void
|
2014-01-23 16:41:02 +00:00
|
|
|
gl_resize (guint width, guint height);
|
2010-03-25 17:28:49 +00:00
|
|
|
|
2010-03-26 09:41:12 +00:00
|
|
|
typedef struct _GLContextState GLContextState;
|
2014-01-23 16:41:02 +00:00
|
|
|
struct _GLContextState
|
|
|
|
{
|
|
|
|
Display *display;
|
|
|
|
Window window;
|
|
|
|
XVisualInfo *visual;
|
|
|
|
GLXContext context;
|
|
|
|
guint swapped_buffers:1;
|
2010-03-26 09:41:12 +00:00
|
|
|
};
|
|
|
|
|
2012-07-19 15:55:00 +00:00
|
|
|
G_GNUC_INTERNAL
|
2010-03-31 15:25:19 +00:00
|
|
|
GLContextState *
|
2014-01-23 16:41:02 +00:00
|
|
|
gl_create_context (Display * dpy, int screen, GLContextState * parent);
|
2010-03-31 15:25:19 +00:00
|
|
|
|
2012-07-19 15:55:00 +00:00
|
|
|
G_GNUC_INTERNAL
|
2010-03-31 15:25:19 +00:00
|
|
|
void
|
2014-01-23 16:41:02 +00:00
|
|
|
gl_destroy_context (GLContextState * cs);
|
2010-03-31 15:25:19 +00:00
|
|
|
|
2012-07-19 15:55:00 +00:00
|
|
|
G_GNUC_INTERNAL
|
2010-03-31 15:25:19 +00:00
|
|
|
void
|
2014-01-23 16:41:02 +00:00
|
|
|
gl_get_current_context (GLContextState * cs);
|
2010-03-31 15:25:19 +00:00
|
|
|
|
2012-07-19 15:55:00 +00:00
|
|
|
G_GNUC_INTERNAL
|
2010-03-26 09:41:12 +00:00
|
|
|
gboolean
|
2014-01-23 16:41:02 +00:00
|
|
|
gl_set_current_context (GLContextState * new_cs, GLContextState * old_cs);
|
2010-03-26 09:41:12 +00:00
|
|
|
|
2012-07-19 15:55:00 +00:00
|
|
|
G_GNUC_INTERNAL
|
2010-03-29 13:40:27 +00:00
|
|
|
void
|
2014-01-23 16:41:02 +00:00
|
|
|
gl_swap_buffers (GLContextState * cs);
|
2010-03-29 13:40:27 +00:00
|
|
|
|
2010-03-26 16:52:07 +00:00
|
|
|
typedef struct _GLTextureState GLTextureState;
|
2014-01-23 16:41:02 +00:00
|
|
|
struct _GLTextureState
|
|
|
|
{
|
|
|
|
GLenum target;
|
|
|
|
GLuint old_texture;
|
|
|
|
guint was_enabled:1;
|
|
|
|
guint was_bound:1;
|
2010-03-26 16:52:07 +00:00
|
|
|
};
|
|
|
|
|
2012-07-19 15:55:00 +00:00
|
|
|
G_GNUC_INTERNAL
|
2010-03-26 16:52:07 +00:00
|
|
|
gboolean
|
2014-01-23 16:41:02 +00:00
|
|
|
gl_bind_texture (GLTextureState * ts, GLenum target, GLuint texture);
|
2010-03-26 16:52:07 +00:00
|
|
|
|
2015-11-26 09:26:10 +00:00
|
|
|
G_GNUC_INTERNAL
|
|
|
|
gboolean
|
|
|
|
gl3_bind_texture_2d (GLTextureState * ts, GLenum target, GLuint texture);
|
|
|
|
|
2012-07-19 15:55:00 +00:00
|
|
|
G_GNUC_INTERNAL
|
2010-03-26 16:52:07 +00:00
|
|
|
void
|
2014-01-23 16:41:02 +00:00
|
|
|
gl_unbind_texture (GLTextureState * ts);
|
2010-03-26 16:52:07 +00:00
|
|
|
|
2012-07-19 15:55:00 +00:00
|
|
|
G_GNUC_INTERNAL
|
2010-03-26 16:52:07 +00:00
|
|
|
GLuint
|
2014-01-23 16:41:02 +00:00
|
|
|
gl_create_texture (GLenum target, GLenum format, guint width, guint height);
|
2010-03-26 16:52:07 +00:00
|
|
|
|
2010-03-30 12:59:15 +00:00
|
|
|
typedef struct _GLVTable GLVTable;
|
2014-01-23 16:41:02 +00:00
|
|
|
struct _GLVTable
|
|
|
|
{
|
|
|
|
PFNGLXCREATEPIXMAPPROC glx_create_pixmap;
|
|
|
|
PFNGLXDESTROYPIXMAPPROC glx_destroy_pixmap;
|
|
|
|
PFNGLXBINDTEXIMAGEEXTPROC glx_bind_tex_image;
|
|
|
|
PFNGLXRELEASETEXIMAGEEXTPROC glx_release_tex_image;
|
|
|
|
PFNGLGENFRAMEBUFFERSEXTPROC gl_gen_framebuffers;
|
|
|
|
PFNGLDELETEFRAMEBUFFERSEXTPROC gl_delete_framebuffers;
|
|
|
|
PFNGLBINDFRAMEBUFFEREXTPROC gl_bind_framebuffer;
|
|
|
|
PFNGLGENRENDERBUFFERSEXTPROC gl_gen_renderbuffers;
|
|
|
|
PFNGLDELETERENDERBUFFERSEXTPROC gl_delete_renderbuffers;
|
|
|
|
PFNGLBINDRENDERBUFFEREXTPROC gl_bind_renderbuffer;
|
|
|
|
PFNGLRENDERBUFFERSTORAGEEXTPROC gl_renderbuffer_storage;
|
|
|
|
PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC gl_framebuffer_renderbuffer;
|
|
|
|
PFNGLFRAMEBUFFERTEXTURE2DEXTPROC gl_framebuffer_texture_2d;
|
|
|
|
PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC gl_check_framebuffer_status;
|
|
|
|
guint has_texture_from_pixmap:1;
|
|
|
|
guint has_framebuffer_object:1;
|
2010-03-30 12:59:15 +00:00
|
|
|
};
|
|
|
|
|
2012-07-19 15:55:00 +00:00
|
|
|
G_GNUC_INTERNAL
|
2010-03-30 12:59:15 +00:00
|
|
|
GLVTable *
|
2014-01-23 16:41:02 +00:00
|
|
|
gl_get_vtable (void);
|
2010-03-30 12:59:15 +00:00
|
|
|
|
|
|
|
typedef struct _GLPixmapObject GLPixmapObject;
|
2014-01-23 16:41:02 +00:00
|
|
|
struct _GLPixmapObject
|
|
|
|
{
|
|
|
|
Display *dpy;
|
|
|
|
GLenum target;
|
|
|
|
GLuint texture;
|
|
|
|
GLTextureState old_texture;
|
|
|
|
guint width;
|
|
|
|
guint height;
|
|
|
|
Pixmap pixmap;
|
|
|
|
GLXPixmap glx_pixmap;
|
|
|
|
guint is_bound:1;
|
2010-03-30 12:59:15 +00:00
|
|
|
};
|
|
|
|
|
2012-07-19 15:55:00 +00:00
|
|
|
G_GNUC_INTERNAL
|
2010-03-30 12:59:15 +00:00
|
|
|
GLPixmapObject *
|
2014-01-23 16:41:02 +00:00
|
|
|
gl_create_pixmap_object (Display * dpy, guint width, guint height);
|
2010-03-30 12:59:15 +00:00
|
|
|
|
2012-07-19 15:55:00 +00:00
|
|
|
G_GNUC_INTERNAL
|
2010-03-30 12:59:15 +00:00
|
|
|
void
|
2014-01-23 16:41:02 +00:00
|
|
|
gl_destroy_pixmap_object (GLPixmapObject * pixo);
|
2010-03-30 12:59:15 +00:00
|
|
|
|
2012-07-19 15:55:00 +00:00
|
|
|
G_GNUC_INTERNAL
|
2010-03-30 12:59:15 +00:00
|
|
|
gboolean
|
2014-01-23 16:41:02 +00:00
|
|
|
gl_bind_pixmap_object (GLPixmapObject * pixo);
|
2010-03-30 12:59:15 +00:00
|
|
|
|
2012-07-19 15:55:00 +00:00
|
|
|
G_GNUC_INTERNAL
|
2010-03-30 12:59:15 +00:00
|
|
|
gboolean
|
2014-01-23 16:41:02 +00:00
|
|
|
gl_unbind_pixmap_object (GLPixmapObject * pixo);
|
2010-03-30 12:59:15 +00:00
|
|
|
|
|
|
|
typedef struct _GLFramebufferObject GLFramebufferObject;
|
2014-01-23 16:41:02 +00:00
|
|
|
struct _GLFramebufferObject
|
|
|
|
{
|
|
|
|
guint width;
|
|
|
|
guint height;
|
|
|
|
GLuint fbo;
|
|
|
|
GLuint old_fbo;
|
|
|
|
guint is_bound:1;
|
2010-03-30 12:59:15 +00:00
|
|
|
};
|
|
|
|
|
2012-07-19 15:55:00 +00:00
|
|
|
G_GNUC_INTERNAL
|
2010-03-30 12:59:15 +00:00
|
|
|
GLFramebufferObject *
|
2014-01-23 16:41:02 +00:00
|
|
|
gl_create_framebuffer_object (GLenum target,
|
|
|
|
GLuint texture, guint width, guint height);
|
2010-03-30 12:59:15 +00:00
|
|
|
|
2012-07-19 15:55:00 +00:00
|
|
|
G_GNUC_INTERNAL
|
2010-03-30 12:59:15 +00:00
|
|
|
void
|
2014-01-23 16:41:02 +00:00
|
|
|
gl_destroy_framebuffer_object (GLFramebufferObject * fbo);
|
2010-03-30 12:59:15 +00:00
|
|
|
|
2012-07-19 15:55:00 +00:00
|
|
|
G_GNUC_INTERNAL
|
2010-03-30 12:59:15 +00:00
|
|
|
gboolean
|
2014-01-23 16:41:02 +00:00
|
|
|
gl_bind_framebuffer_object (GLFramebufferObject * fbo);
|
2010-03-30 12:59:15 +00:00
|
|
|
|
2012-07-19 15:55:00 +00:00
|
|
|
G_GNUC_INTERNAL
|
2010-03-30 12:59:15 +00:00
|
|
|
gboolean
|
2014-01-23 16:41:02 +00:00
|
|
|
gl_unbind_framebuffer_object (GLFramebufferObject * fbo);
|
2010-03-30 12:59:15 +00:00
|
|
|
|
2015-11-26 09:14:45 +00:00
|
|
|
typedef enum {
|
|
|
|
GST_VAAPI_GL_API_NONE = 0,
|
|
|
|
GST_VAAPI_GL_API_OPENGL = (1 << 0),
|
|
|
|
GST_VAAPI_GL_API_OPENGL3 = (1 << 1),
|
|
|
|
GST_VAAPI_GL_API_GLES1 = (1 << 15),
|
|
|
|
GST_VAAPI_GL_API_GLES2 = (1 << 16),
|
|
|
|
|
|
|
|
GST_VAAPI_GL_API_ANY = G_MAXUINT32
|
|
|
|
} GstVaapiGLApi;
|
|
|
|
|
|
|
|
G_GNUC_INTERNAL
|
|
|
|
GstVaapiGLApi
|
|
|
|
gl_get_current_api (guint * major, guint * minor);
|
|
|
|
|
2010-03-25 17:28:49 +00:00
|
|
|
#endif /* GST_VAAPI_UTILS_GLX_H */
|