This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
专业(SIM)
UnigineEditor
界面概述
资源工作流程
版本控制
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
材质和着色器
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
创建内容
内容优化
材质
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

异步数据流

Data streaming is an optimization technique intended to reduce spikes caused by loading graphic resources. With this technique, not all the data is loaded into memory at once. Instead, only the required data is loaded, and the rest is loaded progressively on demand.数据流传输是一种优化技术,旨在减少由于加载图形资源而导致的峰值。使用此技术,并非所有数据都立即加载到随机存取存储器(RAM)中。取而代之的是,仅加载所需的数据,其余所有数据根据需要逐步加载。

Resource loading is performed and transferred to the GPU in separate asynchronous threads. After that, resources are synchronized and added to the virtual scene on the CPU side.执行资源加载,并在单独的异步线程中将其转移到GPU。之后,资源将同步并添加到CPU一侧的虚拟场景。

The output of the Microprofile tool.Microprofile工具的输出。

In UNIGINE, asynchronous data streaming is enabled by default. You can disable asynchronous data streaming in UnigineEditor or via the console:在 UNIGINE 中,默认启用异步数据流。 您可以在 UnigineEditor 中或通过控制台禁用异步数据流

  • In UnigineEditor, open the Settings window and go to the Streaming section. Here you can switch the streaming mode for textures and/or meshes.在UnigineEditor中,打开Settings窗口并转到Streaming部分。在这里你可以为纹理和/或网格切换流模式。
  • In the console, run the corresponding commands that switch the streaming mode for textures and/or meshes.在控制台中,运行相应的命令,切换纹理和/或网格的流模式。

There are two main streaming modes — asynchronous (Async) and forced (Force). The Force mode ensures force-loading of all meshes and textures required for each frame at once (e.g., grabbing frame sequences, rendering node previews, warmup, etc.).有两种主要的流模式——异步(Async)和强制(Force)。Force模式确保每帧一次加载所需的所有网格和纹理(例如,抓取帧序列,渲染节点预览,预热等)。

注意
The Force mode may cause freezes, so use it only if you are sure that the graphic resources in your world fit into the available video memory.Force模式可能会导致死机,所以只有在您确信您的世界中的图形资源适合可用的视频内存时才使用它。

For meshes, there is an additional All mode that disables mesh streaming and provides loading of all meshes available in the project on the application start-up. This mode is good for small projects with few meshes.对于网格,有一个额外的All模式,它禁用网格流,并在应用程序启动时提供项目中所有可用网格的加载。这种模式适用于网格较少的小项目。

The streaming system provides asynchronous loading of the following data to RAM:流系统提供以下数据异步加载到RAM:

You can obtain general information on streamed resources by using the render_streaming_meshes_info and render_streaming_textures_info console commands.可以通过使用render_streaming_meshes_inforender_streaming_textures_info控制台命令获取流资源的一般信息。

The render_streaming_meshes_info output.render_streaming_meshes_info输出。

It is also possible to print the list of loaded resources and detailed information on them by using the render_streaming_meshes_list and render_streaming_textures_list console commands.还可以通过使用render_streaming_meshes_listrender_streaming_textures_list控制台命令打印已加载资源的列表和有关它们的详细信息。

The render_streaming_meshes_list output.render_streaming_meshes_list输出。

Procedurally generated objects such as ObjectMeshClutter are generated in a separate thread, significantly reducing performance costs.程序生成的对象(如ObjectMeshClutter)生成在一个单独的线程,显著降低性能成本。

Common Streaming Settings通用流媒体设置#

To make the scene appear immediately when the application starts, there is the First Frames Force parameter, which sets the number of frames that will be loaded right after the first frame. 为了在应用程序启动时立即显示场景,有一个First Frames Force参数,它设置在第一帧之后加载的帧数。

