Asynchronous Texture Upload 异步贴图上传 AUP(Async Upload Pipeline) Advanced Rendering Features系列之一

本文主要是介绍Asynchronous Texture Upload 异步贴图上传 AUP(Async Upload Pipeline) Advanced Rendering Features系列之一,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Asynchronous Texture Upload 异步贴图上传 AUP(Async Upload Pipeline)

本文档主要是对Unity官方手册的个人理解与总结(其实以翻译记录为主:>)
仅作为个人学习使用,不得作为商业用途,欢迎转载,并请注明出处。
文章中涉及到的操作都是基于Unity2018.4版本
参考链接:https://docs.unity3d.com/Manual/AsyncTextureUpload.html

Asynchronous Texture Upload enables asynchronous loading of Texture Data from disk and enables time-sliced upload to GPU on the Render-thread. This reduces wait for GPU uploads in the main thread. Async Texture Upload will automatically be used for all Textures that are not read-write enabled, so to use this feature no direct action is required. You can however control some aspects of how the async upload operates, and so some understanding of the process is useful to be able to use these controls.
AUP支持从磁盘异步加载纹理数据,并支持在渲染线程上以时间片方式把纹理数据上传到GPU。这减少了纹理数据从主线程上传到GPU的等待时间。AUP将自动用于所有未启用读写的纹理,因此使用此功能不需要直接操作。不过,您可以控制AUP的一些参数,因此了解其过程有助于使用这些参数。

When the project is built, the texture data of asynchronous uploadable textures are stored in as streaming resource files and are loaded asynchronously.
在构建项目时,异步可上传纹理的纹理数据作为流资源文件存储并用于异步加载。

Simple & Full Control Over Memory / Time-Slicing 简单并全面由内存和时间片控制

A single ring-buffer is reused to load the texture data and upload it to the GPU, which reduces the amount of memory allocations required. For example, if you have 20 small textures, Unity will set up an asynchronous load request for those 20 textures in one go. If you have one huge texture, Unity will request only one.
一个环形缓冲区被重用来加载纹理数据并上传到GPU,这减少了所需的内存分配量。例如,如果你有20个小纹理,Unity会一次性为这20个纹理建立一个异步加载请求。如果你有一个巨大的纹理,那Unity只请求加载一个。

If the buffer size is not large enough for the textures being requested, it will automatically resize to accomodate, however it is always optimal to try to set the size to fit the largest sized texture that you will be uploading from the outset, so that the buffer does not need to resize for each new larger texture it encounters.
如果可请求的纹理缓冲区大小不足够大,它会自动调整适应,然而它总是设置大小为最大的纹理大小以作为最优的内存占用,这是从一开始上传就开始调整的,所以缓冲不需要为每个新遇到的更大的纹理而调整。

The time spent on texture upload each frame can be controlled, with larger values meaning the textures will become ready on the GPU sooner but with the overhead of more CPU time being used during those frames for other processing. This CPU time is only used if there are textures waiting in the buffer to be uploaded to the GPU.
花在每帧纹理上传的时间是可以被控制的,更大的值意味着纹理数据将会在GPU上更快地就绪,但这些帧的占用导致用于其他处理的CPU时间开销会更大。这个CPU时间只在缓存中有纹理数据等待上传到GPU时才会持续占用。

The size of the buffer and time-slice can be specified through the Quality settings:
缓冲区大小和时间片可以通过Quality设置来指定:
在这里插入图片描述
The Async Upload settings in the Quality settings

Async Texture Upload Scripting API AUP的脚本API

We provide the ability to control the Buffer Size and the Time-Slice value from script.
我们提供了从脚本控制 缓冲区大小 和 时间片值 的功能。

Time-Slice

Sets the Time-Slice in milliseconds for CPU time spent on Asynchronous Texture Uploads per frame. Depending on the target platform and API, you may want to set this. Time is only spent on the function call if there are textures to upload, otherwise it early-exits.
设置每帧用于AUP的CPU时间片(以毫秒为单位)。根据目标平台和API的不同,您可能需要设置这个参数。只有当要上传纹理时,才会耗费时间在AUP的函数调用上,否则它会提前退出。

Buffer Size

Set the Ring Buffer Size for Asynchronous Texture Uploads. The size is in mega-bytes. Ensure that you set a reasonable size depending on the Target platform. Also please ensure that it is always sufficient to load any huge texture in your games. For example if you have a Cubemap of size 22MB and if you set the size of the RingBuffer to 16MB, the App will automatically resize the Ringbuffer to 22MB while loading that scene.
设置AUP的环形缓冲区大小。大小以MB为单位。确保根据目标平台设置合理的大小。此外,请确保它总是足够加载任何巨大的纹理在您的游戏。例如,如果您有一个22MB大小的Cubemap,并且将RingBuffer的大小设置为16MB,那么在加载该场景时,应用程序将自动将RingBuffer的大小调整为22MB。

Notes

