aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2023-03-21 22:37:30 +0100
committerdec05eba <dec05eba@protonmail.com>2023-03-21 22:37:30 +0100
commite745e9ae0bd422c9a4249884d37e26612e03762e (patch)
tree57bc5de67bb77ec14fc7b6787355b236797b29ee
parent9afaf6e037d13e5375aae774e6666ceb7d75a8f1 (diff)
Show error if cuda/nvenc is not installed
-rw-r--r--README.md2
-rw-r--r--TODO3
-rw-r--r--src/main.cpp53
3 files changed, 50 insertions, 8 deletions
diff --git a/README.md b/README.md
index 26d050b..fc5b4cd 100644
--- a/README.md
+++ b/README.md
@@ -25,7 +25,7 @@ NVIDIA driver has a "feature" (read: bug) where it will downclock memory transfe
## Installation
This program depends on [gpu-screen-recorder](https://git.dec05eba.com/gpu-screen-recorder/) which needs to be installed first.\
Run `./install.sh` as root or if you are running Arch Linux, then you can find gpu screen recorder gtk on aur under the name gpu-screen-recorder-gtk-git (`yay -S gpu-screen-recorder-gtk-git`).\
-Dependencies needed when building using `build.sh` or `install.sh`: `gtk3 libx11 libxrandr libpulse libglvnd (which provides libgl and libegl)`.\
+Dependencies needed when building using `build.sh` or `install.sh`: `gtk3 libx11 libxrandr libpulse`.\
You can also install gpu screen recorder (the gtk gui version) from [flathub](https://flathub.org/apps/details/com.dec05eba.gpu_screen_recorder). This flatpak includes gpu-screen-recorder so no need to install that first.\
Note that if you use the flatpak version then you wont be able to use overclocking unless you set "Coolbits" NVIDIA X setting. See https://git.dec05eba.com/gpu-screen-recorder/about/ for more information and how to overcome this.
diff --git a/TODO b/TODO
index 0456172..7c7c218 100644
--- a/TODO
+++ b/TODO
@@ -1,3 +1,4 @@
Capture stderr (ignore fps: 250) and show that in notification on error.
Make sure the resolution is allowed for streaming.
-Add list of windows to select from. This makes it easier to select another window that is not in the view to be clickable. \ No newline at end of file
+Add list of windows to select from. This makes it easier to select another window that is not in the view to be clickable.
+Detect switchable graphics, to give proper error if cuda is not installed. \ No newline at end of file
diff --git a/src/main.cpp b/src/main.cpp
index b673040..4ce1f8f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -868,7 +868,7 @@ static gboolean on_start_streaming_click(GtkButton *button, gpointer userdata) {
if(num_audio_tracks > 1 && !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(merge_audio_tracks_button))) {
GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
- "Streaming doesn't work with more than 1 audio track. Please remove all audio tracks or only use 1 audio track or select to merge audio tracks");
+ "Streaming doesn't work with more than 1 audio track. Please remove all audio tracks or only use 1 audio track or select to merge audio tracks.");
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
return true;
@@ -1473,12 +1473,33 @@ static void stream_service_item_change_callback(GtkComboBox *widget, gpointer us
}
static bool is_nv_fbc_installed() {
- void *lib = dlopen("libnvidia-fbc.so.1", RTLD_NOW);
+ void *lib = dlopen("libnvidia-fbc.so.1", RTLD_LAZY);
if(lib)
dlclose(lib);
return lib != nullptr;
}
+static bool is_nvenc_installed() {
+ void *lib = dlopen("libnvidia-encode.so.1", RTLD_LAZY);
+ if(lib)
+ dlclose(lib);
+ return lib != nullptr;
+}
+
+static bool is_cuda_installed() {
+ void *lib = dlopen("libcuda.so.1", RTLD_LAZY);
+ if(lib) {
+ dlclose(lib);
+ return true;
+ }
+
+ lib = dlopen("libcuda.so", RTLD_LAZY);
+ if(lib)
+ dlclose(lib);
+
+ return lib != nullptr;
+}
+
typedef gboolean (*KeyPressHandler)(GtkButton *button, gpointer userdata);
static void keypress_toggle_recording(bool recording_state, GtkButton *record_button, KeyPressHandler keypress_handler, GtkApplication *app) {
if(!gtk_widget_get_sensitive(GTK_WIDGET(record_button)))
@@ -1575,7 +1596,7 @@ static GdkFilterReturn hotkey_filter_callback(GdkXEvent *xevent, GdkEvent *event
if(hotkey_already_used_by_another_hotkey) {
std::string hotkey_text = gtk_entry_get_text(GTK_ENTRY(current_hotkey->hotkey_entry));
- std::string error_text = "Hotkey " + hotkey_text + " can't be used because it's used for something else. Please choose another hotkey";
+ std::string error_text = "Hotkey " + hotkey_text + " can't be used because it's used for something else. Please choose another hotkey.";
set_hotkey_text_from_hotkey_data(GTK_ENTRY(current_hotkey->hotkey_entry), *current_hotkey);
GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", error_text.c_str());
gtk_dialog_run(GTK_DIALOG(dialog));
@@ -1605,7 +1626,7 @@ static GdkFilterReturn hotkey_filter_callback(GdkXEvent *xevent, GdkEvent *event
} else {
*current_hotkey = prev_current_hotkey;
std::string hotkey_text = gtk_entry_get_text(GTK_ENTRY(current_hotkey->hotkey_entry));
- std::string error_text = "Hotkey " + hotkey_text + " can't be used because it's used by another program. Please choose another hotkey";
+ std::string error_text = "Hotkey " + hotkey_text + " can't be used because it's used by another program. Please choose another hotkey.";
set_hotkey_text_from_hotkey_data(GTK_ENTRY(current_hotkey->hotkey_entry), *current_hotkey);
GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", error_text.c_str());
gtk_dialog_run(GTK_DIALOG(dialog));
@@ -2400,7 +2421,7 @@ static void activate(GtkApplication *app, gpointer userdata) {
if(is_wayland() || is_xwayland()) {
GtkWidget *dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
- "GPU Screen Recorder only works in a pure X11 session. Xwayland is not supported");
+ "GPU Screen Recorder only works in a pure X11 session. Xwayland is not supported.");
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
g_application_quit(G_APPLICATION(app));
@@ -2410,7 +2431,7 @@ static void activate(GtkApplication *app, gpointer userdata) {
gpu_info gpu_inf;
if(!gl_get_gpu_info(gdk_x11_get_default_xdisplay(), &gpu_inf)) {
GtkWidget *dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
- "Failed to get OpenGL information. Make sure your are using a NVIDIA GPU and that you have NVIDIA proprietary drivers installed");
+ "Failed to get OpenGL information. Make sure your are using a NVIDIA GPU and that you have NVIDIA proprietary drivers installed.");
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
g_application_quit(G_APPLICATION(app));
@@ -2427,6 +2448,26 @@ static void activate(GtkApplication *app, gpointer userdata) {
return;
}
+ if(gpu_inf.vendor == GPU_VENDOR_NVIDIA) {
+ if(!is_cuda_installed()) {
+ GtkWidget *dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+ "CUDA is not installed on your system. GPU Screen Recorder requires CUDA to be installed to work with a NVIDIA GPU.");
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
+ g_application_quit(G_APPLICATION(app));
+ return;
+ }
+
+ if(!is_nvenc_installed()) {
+ GtkWidget *dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+ "NVENC is not installed on your system. GPU Screen Recorder requires NVENC to be installed to work with a NVIDIA GPU.");
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
+ g_application_quit(G_APPLICATION(app));
+ return;
+ }
+ }
+
window = gtk_application_window_new(app);
g_signal_connect(window, "destroy", G_CALLBACK(on_destroy_window), nullptr);
gtk_window_set_title(GTK_WINDOW(window), "GPU Screen Recorder");