mirror of
https://github.com/hyprwm/Hyprland
synced 2025-12-20 07:10:02 +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() {
|
SP<CTexture> CDMABuffer::createTexture() {
|
||||||
|
if (m_texture) // dmabuffers only get one texture per buffer.
|
||||||
|
return m_texture;
|
||||||
|
|
||||||
g_pHyprRenderer->makeEGLCurrent();
|
g_pHyprRenderer->makeEGLCurrent();
|
||||||
auto eglImage = g_pHyprOpenGL->createEGLImage(m_attrs);
|
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");
|
Debug::log(ERR, "Failed to create a dmabuf: texture is null");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tex;
|
return m_texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CDMABuffer::good() {
|
bool CDMABuffer::good() {
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ class CDMABuffer : public IHLBuffer {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Aquamarine::SDMABUFAttrs m_attrs;
|
Aquamarine::SDMABUFAttrs m_attrs;
|
||||||
|
SP<CTexture> m_texture;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
CHyprSignalListener resourceDestroy;
|
CHyprSignalListener resourceDestroy;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue