Runs in debug, not release

Started by
2 comments, last by TheUnbeliever 12 years, 1 month ago
I am using Visual C++ 2010 Express, and I just finished the basics of my engine code, and wanted to test under release to ensure it worked properly. I started by changing the settings in the directx control panel to force debug layer off, swapped to release mode, and added the include and lib directories (same as the debug directories). The program compiles and links fine, with no errors, but when I try to run the executable it crashes. I am using DirectInput for all input and XAudio2 for sound. The sounds I have playing actually start before the program crashes, so I'm sure it's in the graphics.

The odd thing in, I can navigate in windows to the debug executable, and it runs perfectly fine. Is there some other step that must be taken when switching to release mode for it to run properly, when running D3D11? I've been looking for a while now, and the only things I can find are questions about getting an app to run on a different computer, not just swapping from debug to release.

Thanks!
Advertisement
When you switch to release mode, a lot more optimizations are enabled by default, and the runtime no longer initializes variables and memory for you. If you're unlucky, this will uncover a bug when you've been unwittingly relying on this behaviour. I would recommend running a release build with the debugger attached (e.g. by switching profile to 'release' and hitting F5). What will probably happen is that you'll discover that you're doing something like dereferencing an uninitalized pointer. Note that, because of said optimizations, release-mode debugging can be an interesting experience.
[TheUnbeliever]
Awesome, managed to get it fixed! The problem was happening around this code:

if(numVSBuffers > 0){
DevCon->VSSetConstantBuffers(0, numVSBuffers, reinterpret_cast<ID3D11Buffer* const*>(g_pVSConstantBuffers));
}

where numVSBuffers is an int. I added "numVSBuffers = 0;" to the constructor for the class, and the problem went away.
Thanks!
Glad to hear :-) Incidentally, you usually want to use an initialization list rather than assignment in the constructor.
[TheUnbeliever]

This topic is closed to new replies.

Advertisement