aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/capture/kms_cuda.h18
-rw-r--r--include/capture/kms_vaapi.h2
-rw-r--r--include/color_conversion.h1
-rw-r--r--include/cuda.h3
-rw-r--r--include/egl.h37
-rw-r--r--include/utils.h19
6 files changed, 71 insertions, 9 deletions
diff --git a/include/capture/kms_cuda.h b/include/capture/kms_cuda.h
new file mode 100644
index 0000000..e34802e
--- /dev/null
+++ b/include/capture/kms_cuda.h
@@ -0,0 +1,18 @@
+#ifndef GSR_CAPTURE_KMS_CUDA_H
+#define GSR_CAPTURE_KMS_CUDA_H
+
+#include "../vec2.h"
+#include "../utils.h"
+#include "capture.h"
+
+typedef struct _XDisplay Display;
+
+typedef struct {
+ const char *display_to_capture; /* if this is "screen", then the entire x11 screen is captured (all displays). A copy is made of this */
+ gsr_gpu_info gpu_inf;
+ const char *card_path; /* reference */
+} gsr_capture_kms_cuda_params;
+
+gsr_capture* gsr_capture_kms_cuda_create(const gsr_capture_kms_cuda_params *params);
+
+#endif /* GSR_CAPTURE_KMS_CUDA_H */
diff --git a/include/capture/kms_vaapi.h b/include/capture/kms_vaapi.h
index 741d74b..e7bd652 100644
--- a/include/capture/kms_vaapi.h
+++ b/include/capture/kms_vaapi.h
@@ -4,7 +4,6 @@
#include "../vec2.h"
#include "../utils.h"
#include "capture.h"
-#include <X11/X.h>
typedef struct _XDisplay Display;
@@ -12,6 +11,7 @@ typedef struct {
const char *display_to_capture; /* if this is "screen", then the entire x11 screen is captured (all displays). A copy is made of this */
gsr_gpu_info gpu_inf;
const char *card_path; /* reference */
+ bool wayland;
} gsr_capture_kms_vaapi_params;
gsr_capture* gsr_capture_kms_vaapi_create(const gsr_capture_kms_vaapi_params *params);
diff --git a/include/color_conversion.h b/include/color_conversion.h
index 1fe488b..e60f4d0 100644
--- a/include/color_conversion.h
+++ b/include/color_conversion.h
@@ -9,6 +9,7 @@ typedef enum {
} gsr_source_color;
typedef enum {
+ GSR_DESTINATION_COLOR_RGB,
GSR_DESTINATION_COLOR_NV12
} gsr_destination_color;
diff --git a/include/cuda.h b/include/cuda.h
index ab07429..41fe15b 100644
--- a/include/cuda.h
+++ b/include/cuda.h
@@ -91,7 +91,8 @@ typedef struct {
CUresult (*cuMemsetD8_v2)(CUdeviceptr dstDevice, unsigned char uc, size_t N);
CUresult (*cuMemcpy2D_v2)(const CUDA_MEMCPY2D *pCopy);
- CUresult (*cuGraphicsGLRegisterImage)(CUgraphicsResource *pCudaResource, unsigned int image, unsigned int target, unsigned int Flags);
+ CUresult (*cuGraphicsGLRegisterImage)(CUgraphicsResource *pCudaResource, unsigned int image, unsigned int target, unsigned int flags);
+ CUresult (*cuGraphicsEGLRegisterImage)(CUgraphicsResource *pCudaResource, void *image, unsigned int flags);
CUresult (*cuGraphicsResourceSetMapFlags)(CUgraphicsResource resource, unsigned int flags);
CUresult (*cuGraphicsMapResources)(unsigned int count, CUgraphicsResource *resources, CUstream hStream);
CUresult (*cuGraphicsUnmapResources)(unsigned int count, CUgraphicsResource *resources, CUstream hStream);
diff --git a/include/egl.h b/include/egl.h
index e410958..920e0f0 100644
--- a/include/egl.h
+++ b/include/egl.h
@@ -50,13 +50,24 @@ typedef void (*__eglMustCastToProperFunctionPointerType)(void);
#define EGL_DMA_BUF_PLANE0_FD_EXT 0x3272
#define EGL_DMA_BUF_PLANE0_OFFSET_EXT 0x3273
#define EGL_DMA_BUF_PLANE0_PITCH_EXT 0x3274
+#define EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT 0x3443
+#define EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT 0x3444
#define EGL_LINUX_DMA_BUF_EXT 0x3270
+#define EGL_OPENGL_API 0x30A2
+#define EGL_OPENGL_ES_API 0x30A0
+#define EGL_RED_SIZE 0x3024
+#define EGL_ALPHA_SIZE 0x3021
+#define EGL_BLUE_SIZE 0x3022
+#define EGL_GREEN_SIZE 0x3023
+#define EGL_SURFACE_TYPE 0x3033
+#define EGL_PBUFFER_BIT 0x0001
#define GL_FLOAT 0x1406
#define GL_FALSE 0
#define GL_TRUE 1
#define GL_TRIANGLES 0x0004
#define GL_TEXTURE_2D 0x0DE1
+#define GL_TEXTURE_EXTERNAL_OES 0x8D65 // TODO: Use this where applicable
#define GL_RGB 0x1907
#define GL_RGBA 0x1908
#define GL_RGBA8 0x8058
@@ -97,11 +108,27 @@ typedef void (*FUNC_glEGLImageTargetTexture2DOES)(unsigned int target, GLeglImag
typedef struct {
void *egl_library;
void *gl_library;
- Display *dpy;
+
EGLDisplay egl_display;
EGLSurface egl_surface;
EGLContext egl_context;
- Window window;
+
+ Display *x11_dpy;
+ Window x11_window;
+
+ void *wayland_dpy;
+ void *wayland_window;
+ void *wayland_registry;
+ void *wayland_surface;
+ void *wayland_compositor;
+
+ int fd;
+ uint32_t width;
+ uint32_t height;
+ uint32_t pitch;
+ uint32_t offset;
+ uint32_t pixel_format;
+ uint64_t modifier;
int32_t (*eglGetError)(void);
EGLDisplay (*eglGetDisplay)(EGLNativeDisplayType display_id);
@@ -117,6 +144,7 @@ typedef struct {
unsigned int (*eglDestroyImage)(EGLDisplay dpy, EGLImage image);
unsigned int (*eglSwapInterval)(EGLDisplay dpy, int32_t interval);
unsigned int (*eglSwapBuffers)(EGLDisplay dpy, EGLSurface surface);
+ unsigned int (*eglBindAPI)(unsigned int api);
__eglMustCastToProperFunctionPointerType (*eglGetProcAddress)(const char *procname);
FUNC_eglExportDMABUFImageQueryMESA eglExportDMABUFImageQueryMESA;
@@ -173,7 +201,10 @@ typedef struct {
void (*glUniform1f)(int location, float v0);
} gsr_egl;
-bool gsr_egl_load(gsr_egl *self, Display *dpy);
+bool gsr_egl_load(gsr_egl *self, Display *dpy, bool wayland);
void gsr_egl_unload(gsr_egl *self);
+void gsr_egl_update(gsr_egl *self);
+void gsr_egl_cleanup_frame(gsr_egl *self);
+
#endif /* GSR_EGL_H */
diff --git a/include/utils.h b/include/utils.h
index 7d76a2d..68d4e81 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -3,6 +3,7 @@
#include "vec2.h"
#include <stdbool.h>
+#include <stdint.h>
#include <X11/extensions/Xrandr.h>
typedef enum {
@@ -17,10 +18,20 @@ typedef struct {
} gsr_gpu_info;
typedef struct {
+ const char *name;
+ int name_len;
vec2i pos;
vec2i size;
+ XRRCrtcInfo *crt_info; /* Only on x11 */
+ uint32_t connector_id; /* Only on drm */
} gsr_monitor;
+typedef enum {
+ GSR_CONNECTION_X11,
+ GSR_CONNECTION_WAYLAND,
+ GSR_CONNECTION_DRM
+} gsr_connection_type;
+
typedef struct {
const char *name;
int name_len;
@@ -30,11 +41,11 @@ typedef struct {
double clock_get_monotonic_seconds(void);
-typedef void (*active_monitor_callback)(const XRROutputInfo *output_info, const XRRCrtcInfo *crt_info, const XRRModeInfo *mode_info, void *userdata);
-void for_each_active_monitor_output(Display *display, active_monitor_callback callback, void *userdata);
-bool get_monitor_by_name(Display *display, const char *name, gsr_monitor *monitor);
+typedef void (*active_monitor_callback)(const gsr_monitor *monitor, void *userdata);
+void for_each_active_monitor_output(void *connection, gsr_connection_type connection_type, active_monitor_callback callback, void *userdata);
+bool get_monitor_by_name(void *connection, gsr_connection_type connection_type, const char *name, gsr_monitor *monitor);
-bool gl_get_gpu_info(Display *dpy, gsr_gpu_info *info);
+bool gl_get_gpu_info(Display *dpy, gsr_gpu_info *info, bool wayland);
/* |output| should be at least 128 bytes in size */
bool gsr_get_valid_card_path(char *output);