From 3f31400e7fe6e5fcbda4d271312582048fab8cbf Mon Sep 17 00:00:00 2001 From: Kelvie Wong Date: Wed, 24 Jan 2024 15:13:49 -0800 Subject: [PATCH] Revert "Remove useless texture size queries for every frame in display_ram_t" This reverts commit ebe01ce20b06c6f10392f945c1c7083ed3aa733f. Looks like this commit undos the fix for #453, see also PRs #649 and #884. This also adds a comment so hopefully it doesn't get removed again in the future (or a proper fix is found). --- src/platform/linux/kmsgrab.cpp | 9 ++++++++- src/platform/linux/wlgrab.cpp | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/platform/linux/kmsgrab.cpp b/src/platform/linux/kmsgrab.cpp index faa6dfb4ed9..eb85a257ec4 100644 --- a/src/platform/linux/kmsgrab.cpp +++ b/src/platform/linux/kmsgrab.cpp @@ -1259,11 +1259,18 @@ namespace platf { auto &rgb = *rgb_opt; + gl::ctx.BindTexture(GL_TEXTURE_2D, rgb->tex[0]); + + // Don't remove these lines, see https://github.com/LizardByte/Sunshine/issues/453 + int w, h; + gl::ctx.GetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w); + gl::ctx.GetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h); + BOOST_LOG(debug) << "width and height: w "sv << w << " h "sv << h; + if (!pull_free_image_cb(img_out)) { return platf::capture_e::interrupted; } - gl::ctx.BindTexture(GL_TEXTURE_2D, rgb->tex[0]); gl::ctx.GetTextureSubImage(rgb->tex[0], 0, img_offset_x, img_offset_y, 0, width, height, 1, GL_BGRA, GL_UNSIGNED_BYTE, img_out->height * img_out->row_pitch, img_out->data); if (cursor && captured_cursor.visible) { diff --git a/src/platform/linux/wlgrab.cpp b/src/platform/linux/wlgrab.cpp index 0e22cbe2248..24791d0d6b2 100644 --- a/src/platform/linux/wlgrab.cpp +++ b/src/platform/linux/wlgrab.cpp @@ -182,6 +182,13 @@ namespace wl { } gl::ctx.BindTexture(GL_TEXTURE_2D, (*rgb_opt)->tex[0]); + + // Don't remove these lines, see https://github.com/LizardByte/Sunshine/issues/453 + int w, h; + gl::ctx.GetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w); + gl::ctx.GetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h); + BOOST_LOG(debug) << "width and height: w "sv << w << " h "sv << h; + gl::ctx.GetTextureSubImage((*rgb_opt)->tex[0], 0, 0, 0, 0, width, height, 1, GL_BGRA, GL_UNSIGNED_BYTE, img_out->height * img_out->row_pitch, img_out->data); gl::ctx.BindTexture(GL_TEXTURE_2D, 0);