How to get data from render-target when device is lost?

Started by
4 comments, last by IndakungWoo 12 years, 2 months ago
For resetting device after it was lost, all D3DPOOL_DEFAULT resources should be released. I want to restore some render-target textures after the device is reseted, so I'm trying to save their data to D3DPOOL_SYSTEMMEM texture when device is lost, but I cannot call IDirect3DDevice9::GetRenderTargetData successfully because the device was lost. The DX debug report says:

"Failing copy from video-memory surface to system-memory or managed surface because device is lost. UpdateSurface returns D3DERR_DEVICELOST"

Is there another way to restore the D3DPOOL_DEFAULT resources after a device losing?
Advertisement
Once you lose the device, you lose all of your render targets. You would have to copy the data before you lose the device.
Why not just re-render what was originally rendered into your render targets?

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.


Once you lose the device, you lose all of your render targets. You would have to copy the data before you lose the device.

Thank you. But how could the program predict the device's losing? Or just copy the data every frame? It seems not so efficient.


Why not just re-render what was originally rendered into your render targets?

Because those render targets are used for saving states of a GPU-based particle system. I think it'll be weird when all particles are disappeared or reseted at their initial position or other states after a device' losing.

Thank you. But how could the program predict the device's losing? Or just copy the data every frame? It seems not so efficient.


I don't think you can in a reliable manner. You can detect a focus change, but I don't know if the device will already be considered "lost" at that point.

If you want, you can detect if your app is running on Vista or Win7 and create D3D9Ex interfaces. If you use those, you won't get a lost device scenario. Doesn't help you for at all for XP, obviously.

[quote name='Indakung' timestamp='1329105128' post='4912460']
Thank you. But how could the program predict the device's losing? Or just copy the data every frame? It seems not so efficient.


I don't think you can in a reliable manner. You can detect a focus change, but I don't know if the device will already be considered "lost" at that point.

If you want, you can detect if your app is running on Vista or Win7 and create D3D9Ex interfaces. If you use those, you won't get a lost device scenario. Doesn't help you for at all for XP, obviously.
[/quote]
Thank you. As a matter of fact, losing device is not an usual thing, and I think most people would ignored the resetting of particles after that case, so I'd better ignore this problem too.

This topic is closed to new replies.

Advertisement