|
View previous topic :: View next topic
|
| Author |
Message |
casey Site Admin
Joined: 18 Dec 2004 Posts: 1835 Location: Seattle
|
| |
Posted: Wed Jan 16, 2008 12:41 pm Post subject: Microsoft Gamepads: 1,000,000 cycles per poll? |
 |
|
For the last several days I've been working on really annoying things, like full-screen OpenGL failing for no apparent reason on a specific computer (Fujitsu Lifebook), weird vsync behavior, Windows' kernel fucking me every which way on my resource loading thread, etc.
Most recently, I've come across a wonderful little surprise, which is that allowing XInput in my game actually has a rather severe impact on my frame time. It took me a while to figure this out, because it's not something I would normally think of checking... but after blocking it out with my inline profiler and then manually confirming it by commenting out the polling call, I seem to have reached the inescapable conclusion that polling four Microsoft Gamepads takes upwards of around 4-5 million cycles.
The best part? It takes that long even if there aren't any gamepads connected. It even takes that long if the little Wireless receiver is completely unplugged.
How can it take five million cycles to not tell me anything? I mean I'm assuming that it doesn't actually even gather the information during the call, right - presumably the driver gathers the data asynchronously, and the call is just going to make a copy of the current state for your app to process. How can this take a million cycles per controller???
Seriously, can someone from Microsoft send me the secret clue here? Do you have to compute Pi in a bigint or something in order to return the direction of the analog stick or something? What is going on in there?
- Casey |
|
| Back to top |
|
 |
TomF
Joined: 18 Feb 2007 Posts: 124 Location: Seattle
|
| |
Posted: Fri Jan 18, 2008 7:54 am Post subject: Re: Microsoft Gamepads: 1,000,000 cycles per poll? |
 |
|
It's not something dumb like it thinks you have ancient analogue joystick attached is it? The sort where you send it a pulse to fill a capacitor, then do a loop until you get a 1 back?
Ah, the days when you'd get a better framerate if you put the stick in the top-left corner. Good times. |
|
| Back to top |
|
 |
casey Site Admin
Joined: 18 Dec 2004 Posts: 1835 Location: Seattle
|
| |
Posted: Fri Jan 18, 2008 4:02 pm Post subject: |
 |
|
I wish. It's XInput, so they don't support legacy controllers, so if somehow it was still checking for some that would be pretty ridiculous...
- Casey |
|
| Back to top |
|
 |
BrianRichardson
Joined: 22 Jan 2008 Posts: 6 Location: Portland, OR
|
| |
Posted: Tue Jan 22, 2008 7:18 pm Post subject: |
 |
|
I vaguely remember hearing about similar issues when XInput was polling for controllers that didn't exist or were unconnected. It maybe a timeout inside of XInput. I think the fix was to not poll devices that returned disconnected, or to poll those devices much less.
This is blurry second-hand information from a few months ago, but it might push you in the right direction. |
|
| Back to top |
|
 |
casey Site Admin
Joined: 18 Dec 2004 Posts: 1835 Location: Seattle
|
| |
Posted: Wed Jan 23, 2008 3:41 pm Post subject: |
 |
|
I haven't actually gotten around to this to-do item yet. I did briefly test with the transceiver plugged in and not plugged in, but I have not yet tested with controllers in/out yet since I didn't have them handy. I will report the timings when I have them.
- Casey |
|
| Back to top |
|
 |
sean
Joined: 01 Feb 2005 Posts: 1549 Location: Kirkland WA
|
|
| Back to top |
|
 |
casey Site Admin
Joined: 18 Dec 2004 Posts: 1835 Location: Seattle
|
| |
Posted: Thu Feb 21, 2008 3:09 pm Post subject: |
 |
|
Awesome.
And XInput was so nice otherwise. I guess they really can't do anything right over there.
- Casey |
|
| Back to top |
|
 |
|