diff --git a/control.hh b/control.hh index 4cd7e3e..04c0bd4 100644 --- a/control.hh +++ b/control.hh @@ -29,6 +29,8 @@ enum E_OpType OP_CONST , OP_OFFSET , // + OP_GET_INPUT , + // OP_FP_LOAD , OP_FP_STORE , OP_FP_SLOAD , diff --git a/demo.cc b/demo.cc index 7986671..8fb8699 100644 --- a/demo.cc +++ b/demo.cc @@ -83,6 +83,15 @@ void T_Demo::render( ) } playingPrevious = playing; + if ( context && !context->aborted ) { + try { + context->run( ops::T_OpContext::R_RENDER , sync.time( ) , width , height ); + } catch ( ops::X_OpFailure const& fail ) { + printf( "FAILED TO RUN FRAME!\n\t%s\n" , fail.what( ) ); + context->aborted = true; + } + } + #if 0 raymarcher->render( ); dof->render( ); @@ -200,5 +209,16 @@ void T_Demo::runInit( ) context->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( ) ); + context->aborted = true; + return; } + + Globals::Sync( ).clearInputs( ); + const auto n( context->initialInputs.size( ) ); + assert( n == program->inputs.size( ) ); + for ( auto i = 0u ; i < n ; i ++ ) { + Globals::Sync( ).addInput( program->inputs[ i ] , + context->initialInputs[ i ] ); + } + Globals::Sync( ).updateCurveCaches( ); } diff --git a/demo.srd b/demo.srd index 76579d8..2f19931 100644 --- a/demo.srd +++ b/demo.srd @@ -98,7 +98,7 @@ (get-input raymarcher-max-dist) ) (uniforms prg-scene-p1 7 (get-input fog)) - (uniforms prg-scene-p1 8 (get-input raymarcher-correction)) + (uniforms-i prg-scene-p1 8 (get-input raymarcher-correction)) (use-pipeline pl-scene-p1) (use-framebuffer rt-scene) (viewport 0 0 $vp-width $vp-height) @@ -299,7 +299,7 @@ (use-framebuffer target) (use-texture 0 tx-bloom1 smp-bloom-blur) (uniforms prg-bloom-downsample 1 $w $h) - (uniforms prg-bloom-downsample 2 (sub $level 1)) + (uniforms-i prg-bloom-downsample 2 (sub $level 1)) (viewport 0 0 $w $h) (fullscreen) @@ -309,7 +309,7 @@ (fn bloom-blur-pass (lod fb1 fb2) # Common stuff for both passes (use-pipeline pl-bloom-blur) - (uniforms prg-bloom-blur 2 $lod) + (uniforms-i prg-bloom-blur 2 $lod) # Pass 1 (use-framebuffer fb2) diff --git a/opcomp.cc b/opcomp.cc index 28c1369..9df2c73 100644 --- a/opcomp.cc +++ b/opcomp.cc @@ -740,6 +740,11 @@ bool T_CompilerImpl_::compileNode( case A_Node::EXPR_INPUT: if ( !exit ) { + auto& in( (T_InputExprNode&) node ); + assert( output->inputs.contains( in.id( ) ) ); + addInstruction( OP_GET_INPUT , + output->inputs.indexOf( in.id( ) ) , + in.location( ) ); } break; } diff --git a/ops.cc b/ops.cc index db78837..fc46631 100644 --- a/ops.cc +++ b/ops.cc @@ -101,6 +101,7 @@ static T_KeyValueTable< E_OpType , T_OpInfo > OpInfoTable_{ ([]() { infos.add( E_OpType::OP_CONST , T_OpInfo{ "const" , 1 } ); infos.add( E_OpType::OP_OFFSET , T_OpInfo{ "offset" , 1 } ); // + infos.add( E_OpType::OP_GET_INPUT , T_OpInfo{ "get-input" , 1 , OpStackFPU{ 1 } } ); infos.add( E_OpType::OP_FP_LOAD , T_OpInfo{ "fp-load" , 1 , OpStackFPU{ 1 } } ); infos.add( E_OpType::OP_FP_SLOAD , T_OpInfo{ "fp-load-stack" , 1 , OpStackFPU{ 1 } } ); infos.add( E_OpType::OP_FP_STORE , T_OpInfo{ "fp-store" , 1 , OpStackFPU{ -1 } } ); @@ -286,6 +287,20 @@ void T_OpContext::run( //#define YOUR_MUM_IS_A_TRACE #ifdef YOUR_MUM_IS_A_TRACE + GL_ASSERT( ); + T_StringBuilder sb; + sb << "\nEXECUTE " << instrPtr << ":\t(" << instr << ") {" + << instr.location << "}\nSTACK:"; + for ( auto i = 0u ; i < stack.size( ) ; i ++ ) { + sb << ' ' << stack[ i ].u; + } + sb << "\nFPU STACK:"; + for ( auto i = 0u ; i < x87sp ; i ++ ) { + sb << ' ' << x87stack[ i ]; + } + sb << "\nWREG: " << wreg.f << '/' << wreg.u << '\n' << '\0'; + printf( "%s" , sb.data( ) ); + printf( "VALUES\n00" ); for ( auto i = 0u ; i < values.size( ) ; i ++ ) { printf( " %08x" , values[ i ].u ); @@ -296,19 +311,6 @@ void T_OpContext::run( if ( values.size( ) % 4 != 0 ) { printf( "\n" ); } - - T_StringBuilder sb; - sb << "EXECUTE " << instrPtr << ":\t(" << instr << ") {" - << instr.location << "}\nSTACK:"; - for ( auto i = 0u ; i < stack.size( ) ; i ++ ) { - sb << ' ' << stack[ i ].u; - } - sb << "\nFPU STACK:"; - for ( auto i = 0u ; i < x87sp ; i ++ ) { - sb << ' ' << x87stack[ i ]; - } - sb << '\n' << '\0'; - printf( "%s" , sb.data( ) ); #endif switch ( instr.op ) { @@ -348,7 +350,7 @@ void T_OpContext::run( // -------------------------------------------------------------------------------- case OP_RES_STACK: - stack.resize( stack.size( ) + instr.args[ 0 ] ); + stack.resize( stack.size( ) + instr.args[ 0 ] + 1 ); break; case OP_PUSH: @@ -389,6 +391,11 @@ void T_OpContext::run( // -------------------------------------------------------------------------------- + case OP_GET_INPUT: + ensureFpuStack( instr , 0 , 1 ); + x87stack[ x87sp ++ ] = Globals::Sync( ).inputs( )[ instr.args[ 0 ] + 1 ]; + break; + case OP_FP_LOAD: ensureFpuStack( instr , 0 , 1 ); checkAddress( instr , instr.args[ 0 ] ); @@ -822,7 +829,7 @@ void T_OpContext::run( if ( sv == 0 ) { glBindFramebuffer( GL_FRAMEBUFFER , 0 ); curFb = -1; - return; + break; } const auto index( sv - 1 );