OpenGL:在帧中回收帧缓冲区会影响性能吗?
OpenGL: Will recycling a Framebuffer in a frame hurt performance?
Framebuffer 不在片段着色器中被绘制和采样之间频繁切换对 GPU 性能很重要吗?我可以通过在单个帧中回收帧缓冲区来节省视频内存,但我担心它可能会阻碍 GPU 在 FBO 写入不依赖于彼此时可能进行的一些并行优化,或者只是以其他方式代价高昂。
背景:
在我的渲染器中,我在当前帧中分配我需要的所有帧缓冲区,如果可能的话重用前一帧,并以这种方式使用它们:
FBO_0, FBO_1, FBO_n are allocated (FBO_n is the final output)
FBO_0 bind ]_____________________
FBO_0 drawn to ] \
FBO_n bind \
FBO_0 color used as a texture Could the GPU be doing these two tasks
FBO_n drawn to with this texture in parallel thanks to them using seperate FBO?
/
FBO_1 bind ]_____________________/
FBO_1 drawn to ]
FBO_n bind
FBO_1 color used as a texture
FBO_n drawn to with this texture
虽然在这种情况下,可以回收 FBO_0 充当 FBO_1,减少我需要的整体视频内存。这在实践中有点复杂,需要大量重构,所以我正在研究这是否会对性能产生不利影响并且值得这样做。
只用FBO_0和FBO_n就可以了,比如:
FBO_0 bind
FBO_0 drawn data1
FBO_n bind
FBO_0 color used as a texture
FBO_n drawn to with this texture
FBO_0 bind
FBO_0 drawn data2
FBO_n bind
FBO_0 color used as a texture
FBO_n drawn to with this texture
一般来说,如果您写入一个对象,您以后发出的任何命令都会看到新值。
少数例外情况可以在这个 wiki 中找到:
https://www.khronos.org/opengl/wiki/Memory_Model
但最快的方法在很大程度上取决于 OpenGL 的实现。
在您的示例中,由于第一个 "FBO_n draw" 取决于 FBO_0 绘制的完成,实施可能会并行开始 FBO_1 绘制。但是你没有那个保证。
Framebuffer 不在片段着色器中被绘制和采样之间频繁切换对 GPU 性能很重要吗?我可以通过在单个帧中回收帧缓冲区来节省视频内存,但我担心它可能会阻碍 GPU 在 FBO 写入不依赖于彼此时可能进行的一些并行优化,或者只是以其他方式代价高昂。
背景:
在我的渲染器中,我在当前帧中分配我需要的所有帧缓冲区,如果可能的话重用前一帧,并以这种方式使用它们:
FBO_0, FBO_1, FBO_n are allocated (FBO_n is the final output)
FBO_0 bind ]_____________________
FBO_0 drawn to ] \
FBO_n bind \
FBO_0 color used as a texture Could the GPU be doing these two tasks
FBO_n drawn to with this texture in parallel thanks to them using seperate FBO?
/
FBO_1 bind ]_____________________/
FBO_1 drawn to ]
FBO_n bind
FBO_1 color used as a texture
FBO_n drawn to with this texture
虽然在这种情况下,可以回收 FBO_0 充当 FBO_1,减少我需要的整体视频内存。这在实践中有点复杂,需要大量重构,所以我正在研究这是否会对性能产生不利影响并且值得这样做。
只用FBO_0和FBO_n就可以了,比如:
FBO_0 bind
FBO_0 drawn data1
FBO_n bind
FBO_0 color used as a texture
FBO_n drawn to with this texture
FBO_0 bind
FBO_0 drawn data2
FBO_n bind
FBO_0 color used as a texture
FBO_n drawn to with this texture
一般来说,如果您写入一个对象,您以后发出的任何命令都会看到新值。
少数例外情况可以在这个 wiki 中找到:
https://www.khronos.org/opengl/wiki/Memory_Model
但最快的方法在很大程度上取决于 OpenGL 的实现。
在您的示例中,由于第一个 "FBO_n draw" 取决于 FBO_0 绘制的完成,实施可能会并行开始 FBO_1 绘制。但是你没有那个保证。