Compiler - OP_UNIFORMS

This commit is contained in:
Emmanuel BENOîT 2017-11-13 17:20:45 +01:00
parent d6fb6f9831
commit cdf883c3cd
5 changed files with 23 additions and 5 deletions

View file

@ -23,6 +23,7 @@ enum E_OpType
//
OP_LOAD ,
OP_SLOAD ,
OP_CONST ,
//
OP_FP_LOAD ,
OP_FP_STORE ,
@ -57,6 +58,7 @@ enum E_OpType
OP_USE_PIPELINE ,
OP_USE_PROGRAM ,
OP_USE_TEXTURE ,
OP_UNIFORMS ,
//
OP_FULLSCREEN ,
OP_CLEAR ,

View file

@ -260,8 +260,9 @@ A_Node* opast::ASTVisitorBrowser(
case A_Node::OP_UNIFORMS:
{
auto& n( (T_UniformsInstrNode&) node );
if ( child < n.values( ) ) {
return &n.value( child );
const auto nv( n.values( ) );
if ( child < nv ) {
return &n.value( nv - child - 1 );
}
break;
}

View file

@ -1032,7 +1032,7 @@ class T_UniformsInstrNode : public A_InstructionNode
T_SRDLocation progIdLocation_;
uint32_t uloc_;
T_SRDLocation ulocLocation_;
T_StaticArray< P_ExpressionNode , 4 > values_;
T_StaticArray< P_ArgumentNode , 4 > values_;
public:
T_UniformsInstrNode( T_InstrListNode& parent ,
@ -1060,13 +1060,14 @@ class T_UniformsInstrNode : public A_InstructionNode
void addValue( P_ExpressionNode value ) noexcept
{
if ( value ) {
values_.add( std::move( value ) );
values_.add( NewOwned< T_ArgumentNode >(
*this , std::move( value ) ) );
}
}
uint32_t values( ) const noexcept
{ return values_.size( ); }
A_ExpressionNode& value( const uint32_t index ) const noexcept
T_ArgumentNode& value( const uint32_t index ) const noexcept
{ return *values_[ index ]; }
};

View file

@ -531,6 +531,18 @@ bool T_CompilerImpl_::compileNode(
}
break;
case A_Node::OP_UNIFORMS:
if ( exit ) {
auto& un( (T_UniformsInstrNode&) node );
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 } ,
un.location( ) );
sdMain -= un.values( );
}
break;
//- RENDERING -------------------------------------------------------------------------

2
ops.cc
View file

@ -95,6 +95,7 @@ static T_KeyValueTable< E_OpType , T_OpInfo > OpInfoTable_{ ([]() {
//
infos.add( E_OpType::OP_LOAD , T_OpInfo{ "load" , 1 } );
infos.add( E_OpType::OP_SLOAD , T_OpInfo{ "load-stack" , 1 } );
infos.add( E_OpType::OP_CONST , T_OpInfo{ "const" , 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 } } );
@ -129,6 +130,7 @@ static T_KeyValueTable< E_OpType , T_OpInfo > OpInfoTable_{ ([]() {
infos.add( E_OpType::OP_USE_PIPELINE , T_OpInfo{ "use-pipeline" , 0 , OpStackMain{ -1 } } );
infos.add( E_OpType::OP_USE_PROGRAM , T_OpInfo{ "use-program" , 0 , OpStackMain{ -1 } } );
infos.add( E_OpType::OP_USE_TEXTURE , T_OpInfo{ "use-texture" , 1 , OpStackMain{ -2 } } );
infos.add( E_OpType::OP_UNIFORMS , T_OpInfo{ "uniforms" , 2 , OpStackMain{ -2 } } );
//
infos.add( E_OpType::OP_FULLSCREEN , T_OpInfo{ "fullscreen" } );
infos.add( E_OpType::OP_CLEAR , T_OpInfo{ "clear" , 0 , OpStackMain{ -4 } } );