OGRECave/ogre-next

How to know when rendering to texture is done

Opened this issue · 2 comments

Hello. I would like to ask, in ogre, how do I know that the current frame has been rendered by the gpu? For example, when I render to the texture, how do I know that the GPU has finished rendering, and I need to sample it back to do other processing at this time. I tried Ogre::FrameListener, but frameRenderingQueued doesn't sync gpu rendering complete event

Hi!

Depending on what you want do:

To answer your question specifically: See VaoManager::getFrameCount, VaoManager::waitForSpecificFrameToFinish and VaoManager::isFrameFinished

What I suspect you probably want: If you want to download the data back for processing, you can use an AsyncTextureTicket. See the manual.

The code in Image2::copyContentsToMemory and Image2::convertFromTexture show how to deal with every single edge case.

When you call asyncTicket->map( ... ) it will stall until the rendering & transfer to CPU is done. If you do not wish to stall, you can call asyncTicket->queryIsTransferDone() to see if it's done transferring. If it returns true, asyncTicket->map( ... ) will return immediately.

The most efficient way to do it (e.g. video streaming) is to wait vaoManager->getDynamicBufferMultiplier() frames (e.g. if it returns 2, download() the data immediately but call map/queryIsTransferDone after the next time frameRenderingQueued gets called, if it returns 3, wait another frameRenderingQueued call).

Hi!
I don't want to copy data from the gpu back to the cpu, I just want to strictly control the frame rate. For example, I have an external program that uses shared texture technology. I set this texture as a rendering texture in the ogre application. I want to know when ogre finishes rendering this frame. Because after rendering, my ogre application will notify the external program to process this frame. After the external program has finished processing, it will tell the ogre program. At this time, the ogre program will start rendering the next frame, and so on. But I found that ogre's rendering is performed asynchronously, and I don't want to spend the cost of copying data every time I render synchronously
If ogre provides such a method, please let me know, thank you very much