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

Function main

shadercompiler/ShaderCompiler.cpp:585–889  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

583int _tmain( int argc, _TCHAR* argv[] )
584#else
585int main( int argc, char* argv[] )
586#endif
587{
588
589#if _WIN32
590 InitializeCriticalSection( &s_exceptionMutex );
591 SetUnhandledExceptionFilter( &ReportException );
592
593 char metalToolsPath[MAX_PATH] = { 0 };
594 size_t metalToolsPathSize;
595 if( getenv_s( &metalToolsPathSize, metalToolsPath, "METAL_TOOLS_PATH" ) == 0 )
596 {
597 g_metalToolsPath = metalToolsPath;
598 }
599#else
600 if( auto metalToolsPath = getenv( "METAL_TOOLS_PATH" ) )
601 {
602 g_metalToolsPath = metalToolsPath;
603 }
604#endif
605
606
607 ProgramArguments args;
608 if( !ExtractCommandLineArguments( args, argc, argv ) )
609 {
610 PrintUsage();
611 return 1;
612 }
613
614 WithTelemetry withTelemetry( args.telemetry );
615
616 if( args.checkMTime )
617 {
618 PrintOutOfDateFiles( args.coreCount );
619 return 0;
620 }
621 if( args.printPermutations )
622 {
623 return PrintPermutations( args.shaderPath ) ? 0 : 1;
624 }
625
626 // Preload shader file
627 auto shader = g_includeHandler.Open( args.shaderPath );
628 if( !shader )
629 {
630 printf( "%s: error X0000: Could not open input file \"%s\"\n", args.shaderPath, args.shaderPath );
631 return 1;
632 }
633 g_shaderSource = shader->data;
634 g_shaderLength = shader->size;
635
636 g_includeHandler.SetRootPath( args.shaderPath );
637 g_messages.SetEntryFileName( args.shaderPath );
638
639 const int32_t coreFactor = 4;
640
641 CompileQueue compileQueue( args.coreCount * coreFactor, args.coreCount, &CompileShader );
642

Callers

nothing calls this directly

Calls 15

PrintUsageFunction · 0.85
PrintOutOfDateFilesFunction · 0.85
PrintPermutationsFunction · 0.85
DiscoverPermutationsFunction · 0.85
fopen_sFunction · 0.85
GetSourceHashFunction · 0.85
OpenMethod · 0.80
SetRootPathMethod · 0.80
SetEntryFileNameMethod · 0.80
AddPrefixMethod · 0.80

Tested by

no test coverage detected