Emmanuel BENOîT
a266120761
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.
88 lines
1.9 KiB
C++
88 lines
1.9 KiB
C++
#include "externals.hh"
|
|
|
|
#include "common.hh"
|
|
#include "c-opcomp.hh"
|
|
#include "c-sync.hh"
|
|
|
|
#include "ui.hh"
|
|
#include "ui-demo.hh"
|
|
#include "ui-opemu.hh"
|
|
#include "ui-rendertarget.hh"
|
|
#include "ui-sync.hh"
|
|
|
|
#include <ebcl/Files.hh>
|
|
#include <ebcl/SRDText.hh>
|
|
|
|
|
|
bool T_Demo::initialise(
|
|
const uint32_t w ,
|
|
const uint32_t h )
|
|
{
|
|
width = w;
|
|
height = h;
|
|
return program && runInit( *program );
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
UI::Sync( ).updateTime( );
|
|
|
|
if ( context && !context->aborted ) {
|
|
try {
|
|
context->run( ops::T_OpContext::R_RENDER ,
|
|
Common::Sync( ).time( ) ,
|
|
width , height );
|
|
} catch ( ops::X_OpFailure const& fail ) {
|
|
printf( "FAILED TO RUN FRAME!\n\t%s\n" , fail.what( ) );
|
|
context->aborted = true;
|
|
}
|
|
}
|
|
return rv;
|
|
}
|
|
|
|
bool T_Demo::runInit(
|
|
ops::T_OpProgram& p )
|
|
{
|
|
auto nContext{ NewOwned< ops::T_OpContext >( p ) };
|
|
try {
|
|
nContext->run( ops::T_OpContext::R_INIT , 0 , width , height );
|
|
} catch ( ops::X_OpFailure const& fail ) {
|
|
printf( "FAILED TO RUN INIT!\n\t%s\n" , fail.what( ) );
|
|
nContext.clear( );
|
|
}
|
|
if ( !nContext ) {
|
|
return false;
|
|
}
|
|
context = std::move( nContext );
|
|
|
|
Common::Sync( ).clearInputs( );
|
|
Common::Sync( ).clearOverrides( );
|
|
|
|
const auto n( context->initialInputs.size( ) );
|
|
assert( n == p.inputs.size( ) );
|
|
for ( auto i = 0u ; i < n ; i ++ ) {
|
|
Common::Sync( ).addInput( p.inputs[ i ] ,
|
|
context->initialInputs[ i ] );
|
|
#ifdef INVASIVE_TRACES
|
|
printf( "#%d %s pos %d\n" , i , p.inputs[ i ].toOSString( ).data( ) ,
|
|
Common::Sync( ).inputPos( p.inputs[ i ] ) );
|
|
#endif //INVASIVE_TRACES
|
|
}
|
|
Common::Sync( ).updateCurveCaches( );
|
|
|
|
if ( context->installOverrides ) {
|
|
Common::Sync( ).mergeOverrides( *( context->installOverrides ) );
|
|
context->installOverrides.clear( );
|
|
}
|
|
|
|
return true;
|
|
}
|