From 01bf4f12d3093f6a19015c3b6a1608762200c345 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Wed, 23 Nov 2022 19:04:18 +0100 Subject: [PATCH] kwinglutils: don't crash on gpu resets --- src/libkwineffects/kwinglutils.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/libkwineffects/kwinglutils.cpp b/src/libkwineffects/kwinglutils.cpp index 34ab5ff997..601b4d6abf 100644 --- a/src/libkwineffects/kwinglutils.cpp +++ b/src/libkwineffects/kwinglutils.cpp @@ -1802,11 +1802,11 @@ GLvoid *GLVertexBufferPrivate::getIdleRange(size_t size) } // Emit a fence now - BufferFence fence; - fence.sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); - Q_ASSERT(fence.sync); - fence.nextEnd = bufferSize; - fences.emplace_back(fence); + if (auto sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0)) { + fences.push_back(BufferFence{ + .sync = sync, + .nextEnd = intptr_t(bufferSize)}); + } } if (unlikely(nextOffset + intptr_t(size) > bufferEnd)) { @@ -2092,12 +2092,11 @@ void GLVertexBuffer::endOfFrame() d->nextOffset = 0; d->map = nullptr; } else { - BufferFence fence; - fence.sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); - Q_ASSERT(fence.sync); - fence.nextEnd = d->nextOffset + d->bufferSize; - - d->fences.emplace_back(fence); + if (auto sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0)) { + d->fences.push_back(BufferFence{ + .sync = sync, + .nextEnd = intptr_t(d->nextOffset + d->bufferSize)}); + } } } }