To take advantage of multithreading, set the maximum number of threads used for resource streaming by using the render_streaming_max_threads console parameter. A higher number of threads results in faster streaming but may cause spikes in the case of excessive consumption of GPU resources.利用多线程,设置的最大线程数用于流媒体资源利用(国家统计局) render_streaming_max_threads 控制台参数。更高的线程数量导致更快的流,但可能导致峰值在GPU资源的过度消费。

注意
The streaming system requires a GPU driver with multithreading support.流系统需要一个支持多线程的GPU驱动程序。

You can limit the number of loaded and unloaded graphic resources per frame by specifying the corresponding budgets. Use them to find the balance between loading/unloading speed and performance: keep in mind that increasing the budget increases streaming performance, however, memory consumption increases as well.您可以通过指定相应的 预算 来限制每帧加载和卸载的图形资源的数量。 使用它们来找到加载/卸载速度和性能之间的平衡点:请记住,增加预算会提高流媒体性能,但是,内存消耗也会增加。

Adjustable memory limits and life times enable to avoid situations where resources remain loaded in memory or video memory even after they are no longer used. They are defined for meshes loaded to RAM/VRAM, textures, and particles separately in a percentage of the total RAM/VRAM.可调整的内存限制和生命周期可以避免资源在不再使用后仍然加载在内存或视频内存中的情况。它们是为加载到RAM / VRAM的网格、纹理和粒子分别定义的,占总RAM / VRAM的百分比。

注意
The memory limit is a recommended value to aim for. It can be exceeded if textures or meshes are required for the current frame.内存限制是推荐值为目标。它可以超过如果纹理或网格所需的当前帧。

The memory limit is associated with the lifetime: resources are deleted from memory or video memory only when both values are exceeded.内存限制与生命周期关联:只有当内存或显存超过这两个值时,资源才会从内存或显存中删除。

Memory limits and RAM / VRAM occupied by streamed resources are available in the Performance Profiler tool.内存限制和RAM / VRAM被流资源可在Performance Profiler工具。

The limits are slash separated: the first value displays the current RAM / VRAM usage, and the second value is the limit.限制用斜杠分隔:第一个值显示当前RAM / VRAM使用情况,第二个值是限制。

Texture Cache纹理缓存#

The streaming system uses the texture cache composed of minimized copies generated for all textures with user-defined resolution stored in the data/.cache_textures folder. These copies are used instead of the originals while they are being loaded.流传输系统使用纹理缓存,该纹理缓存由为具有用户定义的分辨率的所有纹理生成的最小化副本组成,并存储在 data/.cache_textures 文件夹中。这些副本将在加载时代替原始文件使用。

Texture cache is loaded at Engine's startup and always stays in the memory after loading. The following default loading order ensures smooth loading and rendering of resources:纹理缓存在引擎启动时加载,并始终在加载后保留在内存中。为了提供流畅的资源加载和呈现,流式实体具有以下加载优先级:

  1. Texture cache 纹理缓存
  2. Geometry 几何形状
  3. Uncached textures cause spikes as texture cache is generated for them on the fly; materials with uncached and unloaded textures applied are rendered black 未缓存的纹理(由于在运行中为其生成纹理缓存时会产生尖峰;应用了未缓存和未加载纹理的材质会呈现黑色)
  4. Full-size textures 全尺寸纹理

Using the textures_cache_preload flag in the boot config file, you can choose the texture cache loading priority — preloaded or loaded after geometry data.使用boot配置文件中的 textures_cache_preload标志,您可以选择纹理缓存加载优先级:预加载或在几何数据后加载。

注意
If there is no texture cache in the project, it will be generated for all textures at Engine's startup, causing spikes and extremely increasing loading time (up to several minutes).如果项目中没有纹理缓存,则将在引擎启动时为所有纹理生成纹理缓存,从而导致峰值并极大增加加载时间(长达数分钟)。

By default, texture cache files are generated with a resolution of 16 x 16 px. Such a low resolution of textures may be noticeable during loading.默认情况下,生成纹理缓存文件的分辨率为16x16,如此低的纹理分辨率会导致加载过程中出现视觉伪像。

