Low Frame Rate on Xbox.
by Matthew Hoesterey · in Torque X 2D · 10/14/2008 (9:37 pm) · 18 replies
Hi, I'm having an issue with my game running super slow on the xbox. It's running 100% ok on my pc though.
The game is running at about 1/2 framerate. Also you can actually see the anims slow as I move my character.
right now I'm only loading 1 small texture that I tile across the bottem of the screen as a platform. A small 64 x64 texture for my system objects and a few 1024 x 1024s (with animations on them) as my character.
I'd be surprised if I'm tanking the xbox with only a few textures and objects on screen, unless I'm doing something screwy in code.
Is there some setting I can look for that might account for my low xbox framerate?
Thanks.
The game is running at about 1/2 framerate. Also you can actually see the anims slow as I move my character.
right now I'm only loading 1 small texture that I tile across the bottem of the screen as a platform. A small 64 x64 texture for my system objects and a few 1024 x 1024s (with animations on them) as my character.
I'd be surprised if I'm tanking the xbox with only a few textures and objects on screen, unless I'm doing something screwy in code.
Is there some setting I can look for that might account for my low xbox framerate?
Thanks.
#2
10/15/2008 (7:51 am)
I deployed to the Xbox through VC and then launched it on the xbox.
#3
I've discovered it's not only my game but anything I export to the xbox. I exported XNA ChopperStrike from Johns book and it runs slower on the xbox too.
Also Both games have vertical tearing (black lines in the upper corner of the screen.)
This is running on the Xbox.
It's a bit discouraging that the Sample games run slow too.
Does anyone have any Idea whats going on?
10/15/2008 (6:43 pm)
Is there a way to See the framerate? I've discovered it's not only my game but anything I export to the xbox. I exported XNA ChopperStrike from Johns book and it runs slower on the xbox too.
Also Both games have vertical tearing (black lines in the upper corner of the screen.)
This is running on the Xbox.
It's a bit discouraging that the Sample games run slow too.
Does anyone have any Idea whats going on?
#6
I was sure it was something I was doing with my animation loading or camera movement but I stripped my game down to a single mat and took out my camera movement and still had issues.
Also I tried the backbuffer on 1280 by 720 and 1024 by 768 with no other results.
Choper strike is running slow as well but not as dramatically as my game (probably only about 15-20% slower on xbox then pc) I actually could only see it when I raced the choppers across the screen on the respective platforms. The PC chopper always got to the other side of the map about 2-3 sec sooner. (I realize the test isn't science but it was hard to tell from just the rotter blade speed ;) ).
Lastly the game seams to slow down the most when an object is in the top right of the screen were the tearing is happening. Though it will slow down at seemingly random other times too.
Thanks so much for the help. I've been asking a ton of questions and appreciate the help.
10/15/2008 (8:43 pm)
Also If it helps the game seams to speed up and slow down. I was sure it was something I was doing with my animation loading or camera movement but I stripped my game down to a single mat and took out my camera movement and still had issues.
Also I tried the backbuffer on 1280 by 720 and 1024 by 768 with no other results.
Choper strike is running slow as well but not as dramatically as my game (probably only about 15-20% slower on xbox then pc) I actually could only see it when I raced the choppers across the screen on the respective platforms. The PC chopper always got to the other side of the map about 2-3 sec sooner. (I realize the test isn't science but it was hard to tell from just the rotter blade speed ;) ).
Lastly the game seams to slow down the most when an object is in the top right of the screen were the tearing is happening. Though it will slow down at seemingly random other times too.
Thanks so much for the help. I've been asking a ton of questions and appreciate the help.
#7
I'm trying to figure this out from my end as well. Thanks for any help in advance.
public void FPS()
{
// The Total Game time Ellapsed
float elapsed = (float)Game.Instance.Engine.TorqueTime;
//Find FPS
_calls += 1.0f;
_fps = _calls / (elapsed / 1000);
Game.Instance.FPS(_fps);
}
public virtual void ProcessTick(Move move, float dt)
{
FPS();
}
//I then output this to the screen every frame in my GUI as a string.
10/16/2008 (7:37 pm)
I wrote some code to try and track down the problem. you can see it below. What I found is that my game runs at 33.33333 - 33.32 Frames per second on the pc and a solid 33.3333 on the xbox. (thats assuming 1 process tick per frame, am I right in that assumption?) Whats strange is that despite "running" at 33.33333 on the xbox everything is moving slow.I'm trying to figure this out from my end as well. Thanks for any help in advance.
public void FPS()
{
// The Total Game time Ellapsed
float elapsed = (float)Game.Instance.Engine.TorqueTime;
//Find FPS
_calls += 1.0f;
_fps = _calls / (elapsed / 1000);
Game.Instance.FPS(_fps);
}
public virtual void ProcessTick(Move move, float dt)
{
FPS();
}
//I then output this to the screen every frame in my GUI as a string.
#8
10/17/2008 (4:10 pm)
Arg I looked deeper into the framework and realized the proccess tick is not framerate dependent. I'm going to tap into the update method or temporarily disable UseFixedTimeStamp to get an accurate framerate.
#9
I have no idea why as I've rebuilt the entire project several times. Perhaps an update issue. LOL
In any case everything is working great now though I'd love to know why.
I'm going to make a new project and move my code over just to make sure I'm not missing some file that is linking to old data.
10/17/2008 (4:47 pm)
Ready for this one? So I set UseFixedTimeStamp to false. Then I ran it on the pc and xbox. everything ran super fast which is bad but anticipated. I then set UseFixedTimeStamp back to true and redeployed. Everything runs great now....I have no idea why as I've rebuilt the entire project several times. Perhaps an update issue. LOL
In any case everything is working great now though I'd love to know why.
I'm going to make a new project and move my code over just to make sure I'm not missing some file that is linking to old data.
#10
10/17/2008 (5:24 pm)
I take that back it stopped working again :(. I copied all my code, xml, and engine settings over to a new project file and re-deployed. It's running slow on xbox again. I can't get it to run fast again. Any Ideas?
#11
I changed my settings to look like this :
10/17/2008 (9:38 pm)
I may have got it working again. Well I did I just hope that it keeps working :)I changed my settings to look like this :
<?xml version="1.0" encoding="utf-8" standalone="yes" ?> <TorqueEngineSettings> <SimulateFences>false</SimulateFences> <UseFixedTimeStep>true</UseFixedTimeStep> <UseInterpolation>false</UseInterpolation> <EnableAudio>false</EnableAudio> <GraphicsClearSettings> <ClearColor valueOf="Microsoft.Xna.Framework.Graphics.Color.Black"/> </GraphicsClearSettings> <WindowsGraphicsManagerSettings> <PreferMultiSampling>false</PreferMultiSampling> <PreferredBackBufferHeight>960</PreferredBackBufferHeight> <PreferredBackBufferWidth>1280</PreferredBackBufferWidth> </WindowsGraphicsManagerSettings> <XboxGraphicsManagerSettings> <PreferMultiSampling>false</PreferMultiSampling> <UseDisplaySizeForBackbuffer>true</UseDisplaySizeForBackbuffer> </XboxGraphicsManagerSettings> </TorqueEngineSettings>
#12
John K.
10/18/2008 (8:59 am)
UseFixedTimeStep should always be false. Setting SimulateFences to true might help, I have tested that on Xbox. But game performance will really depend upon what's going on within all of your ProcessTick() methods. If all of your components have ProcessTick() methods that are doing a lot of time consuming tasks, the game will run really slow. As for PC vs. Xbox, the PC might be running faster where large graphics are involved - size, not quantity. Xbox isn't that good about workgin with large graphics in memory. Take ChopperStrike - I think the background graphic is pretty big. If that image was sliced and manually tiled together in the scene, performance would probably improve on the Xbox and stay the same on the PC. Also, getting an accurate framerate is only going to happen if you do that in the Update method in the game.cs file. I'll look around for my implementation and post that.John K.
#13
I should set UseFixedTimestep to false? I was under the impreshion that UseFixedTimestep made the process ticks consistent so that the game runs the same on all computers regardless of there speed. When I set it to true the parts of my game in the process tick run to "fast". I know this could be because the math in the process tick code was made when UseFixedTimeStep was set to false.
Should I Set this value to false and then just adjust the math in my code? if I do that will my game run at the same speed on all computers?
10/18/2008 (6:47 pm)
Hi John, I have everything running great with the settings above but would like to get them "right" so I don't have issues in the future.I should set UseFixedTimestep to false? I was under the impreshion that UseFixedTimestep made the process ticks consistent so that the game runs the same on all computers regardless of there speed. When I set it to true the parts of my game in the process tick run to "fast". I know this could be because the math in the process tick code was made when UseFixedTimeStep was set to false.
Should I Set this value to false and then just adjust the math in my code? if I do that will my game run at the same speed on all computers?
#14
Also, you should definitely do your best to optimize ProcessTick() methods. A couple of effective ways to do this to remove ALL variable declarations. Instead, create the variable once at the class level and reference that variable within ProcessTick(). Also, don't compute on every tick. Not many things need to be accurate down to the tick - instead, setup a tick count variable in the class (like: int TimeSinceLastTick). Then, in your ProcessTick() method, increment that variable. If the counter hits, say 3 or 5, then, set it back to 0 and perform your task. This is especially true for AI components that do not be accurate down to the tick, but rather down to the second. Also, don't do big expensive functions, like searching the object database, on every tick. Nothing will likely move so fast that it has to be checked on every tick. Also, avoid the C# foreach operator at all costs! It's much less efficient than a simple for loop.
John K.
10/18/2008 (7:41 pm)
I think it's best to set UseFixedTimeStep to true for PC games, where the hardware is not likely to be consistent. But on Xbox360, the hardware is essentially consistent, so the focus should be on performence. Therefore, setting thie property to true is best for Xbox 360 games. Also, you should definitely do your best to optimize ProcessTick() methods. A couple of effective ways to do this to remove ALL variable declarations. Instead, create the variable once at the class level and reference that variable within ProcessTick(). Also, don't compute on every tick. Not many things need to be accurate down to the tick - instead, setup a tick count variable in the class (like: int TimeSinceLastTick). Then, in your ProcessTick() method, increment that variable. If the counter hits, say 3 or 5, then, set it back to 0 and perform your task. This is especially true for AI components that do not be accurate down to the tick, but rather down to the second. Also, don't do big expensive functions, like searching the object database, on every tick. Nothing will likely move so fast that it has to be checked on every tick. Also, avoid the C# foreach operator at all costs! It's much less efficient than a simple for loop.
John K.
#15
Could I also ask one other performance question.
My main character has a large number of animations and as such I have to use more then one texture sheet. I'm keeping the amount of textures loaded relatively low. But was wondering. If an object loads in multiple textures for animations does torqueX cache all the textures or will it unload and reload them each time they are called. I'm not sure if it knows to pool the data. Right now I have all the anims loaded off screan with the pool option checked. Is this necessary, or is torque already caching the anims?
Thanks for the info! It should help a ton.
10/19/2008 (1:03 am)
Awesome. :) thanks so much for the info!Could I also ask one other performance question.
My main character has a large number of animations and as such I have to use more then one texture sheet. I'm keeping the amount of textures loaded relatively low. But was wondering. If an object loads in multiple textures for animations does torqueX cache all the textures or will it unload and reload them each time they are called. I'm not sure if it knows to pool the data. Right now I have all the anims loaded off screan with the pool option checked. Is this necessary, or is torque already caching the anims?
Thanks for the info! It should help a ton.
#16
John K.
10/19/2008 (10:33 am)
The animation texture sheets are loaded when the animated sptite object is created and remain cached as long as that object exists. They are not re-load upon each playback. Also, when a sprite object is marked as pooled, then its animated textures are also cached between instances of adding and removing the object to and from the scene (for example, when the player dies). The more important task is to make sure that your material sprite sheets are reasonably sized, if you have dozens of 1024x1024 sprite sheets attached to an object, there might not be enough space to keep all that data in memory at once.John K.
#17
Right now my plan is to only use 256 megs of the ram for character materials, enviorments, fx, and sound and leave the rest for the Xna Framework, Engine, AI, ect...
I'm guessing that 256 megs is a conservative amount to leave for processes as I know art tends to eat up most of the memory budgets in Modern games but I'm unfamilure with the xbox so I'm not entirely sure. Does this number sound about right to you?
Also How is the API handling textures? As an uncompressed bitmap a 1024 is 3 megs but as a png (what I'm importing it's about 200k.)
Does Torque or XNA convert the texture into some other format such as .dxt? I'm guessing torque coverts everything DXT 1 or 5 so that each 4x4 block is either 64 or 128 bit * 1.33 for the mips. I'm I correct in that assumption.
10/19/2008 (2:03 pm)
Great thanks for the info. I will be calling a relatively large amount of textures in but I shouldn't have more then 4 characters in a level at once. I know that the xbox only has 512 megs of ram and that not all of that can be used for textures. The problems with speed I was having before where with only one textures loaded, but I know that having a ton of textures could quickly tank performance (especially because the xbox deals so much better with large poly counts then it does with big textures:) )Right now my plan is to only use 256 megs of the ram for character materials, enviorments, fx, and sound and leave the rest for the Xna Framework, Engine, AI, ect...
I'm guessing that 256 megs is a conservative amount to leave for processes as I know art tends to eat up most of the memory budgets in Modern games but I'm unfamilure with the xbox so I'm not entirely sure. Does this number sound about right to you?
Also How is the API handling textures? As an uncompressed bitmap a 1024 is 3 megs but as a png (what I'm importing it's about 200k.)
Does Torque or XNA convert the texture into some other format such as .dxt? I'm guessing torque coverts everything DXT 1 or 5 so that each 4x4 block is either 64 or 128 bit * 1.33 for the mips. I'm I correct in that assumption.
#18
even adding code such as:
Didn't make the game run at an normal frame rate with a fixedTimeStep set to false.
On the other side of things It is still running great on the xbox with fixedTimeStep set to true so though I might not be getting the best performance with that setting I'm going to go with that setting as I don't seem to have a way to make it work the other way. If anyone has any idea why I am getting these results I'd be up to give any suggestions a try.
Also does anyone know if Torque uses a .dxt format at runtime or if textures are uncompressed as raw data?
10/23/2008 (5:56 pm)
I havn't been able to get torqueX to run right on the xbox without fixedTimeStem to trueeven adding code such as:
public virtual void ProcessTick(Move move, float dt)
{
_gameTime = Game.Instance.Engine.TorqueTime;
_elapsedTime = _gameTime - _lastCallTime;
if (_elapsedTime >= _tickTime && _elapsedTime > 0)
{
_doStuff();
_lastCallTime = Game.Instance.Engine.TorqueTime;
}
}
protected override bool _OnRegister(TorqueObject owner)
{
_gameTime = Game.Instance.Engine.TorqueTime;
_lastCallTime = (Game.Instance.Engine.TorqueTime + 1.0f);
_elapsedTime = 0.0f;
_tickTime = 30;
_timeMultiplier = 0.0f;
}Didn't make the game run at an normal frame rate with a fixedTimeStep set to false.
On the other side of things It is still running great on the xbox with fixedTimeStep set to true so though I might not be getting the best performance with that setting I'm going to go with that setting as I don't seem to have a way to make it work the other way. If anyone has any idea why I am getting these results I'd be up to give any suggestions a try.
Also does anyone know if Torque uses a .dxt format at runtime or if textures are uncompressed as raw data?
Torque Owner Christian Rousselle
Default Studio Name