首先,没弄懂 这个东西是否带来了性能上的提升?
它用少量CPU资源以节省潜在的大量GPU内存。
Texture mipmap Streaming系统使您可以控制实际加载到内存中的mipmap级别。 通常Unity会加载存储在磁盘上的所有mipmap级别,但是使用此系统,您可以直接控制加载哪些mipmap级别。
通常,这样的系统通过仅加载渲染场景中当前相机位置所需的mipmap来减少纹理所需的总内存量。 它可以节省少量CPU成本,从而节省大量GPU内存。
在维京村的场景中,系统节省了25-30%的纹理内存,具体取决于相机的位置。
https://docs.unity3d.com/Manual/AsyncTextureUpload.html
这个异步纹理上传 和 Texture Streaming 有关系么????
使命召唤手游有 使用 : Texture Streaming
https://mp.weixin.qq.com/s?src=11×tamp=1563935430&ver=1747&signature=qIm5L3zeFnOXEUDvHZn0BMxfp1TMSsc7e9cPfY4CEwtFIS4wzaMGEchnXLOE*7NPjmxY9rO2WSANiqc*ujdkEanX7o6njUbrLaJutf4clUjAJfg7bSW4OTHHloVpGEsM&new=1
-----------------------------------------------------
https://unity3d.com/fr/learn/tutorials/topics/best-practices/textures?playlist=30089
GPU上传 (GPU Upload)
完成加载后,Unity会将纹理直接上传到GPU,并且不会等到纹理在摄像机视锥中看到。
当加载线程完成加载场景或资产时,Unity需要唤醒它们。加载的位置和方式取决于Unity版本和用于初始化加载的调用。
加载行为
如果从AssetBundles,Resources或Scenes加载资产,Unity会从预加载线程(磁盘I / O)转到图形线程(GPU上载)。如果您使用Unity 5.5或更高版本,并且启用了图形作业,Unity会从预加载作业直接进入GPU。
觉醒行为
在唤醒所有场景游戏对象后,Unity直接唤醒主线程上的资产。如果使用AssetBundle.LoadAsset,Resources.Load或SceneManager.LoadScene来加载资产和场景,Unity会阻止主线程并唤醒所有资产。如果您正在使用这些调用的非阻塞版本(例如,AssetBundle.LoadAssetAsync),Unity会使用时间切片来唤醒资产。
记忆行为
在一次加载多个纹理时,如果上传速度不够快或主线程停止,您可以调整纹理缓冲区。但是,更改默认值可能会导致高内存压力。在Unity指南中的Memory Management的RingBuffer部分中使用时间片唤醒时,您可以阅读有关纹理缓冲区中内存限制的更多信息。
注意:如果GPU内存过载,GPU会卸载最近最少使用的纹理,并强制CPU在下次进入相机平台时重新上传它。
https://docs.unity3d.com/560/Documentation/Manual/AsyncTextureUpload.html
异步纹理上传
异步纹理上载允许从磁盘异步加载纹理数据,并在Render-thread上启用时间片上传到GPU。这减少了主线程中GPU上传的等待时间。
笔记
对于非读/写启用的纹理,TextureData是resS(流媒体资源)的一部分,现在上传发生在Render-Thread上。在调用AwakeFromLoad之前,可以保证Texture的可用性,因此在加载顺序或渲染上的Textures的可用性方面没有变化。
对于其他类型的纹理加载,例如启用读/写的纹理,直接使用LoadImage(byte []数据)函数加载的纹理,或从Resources文件夹加载,不使用异步缓冲区加载 - 使用较旧的同步方法。
《优化加载性能:了解异步上载管道》中文翻译: https://mp.weixin.qq.com/s?__biz=MzU5MjQ1NTEwOA==&mid=2247495299&idx=1&sn=8f0a56a98a3c17fb6ccfacbccbda3000&chksm=fe1dda28c96a533e8fdfcf8feb5b41ccd595d66cd31968a5748413dacc95ae9e2f78f4d7802d&scene=21#wechat_redirect
《Texture Mipmap Streaming()2018.2 》 有很多调试脚本的功能!!!!
https://docs.unity3d.com/Manual//TextureStreaming.html
https://docs.unity3d.com/Manual//TextureStreaming-API.htm
---------------------------------------------------------------------------------------------------------
转载自: https://docs.google.com/document/d/1P3OUoQ_y6Iu9vKcI5B3Vs2kWhQYSXe02h6YrkDcEpGM/edit#
警告: 文章中给的脚本 太容易导致闪退了, 我在编辑器下2018.2 版本中测试,必闪退!!!
Texture Mipmap Streaming (Unity 2018.2)
Overview
The Texture mipmap Streaming system gives you control over which mipmap levels are actually loaded into memory. Normally Unity will load all the mipmap levels that are stored on the disk, but with this system you can take direct control over which mipmap levels are loaded.
Typically a system like this is used to reduce the total amount of memory required for textures by only loading the mipmaps needed to render the current camera position in a scene. It trades a small amount of CPU cost for a potentially large GPU memory saving.
In the viking village scene the system saved 25-30% texture memory, depending on camera location.
There are two ways you can use this system. If you enable Streaming mipmaps on textures, the engine will try to ‘do the right thing’ and load appropriate mipmaps while observing the texture budget. For more low level control you can use the C# API to specify mipmap levels. These two systems can be used in conjunction with each other.
Moving large distances quickly or instantaneous camera cuts can cause noticeable texture quality changes as the mipmaps are streamed in. The API supports features for preloading mipmaps at a new camera location to reduce this problem.
Features
-
Engine support for picking the appropriate mipmap level based on camera view.
-
C# API to request a specific mipmap level for a texture.
-
Sample C# code that duplicates the engine logic for mipmap selection. This allows you to override the engine logic for your own use cases.
-
Set a total budget to be used by all textures in a game. Unity will automatically reduce mipmap levels in order to hit this budget.
-
The budget includes non streaming textures so if your budget is 100MB and you have 90MB of non streaming textures Unity will try to fit all the streaming textures in 10MB.
Setup
Enable the feature and set the memory budget in the Quality Settings Panel.
For the textures you want to enable mipmap streaming set the ‘Streaming Mipmaps’