void FAppEventManager::ResumeRendering() { if( GUseThreadedRendering ) { if (!GIsThreadedRendering) { StartRenderingThread(); } } else { RHIAcquireThreadOwnership(); } }
void Graphics_Imp::StartRenderingThreadFunc(void* self) { auto self_ = (Graphics_Imp*) self; self_->StartRenderingThread(); }
/** * Perform an editor build with behavior dependent upon the specified id * * @param Id Action Id specifying what kind of build is requested * * @return true if the build completed successfully; false if it did not (or was manually canceled) */ bool FEditorBuildUtils::EditorBuild( UWorld* InWorld, EBuildOptions::Type Id, const bool bAllowLightingDialog ) { FMessageLog("MapCheck").NewPage(LOCTEXT("MapCheckNewPage", "Map Check")); // Make sure to set this flag to false before ALL builds. GEditor->SetMapBuildCancelled( false ); // Will be set to false if, for some reason, the build does not happen. bool bDoBuild = true; // Indicates whether the persistent level should be dirtied at the end of a build. bool bDirtyPersistentLevel = true; // Stop rendering thread so we're not wasting CPU cycles. StopRenderingThread(); // Hack: These don't initialize properly and if you pick BuildAll right off the // bat when opening a map you will get incorrect values in them. GSwarmDebugOptions.Touch(); // Show option dialog first, before showing the DlgBuildProgress window. FLightingBuildOptions LightingBuildOptions; if ( Id == EBuildOptions::BuildLighting ) { // Retrieve settings from ini. GConfig->GetBool( TEXT("LightingBuildOptions"), TEXT("OnlyBuildSelected"), LightingBuildOptions.bOnlyBuildSelected, GEditorUserSettingsIni ); GConfig->GetBool( TEXT("LightingBuildOptions"), TEXT("OnlyBuildCurrentLevel"), LightingBuildOptions.bOnlyBuildCurrentLevel, GEditorUserSettingsIni ); GConfig->GetBool( TEXT("LightingBuildOptions"), TEXT("OnlyBuildSelectedLevels"),LightingBuildOptions.bOnlyBuildSelectedLevels, GEditorUserSettingsIni ); GConfig->GetBool( TEXT("LightingBuildOptions"), TEXT("OnlyBuildVisibility"), LightingBuildOptions.bOnlyBuildVisibility, GEditorUserSettingsIni ); GConfig->GetBool( TEXT("LightingBuildOptions"), TEXT("UseErrorColoring"), LightingBuildOptions.bUseErrorColoring, GEditorUserSettingsIni ); GConfig->GetBool( TEXT("LightingBuildOptions"), TEXT("ShowLightingBuildInfo"), LightingBuildOptions.bShowLightingBuildInfo, GEditorUserSettingsIni ); int32 QualityLevel; GConfig->GetInt( TEXT("LightingBuildOptions"), TEXT("QualityLevel"), QualityLevel, GEditorUserSettingsIni ); QualityLevel = FMath::Clamp<int32>(QualityLevel, Quality_Preview, Quality_Production); LightingBuildOptions.QualityLevel = (ELightingBuildQuality)QualityLevel; } // Show the build progress dialog. SBuildProgressWidget::EBuildType BuildType = SBuildProgressWidget::BUILDTYPE_Geometry; switch (Id) { case EBuildOptions::BuildGeometry: case EBuildOptions::BuildVisibleGeometry: case EBuildOptions::BuildAll: case EBuildOptions::BuildAllOnlySelectedPaths: BuildType = SBuildProgressWidget::BUILDTYPE_Geometry; break; case EBuildOptions::BuildLighting: BuildType = SBuildProgressWidget::BUILDTYPE_Lighting; break; case EBuildOptions::BuildAIPaths: case EBuildOptions::BuildSelectedAIPaths: BuildType = SBuildProgressWidget::BUILDTYPE_Paths; break; case EBuildOptions::BuildHierarchicalLOD: BuildType = SBuildProgressWidget::BUILDTYPE_LODs; break; default: BuildType = SBuildProgressWidget::BUILDTYPE_Unknown; break; } TWeakPtr<class SBuildProgressWidget> BuildProgressWidget = GWarn->ShowBuildProgressWindow(); BuildProgressWidget.Pin()->SetBuildType(BuildType); bool bShouldMapCheck = true; switch( Id ) { case EBuildOptions::BuildGeometry: { // We can't set the busy cursor for all windows, because lighting // needs a cursor for the lighting options dialog. const FScopedBusyCursor BusyCursor; GUnrealEd->Exec( InWorld, TEXT("MAP REBUILD") ); TriggerNavigationBuilder(InWorld, Id); // No need to dirty the persient level if we're building BSP for a sub-level. bDirtyPersistentLevel = false; break; } case EBuildOptions::BuildVisibleGeometry: { // If any levels are hidden, prompt the user about how to proceed bDoBuild = GEditor->WarnAboutHiddenLevels( InWorld, true ); if ( bDoBuild ) { // We can't set the busy cursor for all windows, because lighting // needs a cursor for the lighting options dialog. const FScopedBusyCursor BusyCursor; GUnrealEd->Exec( InWorld, TEXT("MAP REBUILD ALLVISIBLE") ); TriggerNavigationBuilder(InWorld, Id); } break; } case EBuildOptions::BuildLighting: { if( bDoBuild ) { // We can't set the busy cursor for all windows, because lighting // needs a cursor for the lighting options dialog. const FScopedBusyCursor BusyCursor; GUnrealEd->BuildLighting( LightingBuildOptions ); bShouldMapCheck = false; } break; } case EBuildOptions::BuildAIPaths: { bDoBuild = GEditor->WarnAboutHiddenLevels( InWorld, false ); if ( bDoBuild ) { GEditor->ResetTransaction( NSLOCTEXT("UnrealEd", "RebuildNavigation", "Rebuilding Navigation") ); // We can't set the busy cursor for all windows, because lighting // needs a cursor for the lighting options dialog. const FScopedBusyCursor BusyCursor; TriggerNavigationBuilder(InWorld, Id); } break; } case EBuildOptions::BuildHierarchicalLOD: { bDoBuild = GEditor->WarnAboutHiddenLevels( InWorld, false ); if ( bDoBuild ) { GEditor->ResetTransaction( NSLOCTEXT("UnrealEd", "RebuildLOD", "Rebuilding HierarchicalLOD") ); // We can't set the busy cursor for all windows, because lighting // needs a cursor for the lighting options dialog. const FScopedBusyCursor BusyCursor; TriggerHierarchicalLODBuilder(InWorld, Id); } break; } case EBuildOptions::BuildAll: case EBuildOptions::BuildAllSubmit: { bDoBuild = GEditor->WarnAboutHiddenLevels( InWorld, true ); bool bLightingAlreadyRunning = GUnrealEd->WarnIfLightingBuildIsCurrentlyRunning(); if ( bDoBuild && !bLightingAlreadyRunning ) { // We can't set the busy cursor for all windows, because lighting // needs a cursor for the lighting options dialog. const FScopedBusyCursor BusyCursor; GUnrealEd->Exec( InWorld, TEXT("MAP REBUILD ALLVISIBLE") ); // disable this in build all path, it's very slow, it can be painful // they don't have any collision, but make sure it's added first before doing anything { BuildProgressWidget.Pin()->SetBuildType(SBuildProgressWidget::BUILDTYPE_LODs); TriggerHierarchicalLODBuilder(InWorld, Id); } { BuildProgressWidget.Pin()->SetBuildType(SBuildProgressWidget::BUILDTYPE_Paths); TriggerNavigationBuilder(InWorld, Id); } //Do a canceled check before moving on to the next step of the build. if( GEditor->GetMapBuildCancelled() ) { break; } else { BuildProgressWidget.Pin()->SetBuildType(SBuildProgressWidget::BUILDTYPE_Lighting); FLightingBuildOptions LightingOptions; int32 QualityLevel; // Force automated builds to always use production lighting if ( Id == EBuildOptions::BuildAllSubmit ) { QualityLevel = Quality_Production; } else { GConfig->GetInt( TEXT("LightingBuildOptions"), TEXT("QualityLevel"), QualityLevel, GEditorUserSettingsIni); QualityLevel = FMath::Clamp<int32>(QualityLevel, Quality_Preview, Quality_Production); } LightingOptions.QualityLevel = (ELightingBuildQuality)QualityLevel; GUnrealEd->BuildLighting(LightingOptions); bShouldMapCheck = false; } } break; } default: UE_LOG(LogEditorBuildUtils, Warning, TEXT("Invalid build Id")); break; } // Check map for errors (only if build operation happened) if ( bShouldMapCheck && bDoBuild && !GEditor->GetMapBuildCancelled() ) { GUnrealEd->Exec( InWorld, TEXT("MAP CHECK DONTDISPLAYDIALOG") ); } // Re-start the rendering thread after build operations completed. if (GUseThreadedRendering) { StartRenderingThread(); } if ( bDoBuild && InWorld->Scene ) { // Invalidating lighting marked various components as needing a re-register // Propagate the re-registers before rendering the scene to get the latest state InWorld->SendAllEndOfFrameUpdates(); } if ( bDoBuild ) { // Display elapsed build time. UE_LOG(LogEditorBuildUtils, Log, TEXT("Build time %s"), *BuildProgressWidget.Pin()->BuildElapsedTimeText().ToString() ); } // Build completed, hide the build progress dialog. // NOTE: It's important to turn off modalness before hiding the window, otherwise a background // application may unexpectedly be promoted to the foreground, obscuring the editor. GWarn->CloseBuildProgressWindow(); GUnrealEd->RedrawLevelEditingViewports(); if ( bDoBuild ) { if ( bDirtyPersistentLevel ) { InWorld->MarkPackageDirty(); } ULevel::LevelDirtiedEvent.Broadcast(); } // Don't show map check if we cancelled build because it may have some bogus data const bool bBuildCompleted = bDoBuild && !GEditor->GetMapBuildCancelled(); if( bBuildCompleted ) { if (bShouldMapCheck) { FMessageLog("MapCheck").Open( EMessageSeverity::Warning ); } FMessageLog("LightingResults").Notify(LOCTEXT("LightingErrorsNotification", "There were lighting errors."), EMessageSeverity::Error); } return bBuildCompleted; }