IDirect3DDevice9 D3DPOOL_MANAGED

Started by
5 comments, last by Muhammad Haggag 18 years, 10 months ago
someone told me if deivce is deleted.and the all data is lost.like mesh tex etc... but I want to know why ? the mesh is placed on vertexbuffer. the texture is placed on IDirect3DTexture9 so what is relation between IDirect3DDevice9 and mesh ,texture ,and material ,light etc. If the data is placed at D3DPOOL_MANAGED so these are still exist,if device is deleted. so If I create a new device ,I can directly use previouse vertexbuffer pointer ,don't need to do anythingelse for restore?
Advertisement
The D3D device is an abstraction of the graphics card. One D3DDevice has no relation to another, since you could have two graphics cards in one machine. If that was the case, then you could create one D3DDevice for each card, and you wouldn't be able to share memory between the two cards (It'd be horrible slow to do so), so the data on one device cannot be accessed by another. It's the same with HAL / REF devices, the reference device is software based, and the HAL device is hardware based.

If you delete your device, then all of the resources associated with it need to be cleaned up too, even in the managed pool.
When you create a resource in the managed pool, D3D creates two copies of it. One copy it places in video memory (Well, in D3DPOOL_DEFAULT), and one copy it places in system memory. If video memory runs low, D3D swaps resources around to accomodate. If the device is lost (not deleted) then D3D uses the system memory copy to recreate the resource after the device is reset.

When a device is lost, it's usually because another application has requested access to the HAL. When that happens, D3D has to empty video memory so there's room for the new application. That's why all of your non-managed resources get lost. The video memory copy of the managed resources are also lost.
When a device is reset, D3D empties out the video memory from the other app, and allows you to recreate your resources. The managed resources are created automatically by D3D, using the system memory copies it has.

To summarise: If you delete (Release()) a device, you lose everything it contains, in the same way that if you bulldoze a house, you'll lose all of the furniture in it.
So if you were to create a texture with the default pool and the device is reset it your responsibility to reload it. But if you used the managed pool you can just assume its ready to be used?

Also when you detect the device has been lost, should you release textures created with the managed pool?
Go on an Intense Rampage
Quote:Original post by Graham
So if you were to create a texture with the default pool and the device is reset it your responsibility to reload it. But if you used the managed pool you can just assume its ready to be used?
Yup. That's the advantage of the managed pool. However, there are some situations where you want to stick with the default pool, for example for dynamic vertex buffers; you just fill them and send them off to the card. Having a system memory copy would be pointless.

Quote:Original post by Graham
Also when you detect the device has been lost, should you release textures created with the managed pool?
Nope, only resources created in the default pool. D3D will release the video memory copy of managed resources automatically.
I see,if a device lost,so D3D will empty all data on video.
when device lost ,the data lost too.because D3D delelte it,not because data is placed device.
How do the professional game developers do it? Do they use MANAGED at all, or do they use DEFAULT and write their own resource managers?
Quote:Original post by kosmon_x
How do the professional game developers do it? Do they use MANAGED at all, or do they use DEFAULT and write their own resource managers?

Use MANAGED when possible, DEFAULT when you have to. You don't have enough information to write a good resource manager. Basically, you can't even know whether a resource you've created is in video or AGP memory, all you can do is hint. So you leave that to the runtime and the driver.

This topic is closed to new replies.

Advertisement