Jump to content
  • Advertisement
Sign in to follow this  
Desperado

OpenGL GPGPU Multipass Rendering FAST

This topic is 4446 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hallo folks I'm currently writing my diploma thesis and an important part of it considers image processing via the OpenGL and the NVidia Cg API. What I basically need to do is take an image from memory and manipulate it with a fragment-program multiple times. Every step takes as input the image from the last step. To achieve this, I currently take the common approach of rendering a quad to the framebuffer that uses the image as texture. Then I read the result to another texture using glCopyTexImage2D. However, the problem ist I need to do this very often (about 400 times) and doing that many rendering passes takes a lot of time (1.2 Seconds on a Radeon 9800). My question is: Is there a faster way of doing multiple rendering passes where each pass has access to the full output image of the last pass? Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
The solution is not to render to the framebuffer, but to render directly to a texture, bind it and use in the next pass. The older (but maybe more widely supported) way is to use pbuffers (WGL_ARB_pbuffer) with the render-texture extension WGL_ARB_render_texture . As you may have noted, this is not cross-platform.

The newer way of doing this is with cross-platform framebuffer objects (GL_EXT_framebuffer_object) and as bonus they are also more easy to set up and use than pbuffers.

Share this post


Link to post
Share on other sites
The framebuffer object method reduced the computation time by about a half.
Thank you for that suggestion.
However, it still takes more than 0.5 seconds and I need to push it down to less
than 0.1 seconds.

Can you tell me what takes generally most of the time of a rendering pass?
Maybe I could raise the number of PU instructions in the fragment program
and reduce the number of passes.

If you don't have some other hints that is...

Share this post


Link to post
Share on other sites
Check out the performance docs at the nvidia dev site (there are a lot [smile]) - they explain hw to profile your app and find the bottleneck. Apart from this you can also try using a profiler such as gDEbugger.

If you ask me, I don't think any number of shader cycles within the instruction limit will hurt you more than an extra pass. Take this with a grain (very large grain!) of salt though as it's coming from someone whose video card doesn't even support fragment shaders!

If your scene is complex, you might benefit by laying down a depth pass first so that hidden fragments are discarded early.

// depth pass
glDepthMask(1);
glColorMask(0, 0, 0, 0);
draw_scene();

// your passes
glDepthMask(0);
glColorMask(1, 1, 1, 1);
draw_pass1();
draw_pass2();
// ...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!