Sign in to follow this  
Nostalgia

Trouble with D3D9-CreateDevice()

Recommended Posts

Hi all. I just had a problem start showing up, and I can't figure out what I did to make it appear. I have an application that worked up until today. I didn't make any changes to the DirectX section of the code, and I can't get enough info out of the DX libs to help me out. I've got the debug libraries installed, the "Debug Output Level" slider all the way to the right. In my output window, I see:
Direct3D9: (INFO) :======================= Hal SWVP device selected

Direct3D9: (INFO) :HalDevice Driver style 9

Direct3D9: :DoneExclusiveMode
Direct3D9: (ERROR) :Failed to create driver surface
Direct3D9: (ERROR) :Failed to initialize primary swapchain
Direct3D9: (ERROR) :Failed to initialize Framework Device. CreateDevice Failed.

D3D9 Helper: IDirect3D9::CreateDevice failed: D3DERR_DRIVERINTERNALERROR
Does that mean anything to you guys? Here's the code leading up to that point (error checking removed for clarity - I test all return codes):
D3DDISPLAYMODE d3ddm;
m_pD3D->GetAdapterDisplayMode(m_nAdapter, &d3ddm);

ZeroMemory(&m_d3dppWin, sizeof(m_d3dppWin));
m_d3dppWin.Windowed   = TRUE;
m_d3dppWin.SwapEffect = D3DSWAPEFFECT_DISCARD;		
m_d3dppWin.BackBufferFormat = d3ddm.Format;
m_d3dppWin.BackBufferCount = 2;
m_d3dppWin.EnableAutoDepthStencil = TRUE;
m_d3dppWin.AutoDepthStencilFormat = D3DFMT_D16;
m_d3dppWin.hDeviceWindow = m_hWnd;

m_pD3D->CreateDevice(
	0,
	D3DDEVTYPE_HAL,
	m_hWnd,
	D3DCREATE_SOFTWARE_VERTEXPROCESSING,
	&m_d3dppWin,
	&m_pd3dDevice);


Thanks for any suggestions. -Joe

Share this post


Link to post
Share on other sites
Possibilities:

m_nAdapter is junk. You create device on adapter 0, so why get the display mode for a specific, possibly different, adapter.

BackBufferCount of 2. I've never set this. You're not allow anything except 1 (or 0) when using SWAPEFFECT_COPY, but you're not using that. Not likely the problem.

Depth format D16 isn't allowed with whatever backbuffer format you're using. Use CheckDepthStencilMatch and CheckDeviceFormat, as per the snippet shown in CheckDepthStencilMatch's help. Be prepared to switch to an alternate depth format.

m_hWnd isn't created yet, has no client area, or is minimized

m_hWnd is too big. (doubtful)

The desktop format isn't a valid D3D format (doubtful)

COM isn't initialized (CoInitialize()... not sure you really need it).

Share this post


Link to post
Share on other sites
Hey! Thanks for the suggestions.

Quote:
m_nAdapter is junk. You create device on adapter 0, so why get the display mode for a specific, possibly different, adapter.

I actually use m_nAdapter in both cases - I made it 0 just for clarity and missed one. I've checked it in the debugger, and it's 0 in both places.

Quote:
BackBufferCount of 2. I've never set this. You're not allow anything except 1 (or 0) when using SWAPEFFECT_COPY, but you're not using that. Not likely the problem.

Nope. I had already tried it both ways.

Quote:
Depth format D16 isn't allowed with whatever backbuffer format you're using. Use CheckDepthStencilMatch and CheckDeviceFormat, as per the snippet shown in CheckDepthStencilMatch's help. Be prepared to switch to an alternate depth format.

Interesting. I'll check that out. I'd be quite surprised, as I've been using D16 the whole time without trouble until now.

Quote:
m_hWnd isn't created yet, has no client area, or is minimized

Has no client area! I bet that's it...hang on...Brilliant!!

I was reading the window size from a previously set registry value, and the data was crap.

Thanks for that!

-Joe

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this