Skip to content

Instantly share code, notes, and snippets.

@elupus
Last active August 29, 2015 14:10
Show Gist options
  • Save elupus/addbc44e9f7b6887c35e to your computer and use it in GitHub Desktop.
Save elupus/addbc44e9f7b6887c35e to your computer and use it in GitHub Desktop.
GL Delay Measurement
diff --git a/xbmc/rendering/gl/RenderSystemGL.cpp b/xbmc/rendering/gl/RenderSystemGL.cpp
index ae10d3e..b334d45 100644
--- a/xbmc/rendering/gl/RenderSystemGL.cpp
+++ b/xbmc/rendering/gl/RenderSystemGL.cpp
@@ -34,6 +34,7 @@
#include "utils/SystemInfo.h"
#include "utils/MathUtils.h"
#include "utils/StringUtils.h"
+#include <queue>
CRenderSystemGL::CRenderSystemGL() : CRenderSystemBase()
{
@@ -323,6 +324,24 @@ bool CRenderSystemGL::PresentRender(const CDirtyRegionList& dirty)
bool result = PresentRenderImpl(dirty);
+ static std::queue<GLsync> syncs;
+ static double delay;
+ static int count = 0;
+#if(1)
+ syncs.push(glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0));
+ delay = delay * 0.9 + 0.1 * syncs.size();
+ while(!syncs.empty())
+ {
+ if(glClientWaitSync(syncs.front(), 0, 0) == GL_TIMEOUT_EXPIRED)
+ break;
+ glDeleteSync(syncs.front());
+ syncs.pop();
+ }
+ if(count++ == 100) {
+ fprintf(stderr, "delay %f\n", delay);
+ count = 0;
+ }
+#endif
if (m_iVSyncMode && m_iSwapRate != 0)
{
int64_t curr, diff;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment