void Loop() { UE_LOG(LogShaders, Log, TEXT("Entering job loop")); while(true) { TArray<FJobResult> JobResults; // Read & Process Input { FArchive* InputFilePtr = OpenInputFile(); if(!InputFilePtr) { break; } UE_LOG(LogShaders, Log, TEXT("Processing shader")); LastCompileTime = FPlatformTime::Seconds(); ProcessInputFromArchive(InputFilePtr, JobResults); // Close the input file. delete InputFilePtr; } // Prepare for output FArchive* OutputFilePtr = CreateOutputArchive(); check(OutputFilePtr); WriteToOutputArchive(OutputFilePtr, JobResults); // Close the output file. delete OutputFilePtr; // Change the output file name to requested one IFileManager::Get().Move(*OutputFilePath, *TempFilePath); if (GShaderCompileUseXGE) { // To signal compilation completion, create a zero length file in the working directory. WriteXGESuccessFile(*WorkingDirectory); // We only do one pass per process when using XGE. break; } } UE_LOG(LogShaders, Log, TEXT("Exiting job loop")); }
int32 GuardedMainWrapper(int32 ArgC, TCHAR* ArgV[], const TCHAR* CrashOutputFile) { // We need to know whether we are using XGE now, in case an exception // is thrown before we parse the command line inside GuardedMain. GShaderCompileUseXGE = (ArgC > 6) && FCString::Strcmp(ArgV[6], TEXT("-xge")) == 0; int32 ReturnCode = 0; #if PLATFORM_WINDOWS if (FPlatformMisc::IsDebuggerPresent()) #endif { ReturnCode = GuardedMain(ArgC, ArgV); } #if PLATFORM_WINDOWS else { // Don't want 32 dialogs popping up when SCW fails GUseCrashReportClient = false; __try { GIsGuarded = 1; ReturnCode = GuardedMain(ArgC, ArgV); GIsGuarded = 0; } __except( ReportCrash( GetExceptionInformation() ) ) { FArchive& OutputFile = *IFileManager::Get().CreateFileWriter(CrashOutputFile,FILEWRITE_NoFail); int32 OutputVersion = ShaderCompileWorkerOutputVersion; OutputFile << OutputVersion; int32 ErrorCode = GFailedDueToShaderFormatVersion ? 2 : 1; OutputFile << ErrorCode; // Note: Can't use FStrings here as SEH can't be used with destructors int32 CallstackLength = FCString::Strlen(GErrorHist); OutputFile << CallstackLength; int32 ExceptionInfoLength = FCString::Strlen(GErrorExceptionDescription); OutputFile << ExceptionInfoLength; OutputFile.Serialize(GErrorHist, CallstackLength * sizeof(TCHAR)); OutputFile.Serialize(GErrorExceptionDescription, ExceptionInfoLength * sizeof(TCHAR)); int32 NumBatches = 0; OutputFile << NumBatches; // Close the output file. delete &OutputFile; if (GShaderCompileUseXGE) { ReturnCode = 1; WriteXGESuccessFile(ArgV[1]); } } } #endif FEngineLoop::AppPreExit(); FEngineLoop::AppExit(); return ReturnCode; }
void Loop() { UE_LOG(LogShaders, Log, TEXT("Entering job loop")); while(true) { TArray<FJobResult> JobResults; // Read & Process Input { FArchive* InputFilePtr = OpenInputFile(); if(!InputFilePtr) { break; } UE_LOG(LogShaders, Log, TEXT("Processing shader")); LastCompileTime = FPlatformTime::Seconds(); ProcessInputFromArchive(InputFilePtr, JobResults); // Close the input file. delete InputFilePtr; } // Prepare for output FArchive* OutputFilePtr = CreateOutputArchive(); check(OutputFilePtr); WriteToOutputArchive(OutputFilePtr, JobResults); // Close the output file. delete OutputFilePtr; #if PLATFORM_MAC || PLATFORM_LINUX // Change the output file name to requested one IFileManager::Get().Move(*OutputFilePath, *TempFilePath); #endif #if PLATFORM_SUPPORTS_NAMED_PIPES if (CommunicationMode == ThroughNamedPipeOnce || CommunicationMode == ThroughNamedPipe) { VerifyResult(Pipe.WriteInt32(TransferBufferOut.Num()), TEXT("Writing Transfer Size")); VerifyResult(Pipe.WriteBytes(TransferBufferOut.Num(), TransferBufferOut.GetData()), TEXT("Writing Transfer Buffer")); //FPlatformMisc::LowLevelOutputDebugStringf(TEXT("*** Closing pipe...\n")); Pipe.Destroy(); if (CommunicationMode == ThroughNamedPipeOnce) { // Give up CPU time while we are waiting FPlatformProcess::Sleep(0.02f); break; } LastConnectionTime = FPlatformTime::Seconds(); } #endif // PLATFORM_SUPPORTS_NAMED_PIPES if (GShaderCompileUseXGE) { // To signal compilation completion, create a zero length file in the working directory. WriteXGESuccessFile(*WorkingDirectory); // We only do one pass per process when using XGE. break; } } UE_LOG(LogShaders, Log, TEXT("Exiting job loop")); }