Fast copy between two FBO(s) or from FBO to Texture in OpenGL-ES 1.1

China☆狼群 提交于 2021-01-29 07:25:57

问题


Greetings.

My goal is to implement a pipeline for processing video frames that has a "current" and "previous" frame. It needs to copy a subregion from the "previous" frame into the "current" frame on some occasions. This is a kind of decoder which is part of a larger application.

This is what I have running so far, on the iPhone using OpenGL-ES 1.1

                            glCopyTexSubImage2D
                        .--------------------\
  glTexSubImage2D       V     glDrawArray    |

image --------------------------> Texture --------------> FBO/Texture -------> render buffer

The Texture gets each new frame or partial frame updated as usual. The Texture is drawn into the frame buffer object and eventually rendered.

These parts perform very nicely.

The problem is the glCopyTexSubImage2D, which profiled using Instruments shows that it takes about 50% of the CPU; it looks like it's doing the copy using the CPU. Yuck.

Before I post the code (and I will happily do that), I wanted to ask if this architecture is sound?

The next phase of the project is share the final FBO/Texture with another GL context to render to an external screen. I've read other posts here about the delicate nature of shared resources.

Thanks for any guidance.

Cheers, Chris

P.S. I had some trouble getting the diagram to look right. The back-flow line should go from the FBO/Texture node to the Texture node.


回答1:


glCopyTexImage*D and glGetTexImage*D is know to be slow as hell, no matter what platform you're on.

To replace glCopyTexSubImage2D you could just add another FBO/Texture and render the other texture you want to copy into it, then you can get the texture from the FBO. I'm not sure It'll be faster but it should be.

                           Render to FBO
                       .--------------------\
 glTexSubImage2D       V     glDrawArray    |

image --------------------------> FBO/Texture --------------> FBO/Texture -------> render buffer



来源:https://stackoverflow.com/questions/5226990/fast-copy-between-two-fbos-or-from-fbo-to-texture-in-opengl-es-1-1

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!