Control - All opcodes that do not use assets are done

This commit is contained in:
Emmanuel BENOîT 2017-11-14 14:25:55 +01:00
parent 512c981402
commit 71f6fed1ee
3 changed files with 73 additions and 1 deletions

View file

@ -159,11 +159,14 @@ struct T_OpContext
T_Array< T_OpValue > values; // VM data
T_Array< T_OpValue > stack; // Main VM stack
T_Array< float > initialInputs; // Initial input values
T_OpValue wreg; // Work register
double x87stack[ 8 ]; // x87 FPU emulation stack
uint32_t x87sp; // x87 FPU emulation stack pointer
T_Array< T_String > profiling; // Profiling sections that have been started
enum E_RunTarget {
R_INIT ,
R_RENDER

View file

@ -572,7 +572,7 @@ bool T_CompilerImpl_::compileNode(
addInstruction( OP_CONST , un.uloc( ) , un.ulocLocation( ) );
addInstruction( OP_PUSH , un.ulocLocation( ) );
processIdentifier( funcIndex , un.progId( ) , un.progIdLocation( ) );
addInstruction( OP_UNIFORMS , { un.values( ) , un.integers( ) ? 1u : 0u } ,
addInstruction( OP_UNIFORMS , { un.values( ) - 1 , un.integers( ) ? 1u : 0u } ,
un.location( ) );
sdMain -= un.values( );
}

69
ops.cc
View file

@ -2,6 +2,7 @@
#include "control.hh"
#include "globals.hh"
#include "sync.hh"
#include "profiling.hh"
using namespace ops;
using namespace ebcl;
@ -224,6 +225,7 @@ T_OpContext::T_OpContext(
+ program.nPrograms + program.nPipelines
+ program.nSamplers + program.nTextures };
values.resize( ts );
initialInputs.resize( program.inputs.size( ) );
for ( auto i = 0u ; i < nc ; i ++ ) {
values[ i + 3 ] = program.constants[ nc ];
@ -495,6 +497,73 @@ void T_OpContext::run(
break;
}
// --------------------------------------------------------------------------------
// TODO resource init
// --------------------------------------------------------------------------------
// TODO resource usage
case OP_UNIFORMS:
{
ensureStack( instr , 3 + instr.args[ 0 ] );
const auto ss( stack.size( ) );
T_OpValue values[ 4 ];
for ( auto i = 0u ; i <= instr.args[ 0 ] ; i ++ ) {
values[ i ] = stack[ ss - 2 - i ];
}
// FIXME can't actually finish this, I'm stupid.
break;
}
case OP_VIEWPORT:
{
ensureStack( instr , 4 );
const auto ss( stack.size( ) );
glViewport( stack[ ss - 1 ].f , stack[ ss - 2 ].f ,
stack[ ss - 3 ].f , stack[ ss - 4 ].f );
stack.resize( ss - 4 );
break;
}
// --------------------------------------------------------------------------------
case OP_FULLSCREEN:
glDrawArrays( GL_TRIANGLE_STRIP , 0 , 4 );
break;
case OP_CLEAR:
{
ensureStack( instr , 4 );
const auto ss( stack.size( ) );
glClearColor( stack[ ss - 1 ].f , stack[ ss - 2 ].f ,
stack[ ss - 3 ].f , stack[ ss - 4 ].f );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
stack.resize( ss - 4 );
break;
}
// --------------------------------------------------------------------------------
case OP_UI_PENTER:
{
T_String const& section( program.uiStrings[ instr.args[ 0 ] ] );
Globals::Profiler( ).start( section );
profiling.add( section );
break;
}
case OP_UI_PEXIT:
Globals::Profiler( ).end( profiling.last( ) );
profiling.removeLast( );
break;
case OP_UI_INPUT_DFT:
initialInputs[ instr.args[ 0 ] ] = values[ instr.args[ 1 ] ].f;
break;
}