Sign in to follow this  
Norman0406

Application crashing at IDirect3DDevice9::Present when using DirectX Debug Runtime

Recommended Posts

Hello, I'm recently getting odd behaviour of my directx application. I used the DirectX Control Panel to switch to the debug runtime in order to get some additional information in the debug output window. But after that my application crashes at IDirect3DDevice9::Present, without giving information about the reason. In the debug output window it just says: First-chance exception at 0x6fcadfbf in Test - Console.exe: 0xC0000005: Access violation reading location 0x00000188. Unhandled exception at 0x6fcadfbf in Test - Console.exe: 0xC0000005: Access violation reading location 0x00000188. and that's it. I also checked for NULL pointers, but found none, the device has been created successfully. When switching back to the retail runtime it works, but then I'm not getting additional debug information any more. I also compiled with D3D_DEBUG_INFO, but still no error messages occur, just this "access violation". I use DirectX 9.0c and Visual Studio 2005. Does anyone have a clue? Norman.

Share this post


Link to post
Share on other sites
You're going to have post some code around where it's crashing. Have you tried stepping through your program with the debugger? What do the variables around the crash site look like? Frankly, it's impossible for us to just guess what's going wrong. We need solid information.

Share this post


Link to post
Share on other sites
Alright, I did not post any code because there is nothing special about it, but here is the function where my app crashes:

void Render()
{
g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);

if (SUCCEEDED(g_pd3dDevice->BeginScene()))
{
Move(duration);

g_pConsole->Render();

Look();

g_pd3dDevice->EndScene();
}

g_pd3dDevice->Present(NULL, NULL, NULL, NULL);
}

The Problem occurs when exectuing g_pd3dDevice->Present(NULL, NULL, NULL, NULL);
The moment before, everything seems to be fine. g_pd3dDevice is not NULL and all the calls before returned S_OK. My Presentation parameters are created this way:

d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferHeight = 600;
d3dpp.BackBufferWidth = 800;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.FullScreen_RefreshRateInHz = 0;
d3dpp.MultiSampleQuality = 0;
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.Windowed = TRUE;
d3dpp.hDeviceWindow = g_hWnd;

Here is a more detailed extract of my debug output:
Direct3D9: :====> ENTER: DLLMAIN(6e9a9b10): Process Attach: 00000d14, tid=000015b4
Direct3D9: :====> EXIT: DLLMAIN(6e9a9b10): Process Attach: 00000d14
Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.
'Test - Console.exe': Loaded 'C:\Windows\System32\nvd3dum.dll', No symbols loaded.
Direct3D9: (INFO) :======================= Hal HWVP device selected

Direct3D9: (INFO) :HalDevice Driver Style b

Direct3D9: :DoneExclusiveMode
Direct3D9: (INFO) :Using FF to VS converter

Direct3D9: (INFO) :Using FF to PS converter

D3D9 Helper: Warning: Default value for D3DRS_POINTSIZE_MAX is 2.19902e+012f, not 1.81098e-316f. This is ok.
Direct3D9: (WARN) :Ignoring redundant SetRenderState - 7

Direct3D9: (WARN) :Ignoring redundant SetRenderState - 22

Direct3D9: (WARN) :Ignoring redundant SetRenderState - 8

D3DX: (INFO) Using SSE2 Instructions
'Test - Console.exe': Loaded 'C:\Windows\System32\clbcatq.dll', No symbols loaded.
First-chance exception at 0x6e9ddfbf in Test - Console.exe: 0xC0000005: Access violation reading location 0x00000188.
Unhandled exception at 0x6e9ddfbf in Test - Console.exe: 0xC0000005: Access violation reading location 0x00000188.

The thing that confuses me is that everything works fine when I select the retail runtime...

Share this post


Link to post
Share on other sites
What hardware and driver are you using? I've had PIX crash with the debug runtime on a Intel integrated chipset, but running perfectly well with the debug runtime with the same program on ATI and NVIDIA hardware, so I guess that drivers can cause a crash with the debug runtime.

Share this post


Link to post
Share on other sites
Does it happen if you comment all rendering code (Move(), g_pConsole->Render(), and Look())? That is, if you're just calling Clear, BeginFrame, EndFrame, Present?

If it does, try commenting your code line-by-line until you find the line that causes it to crash.

If it crashes with an empty loop, it's most likely some driver bug.

Either way, make sure you've got the latest drivers for your card.

Share this post


Link to post
Share on other sites
Just a guess, but I recently crashed on Present with no other indications. I traced it to a corrupted index buffer. The buffer got corrupted by overwriting it using incorrect loop variables for another array!

As suggested above:

- comment everything out and add calls back in one at a time till it crashes.

Share this post


Link to post
Share on other sites
I checked it. Even when I comment out all relevant calls and just leaving initialization routine and primary rendering routine, so that there are no index buffers being created or other stuff, it still crashes. It now looks this way:
g_pD3D = Direct3DCreate9( D3D_SDK_VERSION );
ZeroMemory(&d3dpp, sizeof(D3DPRESENT_PARAMETERS));
d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferHeight = 600;
d3dpp.BackBufferWidth = 800;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.FullScreen_RefreshRateInHz = 0;
d3dpp.MultiSampleQuality = 0;
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.Windowed = TRUE;
d3dpp.hDeviceWindow = g_hWnd;

g_pD3D->CreateDevice(0, D3DDEVTYPE_HAL, g_hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &g_pd3dDevice);

g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);

// Begin the scene
if (SUCCEEDED(g_pd3dDevice->BeginScene()))
{
g_pd3dDevice->EndScene();
}

g_pd3dDevice->Present(NULL, NULL, NULL, NULL);

and it still does not work. Just setting d3dpp.Windowed = FALSE or switching back to the retail runtime makes it work. Yesterday I tried out 4 Versions of the SDK since 2004 and installed 3 different driver versions for my NVIDIA card, but it made no difference. Maybe a serious bug relevant only for a small group of users? Are there any ways to get detailed debug information using the retail runtime? I know that should not be possible, but maybe there is a way.

Share this post


Link to post
Share on other sites
I tried playing around with the presentation parameters for quite a while now, tried changing DepthStencilFormat to D16 (and the other formats as well), the Backbufferformat, SwapEffects and Behaviourflags and nothing seems to work. Why does it work when setting d3dpp.Windowed = FALSE? The parameters are exactly the same...

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