Overrides - Support in program
There's still a bug with the subsections (either during parsing or at merge, but KID INTERRUPT!!!!)
This commit is contained in:
parent
12f580d384
commit
0796847b5e
9 changed files with 112 additions and 32 deletions
27
demo.cc
27
demo.cc
|
@ -97,29 +97,10 @@ bool T_Demo::runInit(
|
||||||
}
|
}
|
||||||
Globals::Sync( ).updateCurveCaches( );
|
Globals::Sync( ).updateCurveCaches( );
|
||||||
|
|
||||||
#warning silly test here
|
if ( context->installOverrides ) {
|
||||||
T_OwnPtr< sov::T_Float > ov{ NewOwned< sov::T_Float >(
|
Globals::Sync( ).mergeOverrides( *( context->installOverrides ) );
|
||||||
"dof-sharp-distance" , "Sharp distance" ) };
|
context->installOverrides.clear( );
|
||||||
ov->setMin( 0 );
|
}
|
||||||
ov->setMax( 1000 );
|
|
||||||
ov->setStep( .1 );
|
|
||||||
// ov->setSlider( true );
|
|
||||||
ov->setup( );
|
|
||||||
|
|
||||||
T_SyncOverrideSection sos( "" );
|
|
||||||
sos.subsections.add( NewOwned< T_SyncOverrideSection >( "Testing" ) );
|
|
||||||
sos.subsections[ 0 ]->subsections.add( NewOwned< T_SyncOverrideSection >( "Yeah really" ) );
|
|
||||||
sos.subsections[ 0 ]->subsections[ 0 ]->overrides.add( std::move( ov ) );
|
|
||||||
|
|
||||||
auto ov2{ NewOwned< sov::T_Float4 >(
|
|
||||||
"bloom-bw0" , "bloom-bw1" , "bloom-bw2" , "bloom-bw3" ,
|
|
||||||
"Blur weights" ) };
|
|
||||||
ov2->setMax( 1 );
|
|
||||||
ov2->setSlider( );
|
|
||||||
ov2->setup( );
|
|
||||||
sos.subsections[ 0 ]->overrides.add( std::move( ov2 ) );
|
|
||||||
|
|
||||||
Globals::Sync( ).mergeOverrides( sos );
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
3
opast.hh
3
opast.hh
|
@ -968,6 +968,9 @@ class T_OverridesInstrNode : public A_InstructionNode
|
||||||
|
|
||||||
T_SyncOverrideSection& root( ) const noexcept
|
T_SyncOverrideSection& root( ) const noexcept
|
||||||
{ return *overrides_; }
|
{ return *overrides_; }
|
||||||
|
|
||||||
|
T_OwnPtr< T_SyncOverrideSection > extractRoot( ) noexcept
|
||||||
|
{ return std::move( overrides_ ); }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Profiling instruction
|
// Profiling instruction
|
||||||
|
|
|
@ -667,6 +667,14 @@ bool T_CompilerImpl_::compileNode(
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case A_Node::OP_OVERRIDES:
|
||||||
|
if ( exit ) {
|
||||||
|
auto& n{ (T_OverridesInstrNode&) node };
|
||||||
|
const auto idx{ output->overrides.add( n.extractRoot( ) ) };
|
||||||
|
addInstruction( OP_UI_INPUT_OVR , idx , node.location( ) );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
//- EXPRESSIONS - ARGUMENTS -----------------------------------------------------------
|
//- EXPRESSIONS - ARGUMENTS -----------------------------------------------------------
|
||||||
|
|
||||||
|
|
23
opparser.cc
23
opparser.cc
|
@ -169,6 +169,7 @@ struct T_ParserImpl_
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
} };
|
} };
|
||||||
|
T_SyncOverrideVisitor ovVisitor;
|
||||||
|
|
||||||
T_ParserImpl_( T_Array< T_SRDError >* errors ,
|
T_ParserImpl_( T_Array< T_SRDError >* errors ,
|
||||||
T_OwnPtr< T_OpsParserOutput >* root ) noexcept;
|
T_OwnPtr< T_OpsParserOutput >* root ) noexcept;
|
||||||
|
@ -772,6 +773,28 @@ bool T_ParserImpl_::checkIdentifiers( ) noexcept
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case A_Node::OP_OVERRIDES:
|
||||||
|
{
|
||||||
|
auto& ov{ dynamic_cast< T_OverridesInstrNode& >( n ) };
|
||||||
|
ovVisitor.visitor.visit( &ov.root( ) ,
|
||||||
|
[&]( T_SyncOverrideVisitor::T_Element element , bool exit ) -> bool {
|
||||||
|
if ( exit || element.hasType< T_SyncOverrideSection* >( ) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& ovr( *element.value< A_SyncOverride* >( ) );
|
||||||
|
auto const& in( ovr.inputNames( ) );
|
||||||
|
const auto nin( in.size( ) );
|
||||||
|
for ( auto i = 0u ; i < nin ; i ++ ) {
|
||||||
|
checkIdentifier( in[ i ] , ovr.location( ) ,
|
||||||
|
cfi , E_DataType::INPUT );
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
9
ops.cc
9
ops.cc
|
@ -146,6 +146,7 @@ static T_KeyValueTable< E_OpType , T_OpInfo > OpInfoTable_{ ([]() {
|
||||||
infos.add( E_OpType::OP_UI_PENTER , T_OpInfo{ "ui-prof-enter" , 1 } );
|
infos.add( E_OpType::OP_UI_PENTER , T_OpInfo{ "ui-prof-enter" , 1 } );
|
||||||
infos.add( E_OpType::OP_UI_PEXIT , T_OpInfo{ "ui-prof-exit" } );
|
infos.add( E_OpType::OP_UI_PEXIT , T_OpInfo{ "ui-prof-exit" } );
|
||||||
infos.add( E_OpType::OP_UI_INPUT_DFT , T_OpInfo{ "ui-input-default" , 2 } );
|
infos.add( E_OpType::OP_UI_INPUT_DFT , T_OpInfo{ "ui-input-default" , 2 } );
|
||||||
|
infos.add( E_OpType::OP_UI_INPUT_OVR , T_OpInfo{ "ui-overrides" , 1 } );
|
||||||
infos.add( E_OpType::OP_UI_ODBG , T_OpInfo{ "ui-odbg" , 2 , OpStackMain{ -1 } } );
|
infos.add( E_OpType::OP_UI_ODBG , T_OpInfo{ "ui-odbg" , 2 , OpStackMain{ -1 } } );
|
||||||
|
|
||||||
return infos;
|
return infos;
|
||||||
|
@ -281,6 +282,7 @@ void T_OpContext::run(
|
||||||
|
|
||||||
stack.clear( );
|
stack.clear( );
|
||||||
stack.add( 0xffffffff );
|
stack.add( 0xffffffff );
|
||||||
|
installOverrides.clear( );
|
||||||
|
|
||||||
while ( !stack.empty( ) ) {
|
while ( !stack.empty( ) ) {
|
||||||
auto const& instr{ program.ops[ instrPtr ] };
|
auto const& instr{ program.ops[ instrPtr ] };
|
||||||
|
@ -884,6 +886,13 @@ void T_OpContext::run(
|
||||||
initialInputs[ instr.args[ 0 ] ] = values[ instr.args[ 1 ] ].f;
|
initialInputs[ instr.args[ 0 ] ] = values[ instr.args[ 1 ] ].f;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case OP_UI_INPUT_OVR:
|
||||||
|
if ( !installOverrides ) {
|
||||||
|
installOverrides = NewOwned< T_SyncOverrideSection >( "*" );
|
||||||
|
}
|
||||||
|
installOverrides->merge( *( program.overrides[ instr.args[ 0 ] ] ) );
|
||||||
|
break;
|
||||||
|
|
||||||
case OP_UI_ODBG:
|
case OP_UI_ODBG:
|
||||||
{
|
{
|
||||||
ensureStack( instr , 1 );
|
ensureStack( instr , 1 );
|
||||||
|
|
5
ops.hh
5
ops.hh
|
@ -73,6 +73,7 @@ enum E_OpType
|
||||||
OP_UI_PENTER ,
|
OP_UI_PENTER ,
|
||||||
OP_UI_PEXIT ,
|
OP_UI_PEXIT ,
|
||||||
OP_UI_INPUT_DFT ,
|
OP_UI_INPUT_DFT ,
|
||||||
|
OP_UI_INPUT_OVR ,
|
||||||
OP_UI_ODBG ,
|
OP_UI_ODBG ,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -142,6 +143,8 @@ struct T_OpProgram
|
||||||
T_Array< T_String > progNames; // GLSL program files
|
T_Array< T_String > progNames; // GLSL program files
|
||||||
|
|
||||||
T_Array< T_String > uiStrings; // UI strings for profiling, etc.
|
T_Array< T_String > uiStrings; // UI strings for profiling, etc.
|
||||||
|
T_Array< P_SyncOverrideSection > overrides;
|
||||||
|
// Override definitions for the UI
|
||||||
};
|
};
|
||||||
using P_OpProgram = T_OwnPtr< T_OpProgram >;
|
using P_OpProgram = T_OwnPtr< T_OpProgram >;
|
||||||
|
|
||||||
|
@ -161,6 +164,8 @@ struct T_OpContext
|
||||||
double x87stack[ 8 ]; // x87 FPU emulation stack
|
double x87stack[ 8 ]; // x87 FPU emulation stack
|
||||||
uint32_t x87sp; // x87 FPU emulation stack pointer
|
uint32_t x87sp; // x87 FPU emulation stack pointer
|
||||||
|
|
||||||
|
P_SyncOverrideSection installOverrides; // Install UI overrides
|
||||||
|
|
||||||
// Allocated resources
|
// Allocated resources
|
||||||
T_Array< T_OwnPtr< T_Rendertarget > > framebuffers;
|
T_Array< T_OwnPtr< T_Rendertarget > > framebuffers;
|
||||||
T_Array< T_OwnPtr< T_ShaderProgram > > programs;
|
T_Array< T_OwnPtr< T_ShaderProgram > > programs;
|
||||||
|
|
34
sync.cc
34
sync.cc
|
@ -481,6 +481,28 @@ T_SyncOverrideSection const* T_SyncOverrideSection::section(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*= T_SyncOverrideVisitor ====================================================*/
|
||||||
|
|
||||||
|
T_SyncOverrideVisitor::T_OpElement T_SyncOverrideVisitor::nodeBrowser(
|
||||||
|
const T_Element element ,
|
||||||
|
const uint32_t child )
|
||||||
|
{
|
||||||
|
if ( element.hasType< A_SyncOverride* >( ) ) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& section( *element.value< T_SyncOverrideSection* >( ) );
|
||||||
|
const auto nss( section.subsections.size( ) );
|
||||||
|
if ( child < nss ) {
|
||||||
|
return T_OpElement{ section.subsections[ child ].get( ) };
|
||||||
|
}
|
||||||
|
if ( child - nss < section.overrides.size( ) ) {
|
||||||
|
return T_OpElement{ section.overrides[ child - nss ].get( ) };
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*= T_SyncManager ============================================================*/
|
/*= T_SyncManager ============================================================*/
|
||||||
|
|
||||||
T_SyncManager::T_SyncManager( )
|
T_SyncManager::T_SyncManager( )
|
||||||
|
@ -635,6 +657,18 @@ void T_SyncManager::mergeOverrides(
|
||||||
{
|
{
|
||||||
assert( overrides.overrides.empty( ) );
|
assert( overrides.overrides.empty( ) );
|
||||||
soRoot_.merge( overrides );
|
soRoot_.merge( overrides );
|
||||||
|
|
||||||
|
T_SyncOverrideVisitor v;
|
||||||
|
v.visitor.visit( &soRoot_ ,
|
||||||
|
[]( T_SyncOverrideVisitor::T_Element node , bool exit ) -> bool {
|
||||||
|
if ( exit || node.hasType< T_SyncOverrideSection* >( ) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
auto& ovr( *node.value< A_SyncOverride* >( ) );
|
||||||
|
ovr.setup( );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void T_SyncManager::makeOverridesWindow( )
|
void T_SyncManager::makeOverridesWindow( )
|
||||||
|
|
16
sync.hh
16
sync.hh
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include <ebcl/SRDParserConfig.hh>
|
#include <ebcl/SRDParserConfig.hh>
|
||||||
#include <ebcl/Sets.hh>
|
#include <ebcl/Sets.hh>
|
||||||
|
#include <ebcl/Algorithms.hh>
|
||||||
|
|
||||||
|
|
||||||
// Duration and current playing time
|
// Duration and current playing time
|
||||||
|
@ -235,6 +236,21 @@ struct T_SyncOverrideSection
|
||||||
T_String const& name ) const noexcept;
|
T_String const& name ) const noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
struct T_SyncOverrideVisitor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using T_Element = ebcl::T_Union<
|
||||||
|
T_SyncOverrideSection* ,
|
||||||
|
A_SyncOverride* >;
|
||||||
|
using T_OpElement = T_Optional< T_Element >;
|
||||||
|
|
||||||
|
static T_OpElement nodeBrowser( T_Element element , uint32_t child );
|
||||||
|
|
||||||
|
ebcl::T_Visitor< T_Element , T_Element > visitor{ nodeBrowser };
|
||||||
|
};
|
||||||
|
|
||||||
/*============================================================================*/
|
/*============================================================================*/
|
||||||
|
|
||||||
// Synchronisation manager; handles all the synchronization data and makes it
|
// Synchronisation manager; handles all the synchronization data and makes it
|
||||||
|
|
|
@ -48,8 +48,8 @@ using SP_Float = T_SharedPtr< A_Float >;
|
||||||
bool EnterFloat1_( T_SRDParserData const& data )
|
bool EnterFloat1_( T_SRDParserData const& data )
|
||||||
{
|
{
|
||||||
auto const& input( *( data.input ) );
|
auto const& input( *( data.input ) );
|
||||||
SP_Float ptr{ NewShared< T_Float >(
|
SP_Float ptr{ NewShared< T_Float >( input[ 2 ].stringValue( ) ,
|
||||||
input[ 1 ].stringValue( ) , input[ 2 ].stringValue( ) ) };
|
input[ 1 ].stringValue( ) ) };
|
||||||
ptr->location( ) = input[ 0 ].location( );
|
ptr->location( ) = input[ 0 ].location( );
|
||||||
*( data.targetData ) = std::move( ptr );
|
*( data.targetData ) = std::move( ptr );
|
||||||
return true;
|
return true;
|
||||||
|
@ -59,8 +59,8 @@ bool EnterFloat2_( T_SRDParserData const& data )
|
||||||
{
|
{
|
||||||
auto const& input( *( data.input ) );
|
auto const& input( *( data.input ) );
|
||||||
SP_Float ptr{ NewShared< T_Float2 >(
|
SP_Float ptr{ NewShared< T_Float2 >(
|
||||||
input[ 1 ].stringValue( ) , input[ 2 ].stringValue( ) ,
|
input[ 2 ].stringValue( ) , input[ 3 ].stringValue( ) ,
|
||||||
input[ 3 ].stringValue( ) ) };
|
input[ 1 ].stringValue( ) ) };
|
||||||
ptr->location( ) = input[ 0 ].location( );
|
ptr->location( ) = input[ 0 ].location( );
|
||||||
*( data.targetData ) = std::move( ptr );
|
*( data.targetData ) = std::move( ptr );
|
||||||
return true;
|
return true;
|
||||||
|
@ -70,8 +70,9 @@ bool EnterFloat3_( T_SRDParserData const& data )
|
||||||
{
|
{
|
||||||
auto const& input( *( data.input ) );
|
auto const& input( *( data.input ) );
|
||||||
SP_Float ptr{ NewShared< T_Float3 >(
|
SP_Float ptr{ NewShared< T_Float3 >(
|
||||||
input[ 1 ].stringValue( ) , input[ 2 ].stringValue( ) ,
|
input[ 2 ].stringValue( ) , input[ 3 ].stringValue( ) ,
|
||||||
input[ 3 ].stringValue( ) , input[ 4 ].stringValue( ) ) };
|
input[ 4 ].stringValue( ) ,
|
||||||
|
input[ 1 ].stringValue( ) ) };
|
||||||
ptr->location( ) = input[ 0 ].location( );
|
ptr->location( ) = input[ 0 ].location( );
|
||||||
*( data.targetData ) = std::move( ptr );
|
*( data.targetData ) = std::move( ptr );
|
||||||
return true;
|
return true;
|
||||||
|
@ -81,9 +82,9 @@ bool EnterFloat4_( T_SRDParserData const& data )
|
||||||
{
|
{
|
||||||
auto const& input( *( data.input ) );
|
auto const& input( *( data.input ) );
|
||||||
SP_Float ptr{ NewShared< T_Float4 >(
|
SP_Float ptr{ NewShared< T_Float4 >(
|
||||||
input[ 1 ].stringValue( ) , input[ 2 ].stringValue( ) ,
|
input[ 2 ].stringValue( ) , input[ 3 ].stringValue( ) ,
|
||||||
input[ 3 ].stringValue( ) , input[ 4 ].stringValue( ) ,
|
input[ 4 ].stringValue( ) , input[ 5 ].stringValue( ) ,
|
||||||
input[ 5 ].stringValue( ) ) };
|
input[ 1 ].stringValue( ) ) };
|
||||||
ptr->location( ) = input[ 0 ].location( );
|
ptr->location( ) = input[ 0 ].location( );
|
||||||
*( data.targetData ) = std::move( ptr );
|
*( data.targetData ) = std::move( ptr );
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue