Mark
Mark

Reputation: 155

DirectX 11 API and exception safety

Is there anywhere I can find documentation on the exception safety levels of different methods in the DirectX 11 API?

Upvotes: 1

Views: 391

Answers (1)

Chuck Walbourn
Chuck Walbourn

Reputation: 41127

None of the DirectX APIs in C++ will throw C++ exceptions. They won't generate SEH exceptions either unless there's some kind of runtime or user-mode driver bug, or a breakpoint is triggered by the debug runtime.

That's why they all return HRESULTs or void.

In general Direct3D 11 objects follow standard COM lifetime rules based on their AddRef/Release reference counts with the major exception that if the device is fully released, then all device-child objects created from it are immediately invalidated.

Even if not using C++ exception handling, it's good practice to write exception-safe code and using Microsoft::WRL::ComPtr for DirectX 11 interface objects is a good idea--with the caveat that you need to ensure the final device instance itself is released/reset last of course.

Upvotes: 2

Related Questions