Can't create texture on WM5.0 PPC

Hi all,

I invoke IDirect3DMobileDevice->CreateTexture to create a texture, but what annoyed me is CreateTexutre always return error D3DMERR_DRIVERUNSUPPORTED while it can work correctly on WM5.0 PPC emulator.

the device I used is Dell AXIM X51V, and sample code as follows:

// create d3d object.

m_pD3DMobile = ::Direct3DMobileCreate( D3DM_SDK_VERSION );

RECT rtClt;

::GetClientRect( hWnd, &rtClt );

D3DMFORMAT format = D3DMFMT_R5G6B5;

D3DMPRESENT_PARAMETERS param;

memset( &param, 0, sizeof(D3DMPRESENT_PARAMETERS) );

param.BackBufferWidth = rtClt.right;

param.BackBufferHeight = rtClt.bottom;

param.BackBufferFormat = format;

param.BackBufferCount = 0;

param.MultiSampleType = D3DMMULTISAMPLE_NONE;

param.SwapEffect = D3DMSWAPEFFECT_DISCARD;

param.Windowed = TRUE;

param.EnableAutoDepthStencil = FALSE;

param.AutoDepthStencilFormat = D3DMFMT_UNKNOWN;

param.Flags = 0;

param.FullScreen_PresentationInterval = D3DMPRESENT_INTERVAL_DEFAULT;

// create d3d device

HRESULT hr = m_pD3DMobile->CreateDevice( D3DMADAPTER_DEFAULT, D3DMDEVTYPE_DEFAULT, hWnd, 0, &param, &m_pD3DMobileDevice );

if ( FAILED( hr ) )

return hr;

// create 3d3 texture.

hr = m_pD3DMobileDevice->CreateTexture( m_bitmapInfo.header.biWidth, m_bitmapInfo.header.biHeight,

1, D3DMUSAGE_LOCKABLE | D3DMUSAGE_DYNAMIC, format, D3DMPOOL_SYSTEMMEM, &m_pD3DMobileTexture );

if ( FAILED( hr ) )

return hr; // here, always return D3DMERR_DRIVERUNSUPPORTED

if any adive and help, I'm appreciated.
[1932 byte] By [XRanger] at [2007-12-25]
# 1
Are you sure your device supports the format you're asking for under the flags you're passing?
WessamBahnassi at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 2

Hi Wessam,

if the format(D3DMFMT_R5G6B5) isn't supported, why can CreateDevice go through?

I also try to repeat invoking CreateTexture passing every format which can be found in Mobile SDK, but no one return ok.

thanks for your concern.

XRanger at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 3
The driver is not required to support a format for both render-target and texture usage. Use IDirect3DMobile::CheckDeviceFormat() to enumerate what formats are supported for texturing by your device.
WessamBahnassi at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 4

I have done it as you say. I check if D3DMFMT_R5G6B5 is valid for the usage D3DMUSAGE_DYNAMIC | D3DMUSAGE_LOCKABLE and CheckDeviceFormat return ok, code as follow:

D3DMDISPLAYMODE mode;

HRESULT hr = m_pD3DMobile->GetAdapterDisplayMode( D3DMADAPTER_DEFAULT, &mode );

if ( FAILED( hr ) )

return hr;

hr = m_pD3DMobile->CheckDeviceFormat( D3DMADAPTER_DEFAULT, D3DMDEVTYPE_DEFAULT, mode.Format,

D3DMUSAGE_DYNAMIC | D3DMUSAGE_LOCKABLE, D3DMRTYPE_TEXTURE, D3DMFMT_R5G6B5);

if ( FAILED( hr ) )

return hr;

but CreateTexture returned D3DMERR_DRIVERUNSUPPORTED yet.

I have another question, and it's very weird when I try to use DD to create surface, because I have to use COM, and when start thread, call CoInitializeEx( 0, COINIT_MULTITHREADED ), but after this I can't create surface,if remove calling CoInitializeEx, it can create it successfully.I searched for doc, but didn't find any doc point out it.

do you know the reason?:)

XRanger at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 5

I'm not sure what debugging capabilities D3DM offers, but the only thing left is to assert that the dimensions of the texture don't break through the caps of the device also. It's highly possible they have to be powers-of-two, and they most probably have an upper-limit also (probably not greater than 256x256).

Regarding your COM initialize issue, it's again hard to tell without additional info from D3D itself. On D3D9 you run your app under the debugger with D3D debug libs, and D3D will log helpful messages about every illegal operation you do with it... It would probably be a good idea to invest some time exploring if D3DM has such a facility.

WessamBahnassi at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 6

Check the caps bits to see if your driver supports lockable textures (D3DMCAPS::SurfaceCaps & D3DMSURFCAPS_LOCKTEXTURE). If it doesn't, you'll have to create an image surface and use CopyRects to load the texture.

There is a debug version of the D3DM runtime that will report a lot more information when an API fails. It isn't shipped with the WM5 SDK though. It's included with Platform Builder and you'd have to enable debug zones on the target device in order to get the output to the debugger. I haven't tried this with a retail device but we use it with our Intel BSP devices all the time when doing driver development.

DonCrouch at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 7

Thank you Wessam and Don,
I have found the issue, the reason is: demension of texture must be powers-of-two. I only used demension of image in our code, but it's not powers-of-two, so creating texture failed.
thank you once more Wessam.

XRanger at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...