aboutsummaryrefslogtreecommitdiff
path: root/src/pipewire.c
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-07-22 17:20:09 +0200
committerdec05eba <dec05eba@protonmail.com>2024-07-22 17:20:09 +0200
commite9343cce911c6401f9318165b4d098bdef723f8a (patch)
treeb2fc6c23729bfc9ac93c9ef77135f64c4792a51c /src/pipewire.c
parent28eef4619f983234a8c1c92430821c1eea7dff96 (diff)
Fix pipewire capture on amd (fallback to no drm modifiers if eglCreateImage fails), might happen because of a buggy desktop portal/pipewire implementation
Diffstat (limited to 'src/pipewire.c')
-rw-r--r--src/pipewire.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/pipewire.c b/src/pipewire.c
index db3122a..fae83cd 100644
--- a/src/pipewire.c
+++ b/src/pipewire.c
@@ -643,11 +643,27 @@ bool gsr_pipewire_map_texture(gsr_pipewire *self, unsigned int texture_id, unsig
modifiers[i] = self->format.info.raw.modifier;
}
+ EGLImage image = NULL;
intptr_t img_attr[44];
- setup_dma_buf_attrs(img_attr, spa_video_format_to_drm_format(self->format.info.raw.format), self->format.info.raw.size.width, self->format.info.raw.size.height,
- fds, offsets, pitches, modifiers, self->dmabuf_num_planes, true);
- EGLImage image = self->egl->eglCreateImage(self->egl->egl_display, 0, EGL_LINUX_DMA_BUF_EXT, NULL, img_attr);
+ if(self->no_modifiers_fallback) {
+ setup_dma_buf_attrs(img_attr, spa_video_format_to_drm_format(self->format.info.raw.format), self->format.info.raw.size.width, self->format.info.raw.size.height,
+ fds, offsets, pitches, modifiers, self->dmabuf_num_planes, false);
+ } else {
+ setup_dma_buf_attrs(img_attr, spa_video_format_to_drm_format(self->format.info.raw.format), self->format.info.raw.size.width, self->format.info.raw.size.height,
+ fds, offsets, pitches, modifiers, self->dmabuf_num_planes, true);
+
+ while(self->egl->eglGetError() != EGL_SUCCESS){}
+ image = self->egl->eglCreateImage(self->egl->egl_display, 0, EGL_LINUX_DMA_BUF_EXT, NULL, img_attr);
+ if(!image || self->egl->eglGetError() != EGL_SUCCESS) {
+ fprintf(stderr, "gsr error: gsr_pipewire_map_texture: failed to create egl image with modifiers, trying without modifiers\n");
+ self->no_modifiers_fallback = true;
+ setup_dma_buf_attrs(img_attr, spa_video_format_to_drm_format(self->format.info.raw.format), self->format.info.raw.size.width, self->format.info.raw.size.height,
+ fds, offsets, pitches, modifiers, self->dmabuf_num_planes, false);
+ image = self->egl->eglCreateImage(self->egl->egl_display, 0, EGL_LINUX_DMA_BUF_EXT, NULL, img_attr);
+ }
+ }
+
self->egl->glBindTexture(GL_TEXTURE_2D, texture_id);
self->egl->glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
self->egl->eglDestroyImage(self->egl->egl_display, image);