Capture DirectX 10/11 debug output to Visual Studio

Working with default DirectX configuration in a Visual Studio project is like working with a black box. Even more so when you have a managed code project. Mostly you’ll get an ArgumentException saying “Additional information: Value does not fall within the expected range.” or something like that, almost totally not helpful. But fear not, there is a way to capture a ton of useful information right into Visual Studio’s Debug output window. And here is how:

0. I assume you have DirectX SDK already installed.

If not download if it from DirectX Developer Center.

1. Enable debug output in DirectX control panel

a) Go to Start/All Programs/Microsoft DirectX SDK ([Month] [Year])/DirectX Utilities [(64-bit)] and run DirectX Control Panel [(64-bit)]


b) Go to Direct3D 10.x/11 tab. Except for the Edit List… button everything is disabled. The reason is that you have to add applications you wish to debug beforehand you can alter the settings (this is not obvious and UI is really clumsy here).


c) Click Edit List… and add your application to the List of process or folders. Clicking on […] button and selecting application exe file does the trick. Click OK button to close this window.

d) Next step is to actually enable debugging of the application. This can be done in two ways – either select Debug Layer’s Force On or switch on debugging directly from code (shown later in step 2.). You can select which messages won’t be displayed through Mute settings.


2. Alternatively to enabling debugging from step 2d)

You can create the DirectX device in code with CreateDeviceOptions.Debug option, like the code below when using managed code and Windows API Codepack:

D3DDevice device = D3DDevice.CreateDevice(null, DriverType.Hardware, null, CreateDeviceOptions.SingleThreaded | CreateDeviceOptions.Debug, levels);

This option will work with both Applications Controlled and Force On Debug Layer settings but not with Force Off.

3. Enable unmanaged debug output in Visual Studio project

The final step is to allow showing unmanaged debug output in Visual Studio debug output window. This works by default in an unmanaged project but not in managed projects. Note that it is a per-project setting.

Open project properties, Debug tab and make sure that Enable unmanaged code debugging option is checked.


Here you go. You’ll see plenty of DirectX messages in Debug output window from DirectX such as:


Disabled post comments due to spam

Due to the massive spam amount I was getting these days I’ve opted to disable all comments to my posts for the time being. When I figure out a proper anti-spam system I’ll re-enable them, perhaps through reCaptcha or something.

You can still send me the feedback through the Contact form.

Stay tuned.

A good use of an old Windows Mobile phone

Before owning an Android phone (Samsung Galaxy S) I had a HTC TyTN II which is a Windows Mobile 6.1 device. Until recently it was lying in a drawer because I didn’t know what to do with it. I didn’t want to give it away because I was afraid to turn the new owner into an enemy due the the poor quality of the phone. Anyway I am a so-so happy Android user now.

But recently I had to travel to Italy here and there and I was really lost without an internet connection to my laptop. Sure, I could use roaming, but I am not that rich. I figured out that the cheapest way to get connected in Italy is to buy an Italian prepaid SIM card, from TIM in my case. During the buying process I encountered two peculiarities.

1. The vendor asked me for ID. ID? For prepaid SIM card? I learned that they have this fabulous anti terrorism law in Italy that forbids vending SIM cards to anonymous users. Never heard of it in Slovenia. They even forbid vending more than 4 cards to a single person if I recall correctly. Go figure.

2. The guy asked me whether I want to use internet on my phone or on my laptop. Phone of course, why would I pay a premium price? After all Galaxy S comes with a mobile access point and I though it would be fine. It worked in Croatia just fine. Surprise, surprise, it doesn’t work. It works if I access the internet from my phone but not through an access point. After speaking with a fellow MVP network guru Miha Pihler he figured out that they probably inspect TCP/IP packets for traces of NAT and in such cases block the traffic.

One solution to this problem was to switch my Slovene SIM card in Galaxy S with the Italian one each time I travelled to Italy. There are two shortcoming to this solution. It is annoying to switch them again and again and I still couldn’t access internet from my laptop. Hey, I could buy a cheap GPRS modem. Hm, those aren’t that cheap after all, specially because I don’t need it that often.

At this point I remembered my old crappy TyTN II lying in the drawer. I also remembered that there is a really nice internet tethering application out there called WMWiFiRouter. Combining the two and using Bluetooth PAN feature it was a matter of minutes for connecting my laptop through bluetooth to TyTN II to the Italian internet. It is just that easy - a matter of starting the application and clicking a button. Besides Bluetooth PAN WMWiFiRouter can share cellular internet connection through USB and WiFi and much much more, see the features list.

The bottom line is that I finally found a good use for TyTN II and found a good internet tethering application as well which I’d definitely recommended.