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

Method CompileEffect

shadercompiler/EffectCompilerMetal.cpp:4852–5450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4850}
4851
4852bool EffectCompilerMetal::CompileEffect( const char* source, size_t sourceLength, const std::vector<Macro>& defines, EffectData& result, IWorkQueue* workQueue )
4853{
4854 ZoneScoped;
4855
4856 ParserState state( MakeInlineString( source, source + sourceLength ) );
4857 for( auto& it : defines )
4858 {
4859 PreprocessorDefine d;
4860 d.location.fileName = MakeInlineString( "" );
4861 d.location.lineNumber = 0;
4862 d.value = MakeInlineString( it.value.c_str() );
4863 state.m_defines[MakeInlineString( it.name.c_str() )] = d;
4864 }
4865
4866 if( !state.Parse() )
4867 {
4868 return false;
4869 }
4870
4871 ASTNode* root = state.GetTree();
4872 if( root )
4873 {
4874 SortProgramNodes( root );
4875 }
4876
4877 PatchStdlibFunctions( state );
4878 // PatchCBuffers( state );
4879
4880 ReplaceFloatModulo( state );
4881
4882 std::map<Symbol*, ASTNode*> functions;
4883 std::vector<ASTNode*> globals;
4884
4885 TransferSRGBToTexturesDX11( state );
4886
4887 CollectFunctions( state, functions );
4888 CollectGlobals( state, functions, globals );
4889
4890 AddShaderTableArguments( state, functions );
4891
4892 ConvertTextureFunctionsToMetal( state );
4893 ConvertSyncFunctionsToMetal( functions );
4894
4895 AssignDeviceSpaceToSymbols( state.GetTree() );
4896
4897 if( !globals.empty() )
4898 {
4899 AddUsedGlobalsAsFunctionParams( functions, globals );
4900
4901 for( auto it : globals )
4902 {
4903 if( it->GetType().symbol ) // Not a built-in type?
4904 {
4905 StripSemanticsInsideStucts( it->GetType().symbol->definition );
4906 }
4907 }
4908 }
4909

Callers

nothing calls this directly

Calls 15

MakeInlineStringFunction · 0.85
SortProgramNodesFunction · 0.85
PatchStdlibFunctionsFunction · 0.85
ReplaceFloatModuloFunction · 0.85
CollectFunctionsFunction · 0.85
CollectGlobalsFunction · 0.85
AddShaderTableArgumentsFunction · 0.85

Tested by

no test coverage detected