问题
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