aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSteam Deck User <deck@archlinux.steamdeck>2023-04-01 15:14:36 +0200
committerSteam Deck User <deck@archlinux.steamdeck>2023-04-01 16:29:24 +0200
commit2f67083915ccb16727d00d49917a520d0962fb8c (patch)
tree6bc13adc7819305f03aa3e68f904d9e19e4b1248 /include
parent162eac8c2f460ac8231696b511785d69bb7c97ff (diff)
Use vaapi to do rgb->yuv420p color conversion
Enable window capture for amd/intel. Properly check if h264/hevc is supported on amd/intel before using codec.
Diffstat (limited to 'include')
-rw-r--r--include/egl.h35
-rw-r--r--include/vaapi.h168
2 files changed, 6 insertions, 197 deletions
diff --git a/include/egl.h b/include/egl.h
index 7f3321f..1021fc4 100644
--- a/include/egl.h
+++ b/include/egl.h
@@ -39,6 +39,10 @@ typedef void (*__eglMustCastToProperFunctionPointerType)(void);
#define EGL_OPENGL_ES2_BIT 0x0004
#define EGL_NONE 0x3038
#define EGL_CONTEXT_CLIENT_VERSION 0x3098
+#define EGL_BACK_BUFFER 0x3084
+#define EGL_GL_TEXTURE_2D 0x30B1
+#define EGL_TRUE 1
+#define EGL_IMAGE_PRESERVED_KHR 0x30D2
#define GL_TEXTURE_2D 0x0DE1
#define GL_RGB 0x1907
@@ -87,6 +91,8 @@ typedef struct {
unsigned int (*eglSwapBuffers)(EGLDisplay dpy, EGLSurface surface);
__eglMustCastToProperFunctionPointerType (*eglGetProcAddress)(const char *procname);
+ unsigned int (*eglExportDMABUFImageQueryMESA)(EGLDisplay dpy, EGLImageKHR image, int *fourcc, int *num_planes, uint64_t *modifiers);
+ unsigned int (*eglExportDMABUFImageMESA)(EGLDisplay dpy, EGLImageKHR image, int *fds, int32_t *strides, int32_t *offsets);
void (*glEGLImageTargetTexture2DOES)(unsigned int target, GLeglImageOES image);
unsigned int (*glGetError)(void);
@@ -101,35 +107,6 @@ typedef struct {
void (*glTexImage2D)(unsigned int target, int level, int internalFormat, int width, int height, int border, unsigned int format, unsigned int type, const void *pixels);
void (*glCopyImageSubData)(unsigned int srcName, unsigned int srcTarget, int srcLevel, int srcX, int srcY, int srcZ, unsigned int dstName, unsigned int dstTarget, int dstLevel, int dstX, int dstY, int dstZ, int srcWidth, int srcHeight, int srcDepth);
void (*glClearTexImage)(unsigned int texture, unsigned int level, unsigned int format, unsigned int type, const void *data);
- void (*glGenFramebuffers)(int n, unsigned int *framebuffers);
- void (*glBindFramebuffer)(unsigned int target, unsigned int framebuffer);
- void (*glViewport)(int x, int y, int width, int height);
- void (*glFramebufferTexture2D)(unsigned int target, unsigned int attachment, unsigned int textarget, unsigned int texture, int level);
- void (*glDrawBuffers)(int n, const unsigned int *bufs);
- unsigned int (*glCheckFramebufferStatus)(unsigned int target);
- void (*glBindBuffer)(unsigned int target, unsigned int buffer);
- void (*glGenBuffers)(int n, unsigned int *buffers);
- void (*glBufferData)(unsigned int target, khronos_ssize_t size, const void *data, unsigned int usage);
- void (*glGenVertexArrays)(int n, unsigned int *arrays);
- void (*glBindVertexArray)(unsigned int array);
-
- unsigned int (*glCreateProgram)(void);
- unsigned int (*glCreateShader)(unsigned int type);
- void (*glAttachShader)(unsigned int program, unsigned int shader);
- void (*glBindAttribLocation)(unsigned int program, unsigned int index, const char *name);
- void (*glCompileShader)(unsigned int shader);
- void (*glLinkProgram)(unsigned int program);
- void (*glShaderSource)(unsigned int shader, int count, const char *const*string, const int *length);
- void (*glUseProgram)(unsigned int program);
- void (*glGetProgramInfoLog)(unsigned int program, int bufSize, int *length, char *infoLog);
- void (*glGetShaderiv)(unsigned int shader, unsigned int pname, int *params);
- void (*glGetShaderInfoLog)(unsigned int shader, int bufSize, int *length, char *infoLog);
- void (*glDeleteProgram)(unsigned int program);
- void (*glDeleteShader)(unsigned int shader);
- void (*glGetProgramiv)(unsigned int program, unsigned int pname, int *params);
- void (*glVertexAttribPointer)(unsigned int index, int size, unsigned int type, unsigned char normalized, int stride, const void *pointer);
- void (*glEnableVertexAttribArray)(unsigned int index);
- void (*glDrawArrays)(unsigned int mode, int first, int count );
} gsr_egl;
bool gsr_egl_load(gsr_egl *self, Display *dpy);
diff --git a/include/vaapi.h b/include/vaapi.h
deleted file mode 100644
index 56acb13..0000000
--- a/include/vaapi.h
+++ /dev/null
@@ -1,168 +0,0 @@
-#ifndef GSR_VAAPI_H
-#define GSR_VAAPI_H
-
-#include <stdint.h>
-#include <stdbool.h>
-
-// To prevent hwcontext_vaapi.h from including va.h.. An ugly hack
-#define _VA_H_
-
-// These definitions are copied from va.h, which is licensed under MIT
-
-typedef void* VADisplay;
-typedef int VAStatus;
-
-typedef unsigned int VAGenericID;
-typedef VAGenericID VAConfigID;
-typedef VAGenericID VAContextID;
-typedef VAGenericID VASurfaceID;
-
-#define VA_STATUS_SUCCESS 0x00000000
-
-typedef struct {
- /** Pixel format fourcc of the whole surface (VA_FOURCC_*). */
- uint32_t fourcc;
- /** Width of the surface in pixels. */
- uint32_t width;
- /** Height of the surface in pixels. */
- uint32_t height;
- /** Number of distinct DRM objects making up the surface. */
- uint32_t num_objects;
- /** Description of each object. */
- struct {
- /** DRM PRIME file descriptor for this object. */
- int fd;
- /** Total size of this object (may include regions which are
- * not part of the surface). */
- uint32_t size;
- /** Format modifier applied to this object. */
- uint64_t drm_format_modifier;
- } objects[4];
- /** Number of layers making up the surface. */
- uint32_t num_layers;
- /** Description of each layer in the surface. */
- struct {
- /** DRM format fourcc of this layer (DRM_FOURCC_*). */
- uint32_t drm_format;
- /** Number of planes in this layer. */
- uint32_t num_planes;
- /** Index in the objects array of the object containing each
- * plane. */
- uint32_t object_index[4];
- /** Offset within the object of each plane. */
- uint32_t offset[4];
- /** Pitch of each plane. */
- uint32_t pitch[4];
- } layers[4];
-} VADRMPRIMESurfaceDescriptor;
-
-#define VA_INVALID_ID 0xffffffff
-#define VA_INVALID_SURFACE VA_INVALID_ID
-
-/** \brief Generic value types. */
-typedef enum {
- VAGenericValueTypeInteger = 1, /**< 32-bit signed integer. */
- VAGenericValueTypeFloat, /**< 32-bit floating-point value. */
- VAGenericValueTypePointer, /**< Generic pointer type */
- VAGenericValueTypeFunc /**< Pointer to function */
-} VAGenericValueType;
-
-/** \brief Generic function type. */
-typedef void (*VAGenericFunc)(void);
-
-/** \brief Generic value. */
-typedef struct _VAGenericValue {
- /** \brief Value type. See #VAGenericValueType. */
- VAGenericValueType type;
- /** \brief Value holder. */
- union {
- /** \brief 32-bit signed integer. */
- int32_t i;
- /** \brief 32-bit float. */
- float f;
- /** \brief Generic pointer. */
- void *p;
- /** \brief Pointer to function. */
- VAGenericFunc fn;
- } value;
-} VAGenericValue;
-
-/** @name Surface attribute flags */
-/**@{*/
-/** \brief Surface attribute is not supported. */
-#define VA_SURFACE_ATTRIB_NOT_SUPPORTED 0x00000000
-/** \brief Surface attribute can be got through vaQuerySurfaceAttributes(). */
-#define VA_SURFACE_ATTRIB_GETTABLE 0x00000001
-/** \brief Surface attribute can be set through vaCreateSurfaces(). */
-#define VA_SURFACE_ATTRIB_SETTABLE 0x00000002
-/**@}*/
-
-/** \brief Surface attribute types. */
-typedef enum {
- VASurfaceAttribNone = 0,
- /**
- * \brief Pixel format as a FOURCC (int, read/write).
- *
- * When vaQuerySurfaceAttributes() is called, the driver will return one
- * PixelFormat attribute per supported pixel format.
- *
- * When provided as an input to vaCreateSurfaces(), the driver will
- * allocate a surface with the provided pixel format.
- */
- VASurfaceAttribPixelFormat,
- /** \brief Minimal width in pixels (int, read-only). */
- VASurfaceAttribMinWidth,
- /** \brief Maximal width in pixels (int, read-only). */
- VASurfaceAttribMaxWidth,
- /** \brief Minimal height in pixels (int, read-only). */
- VASurfaceAttribMinHeight,
- /** \brief Maximal height in pixels (int, read-only). */
- VASurfaceAttribMaxHeight,
- /** \brief Surface memory type expressed in bit fields (int, read/write). */
- VASurfaceAttribMemoryType,
- /** \brief External buffer descriptor (pointer, write).
- *
- * Refer to the documentation for the memory type being created to
- * determine what descriptor structure to pass here. If not otherwise
- * stated, the common VASurfaceAttribExternalBuffers should be used.
- */
- VASurfaceAttribExternalBufferDescriptor,
- /** \brief Surface usage hint, gives the driver a hint of intended usage
- * to optimize allocation (e.g. tiling) (int, read/write). */
- VASurfaceAttribUsageHint,
- /** \brief List of possible DRM format modifiers (pointer, write).
- *
- * The value must be a pointer to a VADRMFormatModifierList. This can only
- * be used when allocating a new buffer, it's invalid to use this attribute
- * when importing an existing buffer.
- */
- VASurfaceAttribDRMFormatModifiers,
- /** \brief Number of surface attributes. */
- VASurfaceAttribCount
-} VASurfaceAttribType;
-
-/** \brief Surface attribute. */
-typedef struct _VASurfaceAttrib {
- /** \brief Type. */
- VASurfaceAttribType type;
- /** \brief Flags. See "Surface attribute flags". */
- uint32_t flags;
- /** \brief Value. See "Surface attribute types" for the expected types. */
- VAGenericValue value;
-} VASurfaceAttrib;
-
-#define VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2 0x40000000
-#define VA_EXPORT_SURFACE_READ_WRITE 0x0003
-#define VA_EXPORT_SURFACE_SEPARATE_LAYERS 0x0004
-
-typedef struct {
- void *library;
-
- VAStatus (*vaExportSurfaceHandle)(VADisplay dpy, VASurfaceID surface_id, uint32_t mem_type, uint32_t flags, void *descriptor);
- VAStatus (*vaSyncSurface)(VADisplay dpy, VASurfaceID render_target);
-} gsr_vaapi;
-
-bool gsr_vaapi_load(gsr_vaapi *self);
-void gsr_vaapi_unload(gsr_vaapi *self);
-
-#endif /* GSR_VAAPI_H */