Sign in to follow this  
freka586

[SlimDX] Blank device caps + error handling pattern?

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this