如何在没有任何值得计算的事情发生的情况下减少 XNA 游戏 CPU 使用率? [英] How to reduce XNA game CPU usage while nothing worth computing is happening?

查看:25
本文介绍了如何在没有任何值得计算的事情发生的情况下减少 XNA 游戏 CPU 使用率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个新的 XNA 游戏项目应用程序在其窗口处于活动状态时会消耗相当多的 CPU 百分比.在我的台式 PC 上,它大约是 2 核处理器的一个核心的 30%.当窗口失去焦点时,游戏进入空闲模式并消耗大约 1% 的 CPU.

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.

在我最近使用 XNA 制作的图像查看器应用程序中,在没有进行图像处理时重绘帧没有多大意义,因此我使用了 SuppressDraw() 方法,作为顾名思义,抑制用于绘制下一帧的资源,而是显示最后绘制的帧.但是,仍然存在一个问题,即应用程序不断浪费 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.

当 XNA 应用程序不需要太多 CPU 时,如何减少它的 CPU 使用率?

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

推荐答案

引用自 this问题

根据 XBox Live Indie Games 论坛上的讨论,显然在某些处理器(和操作系统)上,当使用 Game.IsFixedTimeStep 的默认值时,XNA 在一个内核上占用 100% 的 CPU 时间.

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.

一个常见的解决方案(也适用于我)是将以下内容放入您的游戏构造函数中:IsFixedTimeStep = false;

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

更多详情这里

这篇关于如何在没有任何值得计算的事情发生的情况下减少 XNA 游戏 CPU 使用率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