From b5b4d6b2bdd1809b2e8af0b7ddec32a8d4f88e9a Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 22 Jul 2024 04:58:41 +0200 Subject: Fix portal capture on intel, support multiple planes in one egl image (might fix capture on intel iris) --- include/egl.h | 15 +++++++++++++++ include/pipewire.h | 9 ++++++--- include/utils.h | 3 +++ 3 files changed, 24 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/egl.h b/include/egl.h index c86cb6b..c1e0aea 100644 --- a/include/egl.h +++ b/include/egl.h @@ -56,8 +56,23 @@ typedef void(*__GLXextFuncPtr)(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_PLANE1_FD_EXT 0x3275 +#define EGL_DMA_BUF_PLANE1_OFFSET_EXT 0x3276 +#define EGL_DMA_BUF_PLANE1_PITCH_EXT 0x3277 +#define EGL_DMA_BUF_PLANE2_FD_EXT 0x3278 +#define EGL_DMA_BUF_PLANE2_OFFSET_EXT 0x3279 +#define EGL_DMA_BUF_PLANE2_PITCH_EXT 0x327A +#define EGL_DMA_BUF_PLANE3_FD_EXT 0x3440 +#define EGL_DMA_BUF_PLANE3_OFFSET_EXT 0x3441 +#define EGL_DMA_BUF_PLANE3_PITCH_EXT 0x3442 #define EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT 0x3443 #define EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT 0x3444 +#define EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT 0x3445 +#define EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT 0x3446 +#define EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT 0x3447 +#define EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT 0x3448 +#define EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT 0x3449 +#define EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT 0x344A #define EGL_LINUX_DMA_BUF_EXT 0x3270 #define EGL_RED_SIZE 0x3024 #define EGL_ALPHA_SIZE 0x3021 diff --git a/include/pipewire.h b/include/pipewire.h index 2a53423..4e486fc 100644 --- a/include/pipewire.h +++ b/include/pipewire.h @@ -9,7 +9,8 @@ #include #define GSR_PIPEWIRE_MAX_MODIFIERS 1024 -#define GSR_PIPEWIRE_NUM_VIDEO_FORMATS 10 +#define GSR_PIPEWIRE_NUM_VIDEO_FORMATS 6 +#define GSR_PIPEWIRE_DMABUF_MAX_PLANES 4 typedef struct gsr_egl gsr_egl; @@ -78,7 +79,8 @@ typedef struct { gsr_pipewire_data_version server_version; gsr_pipewire_video_info video_info; - gsr_pipewire_dmabuf_data dmabuf_data; + gsr_pipewire_dmabuf_data dmabuf_data[GSR_PIPEWIRE_DMABUF_MAX_PLANES]; + size_t dmabuf_num_planes; bool started; bool stopped; @@ -95,7 +97,8 @@ typedef struct { bool gsr_pipewire_init(gsr_pipewire *self, int pipewire_fd, uint32_t pipewire_node, int fps, bool capture_cursor, gsr_egl *egl); void gsr_pipewire_deinit(gsr_pipewire *self); -bool gsr_pipewire_map_texture(gsr_pipewire *self, unsigned int texture_id, unsigned int cursor_texture_id, gsr_pipewire_region *region, gsr_pipewire_region *cursor_region, int *plane_fd); +/* |plane_fds| should be at GSR_PIPEWIRE_DMABUF_MAX_PLANES in size */ +bool gsr_pipewire_map_texture(gsr_pipewire *self, unsigned int texture_id, unsigned int cursor_texture_id, gsr_pipewire_region *region, gsr_pipewire_region *cursor_region, int *plane_fds, int *num_plane_fds); bool gsr_pipewire_recording_stopped(gsr_pipewire *self); #endif /* GSR_PIPEWIRE_H */ diff --git a/include/utils.h b/include/utils.h index c08b3f6..3921dad 100644 --- a/include/utils.h +++ b/include/utils.h @@ -44,4 +44,7 @@ bool gsr_card_path_get_render_path(const char *card_path, char *render_path); int create_directory_recursive(char *path); +/* |img_attr| needs to be at least 44 in size */ +void setup_dma_buf_attrs(intptr_t *img_attr, uint32_t format, uint32_t width, uint32_t height, const int *fds, const uint32_t *offsets, const uint32_t *pitches, const uint64_t *modifiers, int num_planes, bool use_modifier); + #endif /* GSR_UTILS_H */ -- cgit v1.2.3