From bfe6c75bcc0c768548f9b822c609c600a01a268d Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 10 Aug 2018 12:21:32 +0100 Subject: [PATCH] Don't replay markers in GL while timing. Refs #1068 * We also clear GL errors after replaying to ensure we don't get false positives when checking for errors beginning the query. --- renderdoc/driver/gl/gl_counters.cpp | 12 ++++++++++++ renderdoc/driver/gl/gl_driver.cpp | 2 +- renderdoc/driver/gl/gl_driver.h | 3 +++ renderdoc/driver/gl/wrappers/gl_debug_funcs.cpp | 16 +++++++++++----- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/renderdoc/driver/gl/gl_counters.cpp b/renderdoc/driver/gl/gl_counters.cpp index 981bf13f9..8edd15ec3 100644 --- a/renderdoc/driver/gl/gl_counters.cpp +++ b/renderdoc/driver/gl/gl_counters.cpp @@ -256,8 +256,11 @@ void GLReplay::FillTimers(GLCounterContext &ctx, const DrawcallDescription &draw m_pDriver->ReplayLog(ctx.eventStart, d.eventId, eReplay_WithoutDraw); + ClearGLErrors(); + // Reverse order so that Timer counter is queried the last. for(int32_t q = uint32_t(GPUCounter::Count) - 1; q >= 0; q--) + { if(queries->obj[q]) { m_pDriver->glBeginQuery(glCounters[q], queries->obj[q]); @@ -267,6 +270,7 @@ void GLReplay::FillTimers(GLCounterContext &ctx, const DrawcallDescription &draw queries->obj[q] = 0; } } + } m_pDriver->ReplayLog(ctx.eventStart, d.eventId, eReplay_OnlyDraw); @@ -335,6 +339,8 @@ vector GLReplay::FetchCountersAMD(const vector &count vector eventIDs; + m_pDriver->ReplayMarkers(false); + for(uint32_t p = 0; p < passCount; p++) { m_pAMDCounters->BeginPass(); @@ -350,6 +356,8 @@ vector GLReplay::FetchCountersAMD(const vector &count m_pAMDCounters->EndPass(); } + m_pDriver->ReplayMarkers(true); + m_pAMDCounters->EndSesssion(sessionID); std::vector ret = @@ -397,10 +405,14 @@ vector GLReplay::FetchCounters(const vector &allCount GLCounterContext ctx; ctx.eventStart = 0; + m_pDriver->ReplayMarkers(false); + m_pDriver->SetFetchCounters(true); FillTimers(ctx, m_pDriver->GetRootDraw(), counters); m_pDriver->SetFetchCounters(false); + m_pDriver->ReplayMarkers(true); + double nanosToSecs = 1.0 / 1000000000.0; GLuint prevbind = 0; diff --git a/renderdoc/driver/gl/gl_driver.cpp b/renderdoc/driver/gl/gl_driver.cpp index b023c6a98..564ecae88 100644 --- a/renderdoc/driver/gl/gl_driver.cpp +++ b/renderdoc/driver/gl/gl_driver.cpp @@ -4838,7 +4838,7 @@ void WrappedOpenGL::ReplayLog(uint32_t startEventID, uint32_t endEventID, Replay RDCASSERTEQUAL(status, ReplayStatus::Succeeded); // make sure to end any unbalanced replay events if we stopped in the middle of a frame - for(int i = 0; i < m_ReplayEventCount; i++) + for(int i = 0; m_ReplayMarkers && i < m_ReplayEventCount; i++) GLMarkerRegion::End(); GLMarkerRegion::Set("!!!!RenderDoc Internal: Done replay"); diff --git a/renderdoc/driver/gl/gl_driver.h b/renderdoc/driver/gl/gl_driver.h index 450c7d799..5b1840907 100644 --- a/renderdoc/driver/gl/gl_driver.h +++ b/renderdoc/driver/gl/gl_driver.h @@ -224,6 +224,8 @@ private: vector m_CurEvents, m_Events; bool m_AddedDrawcall; + bool m_ReplayMarkers = true; + uint64_t m_CurChunkOffset; SDChunkMetaData m_ChunkMetadata; uint32_t m_CurEventID, m_CurDrawcallID; @@ -536,6 +538,7 @@ public: bool UsesVRFrameMarkers() { return m_UsesVRMarkers; } void FirstFrame(void *ctx, void *wndHandle); + void ReplayMarkers(bool replay) { m_ReplayMarkers = replay; } void StartFrameCapture(void *dev, void *wnd); bool EndFrameCapture(void *dev, void *wnd); diff --git a/renderdoc/driver/gl/wrappers/gl_debug_funcs.cpp b/renderdoc/driver/gl/wrappers/gl_debug_funcs.cpp index fb04cbfa7..f54b85159 100644 --- a/renderdoc/driver/gl/wrappers/gl_debug_funcs.cpp +++ b/renderdoc/driver/gl/wrappers/gl_debug_funcs.cpp @@ -175,7 +175,8 @@ bool WrappedOpenGL::Serialise_glDebugMessageInsert(SerialiserType &ser, GLenum s if(IsReplayingAndReading()) { - GLMarkerRegion::Set(name); + if(m_ReplayMarkers) + GLMarkerRegion::Set(name); if(IsLoading(m_State)) { @@ -265,7 +266,8 @@ bool WrappedOpenGL::Serialise_glInsertEventMarkerEXT(SerialiserType &ser, GLsize if(IsReplayingAndReading()) { - GLMarkerRegion::Set(marker); + if(m_ReplayMarkers) + GLMarkerRegion::Set(marker); if(IsLoading(m_State)) { @@ -328,8 +330,11 @@ bool WrappedOpenGL::Serialise_glPushDebugGroup(SerialiserType &ser, GLenum sourc if(IsReplayingAndReading()) { - GLMarkerRegion::Begin(message, source, id); - m_ReplayEventCount++; + if(m_ReplayMarkers) + { + GLMarkerRegion::Begin(message, source, id); + m_ReplayEventCount++; + } if(IsLoading(m_State)) { @@ -365,7 +370,8 @@ bool WrappedOpenGL::Serialise_glPopDebugGroup(SerialiserType &ser) { if(IsReplayingAndReading()) { - GLMarkerRegion::End(); + if(m_ReplayMarkers) + GLMarkerRegion::End(); m_ReplayEventCount = RDCMAX(0, m_ReplayEventCount - 1); if(IsLoading(m_State) && !m_CurEvents.empty())