aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-07-26 05:21:47 +0200
committerdec05eba <dec05eba@protonmail.com>2024-07-26 10:55:24 +0200
commitb1d8346ed95f356842455fedb415f97d6c4cacb9 (patch)
tree90be0f3054f0e5f9988f25290c5fbedf1ee9914e /src
parentaf4f9b805a947b4495961a519af6045cd3f19a33 (diff)
Move glClear and glx/eglSwapBuffers from capture backends to main
Diffstat (limited to 'src')
-rw-r--r--src/capture/kms.c5
-rw-r--r--src/capture/nvfbc.c5
-rw-r--r--src/capture/portal.c5
-rw-r--r--src/capture/xcomposite.c5
-rw-r--r--src/egl.c9
-rw-r--r--src/main.cpp7
6 files changed, 13 insertions, 23 deletions
diff --git a/src/capture/kms.c b/src/capture/kms.c
index b3b4be2..5d0aed3 100644
--- a/src/capture/kms.c
+++ b/src/capture/kms.c
@@ -275,9 +275,6 @@ static int gsr_capture_kms_capture(gsr_capture *cap, AVFrame *frame, gsr_color_c
gsr_capture_kms *self = cap->priv;
const bool cursor_texture_id_is_external = self->params.egl->gpu_info.vendor == GSR_GPU_VENDOR_NVIDIA;
- //egl->glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
- self->params.egl->glClear(0);
-
gsr_capture_kms_cleanup_kms_fds(self);
gsr_kms_response_item *drm_fd = NULL;
@@ -457,8 +454,6 @@ static int gsr_capture_kms_capture(gsr_capture *cap, AVFrame *frame, gsr_color_c
self->params.egl->glDisable(GL_SCISSOR_TEST);
}
- self->params.egl->eglSwapBuffers(self->params.egl->egl_display, self->params.egl->egl_surface);
-
//self->params.egl->glFlush();
//self->params.egl->glFinish();
diff --git a/src/capture/nvfbc.c b/src/capture/nvfbc.c
index 134480d..1944dcc 100644
--- a/src/capture/nvfbc.c
+++ b/src/capture/nvfbc.c
@@ -418,16 +418,11 @@ static int gsr_capture_nvfbc_capture(gsr_capture *cap, AVFrame *frame, gsr_color
return 0;
}
- //cap_nvfbc->params.egl->glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
- cap_nvfbc->params.egl->glClear(0);
-
gsr_color_conversion_draw(color_conversion, cap_nvfbc->setup_params.dwTextures[grab_params.dwTextureIndex],
(vec2i){0, 0}, (vec2i){frame->width, frame->height},
(vec2i){0, 0}, (vec2i){frame->width, frame->height},
0.0f, false);
- cap_nvfbc->params.egl->glXSwapBuffers(cap_nvfbc->params.egl->x11.dpy, cap_nvfbc->params.egl->x11.window);
-
return 0;
}
diff --git a/src/capture/portal.c b/src/capture/portal.c
index 092fd9f..a53f0a1 100644
--- a/src/capture/portal.c
+++ b/src/capture/portal.c
@@ -297,9 +297,6 @@ static int gsr_capture_portal_capture(gsr_capture *cap, AVFrame *frame, gsr_colo
gsr_capture_portal_cleanup_plane_fds(self);
- //egl->glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
- self->params.egl->glClear(0);
-
/* TODO: Handle formats other than RGB(a) */
gsr_pipewire_region region = {0, 0, 0, 0};
gsr_pipewire_region cursor_region = {0, 0, 0, 0};
@@ -332,8 +329,6 @@ static int gsr_capture_portal_capture(gsr_capture *cap, AVFrame *frame, gsr_colo
0.0f, false);
self->params.egl->glDisable(GL_SCISSOR_TEST);
- self->params.egl->eglSwapBuffers(self->params.egl->egl_display, self->params.egl->egl_surface);
-
//self->params.egl->glFlush();
//self->params.egl->glFinish();
diff --git a/src/capture/xcomposite.c b/src/capture/xcomposite.c
index 7e78fb9..a81c19f 100644
--- a/src/capture/xcomposite.c
+++ b/src/capture/xcomposite.c
@@ -317,9 +317,6 @@ static int gsr_capture_xcomposite_capture(gsr_capture *cap, AVFrame *frame, gsr_
gsr_capture_xcomposite *self = cap->priv;
(void)frame;
- //self->params.egl->glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
- self->params.egl->glClear(0);
-
if(self->clear_background) {
self->clear_background = false;
gsr_color_conversion_clear(color_conversion);
@@ -352,8 +349,6 @@ static int gsr_capture_xcomposite_capture(gsr_capture *cap, AVFrame *frame, gsr_
self->params.egl->glDisable(GL_SCISSOR_TEST);
}
- self->params.egl->eglSwapBuffers(self->params.egl->egl_display, self->params.egl->egl_surface);
-
// TODO: Do video encoder specific conversion here
//self->params.egl->glFlush();
diff --git a/src/egl.c b/src/egl.c
index 3d4c5c7..da8dc9f 100644
--- a/src/egl.c
+++ b/src/egl.c
@@ -419,7 +419,6 @@ static bool gsr_egl_load_gl(gsr_egl *self, void *library) {
{ (void**)&self->glTexSubImage2D, "glTexSubImage2D" },
{ (void**)&self->glCopyImageSubData, "glCopyImageSubData" },
{ (void**)&self->glGetTexImage, "glGetTexImage" },
- { (void**)&self->glClearTexImage, "glClearTexImage" },
{ (void**)&self->glGenFramebuffers, "glGenFramebuffers" },
{ (void**)&self->glBindFramebuffer, "glBindFramebuffer" },
{ (void**)&self->glDeleteFramebuffers, "glDeleteFramebuffers" },
@@ -651,3 +650,11 @@ void gsr_egl_update(gsr_egl *self) {
// TODO: pselect on wl_display_get_fd before doing dispatch
wl_display_dispatch(self->wayland.dpy);
}
+
+void gsr_egl_swap_buffers(gsr_egl *self) {
+ if(self->egl_display) {
+ self->eglSwapBuffers(self->egl_display, self->egl_surface);
+ } else if(self->x11.window) {
+ self->glXSwapBuffers(self->x11.dpy, self->x11.window);
+ }
+}
diff --git a/src/main.cpp b/src/main.cpp
index 2c6bced..48d94f2 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1731,7 +1731,7 @@ static void list_supported_capture_options(gsr_egl *egl, bool wayland) {
#endif
}
-static void list_command() {
+static void info_command() {
bool wayland = false;
Display *dpy = XOpenDisplay(nullptr);
if (!dpy) {
@@ -2022,7 +2022,7 @@ int main(int argc, char **argv) {
usage_full();
if(argc == 2 && strcmp(argv[1], "--info") == 0) {
- list_command();
+ info_command();
_exit(0);
}
@@ -3154,7 +3154,10 @@ int main(int argc, char **argv) {
const int num_frames = framerate_mode == FramerateMode::CONSTANT ? std::max((int64_t)0LL, expected_frames - video_pts_counter) : 1;
if(num_frames > 0 && !paused) {
+ egl.glClear(0);
gsr_capture_capture(capture, video_frame, &color_conversion);
+ gsr_egl_swap_buffers(&egl);
+
gsr_video_encoder_copy_textures_to_frame(video_encoder, video_frame);
if(hdr && !hdr_metadata_set && replay_buffer_size_secs == -1 && add_hdr_metadata_to_video_stream(capture, video_stream))