The ZBuffer - Managed DirectX resources
Search ZBuffer
Links


 

6/8/06: Added FromStream workaround.

To be able to convert from every possible format of bitmap, Managed DirectX uses Bitmap.GetPixel to read each pixel. This means height*width calls into GDI. Unfortunately due to a known issue (passport required) with the way that the managed debugging assistants (MDAs) work in Visual Studio there is a huge amount of overhead with each under-the-covers PInvoke. This overhead combined with the height*width calls means that textures can take minutes to convert into textures and you would probably think your application has crashed.

Note that this issue only occurs when running your application under the debugger. Outside of Visual Studio your application will run at a perfectly normal speed.

There are several workarounds noted in the bug:

  1. Instead of using Texture.FromBitmap save the bitmap to a memory stream and then read it back using Texture.FromStream. Nice workaround suggested by Wyzfen, implemented by Dave Hunt and documented in this gamedev thread.
  2. Don't use the debugger. Start your application with ctrl-f5 (start without debugging). Useless if you actually need to debug something.
  3. Write the conversion yourself using unsafe code. Note that this may get tricky to deal with the generic case where you have no clue what format the bitmap is in.
  4. Disabling MDAs in general (passport required). Note that this is not turning of the reporting of an MDA like we do for the LoaderLock issue. We have to totally stop MDA checking from occurring using a settings file. You may also have to turn off the Visual Studio Hosting process - or one workaround suggests that this step alone is sufficient.

The following links have more details:

Updated 6/8/2006 10:00:00 AM by Zman