summaryrefslogtreecommitdiff
path: root/src/protocols/core
diff options
context:
space:
mode:
authorTom Englund <tomenglund26@gmail.com>2025-10-08 22:25:55 +0200
committerGitHub <noreply@github.com>2025-10-08 22:25:55 +0200
commit82759d4095dc95a0d10aefe87072385dce9a4bf1 (patch)
treec61cc4ab708a76d1850902186c0b50ff16e6a5c5 /src/protocols/core
parent0dc45b54f3df45483df1c44fdc188381ac8fddc4 (diff)
buffer: move texture creation to commit time (#11964)
* buffer: move texture creation to commit time move creating texture away from buffer attach into commitstate in an attempt to postpone gpu work until its really needed. best case scenario gpu clocks have ramped up before because we are actively doing things causing surface states and a commit to happend meaning less visible lag. * buffer: simplify texture creation make createTexture return a shared ptr directly, remove not needed member variables as m_success and m_texture.
Diffstat (limited to 'src/protocols/core')
-rw-r--r--src/protocols/core/Compositor.cpp8
-rw-r--r--src/protocols/core/Shm.cpp4
-rw-r--r--src/protocols/core/Shm.hpp1
3 files changed, 9 insertions, 4 deletions
diff --git a/src/protocols/core/Compositor.cpp b/src/protocols/core/Compositor.cpp
index 955ba5ca..8ad2a373 100644
--- a/src/protocols/core/Compositor.cpp
+++ b/src/protocols/core/Compositor.cpp
@@ -91,12 +91,10 @@ CWLSurfaceResource::CWLSurfaceResource(SP<CWlSurface> resource_) : m_resource(re
if (buf && buf->m_buffer) {
m_pending.buffer = CHLBufferReference(buf->m_buffer.lock());
- m_pending.texture = buf->m_buffer->m_texture;
m_pending.size = buf->m_buffer->size;
m_pending.bufferSize = buf->m_buffer->size;
} else {
- m_pending.buffer = {};
- m_pending.texture.reset();
+ m_pending.buffer = {};
m_pending.size = Vector2D{};
m_pending.bufferSize = Vector2D{};
}
@@ -132,7 +130,7 @@ CWLSurfaceResource::CWLSurfaceResource(SP<CWlSurface> resource_) : m_resource(re
}
// null buffer attached
- if (!m_pending.buffer && !m_pending.texture && m_pending.updated.bits.buffer) {
+ if (!m_pending.buffer && m_pending.updated.bits.buffer) {
commitState(m_pending);
// remove any pending states.
@@ -528,6 +526,8 @@ void CWLSurfaceResource::commitState(SSurfaceState& state) {
if (m_current.buffer) {
if (m_current.buffer->isSynchronous())
m_current.updateSynchronousTexture(lastTexture);
+ else if (!m_current.buffer->isSynchronous() && state.updated.bits.buffer) // only get a new texture when a new buffer arrived
+ m_current.texture = m_current.buffer->createTexture();
// if the surface is a cursor, update the shm buffer
// TODO: don't update the entire texture
diff --git a/src/protocols/core/Shm.cpp b/src/protocols/core/Shm.cpp
index 43c087bc..30189d8b 100644
--- a/src/protocols/core/Shm.cpp
+++ b/src/protocols/core/Shm.cpp
@@ -69,6 +69,10 @@ void CWLSHMBuffer::endDataPtr() {
;
}
+SP<CTexture> CWLSHMBuffer::createTexture() {
+ return nullptr;
+}
+
bool CWLSHMBuffer::good() {
return true;
}
diff --git a/src/protocols/core/Shm.hpp b/src/protocols/core/Shm.hpp
index 37210398..fba3de8d 100644
--- a/src/protocols/core/Shm.hpp
+++ b/src/protocols/core/Shm.hpp
@@ -43,6 +43,7 @@ class CWLSHMBuffer : public IHLBuffer {
virtual Aquamarine::SSHMAttrs shm();
virtual std::tuple<uint8_t*, uint32_t, size_t> beginDataPtr(uint32_t flags);
virtual void endDataPtr();
+ virtual SP<CTexture> createTexture();
bool good();