force to swap the texture from system memory to video memory

Started by
2 comments, last by feal87 14 years, 11 months ago
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?
akira32 編程之家 Yahoohttp://tw.myblog.yahoo.com/akira32-akira32
Advertisement
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)
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.
------------------------------------I always enjoy being rated up by you ...
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

This topic is closed to new replies.

Advertisement