From 75c17e4f9bf04ac60ae39f4cc5430854fcb52387 Mon Sep 17 00:00:00 2001 From: Vincent Tavernier <vincent.tavernier@inria.fr> Date: Fri, 16 Feb 2018 15:52:02 +0100 Subject: [PATCH] Remove binding changes from runtime measurement --- include/shadertoy/RenderContext.hpp | 8 ++++++++ src/RenderContext.cpp | 11 +++++++++++ src/ToyBuffer.cpp | 8 +------- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/include/shadertoy/RenderContext.hpp b/include/shadertoy/RenderContext.hpp index 92e889c..2afcfc1 100644 --- a/include/shadertoy/RenderContext.hpp +++ b/include/shadertoy/RenderContext.hpp @@ -240,6 +240,14 @@ public: */ void RenderScreenQuad(); + /** + * @brief Render a screen quad using the current context + * + * @param timerQuery Query object to use for measuring the runtime of the + * draw call. + */ + void RenderScreenQuad(OpenGL::Query &timerQuery); + /** * @brief Binds the texture containing the shadertoy result as well as * a program which renders this texture to the viewport. Useful diff --git a/src/RenderContext.cpp b/src/RenderContext.cpp index 9099fff..84748a4 100644 --- a/src/RenderContext.cpp +++ b/src/RenderContext.cpp @@ -382,6 +382,17 @@ void RenderContext::RenderScreenQuad() glCall(glDrawElements, GL_TRIANGLES, 3 * 2, GL_UNSIGNED_INT, nullptr); } +void RenderContext::RenderScreenQuad(OpenGL::Query &timerQuery) +{ + screenQuadCorners.Bind(GL_ARRAY_BUFFER); + + timerQuery.Begin(GL_TIME_ELAPSED); + + glCall(glDrawElements, GL_TRIANGLES, 3 * 2, GL_UNSIGNED_INT, nullptr); + + timerQuery.End(GL_TIME_ELAPSED); +} + void RenderContext::BindResult() { // Prepare prog and texture diff --git a/src/ToyBuffer.cpp b/src/ToyBuffer.cpp index 1f38d0c..1a222c8 100644 --- a/src/ToyBuffer.cpp +++ b/src/ToyBuffer.cpp @@ -161,14 +161,8 @@ void ToyBuffer::Render() for (auto &inputs : boundInputs) inputs->Apply(); - // Start query measurement - timeDeltaQuery.Begin(GL_TIME_ELAPSED); - // Render the program - context.RenderScreenQuad(); - - // End query measurement - timeDeltaQuery.End(GL_TIME_ELAPSED); + context.RenderScreenQuad(timeDeltaQuery); // Swap texture object pointers swap(sourceTex, targetTex); -- GitLab