Celios

Hi,

I have been wondering about the most efficient way to create texture in Direct3D from
existing RGB data already loaded to RAM because I feel like I need to increase performance to my application.

The way I do it now is this :

d3tex is an LPDIRECT3DTEXTURE9

D3DLOCKED_RECT rect;
d3tex->LockRect(0, &rect, NULL, D3DLOCK_DISCARD);
CopyMemory(rect.pBits, rgbdata, width*height*sizeof(rgbdata));
d3tex->UnlockRect(0);


I have been told that locking is expensive.
Is there a better, more efficient way of doing this


Re: Game Technologies: DirectX 101 Fastest way to create texture from existing RGB data in memory for Direct3D

Wessam Bahnassi

Generally it's not a good idea to do CPU texture updates frequently. Although the situation is getting better, the cost is at least a GPU stall. You can either double/triple buffer your texture, or avoid doing the update from the CPU if algorithmically possible. I assume you're already using a dynamic texture since you're passing D3DLOCK_DISCARD.






Re: Game Technologies: DirectX 101 Fastest way to create texture from existing RGB data in memory for Direct3D

Celios

Thanks, Wessam.

This is for a video playing application, so unfortunately I cannot avoid updating textures unless I find another way of doing video in Direct3D without using DirectShow.

By the way, what do you mean by double/triple buffer the textures
Do I maintain a queue of 2 or 3 textures during the video playback

Celios




Re: Game Technologies: DirectX 101 Fastest way to create texture from existing RGB data in memory for Direct3D

Wessam Bahnassi

Yes, that's what I meant.