From a775cc3814431fc2513f0a11599a265c1ad1bae3 Mon Sep 17 00:00:00 2001 From: Alessandro Astone Date: Fri, 17 Nov 2023 00:23:31 +0100 Subject: [PATCH] Backport proposed patch to fix nvidia screencasting --- fix-nvidia-screencast.patch | 68 +++++++++++++++++++++++++++++++++++++ kwin.spec | 7 +++- 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 fix-nvidia-screencast.patch diff --git a/fix-nvidia-screencast.patch b/fix-nvidia-screencast.patch new file mode 100644 index 0000000..a3cb634 --- /dev/null +++ b/fix-nvidia-screencast.patch @@ -0,0 +1,68 @@ +From 17f81c4faa4c93dc9ac2d9abf1b759b38df2ed9d Mon Sep 17 00:00:00 2001 +From: Alessandro Astone +Date: Wed, 15 Nov 2023 23:22:56 +0100 +Subject: [PATCH 1/2] screencast: Fix GLES path + +glReadPixels reads from the bound framebuffer, so create an offscreen +framebuffer and attach the texture to it + +Co-authored-by: Jan Grulich +--- + src/plugins/screencast/screencastutils.h | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/plugins/screencast/screencastutils.h b/src/plugins/screencast/screencastutils.h +index f402c21fdf..1a57362dea 100644 +--- a/src/plugins/screencast/screencastutils.h ++++ b/src/plugins/screencast/screencastutils.h +@@ -8,6 +8,7 @@ + + #include "kwinglplatform.h" + #include "kwingltexture.h" ++#include "kwinglutils.h" + #include + #include + +@@ -60,7 +61,10 @@ static void grabTexture(GLTexture *texture, spa_data *spa, spa_video_format form + + texture->bind(); + if (GLPlatform::instance()->isGLES()) { ++ GLFramebuffer fbo(texture); ++ GLFramebuffer::pushFramebuffer(&fbo); + glReadPixels(0, 0, size.width(), size.height(), closestGLType(format), GL_UNSIGNED_BYTE, spa->data); ++ GLFramebuffer::popFramebuffer(); + } else if (GLPlatform::instance()->glVersion() >= kVersionNumber(4, 5)) { + glGetTextureImage(texture->texture(), 0, closestGLType(format), GL_UNSIGNED_BYTE, spa->chunk->size, spa->data); + } else { +-- +2.41.0 + + +From 79083bdf721dd56ace7412f89d7b80e7b9a2ba52 Mon Sep 17 00:00:00 2001 +From: Alessandro Astone +Date: Wed, 15 Nov 2023 23:23:14 +0100 +Subject: [PATCH 2/2] screencast: Make nvidia use the GLES path + +glGetTexImage returns a black image + +Fixes: BUG:476602 +--- + src/plugins/screencast/screencastutils.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/plugins/screencast/screencastutils.h b/src/plugins/screencast/screencastutils.h +index 1a57362dea..31b8a1c95c 100644 +--- a/src/plugins/screencast/screencastutils.h ++++ b/src/plugins/screencast/screencastutils.h +@@ -60,7 +60,7 @@ static void grabTexture(GLTexture *texture, spa_data *spa, spa_video_format form + } + + texture->bind(); +- if (GLPlatform::instance()->isGLES()) { ++ if (GLPlatform::instance()->isGLES() || GLPlatform::instance()->driver() == Driver_NVidia) { + GLFramebuffer fbo(texture); + GLFramebuffer::pushFramebuffer(&fbo); + glReadPixels(0, 0, size.width(), size.height(), closestGLType(format), GL_UNSIGNED_BYTE, spa->data); +-- +2.41.0 + diff --git a/kwin.spec b/kwin.spec index 4592ba8..5aa171b 100644 --- a/kwin.spec +++ b/kwin.spec @@ -17,7 +17,7 @@ Name: kwin Version: 5.27.9 -Release: 2%{?dist} +Release: 3%{?dist} Summary: KDE Window manager # all sources are effectively GPLv2+, except for: @@ -39,6 +39,8 @@ Source0: http://download.kde.org/%{stable}/plasma/%{version}/%{name}-%{version}. ## upstream patches ## proposed patches +# https://invent.kde.org/plasma/kwin/-/merge_requests/4651 +Patch0: fix-nvidia-screencast.patch # Base BuildRequires: extra-cmake-modules @@ -363,6 +365,9 @@ make test ARGS="--output-on-failure --timeout 10" -C %{_target_platform} ||: %changelog +* Thu Nov 16 2023 Alessandro Astone - 5.27.9-3 +- Backport proposed patch to fix nvidia screencasting + * Fri Nov 03 2023 Neal Gompa - 5.27.9-2 - Mark kwin-x11 as deprecated