From 2ddecf35d261e5765ccb1f1dc6646241684cc237 Mon Sep 17 00:00:00 2001 From: xperia64 Date: Tue, 9 Feb 2021 16:32:48 +0000 Subject: [PATCH] Avoid leaking fences during re-presentation (#5713) * Avoid leaking fences during re-presentation --- src/video_core/renderer_opengl/renderer_opengl.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index bf123c4e0..3058ef879 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -1107,6 +1107,11 @@ void RendererOpenGL::TryPresent(int timeout_ms) { glBlitFramebuffer(0, 0, frame->width, frame->height, 0, 0, layout.width, layout.height, GL_COLOR_BUFFER_BIT, GL_LINEAR); + // Delete the fence if we're re-presenting to avoid leaking fences + if (frame->present_fence) { + glDeleteSync(frame->present_fence); + } + /* insert fence for the main thread to block on */ frame->present_fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); glFlush();