Compiler - Sampler initialisation command

This commit is contained in:
Emmanuel BENOîT 2017-11-13 18:16:48 +01:00
parent 91f363ee06
commit e7029af764
5 changed files with 36 additions and 5 deletions

View file

@ -50,6 +50,7 @@ enum E_OpType
//
OP_INIT_PIPELINE ,
OP_INIT_PROGRAM ,
OP_INIT_SAMPLER ,
OP_INIT_TEXTURE ,
OP_FB_ATTACH ,
//

View file

@ -604,7 +604,9 @@ T_Optional< T_SRDLocation > T_SamplerInstrNode::setLOD(
if ( lod_ ) {
return lod_->location;
}
lod_ = T_LOD_{ location , std::move( min ) , std::move( max ) };
lod_ = T_LOD_{ location ,
min ? NewOwned< T_ArgumentNode >( *this , std::move( min ) ) : P_ArgumentNode{} ,
max ? NewOwned< T_ArgumentNode >( *this , std::move( max ) ) : P_ArgumentNode{} };
return {};
}

View file

@ -804,8 +804,8 @@ class T_SamplerInstrNode : public A_ResourceDefInstrNode
struct T_LOD_
{
T_SRDLocation location;
P_ExpressionNode min;
P_ExpressionNode max;
P_ArgumentNode min;
P_ArgumentNode max;
};
T_Optional< T_Sampling_ > sampling_;
@ -847,9 +847,9 @@ class T_SamplerInstrNode : public A_ResourceDefInstrNode
{ return mipmaps_ ? mipmaps_->mode : T_Optional< E_TexSampling >{}; }
E_TexWrap wrapping( ) const noexcept
{ return wrapping_ ? wrapping_->mode : E_TexWrap::REPEAT; }
A_ExpressionNode* minLod( ) const noexcept
T_ArgumentNode* minLod( ) const noexcept
{ return lod_ ? lod_->min.get( ) : nullptr; }
A_ExpressionNode* maxLod( ) const noexcept
T_ArgumentNode* maxLod( ) const noexcept
{ return lod_ ? lod_->max.get( ) : nullptr; }
};

View file

@ -457,6 +457,25 @@ bool T_CompilerImpl_::compileNode(
}
break;
case A_Node::OP_SAMPLER:
if ( exit ) {
auto& sn( (T_SamplerInstrNode&) node );
if ( !sn.minLod( ) ) {
// XXX maybe use OP_RES_STACK
addInstruction( OP_CONST , 0 , node.location( ) );
addInstruction( OP_PUSH , node.location( ) );
addInstruction( OP_PUSH , node.location( ) );
}
processIdentifier( funcIndex , sn.id( ) , sn.idLocation( ) );
addInstruction( OP_INIT_SAMPLER , {
( uint32_t( sn.sampling( ) ) << 2 )
| ( ( sn.mipmap( ) ? 1 : 0 ) << 1 )
| ( sn.mipmap( ) ? uint32_t( *sn.mipmap( ) ) : 0 ) ,
uint32_t( sn.wrapping( ) )
} , node.location( ) );
}
break;
case A_Node::OP_TEXTURE:
if ( exit ) {
auto& tn( (T_TextureInstrNode&) node );
@ -498,6 +517,14 @@ bool T_CompilerImpl_::compileNode(
//- STATE -----------------------------------------------------------------------------
case A_Node::OP_MAINOUT:
if ( exit ) {
addInstruction( OP_CONST , 0 , node.location( ) );
addInstruction( OP_PUSH , node.location( ) );
addInstruction( OP_USE_FRAMEBUFFER , node.location( ) );
}
break;
case A_Node::OP_USE_FRAMEBUFFER:
if ( exit ) {
auto& fbn( (T_UseInstrNode&) node );

1
ops.cc
View file

@ -123,6 +123,7 @@ static T_KeyValueTable< E_OpType , T_OpInfo > OpInfoTable_{ ([]() {
infos.add( E_OpType::OP_INIT_PIPELINE , T_OpInfo{ "pipeline" , 1 , OpStackMain{ -1 } } );
infos.add( E_OpType::OP_INIT_PROGRAM , T_OpInfo{ "program" , 1 , OpStackMain{ -1 } } );
infos.add( E_OpType::OP_INIT_TEXTURE , T_OpInfo{ "texture" , 2 , OpStackMain{ -3 } } );
infos.add( E_OpType::OP_INIT_SAMPLER , T_OpInfo{ "sampler" , 2 , OpStackMain{ -3 } } );
infos.add( E_OpType::OP_FB_ATTACH , T_OpInfo{ "fb-attach" , 2 , OpStackMain{ -1 } } );
//
infos.add( E_OpType::OP_USE_FRAMEBUFFER , T_OpInfo{ "use-framebuffer" , 0 , OpStackMain{ -1 } } );