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.
This commit is contained in:
Tom Englund 2025-10-10 14:13:14 +02:00 committed by GitHub
parent 2b0926dcd4
commit 32f3233324
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

View file

@ -60,6 +60,9 @@ void CDMABuffer::endDataPtr() {
}
SP<CTexture> 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<CTexture> CDMABuffer::createTexture() {
}
}
auto tex = makeShared<CTexture>(m_attrs, eglImage); // texture takes ownership of the eglImage
m_texture = makeShared<CTexture>(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() {

View file

@ -22,6 +22,7 @@ class CDMABuffer : public IHLBuffer {
private:
Aquamarine::SDMABUFAttrs m_attrs;
SP<CTexture> m_texture;
struct {
CHyprSignalListener resourceDestroy;