For non-read/write enabled textures, the TextureData is part of resS (Streaming Resource) and upload now happens on Render-Thread. Availability of Texture is guaranteed during call to AwakeFromLoad just as before, so there are no changes in terms of order of loading or availability of Textures on Rendering.
对于非 读/写 的纹理,TextureData作为resS(流资源)的一部分,现在可以在渲染线程上进行上传。纹理的可用性在调用AwakeFromLoad时就得到了保证,就像以前一样,因此在加载顺序或渲染时纹理的可用性方面没有变化。

For other types of texture loading, such as read/write enabled textures, textures loaded directly with the LoadImage(byte[] data) function, or loading from the Resources folder, the Asynchronous buffer loading is not used - the older Synchronous method is used.
对于其他类型的纹理加载,比如支持 读/写 的纹理,直接用LoadImage(byte[] data)函数加载的纹理,或者从Resources文件夹加载的纹理,都不会用AUP加载而是使用旧的同步方法。

这篇关于Asynchronous Texture Upload 异步贴图上传 AUP(Async Upload Pipeline) Advanced Rendering Features系列之一的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/309986

相关文章

基于Python编写一个git自动上传的脚本(打包成exe)

《基于Python编写一个git自动上传的脚本(打包成exe)》这篇文章主要为大家详细介绍了如何基于Python编写一个git自动上传的脚本并打包成exe,文中的示例代码讲解详细,感兴趣的小伙伴可以跟... 目录前言效果如下源码实现利用pyinstaller打包成exe利用ResourceHacker修改e

input的accept属性让文件上传安全高效

《input的accept属性让文件上传安全高效》文章介绍了HTML的input文件上传`accept`属性在文件上传校验中的重要性和优势,通过使用`accept`属性,可以减少前端JavaScrip... 目录前言那个悄悄毁掉你上传体验的“常见写法”改变一切的 html 小特性:accept真正的魔法:让

java对接Pinata上传文件到IPFS全过程

《java对接Pinata上传文件到IPFS全过程》本文详细介绍了如何使用PinataAPI将文件上传到IPFS网络,首先登录Pinata官网并生成JWT令牌,然后在项目中导入OkHttp依赖并编写代... 目录1.登录2.生成令牌3.导入依赖4.编写代码5.调用接口调试China编程代码总结Pinata调用AP

Python爬虫HTTPS使用requests,httpx,aiohttp实战中的证书异步等问题

《Python爬虫HTTPS使用requests,httpx,aiohttp实战中的证书异步等问题》在爬虫工程里,“HTTPS”是绕不开的话题,HTTPS为传输加密提供保护,同时也给爬虫带来证书校验、... 目录一、核心问题与优先级检查(先问三件事)二、基础示例:requests 与证书处理三、高并发选型:

Python使用FastAPI实现大文件分片上传与断点续传功能

《Python使用FastAPI实现大文件分片上传与断点续传功能》大文件直传常遇到超时、网络抖动失败、失败后只能重传的问题,分片上传+断点续传可以把大文件拆成若干小块逐个上传,并在中断后从已完成分片继... 目录一、接口设计二、服务端实现(FastAPI)2.1 运行环境2.2 目录结构建议2.3 serv

Python一次性将指定版本所有包上传PyPI镜像解决方案

《Python一次性将指定版本所有包上传PyPI镜像解决方案》本文主要介绍了一个安全、完整、可离线部署的解决方案,用于一次性准备指定Python版本的所有包,然后导出到内网环境,感兴趣的小伙伴可以跟随... 目录为什么需要这个方案完整解决方案1. 项目目录结构2. 创建智能下载脚本3. 创建包清单生成脚本4

SpringBoot+RustFS 实现文件切片极速上传的实例代码

《SpringBoot+RustFS实现文件切片极速上传的实例代码》本文介绍利用SpringBoot和RustFS构建高性能文件切片上传系统,实现大文件秒传、断点续传和分片上传等功能,具有一定的参考... 目录一、为什么选择 RustFS + SpringBoot?二、环境准备与部署2.1 安装 RustF

SpringBoot实现不同接口指定上传文件大小的具体步骤

《SpringBoot实现不同接口指定上传文件大小的具体步骤》:本文主要介绍在SpringBoot中通过自定义注解、AOP拦截和配置文件实现不同接口上传文件大小限制的方法,强调需设置全局阈值远大于... 目录一  springboot实现不同接口指定文件大小1.1 思路说明1.2 工程启动说明二 具体实施2

Python异步编程之await与asyncio基本用法详解

《Python异步编程之await与asyncio基本用法详解》在Python中,await和asyncio是异步编程的核心工具,用于高效处理I/O密集型任务(如网络请求、文件读写、数据库操作等),接... 目录一、核心概念二、使用场景三、基本用法1. 定义协程2. 运行协程3. 并发执行多个任务四、关键

C#异步编程ConfigureAwait的使用小结

《C#异步编程ConfigureAwait的使用小结》本文介绍了异步编程在GUI和服务器端应用的优势,详细的介绍了async和await的关键作用,通过实例解析了在UI线程正确使用await.Conf... 异步编程是并发的一种形式,它有两大好处:对于面向终端用户的GUI程序,提高了响应能力对于服务器端应