From a266120761ce23ab987edf9e8807521815a2ffe9 Mon Sep 17 00:00:00 2001 From: Emmanuel Benoit Date: Fri, 30 Mar 2018 17:34:22 +0200 Subject: [PATCH] Profiler - "Expected order" workaround So the profiler apparently expects starts and ends to be consistent in ordering. Whenever the order changes, it will likely crash. Modified the main loop so it doesn't add the debug output's timings if the profiler has been reset due to reloading as a workaround. This needs to be fixed, though. --- m-tool.cc | 15 ++++++++++++--- ui-demo.cc | 5 ++++- ui-demo.hh | 2 +- ui-profiling.cc | 1 + 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/m-tool.cc b/m-tool.cc index 9446270..9c9bbbe 100644 --- a/m-tool.cc +++ b/m-tool.cc @@ -175,14 +175,23 @@ void T_Main::makeUI( ) void T_Main::render( ) { if ( demo ) { - demo->render( ); + const bool hadReset = demo->render( ); + if ( hadReset ) { + UI::Profiler( ).clear( ); + UI::Profiler( ).startFrame( ); + UI::Profiler( ).start( "Full frame" ); + } - UI::Profiler( ).start( "Debug" ); + if ( !hadReset ) { + UI::Profiler( ).start( "Debug" ); + } T_Rendertarget::MainOutput( ); if ( UI::ODbg( ).isActive( ) ) { UI::ODbg( ).debugOutput( ); } - UI::Profiler( ).end( "Debug" ); + if ( !hadReset ) { + UI::Profiler( ).end( "Debug" ); + } } else { T_Rendertarget::MainOutput( ); diff --git a/ui-demo.cc b/ui-demo.cc index cfdcb5f..d18cbef 100644 --- a/ui-demo.cc +++ b/ui-demo.cc @@ -23,12 +23,14 @@ bool T_Demo::initialise( return program && runInit( *program ); } -void T_Demo::render( ) +bool T_Demo::render( ) { + bool rv = false; if ( Common::Ops( ).hasNewProgram( ) ) { auto nProgram{ Common::Ops( ).program( ) }; if ( runInit( *nProgram ) ) { program = std::move( nProgram ); + rv = true; } } @@ -44,6 +46,7 @@ void T_Demo::render( ) context->aborted = true; } } + return rv; } bool T_Demo::runInit( diff --git a/ui-demo.hh b/ui-demo.hh index e3ced13..76d766e 100644 --- a/ui-demo.hh +++ b/ui-demo.hh @@ -16,7 +16,7 @@ struct T_Demo bool initialise( const uint32_t width , const uint32_t height ); - void render( ); + bool render( ); // --------------------------------------------------------------------- diff --git a/ui-profiling.cc b/ui-profiling.cc index a937bcc..73a8ab1 100644 --- a/ui-profiling.cc +++ b/ui-profiling.cc @@ -94,6 +94,7 @@ void T_Profiler::start( parents_.add( Invalid ); } + assert( previous_ == Invalid || previous_ < pos ); chain_[ pos ] = previous_; if ( current_ != Invalid ) { parents_[ pos ] = current_;