How to reduce XNA game CPU usage while nothing worth computing is happening?

删除回忆录丶 提交于 2019-12-10 17:09:45

问题


A fresh XNA game project application consumes quite some CPU percentage while its window is active. On my desktop PC it's about 30% of one core of a 2-core processor. When the window loses focus, the game goes into idle mode and consumes about 1% of CPU.

In an image viewer application I recently made using XNA, redrawing frames when no image manipulation is going on doesn't make much sense, so I'm using the SuppressDraw() method which, as the name suggests, suppresses spending resources for drawing the next frame, showing the last drawn frame instead. But still, there's a problem where the application keeps wasting CPU for a very simple input update.

How do I reduce the CPU usage for an XNA application when it doesn't require much of it?


回答1:


quote from this question

According to this discussion on XBox Live Indie Games forum , apparently on some processors (and OS-s) XNA takes up 100% CPU time on one core when the default value of Game.IsFixedTimeStep is used.

A common solution (one that worked for me as well) is to put the following in your Game constructor: IsFixedTimeStep = false;

more details here



来源:https://stackoverflow.com/questions/16704284/how-to-reduce-xna-game-cpu-usage-while-nothing-worth-computing-is-happening

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!