Archived

This topic is now archived and is closed to further replies.

D3DPOOL_MANAGED question

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

I'm still a bit confused with the D3D Framework library, specifically InitDeviceObjects(), RestoreDeviceObjects(), InvalidateDeviceObjects(), and DeleteDeviceObjects(). Within OneTimeSceneInit() I placed the following code: ----- if( FAILED(pd3dDevice->CreateVertexBuffer(sizeof(CUSTOMVERTEX),0, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED, &m_pVB))) return E_FAIL; if( FAILED(D3DXCreateTextureFromFile(pd3dDevice, (LPCSTR)m_TextureFileName, &m_pTexture))) return E_FAIL; ----- Now from the Dx SDK docs information because the vertex buffer and textures are being D3DPOOL_MANAGED if the device is lost/restored there is no need for me to have to release/restore these resources. So then if I resize the window, go Full Screen, change the videomode or colordepth, anything short of closing down my app D3D will "automatically" manage these resources by freeing them up from video memory, copying them back from system memory and "relinking variables" to the proper locations. So then, by placing my CreateVertex and CreateTexture routines within OneTimeSceneInit() there should be no problems? m_pTexture, m_pVB will "always" point to their respective resource? If these resources are completely managed by D3D am I still required to place a SAFE_RELEASE(m_pVB), SAFE_RELEASE(m_pTexture) within FinalCleanup() ? I do intend on altering the vertex buffer data from time to time. [edited by - quantass on August 26, 2002 6:12:34 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by quantass
Within OneTimeSceneInit() I placed the following code:
[snip]


that code should be in InitDeviceObjects. when OneTimeSceneInit is called, the device is not yet created and any code using the device will consequently fail.
quote:

Now from the Dx SDK docs information because the vertex buffer and textures are being D3DPOOL_MANAGED if the device is lost/restored there is no need for me to have to release/restore these resources.


this is correct.
quote:

So then if I resize the window, go Full Screen, change the videomode or colordepth, anything short of closing down my app D3D will "automatically" manage these resources by freeing them up from video memory, copying them back from system memory and "relinking variables" to the proper locations.


yes, this is what managed pool does.
quote:

So then, by placing my CreateVertex and CreateTexture routines within OneTimeSceneInit() there should be no problems? m_pTexture, m_pVB will "always" point to their respective resource?


almost right, except you need to put that code in InitDeviceObjects as i said above.
quote:

If these resources are completely managed by D3D am I still required to place a SAFE_RELEASE(m_pVB), SAFE_RELEASE(m_pTexture) within FinalCleanup() ?


yes, you must explicitly release all allocated resources no matter which attributes they have.
quote:

I do intend on altering the vertex buffer data from time to time.


a good idea may be to have a writeonly vertex buffer and hold a copy of the data in system memory, to avoid reads from vram (if you didn''t think of it already).

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
i forgot to say that you should release the device objects in DeleteDeviceObjects, not in FinalCleanup.

Share this post


Link to post
Share on other sites