Unity can load texture and meshThe main graphics primitive of Unity. Meshes make up a large part of your 3D worlds. Unity supports triangulated or Quadrangulated polygon meshes. Nurbs, Nurms, Subdiv surfaces must be converted to polygons. More info
See in Glossary data from disk and upload it to the GPU in two different ways: synchronously or asynchronously. These two processes are called the synchronous upload pipeline and the asynchronous upload pipeline.
When Unity uses the synchronous upload pipeline, it cannot perform other tasks while it loads and uploads the data. This can cause visible pauses in your application. When Unity uses the asynchronous upload pipeline, it can perform other tasks while it loads and uploads the data in the background.
If a texture or mesh is eligible for the asynchronous upload pipeline, Unity uses the asynchronous upload pipeline automatically. If a texture or mesh is ineligible for the asynchronous upload pipeline, Unity uses the synchronous upload pipeline automatically.
The main difference between the synchronous and asynchronous upload pipelines is where Unity saves the data at build time, which affects how Unity loads it at runtime.
In the synchronous upload pipeline, Unity must load both the metadata (header data) and the texel or vertex data (binary data) for the texture or mesh in a single frame. In the asynchronous upload pipeline, Unity must load only the header data in a single frame, and it can stream the binary data to the GPU over subsequent frames.
In the synchronous upload pipeline:
In the asynchronous upload pipeline:
A texture is eligible for the asynchronous upload pipeline if the following conditions are met:
Note that if you load a texture using LoadImage(byte[] data)
, this forces Unity to use the synchronous upload pipeline, even if the above conditions are met.
A mesh is eligible for the asynchronous upload pipeline if the following conditions are met:
In all other circumstances, Unity loads textures and meshes synchronously.
You can use the ProfilerA window that helps you to optimize your game. It shows how much time is spent in the various areas of your game. For example, it can report the percentage of time spent rendering, animating, or in your game logic. More info
See in Glossary or another profiling tool to identify when Unity is using the asynchronous upload pipeline, by observing thread activity and profiler markersPlaced in code to describe a CPU or GPU event that is then displayed in the Unity Profiler window. Added to Unity code by default, or you can use ProfilerMarker API to add your own custom markers. More info
See in Glossary.
The following indicate that Unity is using the asynchronous upload pipeline to upload textures or meshes:
AsyncUploadManager.ScheduleAsyncRead
, AsyncReadManager.ReadFile
, and Async.DirectTextureLoadBegin
profiler markers.AsyncRead
thread.If you do not see this activity, then Unity is not using the asynchronous upload pipeline.
Note that the following profiler markers do not indicate that Unity is using the asynchronous upload pipeline; Unity calls them to check whether any asynchronous upload work needs to occur:
Initialization.AsyncUploadTimeSlicedUpdate
AsyncUploadManager.AsyncResourceUpload
AsyncUploadManager.ScheduleAsyncCommands
You can configure these settings for the asynchronous upload pipeline. Note that you cannot configure settings for the synchronous upload pipeline.
Unity re-uses a single ring buffer to stream texture and mesh data to the GPU. This reduces the number of memory allocations required.
The Async Upload Buffer determines the size of this ring buffer. It has a minimum size of 2 megabytes, and a maximum size of 2047 megabytes.
Unity automatically resizes the buffer to fit the largest texture or mesh that is currently loading. This can be a slow operation, especially if Unity has to perform it more than once; for example, if you are loading many textures that are larger than the default buffer size. To reduce the number of times that Unity must resize the buffer, set this value to fit the largest value that you expect to load. This is usually the largest texture in the SceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary.
You can configure this value in the Quality settings window, or using the QualitySettings.asyncUploadBufferSize API.
Async Upload Time Slice is the amount of time the CPU spends uploading texture or mesh data to the GPU, in milliseconds per frame.
A larger value means the data will be ready on the GPU sooner, but the CPU will spend more time on upload operations during those frames. Note that Unity only uses this time for uploading if there is data waiting in the buffer to be uploaded to the GPU; if there is no data waiting, Unity can use this time for other operations.
You can configure this value in the Quality settings window, or using the QualitySettings.asyncUploadTimeSlice API.
For more information on uploading texture and mesh data asynchronously, see the Unity blog post Optimizing loading performance: Understanding the Async Upload Pipeline.