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

Function PrepareFragmentFunction

shadercompiler/EffectCompilerMetal.cpp:1630–1699  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1628}
1629
1630void PrepareFragmentFunction( StageInput&, ASTNode* callNode )
1631{
1632 Symbol* entryPointSymbol = callNode->GetSymbol();
1633 if( !entryPointSymbol || !entryPointSymbol->definition )
1634 {
1635 return;
1636 }
1637
1638 ASTNode* header = entryPointSymbol->definition->GetChildOrNull( 0 );
1639 if( !header )
1640 {
1641 return;
1642 }
1643 assert( header->GetNodeType() == NT_FUNCTION_HEADER );
1644
1645 for( size_t i = 0, n = header->GetChildrenCount(); i < n; ++i )
1646 {
1647 ASTNode* param = header->GetChild( i );
1648 Symbol* symbol = param->GetSymbol();
1649 const Symbol* typeSymbol = symbol->type.symbol;
1650
1651 if( typeSymbol )
1652 {
1653 // This funciton parameter is of struct type. Check if this struct has declarations
1654 // with input semantics.
1655 bool hasInputs = RemapFragmentInputSemanticsDXToMetal( typeSymbol->definition );
1656
1657 if( hasInputs )
1658 {
1659 // [[stage_in]]
1660 RegisterSpecifier reg;
1661 reg.shaderProfile.start = nullptr;
1662 reg.shaderProfile.end = nullptr;
1663 reg.registerType = MetalRegister::StageIn;
1664 reg.registerNumber = -1;
1665 reg.subComponent = -1;
1666 reg.space = -1;
1667 reg.explicitRegister = true;
1668 reg.explicitSpace = false;
1669 symbol->registerSpecifier[reg.shaderProfile] = reg;
1670 }
1671 else
1672 {
1673 // Inherit register specifier from the type.
1674 symbol->registerSpecifier = typeSymbol->registerSpecifier;
1675 }
1676 }
1677 else if( symbol->type.builtInType )
1678 {
1679 if( param->GetToken() && param->GetToken()->type == OP_OUT )
1680 {
1681 RemapFragmentOutputSemanticsDXToMetal( symbol );
1682 }
1683 else
1684 {
1685 RemapFragmentInputSemanticsDXToMetal( symbol );
1686 }
1687 }

Callers 1

CompileEffectMethod · 0.85

Calls 9

GetSymbolMethod · 0.80
GetChildOrNullMethod · 0.80
GetNodeTypeMethod · 0.80
GetChildrenCountMethod · 0.80
GetTokenMethod · 0.80
GetChildMethod · 0.45
GetTypeMethod · 0.45

Tested by

no test coverage detected