简体   繁体   English

FBO深度缓冲区的纹理与存储

[英]Texture vs storage for FBO depth buffer

假设设备支持GL_OES_depth_texture扩展,则在将存储或纹理附加到FBO方面在性能或内存消耗方面是否有任何区别?

Your post is tagged with OpenGLES 2.0 which most likely means you're talking about mobile. 您的帖子标有OpenGLES 2.0,这很可能意味着您在谈论移动。

Many Android mobile GPUs and all iOS GPUs are based on Tile Based Deferred Renderers - in this design, the rendering is all done to small (eg 32x32) tiles using special fast on-chip memory. 许多Android移动GPU和所有iOS GPU都是基于“基于图块的延迟渲染器”的-在此设计中,渲染都是使用特殊的快速片上内存完成的(例如32x32)小图块。 In a typical rendering pass, with correct calls to glClear and glDiscardFramebufferEXT, there's no need for the device to ever have to copy depth buffer out from the on-chip memory into storage. 在典型的渲染过程中,通过正确调用glClear和glDiscardFramebufferEXT,设备无需将深度缓冲区从片上存储器复制到存储中。

However, if you're using a depth texture, then this copy is unavoidable. 但是,如果您使用的是深度纹理,则此副本是不可避免的。 The cost of transferring a screen-sized depth texture from on-chip memory into a texture is significant. 将屏幕大小的深度纹理从片上存储器转移到纹理中的成本非常高。 However, I'd expect the rendering costs of your draw calls during the render pass to be unaffected. 但是,我希望在渲染过程中进行绘制调用的渲染成本不会受到影响。

In terms of memory usage, it's a bit more speculative. 在内存使用方面,它更具推测性。 It's possible that a clever driver might not need to allocate any memory at all for a depth buffer on a TBDR GPU if you're not using a depth texture and you're using glClear and glDiscardFramebufferEXT correctly because at no point does your depth buffer have to be backed by any storage. 如果您没有使用深度纹理并且正确使用glClear和glDiscardFramebufferEXT,那么聪明的驱动程序可能根本不需要为TBDR GPU上的深度缓冲区分配任何内存,因为深度缓冲区根本没有由任何存储支持。 Whether drivers actually do that is internal to the driver's implementation and you would have to ask the driver authors (Apple/Imagination Technologies/ARM, etc). 驱动程序是否实际执行此操作是驱动程序实现的内部内容,因此您必须询问驱动程序作者(Apple / Imagination Technologies / ARM等)。

Finally, it may be the case that the depth buffer format has to undergo some reconfiguration to be usable as a depth texture which could mean it uses more memory and affect efficiency. 最后,可能的情况是深度缓冲区格式必须进行一些重新配置才能用作深度纹理,这可能意味着它使用更多的内存并影响效率。 I think that's unlikely though. 我认为这不太可能。

TLDR: Don't use a depth texture unless you actually need to, but if you do need one, then I don't think it will impact your rendering performance too much. TLDR:除非确实需要,否则不要使用深度纹理,但是如果确实需要深度纹理,那么我认为它不会对渲染性能产生太大影响。 The main cost is in the bandwidth of copying the depth data about. 主要成本在于复制深度数据的带宽。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM