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

Function PatchRtShader

shadercompiler/EffectCompilerMetal.cpp:3078–3367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3076}
3077
3078ASTNode* PatchRtShader( RtShaderType shaderType, ASTNode* callNode, ParserState& state, std::vector<Symbol*>& rtConstantBuffers, const std::vector<GlobalInputElement>& globalInput, ASTNode* globalInputsStruct )
3079{
3080 ZoneScoped;
3081
3082 Symbol* entryPointSymbol = callNode->GetSymbol();
3083 if( !entryPointSymbol || !entryPointSymbol->definition )
3084 {
3085 return nullptr;
3086 }
3087
3088 ASTNode* functionHeader = entryPointSymbol->definition->GetChildOrNull( 0 );
3089 if( !functionHeader )
3090 {
3091 return nullptr;
3092 }
3093
3094 ApplyPackedModifiersToConstantBuffers( entryPointSymbol->definition );
3095
3096 ScannerToken shaderName = ScannerToken::ID( callNode->GetSymbol()->name );
3097
3098 state.GetCurrentLocation().fileName = shaderName.stringValue;
3099 state.GetCurrentLocation().lineNumber = 1;
3100
3101 auto header = state.NewNode( NT_FUNCTION_HEADER, shaderName );
3102 auto shaderSymbol = state.GetSymbolTable().AddSymbol( shaderName.stringValue, ALLOW_OVERRIDES );
3103 shaderSymbol->isFunction = true;
3104 header->SetSymbol( shaderSymbol );
3105
3106 state.GetSymbolTable().EnterScope();
3107
3108 auto shaderBody = state.NewNode( NT_BLOCK );
3109
3110 ASTNode* payloadArg = nullptr;
3111 ASTNode* attributeArg = nullptr;
3112
3113 auto sourceArguments = ClassifyRtShaderArguments( functionHeader );
3114 if( sourceArguments.payloadArg )
3115 {
3116 payloadArg = NewFunctionParameter( state, sourceArguments.payloadArg->GetType(), state.AllocateName( sourceArguments.payloadArg->GetSymbol()->name ) );
3117 payloadArg->SetToken( ScannerToken::FromTokenType( OP_INOUT ) );
3118 header->AddChild( payloadArg );
3119 }
3120 if( sourceArguments.attributeArg )
3121 {
3122 attributeArg = NewFunctionParameter( state, sourceArguments.attributeArg->GetType(), state.AllocateName( sourceArguments.attributeArg->GetSymbol()->name ) );
3123 header->AddChild( attributeArg );
3124 }
3125
3126 ASTNode* localInputArg = nullptr;
3127 {
3128 auto t = state.GetSymbolTable().AddTypeSymbol( MakeInlineString( "device __RtLocalMaterial*" ) );
3129 localInputArg = NewFunctionParameter( state, TypeFromSymbol( t ), "__rtMaterials", RegisterSpecifier::Register( MetalRegister::SRV, 0 ) );
3130 header->AddChild( localInputArg );
3131 }
3132
3133 ASTNode* globalInputArg = nullptr;
3134 {
3135 globalInputArg = NewFunctionParameter( state, TypeFromSymbol( globalInputsStruct->GetSymbol() ), "__rtGlobals", RegisterSpecifier::Register( MetalRegister::SRV, 1 ) );

Callers 1

CompileEffectMethod · 0.85

Calls 15

NewFunctionParameterFunction · 0.85
MakeInlineStringFunction · 0.85
TypeFromSymbolFunction · 0.85
MetalSystemSemanticsFunction · 0.85
NewDotFunction · 0.85
NewVarIdentifierFunction · 0.85
NewLiteralConstFunction · 0.85
NewCastExpressionFunction · 0.85
NewVarDeclarationFunction · 0.85

Tested by

no test coverage detected