From 32f323332414e5633a3412270c35018a53219946 Mon Sep 17 00:00:00 2001 From: Tom Englund Date: Fri, 10 Oct 2025 14:13:14 +0200 Subject: [PATCH] dmabuffer: ensure we only create one texture per buffer (#11990) buffer can be recomitted, when moving texture creation from constructor to committime it means same buffer recommit can cause a new texture unless we store it per buffer and return the pointer for it. --- src/protocols/types/DMABuffer.cpp | 9 ++++++--- src/protocols/types/DMABuffer.hpp | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/protocols/types/DMABuffer.cpp b/src/protocols/types/DMABuffer.cpp index b361c6c8..ed24baae 100644 --- a/src/protocols/types/DMABuffer.cpp +++ b/src/protocols/types/DMABuffer.cpp @@ -60,6 +60,9 @@ void CDMABuffer::endDataPtr() { } SP CDMABuffer::createTexture() { + if (m_texture) // dmabuffers only get one texture per buffer. + return m_texture; + g_pHyprRenderer->makeEGLCurrent(); auto eglImage = g_pHyprOpenGL->createEGLImage(m_attrs); @@ -73,14 +76,14 @@ SP CDMABuffer::createTexture() { } } - auto tex = makeShared(m_attrs, eglImage); // texture takes ownership of the eglImage + m_texture = makeShared(m_attrs, eglImage); // texture takes ownership of the eglImage - if UNLIKELY (!tex->m_texID) { + if UNLIKELY (!m_texture->m_texID) { Debug::log(ERR, "Failed to create a dmabuf: texture is null"); return nullptr; } - return tex; + return m_texture; } bool CDMABuffer::good() { diff --git a/src/protocols/types/DMABuffer.hpp b/src/protocols/types/DMABuffer.hpp index 14c1eb75..8b838252 100644 --- a/src/protocols/types/DMABuffer.hpp +++ b/src/protocols/types/DMABuffer.hpp @@ -22,6 +22,7 @@ class CDMABuffer : public IHLBuffer { private: Aquamarine::SDMABUFAttrs m_attrs; + SP m_texture; struct { CHyprSignalListener resourceDestroy;