سؤال

I am working with a fairly large and complicated codebase I am not familiar with, which uses DirectWrite for text rendering. I don't know whether if it matters, but this is a WinRT (Windows Store) application.

The app is multi threaded, and some DirectX calls are done from a background (not UI) thread. All the BeginDraw and EndDraw calls are made from the UI thread, and some of the DrawText calls are made from background threads. I made sure that none of these calls overlap, and DrawText is only called between BeginDraw and EndDraw pairs.

However, sometimes I get a SEHException when calling the DrawText method. It never happens when it is called from the UI thread, only when called from a background thread.
This does not happen on every computer. It very often happens on some, and can not be reproduced at all on others.
The exact message the VS Debugger says is this: "A first chance exception of type 'System.Runtime.InteropServices.SEHException' occurred in x.DLL", and it happens when I call the ID2D1DeviceContext.DrawText() function, and the debugger breaks in the d2d1.h header file at the DrawText call.

Is there any way to debug or diagnose what is going wrong when a SEHException is thrown? (It is clearly connected to calling the DrawText function from a background thread.)
And apart from this, are there any general rules of calling DirectX functions from background threads? (I made sure that the D2D1Factory gets created with D2D1_FACTORY_TYPE_MULTI_THREADED option.)

هل كانت مفيدة؟

المحلول 2

The problem only occurred on a single computer, and couldn't be reproduced on others. And after a video card driver update it ceased on that computer as well, so it might have been some driver issue (there have already been some problems with the Nvidia drivers for Windows 8).

نصائح أخرى

A SEH exception is simply a Win32 exception: the exception mechanism used by Windows internally, which is a different from C++ exceptions.

So all a SEH exception tells you is that "some Windows function threw an exception". As with any other exception, that can happen for a lot of reasons.

So asking what the "usual reasons" for such an exception is, is kind of futile.

What are the usual reasons for a std::exception? There are a lot of them.

Make sure to turn on the DirectX debug runtime. Run in visual studio. It has very verbose error checking that is printed to the console. To turn it on run the DirectX control panel.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top