Sign in to follow this  

force to swap the texture from system memory to video memory

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

If my video memry is too small to put all textures I need, so I load those textures into system memory by D3DPOOL_MANAGED or D3DPOOL_DEFAULT. When my DirectX application want to render certain texture, how do I swap the memory of the texture from system meory to video memory?

Share this post


Link to post
Share on other sites
Quote:
Original post by akira32
If my video memry is too small to put all textures I need, so I load those textures into system memory by D3DPOOL_MANAGED or D3DPOOL_DEFAULT. When my DirectX application want to render certain texture, how do I swap the memory of the texture from system meory to video memory?


DirectX will do it for you, if you are using D3DPOOL_MANAGED. (If you are using D3DPOOL_DEFAULT and the memory is not enough the game will crash because a texture created with that flag will live ONLY on the graphic card memory)

Share this post


Link to post
Share on other sites
Quote:
Original post by feal87
DirectX will do it for you, if you are using D3DPOOL_MANAGED. (If you are using D3DPOOL_DEFAULT and the memory is not enough the game will crash because a texture created with that flag will live ONLY on the graphic card memory)

Er ... no of course it won't crash. D3DPOOL_DEFAULT has other implications, most notably the following ones:

Quote:
Original post by MSDN DX Docu
This is usually video memory, including both local video memory and AGP memory. The D3DPOOL_DEFAULT pool is separate from D3DPOOL_MANAGED and D3DPOOL_SYSTEMMEM, and it specifies that the resource is placed in the preferred memory for device access.

[...]

When creating resources with D3DPOOL_DEFAULT, if video card memory is already committed, managed resources will be evicted to free enough memory to satisfy the request.


If you run out of VRAM the driver moves resources from VRAM to SYSRAM to allocate VRAM space. During runtime it then needs to upload resources to VRAM if they are not present there already. If you run out of VRAM you will notice a slow down due to the driver moving resources around but you won't crash.

read more about pool values

To OP:
Using the MANAGED flag does the following: It creates one copy of the resource in SYSMEM and one in DEFAULT (should be VRAM but does not have to be). That makes accessing the resource for reads and writes more efficient but wastes more SYSMEM. You should only use MANAGED resources if you are going to access the resource frequently for read back or for writing other data to it.

Another advantage of MANAGED is that DX can take care of re-creating the resource automatically upon DEVICE LOST. For DEFAULT resources you have to recreate them upon DEVICE LOST on your own.

Share this post


Link to post
Share on other sites
I thought i remember some crash when going over the limit of the GPU with the DEFAULT pool, but if you say so...i'm not sure 100% as nowadays its pretty difficult going over the gpu available memory and i have no tests available. ;D

Share this post


Link to post
Share on other sites

This topic is 3111 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this