Guard against render time query failing

glGetQuery can fail (for example because of a context loss) in this
case the buffer stays unmodified. In this case this is zero resulting
in GLRenderTimeQuery::result() returning a negative value. Down the
line this leads to a negative duration in the RenderJournal and
RenderLoopPrivate::scheduleRepaint starting a timer with an amount
of milliseconds bigger than what an int can hold. This will not
actually start a timer but QTimer::isActive returns true resulting
in no futher repaints being scheduled.
BUG: 475605
FIXED-IN: 6.0
This commit is contained in:
David Redondo 2024-02-08 12:35:09 +01:00
parent 51fb56773b
commit 6b4018014c

View file

@ -56,6 +56,9 @@ std::chrono::nanoseconds GLRenderTimeQuery::result()
if (m_query) {
uint64_t nanos = 0;
glGetQueryObjectui64v(m_query, GL_QUERY_RESULT, &nanos);
if (nanos == 0) {
return std::chrono::nanoseconds::zero();
}
return std::chrono::nanoseconds(nanos) - m_cpuStart;
} else {
return m_cpuEnd - m_cpuStart;