Sign in to follow this  

DX10: Help with D3D10CreateDeviceAndSwapChain

This topic is 3196 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

First off, some background. The thing that strikes me as odd, specifically, is the fact that I had this program working prior to this moment. It did exactly what it was supposed to with no crash. Then it started crashing numerous times in a row, so I restarted my computer, but the problem still continues. I'm using SDL to create the window, then I retrieve the platform-specific information so that I can use the necessary HWND (window handle) that DX10 needs for the swap chain description. Since it does matter, here is the swap chain description initialization:
[source="cpp"]
DXGI_SWAP_CHAIN_DESC scd;
scd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
scd.OutputWindow = sdlMgr->getWindowHandle();
scd.Windowed = TRUE;
scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
scd.BufferDesc.Width = 640;
scd.BufferDesc.Height = 480;
scd.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
scd.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
scd.BufferDesc.RefreshRate.Numerator = 60;
scd.BufferDesc.RefreshRate.Denominator = 1;
scd.SampleDesc.Count = 1;
scd.SampleDesc.Quality = 0;
scd.Flags = 0;


Pretty standard, as you can probably see. Now the real problem comes when creating the device and swap chain with D3D10CreateDeviceAndSwapChain. Here's the code for that:
[source="cpp"]
if( FAILED( hr = D3D10CreateDeviceAndSwapChain(
				NULL,
				D3D10_DRIVER_TYPE_HARDWARE,
				NULL,
				0,
				D3D10_SDK_VERSION,
				&scd,
				&g_SwapChain,
				&g_Device ) ) )
	{


Now in the block of code that comes after that, I check all the possible values (according to documentation) that D3D10CreateDeviceAndSwapChain can return. Here's the full list: D3D10_ERROR_FILE_NOT_FOUND, D3D10_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS, D3DERR_INVALIDCALL, D3DERR_WASSTILLDRAWING, E_FAIL, E_INVALIDARG, E_OUTOFMEMORY, S_FALSE, S_OK. In my switch statement, I included a default clause as well. The result of D3D10CreateDeviceAndSwapChain always goes to default, meaning an unrecognized error. So the only possible thing I can think of is the fact that there must be some kind of error value that isn't documented in the DX10 documentation. By the way, here's the hexadecimal equivalent of the HRESULT that is returned: 0x887A0001

Share this post


Link to post
Share on other sites
Yes I have tried those in fact. When it fails though, it only tells me "Unhandled exception at 0x67861079 in Lesson01.exe: 0xC0000005: Access violation reading location 0x31a87e09.", and then says that no source code is available.

So I can't step through or anything.

Share this post


Link to post
Share on other sites
Quote:
Original post by Erik Rufelt
Try memset the scd to 0 before filling it, it can contain some bogus data. Also, try setting the BufferCount member to 1.

Ah yes! Great catch there Erik, that was the exact problem.

Share this post


Link to post
Share on other sites

This topic is 3196 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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