aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-03-04 20:30:43 +0100
committerdec05eba <dec05eba@protonmail.com>2024-03-08 11:35:26 +0100
commit0d89378021b9e8913b521164d1bc436d9bc2630f (patch)
treec72f8ae7453aa7c6b4f149b1d6292d2292b6411b /include
parentd0c221a233e0bc07e22cffb06ec3ae77a5f96010 (diff)
Use opengl capture for nvfbc (prepare for vulkan capture without cuda)
Diffstat (limited to 'include')
-rw-r--r--include/capture/capture.h2
-rw-r--r--include/capture/nvfbc.h6
-rw-r--r--include/color_conversion.h5
-rw-r--r--include/egl.h45
4 files changed, 51 insertions, 7 deletions
diff --git a/include/capture/capture.h b/include/capture/capture.h
index 2ca57cc..43b5de5 100644
--- a/include/capture/capture.h
+++ b/include/capture/capture.h
@@ -55,7 +55,7 @@ void gsr_capture_end(gsr_capture *cap, AVFrame *frame);
void gsr_capture_destroy(gsr_capture *cap, AVCodecContext *video_codec_context);
bool gsr_capture_base_setup_vaapi_textures(gsr_capture_base *self, AVFrame *frame, gsr_egl *egl, VADisplay va_dpy, VADRMPRIMESurfaceDescriptor *prime, gsr_color_range color_range);
-bool gsr_capture_base_setup_cuda_textures(gsr_capture_base *base, AVFrame *frame, gsr_cuda_context *cuda_context, gsr_egl *egl, gsr_color_range color_range, bool hdr);
+bool gsr_capture_base_setup_cuda_textures(gsr_capture_base *base, AVFrame *frame, gsr_cuda_context *cuda_context, gsr_egl *egl, gsr_color_range color_range, gsr_source_color source_color, bool hdr);
void gsr_capture_base_stop(gsr_capture_base *self, gsr_egl *egl);
#endif /* GSR_CAPTURE_CAPTURE_H */
diff --git a/include/capture/nvfbc.h b/include/capture/nvfbc.h
index 431777b..da486f2 100644
--- a/include/capture/nvfbc.h
+++ b/include/capture/nvfbc.h
@@ -4,16 +4,16 @@
#include "capture.h"
#include "../vec2.h"
-typedef struct _XDisplay Display;
-
typedef struct {
- Display *dpy;
+ gsr_egl *egl;
const char *display_to_capture; /* if this is "screen", then the entire x11 screen is captured (all displays). A copy is made of this */
int fps;
vec2i pos;
vec2i size;
bool direct_capture;
bool overclock;
+ bool hdr;
+ gsr_color_range color_range;
} gsr_capture_nvfbc_params;
gsr_capture* gsr_capture_nvfbc_create(const gsr_capture_nvfbc_params *params);
diff --git a/include/color_conversion.h b/include/color_conversion.h
index 222be4b..1848715 100644
--- a/include/color_conversion.h
+++ b/include/color_conversion.h
@@ -11,11 +11,12 @@ typedef enum {
} gsr_color_range;
typedef enum {
- GSR_SOURCE_COLOR_RGB
+ GSR_SOURCE_COLOR_RGB,
+ GSR_SOURCE_COLOR_BGR
} gsr_source_color;
typedef enum {
- GSR_DESTINATION_COLOR_BGR,
+ GSR_DESTINATION_COLOR_BGR, // TODO: remove
GSR_DESTINATION_COLOR_NV12, /* YUV420, BT709, 8-bit */
GSR_DESTINATION_COLOR_P010 /* YUV420, BT2020, 10-bit */
} gsr_destination_color;
diff --git a/include/egl.h b/include/egl.h
index 6f0c11b..a0a44d0 100644
--- a/include/egl.h
+++ b/include/egl.h
@@ -8,6 +8,7 @@
#include <stdbool.h>
#include <stdint.h>
#include "vec2.h"
+#include "defs.h"
#ifdef _WIN64
typedef signed long long int khronos_intptr_t;
@@ -33,6 +34,10 @@ typedef void* EGLImage;
typedef void* EGLImageKHR;
typedef void *GLeglImageOES;
typedef void (*__eglMustCastToProperFunctionPointerType)(void);
+typedef struct __GLXFBConfigRec *GLXFBConfig;
+typedef struct __GLXcontextRec *GLXContext;
+typedef XID GLXDrawable;
+typedef void(*__GLXextFuncPtr)(void);
#define EGL_SUCCESS 0x3000
#define EGL_BUFFER_SIZE 0x3020
@@ -71,6 +76,10 @@ typedef void (*__eglMustCastToProperFunctionPointerType)(void);
#define GL_TEXTURE_2D 0x0DE1
#define GL_TEXTURE_EXTERNAL_OES 0x8D65
#define GL_RED 0x1903
+#define GL_GREEN 0x1904
+#define GL_BLUE 0x1905
+#define GL_ALPHA 0x1906
+#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46
#define GL_RG 0x8227
#define GL_RGB 0x1907
#define GL_RGBA 0x1908
@@ -98,6 +107,7 @@ typedef void (*__eglMustCastToProperFunctionPointerType)(void);
#define GL_BLEND 0x0BE2
#define GL_SRC_ALPHA 0x0302
#define GL_ONE_MINUS_SRC_ALPHA 0x0303
+#define GL_DEBUG_OUTPUT 0x92E0
#define GL_VENDOR 0x1F00
#define GL_RENDERER 0x1F01
@@ -112,6 +122,11 @@ typedef void (*__eglMustCastToProperFunctionPointerType)(void);
typedef unsigned int (*FUNC_eglExportDMABUFImageQueryMESA)(EGLDisplay dpy, EGLImageKHR image, int *fourcc, int *num_planes, uint64_t *modifiers);
typedef unsigned int (*FUNC_eglExportDMABUFImageMESA)(EGLDisplay dpy, EGLImageKHR image, int *fds, int32_t *strides, int32_t *offsets);
typedef void (*FUNC_glEGLImageTargetTexture2DOES)(unsigned int target, GLeglImageOES image);
+typedef GLXContext (*FUNC_glXCreateContextAttribsARB)(Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list);
+typedef void (*FUNC_glXSwapIntervalEXT)(Display * dpy, GLXDrawable drawable, int interval);
+typedef int (*FUNC_glXSwapIntervalMESA)(unsigned int interval);
+typedef int (*FUNC_glXSwapIntervalSGI)(int interval);
+typedef void (*GLDEBUGPROC)(unsigned int source, unsigned int type, unsigned int id, unsigned int severity, int length, const char *message, const void *userParam);
#define GSR_MAX_OUTPUTS 32
@@ -139,15 +154,28 @@ typedef struct {
int num_outputs;
} gsr_wayland;
+typedef enum {
+ GSR_GL_CONTEXT_TYPE_EGL,
+ GSR_GL_CONTEXT_TYPE_GLX
+} gsr_gl_context_type;
+
typedef struct gsr_egl gsr_egl;
struct gsr_egl {
void *egl_library;
+ void *glx_library;
void *gl_library;
+ gsr_gl_context_type context_type;
+
EGLDisplay egl_display;
EGLSurface egl_surface;
EGLContext egl_context;
+ void *glx_context;
+ void *glx_fb_config;
+
+ gsr_gpu_info gpu_info;
+
gsr_x11 x11;
gsr_wayland wayland;
char card_path[128];
@@ -173,6 +201,19 @@ struct gsr_egl {
FUNC_eglExportDMABUFImageMESA eglExportDMABUFImageMESA;
FUNC_glEGLImageTargetTexture2DOES glEGLImageTargetTexture2DOES;
+ __GLXextFuncPtr (*glXGetProcAddress)(const unsigned char *procName);
+ GLXFBConfig* (*glXChooseFBConfig)(Display *dpy, int screen, const int *attribList, int *nitems);
+ Bool (*glXMakeContextCurrent)(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
+ // TODO: Remove
+ GLXContext (*glXCreateNewContext)(Display *dpy, GLXFBConfig config, int renderType, GLXContext shareList, Bool direct);
+ void (*glXSwapBuffers)(Display *dpy, GLXDrawable drawable);
+ FUNC_glXCreateContextAttribsARB glXCreateContextAttribsARB;
+
+ /* Optional */
+ FUNC_glXSwapIntervalEXT glXSwapIntervalEXT;
+ FUNC_glXSwapIntervalMESA glXSwapIntervalMESA;
+ FUNC_glXSwapIntervalSGI glXSwapIntervalSGI;
+
unsigned int (*glGetError)(void);
const unsigned char* (*glGetString)(unsigned int name);
void (*glFlush)(void);
@@ -183,6 +224,7 @@ struct gsr_egl {
void (*glDeleteTextures)(int n, const unsigned int *texture);
void (*glBindTexture)(unsigned int target, unsigned int texture);
void (*glTexParameteri)(unsigned int target, unsigned int pname, int param);
+ void (*glTexParameteriv)(unsigned int target, unsigned int pname, const int *params);
void (*glGetTexLevelParameteriv)(unsigned int target, int level, unsigned int pname, int *params);
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);
@@ -224,9 +266,10 @@ struct gsr_egl {
int (*glGetUniformLocation)(unsigned int program, const char *name);
void (*glUniform1f)(int location, float v0);
void (*glUniform2f)(int location, float v0, float v1);
+ void (*glDebugMessageCallback)(GLDEBUGPROC callback, const void *userParam);
};
-bool gsr_egl_load(gsr_egl *self, Display *dpy, bool wayland);
+bool gsr_egl_load(gsr_egl *self, Display *dpy, bool wayland, bool is_monitor_capture);
void gsr_egl_unload(gsr_egl *self);
void gsr_egl_update(gsr_egl *self);