Skip to main content
GameDev.net gamedev.net
🔒 Locked

[.net] [MDX] Debugging with VS 2005

Started by g0nzo Jul 10, 2006 at 12:14 PM 7 replies 3.9k views
Original Post
g0nzo
g0nzo
Hi! I've got few questions about debugging MDX 1.1 in VS 2005. I've switched to debug runtime, enabled unmanaged code debugging and disabled breaking on Loader Lock exception. 1. How can i check what exactly is causing memory leaks? I get lots of errors like: Direct3D9: (WARN) :Memory still allocated! Alloc count = 152 Direct3D9: (WARN) :Current Process (pid) = 00000d24 Demo.exe has triggered a breakpoint Direct3D9: (WARN) :Memory Address: 00924cb8 lAllocID=1 dwSize=000047f8, (pid=00000d24) Direct3D9: (WARN) : Stack Back Trace Direct3D9: (ERROR) : [0] : Address 038CD4CB ... but it doesn't really tell me much. 2. In debug output window i get: "D3D9 Helper: Enhanced D3DDebugging disabled; Application was not compiled with D3D_DEBUG_INFO" What exactly is it? Is this "Enhanced D3DDebugging" useful? If it is, where do i have to add this D3D_DEBUG_INFO parameter? 3. I get *lots* of warnings like this: Direct3D9: (WARN) :Ignoring redundant SetRenderState 209 Direct3D9: (WARN) :Ignoring redundant SetTextureStageState Stage: 0, State: 1 Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 18, State: 31 Is it something i should worry about? 4. What exactly are symbol files? Are they helpful? Should i download them? 5. Is it normal that when i set "Debug Output Level" in DX Panel to maximum i get 0.5-1 fps? When i set it one level lower i get about 150 and without debugging i get about 600. Does it switch to reference rasterizer or does it provide so much useful info that it has to work so slow? :) Thanks in advance, g0nzo
darookie
darookie
Quote:
Original post by g0nzo
1. How can i check what exactly is causing memory leaks? I get lots of errors like:
Direct3D9: (WARN) :Memory still allocated! Alloc count = 152
Direct3D9: (WARN) :Current Process (pid) = 00000d24
Demo.exe has triggered a breakpoint
Direct3D9: (WARN) :Memory Address: 00924cb8 lAllocID=1 dwSize=000047f8, (pid=00000d24)
Direct3D9: (WARN) : Stack Back Trace
Direct3D9: (ERROR) : [0] : Address 038CD4CB
...
but it doesn't really tell me much.

Write down the lAlloID and in the D3DControl panel, activate "Break On Alloc" and put the lAllocID into the corresponding box on that panel. The program will then issue a breakpoint when the observed resource is first allocated.

Usually this error occurs when resource that is not managed by the device, is still still allocated at the time the device is disposed.

Quote:

3. I get *lots* of warnings like this:
Direct3D9: (WARN) :Ignoring redundant SetRenderState 209
Direct3D9: (WARN) :Ignoring redundant SetTextureStageState Stage: 0, State: 1
Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 18, State: 31
Is it something i should worry about?

Yes, you should care about these warnings, even though they're not critical. The warning are issued by Managed Direct3D to tell you that you do some redundant opreations, i.e. SetRenderState( someState ); /* do stuff, but don't touch "someState" */ SetRenderState( someState );.

Quote:

4. What exactly are symbol files? Are they helpful? Should i download them?

Symbol files contain function and variable names inside compiled binary code. They ease up debugging by providing human-readable names instead of just raw function- and data pointers in the debug window.
It might be worth downloading them.

Quote:

5. Is it normal that when i set "Debug Output Level" in DX Panel to maximum i get 0.5-1 fps? When i set it one level lower i get about 150 and without debugging i get about 600. Does it switch to reference rasterizer or does it provide so much useful info that it has to work so slow? :)

This is a perfectly normal behaviour - though you probably won't get 150fps with the reference rasteriser [smile]. Your device is still hardware accellerated, but the debug-layer observes each call and its parameters and generates a lot of output. This of couse has a significant impact on performance.

HTH,
Pat.
g0nzo
g0nzo
Thanks a lot!

