From 957f35c4bb223d9f79d3aaec214e31ba00ffbf2a Mon Sep 17 00:00:00 2001 From: assiduous Date: Tue, 14 Jan 2020 09:40:20 -0800 Subject: QueryTest: fixed issue with OpenGL: glFinish() does not guarantee that queries become available --- Tests/DiligentCoreAPITest/src/QueryTest.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Tests/DiligentCoreAPITest/src/QueryTest.cpp b/Tests/DiligentCoreAPITest/src/QueryTest.cpp index 4b9405d3..c65cd014 100644 --- a/Tests/DiligentCoreAPITest/src/QueryTest.cpp +++ b/Tests/DiligentCoreAPITest/src/QueryTest.cpp @@ -27,6 +27,7 @@ #include #include +#include #include "TestingEnvironment.h" @@ -201,6 +202,22 @@ protected: } pContext->WaitForIdle(); + if (pDevice->GetDeviceCaps().IsGLDevice()) + { + // glFinish() is not a guarantee that queries will become available + for (Uint32 i = 0; i < sm_NumTestQueries; ++i) + { + WaitForQuery(Queries[i]); + } + } + } + + static void WaitForQuery(IQuery* pQuery) + { + while (!pQuery->GetData(nullptr, 0)) + { + std::this_thread::yield(); + } } static constexpr Uint32 sm_TextureSize = 512; @@ -361,6 +378,13 @@ TEST_F(QueryTest, Timestamp) pContext->Flush(); pContext->FinishFrame(); pContext->WaitForIdle(); + if (pDevice->GetDeviceCaps().IsGLDevice()) + { + // glFinish() is not a guarantee that queries will become available + WaitForQuery(pQueryStart); + WaitForQuery(pQueryEnd); + } + QueryDataTimestamp QueryStartData, QueryEndData; auto QueryReady = pQueryStart->GetData(nullptr, 0); -- cgit v1.2.3