From fc704d0ebf50d22aaa404f377688953d773a50f2 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 31 Aug 2023 12:27:25 +0200 Subject: [PATCH] rhi: gl: Prevent GPU timings from stopping upon resize Doing glGenQueries every time the window (and so swapchain) is resized is not great. Change-Id: Ide1cf970d86dd5469b06633a3276c2130b030037 Reviewed-by: Andy Nichols --- src/gui/rhi/qrhigles2.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index adb195d802..7148d59d18 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -6294,12 +6294,15 @@ bool QGles2SwapChain::createOrResize() void QGles2SwapChainTimestamps::prepare(QRhiGles2 *rhiD) { - rhiD->f->glGenQueries(TIMESTAMP_PAIRS * 2, query); + if (!query[0]) + rhiD->f->glGenQueries(TIMESTAMP_PAIRS * 2, query); } void QGles2SwapChainTimestamps::destroy(QRhiGles2 *rhiD) { rhiD->f->glDeleteQueries(TIMESTAMP_PAIRS * 2, query); + memset(active, 0, sizeof(active)); + memset(query, 0, sizeof(query)); } bool QGles2SwapChainTimestamps::tryQueryTimestamps(int pairIndex, QRhiGles2 *rhiD, double *elapsedSec)