mirror of
https://github.com/hyprwm/Hyprland
synced 2025-12-20 09:10:08 +01:00
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:
parent
2b0926dcd4
commit
32f3233324
2 changed files with 7 additions and 3 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ class CDMABuffer : public IHLBuffer {
|
|||
|
||||
private:
|
||||
Aquamarine::SDMABUFAttrs m_attrs;
|
||||
SP<CTexture> m_texture;
|
||||
|
||||
struct {
|
||||
CHyprSignalListener resourceDestroy;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue