From e1c613666ea394a2295a5cfb34c6c5e621876293 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 22 Apr 2023 00:46:48 +0200 Subject: kms_vaapi: add cursor capture for amd/intel monitor capture Always find largest drm buf, to fix some cases when there are multiple planes and we accidentally capture a drm buf that isn't the target buf. We always want the full SCREEN drm buf. --- include/capture/kms_vaapi.h | 1 - include/color_conversion.h | 16 +++------------- include/cursor.h | 2 ++ include/egl.h | 15 ++++++++++----- 4 files changed, 15 insertions(+), 19 deletions(-) (limited to 'include') diff --git a/include/capture/kms_vaapi.h b/include/capture/kms_vaapi.h index 2836123..741d74b 100644 --- a/include/capture/kms_vaapi.h +++ b/include/capture/kms_vaapi.h @@ -9,7 +9,6 @@ typedef struct _XDisplay Display; typedef struct { - Display *dpy; 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 */ diff --git a/include/color_conversion.h b/include/color_conversion.h index de83d1e..1fe488b 100644 --- a/include/color_conversion.h +++ b/include/color_conversion.h @@ -18,25 +18,15 @@ typedef struct { gsr_source_color source_color; gsr_destination_color destination_color; - unsigned int source_textures[2]; - int num_source_textures; - unsigned int destination_textures[2]; int num_destination_textures; - - float rotation; - - vec2f position; - vec2f size; } gsr_color_conversion_params; typedef struct { - gsr_egl *egl; + gsr_color_conversion_params params; + int rotation_uniforms[2]; gsr_shader shaders[2]; - unsigned int source_textures[2]; - unsigned int destination_textures[2]; - unsigned int framebuffers[2]; unsigned int vertex_array_object_id; @@ -46,6 +36,6 @@ typedef struct { int gsr_color_conversion_init(gsr_color_conversion *self, const gsr_color_conversion_params *params); void gsr_color_conversion_deinit(gsr_color_conversion *self); -int gsr_color_conversion_update(gsr_color_conversion *self, int width, int height); +int gsr_color_conversion_draw(gsr_color_conversion *self, unsigned int texture_id, vec2i source_pos, vec2i source_size, vec2i texture_pos, vec2i texture_size, float rotation); #endif /* GSR_COLOR_CONVERSION_H */ diff --git a/include/cursor.h b/include/cursor.h index 0a7831d..a189ec3 100644 --- a/include/cursor.h +++ b/include/cursor.h @@ -15,6 +15,7 @@ typedef struct { unsigned int texture_id; vec2i size; vec2i hotspot; + vec2i position; bool cursor_image_set; } gsr_cursor; @@ -24,5 +25,6 @@ void gsr_cursor_deinit(gsr_cursor *self); int gsr_cursor_change_window_target(gsr_cursor *self, Window window); void gsr_cursor_update(gsr_cursor *self, XEvent *xev); +void gsr_cursor_tick(gsr_cursor *self); #endif /* GSR_CURSOR_H */ diff --git a/include/egl.h b/include/egl.h index 0d291d0..fb8e887 100644 --- a/include/egl.h +++ b/include/egl.h @@ -66,7 +66,6 @@ typedef void (*__eglMustCastToProperFunctionPointerType)(void); #define GL_TEXTURE_WRAP_T 0x2803 #define GL_TEXTURE_MAG_FILTER 0x2800 #define GL_TEXTURE_MIN_FILTER 0x2801 -#define GL_LINEAR_MIPMAP_LINEAR 0x2703 #define GL_TEXTURE_WIDTH 0x1000 #define GL_TEXTURE_HEIGHT 0x1001 #define GL_NEAREST 0x2600 @@ -75,8 +74,11 @@ typedef void (*__eglMustCastToProperFunctionPointerType)(void); #define GL_FRAMEBUFFER 0x8D40 #define GL_COLOR_ATTACHMENT0 0x8CE0 #define GL_FRAMEBUFFER_COMPLETE 0x8CD5 -#define GL_STATIC_DRAW 0x88E4 +#define GL_STREAM_DRAW 0x88E0 #define GL_ARRAY_BUFFER 0x8892 +#define GL_BLEND 0x0BE2 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 #define GL_VENDOR 0x1F00 #define GL_RENDERER 0x1F01 @@ -129,7 +131,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 (*glGenerateMipmap)(unsigned int target); void (*glGenFramebuffers)(int n, unsigned int *framebuffers); void (*glBindFramebuffer)(unsigned int target, unsigned int framebuffer); void (*glDeleteFramebuffers)(int n, const unsigned int *framebuffers); @@ -140,11 +141,11 @@ typedef struct { 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 (*glBufferSubData)(unsigned int target, khronos_intptr_t offset, khronos_ssize_t size, const void *data); void (*glDeleteBuffers)(int n, const unsigned int *buffers); void (*glGenVertexArrays)(int n, unsigned int *arrays); void (*glBindVertexArray)(unsigned int array); void (*glDeleteVertexArrays)(int n, const unsigned int *arrays); - unsigned int (*glCreateProgram)(void); unsigned int (*glCreateShader)(unsigned int type); void (*glAttachShader)(unsigned int program, unsigned int shader); @@ -161,7 +162,11 @@ typedef struct { 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 ); + void (*glDrawArrays)(unsigned int mode, int first, int count); + void (*glEnable)(unsigned int cap); + void (*glBlendFunc)(unsigned int sfactor, unsigned int dfactor); + int (*glGetUniformLocation)(unsigned int program, const char *name); + void (*glUniform1f)(int location, float v0); } gsr_egl; bool gsr_egl_load(gsr_egl *self, Display *dpy); -- cgit v1.2.3