summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineOpenGL
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-01-03 22:25:47 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-01-03 22:25:47 +0000
commite011c27e544c928ba94b781a56818aa8199519b2 (patch)
treeaa02a2fbaca02bd607c4e22f61f4f57fb810cd9f /Graphics/GraphicsEngineOpenGL
parentImplemented queries in OpenGL (diff)
downloadDiligentCore-e011c27e544c928ba94b781a56818aa8199519b2.tar.gz
DiligentCore-e011c27e544c928ba94b781a56818aa8199519b2.zip
Fixed iOS GLES build issue
Diffstat (limited to 'Graphics/GraphicsEngineOpenGL')
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/GLStubsIOS.h10
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp14
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/QueryGLImpl.cpp30
3 files changed, 46 insertions, 8 deletions
diff --git a/Graphics/GraphicsEngineOpenGL/include/GLStubsIOS.h b/Graphics/GraphicsEngineOpenGL/include/GLStubsIOS.h
index 355c3135..c6669652 100644
--- a/Graphics/GraphicsEngineOpenGL/include/GLStubsIOS.h
+++ b/Graphics/GraphicsEngineOpenGL/include/GLStubsIOS.h
@@ -503,6 +503,16 @@
# define GL_ALL_BARRIER_BITS 0xFFFFFFFF
#endif
+
+#ifndef GL_SAMPLES_PASSED
+# define GL_SAMPLES_PASSED 0
+#endif
+
+#ifndef GL_PRIMITIVES_GENERATED
+# define GL_PRIMITIVES_GENERATED 0
+#endif
+
+
// Define unsupported GL function stubs
template <typename T>
void UnsupportedGLFunctionStub(const T& Name)
diff --git a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp
index 6726eb6d..efffb8b6 100644
--- a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp
@@ -1073,8 +1073,12 @@ void DeviceContextGLImpl::BeginQuery(IQuery* pQuery)
switch (QueryType)
{
case QUERY_TYPE_OCCLUSION:
+#if GL_SAMPLES_PASSED
glBeginQuery(GL_SAMPLES_PASSED, glQuery);
CHECK_GL_ERROR("Failed to begin GL_SAMPLES_PASSED query");
+#else
+ LOG_ERROR_MESSAGE_ONCE("GL_SAMPLES_PASSED query is not supported by this device");
+#endif
break;
case QUERY_TYPE_BINARY_OCCLUSION:
@@ -1083,8 +1087,12 @@ void DeviceContextGLImpl::BeginQuery(IQuery* pQuery)
break;
case QUERY_TYPE_PIPELINE_STATISTICS:
+#if GL_PRIMITIVES_GENERATED
glBeginQuery(GL_PRIMITIVES_GENERATED, glQuery);
CHECK_GL_ERROR("Failed to begin GL_PRIMITIVES_GENERATED query");
+#else
+ LOG_ERROR_MESSAGE_ONCE("GL_PRIMITIVES_GENERATED query is not supported by this device");
+#endif
break;
default:
@@ -1102,8 +1110,10 @@ void DeviceContextGLImpl::EndQuery(IQuery* pQuery)
switch (QueryType)
{
case QUERY_TYPE_OCCLUSION:
+#if GL_SAMPLES_PASSED
glEndQuery(GL_SAMPLES_PASSED);
CHECK_GL_ERROR("Failed to end GL_SAMPLES_PASSED query");
+#endif
break;
case QUERY_TYPE_BINARY_OCCLUSION:
@@ -1112,8 +1122,10 @@ void DeviceContextGLImpl::EndQuery(IQuery* pQuery)
break;
case QUERY_TYPE_PIPELINE_STATISTICS:
+#if GL_PRIMITIVES_GENERATED
glEndQuery(GL_PRIMITIVES_GENERATED);
CHECK_GL_ERROR("Failed to end GL_PRIMITIVES_GENERATED query");
+#endif
break;
case QUERY_TYPE_TIMESTAMP:
@@ -1121,7 +1133,7 @@ void DeviceContextGLImpl::EndQuery(IQuery* pQuery)
glQueryCounter(pQueryGLImpl->GetGlQueryHandle(), GL_TIMESTAMP);
CHECK_GL_ERROR("glQueryCounter failed");
#else
- LOG_WARNING_MESSAGE_ONCE("Timer queries are not supported by this device");
+ LOG_ERROR_MESSAGE_ONCE("Timer queries are not supported by this device");
#endif
break;
diff --git a/Graphics/GraphicsEngineOpenGL/src/QueryGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/QueryGLImpl.cpp
index f2601f4a..2f3f425d 100644
--- a/Graphics/GraphicsEngineOpenGL/src/QueryGLImpl.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/QueryGLImpl.cpp
@@ -54,13 +54,29 @@ QueryGLImpl::~QueryGLImpl()
bool QueryGLImpl::GetData(void* pData, Uint32 DataSize)
{
- GLint ResultAvailable = 0;
-#if !GL_ARB_timer_query
- if (m_Desc.Type != QUERY_TYPE_TIMESTAMP)
-#endif
+ GLuint ResultAvailable = GL_FALSE;
+
+ switch (m_Desc.Type)
{
- glGetQueryObjectiv(m_GlQuery, GL_QUERY_RESULT_AVAILABLE, &ResultAvailable);
- CHECK_GL_ERROR("Failed to get query result");
+#if GL_SAMPLES_PASSED
+ case QUERY_TYPE_OCCLUSION:
+#endif
+
+ case QUERY_TYPE_BINARY_OCCLUSION:
+
+#if GL_PRIMITIVES_GENERATED
+ case QUERY_TYPE_PIPELINE_STATISTICS:
+#endif
+
+#if GL_ARB_timer_query
+ case QUERY_TYPE_TIMESTAMP:
+#endif
+ glGetQueryObjectuiv(m_GlQuery, GL_QUERY_RESULT_AVAILABLE, &ResultAvailable);
+ CHECK_GL_ERROR("Failed to get query result");
+ break;
+
+ default:
+ return false;
}
if (ResultAvailable)
@@ -120,7 +136,7 @@ bool QueryGLImpl::GetData(void* pData, Uint32 DataSize)
}
}
- return ResultAvailable != 0;
+ return ResultAvailable != GL_FALSE;
}
} // namespace Diligent