From 8cd0ae0162221bf39729734070918dec97cfc824 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 21 Jul 2023 15:11:13 +0200 Subject: [PATCH] vfr on wayland (even on nvidia), add uninstall script --- README.md | 6 +++--- TODO | 4 +++- include/egl.h | 1 - install.sh | 2 +- src/egl.c | 2 +- src/main.cpp | 3 ++- uninstall.sh | 9 +++++++++ 7 files changed, 19 insertions(+), 8 deletions(-) create mode 100755 uninstall.sh diff --git a/README.md b/README.md index 4f62515..d2a7666 100644 --- a/README.md +++ b/README.md @@ -41,11 +41,11 @@ If you install GPU Screen Recorder flatpak, which is the gtk gui version then yo # Dependencies ## AMD -`libglvnd (which provides libgl and libegl), mesa, ffmpeg (libavcodec, libavformat, libavutil, libswresample, libavfilter), libx11, libxcomposite, libxrandr, libxfixes, libpulse, libva, libva-mesa-driver, libdrm, libcap, polkit (for pkexec), wayland-client, wayland-egl`. +`libglvnd (which provides libgl and libegl), mesa, ffmpeg (libavcodec, libavformat, libavutil, libswresample, libavfilter), libx11, libxcomposite, libxrandr, libxfixes, libpulse, libva, libva-mesa-driver, libdrm, libcap, polkit (for pkexec), wayland-client`. ## Intel -`libglvnd (which provides libgl and libegl), mesa, ffmpeg (libavcodec, libavformat, libavutil, libswresample, libavfilter), libx11, libxcomposite, libxrandr, libxfixes, libpulse, libva, libva-intel-driver, libdrm, libcap, polkit (for pkexec), wayland-client, wayland-egl`. +`libglvnd (which provides libgl and libegl), mesa, ffmpeg (libavcodec, libavformat, libavutil, libswresample, libavfilter), libx11, libxcomposite, libxrandr, libxfixes, libpulse, libva, libva-intel-driver, libdrm, libcap, polkit (for pkexec), wayland-client`. ## NVIDIA -`libglvnd (which provides libgl and libegl), ffmpeg (libavcodec, libavformat, libavutil, libswresample, libavfilter), libx11, libxcomposite, libxrandr, libxfixes, libpulse, cuda (libnvidia-compute), nvenc (libnvidia-encode), libva, libdrm, libcap, polkit (for pkexec, only on wayland), wayland-client, wayland-egl`. Additionally, you need to have `nvfbc (libnvidia-fbc1)` installed when using nvfbc and `xnvctrl (libxnvctrl0)` when using the `-oc` option. +`libglvnd (which provides libgl and libegl), ffmpeg (libavcodec, libavformat, libavutil, libswresample, libavfilter), libx11, libxcomposite, libxrandr, libxfixes, libpulse, cuda runtime (libcuda.so.1) (libnvidia-compute), nvenc (libnvidia-encode), libva, libdrm, libcap, polkit (for pkexec, only on wayland), wayland-client`. Additionally, you need to have `nvfbc (libnvidia-fbc1)` installed when using nvfbc and `xnvctrl (libxnvctrl0)` when using the `-oc` option. # How to use Run `gpu-screen-recorder --help` to see all options. diff --git a/TODO b/TODO index 73af124..aaf9e36 100644 --- a/TODO +++ b/TODO @@ -83,4 +83,6 @@ Support screen rotation in amd/intel/nvidia wayland. Capture cursor on amd/intel wayland without xwayland. When nvidia supports hardware cursor then capture the cursor. Right now the cursor is captured because it's a software cursor so it's composed on the dma buf. CPU usage is pretty high on AMD/Intel/(Nvidia(wayland)), why? opening and closing fds, creating egl, cuda association, is slow when done every frame. Test if desktop portal screencast has better performance. -Cursor on amd/intel wayland only shows up when the cursor is above xwayland applications. \ No newline at end of file +Cursor on amd/intel wayland only shows up when the cursor is above xwayland applications. + +Test if everything works fine on amd/intel, if it works fine with kms/wlroots, if it works fine with scaling and finally modify gtk gui to list monitors from wlroots/etc. \ No newline at end of file diff --git a/include/egl.h b/include/egl.h index 58c1861..14e4497 100644 --- a/include/egl.h +++ b/include/egl.h @@ -55,7 +55,6 @@ typedef void (*__eglMustCastToProperFunctionPointerType)(void); #define EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT 0x3444 #define EGL_LINUX_DMA_BUF_EXT 0x3270 #define EGL_OPENGL_API 0x30A2 -#define EGL_OPENGL_ES_API 0x30A0 #define EGL_RED_SIZE 0x3024 #define EGL_ALPHA_SIZE 0x3021 #define EGL_BLUE_SIZE 0x3022 diff --git a/install.sh b/install.sh index c10392c..fe0ab2c 100755 --- a/install.sh +++ b/install.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh -e script_dir=$(dirname "$0") cd "$script_dir" diff --git a/src/egl.c b/src/egl.c index 482b3df..ad51c4c 100644 --- a/src/egl.c +++ b/src/egl.c @@ -249,7 +249,7 @@ static bool gsr_egl_create_window(gsr_egl *self, bool wayland) { } } - self->eglBindAPI(EGL_OPENGL_ES_API); + self->eglBindAPI(EGL_OPENGL_ES2_BIT); self->egl_display = self->eglGetDisplay(self->wayland.dpy ? (EGLNativeDisplayType)self->wayland.dpy : (EGLNativeDisplayType)self->x11.dpy); if(!self->egl_display) { diff --git a/src/main.cpp b/src/main.cpp index af7b224..cbbc594 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1326,10 +1326,11 @@ int main(int argc, char **argv) { // TODO: Fix constant framerate not working properly on amd/intel because capture framerate gets locked to the same framerate as // game framerate, which doesn't work well when you need to encode multiple duplicate frames (AMD/Intel is slow at encoding!). + // It also appears to skip audio frames on nvidia wayland? why? that should be fine, but it causes video stuttering because of audio/video sync. FramerateMode framerate_mode; const char *framerate_mode_str = args["-fm"].value(); if(!framerate_mode_str) - framerate_mode_str = gpu_inf.vendor == GSR_GPU_VENDOR_NVIDIA ? "cfr" : "vfr"; + framerate_mode_str = (gpu_inf.vendor == GSR_GPU_VENDOR_NVIDIA && !wayland) ? "cfr" : "vfr"; if(strcmp(framerate_mode_str, "cfr") == 0) { framerate_mode = FramerateMode::CONSTANT; diff --git a/uninstall.sh b/uninstall.sh new file mode 100755 index 0000000..95e26ac --- /dev/null +++ b/uninstall.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +[ $(id -u) -ne 0 ] && echo "You need root privileges to run the uninstall script" && exit 1 + +rm -f "/usr/local/bin/gpu-screen-recorder" +rm -f "/usr/bin/gsr-kms-server" +rm -f "/usr/bin/gpu-screen-recorder" + +echo "Successfully uninstalled gpu-screen-recorder" \ No newline at end of file