I need to render some CPU generated images in Direct3D 9 and I'm not sure of the best way to get the texture data onto the graphics card as there seems to be a number of approaches.
My usage path goes along the following lines each frame
- Render a bunch of stuff with the textures
- Update a few parts of the texture (which may have been used by the previous renders)
- Render some more stuff with the texture
- Update another part of the texture
- and so on
Ive thought of a couple of ways to do this, however I'm not sure which one to go with. I considered benchmarking each method however I have no way to know if any results I get are representative of hardware in general, or only my hardware.
- Which pool is best for a texture for this task?
- Whats the best way to update this texture?
- Call LockRect and UnlockRect for each region I need to update
- Call LockRect and UnlockRect for the entire texture
- Call LockRect and UnlockRect for the entire texture with D3DLOCK_DISCARD and copy in a bitmap from RAM.
- Create a completely new texture each time I need to "update it"
- Use 1,2 or 3 to update a surface in D3DPOOL_SYSMEM, then UpdateSurface to update level 0 of my texture from this surface
- Same as 5 but specify RECT to cover the entire area I need
- Same as 5 but make multiple calls, one for each region I updated
- Probably yet another way to do this I haven't thought of yet...
It should be noted that the areas I'm updating are usually fairly small compared to the size of the entire texture, eg the texture may be 1024*1024 and I might want to update 5 or so 64*64 regions of it.