Tuesday, 9 January 2007

Managed DirectInput weird slowdown

Yesterday, while finishing the last details of my Custom ActionMapping system, I noticed a terrible slowdown in my application. In a demo app I was using, the fps falled from 82 to 9 !!!!

Looking for the problem, I found that it was due to an access to the Device.DeviceInformation property. I decompiled the DirectInput libraries, and I found that each time an access to this struct is done, a New() object of the type DeviceInstance is created (and don´t tell me why, it´s done twice). This seems to be the source of the slowdown.

So, avoid accesing this struct at runtime. Instead, pre-get any values you need for each device, to local structs at creation time.

Cheers !

No comments: