From ef490965a23e043692584ae26dec4f863c88f2f6 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Thu, 15 Feb 2024 00:58:58 +0000 Subject: [PATCH] screencopy: attempt binding framebuffer before gathering format --- src/protocols/Screencopy.cpp | 12 ++++++++++++ src/protocols/ToplevelExport.cpp | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/protocols/Screencopy.cpp b/src/protocols/Screencopy.cpp index e9ba45dd..b431bd3b 100644 --- a/src/protocols/Screencopy.cpp +++ b/src/protocols/Screencopy.cpp @@ -211,6 +211,18 @@ void CScreencopyProtocolManager::captureOutput(wl_client* client, wl_resource* r PCLIENT->ref++; g_pHyprRenderer->makeEGLCurrent(); + + if (g_pHyprOpenGL->m_mMonitorRenderResources.contains(PFRAME->pMonitor)) { + const auto RDATA = g_pHyprOpenGL->m_mMonitorRenderResources.at(PFRAME->pMonitor); + // bind the fb for its format. Suppress gl errors. +#ifndef GLES2 + glBindFramebuffer(GL_READ_FRAMEBUFFER, RDATA.offloadFB.m_iFb); +#else + glBindFramebuffer(GL_FRAMEBUFFER, RDATA.offloadFB.m_iFb); +#endif + } else + Debug::log(ERR, "No RDATA in screencopy???"); + PFRAME->shmFormat = g_pHyprOpenGL->getPreferredReadFormat(PFRAME->pMonitor); if (PFRAME->shmFormat == DRM_FORMAT_INVALID) { Debug::log(ERR, "No format supported by renderer in capture output"); diff --git a/src/protocols/ToplevelExport.cpp b/src/protocols/ToplevelExport.cpp index 25bab2ef..40265b26 100644 --- a/src/protocols/ToplevelExport.cpp +++ b/src/protocols/ToplevelExport.cpp @@ -178,6 +178,18 @@ void CToplevelExportProtocolManager::captureToplevel(wl_client* client, wl_resou const auto PMONITOR = g_pCompositor->getMonitorFromID(PFRAME->pWindow->m_iMonitorID); g_pHyprRenderer->makeEGLCurrent(); + + if (g_pHyprOpenGL->m_mMonitorRenderResources.contains(PMONITOR)) { + const auto RDATA = g_pHyprOpenGL->m_mMonitorRenderResources.at(PMONITOR); + // bind the fb for its format. Suppress gl errors. +#ifndef GLES2 + glBindFramebuffer(GL_READ_FRAMEBUFFER, RDATA.offloadFB.m_iFb); +#else + glBindFramebuffer(GL_FRAMEBUFFER, RDATA.offloadFB.m_iFb); +#endif + } else + Debug::log(ERR, "No RDATA in toplevelexport???"); + PFRAME->shmFormat = g_pHyprOpenGL->getPreferredReadFormat(PMONITOR); if (PFRAME->shmFormat == DRM_FORMAT_INVALID) { Debug::log(ERR, "No format supported by renderer in capture toplevel");