From 95e1971f8fc2b9f1814a80ffa19d17fc4eda9e47 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 21 Sep 2024 16:38:15 +0200 Subject: Fix first frame is black --- src/capture/kms.c | 3 +++ src/capture/portal.c | 3 +++ src/capture/xcomposite.c | 3 +++ 3 files changed, 9 insertions(+) (limited to 'src/capture') diff --git a/src/capture/kms.c b/src/capture/kms.c index 7a61962..ecc75a5 100644 --- a/src/capture/kms.c +++ b/src/capture/kms.c @@ -570,6 +570,9 @@ static int gsr_capture_kms_capture(gsr_capture *cap, AVFrame *frame, gsr_color_c if(!capture_is_combined_plane) capture_pos = (vec2i){drm_fd->x, drm_fd->y}; + self->params.egl->glFlush(); + self->params.egl->glFinish(); + /* Fast opengl free path */ if(self->monitor_rotation == GSR_MONITOR_ROT_0 && video_codec_context_is_vaapi(self->video_codec_context) && self->params.egl->gpu_info.vendor == GSR_GPU_VENDOR_AMD) { int fds[4]; diff --git a/src/capture/portal.c b/src/capture/portal.c index 58d16d9..db5ba4e 100644 --- a/src/capture/portal.c +++ b/src/capture/portal.c @@ -336,6 +336,9 @@ static int gsr_capture_portal_capture(gsr_capture *cap, AVFrame *frame, gsr_colo const vec2i target_pos = { max_int(0, frame->width / 2 - self->capture_size.x / 2), max_int(0, frame->height / 2 - self->capture_size.y / 2) }; + self->params.egl->glFlush(); + self->params.egl->glFinish(); + // TODO: Handle region crop /* Fast opengl free path */ diff --git a/src/capture/xcomposite.c b/src/capture/xcomposite.c index 31d0b7e..9d053bb 100644 --- a/src/capture/xcomposite.c +++ b/src/capture/xcomposite.c @@ -258,6 +258,9 @@ static int gsr_capture_xcomposite_capture(gsr_capture *cap, AVFrame *frame, gsr_ const vec2i target_pos = { max_int(0, frame->width / 2 - self->texture_size.x / 2), max_int(0, frame->height / 2 - self->texture_size.y / 2) }; + self->params.egl->glFlush(); + self->params.egl->glFinish(); + /* Fast opengl free path */ if(video_codec_context_is_vaapi(self->video_codec_context) && self->params.egl->gpu_info.vendor == GSR_GPU_VENDOR_AMD) { vaapi_copy_egl_image_to_video_surface(self->params.egl, self->window_texture.image, (vec2i){0, 0}, self->texture_size, target_pos, self->texture_size, self->video_codec_context, frame); -- cgit v1.2.3