aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/egl.h2
-rw-r--r--src/capture/kms.c10
-rw-r--r--src/egl.c4
-rw-r--r--src/pipewire.c9
4 files changed, 13 insertions, 12 deletions
diff --git a/include/egl.h b/include/egl.h
index a2228f5..6a44d7e 100644
--- a/include/egl.h
+++ b/include/egl.h
@@ -42,7 +42,9 @@ typedef void(*__GLXextFuncPtr)(void);
#define EGL_BUFFER_SIZE 0x3020
#define EGL_RENDERABLE_TYPE 0x3040
#define EGL_OPENGL_API 0x30A2
+#define EGL_OPENGL_ES_API 0x30A0
#define EGL_OPENGL_BIT 0x0008
+#define EGL_OPENGL_ES_BIT 0x0001
#define EGL_NONE 0x3038
#define EGL_CONTEXT_CLIENT_VERSION 0x3098
#define EGL_BACK_BUFFER 0x3084
diff --git a/src/capture/kms.c b/src/capture/kms.c
index 7785d8d..1616bd7 100644
--- a/src/capture/kms.c
+++ b/src/capture/kms.c
@@ -287,7 +287,6 @@ static bool gsr_capture_kms_bind_image_to_texture(gsr_capture_kms *self, EGLImag
self->params.egl->glBindTexture(texture_target, texture_id);
self->params.egl->glEGLImageTargetTexture2DOES(texture_target, image);
const bool success = self->params.egl->glGetError() == 0;
- self->params.egl->eglDestroyImage(self->params.egl->egl_display, image);
self->params.egl->glBindTexture(texture_target, 0);
return success;
}
@@ -388,12 +387,15 @@ static int gsr_capture_kms_capture(gsr_capture *cap, AVFrame *frame, gsr_color_c
gsr_capture_kms_bind_image_to_texture(self, image, self->external_input_texture_id, true);
} else {
if(!gsr_capture_kms_bind_image_to_texture(self, image, self->input_texture_id, false)) {
- fprintf(stderr, "gsr error: gsr_pipewire_map_texture: failed to bind image to texture, trying with external texture\n");
+ fprintf(stderr, "gsr error: gsr_capture_kms_capture: failed to bind image to texture, trying with external texture\n");
self->external_texture_fallback = true;
gsr_capture_kms_bind_image_to_texture(self, image, self->external_input_texture_id, true);
}
}
+ if(image)
+ self->params.egl->eglDestroyImage(self->params.egl->egl_display, image);
+
vec2i capture_pos = self->capture_pos;
if(!capture_is_combined_plane)
capture_pos = (vec2i){drm_fd->x, drm_fd->y};
@@ -453,9 +455,11 @@ static int gsr_capture_kms_capture(gsr_capture *cap, AVFrame *frame, gsr_color_c
const int target = cursor_texture_id_is_external ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D;
self->params.egl->glBindTexture(target, self->cursor_texture_id);
self->params.egl->glEGLImageTargetTexture2DOES(target, cursor_image);
- self->params.egl->eglDestroyImage(self->params.egl->egl_display, cursor_image);
self->params.egl->glBindTexture(target, 0);
+ if(cursor_image)
+ self->params.egl->eglDestroyImage(self->params.egl->egl_display, cursor_image);
+
self->params.egl->glEnable(GL_SCISSOR_TEST);
self->params.egl->glScissor(target_x, target_y, self->capture_size.x, self->capture_size.y);
diff --git a/src/egl.c b/src/egl.c
index 73645d6..2c68278 100644
--- a/src/egl.c
+++ b/src/egl.c
@@ -187,7 +187,7 @@ static bool gsr_egl_create_window(gsr_egl *self, bool wayland) {
const int32_t attr[] = {
EGL_BUFFER_SIZE, 24,
- EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
EGL_NONE, EGL_NONE
};
@@ -226,7 +226,7 @@ static bool gsr_egl_create_window(gsr_egl *self, bool wayland) {
}
}
- self->eglBindAPI(EGL_OPENGL_API);
+ self->eglBindAPI(EGL_OPENGL_ES_API);
self->egl_display = self->eglGetDisplay(self->wayland.dpy ? (EGLNativeDisplayType)self->wayland.dpy : (EGLNativeDisplayType)self->x11.dpy);
if(!self->egl_display) {
diff --git a/src/pipewire.c b/src/pipewire.c
index 35f0e45..c81ddde 100644
--- a/src/pipewire.c
+++ b/src/pipewire.c
@@ -640,7 +640,6 @@ static bool gsr_pipewire_bind_image_to_texture(gsr_pipewire *self, EGLImage imag
self->egl->glBindTexture(texture_target, texture_id);
self->egl->glEGLImageTargetTexture2DOES(texture_target, image);
const bool success = self->egl->glGetError() == 0;
- self->egl->eglDestroyImage(self->egl->egl_display, image);
self->egl->glBindTexture(texture_target, 0);
return success;
}
@@ -693,12 +692,8 @@ bool gsr_pipewire_map_texture(gsr_pipewire *self, gsr_texture_map texture_map, g
}
}
- const int texture_target = self->external_texture_fallback ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D;
- while(self->egl->glGetError() != 0){}
- self->egl->glBindTexture(texture_target, texture_map.texture_id);
- self->egl->glEGLImageTargetTexture2DOES(texture_target, image);
- self->egl->eglDestroyImage(self->egl->egl_display, image);
- self->egl->glBindTexture(texture_target, 0);
+ if(image)
+ self->egl->eglDestroyImage(self->egl->egl_display, image);
if(self->cursor.data) {
self->egl->glBindTexture(GL_TEXTURE_2D, texture_map.cursor_texture_id);