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 中的异步与同步深度解析(实践记录)

《Python中的异步与同步深度解析(实践记录)》在Python编程世界里,异步和同步的概念是理解程序执行流程和性能优化的关键,这篇文章将带你深入了解它们的差异,以及阻塞和非阻塞的特性,同时通过实际... 目录python中的异步与同步:深度解析与实践异步与同步的定义异步同步阻塞与非阻塞的概念阻塞非阻塞同步

Java 中实现异步的多种方式

《Java中实现异步的多种方式》文章介绍了Java中实现异步处理的几种常见方式,每种方式都有其特点和适用场景,通过选择合适的异步处理方式,可以提高程序的性能和可维护性,感兴趣的朋友一起看看吧... 目录1. 线程池(ExecutorService)2. CompletableFuture3. ForkJoi

Python异步编程中asyncio.gather的并发控制详解

《Python异步编程中asyncio.gather的并发控制详解》在Python异步编程生态中,asyncio.gather是并发任务调度的核心工具,本文将通过实际场景和代码示例,展示如何结合信号量... 目录一、asyncio.gather的原始行为解析二、信号量控制法:给并发装上"节流阀"三、进阶控制

Redis中管道操作pipeline的实现

《Redis中管道操作pipeline的实现》RedisPipeline是一种优化客户端与服务器通信的技术,通过批量发送和接收命令减少网络往返次数,提高命令执行效率,本文就来介绍一下Redis中管道操... 目录什么是pipeline场景一:我要向Redis新增大批量的数据分批处理事务( MULTI/EXE

Java实现数据库图片上传与存储功能

《Java实现数据库图片上传与存储功能》在现代的Web开发中,上传图片并将其存储在数据库中是常见的需求之一,本文将介绍如何通过Java实现图片上传,存储到数据库的完整过程,希望对大家有所帮助... 目录1. 项目结构2. 数据库表设计3. 实现图片上传功能3.1 文件上传控制器3.2 图片上传服务4. 实现

使用mvn deploy命令上传jar包的实现

《使用mvndeploy命令上传jar包的实现》本文介绍了使用mvndeploy:deploy-file命令将本地仓库中的JAR包重新发布到Maven私服,文中通过示例代码介绍的非常详细,对大家的学... 目录一、背景二、环境三、配置nexus上传账号四、执行deploy命令上传包1. 首先需要把本地仓中要

Java实现数据库图片上传功能详解

《Java实现数据库图片上传功能详解》这篇文章主要为大家详细介绍了如何使用Java实现数据库图片上传功能,包含从数据库拿图片传递前端渲染,感兴趣的小伙伴可以跟随小编一起学习一下... 目录1、前言2、数据库搭建&nbsChina编程p; 3、后端实现将图片存储进数据库4、后端实现从数据库取出图片给前端5、前端拿到

Spring Boot 中正确地在异步线程中使用 HttpServletRequest的方法

《SpringBoot中正确地在异步线程中使用HttpServletRequest的方法》文章讨论了在SpringBoot中如何在异步线程中正确使用HttpServletRequest的问题,... 目录前言一、问题的来源:为什么异步线程中无法访问 HttpServletRequest?1. 请求上下文与线

在 Spring Boot 中使用异步线程时的 HttpServletRequest 复用问题记录

《在SpringBoot中使用异步线程时的HttpServletRequest复用问题记录》文章讨论了在SpringBoot中使用异步线程时,由于HttpServletRequest复用导致... 目录一、问题描述:异步线程操作导致请求复用时 Cookie 解析失败1. 场景背景2. 问题根源二、问题详细分

Vue ElementUI中Upload组件批量上传的实现代码

《VueElementUI中Upload组件批量上传的实现代码》ElementUI中Upload组件批量上传通过获取upload组件的DOM、文件、上传地址和数据,封装uploadFiles方法,使... ElementUI中Upload组件如何批量上传首先就是upload组件 <el-upl