From 3f0a58a1e61de8094d9ebf9db320c01b59ab441f Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 10 Jun 2024 12:28:53 +0200 Subject: Do not require a valid drm plane to capture a window on amd/intel x11 --- include/utils.h | 2 +- src/egl.c | 1 - src/main.cpp | 8 ++++---- src/utils.c | 4 ++-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/include/utils.h b/include/utils.h index 74fdd59..58ef099 100644 --- a/include/utils.h +++ b/include/utils.h @@ -37,7 +37,7 @@ gsr_monitor_rotation drm_monitor_get_display_server_rotation(const gsr_egl *egl, bool gl_get_gpu_info(gsr_egl *egl, gsr_gpu_info *info); /* |output| should be at least 128 bytes in size */ -bool gsr_get_valid_card_path(gsr_egl *egl, char *output); +bool gsr_get_valid_card_path(gsr_egl *egl, char *output, bool is_monitor_capture); /* |render_path| should be at least 128 bytes in size */ bool gsr_card_path_get_render_path(const char *card_path, char *render_path); diff --git a/src/egl.c b/src/egl.c index 2ad4f85..2c139e6 100644 --- a/src/egl.c +++ b/src/egl.c @@ -488,7 +488,6 @@ static bool gsr_egl_load_gl(gsr_egl *self, void *library) { // } bool gsr_egl_load(gsr_egl *self, Display *dpy, bool wayland, bool is_monitor_capture) { - (void)is_monitor_capture; memset(self, 0, sizeof(gsr_egl)); self->x11.dpy = dpy; self->context_type = GSR_GL_CONTEXT_TYPE_EGL; diff --git a/src/main.cpp b/src/main.cpp index 367a81b..3674e94 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1442,8 +1442,8 @@ static void list_supported_video_codecs() { card_path[0] = '\0'; if(wayland || egl.gpu_info.vendor != GSR_GPU_VENDOR_NVIDIA) { // TODO: Allow specifying another card, and in other places - if(!gsr_get_valid_card_path(&egl, card_path)) { - fprintf(stderr, "Error: no /dev/dri/cardX device found. If you are running GPU Screen Recorder with prime-run then try running without it\n"); + if(!gsr_get_valid_card_path(&egl, card_path, false)) { + fprintf(stderr, "Error: no /dev/dri/cardX device found. If you are running GPU Screen Recorder with prime-run then try running without it. Also make sure that you have at least one connected monitor or record a single window instead on X11\n"); _exit(2); } } @@ -2017,8 +2017,8 @@ int main(int argc, char **argv) { egl.card_path[0] = '\0'; if(wayland || egl.gpu_info.vendor != GSR_GPU_VENDOR_NVIDIA) { // TODO: Allow specifying another card, and in other places - if(!gsr_get_valid_card_path(&egl, egl.card_path)) { - fprintf(stderr, "Error: no /dev/dri/cardX device found. If you are running GPU Screen Recorder with prime-run then try running without it\n"); + if(!gsr_get_valid_card_path(&egl, egl.card_path, is_monitor_capture)) { + fprintf(stderr, "Error: no /dev/dri/cardX device found. If you are running GPU Screen Recorder with prime-run then try running without it. Also make sure that you have at least one connected monitor or record a single window instead on X11\n"); _exit(2); } } diff --git a/src/utils.c b/src/utils.c index 40d652e..b9995e8 100644 --- a/src/utils.c +++ b/src/utils.c @@ -423,10 +423,10 @@ static void string_copy(char *dst, const char *src, int len) { dst[min_len] = '\0'; } -bool gsr_get_valid_card_path(gsr_egl *egl, char *output) { +bool gsr_get_valid_card_path(gsr_egl *egl, char *output, bool is_monitor_capture) { if(egl->dri_card_path) { string_copy(output, egl->dri_card_path, 127); - return try_card_has_valid_plane(output); + return is_monitor_capture ? try_card_has_valid_plane(output) : true; } for(int i = 0; i < 10; ++i) { -- cgit v1.2.3