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

相关文章

GitLab文件的上传与下载方式

《GitLab文件的上传与下载方式》:本文主要介绍GitLab文件的上传与下载方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录GitLab 项目拉取到本地GitLab 项目上传方法方法 1:本地项目未初始化Git方法 2:本地项目已初始化GitGitLab 上

Nginx 413修改上传文件大小限制的方法详解

《Nginx413修改上传文件大小限制的方法详解》在使用Nginx作为Web服务器时,有时会遇到客户端尝试上传大文件时返回​​413RequestEntityTooLarge​​... 目录1. 理解 ​​413 Request Entity Too Large​​ 错误2. 修改 Nginx 配置2.1

Java应用如何防止恶意文件上传

《Java应用如何防止恶意文件上传》恶意文件上传可能导致服务器被入侵,数据泄露甚至服务瘫痪,因此我们必须采取全面且有效的防范措施来保护Java应用的安全,下面我们就来看看具体的实现方法吧... 目录恶意文件上传的潜在风险常见的恶意文件上传手段防范恶意文件上传的关键策略严格验证文件类型检查文件内容控制文件存储

Java实现MinIO文件上传的加解密操作

《Java实现MinIO文件上传的加解密操作》在云存储场景中,数据安全是核心需求之一,MinIO作为高性能对象存储服务,支持通过客户端加密(CSE)在数据上传前完成加密,下面我们来看看如何通过Java... 目录一、背景与需求二、技术选型与原理1. 加密方案对比2. 核心算法选择三、完整代码实现1. 加密上

在React聊天应用中实现图片上传功能

《在React聊天应用中实现图片上传功能》在现代聊天应用中,除了文字和表情,图片分享也是一个重要的功能,本文将详细介绍如何在基于React的聊天应用中实现图片上传和预览功能,感兴趣的小伙伴跟着小编一起... 目录技术栈实现步骤1. 消息组件改造2. 图片预览组件3. 聊天输入组件改造功能特点使用说明注意事项

Python 异步编程 asyncio简介及基本用法

《Python异步编程asyncio简介及基本用法》asyncio是Python的一个库,用于编写并发代码,使用协程、任务和Futures来处理I/O密集型和高延迟操作,本文给大家介绍Python... 目录1、asyncio是什么IO密集型任务特征2、怎么用1、基本用法2、关键字 async1、async

嵌入式Linux驱动中的异步通知机制详解

《嵌入式Linux驱动中的异步通知机制详解》:本文主要介绍嵌入式Linux驱动中的异步通知机制,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录前言一、异步通知的核心概念1. 什么是异步通知2. 异步通知的关键组件二、异步通知的实现原理三、代码示例分析1. 设备结构

Redis Pipeline(管道) 详解

《RedisPipeline(管道)详解》Pipeline管道是Redis提供的一种批量执行命令的机制,通过将多个命令一次性发送到服务器并统一接收响应,减少网络往返次数(RTT),显著提升执行效率... 目录Redis Pipeline 详解1. Pipeline 的核心概念2. 工作原理与性能提升3. 核

Redis消息队列实现异步秒杀功能

《Redis消息队列实现异步秒杀功能》在高并发场景下,为了提高秒杀业务的性能,可将部分工作交给Redis处理,并通过异步方式执行,Redis提供了多种数据结构来实现消息队列,总结三种,本文详细介绍Re... 目录1 Redis消息队列1.1 List 结构1.2 Pub/Sub 模式1.3 Stream 结

springboot上传zip包并解压至服务器nginx目录方式

《springboot上传zip包并解压至服务器nginx目录方式》:本文主要介绍springboot上传zip包并解压至服务器nginx目录方式,具有很好的参考价值,希望对大家有所帮助,如有错误... 目录springboot上传zip包并解压至服务器nginx目录1.首先需要引入zip相关jar包2.然