Control the resolution of texture cache by setting the Texture Cache Resolution parameter. To apply changes, wipe away existing cache files by using the render_streaming_textures_cache_destroy console command, after which the texture cache will be generated automatically with the new specified resolution.通过设置Texture Cache Resolution参数来控制纹理缓存的分辨率。要应用更改,请使用render_streaming_textures_cache_destroy 控制台命令擦除现有的缓存文件,之后将使用新的指定分辨率自动生成纹理缓存。

注意
Be aware that higher texture cache resolution requires more video memory.请注意,高分辨率纹理缓存需要更多的视频内存。

The video memory amount currently occupied by the texture cache is available in the Performance Profiler tool.视频内存数量目前占领的纹理缓存可用Performance Profiler工具。

注意
As all textures are cached regardless of their use in the project, it is reasonable to use the Cleaner tool to delete unused assets and thus lighten video memory consumption.由于无论是否使用纹理都将缓存项目中的所有纹理,因此使用Cleaner工具删除未使用的资源并因此减轻视频内存消耗是合理的。

The render_streaming_textures_cache_load and render_streaming_textures_cache_unload console commands enable you to control loading of texture cache. For example, after loading full-size textures, you can unload the texture cache from video memory for better performance. render_streaming_textures_cache_load render_streaming_textures_cache_unload 控制台命令使您能够控制加载纹理缓存。例如,加载后全尺寸的纹理,你可以卸载的纹理缓存视频内存更好的性能。

Mesh Streaming网流#

Meshes can be loaded to RAM and VRAM separately for more efficient work with geometry. This allows eliminating memory leaks: meshes participating in collisions and intersections can be loaded to RAM only, if they are not currently rendered.网格可以分别加载到RAM和VRAM中,以便更有效地处理几何图形。这允许消除内存泄漏:参与碰撞和交叉点的网格只能加载到RAM中,如果它们当前没有渲染。

There are 3 modes of mesh streaming to RAM/VRAM:有3种模式的网格流到RAM/VRAM:

  • Asynchronous mode that provides asynchronous loading of meshes.异步模式,提供网格的异步加载。
  • Forced mode for force-loading of meshes required for the current frame at once.强制模式,用于立即加载当前框架所需的网格。
  • Mode for loading all meshes available in the project on the application start-up. Actually, this mode disables mesh streaming at all.模式加载 所有网格应用程序启动的项目。实际上,这种模式禁用网流。

The asynchronous loading to RAM and VRAM differs. Even if a mesh hasn't been loaded to video memory in time, it doesn't affect the application behavior (you may only notice some lag). However, if a mesh hasn't been loaded to memory in time, it may lead to incorrect physical behavior of objects in the scene.异步加载到RAM和VRAM是不同的。即使网格没有及时加载到显存,它也不会影响应用程序的行为(您可能只会注意到一些延迟)。但是,如果网格没有及时加载到内存中,可能会导致场景中对象的物理行为不正确。

First of all, we highly recommend you to use shapes for collision and intersection detection as it is faster. If, for some reason, it doesn't suit you, use the following methods:首先,我们强烈推荐您使用 形状碰撞和碰撞测试,因为它更快。如果出于某种原因,它不适合你,使用以下方法:

  • Load meshes and hold them in memory while they exist. API of some mesh-based objects provides this functionality out of the box. It may partially solve the problem with incorrect behavior, however, only a few meshes can remain loaded.加载网格并在它们存在时将它们保存在内存中。一些基于网格的对象的API提供了开箱即用的功能。它可以部分解决不正确行为的问题,然而,只有少数网格可以保持加载。
  • Use the prefetch system that allows asynchronous pre-loading of meshes participating in collisions and intersections to memory before they are used:使用预取系统,允许预装的网格参与碰撞和十字路口异步内存之前使用:

    1. Set the Radius prefetch mode.设置Radius预取模式。
    2. Specify the physics radius (for collisions) and/or the radius within which intersections are calculated.指定物理半径(用于碰撞)和/或计算交叉点的半径。
    3. Specify the prefetch radius that should exceed the collison and intersection radius values.指定应该超过碰撞和相交半径值的预取半径。

    You can also preload all meshes for which collisions and intersections are calculated (the Full prefetch mode), however it will significantly increase RAM usage.您还可以预加载所有网格计算碰撞和十字路口(Full预抓取模式),但是它将大大增加内存的使用。

  • API of some mesh-based objects, as well as the MeshStatic class API provides also methods which allow implementing a custom prefetch logic for pre-loading meshes.一些基于网格(mesh)对象的API,以及MeshStatic类API也提供了允许实现预加载网格的自定义预取逻辑的方法。
