MCPcopy Create free account
hub / github.com/carbonengine/trinity / GatherOutputs

Function GatherOutputs

shadercompiler/EffectCompilerMetal.cpp:2449–2499  ·  view source on GitHub ↗

Given a function header, gathers all function outputs into a flat structure

Source from the content-addressed store, hash-verified

2447
2448// Given a function header, gathers all function outputs into a flat structure
2449void GatherOutputs( ASTNode* destStruct, std::vector<ASTNode*>& accessors, const std::vector<Symbol*>& params, ASTNode* header, ParserState& state )
2450{
2451 for( size_t i = 0; i < header->GetChildrenCount(); ++i )
2452 {
2453 auto arg = header->GetChild( i );
2454
2455 if( IsUniformInputArgument( arg ) || arg->GetSymbol()->addressSpace != AddressSpace::None )
2456 {
2457 continue;
2458 }
2459
2460 bool isIn = arg->GetToken() == 0 || arg->GetToken()->type == OP_IN;
2461 if( isIn )
2462 {
2463 continue;
2464 }
2465
2466 Symbol* symbol = arg->GetSymbol();
2467 if( symbol == nullptr )
2468 {
2469 continue;
2470 }
2471
2472 auto access = NewVarIdentifier( state, params[i] );
2473
2474 if( symbol->type.IsStruct() )
2475 {
2476 GatherFields( destStruct, accessors, access, symbol->type.symbol->definition, state );
2477 }
2478 else if( symbol->type.IsScalarOrVector() )
2479 {
2480 destStruct->AddChild( NewStructMember( state, symbol ) );
2481 accessors.push_back( access );
2482 }
2483 }
2484 if( header->GetType().IsStruct() || header->GetType().IsScalarOrVector() )
2485 {
2486 Symbol* symbol = header->GetSymbol();
2487 auto access = NewVarIdentifier( state, params.back() );
2488
2489 if( symbol->type.IsStruct() )
2490 {
2491 GatherFields( destStruct, accessors, access, symbol->type.symbol->definition, state );
2492 }
2493 else
2494 {
2495 destStruct->AddChild( NewStructMember( state, symbol ) );
2496 accessors.push_back( access );
2497 }
2498 }
2499}
2500
2501// Patches VPOS usages for pixel shaders: a common Dx9 legacy pattern of passing both POSITION (from
2502// vertex shader) and VPOS. Function remaps VPOS inputs to POSION so that there are no duplicate semantics

Callers 1

PatchShaderFunction · 0.85

Calls 12

IsUniformInputArgumentFunction · 0.85
NewVarIdentifierFunction · 0.85
GatherFieldsFunction · 0.85
NewStructMemberFunction · 0.85
GetChildrenCountMethod · 0.80
GetSymbolMethod · 0.80
GetTokenMethod · 0.80
IsStructMethod · 0.80
IsScalarOrVectorMethod · 0.80
AddChildMethod · 0.80
GetChildMethod · 0.45
GetTypeMethod · 0.45

Tested by

no test coverage detected