Very Computer

DX9 and Textures

I'm trying to load a tiled texture in a .bmp file into multiple textures in program memory. I'm having trouble the the IDirect3DDevice9::CreateTexture and IDirect3DTexture9::LockRect functions.

First of all, I don't want a full mipmap chain, but Direct3D INSISTS on building one (the call fails unless I specify 0 or D3DX_DEFAULT, both of which make a full chain.)

Ok, that's not so big a deal. It uses up more memory, but I can live with it. Now for the next part: When I go to lock the texture so that I can copy data from the loaded texture into my created one, it decides to give me "D3DERR_INVALIDCALL" no matter what I do.

> I'm trying to load a tiled texture in a .bmp file into > multiple textures in program memory. I'm having trouble > the the IDirect3DDevice9::CreateTexture and > IDirect3DTexture9::LockRect functions.

> First of all, I don't want a full mipmap chain, but > Direct3D INSISTS on building one (the call fails unless I > specify 0 or D3DX_DEFAULT, both of which make a full > chain.)

> Ok, that's not so big a deal. It uses up more memory, but > I can live with it. Now for the next part: When I go to > lock the texture so that I can copy data from the loaded > texture into my created one, it decides to give > me "D3DERR_INVALIDCALL" no matter what I do.

> Anyone have an idea as to what's going on?

> Karl

It would be helpful if you posted your function calls. What pool are you creating your texture in? From the SDK:

"Textures placed in the D3DPOOL_DEFAULT pool cannot be locked unless they are dynamic textures or they are private, four-character code (FOURCC), driver formats. To access unlockable textures, you must use functions such as IDirect3DDevice9::UpdateSurface, IDirect3DDevice9::UpdateTexture, IDirect3DDevice9::GetFrontBufferData and IDirect3DDevice9::GetRenderTargetData. "

My target graphics device (a Radeon 7000) claims to support D3DFORMAT_UYVY textures. This turned out to be true, unless I specify D3DUSAGE_DYNAMIC, for which CreateTexture fails. So I cannot load pixels to the texture by locking/unlocking.

The only way left to load pixel data to the texture is either UpdateTexture / UpdateSurface or StretchRect.

But now I discovered that the board does not support off-screen-plain-surfaces with a format of D3DFORMAT_UYVY.

So I only can create D3DPOOL_SCRATCH surfaces as a source surface to UpdateSurface / StretchRect. However D3DPOOL_SCRATCH surfaces are not supported by these methods.

What am I missing? How can I update a texture when I cannot create Off-Screen-Plain-Surfaces of the same format and can't create the texture as D3DUSAGE_DYNMAIC? There must be a way, otherwise the YUV-texture feature would be ueseless...