Set cap sys nice again, to prevent gsr from being limited to game fps

This commit is contained in:
dec05eba
2024-02-26 19:46:38 +01:00
parent 6f498dd020
commit 8043453bd8
4 changed files with 21 additions and 2 deletions

View File

@@ -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:\ 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 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.\ 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. 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.
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.
## Note about optimal performance on NVIDIA ## 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.\ 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.\ 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.\

View File

@@ -14,5 +14,7 @@ if [ -d "/usr/lib/systemd/user" ]; then
fi fi
# Not necessary, but removes the password prompt when trying to record a monitor on amd/intel or nvidia wayland # 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 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)" echo "Successfully installed gpu-screen-recorder (debug)"

View File

@@ -16,5 +16,7 @@ if [ -d "/usr/lib/systemd/user" ]; then
fi fi
# Not necessary, but removes the password prompt when trying to record a monitor on amd/intel or nvidia wayland # 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 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" echo "Successfully installed gpu-screen-recorder"

View File

@@ -9,6 +9,7 @@
#include <wayland-client.h> #include <wayland-client.h>
#include <wayland-egl.h> #include <wayland-egl.h>
#include <unistd.h> #include <unistd.h>
#include <sys/capability.h>
// Move this shit to a separate wayland file, and have a separate file for x11. // 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, .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) // 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) { static bool gsr_egl_create_window(gsr_egl *self, bool wayland) {
EGLConfig ecfg; EGLConfig ecfg;
@@ -131,6 +144,7 @@ static bool gsr_egl_create_window(gsr_egl *self, bool wayland) {
const int32_t ctxattr[] = { const int32_t ctxattr[] = {
EGL_CONTEXT_CLIENT_VERSION, 2, EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG, /* requires cap_sys_nice, ignored otherwise */
EGL_NONE EGL_NONE
}; };
@@ -205,9 +219,11 @@ static bool gsr_egl_create_window(gsr_egl *self, bool wayland) {
goto fail; goto fail;
} }
reset_cap_nice();
return true; return true;
fail: fail:
reset_cap_nice();
gsr_egl_unload(self); gsr_egl_unload(self);
return false; return false;
} }