From e011c27e544c928ba94b781a56818aa8199519b2 Mon Sep 17 00:00:00 2001 From: assiduous Date: Fri, 3 Jan 2020 14:25:47 -0800 Subject: Fixed iOS GLES build issue --- Graphics/GraphicsEngineOpenGL/include/GLStubsIOS.h | 10 ++++++++ .../src/DeviceContextGLImpl.cpp | 14 +++++++++- Graphics/GraphicsEngineOpenGL/src/QueryGLImpl.cpp | 30 +++++++++++++++++----- 3 files changed, 46 insertions(+), 8 deletions(-) (limited to 'Graphics/GraphicsEngineOpenGL') 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 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 -- cgit v1.2.3