mirror of
https://repo.dec05eba.com/gpu-screen-recorder
synced 2026-03-31 17:17:16 +09:00
Fix portal capture on intel, support multiple planes in one egl image (might fix capture on intel iris)
This commit is contained in:
93
src/utils.c
93
src/utils.c
@@ -8,6 +8,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <xf86drmMode.h>
|
||||
#include <xf86drm.h>
|
||||
@@ -518,3 +519,95 @@ int create_directory_recursive(char *path) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
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) {
|
||||
size_t img_attr_index = 0;
|
||||
|
||||
img_attr[img_attr_index++] = EGL_LINUX_DRM_FOURCC_EXT;
|
||||
img_attr[img_attr_index++] = format;
|
||||
|
||||
img_attr[img_attr_index++] = EGL_WIDTH;
|
||||
img_attr[img_attr_index++] = width;
|
||||
|
||||
img_attr[img_attr_index++] = EGL_HEIGHT;
|
||||
img_attr[img_attr_index++] = height;
|
||||
|
||||
if(num_planes >= 1) {
|
||||
img_attr[img_attr_index++] = EGL_DMA_BUF_PLANE0_FD_EXT;
|
||||
img_attr[img_attr_index++] = fds[0];
|
||||
|
||||
img_attr[img_attr_index++] = EGL_DMA_BUF_PLANE0_OFFSET_EXT;
|
||||
img_attr[img_attr_index++] = offsets[0];
|
||||
|
||||
img_attr[img_attr_index++] = EGL_DMA_BUF_PLANE0_PITCH_EXT;
|
||||
img_attr[img_attr_index++] = pitches[0];
|
||||
|
||||
if(use_modifier) {
|
||||
img_attr[img_attr_index++] = EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT;
|
||||
img_attr[img_attr_index++] = modifiers[0] & 0xFFFFFFFFULL;
|
||||
|
||||
img_attr[img_attr_index++] = EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT;
|
||||
img_attr[img_attr_index++] = modifiers[0] >> 32ULL;
|
||||
}
|
||||
}
|
||||
|
||||
if(num_planes >= 2) {
|
||||
img_attr[img_attr_index++] = EGL_DMA_BUF_PLANE1_FD_EXT;
|
||||
img_attr[img_attr_index++] = fds[1];
|
||||
|
||||
img_attr[img_attr_index++] = EGL_DMA_BUF_PLANE1_OFFSET_EXT;
|
||||
img_attr[img_attr_index++] = offsets[1];
|
||||
|
||||
img_attr[img_attr_index++] = EGL_DMA_BUF_PLANE1_PITCH_EXT;
|
||||
img_attr[img_attr_index++] = pitches[1];
|
||||
|
||||
if(use_modifier) {
|
||||
img_attr[img_attr_index++] = EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT;
|
||||
img_attr[img_attr_index++] = modifiers[1] & 0xFFFFFFFFULL;
|
||||
|
||||
img_attr[img_attr_index++] = EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT;
|
||||
img_attr[img_attr_index++] = modifiers[1] >> 32ULL;
|
||||
}
|
||||
}
|
||||
|
||||
if(num_planes >= 3) {
|
||||
img_attr[img_attr_index++] = EGL_DMA_BUF_PLANE2_FD_EXT;
|
||||
img_attr[img_attr_index++] = fds[2];
|
||||
|
||||
img_attr[img_attr_index++] = EGL_DMA_BUF_PLANE2_OFFSET_EXT;
|
||||
img_attr[img_attr_index++] = offsets[2];
|
||||
|
||||
img_attr[img_attr_index++] = EGL_DMA_BUF_PLANE2_PITCH_EXT;
|
||||
img_attr[img_attr_index++] = pitches[2];
|
||||
|
||||
if(use_modifier) {
|
||||
img_attr[img_attr_index++] = EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT;
|
||||
img_attr[img_attr_index++] = modifiers[2] & 0xFFFFFFFFULL;
|
||||
|
||||
img_attr[img_attr_index++] = EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT;
|
||||
img_attr[img_attr_index++] = modifiers[2] >> 32ULL;
|
||||
}
|
||||
}
|
||||
|
||||
if(num_planes >= 4) {
|
||||
img_attr[img_attr_index++] = EGL_DMA_BUF_PLANE3_FD_EXT;
|
||||
img_attr[img_attr_index++] = fds[3];
|
||||
|
||||
img_attr[img_attr_index++] = EGL_DMA_BUF_PLANE3_OFFSET_EXT;
|
||||
img_attr[img_attr_index++] = offsets[3];
|
||||
|
||||
img_attr[img_attr_index++] = EGL_DMA_BUF_PLANE3_PITCH_EXT;
|
||||
img_attr[img_attr_index++] = pitches[3];
|
||||
|
||||
if(use_modifier) {
|
||||
img_attr[img_attr_index++] = EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT;
|
||||
img_attr[img_attr_index++] = modifiers[3] & 0xFFFFFFFFULL;
|
||||
|
||||
img_attr[img_attr_index++] = EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT;
|
||||
img_attr[img_attr_index++] = modifiers[3] >> 32ULL;
|
||||
}
|
||||
}
|
||||
|
||||
img_attr[img_attr_index++] = EGL_NONE;
|
||||
assert(img_attr_index <= 44);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user