aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-02-26 19:46:38 +0100
committerdec05eba <dec05eba@protonmail.com>2024-02-26 19:46:38 +0100
commit8043453bd85eca50d4fcc3a653603535597e68bd (patch)
tree42345850bb8d860e267916a13ba65b9c8639e710
parent6f498dd0200cab6dff2613518d5a6a8df96276c7 (diff)
Set cap sys nice again, to prevent gsr from being limited to game fps
-rw-r--r--README.md3
-rwxr-xr-xdebug-install.sh2
-rwxr-xr-xinstall.sh2
-rw-r--r--src/egl.c16
4 files changed, 21 insertions, 2 deletions
diff --git a/README.md b/README.md
index f6211c8..fedb754 100644
--- a/README.md
+++ b/README.md
@@ -30,8 +30,7 @@ For you as a user this only means that if you installed GPU Screen Recorder as a
On a system with a i5 4690k CPU and a GTX 1080 GPU:\
When recording Legend of Zelda Breath of the Wild at 4k, fps drops from 30 to 7 when using OBS Studio + nvenc, however when using this screen recorder the fps remains at 30.\
When recording GTA V at 4k on highest settings, fps drops from 60 to 23 when using obs-nvfbc + nvenc, however when using this screen recorder the fps only drops to 58. The quality is also much better when using gpu screen recorder.\
-It is recommended to save the video to a SSD because of the large file size, which a slow HDD might not be fast enough to handle. This might also be an issue if the drive is partitioned with NTFS.
-If you notice jitter in the video output then you could also switch to a lower quality setting. Ultra quality is usually overkill, very high (the default) is good enough most of the time.
+It is recommended to save the video to a SSD because of the large file size, which a slow HDD might not be fast enough to handle. Using variable framerate mode (-fm vfr) which is the default is also recommended as this reduces encoding load.
## Note about optimal performance on NVIDIA
NVIDIA driver has a "feature" (read: bug) where it will downclock memory transfer rate when a program uses cuda (or nvenc, which uses cuda), such as GPU Screen Recorder. To work around this bug, GPU Screen Recorder can overclock your GPU memory transfer rate to it's normal optimal level.\
To enable overclocking for optimal performance use the `-oc` option when running GPU Screen Recorder. You also need to have "Coolbits" NVIDIA X setting set to "12" to enable overclocking. You can automatically add this option if you run `sudo nvidia-xconfig --cool-bits=12` and then reboot your computer.\
diff --git a/debug-install.sh b/debug-install.sh
index 3177ace..d17575c 100755
--- a/debug-install.sh
+++ b/debug-install.sh
@@ -14,5 +14,7 @@ if [ -d "/usr/lib/systemd/user" ]; then
fi
# Not necessary, but removes the password prompt when trying to record a monitor on amd/intel or nvidia wayland
setcap cap_sys_admin+ep /usr/bin/gsr-kms-server
+# Not necessary, but allows use of EGL_CONTEXT_PRIORITY_LEVEL_IMG which allows gpu screen recorder to run without being limited to game fps under heavy load
+setcap cap_sys_nice+ep /usr/bin/gpu-screen-recorder
echo "Successfully installed gpu-screen-recorder (debug)"
diff --git a/install.sh b/install.sh
index adc9230..6c49e16 100755
--- a/install.sh
+++ b/install.sh
@@ -16,5 +16,7 @@ if [ -d "/usr/lib/systemd/user" ]; then
fi
# Not necessary, but removes the password prompt when trying to record a monitor on amd/intel or nvidia wayland
setcap cap_sys_admin+ep /usr/bin/gsr-kms-server
+# Not necessary, but allows use of EGL_CONTEXT_PRIORITY_LEVEL_IMG which allows gpu screen recorder to run without being limited to game fps under heavy load
+setcap cap_sys_nice+ep /usr/bin/gpu-screen-recorder
echo "Successfully installed gpu-screen-recorder"
diff --git a/src/egl.c b/src/egl.c
index ec6f91c..7971dbd 100644
--- a/src/egl.c
+++ b/src/egl.c
@@ -9,6 +9,7 @@
#include <wayland-client.h>
#include <wayland-egl.h>
#include <unistd.h>
+#include <sys/capability.h>
// Move this shit to a separate wayland file, and have a separate file for x11.
@@ -118,6 +119,18 @@ static struct wl_registry_listener registry_listener = {
.global_remove = registry_remove_object,
};
+static void reset_cap_nice(void) {
+ cap_t caps = cap_get_proc();
+ if(!caps)
+ return;
+
+ const cap_value_t cap_to_remove = CAP_SYS_NICE;
+ cap_set_flag(caps, CAP_EFFECTIVE, 1, &cap_to_remove, CAP_CLEAR);
+ cap_set_flag(caps, CAP_PERMITTED, 1, &cap_to_remove, CAP_CLEAR);
+ cap_set_proc(caps);
+ cap_free(caps);
+}
+
// TODO: Create egl context without surface (in other words, x11/wayland agnostic, doesn't require x11/wayland dependency)
static bool gsr_egl_create_window(gsr_egl *self, bool wayland) {
EGLConfig ecfg;
@@ -131,6 +144,7 @@ static bool gsr_egl_create_window(gsr_egl *self, bool wayland) {
const int32_t ctxattr[] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
+ EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG, /* requires cap_sys_nice, ignored otherwise */
EGL_NONE
};
@@ -205,9 +219,11 @@ static bool gsr_egl_create_window(gsr_egl *self, bool wayland) {
goto fail;
}
+ reset_cap_nice();
return true;
fail:
+ reset_cap_nice();
gsr_egl_unload(self);
return false;
}