在OpenGL中处理FBO的最佳方法是什么? [英] What is the best way to handle FBOs in OpenGL?

查看:337
本文介绍了在OpenGL中处理FBO的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道很长一段时间以来,处理OpenGL FrameBuffer对象(FBO)的最佳方法是什么. 切换FBO的成本可能很高,但也要定义新的附件.

I wonder since a long time what would be the best way to handle OpenGL FrameBuffer Objects (FBO). Switching FBOs can be costly but defining new attachments too.

您如何做到快速?

我在这3个之间犹豫不决:

I hesitate between these 3:

  • 1个FBO用于所有东西,更改附件,但不要在FBO之间切换

  • 1 FBO for everything, change attachment but don't switch between FBOs

1 FBO.这意味着我将对相同的渲染目标重复使用相同的FBO.但是通过这种方式,自定义模糊将花费4个以上的FBO.

1 FBO for each render target (size + format) in the rendering path. That means i will reuse the same FBO for similar render targets. But this way a custom blur would cost 4+ FBOs.

每个渲染目标1个FBO,仅设置一次附件,然后在FBO之间切换

1 FBO for each render target, set attachments only once and then switch between FBOs

此外,我是否应该最小化FBO开关的数量(如我最小化纹理绑定的数量)?

Also, should I minimize the number of FBO switches (like I minimize the number of texture bindings) ?

推荐答案

更新的参考文献:

  • NVIDIA 2016 (?): Use multiple FBOs
  • intel 2016: Use multiple FBOs

NVIDIA 2005(可能已过时): 据我所知,NVIDIA最新的官方性能建议已经有将近五年的历史了.西蒙·格林(Simon Green)在他的 GDC演示中建议以下内容(幻灯片29):

NVIDIA 2005 (probably outdated): The last official performance recommendation by NVIDIA I know is almost five years old. In his GDC presentation, Simon Green recommends the following (slide 29):

按照性能提高的顺序:

In order of increasing performance:

  1. 多个FBO
    • 为要渲染到的每个纹理创建一个单独的FBO
    • 使用BindFramebuffer()
    • 进行切换
    • 可能比beta版NVIDIA驱动程序中的wglMakeCurrent()快2倍
  1. Multiple FBOs
    • create a separate FBO for each texture you want to render to
    • switch using BindFramebuffer()
    • can be 2x faster than wglMakeCurrent() in beta NVIDIA drivers
  • 纹理应具有相同的格式和尺寸
  • 使用FramebufferTexture()在纹理之间切换
  • textures should have same format and dimensions
  • use FramebufferTexture() to switch between textures
  • 将纹理附加到不同的颜色附件
  • 使用glDrawBuffer()将渲染切换为不同的颜色附件
  • attach textures to different color attachments
  • use glDrawBuffer() to switch rendering to different color attachments

以我的经验,第二种情况确实比第一种情况(ATI Radeon HD4850,Geforce 8800GT)快.我没有尝试过第三种情况,因为这会使我的代码复杂化.

In my experience, the second case is really faster than the first (ATI Radeon HD4850, Geforce 8800GT). I've not tried the third case, as it would have complicated my code.

这篇关于在OpenGL中处理FBO的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