Back to Molly Rocket Molly Rocket
Molly Rocket games and everything even tangentially related
 

  FAQFAQ  SearchSearch  UsergroupsUsergroups 
Log inLog in  RegisterRegister
 

Microsoft Gamepads: 1,000,000 cycles per poll?

 
Post new topic Reply to topic    Molly Rocket Forum Index -> Project Notes
View previous topic :: View next topic  
Author Message
casey
Site Admin


Joined: 18 Dec 2004
Posts: 1835
Location: Seattle

PostPosted: Wed Jan 16, 2008 12:41 pm    Post subject: Microsoft Gamepads: 1,000,000 cycles per poll? Reply with quote

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
View user's profile Send e-mail Visit poster's website
TomF



Joined: 18 Feb 2007
Posts: 124
Location: Seattle

PostPosted: Fri Jan 18, 2008 7:54 am    Post subject: Re: Microsoft Gamepads: 1,000,000 cycles per poll? Reply with quote

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
View user's profile Visit poster's website
casey
Site Admin


Joined: 18 Dec 2004
Posts: 1835
Location: Seattle

PostPosted: Fri Jan 18, 2008 4:02 pm    Post subject: Reply with quote

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
View user's profile Send e-mail Visit poster's website
BrianRichardson



Joined: 22 Jan 2008
Posts: 6
Location: Portland, OR

PostPosted: Tue Jan 22, 2008 7:18 pm    Post subject: Reply with quote

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
View user's profile
casey
Site Admin


Joined: 18 Dec 2004
Posts: 1835
Location: Seattle

PostPosted: Wed Jan 23, 2008 3:41 pm    Post subject: Reply with quote

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
View user's profile Send e-mail Visit poster's website
sean



Joined: 01 Feb 2005
Posts: 1549
Location: Kirkland WA

PostPosted: Thu Feb 21, 2008 8:05 am    Post subject: Reply with quote

Sounds like this might be someone encountering the same thing ?
Back to top
View user's profile Visit poster's website
casey
Site Admin


Joined: 18 Dec 2004
Posts: 1835
Location: Seattle

PostPosted: Thu Feb 21, 2008 3:09 pm    Post subject: Reply with quote

Awesome.

And XInput was so nice otherwise. I guess they really can't do anything right over there.

- Casey
Back to top
View user's profile Send e-mail Visit poster's website
Display posts from previous:   
Post new topic Reply to topic    Molly Rocket Forum Index -> Project Notes All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Molly Rocket topic RSS feed 
Molly Rocket topic RSS feed 
Molly Rocket topic RSS feed, first posts only 


Powered by phpBB © 2001, 2005 phpBB Group