0

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

  1. Render a bunch of stuff with the textures
  2. Update a few parts of the texture (which may have been used by the previous renders)
  3. Render some more stuff with the texture
  4. Update another part of the texture
  5. 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?
    1. Call LockRect and UnlockRect for each region I need to update
    2. Call LockRect and UnlockRect for the entire texture
    3. Call LockRect and UnlockRect for the entire texture with D3DLOCK_DISCARD and copy in a bitmap from RAM.
    4. Create a completely new texture each time I need to "update it"
    5. Use 1,2 or 3 to update a surface in D3DPOOL_SYSMEM, then UpdateSurface to update level 0 of my texture from this surface
    6. Same as 5 but specify RECT to cover the entire area I need
    7. Same as 5 but make multiple calls, one for each region I updated
    8. 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.

4

2 回答 2

1

如果您需要更新多个区域,您应该锁定整个纹理并使用 D3DLOCK_NO_DIRTY_UPDATE 标志,然后在解锁之前为每个区域调用 AddDirtyRect。

当然,这一切都取决于纹理的大小等,对于小纹理,从 ram 复制整个东西可能更有效。

于 2009-08-07T14:56:21.057 回答
-1
  • D3DPOOL_DEFAULT
  • D3DUSAGE_DYNAMIC
  • 为您需要更新的每个区域调用 LockRect 和 UnlockRect

--> 这个是最快的!

基准将遵循...

于 2009-07-28T15:18:40.987 回答