kwinglutils: don't crash on gpu resets

This commit is contained in:
Xaver Hugl 2022-11-23 19:04:18 +01:00
parent f7a8635b10
commit 01bf4f12d3

View file

@ -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)});
}
}
}
}