About capturing frame buffer data to file when rendering

EnergyForm

Newcomer
Every game which use Direct3D or OpenGL has this kind of front frame buffer data update routine. This is very simple example of it.

Renders frame->copy/flip final frame data to front frame buffer->loop this whole process again.

Here comes my question. Is this possible to do?

Renders frame->copy/flip final frame data to front frame buffer->external program can pause this process and copy front frame buffer data to file->loop this whole process again.

I'm newbie in programming and other things but can videocard somehow force program to wait before start to render another frame? Probably programs have some check which checks, has videocard finished rendering single frame before loops again? So it could be possible to delay rendering with modified videocard drivers and prevent program to use frame skipping? I really don't know. :?

It just would had been great to make smooth 30FPS movies from heavy demos. 8)
 
It's not a vid card driver thing as most PC apps/games do not use buffer swaping as the timing system. They use OS calls for timing. Vsync sort of does what you want though. You can use swap interval settings to force the vid card to wait a certain number of refersh periods before buffer swapping. If a 60Hz refersh rate is used, and a swap interval of 2 is used, then you will updates at a max of 30 FPS. Problem with this is just that you can still get slow down, and with Direct3D drivers I haven't personally seen a driver that allows any swap interval setting other than 0 and 1.
 
So is there way to modify that Vsync feature this way: It slows down frame rate to 1-5 fps and no frame skipping so program will render frames like in slow motion? Then my slow hard drive would be quick enough to capture front frame buffer each updated data to files? Like similar to 3DMark03 Pro image quality feature does. I consider to make videos from heavy demos but for example Fraps capture program require fast hard drive and I get frame skipping if I capture in real-time. And sometimes in heavy demos frame rate drops below 30 fps and then it's not worth to make video in real-time.
 
One of the problems is that generally 3d apps are time based. So they will figure out how long it took to render/flip a frame and will adjust the motion accordingly.

One idea (I don't know if this will work!)
You could intercept the flip function in the HAL
(check out http://research.microsoft.com/sn/detours for an easy way to do this)
When your replacement flip function gets called you would first have to get the system timer, do your frame dumping and then reset the timer so that is looks like your function took no time, before calling the HAL flip function.

For details of the driver flip function check out the Directx DDK at http://msdn.microsoft.com



Have fun,
CC
 
Back
Top