From 1894b42773745e8f46e142aef3ee397f82cd034d Mon Sep 17 00:00:00 2001 From: Niraj Venkat Date: Wed, 8 Jul 2015 16:11:36 -0700 Subject: [PATCH] Added EXT support for Mac GL Query calls --- libraries/gpu/src/gpu/GLBackendQuery.cpp | 24 ++++++++++++++----- .../render-utils/src/RenderDeferredTask.cpp | 17 ------------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/libraries/gpu/src/gpu/GLBackendQuery.cpp b/libraries/gpu/src/gpu/GLBackendQuery.cpp index a6e34a90ca..585d7de5ff 100644 --- a/libraries/gpu/src/gpu/GLBackendQuery.cpp +++ b/libraries/gpu/src/gpu/GLBackendQuery.cpp @@ -11,10 +11,6 @@ #include "GPULogging.h" #include "GLBackendShared.h" -#ifndef GL_ARB_timer_query -#define GL_TIME_ELAPSED 0x88BF -#define GL_TIMESTAMP 0x8E28 -#endif using namespace gpu; @@ -70,6 +66,12 @@ void GLBackend::do_beginQuery(Batch& batch, uint32 paramOffset) { GLQuery* glquery = syncGPUObject(*query); if (glquery) { glBeginQuery(GL_TIME_ELAPSED, glquery->_qo); + #if (GPU_FEATURE_PROFILE == GPU_LEGACY) + // (EXT_TIMER_QUERY) + glBeginQuery(TIME_ELAPSED_EXT, glquery->_qo); + #else + glBeginQuery(GL_TIME_ELAPSED, glquery->_qo); + #endif (void)CHECK_GL_ERROR(); } } @@ -78,7 +80,12 @@ void GLBackend::do_endQuery(Batch& batch, uint32 paramOffset) { auto query = batch._queries.get(batch._params[paramOffset]._uint); GLQuery* glquery = syncGPUObject(*query); if (glquery) { - glEndQuery(GL_TIME_ELAPSED); + #if (GPU_FEATURE_PROFILE == GPU_LEGACY) + // (EXT_TIMER_QUERY) + glEndQuery(TIME_ELAPSED_EXT); + #else + glEndQuery(GL_TIME_ELAPSED); + #endif (void)CHECK_GL_ERROR(); } } @@ -87,7 +94,12 @@ void GLBackend::do_getQuery(Batch& batch, uint32 paramOffset) { auto query = batch._queries.get(batch._params[paramOffset]._uint); GLQuery* glquery = syncGPUObject(*query); if (glquery) { - glGetQueryObjectuiv(glquery->_qo, GL_QUERY_RESULT, &glquery->_result); + #if (GPU_FEATURE_PROFILE == GPU_LEGACY) + // (EXT_TIMER_QUERY) + GetQueryObjectui64vEXT(glquery->_qo, GL_QUERY_RESULT, &glquery->_result); + #else + glGetQueryObjectui64v(glquery->_qo, GL_QUERY_RESULT, &glquery->_result); + #endif (void)CHECK_GL_ERROR(); } } diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index 56980058c8..9ae0bd1b36 100755 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -104,27 +104,10 @@ void RenderDeferredTask::run(const SceneContextPointer& sceneContext, const Rend renderContext->args->_context->syncCache(); - // start the current timer query - auto& currentQuery = _timerQueries[_currentTimerQueryIndex]; - { - gpu::Batch batch; - batch.beginQuery(currentQuery); - renderContext->args->_context->render(batch); - } - for (auto job : _jobs) { job.run(sceneContext, renderContext); } - // End the current timer query - { - gpu::Batch batch; - batch.endQuery(currentQuery); - batch.getQuery(currentQuery); - renderContext->args->_context->render(batch); - (_currentTimerQueryIndex++); - _currentTimerQueryIndex = _currentTimerQueryIndex% _timerQueries.size(); - } }; void DrawOpaqueDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems) {