Note that there are some explanatory texts on larger screens.

plurals
  1. POBest way to update a Direct3D Texture
    text
    copied!<p>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.</p> <p>My usage path goes along the following lines each frame</p> <ol> <li>Render a bunch of stuff with the textures</li> <li>Update a few parts of the texture (which may have been used by the previous renders)</li> <li>Render some more stuff with the texture</li> <li>Update another part of the texture</li> <li>and so on</li> </ol> <p>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.</p> <ul> <li>Which pool is best for a texture for this task?</li> <li>Whats the best way to update this texture? <ol> <li>Call LockRect and UnlockRect for each region I need to update</li> <li>Call LockRect and UnlockRect for the entire texture</li> <li>Call LockRect and UnlockRect for the entire texture with D3DLOCK_DISCARD and copy in a bitmap from RAM.</li> <li>Create a completely new texture each time I need to "update it"</li> <li>Use 1,2 or 3 to update a surface in D3DPOOL_SYSMEM, then UpdateSurface to update level 0 of my texture from this surface</li> <li>Same as 5 but specify RECT to cover the entire area I need</li> <li>Same as 5 but make multiple calls, one for each region I updated</li> <li>Probably yet another way to do this I haven't thought of yet...</li> </ol></li> </ul> <p>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.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload