PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Axim speed problems

Well, I finally was able to pick up a new PocketPC after all this time... Got myself a Dell Axim Basic. Hooray for Dell credit! :)

Anyway, I of course wanted to check how my current game project runs on it. The results are not good...

My game is coded to run at 40FPS. On my stock (150MHz) Casio E-125 it does so, occassionally dropping to 37-39 when the action is a little more intense.

On the Axim though, the average FPS is around 26, sometimes falling to 23, never higher than 29.

I am using the X-Scale GD 2.04 DLL, I haven't tried the plain ARM 2002 DLL.

The screen is in standard portrait mode, and for most of the game it is only a 200x200 area that is constantly updated, the rest of the screen is pretty much static. I am using built-in clipping.

What is going on? Anyone see similar results? I looked for other threads regarding this put I didn't find any. Any I missed somewhere?

I should note I currently have my Axim overclocked to 400MHz, so it's reasonable to think it would run SLOWER at stock speed. Not good at all. Is this an issue specific to this model, a GD issue (that maybe is resolved in 2.05?) or something else?

This is a very depressing situation, I'm hoping it's something that's easily resolved, but any info anyone has will be greatly appreciated.
This is a known problem with MediaQ based devices.

The final blit (memory -> framebuffer) is what is slowing the whole process down ( 20 ms as opposed to a standard 5 ms on non mediaq based devices)
There is not much you can do short of limiting number of bytes being blitted to the framebuffer.
Ah crap, I was afraid it was going to be something like that.

Does you warmi, or anyone else, know where I can obtain a list of devices using the MediaQ chip? Because I'm going to have to list them as not supported for my game since the speed makes it not play very well.

I suppose I could implement a frame skip feature, but that's not the way to go.

That is seriously messed up. I bet the game runs full-speed on an old SH3 device, but now a brand-spanking new device. Can we say BIG F'ING MISTAKE?!?
Yeah. It sucks.

As far as I know, Toshibas e3xx and Axims are the most popular devices using MediaQ chip.

Obviously is the frame rate drop is too severe there is not much you can do but if it is manageable ( and 20 fps should be perfectly fine for great majority of games) then you can redesign your game to use floating point position/movement variables and then simply adjust values depending on the current frame rate.
Basically make your game frame rate independent.

PS.
When I say floats I mean fixed point ...
Well, as the game is designed today, it's playable, but noticeably degraded. I wouldn't feel right selling it the way it performs on my Axim, even though it works and is playable.

However, the FMV's that are to be added later MUST run at 30FPS solidly to work right (for voiceover syncing and such), so that's kind of a deal-breaker anyway. I had been assuming, incorrectly it turns out, that if it runs fine on my E-125 I should be fine on any "modern" device. It seemed like a safe assumption at the time :(

Redesigning it as you suggested, at this point, isn't really an option I suspect. I'm too far into it now to do that. I have to admit I don't understand how you desribed implementing it anyway, and I want to, even though I'm not going to do it.

I mean, the way I do it today is that each object on the screen that moves has a "speed" value associated with it. This is just the interval in frames between movements (i.e., a speed value of 3 means it moves every 3rd frame). Some objects will also move more than 1 pixel per interval, but most move one pixel in some direction. This is of course dependant on frame rate in the sense that if the frame rate slows down, so does the movement obviously, but I don't know how to do it otherwise.

I would absolutely appreciate a short "tutorial" on how to not do this very much :)
It is actually quite simple.

For example you assign a given speed value to an object , say 1.0 at 40 fps which will be your target or default movement rate for this object.
During runtime you measure FPS and multiply your movement value by (targetFPS / currentFPS).

So for example if your frame rate drops to 30 and your object is supposed to be moving at 1.0 at 40 FPS ( your perfect rate) you would do :

1.0 * 40/30 which would result in your object "speeding up" to 1.3 per frame as opposed to 1.0 per single game update.
This way your objects will move at the same speed regardless of the current frame rate.

Of course, if your frame rate drops to 5 fps, this algorithm will result in your object moving at 8 pixels per one game update which will look rather crappy but still, the game itself will still run at the same speed.
Maybe I'm missing something, but isn't it better to base movement and other animations on time rather than frames? I use GetTickCount() and compare the speed value to how many ticks have lapsed. Animation is smoother on faster devices because more frames can be shown to cover the same "distance"

Pam
Ah! I see! Your right, it is quite simple.

I was about to ask how I move 1.3 pixels per frame, but then it dawned on me that you just add it to your X coordinate and round that to an integer value to plot it. Since in your example 1.0 * 40 = 40, and 1.3 * 30 = 39.9, when you round off the vales you have still moved the same 40 pixels per second in either case.

You know, I should be able to pretty easily retrofit my code to implement this. In fact, it'll arguably have other benefits besides keeping the game running at a roughly constant speed because I don't really have to do checks each frame to see if it's time to move a given object. Now I just do the calculation and move it, and I can of course set values < 1.0 to skip some frames.

Thank you for that wonderful explanation. Others have tried to explain it, but none did it as well as you just did (part of it was undoubtedly me being thick-headed though).
Pam:
It is the same concept.
Pam, are you saying that if I'm targeting 40 FPS as ideal and I have a device that can actually render 80 FPS that half of your frames are essentially unchanged? I.e., your first rendered frame is the same as your second, then you change things on your third, then render the same for the fourth, and so on?

If so, I can see how that would be better for faster devices, but I don't understand how it helps if the frame rate can't meet the minimum 40.

Warmi, one other question on your approach... Is there some variance between ideal and actual frame rate where the approach yields poor results? You mentioned that 5 FPS yields 8 pixels moved per frame, and that is obviously bad. But it seems like 1.3 pixels per frame if we drop to 30 FPS is reasonable. My question is, what's the lowest FPS, in your opinion, that you can hit and still have decent-looking results?
warmi wrote:
It is actually quite simple.

For example you assign a given speed value to an object , say 1.0 at 40 fps which will be your target or default movement rate for this object.
During runtime you measure FPS and multiply your movement value by (targetFPS / currentFPS).

So for example if your frame rate drops to 30 and your object is supposed to be moving at 1.0 at 40 FPS ( your perfect rate) you would do :

1.0 * 40/30 which would result in your object "speeding up" to 1.3 per frame as opposed to 1.0 per single game update.
This way your objects will move at the same speed regardless of the current frame rate.

Of course, if your frame rate drops to 5 fps, this algorithm will result in your object moving at 8 pixels per one game update which will look rather crappy but still, the game itself will still run at the same speed.

That is exactly what I do in the game Pod, which seems to work very very well. Everything has its own speeds: pods, missiles, grenades and lasers, and they all move based on the current frame rate, which keeps everything smooth. I'd be very interested to hear what kind of FPS it runs at on other devices, as it was designed on my Axim 300MHz. The only responses I've heard so far is that it's "very smooth". :D
fzammetti:

Well, there is no really a good answer for this.
It all depends on your game.
I think you shouldn't worry about that, for example most of ”big” PC games work in a similar way - if your hardware is too slow you will get choppy animation/slide show style game play but they won't abort or quit with a message that your computer is too slow or anything like that:-)

You might want to make sure that below certain FPS you start skipping visual updates ( drawing) to keep your internal game loop going at a certain speed because even if the game variables are being updated correctly ( distance etc ) if your control input loop runs at 5 fps , it will make your game feel sluggish as far as controls are concerned ( you would be sampling user controls at 5 fps ).
Basically, the bottom line is that the visual update ( drawing etc ) should be decoupled from other calculations (movement) and should be given the lowest priority in your game queue.
Yes, after reading all this I think it's well worth the week it'll probably take me to implement this. I have to go home and look through the source, but my gut feeling is that there's no major reworking here, just busy work. Unfortunately, the nature of my current project is such that it will be A LOT of busy work. And working on it part-time, a week sounds about right.

But in the long run I don't see that there's much choice, aside from cutting out a potentially large part of potential buyers. I don't want to do that obviously :)

From what you've said, it sounds like the the frame rates I'm seeing should yield acceptable results. The only thing that concerns me is that the rate seems to fluctuate between 25 and 30 (probably averages about 27). I wonder if it's going to studder too much. Guess I'll have to try it and see.

Incidentally, we probably all would have expected this, but just so you know... When I turned overclocking off, the frame rate was unchanged. Just further proof that the MediaQ chip is indeed the culprit, as if we needed more evidence.

Stupid chip, I hate thee!
warmi wrote:
Pam:
It is the same concept.


Indeed, the result is the same. It's just a matter of preference perhaps, but basing movement on time rather than framerate seems more intuitive.

fzammetti wrote:If so, I can see how that would be better for faster devices, but I don't understand how it helps if the frame rate can't meet the minimum 40.


Say you have an object moving at constant speed, say 50 pixels per second. If you get 100fps than you will have 100 frames of animation in that one second of movement, very smooth. If you can only get 5fps, then the movement will be jerky, but the end location of movement will be the same.

I'm not sure of the optimizations, but it seems less math as well. I have some "if" blocks to compare the current time in GameLoop to the last time in GameLoop, and a lasttic=GetTickCount(), but I don't have to do the division of framerate each time.


Pam
Pejo Software - Per · 09 Sep 2003, 17:45 UTC
The iPAQ 2210 also has the MediaQ chip and the final video memory blit is just as slow as on the Dell Axim. I think however that CPU/memory performance is better on the 2210 so you might actually get a framerate that is OK with the 2210. But the highest framerate you can get with a device using the MediaQ chip is around 50 (if you use GAPI).
I really do hope that Johan would be able to support video memory surfaces for the MediaQ chip (and others) so that you could use video memory to video memory blits and other hardware accelerated metods. If PocketFrog/PocketHAL supports this and GapiDraw don't, I would probably switch to PocketFrog.
Frank,

I don't know if this has any relevance for you.

http://www.pcworld.com/news/article/0,aid,112353,00.asp
Nope, doesn't apply. I just got the Axim a week ago, it has the latest versions of everything (umm, well, I *THINK* it does ;) )
Frank, I have the 400mhz Axim, and it seems to run most things decently, though I do notice some jumps here and there. Its a zillion times faster than my 133 sh3 proc though.

I know you dont want to give too much away, but what exactly are you doing in your game when it slows down?
Frank: It works the same for everyone too. The best way would really be to remove some of the least prioritized stuff on your game (eyecandies) and then start adding them as you monitor your framerate drop. This way, you get the "real" game intact w/out sacrificing any FPS. You haven't yet tried ipaq's 5450, it is even slower and you'll be glad you have the Axim. :(
Frank,

Would you like me to run a demo on my 5550 so you have some comparison?

Also:

http://www.pocketmatrix.com/forums/viewtopic.php?t=11897

You could try int13's GXMark or view their device results page to see how well devices perform. It was "under re-construction" last time I looked.

http://www.int13.net/gxmark_results.htm
anonymous: It slows down right from the start. The first title screen, which is just a bltfast of a single 240x320 image (done every frame), is down around 27FPS, as opposed to the 40FPS it's supposed to run at, and does run at, on my E-125.

I also notice that the frame rate fluctuates quite a bit between 25FPS and 30FPS. It's not as steady as I would expect it to be, even within that range. And I'm talking about just sitting and looking at the title screen, not doing anything. Why wouldn't it at least be a stable FPS there, even if it was a low FPS?

I guess the good thing is that it does stay in that range regardless of what's going on in the game, for the most part. One or two parts drop it down to 23 or 24, but it generally stays within that 25-30 range.

egarayblas: There's really not much in the way of eye candy to remove, pretty much everything that's in there is integral to the game. It's already optimized in the sense that I'm not updating every frame things that never change. In actuality, each frame is always redrawing a 200x200 section of the screen, other parts of the screen only change with user interaction. The frame rate isn't effected by that user interaction to any noticeable degree either because it runs at the same speed whether I'm just watching it or actually playing.

StarFury: I may take you up on that offer, just to see what another device pulls off. I just can't stop thinking that it's ridiculous that an E-125 blows the doors off a brand-new device. It's absolutely nuts!

I'm just going to have to implement the time-based method warmi described, I don't see any other option. I mean, these devices effectively bave a theoretical maximum frame rate of 50FPS in effect (20ms for the memory->backbuffer blit) and that's if you were doing nothing at all each frame. So, could I optimize my game a bit and get the frame rate up? Almost certainly yes. Am I going to be able to get it to run at the 40FPS it's designed for? Almost certainly no. So, I'm left with the inescapable fact that a 3 or 4-year old device runs the game better and I have to do a bunch of extra coding I didn't plan for.

Bleh either way.
fzammetti wrote:
I just can't stop thinking that it's ridiculous that an E-125 blows the doors off a brand-new device. It's absolutely nuts!

So, I'm left with the inescapable fact that a 3 or 4-year old device runs the game better and I have to do a bunch of extra coding I didn't plan for.


Thanks to MediaQ :)

And they say it's an "accelerator" chip...

It's also very difficult to explain that to the final user...
Actually this chip does accelerate GDI stuff, for which it was designed in the first place.

Still, considering that the majority of PPC games do use framebuffer exclusively, it was rather stupid of MediaQ not to take that into consideration when designing their chip.
warmi wrote:
Actually this chip does accelerate GDI stuff, for which it was designed in the first place.

Still, considering that the majority of PPC games do use framebuffer exclusively, it was rather stupid of MediaQ not to take that into consideration when designing their chip.


The MediaQ chip is not doing things faster then the processor. The idea behind it is that it can do stuff while the CPU is doing something else. This is great in most cases (GDI beeing one), but not for direct access like games do.

I've been working quite a bit with the MQ1178 recently and using the MQ hardware blit is practically running at the same speed as using GDI (20 ms). It is probably safe to assume GDI is using the blit functionality. Now direct access is still a little faster (17 ms). Note that the MQ1178 is faster then the MQ1132 (it was reported to blit in 30 ms).

As I've said many times in the past, PocketPCs are NOT designed with gamers in mind. It is just the way it is.
I am no hardware designer but if the thing is not any faster at say drawing lines than CPU is then why bother with internal memory ( which from what I understand is the reason CPU blits from/to system memory are slow ) ?
warmi wrote:
I am no hardware designer but if the thing is not any faster at say drawing lines than CPU is then why bother with internal memory ( which from what I understand is the reason CPU blits from/to system memory are slow ) ?


Because it's going to draw your lines while the CPU is doing something else. This is the whole point. It is also how the first generations of video cards worked on the PC (think pre-Millenium).

There is also lot of other reasons to use the MQ beside performances: power usage, LCD support, ... The MediaQ chips supports over 20 functions including USB, serial, handling video signals, ...
Yeah, well my point was not why to use MediaQ but why not have it use system memory for its own processing ( it would be like having two CPUs accessing the same memory - one of them being a specialized GPU.)

This way there wouldn't be any problem with slow access to onboard memory by the main CPU ( and thus no 20 ms blits)

Anyway,as you mentioned, quality of gaming on PPC devices is obviously not high on the list of either MS or hardware manufacturers so I guess this whole thing is pointless anyway.
warmi wrote:
Yeah, well my point was not why to use MediaQ but why not have it use system memory for its own processing ( it would be like having two CPUs accessing the same memory - one of them being a specialized GPU.)


My guess it that the MediaQ chip is not designed only for PPC but to support a wide range of embedded systems. Some of these systems might not have any memory (or even a CPU!).
I am pretty sure the E125 is a mips processor, I could be wrong though.
The E-125 is a MIPS processor, but the CPU isn't the cause of the problem here. The MediaQ GPU is.

As I posted previously, the fact that I see the exact same frame rate when my Axim is running at stock 300MHz as I get when I overclock it to 400MHz proves that it's not a CPU issue but something else.
fzammetti wrote:
The E-125 is a MIPS processor, but the CPU isn't the cause of the problem here. The MediaQ GPU is.


Not sure how the good old E125 got into this conversation...

fzammetti wrote:
As I posted previously, the fact that I see the exact same frame rate when my Axim is running at stock 300MHz as I get when I overclock it to 400MHz proves that it's not a CPU issue but something else.


