Large texture LockRect performance

Started by
1 comment, last by renman29 16 years, 10 months ago
I noticed that when I try to lock and write pixels to a texture it is quite fast so long as it's 1024x1024 or less. If it's 2048x2048 or larger, the performance is suddenly terrible. Could it be card or driver related? I'm wondering if there's a faster way to update a texture bigger than 1024x1024? Here's what I'm doing right now:

D3DLOCKED_RECT lr_a;
g_proto_textures[obj]->LockRect(0, &lr_a, NULL, NULL);
DWORD *new_pixel = static_cast<DWORD*>(lr_a.pBits);
new_pixel[pixel_offset]=0xffff0000;
g_proto_textures[obj]->UnlockRect(0);

Any advice or ideas about this are totally welcome. :)
Advertisement
a 2048 x 2048 texture needs 4 times the ram of a 1024 x 1024 and therefore should approximately 1/4 the speed. How much of a speed drop are you seeing?

If it's worse than 1/4 then using four 1024 x 1024 textures is an obvious solution.

The best bet is not to lock it at all. If you only need write access then making the texture as a render target and drawing primitives on it should be several times quicker than locking it.

If you can't do that you might want to try using IDirect3DDevice9::UpdateSurface() instead of locking it.
Aha! Yup - it's about 1/4 the speed. Excellent suggestions. Thankyou very much! (^-^)

This topic is closed to new replies.

Advertisement