Jump to content
  • Advertisement
Sign in to follow this  
Grumple

Further rendering after a call to glFinish?

This topic is 3078 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

Hello,

I have a situation where I need to partially render a frame to the back buffer, copy the resultant back buffer contents to a raster image 'cache', then perform further (ie UI) rendering to the back buffer within the same frame. Once this is done I just do a normal swapbuffer() call.

This all seems to work fine (I have tested it a fair amount), but I had a video related crash the other day that got me wondering if this approach could cause problems (I have no real reason at this point to think this was actually the cause).

My general render flow would be:

- clear depth/color buffers
- render some geometry through vbo/ibo
- glFinish()
- glCopyTexSubImage2D() (to a raster buffer)
- render some additional overlay data to back buffer
- SwapBuffers()

Can anyone provide any insight into this? Should I be looking at alternative ways to implement this 'layered' render?

Cheers!

Share this post


Link to post
Share on other sites
Advertisement
What do you need the 'raster buffer' for?

BTW I do a similar stuff in a renderer, and I have no problems with it.

But I think you don't even need the glFinish(), since glCopyTexSubImage2D flushes the render anyway (AFAIK). Did you try not using glfinish?

Anyway, many will argue against flushing the thing in the middle of the render, so I guess there are better ways to do what you want to do.

Share this post


Link to post
Share on other sites
glFinish just flushes buffered-up commands, so it's perfectly safe to call it anytime you want. You definitely shouldn't need it at all in this scenario; I've code that pretty much the very same as you're doing but doesn't use it.

Share this post


Link to post
Share on other sites
Quote:
Original post by Grumple
- clear depth/color buffers
- render some geometry through vbo/ibo
- glFinish()
- glCopyTexSubImage2D() (to a raster buffer)
- render some additional overlay data to back buffer
- SwapBuffers()

In practice, the results of this are undefined if something overlaps the rendering area, due to the pixel ownership test. In other words, if some other window opens over your rendering area, then the backbuffer copy will yield undefined pixel values.

Quote:
Original post by Grumple
Should I be looking at alternative ways to implement this 'layered' render?

Absolutely. Render everything into a cache texture using an FBO. Then you can do whatever you want with it. Not only is this a much more secure way (no undefined behaviour), it is also much faster as it doesn't require a copy.

Share this post


Link to post
Share on other sites
Thanks for the quick replies! It sounds like I can safely rule this out as the source of my problem.

Just to clarify, when I said I copy to a 'raster buffer' I should have specifically said a texture. =)

I did know about the FBO option, but have yet to take the time to experiment with them. Switching to using an FBO would likely involve a lot of changes to the code base I am working with and I don't have the bandwidth to do this and deal with any debugging fallout right now. Someday! ;)

I had the glFinish in place before glCopyTexSubImage2D just because it seemed like the 'correct' thing to do (didn't realize glCopyTexSubImage2D would essentially call this itself). A quick test of removing the call seems to have caused no problems...

Thanks again!

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!