Commit deb99d31 authored by Gwenole Beauchesne's avatar Gwenole Beauchesne Committed by Austin Yuan

Add OpenGL extensions (v3) and generic implementation with TFP and FBO.

parent 50c8ae8a
# Copyright (C) 2009 Splitted-Desktop Systems. All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sub license, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice (including the
# next paragraph) shall be included in all copies or substantial portions
# of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
AM_CFLAGS = -DLINUX -I$(top_srcdir)/va -I$(top_srcdir)/va/x11
source_c = \
va_glx.c \
va_glx_impl.c
source_h = \
va_glx.h \
va_backend_glx.h
source_h_priv = \
va_glx_impl.h \
va_glx_private.h
noinst_LTLIBRARIES = libva_glx.la
libva_glxincludedir = ${includedir}/va
libva_glxinclude_HEADERS = $(source_h)
libva_glx_la_SOURCES = $(source_c)
noinst_HEADERS = $(source_h_priv)
/*
* Copyright (C) 2009 Splitted-Desktop Systems. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef VA_BACKEND_GLX_H
#define VA_BACKEND_GLX_H
struct VADriverContext;
struct VADriverVTableGLX {
/* Optional: create a surface used for display to OpenGL */
VAStatus (*vaCreateSurfaceGLX)(
struct VADriverContext *ctx,
unsigned int gl_target,
unsigned int gl_texture,
void **gl_surface
);
/* Optional: destroy a VA/GLX surface */
VAStatus (*vaDestroySurfaceGLX)(
struct VADriverContext *ctx,
void *gl_surface
);
/* Optional: copy a VA surface to a VA/GLX surface */
VAStatus (*vaCopySurfaceGLX)(
struct VADriverContext *ctx,
void *gl_surface,
VASurfaceID surface,
unsigned int flags
);
};
#endif /* VA_BACKEND_GLX_H */
/*
* Copyright (C) 2009 Splitted-Desktop Systems. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdlib.h>
#include "va_glx_private.h"
#include "va_glx_impl.h"
#define INIT_CONTEXT(ctx, dpy) do { \
if (!vaDisplayIsValid(dpy)) \
return VA_STATUS_ERROR_INVALID_DISPLAY; \
\
ctx = ((VADisplayContextP)(dpy))->pDriverContext; \
if (!(ctx)) \
return VA_STATUS_ERROR_INVALID_DISPLAY; \
\
VAStatus status = va_glx_init_context(ctx); \
if (status != VA_STATUS_SUCCESS) \
return status; \
} while (0)
#define INVOKE(ctx, func, args) do { \
VADriverVTableGLXP vtable; \
vtable = &VA_DRIVER_CONTEXT_GLX(ctx)->vtable; \
if (!vtable->va##func##GLX) \
return VA_STATUS_ERROR_UNIMPLEMENTED; \
status = vtable->va##func##GLX args; \
} while (0)
// Check VADisplay is valid
static inline int vaDisplayIsValid(VADisplay dpy)
{
VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
return (pDisplayContext &&
pDisplayContext->vaIsValid &&
pDisplayContext->vaIsValid(pDisplayContext));
}
// Destroy VA/GLX display context
static void va_DisplayContextDestroy(VADisplayContextP pDisplayContext)
{
VADisplayContextGLXP pDisplayContextGLX;
VADriverContextP pDriverContext;
VADriverContextGLXP pDriverContextGLX;
if (!pDisplayContext)
return;
pDriverContext = pDisplayContext->pDriverContext;
pDriverContextGLX = pDriverContext->glx;
if (pDriverContextGLX) {
free(pDriverContextGLX);
pDriverContext->glx = NULL;
}
pDisplayContextGLX = pDisplayContext->opaque;
if (pDisplayContextGLX) {
vaDestroyFunc vaDestroy = pDisplayContextGLX->vaDestroy;
free(pDisplayContextGLX);
pDisplayContext->opaque = NULL;
if (vaDestroy)
vaDestroy(pDisplayContext);
}
}
// Return a suitable VADisplay for VA API
VADisplay vaGetDisplayGLX(Display *native_dpy)
{
VADisplay dpy = NULL;
VADisplayContextP pDisplayContext = NULL;
VADisplayContextGLXP pDisplayContextGLX = NULL;
VADriverContextP pDriverContext;
VADriverContextGLXP pDriverContextGLX = NULL;
dpy = vaGetDisplay(native_dpy);
if (!dpy)
return NULL;
pDisplayContext = (VADisplayContextP)dpy;
pDriverContext = pDisplayContext->pDriverContext;
pDisplayContextGLX = calloc(1, sizeof(*pDisplayContextGLX));
if (!pDisplayContextGLX)
goto error;
pDriverContextGLX = calloc(1, sizeof(*pDriverContextGLX));
if (!pDriverContextGLX)
goto error;
pDisplayContextGLX->vaDestroy = pDisplayContext->vaDestroy;
pDisplayContext->vaDestroy = va_DisplayContextDestroy;
pDisplayContext->opaque = pDisplayContextGLX;
pDriverContext->glx = pDriverContextGLX;
return dpy;
error:
free(pDriverContextGLX);
free(pDisplayContextGLX);
pDisplayContext->vaDestroy(pDisplayContext);
return NULL;
}
// Create a surface used for display to OpenGL
VAStatus vaCreateSurfaceGLX(
VADisplay dpy,
GLenum target,
GLuint texture,
void **gl_surface
)
{
VADriverContextP ctx;
VAStatus status;
/* Make sure it is a valid GL texture object */
if (!glIsTexture(texture))
return VA_STATUS_ERROR_INVALID_PARAMETER;
INIT_CONTEXT(ctx, dpy);
INVOKE(ctx, CreateSurface, (ctx, target, texture, gl_surface));
return status;
}
// Destroy a VA/GLX surface
VAStatus vaDestroySurfaceGLX(
VADisplay dpy,
void *gl_surface
)
{
VADriverContextP ctx;
VAStatus status;
INIT_CONTEXT(ctx, dpy);
INVOKE(ctx, DestroySurface, (ctx, gl_surface));
return status;
}
// Copy a VA surface to a VA/GLX surface
VAStatus vaCopySurfaceGLX(
VADisplay dpy,
void *gl_surface,
VASurfaceID surface,
unsigned int flags
)
{
VADriverContextP ctx;
VAStatus status;
INIT_CONTEXT(ctx, dpy);
INVOKE(ctx, CopySurface, (ctx, gl_surface, surface, flags));
return status;
}
/*
* Copyright (C) 2009 Splitted-Desktop Systems. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef VA_GLX_H
#define VA_GLX_H
#include <va/va.h>
#include <GL/glx.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* Return a suitable VADisplay for VA API
*
* @param[in] dpy the X11 display
* @return a VADisplay
*/
VADisplay vaGetDisplayGLX(
Display *dpy
);
/**
* Create a surface used for display to OpenGL
*
* The application shall maintain the live GLX context itself.
* Implementations are free to use glXGetCurrentContext() and
* glXGetCurrentDrawable() functions for internal purposes.
*
* @param[in] dpy the VA display
* @param[in] target the GL target to which the texture needs to be bound
* @param[in] texture the GL texture
* @param[out] gl_surface the VA/GLX surface
* @return VA_STATUS_SUCCESS if successful
*/
VAStatus vaCreateSurfaceGLX(
VADisplay dpy,
GLenum target,
GLuint texture,
void **gl_surface
);
/**
* Destroy a VA/GLX surface
*
* The application shall maintain the live GLX context itself.
* Implementations are free to use glXGetCurrentContext() and
* glXGetCurrentDrawable() functions for internal purposes.
*
* @param[in] dpy the VA display
* @param[in] gl_surface the VA surface
* @return VA_STATUS_SUCCESS if successful
*/
VAStatus vaDestroySurfaceGLX(
VADisplay dpy,
void *gl_surface
);
/**
* Copy a VA surface to a VA/GLX surface
*
* This function will not return until the copy is completed. At this
* point, the underlying GL texture will contain the surface pixels
* in an RGB format defined by the user.
*
* The application shall maintain the live GLX context itself.
* Implementations are free to use glXGetCurrentContext() and
* glXGetCurrentDrawable() functions for internal purposes.
*
* @param[in] dpy the VA display
* @param[in] gl_surface the VA/GLX destination surface
* @param[in] surface the VA source surface
* @param[in] flags the PutSurface flags
* @return VA_STATUS_SUCCESS if successful
*/
VAStatus vaCopySurfaceGLX(
VADisplay dpy,
void *gl_surface,
VASurfaceID surface,
unsigned int flags
);
#ifdef __cplusplus
}
#endif
#endif /* VA_GLX_H */
This diff is collapsed.
/*
* Copyright (C) 2009 Splitted-Desktop Systems. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef VA_GLX_IMPL_H
#define VA_GLX_IMPL_H
/**
* Initialize GLX driver context
*
* @param[in] ctx the VA driver context
* @return VA_STATUS_SUCCESS if successful
*/
VAStatus va_glx_init_context(VADriverContextP ctx)
ATTRIBUTE_HIDDEN;
#endif /* VA_GLX_IMPL_H */
/*
* Copyright (C) 2009 Splitted-Desktop Systems. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef VA_GLX_PRIVATE_H
#define VA_GLX_PRIVATE_H
#include "config.h"
#include "va.h"
#include "va_backend.h"
#include "va_x11.h"
#include "va_glx.h"
#include "va_backend_glx.h"
#if GLX_GLXEXT_VERSION < 18
typedef void (*PFNGLXBINDTEXIMAGEEXTPROC)(Display *, GLXDrawable, int, const int *);
typedef void (*PFNGLXRELEASETEXIMAGEEXTPROC)(Display *, GLXDrawable, int);
#endif
typedef struct VAOpenGLVTable *VAOpenGLVTableP;
struct VAOpenGLVTable {
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;
};
typedef struct VADisplayContextGLX *VADisplayContextGLXP;
typedef struct VADriverContextGLX *VADriverContextGLXP;
typedef struct VASurfaceGLX *VASurfaceGLXP;
typedef struct VADriverVTableGLX *VADriverVTableGLXP;
typedef void (*vaDestroyFunc)(VADisplayContextP);
struct VADisplayContextGLX {
vaDestroyFunc vaDestroy;
};
#define VA_DRIVER_CONTEXT_GLX(ctx) ((VADriverContextGLXP)((ctx)->glx))
struct VADriverContextGLX {
struct VADriverVTableGLX vtable;
struct VAOpenGLVTable gl_vtable;
unsigned int is_initialized : 1;
};
#endif /* VA_GLX_PRIVATE_H */
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