// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "IAssetCompilingManager.h" #include "NiagaraCompilationPrivate.h" #include "NiagaraCompilationTypes.h" #include "NiagaraSystem.h" struct FNiagaraSystemCompilationTask; class ITargetPlatform; class FNiagaraSystemCompilingManager : public IAssetCompilingManager { public: struct FCompileOptions { TArray> ParameterCollections; const ITargetPlatform* TargetPlatform = nullptr; EShaderPlatform PreviewShaderPlatform = EShaderPlatform::SP_NumPlatforms; ERHIFeatureLevel::Type PreviewFeatureLevel = ERHIFeatureLevel::Num; bool bForced = false; ENiagaraCompileRIParamMode RIParamMode = ENiagaraCompileRIParamMode::GameThread; }; static FNiagaraSystemCompilingManager& Get(); FNiagaraCompilationTaskHandle AddSystem(UNiagaraSystem* System, FCompileOptions CompileOptions); bool PollSystemCompile(FNiagaraCompilationTaskHandle TaskHandle, bool bPeek, bool bWait, FNiagaraSystemAsyncCompileResults& Results); void AbortSystemCompile(FNiagaraCompilationTaskHandle TaskHandle); void AdvanceAsyncTasks(); using FGameThreadFunction = TFunction; void QueueGameThreadFunction(FGameThreadFunction GameThreadTask); protected: // Begin - IAssetCompilingManager virtual FName GetAssetTypeName() const override; virtual FTextFormat GetAssetNameFormat() const override; virtual TArrayView GetDependentTypeNames() const override; virtual int32 GetNumRemainingAssets() const override; virtual void FinishCompilationForObjects(TArrayView InObjects) override; virtual void FinishAllCompilation() override; virtual void Shutdown() override; virtual void ProcessAsyncTasks(bool bLimitExecutionTime = false) override; // End - IAssetCompilingManager bool ConditionalLaunchTask(); void CheckStalledTask(double CurrentTime, FNiagaraSystemCompilationTask* Task) const; FNiagaraShaderType* NiagaraShaderType = nullptr; using FPlatformFeatureLevelPair = TPair; TMap> PlatformFeatureLevels; void FindOrAddFeatureLevels(const FCompileOptions& CompileOptions, TArray& FeatureLevels); using FTaskPtr = TSharedPtr; mutable FRWLock QueueLock; TMap SystemRequestMap; TArray ActiveTasks; TArray QueuedRequests; TArray RequestsAwaitingRetrieval; std::atomic NextTaskHandle = { 0 }; mutable FRWLock GameThreadFunctionLock; TArray GameThreadFunctions; int32 PeakReportedPendingTaskCount = 0; int32 PeakPendingTaskCount = 0; double LastTaskCountReportTime = 0; };