summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineOpenGL
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-08-25 20:36:06 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-08-25 20:36:06 +0000
commit8f8cae971c7382de88608655f24be278b87d5e42 (patch)
treefa7fe62cd694b38007a906879a0842834f710758 /Graphics/GraphicsEngineOpenGL
parentMerge branch 'master' (diff)
downloadDiligentCore-8f8cae971c7382de88608655f24be278b87d5e42.tar.gz
DiligentCore-8f8cae971c7382de88608655f24be278b87d5e42.zip
Enabled duration queries in GL backend
Diffstat (limited to 'Graphics/GraphicsEngineOpenGL')
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp10
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/GLStubsAndroid.cpp4
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/QueryGLImpl.cpp23
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp2
4 files changed, 33 insertions, 6 deletions
diff --git a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp
index e1755125..a479cb49 100644
--- a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp
@@ -1331,6 +1331,11 @@ void DeviceContextGLImpl::BeginQuery(IQuery* pQuery)
#endif
break;
+ case QUERY_TYPE_DURATION:
+ glBeginQuery(GL_TIME_ELAPSED, glQuery);
+ DEV_CHECK_GL_ERROR("Failed to begin GL_TIME_ELAPSED query");
+ break;
+
default:
UNEXPECTED("Unexpected query type");
}
@@ -1376,6 +1381,11 @@ void DeviceContextGLImpl::EndQuery(IQuery* pQuery)
}
break;
+ case QUERY_TYPE_DURATION:
+ glEndQuery(GL_TIME_ELAPSED);
+ DEV_CHECK_GL_ERROR("Failed to end GL_TIME_ELAPSED query");
+ break;
+
default:
UNEXPECTED("Unexpected query type");
}
diff --git a/Graphics/GraphicsEngineOpenGL/src/GLStubsAndroid.cpp b/Graphics/GraphicsEngineOpenGL/src/GLStubsAndroid.cpp
index 428764ee..e426b2ca 100644
--- a/Graphics/GraphicsEngineOpenGL/src/GLStubsAndroid.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/GLStubsAndroid.cpp
@@ -377,10 +377,12 @@ Func = (FuncType)eglGetProcAddress( #Func );\
#endif
#ifdef LOAD_GL_GET_QUERY_OBJECT_UI64V
- LOAD_GL_FUNCTION(glGetQueryObjectui64v, PFNGLGETQUERYOBJECTUI64VPROC)
+ // Do not use stub
+ glGetQueryObjectui64v = (PFNGLGETQUERYOBJECTUI64VPROC)eglGetProcAddress( "glGetQueryObjectui64v" );
#endif
#ifdef LOAD_GL_QUERY_COUNTER
+ // Do not use stub
glQueryCounter = (PFNGLQUERYCOUNTERPROC)eglGetProcAddress( "glQueryCounter" );
#endif
}
diff --git a/Graphics/GraphicsEngineOpenGL/src/QueryGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/QueryGLImpl.cpp
index fd04362c..82d8b05b 100644
--- a/Graphics/GraphicsEngineOpenGL/src/QueryGLImpl.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/QueryGLImpl.cpp
@@ -71,6 +71,7 @@ bool QueryGLImpl::GetData(void* pData, Uint32 DataSize, bool AutoInvalidate)
case QUERY_TYPE_PIPELINE_STATISTICS:
#endif
+ case QUERY_TYPE_DURATION:
case QUERY_TYPE_TIMESTAMP:
glGetQueryObjectuiv(m_GlQuery, GL_QUERY_RESULT_AVAILABLE, &ResultAvailable);
CHECK_GL_ERROR("Failed to get query result");
@@ -118,16 +119,28 @@ bool QueryGLImpl::GetData(void* pData, Uint32 DataSize, bool AutoInvalidate)
break;
case QUERY_TYPE_TIMESTAMP:
+ case QUERY_TYPE_DURATION:
{
if (glGetQueryObjectui64v != nullptr)
{
- auto& QueryData = *reinterpret_cast<QueryDataTimestamp*>(pData);
- GLuint64 Counter = 0;
+ GLuint64 Counter = 0;
glGetQueryObjectui64v(m_GlQuery, GL_QUERY_RESULT, &Counter);
CHECK_GL_ERROR("Failed to get query result");
- QueryData.Counter = Counter;
- // Counter is always measured in nanoseconds (10^-9 seconds)
- QueryData.Frequency = 1000000000;
+ if (m_Desc.Type == QUERY_TYPE_TIMESTAMP)
+ {
+ auto& QueryData = *reinterpret_cast<QueryDataTimestamp*>(pData);
+ QueryData.Counter = Counter;
+ // Counter is always measured in nanoseconds (10^-9 seconds)
+ QueryData.Frequency = 1000000000;
+ }
+ else
+ {
+ VERIFY_EXPR(m_Desc.Type == QUERY_TYPE_DURATION);
+ auto& QueryData = *reinterpret_cast<QueryDataDuration*>(pData);
+ QueryData.Duration = Counter;
+ // Counter is always measured in nanoseconds (10^-9 seconds)
+ QueryData.Frequency = 1000000000;
+ }
}
}
break;
diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp
index 9b267441..ff9c95e0 100644
--- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp
@@ -160,6 +160,7 @@ RenderDeviceGLImpl::RenderDeviceGLImpl(IReferenceCounters* pRefCounters,
Features.BinaryOcclusionQueries = True; // Present since 3.3
Features.TimestampQueries = True; // Present since 3.3
Features.PipelineStatisticsQueries = True; // Present since 3.3
+ Features.DurationQueries = True; // Present since 3.3
Features.DepthBiasClamp = False; // There is no depth bias clamp in OpenGL
Features.DepthClamp = MajorVersion >= 4 || CheckExtension("GL_ARB_depth_clamp");
Features.IndependentBlend = True;
@@ -206,6 +207,7 @@ RenderDeviceGLImpl::RenderDeviceGLImpl(IReferenceCounters* pRefCounters,
Features.BinaryOcclusionQueries = True; // Supported in GLES3.0
Features.TimestampQueries = strstr(Extensions, "disjoint_timer_query") && glQueryCounter != nullptr;
Features.PipelineStatisticsQueries = False;
+ Features.DurationQueries = strstr(Extensions, "disjoint_timer_query") && glGetQueryObjectui64v != nullptr;
Features.DepthBiasClamp = False; // There is no depth bias clamp in OpenGL
Features.DepthClamp = strstr(Extensions, "depth_clamp");
Features.IndependentBlend = IsGLES32OrAbove;