Yes... The bottleneck is the bus to the MQ chip. In the case of the MQ1132, it is operating at 33 mhz. For the MQ1178, it is operating at 66 mhz. This explains why the MQ1178 is about 33% faster. It also explains why performances are independant of the CPU speed.
The E-125 came into the picture because I was comparing performance of my game on it to my Axim. The game is coded to run at 40FPS, and on the E-125 it does that steadily, no problem. The Dell pulls under 30FPS. It was just a comparison (and a very bad assumption on my part... I figured if the Casio can pull off 40FPS without breaking a sweat, SURELY a brand-new XScale-based device would laugh at how easy it was. D'OH!)
Ok, now I'm a little befuddled...

In the interest of expediency, I decided to deal with this all by simply dropping the set frame rate to 24 and changing all my velocity vectors accordingly (which is exactly what the code would have been doing automatically based on frame rate had I gone through all that trouble, but this only took about an hour as opposed to the week I expect the other approach would take).

Now, this basically works as expected, except for one thing...

The frame rate doesn't stay at a stead 24. It drops as low as 21 and fluctuates quite a bit between 22 and 24 inclusive.

This is very odd because the exact same portions of the game were pulling 27 on average when it was set to 40.

It seems like no matter what frame rate I set I always get something lower. In the case of 24FPS the difference obviously isn't that great, but it does seem noticeable.

Anyone think of something to explain this? Am I crazy in expecting that if the frame rate stays above 25 when set to 40 that setting it to 24 should result in a steady 24 based on the logic that if 26-27 on average is the highest it can pull then backing off to 24 should result in a steady FPS?
Pejo Software - Per · 13 Sep 2003, 06:56 UTC
Here is a possible explanation:
Maybe your framerate counting code is doing some averaging.
Yes, I assume it is (it's the code built-in to GapiDraw).

But even if that's the case, the basic logic I was trying to express is, seemingly at least, being broken: if I set the frsme rate to 40 and I'm getting nothing lower thsn 25, and I then set the frame rate to 24, isn't it reasonable to assume I'd see a very steady 24?

Instead I'm ocassionaly seeing numbrs as low as 21, and that doesn't make sense to me.
Pejo Software - Per · 13 Sep 2003, 13:21 UTC
OK let me exemplify what I mean.

Let us say that your framerate counting code is calculates the framerate based on some frames back in time.

You set target framerate to 40 fps(25 ms / frame).
Then the following happens:
1 frame - 20 ms Sleep 5 ms
2 frame - 20 ms Sleep 5 ms
3 frame - 50 ms
4 frame - 20 ms Sleep 5 ms
framerate = 4/0.125 = 32 fps

You set target framerate to 24 fps(42 ms / frame).
Then the following happens:
1 frame - 20 ms Sleep 22 ms
2 frame - 20 ms Sleep 22 ms
3 frame - 50 ms
4 frame - 20 ms Sleep 22 ms
framerate = 4/0.176 = 22.7 fps

I am not sure that this is how GapiDraw works but it is a possible explanation.
Warmi: Can you please post a code sniffet here the simple speed sync? Thanks. I'm confused still.

Code:

//FLOAT nFrameRate = 0;
//m_timer.GetActualFrameRate(&nFrameRate;);

int GameSpeedX = 0;
int DEF_TARGET_FPS = 40;
FLOAT nActualFrameTime = 0;

m_timer.GetActualFrameTime(&nActualFrameTime;);

int FrameRateRatio = int( DEF_TARGET_FPS/nActualFrameTime);

GameSpeedX += (GameSpeedX*FrameRateRatio);

Well, in my case I sync using the current frame rate.
The code I use :
Code:


ZRaid::timerOffset=(60/wrApp->frameRate());



Where 60 is a "desired" frame rate.

wrApp->frameRate() basically evaluates to CGapiApplication.m_timer.GetActualFrameRate().

The resulting value is then used to scale other values like:
Code:

minSpeed=0.5*timerOffset;
maxSpeed=3.0*timerOffset;
baseSpeed=1.2*timerOffset;


So for example when the actuall frame rate falls to 30 the minSpeed will end up being 0.5*2 etc ...


Looking at your code I think you are mixing up two values, time and frameRate:-)
First of all, your FrameRateRatio and frankly all variables related to movement/acceleration should be floats (fixed point). Downcasting to ints should be done in your drawing code.
I generally do something like.
Code:

int getX() const
{
return (int)(floatXValue+0.5);
}

Another issue - if you want to sync using GetActualFrameTime then you need to use DEF_TARGET_FRAME_TIME or something like that and not DEF_TARGET_FPS.

But , judging by your code I think you intended to synch using frame rate so your code should look more like that:
Code:

float DEF_TARGET_FPS= 40.0;
float FrameRateRatio = DEF_TARGET_FPS/m_timer.GetActualFrameRate();

float myShipAcceleration=DEF_SHIP_ACCELERATION*FrameRateRatio ;

But am I doing it right? Also, I need to refetch the actual frame time right? So I have to put it in processnextframe() function everytime.
Warmi: I came up with a Synchronizing Game Speed Function. Can you please check if I'm doing it right.
I post this once you've read and approved it.

Code:

#define DEF_TARGET_FPS 60

float CMyApplication::SynchronizeSpeed()
{
TCHAR msg[100];

static FLOAT nFrameRate = 0;
static FLOAT nFrameRateRatio = 0;

m_timer.GetActualFrameRate(&nFrameRate;);

if (nFrameRate<20) nFrameRate = 45.0;

nFramRateRatio = (float)DEF_TARGET_FPS/nFrameRate;

return nFrameRateRatio;
}

Usage :

int GameSpeed = 3;

GameSpeedX += (int)(GameSpeed * SynchronizeSpeed());