diff --git a/HotPatcher/Source/HotPatcherCore/Classes/Commandlets/Cooker/HotSingleCookerCommandlet.cpp b/HotPatcher/Source/HotPatcherCore/Classes/Commandlets/Cooker/HotSingleCookerCommandlet.cpp index 0975fdca..c02be636 100644 --- a/HotPatcher/Source/HotPatcherCore/Classes/Commandlets/Cooker/HotSingleCookerCommandlet.cpp +++ b/HotPatcher/Source/HotPatcherCore/Classes/Commandlets/Cooker/HotSingleCookerCommandlet.cpp @@ -40,13 +40,13 @@ int32 UHotSingleCookerCommandlet::Main(const FString& Params) THotPatcherTemplateHelper::TSerializeStructAsJsonString(*ExportSingleCookerSetting,FinalConfig); } - if(IsRunningCommandlet() && ExportSingleCookerSetting->bPackageTracker && ExportSingleCookerSetting->bCookPackageTrackerAssets) - { - SCOPED_NAMED_EVENT_TEXT("SearchAllAssets",FColor::Red); - // load asset registry - FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked(TEXT("AssetRegistry")); - AssetRegistryModule.Get().SearchAllAssets(true); - } + // if(IsRunningCommandlet() && ExportSingleCookerSetting->bPackageTracker && ExportSingleCookerSetting->bCookPackageTrackerAssets) + // { + // SCOPED_NAMED_EVENT_TEXT("SearchAllAssets",FColor::Red); + // // load asset registry + // FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked(TEXT("AssetRegistry")); + // AssetRegistryModule.Get().SearchAllAssets(true); + // } UE_LOG(LogHotSingleCookerCommandlet, Display, TEXT("Cooker %s Id %d,Assets Num %d"), *ExportSingleCookerSetting->MissionName,ExportSingleCookerSetting->MissionID,ExportSingleCookerSetting->CookAssets.Num()); diff --git a/HotPatcher/Source/HotPatcherCore/Private/Cooker/MultiCooker/FlibHotCookerHelper.cpp b/HotPatcher/Source/HotPatcherCore/Private/Cooker/MultiCooker/FlibHotCookerHelper.cpp index 168e01fe..6132e8fb 100644 --- a/HotPatcher/Source/HotPatcherCore/Private/Cooker/MultiCooker/FlibHotCookerHelper.cpp +++ b/HotPatcher/Source/HotPatcherCore/Private/Cooker/MultiCooker/FlibHotCookerHelper.cpp @@ -59,7 +59,7 @@ FString UFlibHotCookerHelper::GetCookerProcFailedResultPath(const FString& BaseD FString UFlibHotCookerHelper::GetProfilingCmd() { - return FString::Printf(TEXT("-trace=cpu,memory,loadtime -statnamedevents implies -llm")); + return FString::Printf(TEXT("-tracehost=127.0.0.1 -trace=cpu,memory,loadtime -statnamedevents implies -llm")); } TSharedPtr UFlibHotCookerHelper::CreateCookShaderCollectionProxyByPlatform( diff --git a/HotPatcher/Source/HotPatcherCore/Private/Cooker/MultiCooker/SingleCookerProxy.cpp b/HotPatcher/Source/HotPatcherCore/Private/Cooker/MultiCooker/SingleCookerProxy.cpp index 0c1656eb..dc93f2bc 100644 --- a/HotPatcher/Source/HotPatcherCore/Private/Cooker/MultiCooker/SingleCookerProxy.cpp +++ b/HotPatcher/Source/HotPatcherCore/Private/Cooker/MultiCooker/SingleCookerProxy.cpp @@ -579,16 +579,26 @@ FCookCluster USingleCookerProxy::GetPackageTrackerAsCluster() PackageTrackerCluster.CookActionCallback.OnAssetCooked = GetOnPackageSavedCallback(); PackageTrackerCluster.CookActionCallback.OnCookBegin = GetOnCookAssetBeginCallback(); - + if(PackageTracker && GetSettingObject()->bCookPackageTrackerAssets) { PackageTrackerCluster.AssetDetails.Empty(); for(FName PackagePath:PackageTracker->GetPendingPackageSet()) { - FAssetDetail AssetDetail = UFlibAssetManageHelper::GetAssetDetailByPackageName(PackagePath.ToString()); - if(AssetDetail.IsValid()) + // make asset data to asset registry + FSoftObjectPath ObjectPath(PackagePath); + FAssetData AssetData; + if(UAssetManager::Get().GetAssetDataForPath(ObjectPath,AssetData)) { - PackageTrackerCluster.AssetDetails.Emplace(AssetDetail); + FAssetDetail AssetDetail; + if(UFlibAssetManageHelper::ConvFAssetDataToFAssetDetail(AssetData,AssetDetail)) + { + PackageTrackerCluster.AssetDetails.Emplace(AssetDetail); + } + } + else + { + UE_LOG(LogHotPatcher,Warning,TEXT("[GetPackageTrackerAsCluster] Get %s AssetData Failed!"),*PackagePath.ToString()); } } } @@ -708,19 +718,32 @@ void USingleCookerProxy::OnAssetCookedHandle(const FSoftObjectPath& PackagePath, { FScopeLock Lock(&SynchronizationObject); SCOPED_NAMED_EVENT_TEXT("OnAssetCookedHandle",FColor::Red); - + + FString PlatformName = THotPatcherTemplateHelper::GetEnumNameByValue(Platform); + FString SavePackageResultStr = UFlibHotPatcherCoreHelper::GetSavePackageResultStr(Result); FName AssetPathName = PackagePath.GetAssetPathName(); - GetPaendingCookAssetsSet().Remove(AssetPathName); + FString AssetPath = PackagePath.GetAssetPathString(); - if(Result == ESavePackageResult::Success) - { - GetPlatformCookAssetOrders(Platform).Add(AssetPathName); - } - else + GetPaendingCookAssetsSet().Remove(AssetPathName); + + switch(Result) { - SCOPED_NAMED_EVENT_TEXT("USingleCookerProxy::OnCookAssetFailed",FColor::Red); - UE_LOG(LogHotPatcher,Warning,TEXT("Cook %s for %d Failed (%s)!"),*PackagePath.GetAssetPathString(),(int32)Platform, *UFlibHotPatcherCoreHelper::GetSavePackageResultStr(Result)); - GetCookFailedAssetsCollection().CookFailedAssets.FindOrAdd(Platform).PackagePaths.Add(AssetPathName); + case ESavePackageResult::Success: + { + GetPlatformCookAssetOrders(Platform).Add(AssetPathName); + break; + } + case ESavePackageResult::Error: + case ESavePackageResult::MissingFile: + { + UE_LOG(LogHotPatcher,Error,TEXT("CookError %s for %s (%s)!"),*AssetPath,*PlatformName,*SavePackageResultStr); + GetCookFailedAssetsCollection().CookFailedAssets.FindOrAdd(Platform).PackagePaths.Add(AssetPathName); + break; + } + default: + { + UE_LOG(LogHotPatcher,Warning,TEXT("CookWarning %s for %s Failed (%s)!"),*AssetPath,*PlatformName, *SavePackageResultStr); + } } } @@ -775,22 +798,7 @@ TSet USingleCookerProxy::GetAdditionalAssets() return TSet{}; } -TArray GetClassesByNames(const TArray& ClassesNames) -{ - TArray result; - for(const auto& ClassesName:ClassesNames) - { - for (TObjectIterator Itt; Itt; ++Itt) - { - if((*Itt)->GetName().Equals(ClassesName.ToString())) - { - result.Add(*Itt); - break; - } - } - } - return result; -} + // pre cache asset type order TArray USingleCookerProxy::GetPreCacheClasses() const { @@ -802,10 +810,10 @@ TArray USingleCookerProxy::GetPreCacheClasses() const TEXT("Texture"), TEXT("PaperSprite"), // material - TEXT("MaterialExpression"), - TEXT("MaterialParameterCollection"), - TEXT("MaterialFunctionInterface"), - TEXT("MaterialInterface"), + // TEXT("MaterialExpression"), + // TEXT("MaterialParameterCollection"), + // TEXT("MaterialFunctionInterface"), + // TEXT("MaterialInterface"), // other TEXT("PhysicsAsset"), TEXT("PhysicalMaterial"), @@ -832,13 +840,13 @@ TArray USingleCookerProxy::GetPreCacheClasses() const // large ref asset TEXT("ActorSequence"), TEXT("LevelSequence"), - TEXT("World") + TEXT("World") }; - for(auto& ParentClass:GetClassesByNames(ParentClassesName)) + for(auto& ParentClass:UFlibHotPatcherCoreHelper::GetClassesByNames(ParentClassesName)) { Classes.Append(UFlibHotPatcherCoreHelper::GetDerivedClasses(ParentClass,true,true)); } - + Classes.Append(UFlibHotPatcherCoreHelper::GetAllMaterialClasses()); return Classes; } diff --git a/HotPatcher/Source/HotPatcherCore/Private/FlibHotPatcherCoreHelper.cpp b/HotPatcher/Source/HotPatcherCore/Private/FlibHotPatcherCoreHelper.cpp index 436cd762..e21ea3c8 100644 --- a/HotPatcher/Source/HotPatcherCore/Private/FlibHotPatcherCoreHelper.cpp +++ b/HotPatcher/Source/HotPatcherCore/Private/FlibHotPatcherCoreHelper.cpp @@ -2112,7 +2112,7 @@ void UFlibHotPatcherCoreHelper::CacheForCookedPlatformData( for(auto Package:Packages) { FString LongPackageName = UFlibAssetManageHelper::LongPackageNameToPackagePath(Package->GetPathName()); - FExecTimeRecoder PreGeneratePlatformDataTimer(FString::Printf(TEXT("PreGeneratePlatformData %s"),*LongPackageName)); + // FExecTimeRecoder PreGeneratePlatformDataTimer(FString::Printf(TEXT("PreGeneratePlatformData %s"),*LongPackageName)); FString FakePackageName = FString(TEXT("Package ")) + LongPackageName; #if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 25 @@ -2249,7 +2249,7 @@ void UFlibHotPatcherCoreHelper::WaitObjectsCachePlatformDataComplete(TSet TargetPlatforms) { SCOPED_NAMED_EVENT_TEXT("WaitObjectsCachePlatformDataComplete",FColor::Red); - FExecTimeRecoder WaitObjectsCachePlatformDataCompleteTimer(TEXT("WaitObjectsCachePlatformDataComplete")); + // FExecTimeRecoder WaitObjectsCachePlatformDataCompleteTimer(TEXT("WaitObjectsCachePlatformDataComplete")); if (GShaderCompilingManager) { // Wait for all shaders to finish compiling @@ -2294,7 +2294,8 @@ void UFlibHotPatcherCoreHelper::WaitObjectsCachePlatformDataComplete(TSetFlush(); } } } @@ -2494,4 +2495,48 @@ TempSandboxFile.Get() ); #endif return bresult; -} \ No newline at end of file +} +TArray UFlibHotPatcherCoreHelper::GetClassesByNames(const TArray& ClassesNames) +{ + TArray result; + for(const auto& ClassesName:ClassesNames) + { + for (TObjectIterator Itt; Itt; ++Itt) + { + if((*Itt)->GetName().Equals(ClassesName.ToString())) + { + result.Add(*Itt); + break; + } + } + } + return result; +} + +TArray UFlibHotPatcherCoreHelper::GetAllMaterialClasses() +{ + TArray Classes; + TArray ParentClassesName = { + // materials + TEXT("MaterialExpression"), + TEXT("MaterialParameterCollection"), + TEXT("MaterialFunctionInterface"), + TEXT("Material"), + TEXT("MaterialInterface"), + }; + for(auto& ParentClass:GetClassesByNames(ParentClassesName)) + { + Classes.Append(UFlibHotPatcherCoreHelper::GetDerivedClasses(ParentClass,true,true)); + } + return Classes; +} + +TSet UFlibHotPatcherCoreHelper::GetAllMaterialClassesNames() +{ + TSet result; + for(const auto& Class:GetAllMaterialClasses()) + { + result.Add(Class->GetFName()); + } + return result; +} diff --git a/HotPatcher/Source/HotPatcherCore/Private/ShaderPatch/FlibShaderCodeLibraryHelper.cpp b/HotPatcher/Source/HotPatcherCore/Private/ShaderPatch/FlibShaderCodeLibraryHelper.cpp index 17310303..d1d3a4eb 100644 --- a/HotPatcher/Source/HotPatcherCore/Private/ShaderPatch/FlibShaderCodeLibraryHelper.cpp +++ b/HotPatcher/Source/HotPatcherCore/Private/ShaderPatch/FlibShaderCodeLibraryHelper.cpp @@ -249,6 +249,7 @@ void UFlibShaderCodeLibraryHelper::WaitShaderCompilingComplete() // LastRemainingJob = CurrentNumRemaingingJobs; // } FPlatformProcess::Sleep(0.5f); + GLog->Flush(); } // One last process to get the shaders that were compiled at the very end diff --git a/HotPatcher/Source/HotPatcherCore/Public/Cooker/MultiCooker/FSingleCookerSettings.h b/HotPatcher/Source/HotPatcherCore/Public/Cooker/MultiCooker/FSingleCookerSettings.h index 2d15395d..4f1911ac 100644 --- a/HotPatcher/Source/HotPatcherCore/Public/Cooker/MultiCooker/FSingleCookerSettings.h +++ b/HotPatcher/Source/HotPatcherCore/Public/Cooker/MultiCooker/FSingleCookerSettings.h @@ -41,6 +41,8 @@ struct HOTPATCHERCORE_API FSingleCookerSettings:public FHotPatcherCookerSettingB UPROPERTY(EditAnywhere,BlueprintReadWrite) int32 MissionID = -1; UPROPERTY(EditAnywhere,BlueprintReadWrite) + bool bShaderCooker = false; + UPROPERTY(EditAnywhere,BlueprintReadWrite) FString ShaderLibName; UPROPERTY(EditAnywhere,BlueprintReadWrite) diff --git a/HotPatcher/Source/HotPatcherCore/Public/FlibHotPatcherCoreHelper.h b/HotPatcher/Source/HotPatcherCore/Public/FlibHotPatcherCoreHelper.h index 58fd588d..374306cc 100644 --- a/HotPatcher/Source/HotPatcherCore/Public/FlibHotPatcherCoreHelper.h +++ b/HotPatcher/Source/HotPatcherCore/Public/FlibHotPatcherCoreHelper.h @@ -278,4 +278,7 @@ class HOTPATCHERCORE_API UFlibHotPatcherCoreHelper : public UBlueprintFunctionLi // need add UNREALED_API to FAssetRegistryGenerator // all chunksinfo.csv / pakchunklist.txt / assetregistry.bin static bool SerializeChunksManifests(ITargetPlatform* TargetPlatform, const TSet&, const TSet&, bool bGenerateStreamingInstallManifest = true); + static TArray GetClassesByNames(const TArray& ClassesNames); + static TArray GetAllMaterialClasses(); + static TSet GetAllMaterialClassesNames(); }; diff --git a/HotPatcher/Source/HotPatcherRuntime/Private/FlibAssetManageHelper.cpp b/HotPatcher/Source/HotPatcherRuntime/Private/FlibAssetManageHelper.cpp index 5a7cfa0b..c5b1558c 100644 --- a/HotPatcher/Source/HotPatcherRuntime/Private/FlibAssetManageHelper.cpp +++ b/HotPatcher/Source/HotPatcherRuntime/Private/FlibAssetManageHelper.cpp @@ -498,7 +498,7 @@ bool UFlibAssetManageHelper::ConvFAssetDataToFAssetDetail(const FAssetData& InAs #endif OutAssetDetail = AssetDetail; - return !OutAssetDetail.AssetType.IsNone() && !OutAssetDetail.AssetType.IsNone() && !OutAssetDetail.AssetType.IsNone(); + return OutAssetDetail.IsValid(); } bool UFlibAssetManageHelper::GetSpecifyAssetDetail(const FString& InLongPackageName, FAssetDetail& OutAssetDetail) diff --git a/HotPatcher/Source/HotPatcherRuntime/Private/FlibPatchParserHelper.cpp b/HotPatcher/Source/HotPatcherRuntime/Private/FlibPatchParserHelper.cpp index 60810c8c..5332d299 100644 --- a/HotPatcher/Source/HotPatcherRuntime/Private/FlibPatchParserHelper.cpp +++ b/HotPatcher/Source/HotPatcherRuntime/Private/FlibPatchParserHelper.cpp @@ -1636,9 +1636,11 @@ FString UFlibPatchParserHelper::ReplaceMark(const FString& Src) result = result.Replace(*Key,*FPaths::ConvertRelativePathToFull(*MarkMap.Find(Key))); } } - + FPaths::NormalizeFilename(result); + FPaths::CollapseRelativeDirectories(result); return result; } + FString UFlibPatchParserHelper::ReplaceMarkPath(const FString& Src) { FString result = UFlibPatchParserHelper::ReplaceMark(Src); diff --git a/Mods/HotMultiCooker b/Mods/HotMultiCooker index 3584e990..b923a599 160000 --- a/Mods/HotMultiCooker +++ b/Mods/HotMultiCooker @@ -1 +1 @@ -Subproject commit 3584e990f86491fb23ef12340c586a7d6b820d98 +Subproject commit b923a599489fa7660882871a53f1004f96587d57