From c4a476ae207dc98a66fd95f50d645f90ce8c5940 Mon Sep 17 00:00:00 2001 From: walon Date: Sat, 9 Mar 2024 19:11:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0dots=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/basic/dots.md | 8 ++++ docs/basic/notsupportedfeatures.md | 2 +- docs/business/dots.md | 38 +++++++++++++++++++ docs/business/supportdots.md | 8 ---- .../current/basic/dots.md | 8 ++++ .../current/business/dots.md | 38 +++++++++++++++++++ .../current/business/supportdots.md | 7 ---- sidebars.js | 3 +- 8 files changed, 95 insertions(+), 17 deletions(-) create mode 100644 docs/basic/dots.md create mode 100644 docs/business/dots.md delete mode 100644 docs/business/supportdots.md create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/basic/dots.md create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/business/dots.md delete mode 100644 i18n/en/docusaurus-plugin-content-docs/current/business/supportdots.md diff --git a/docs/basic/dots.md b/docs/basic/dots.md new file mode 100644 index 000000000..be5be99bb --- /dev/null +++ b/docs/basic/dots.md @@ -0,0 +1,8 @@ +# DOTS支持 + +DOTS的并不支持动态注册Component、System、Aspect等核心类型,导致热更新中的DOTS相关类型无法被DOTS运行时识别,无法正常运行。 + +商业化版本对DOTS做了部分修改,并且相应调整了运行时代码,最终实现了支持DOTS绝大多数特性。尤其是旗舰版本,标记`[BurstCompile]`的函数如果未修改, +可以直接调用burst函数实现,可以极大提升性能。 + +具体请参见[商业化版本的DOTS 支持](../business/dots)文档。 diff --git a/docs/basic/notsupportedfeatures.md b/docs/basic/notsupportedfeatures.md index 7fd7e3ba6..947e34275 100644 --- a/docs/basic/notsupportedfeatures.md +++ b/docs/basic/notsupportedfeatures.md @@ -5,7 +5,7 @@ ::: - 暂时不支持在热更新脚本中定义extern函数,但可以调用AOT中extern函数。 -- 支持2022的dots技术,需要小幅修改dots代码以支持动态注册component和system类型(**需要购买商业化版本获得实现细节**),而且无法利用burst加速。如果burst部分在AOT,则仍然原生方式执行;如果burst部分在热更部分,则虽然是Jobs并发执行,但以解释方式执行。 +- 社区版本不支持dots,商业化版本支持绝大多数dots特性,详见[dots兼容性](./dots) - 不支持`System.Runtime.InteropServices.Marshal`中 `Marshal.StructureToPtr`之类序列化结构的函数,但普通Marshal函数如`Marshal.PtrToStringAnsi`都是能正常工作的。 - 不支持[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.xxx)]。纯粹是时机问题,Unity收集这些函数的时机很早,此时热更新dll还没加载。一个推荐的办法是你使用反射收集这些函数,在合适的时机主动调用它们。 - 不支持对解释代码部分进行C#级别调试,因为没暂时没时间写调试器 diff --git a/docs/business/dots.md b/docs/business/dots.md new file mode 100644 index 000000000..3a25b800b --- /dev/null +++ b/docs/business/dots.md @@ -0,0 +1,38 @@ +# DOTS支持 + + +商业化版本修改了DOTS运行时代码及hybridclr运行时代码,支持绝大多数DOTS特性。 + + +## 特性的支持状况 + +:::tip + +注意,我们不单独罗列Shared Component之类的特性,它们统一归类到Component特性。 + +::: + +|特性|社区版本|专业版|旗舰版|热重载版| +|-|-|-|-|-| +|Jobs|✔|✔|✔|✔| +|Managed Component||✔|✔|✔| +|Unmanaged Component||✔|✔|✔| +|Managed System||✔|✔|✔| +|Unmanaged System||✔|✔|✔| +|Aspect||✔|✔|✔| +|IJobEntity||✔|✔|✔| +|BurstCompile|||✔|| +|SubScene||||| + +## 注意事项 + +1. 专业版和热重载版热更新模块的DOTS代码以解释方式执行 +2. 热重载版本无法卸载包含DOTS代码的程序集 +3. 旗舰版本对标记了`[BurstCompile]`函数,未改变前执行原始burst代码,改变后会以解释方式执行。**改变的burst函数需要删除[BurstCompile]特性,否则运行时将出错** +4. 由于Unity的dots资源的序列化机制的并不支持新增热更新类型,包含热更新组件的资源的SubScene无法正确还原Component + +## 支持的Unity及DOTS版本 + +由于DOTS代码处于不断变动中,目前仅支持 Unity 2022.3.0+ 及 com.unity.entities 1.0.16+版本。我们正尝试支持更多的Unity及DOTS版本。 + +由于维护多个DOTS版本成本较高,有特殊版本需求的开发者,请联系我们单独付费订制。 diff --git a/docs/business/supportdots.md b/docs/business/supportdots.md deleted file mode 100644 index e8d26be38..000000000 --- a/docs/business/supportdots.md +++ /dev/null @@ -1,8 +0,0 @@ -# 支持Unity DOTS技术 - -当前DOTS在系统启动时即已初始化所有Component、System等核心类型,导致解释程序集中使用自定义的Component等类型会出现错误。 -需要对DOTS源码进行修改才能支持热更新类型。 - -商业化版本提供了解决方案,可以在热更新模块中正常使用DOTS技术。不过要注意,由于对Component的操作变成了解释执行而无法使用burst技术,导致性能大幅下降, -最终效果相当于只利用了jobs的多线程来加速执行。 - diff --git a/i18n/en/docusaurus-plugin-content-docs/current/basic/dots.md b/i18n/en/docusaurus-plugin-content-docs/current/basic/dots.md new file mode 100644 index 000000000..52d7558a6 --- /dev/null +++ b/i18n/en/docusaurus-plugin-content-docs/current/basic/dots.md @@ -0,0 +1,8 @@ +# DOTS support + +DOTS does not support dynamic registration of core types such as Component, System, and Aspect. As a result, DOTS-related types in hot updates cannot be recognized by the DOTS runtime and cannot operate normally. + +The commercial version made some modifications to DOTS and adjusted the runtime code accordingly, ultimately supporting most of the features of DOTS. Especially for the flagship version, if the function marked `[BurstCompile]` is not modified, +It can be implemented by directly calling the burst function, which can greatly improve performance. + +For details, please refer to the [Commercial version of DOTS support] (../business/dots) document. \ No newline at end of file diff --git a/i18n/en/docusaurus-plugin-content-docs/current/business/dots.md b/i18n/en/docusaurus-plugin-content-docs/current/business/dots.md new file mode 100644 index 000000000..6aff84247 --- /dev/null +++ b/i18n/en/docusaurus-plugin-content-docs/current/business/dots.md @@ -0,0 +1,38 @@ +# DOTS Support + + +The commercial version has modified the DOTS runtime code and hybridclr runtime code to support most DOTS features. + + +## Feature support status + +:::tip + +Note that we do not list features such as Shared Component separately, they are collectively classified into Component features. + +::: + +|Features|Community Edition|Professional Edition|Ultimate Edition|Hot Reload Edition| +|-|-|-|-|-| +|Jobs|✔|✔|✔|✔| +|Managed Component||✔|✔|✔| +|Unmanaged Component||✔|✔|✔| +|Managed System||✔|✔|✔| +|Unmanaged System||✔|✔|✔| +|Aspect||✔|✔|✔| +|IJobEntity||✔|✔|✔| +|BurstCompile|||✔|| +|SubScene||||| + +## Precautions + +1. The DOTS code of the hot update module of the professional version and hot reload version is executed in interpreted mode +2. The hot reload version cannot uninstall an assembly containing DOTS code. +3. The flagship version has marked the `[BurstCompile]` function. The original burst code will be executed before it is changed. After the change, it will be executed in interpreted mode. **The changed burst function needs to delete the [BurstCompile] attribute, otherwise an error will occur during runtime** +4. Since the serialization mechanism of Unity’s dots resources does not support the new hot update type, the SubScene of the resource containing the hot update component cannot correctly restore the Component. + +## Supported Unity and DOTS versions + +Since the DOTS code is constantly changing, currently only Unity 2022.3.0+ and com.unity.entities 1.0.16+ versions are supported. We are trying to support more Unity and DOTS versions. + +Due to the high cost of maintaining multiple DOTS versions, developers who have special version requirements should contact us to pay for a separate order. \ No newline at end of file diff --git a/i18n/en/docusaurus-plugin-content-docs/current/business/supportdots.md b/i18n/en/docusaurus-plugin-content-docs/current/business/supportdots.md deleted file mode 100644 index 8b03d4968..000000000 --- a/i18n/en/docusaurus-plugin-content-docs/current/business/supportdots.md +++ /dev/null @@ -1,7 +0,0 @@ -# Support Unity DOTS technology - -Currently, DOTS has initialized all core types such as Component and System when the system starts, resulting in errors when using custom Component and other types in the interpreter assembly. -The DOTS source code needs to be modified to support the hot update type. - -The commercial version provides a solution to use DOTS technology normally in hot update modules. However, it should be noted that since the operation of Component becomes interpreted and executed, burst technology cannot be used, resulting in a significant performance drop. -The final effect is equivalent to using only the multi-threading of jobs to speed up execution. \ No newline at end of file diff --git a/sidebars.js b/sidebars.js index 6eb3663b0..b4983d862 100644 --- a/sidebars.js +++ b/sidebars.js @@ -59,6 +59,7 @@ const sidebars = { 'basic/monobehaviour', 'basic/aotgeneric', 'basic/methodbridge', + 'basic/dots', 'basic/memory', 'basic/performance', 'basic/notsupportedfeatures', @@ -83,7 +84,7 @@ const sidebars = { 'business/intro', 'business/differentialhybridexecution', 'business/fullgenericsharing', - 'business/supportdots', + 'business/dots', 'business/metadataoptimization', 'business/basiccodeoptimization', 'business/basicencryption',