Archived

This topic is now archived and is closed to further replies.

Help! Unexplained break in D3D8 debug mode

This topic is 5647 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

I''m not sure if anyone can help, but I''ll try anyway. I have a very simple windowed Direct3D 8.1 application. So simple in fact that I''m not displaying anything yet. I''m just clearing the render target to black. I''m using the debug version of Direct3D and I''ve set "Debug Output Level" to the maximum (in the DirectX Control Panel applet). If I leave "Break on D3D error" unchecked, my app runs fine and I get a black window, which is what I''m supposed to get. If I do check "Break on D3D error", an assert (int 3) is fired in NTDLL (which is called from D3D8D) when I call pDevice->Present( NULL, NULL, NULL, NULL ). Here''s the stack trace in case anyone can use that: NTDLL! 77f9eea9() D3D8D! 00aebc89() D3D8D! 00adda7e() CMyD3DApp::DoPresent() line 154 + 28 bytes I''m not doing anything very complicated in my app, so I don''t know why this is happening. All I do is initialize Direct3D and, once that is done, call the DrawFrame function once in each message loop pass. Here''s how I initialize Direct3D:
  // presentation params
  ZeroMemory( &present, sizeof( D3DPRESENT_PARAMETERS ) );
    present.BackBufferWidth = nWndClientWidth;
    present.BackBufferHeight = nWndClientHeight;
    present.BackBufferFormat = D3DFMT_A8R8G8B8; // forced to 32bit
    present.BackBufferCount = 1;
    present.MultiSampleType = D3DMULTISAMPLE_NONE;
    present.SwapEffect = D3DSWAPEFFECT_FLIP;
    present.hDeviceWindow = hWnd;
    present.Windowed = TRUE;
    present.EnableAutoDepthStencil = TRUE;
    present.AutoDepthStencilFormat = D3DFMT_D24S8;
    present.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
    present.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;

  // create device
  hr = m_pID3D->CreateDevice
    (
    D3DADAPTER_DEFAULT,
    D3DDEVTYPE_HAL,
    m_hWnd,
    D3DCREATE_SOFTWARE_VERTEXPROCESSING,
    &present,
    &m_pID3DDevice
    );

  // init some render states
  pDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
  pDevice->SetRenderState( D3DRS_ZENABLE,  TRUE );
 
And this is my DrawFrame function:
  // clear display
  pDevice->Clear
    (
    0,
    NULL,
    D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
    D3DCOLOR_RGBA( 0, 0, 0, 0 ),
    1.0,
    0
    );

  // begin drawing
  pDevice->BeginScene( );

  // add draw code here

  // end drawing
  pDevice->EndScene( );

  // present frame
  pDevice->Present( NULL, NULL, NULL, NULL );
 
That''s about all the Direct3D code I have in my app for now. Nothing very complex as you can see. Anyone has any idea why this code breaks when "Break on D3D error" is checked? Thanks for any advice!

Share this post


Link to post
Share on other sites
Check the debug output window (usually found at the bottom of the screen in MSVC - check the docs if it isn''t)...

...in there you should find the reason for the error, even if you don''t enable break on error.

There could be a number of things which are returning error messages and codes (which you don''t check for...) which will cause a break if you enable break on error.


--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
Oops! I forgot to mention that! There is absolutely nothing written in the debug output window for that particular problem. There are a few "Ignoring redundant SetRenderState - 137" or similar non-fatal messages like that, but nothing about the assert I am getting.

Even weirder is the fact that the pDevice->Present(...) function call returns S_OK just like if nothing had happened!!!

I really don''t know what this is all about.

Share this post


Link to post
Share on other sites
Read Jim''s ''(Omniscient Book about)Programming Role-Playing Games with DirectX'' It will know the answer to this questions and many others, such as how I should go about getting my other computer started, even though I always get so frustrated with scandisk that I always hit the power switch halfway through.

But in all honesty, yeah thats a strange one. Do some testing like the others suggested and get back to us on anything you can come up with. It may also help if you could try to put some polys up on that thing to see if that will give you any additional BS from DX, although assuming since your making your own framework right now, that may still be a bit beyond your current potential?

~Vendayan

Share this post


Link to post
Share on other sites
Jim: Yes, I get the same problem when I use D3DSWAPEFFECT_DISCARD or other depth buffer types.

Don: I do not get the error if I use the reference rasterizer. Also, if I run the program at home on my GeForce2, I don''t get the error either. I only get the error on my TNT2 at work. Could it be card or driver-specific? I find that hard hard to believe since what I''m doing is so common and simple.

Vendayan: My ''engine'' is obviously far from complete, but I can display polygons fine. The problem doesn''t prevent me from continuing further as long as I don''t enable the "Break on D3D error" option.

I''ll go update my driver now just to see if it helps...

Share this post


Link to post
Share on other sites
Nope, latest NVidia Detonator drivers didn't change anything. In fact, I now get 16 frames less per second...

[edited by - i1977 on June 27, 2002 3:23:28 PM]

Share this post


Link to post
Share on other sites
Thinking about this again - are you sure the client width and height are the actual height of the client area of the window, or of the window itself? In other words, are you supplying the size of the window when you create it via CreateWindow* or getting it from a call like GetClientRect?

Other than that - maybe you should try 16 bit surfaces, and see if your adapter is set to 16 or 32-bit color (try flipping to see what happens).

Jim


Jim Adams
home.att.net/~rpgbook
Author, Programming Role-Playing Games with DirectX

Share this post


Link to post
Share on other sites
I''m using GetClientRect() to determine the width and height of my windows'' client area.

I tried running one of the D3D SDK samples and I get the same error. However, I ran a coworker''s D3D application on my system and the error does not occur in his application.

Weird...

Share this post


Link to post
Share on other sites