I was wondering what the fastest way to update textures generated via the CPU was.
In the past, I only updated textures infrequently, or at low rates, but now I want to update every frame.
I used to write to a system allocated block of memory then lock a D3D texture surface and memcpy the bits.
Looking at the D3D docs, I see...
" For dynamic textures, it is sometimes desirable to use a pair of video memory and system memory textures,
allocating the video memory using D3DPOOL_DEFAULT and the system memory using D3DPOOL_SYSTEMMEM.
You can lock and modify the bits of the system memory texture using a locking method. Then you can update
the video memory texture using IDirect3DDevice9::UpdateTexture. "
My app does this:
Writes 32bit RGBA color bits to a texture.
Writes are somewhat random (not just sequential spans or block copies)
That generated texture is rendered by D3D on the same frame.
Although the 'same frame' does CPU updating and GPU rendering, they are not explicitly locked in sync.
The CPU does not need to read back or modify an older version of the texture.
The whole CPU process is relatively slow, so I would need to lock a surface for some milliseconds if I output directly to a D3D surface instead of locking just to memcpy.
I presume it might be useful to not only create system and video memory textures, but create at least 2 sets to effectively double buffer, preventing buffered frames from waiting for me to release my lock.
I was wondering if anyone using dynamic textures has a recommendation here to save me trialing every possible way to accomplish this.