1. I've set "Break on AllocID" to 1 and it breaks in dxmutenum.cs file at this line:
foreach (AdapterInformation ai in Manager.Adapters)
(with Manager.Adapters highlighted)
This file defines Microsoft.Samples.DirectX.UtilityToolkit.Enumeration class. I assume there's not much i can do about it. Got to check about 20 others errors :)

[EDIT] Uhm something is wrong, because all (or almost) memory leaks come from Microsoft.Samples.DirectX.UtilityToolkit.Framework class. I can't believe that everyone has these errors, so i must be doing something wrong, but what? I'm calling Dispose on Framework object right before end of my app... Any idea?

3. I've lowered the debug output by one level and now it says something different:
"Direct3D9: (WARN) :Can not render to a render target that is also used as a texture. A render target was detected as bound, but couldn't detect if texture was actually used in rendering."
Now i could figure out what caused this error (my lame attempt to post-processing :) ), but i'm not sure how to solve it. Probably i'll create a new topic for this.

4. Is there some info how to install these symbol files for MDX? I've copied the whole uncompressed folder to DX SDK folder and set a path in VS options to it, but it doesn't work. Does VS look also into subfolders or do i have to provide exact path to all (which exactly?) files?

[Edited by - g0nzo on July 10, 2006 4:42:07 PM]
transwarp
transwarp
This may be a rather stupid question, but I have to ask it at some point of time ;) :
Assuming I have correctly set up the stuff in the DirectX control panel applet and enabled unmanaged debugging in Visual Studio.... where exactly do I see this unmanaged debugging output?
Or formulated differently: When I get one of these meaningless "Error in the application" exceptions, how do I find out what caused the problem (missing texture file, invalid shader, etc.)?
remigius
remigius
You'll find the debug output in the Visual Studio output window. The spew from the debug runtime should provide you with all the information you'd ever want (and more!) concerning InvalidCallExceptions [wink] For tracking down errors in shaders, you should use the out string errors parameter in the Effect constructor, this will contain any shader compilation errors.
transwarp
transwarp
@remigius: Thanks for the hint, I never really looked at the output-window after build-time.

Unluckily, I don't seem to be able to find the information I'm actually looking for. I created an error on purpose (trying to load a non-existant model-file) but all I'm getting in the debug output is:

Quote:

Direct3D9: :====> ENTER: DLLMAIN(0354d6e0): Process Attach: 00000be8, tid=00000dc0
Direct3D9: :====> EXIT: DLLMAIN(0354d6e0): Process Attach: 00000be8
Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.
D3D9 Helper: Enhanced D3DDebugging disabled; Application was not compiled with D3D_DEBUG_INFO
Direct3D9: (INFO) :======================= Hal HWVP Pure device selected

Direct3D9: (INFO) :HalDevice Driver style 9

Direct3D9: :BackBufferCount not specified, considered default 1
Direct3D9: :DoneExclusiveMode
Direct3D9: (INFO) :Failed to create driver indexbuffer
Direct3D9: (INFO) :======================= Hal HWVP Pure device selected

Direct3D9: (INFO) :HalDevice Driver style 9

Direct3D9: :BackBufferCount not specified, considered default 1
Direct3D9: :DoneExclusiveMode
Direct3D9: (INFO) :Failed to create driver indexbuffer


Now my obvious question: How do I read this information or where can I find out how to read it?

[Edited by - transwarp on July 11, 2006 7:42:05 AM]
remigius
remigius
This NeXe article might help you understand the debug output a bit better. The output can sometimes indeed be a bit difficult to understand, but you'll generally want to focus on the ERROR messages. By using breakpoints and the 'step through' buttons while debugging, you can find the errors more easily instead of having to browse through the huge pile of output.

The only reason I can think of why the error with loading the non-existent model doesn't show up would be that it's not so much an error within D3D, but simply an error while doing file IO. I noticed the same when trying to load non-existent FX files for effects, but you could just guard against such errors by doing your own checks if the file exists.

Hope this helps :)
g0nzo
g0nzo
Hi again.

I had tens of memory leaks and all pointed to DX SDK Framework class, just because i forgot to dispose a mesh in OnDestroyDevice callback. I really thought it's easier to find memory leaks in C#+MDX. Got to be more careful next time.

However i still get that last warning (in fact lots of them):
"Direct3D9: (WARN) :No SW device has been registered. GetAdapterCaps fails."
It's just a warning, but still it would be nice if i could get rid of it. Anyone knows what it's trying to tell me this time? :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.