[SlimDX] Blank device caps + error handling pattern?

Started by
1 comment, last by freka586 15 years, 10 months ago
When trying to check various device caps (e.g. TextureFilterCaps.SupportsMagnifyLinear) I find that the various caps all seem to be blank. At least nothing shows up using IntelliSense. Is this a Visual Studio issue, user error or are the Caps only stubs and not yet implemented? Something else I noticed when SlimDX-ifying my MDX code was the lack of DeviceReset event and typed exceptions (OutofVideoMemoryException, DeviceNotResetException etc). Is there a different pattern I should be using to get the corresponding behavior for these two things within SlimDX?
Advertisement
Quote:When trying to check various device caps (e.g. TextureFilterCaps.SupportsMagnifyLinear) I find that the various caps all seem to be blank. At least nothing shows up using IntelliSense. Is this a Visual Studio issue, user error or are the Caps only stubs and not yet implemented?


Define what you mean by 'blank'. If by mousing over them nothing shows up in IntelliSense, then it's probably the fault of the debugger. Sometimes mouse over doesn't work. Take a look in your locals window and try expanding the caps structure to see what's really inside.

Quote:Something else I noticed when SlimDX-ifying my MDX code was the lack of DeviceReset event and typed exceptions (OutofVideoMemoryException, DeviceNotResetException etc). Is there a different pattern I should be using to get the corresponding behavior for these two things within SlimDX?


There are no events in SlimDX because they open up a huge possibility for both user error and memory leaks, and they just cause too many problems to be worth implementing. The MDX code internally had to do a lot of extra things to provide them for you. Instead, you need to check for device lost scenarios on your own, just as you would if you were using C++ and DirectX.

There are still individual exceptions; there are just a lot less of them. For example, all Direct3D9 related exceptions get rolled into Direct3D9Exception. All Direct3D10 exceptions get rolled into Direct3D10Exception. The actual exception information (ie. the result and other information) are contained in the exception class that is thrown. This makes it much easier to catch errors, as you don't need a ton of catch blocks to make sure you catch all the possible problems.

On the other hand, SlimDX also provides two other options for error handling. If you want, you can disable exceptions completely (using Configuration.ThrowOnError), and make use of the Result type that is returned from most methods, or make use of the Result.Last member, which contains the result code for the last method called.

The other option is to leave exceptions enabled, but disable them for specific results only. For example, if you want exceptions to be thrown except when a device lost result occurs, you can use the Configuration.AddResultWatch method to customize how you want certain results handled.
Mike Popoloski | Journal | SlimDX
Thanks for the reply!

Yeah, I remembered reading something about events being intentionally removed. Nice to get a quick overview of the options I now have available instead.

Regarding the caps I had simply missed that the old MDX bool flags had been replaced with enums, my bad!

This topic is closed to new replies.

Advertisement