0

I'm implementing camera filter application using GLES like GPUImage on mobile devices.

In order to create final filtered image, need to render sub-filters on the previously filtered image. My approach is to create multiple FBOs for each filter step.

For example, If i use three filters to get final result then create 3 FBOs. Bind FBO1 and draw, next bind FBO2 using FBO1 texture draw and so on.

However, since I don't need FBO1's content when I draw on to FBO3 using FBO2 texture, if I re-use FBO1 instead FBO3 then I don't need to create many FBOs.

I'm not sure which one would better or any performance benefit, just create multiple FBOs for each filter step? or switching between first and second FBOs. Thanks in advance.

I show some code example..

glBindFramebuffer(fbo1);
glClear();
glBindTexture(camera-texture);
draw();

glBindFramebuffer(fbo2);
glClear();
glBindTexture(fbo1-texture);
draw();

glBindFramebuffer(fbo3);
glClear();
glBindTexture(fbo2-texture);
draw();

...

or

If i swtich FBOs..

glBindFramebuffer(fbo1);
glBindTexture(camera-texture);
glClear();
draw();

glBindFramebuffer(fbo2);
glClear();
glBindTexture(fbo1-texture);
draw();

glBindFramebuffer(fbo1);
glClear();
glBindTexture(fbo2-texture);
draw();

...
kju
  • 123
  • 9

1 Answers1

0

For performance, I doubt it really makes any difference - you're doing the same number of API calls.

The big difference is likely to be memory footprint - cycling between a small number of FBOs and so reusing their attachments multiple times within a single frame, will reduce the total number of surfaces you need allocated compared to a scheme where you have unique attachments per render pass.

solidpixel
  • 10,688
  • 1
  • 20
  • 33