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.
This commit is contained in:
Emmanuel BENOîT 2018-03-30 17:34:22 +02:00
parent 68d01ca42e
commit a266120761
4 changed files with 18 additions and 5 deletions

View file

@ -175,14 +175,23 @@ void T_Main::makeUI( )
void T_Main::render( ) void T_Main::render( )
{ {
if ( demo ) { 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( ); T_Rendertarget::MainOutput( );
if ( UI::ODbg( ).isActive( ) ) { if ( UI::ODbg( ).isActive( ) ) {
UI::ODbg( ).debugOutput( ); UI::ODbg( ).debugOutput( );
} }
UI::Profiler( ).end( "Debug" ); if ( !hadReset ) {
UI::Profiler( ).end( "Debug" );
}
} else { } else {
T_Rendertarget::MainOutput( ); T_Rendertarget::MainOutput( );

View file

@ -23,12 +23,14 @@ bool T_Demo::initialise(
return program && runInit( *program ); return program && runInit( *program );
} }
void T_Demo::render( ) bool T_Demo::render( )
{ {
bool rv = false;
if ( Common::Ops( ).hasNewProgram( ) ) { if ( Common::Ops( ).hasNewProgram( ) ) {
auto nProgram{ Common::Ops( ).program( ) }; auto nProgram{ Common::Ops( ).program( ) };
if ( runInit( *nProgram ) ) { if ( runInit( *nProgram ) ) {
program = std::move( nProgram ); program = std::move( nProgram );
rv = true;
} }
} }
@ -44,6 +46,7 @@ void T_Demo::render( )
context->aborted = true; context->aborted = true;
} }
} }
return rv;
} }
bool T_Demo::runInit( bool T_Demo::runInit(

View file

@ -16,7 +16,7 @@ struct T_Demo
bool initialise( const uint32_t width , bool initialise( const uint32_t width ,
const uint32_t height ); const uint32_t height );
void render( ); bool render( );
// --------------------------------------------------------------------- // ---------------------------------------------------------------------

View file

@ -94,6 +94,7 @@ void T_Profiler::start(
parents_.add( Invalid ); parents_.add( Invalid );
} }
assert( previous_ == Invalid || previous_ < pos );
chain_[ pos ] = previous_; chain_[ pos ] = previous_;
if ( current_ != Invalid ) { if ( current_ != Invalid ) {
parents_[ pos ] = current_; parents_[ pos ] = current_;