注意
It is highly recommended to use shapes for collision and intersection detection.强烈推荐使用形状 (shape) 碰撞和碰撞测试。

Asynchronously streamed meshes shouldn't be modified. The only way to change such mesh is to make it procedural. A procedural mesh is a mesh created via code, such meshes have a specific streaming mode — they are always kept in memory after creation and never unloaded until the object is destroyed via code or the mesh returns to its normal mode (streaming from a source file). The mesh-based objects API allows switching a mesh to the procedural mode and apply changes.异步流网格不应该被修改。改变这种网格的唯一方法是使其程序化。一个过程网格是一个通过代码创建的网格,这样的网格有一个特定的流模式——它们总是在创建后保存在内存中,永远不会卸载,直到对象被代码破坏或网格返回到它的正常模式(从源文件流)。基于网格的对象API允许将网格切换到过程模式并应用更改。

OpenGL SettingsOpenGL设置#

Settings and workflow for OpenGL API are slightly different than for DirectX API. OpenGL API的设置和工作流程与DirectX API略有不同。

Under OpenGL, the Data Streaming System engages two intermediate buffers to provide data transfer between CPU and new resource:OpenGL,数据流系统使用两个中间缓冲区来提供CPU与新资源之间的数据传输:

  • Async Buffer used for mesh and texture streaming Async Buffer用于网格和纹理流处理
  • Async Buffer Indices used for streaming of vertex indices of meshes Async Buffer Indices用于流化网格的顶点索引

The size of the Async Buffer buffer must correspond to the size of the largest resource (mesh/texture); otherwise, in the case of a larger resource, the buffer will be resized, causing a spike. Async Buffer缓冲区的 大小 必须与最大资源的大小(网格/纹理)相对应,否则,在资源较大的情况下,将调整缓冲区的大小,从而导致峰值。

注意
Be aware that the size of these intermediate buffers contributes to the increased total memory consumption.请注意,这些中间缓冲区的大小将添加到总内存消耗中。

The Async Buffer Synchronization parameter stands for the mechanism of buffer synchronization. So, async buffers are created only once and then synchronized, reducing the time on allocating and freeing memory. When the synchronization is disabled, both Async Buffer and Async Buffer Indices are created anew for each new resource. This reduces the number of buffer synchronizations but increases the number of memory allocations.如果将Async Buffer Synchronization参数设置为 1 ,则启用缓冲区同步机制。因此,异步缓冲区仅创建一次,然后进行同步,从而减少了分配和释放内存的时间。禁用同步后,将为每个新资源重新创建Async BufferAsync Buffer Indices。这减少了缓冲区同步的次数,但增加了内存分配的数量。

Sometimes (depending on the hardware/driver used, e.g., when the main thread is affected by synchronization primitives in other threads), memory allocation may be faster than synchronizations; in such cases, when streaming becomes unacceptably slow, it is recommended to disable buffer synchronization.有时(取决于所使用的硬件/驱动程序,例如,当主线程受到其他线程中的同步原语影响时),内存分配可能比同步要快;在这种情况下,当流变得异常缓慢时,建议禁用缓冲区同步。

There are some known issues and workarounds for some hardware/driver software:一些硬件/驱动程序软件存在一些已知的问题和解决方法:

最新更新: 2023-07-06
Build: ()