BlueRoseNote/03-UnrealEngine/流程管理与部署/FastBuild联机编译Shader以及共享DDC.md

53 lines
2.9 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: FastBuild联机编译Shader以及共享DDC
date: 2022-08-09 13:55:15
tags: FastBuild DDC
rating: ⭐️⭐️
---
# UE5的Zen Loader & Zen Store
UE5推出了Zen Loader & Zen Store大概率会在之后的版本代替之前的DDC缓存功能。但目前该功能没有详细的使用文档。
- [Zen Loader](https://dev.epicgames.com/documentation/zh-cn/unreal-engine/zen-loader-in-unreal-engine)
- [Zen Store](https://dev.epicgames.com/documentation/zh-cn/unreal-engine/zen-store-in-unreal-engine?application_version=5.4)
# 前言
目前考虑的方法是使用FastBuild的分布式编译来加快Shader编译与速度并且使用共享DDC来减少构建时间。
- 在 Mac 构建机上配置 UE4 FastBuild 及 DDChttps://zhuanlan.zhihu.com/p/474404469
- UE4.24 FastBuild(v1.02) 支持C++与 Shader 可用的分布编译加速方案https://zhuanlan.zhihu.com/p/307581961
- 官方文档
- FastBuildhttps://docs.unrealengine.com/4.27/en-US/ProductionPipelines/BuildTools/UnrealBuildTool/BuildConfiguration/
- DDC文档https://docs.unrealengine.com/4.27/zh-CN/ProductionPipelines/DerivedDataCache/
## 共享DDC
1. 在DefaultEngine.ini中覆盖你的项目设置如下图所示该覆盖项会将路径设置为团队的有效位置。
```ini
[InstalledDerivedDataBackendGraph] Shared=(Type=FileSystem, ReadOnly=false, Clean=false, Flush=false, DeleteUnused=true, UnusedFileAge=10, FoldersToClean=10, MaxFileChecksPerSec=1, ConsiderSlowAt=70, PromptIfMissing=false, Path=\YourCompanyServer\DDC, EnvPathOverride=UE-SharedDataCachePath, EditorOverrideSetting=SharedDerivedDataCache)
```
2. 将 `UE-SharedDataCachePath`在Mac/Linux上为 `UE_SharedDataCachePath`)的环境变量(如下图所示)设置为要使用的文件夹。
3. 在编辑器General-Global-DerivedDataCache中设置 `SharedDerivedDataCache` 变量。
- 官方译版引擎:[InstalledDerivedDataBackendGraph]
- 源码版:[DerivedDataBackendGraph]
### 使用Commandlet生成DDC
在设置完之后就可以通过 Commandlet 来执行DDC的生成了
```cmd
Engine\Binaries\Win64\UE4Editor.exe Client\Client.uproject -run=DerivedDataCache -fill
```
### 禁用共享DDC
当开发人员远程处理项目时并且该项目已配置了共享DDC时开发人员可能会遇到性能不佳的情况这是因为访问DDC数据比生成DDC数据花费的时间更长。要暂时禁用共享DDC请使用以下方法之一
- 在命令行上传递-ddc=noshared。
- 将环境变量设置为本地硬盘驱动器:
- `UE-SharedDataCachePath=None`
- 在Mac上`UE_SharedDataCachePath=None`
## 启用FastBuild编译Shader
Shader 编译使用 CVars 打开,在 DefaultEngine.ini 中的 [/Script/Engine.RendererSettings] 部分,添加如下内容:
```
r.FASTBuildShaderCompile=1
```
### FASTBuild Dashboard
可以使用FASTBuild Dashboard来查看联机构建情况。
地址https://github.com/hillin/FASTBuild-Dashboard