PocketMatrix forums

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

3D Pool tech demo - Performance/Compatibility testing wanted

Edit: A 2nd .exe, using the experimental MediaQ PocketHAL lib is now included in the .zip

This is something I've been working on on-and-off for a while... But I've had quite a bit of spare time to work on it as I'm 'between jobs' at the moment....

- Uses PocketHAL 0.4beta
- Currently only supports 565 displays
- No gameplay/physics yet - it's really just a test of the 3D engine

If it works, it should look like this:

Image

Demo is here:

http://www.bluescrn.net/PocketPockets.zip
(there's no installer - just copy both files to your PPC and run the exe)

Run it at your own risk.... It works fine on my iPaq, but other than that it's completely untested, and PocketHAL is also still beta...

I get between about 48 and 56fps on my iPAQ 3870. But haven't got anything else to test on...

There's still a fair bit of room for optimization, as it's almost all in C (other than clearing the screen...)
Kzinti · 04 Dec 2003, 18:17 UTC — 3D Pool tech demo - Performance/Compatibility testing wanted
bluescrn wrote:
This is something I've been working on on-and-off for a while... But I've had quite a bit of spare time to work on it as I'm 'between jobs' at the moment....


Nice! Runs at 35 fps on my iPAQ 2215.

bluescrn wrote:
- Uses PocketHAL 0.4beta
- Currently only supports 565 displays


If you use PocketHAL, then you support all displays. Non only 565.
bluescrn · 04 Dec 2003, 18:27 UTC — 3D Pool tech demo - Performance/Compatibility testing wanted
Thierry wrote:
If you use PocketHAL, then you support all displays. Non only 565.


Nice :)

I only switched from GD to PocketHAL recently, and hadn't realised that PocketHAL takes care of pixel formats.

Are non-565 devices still common? or are all recent devices 565?

(I've put in my own RGB444 support in my blitting/bitmap loading/alpha blending for Symbian Series 60 devices, but haven't got a working Symbian build yet...)


35fps on a 2215? That's a bit disappointing - Especially when compared to the PocketQuake benchmarks where the 2215 is far faster than the 206Mhz StrongARM-based iPaqs...
Kzinti · 04 Dec 2003, 18:30 UTC — 3D Pool tech demo - Performance/Compatibility testing wanted
bluescrn wrote:
I get between about 48 and 56fps on my iPAQ 3870. But haven't got anything else to test on...


If it wasn't for the bloody MediaQ, this should run at around 70 fps on the 2215. MMmm... Do you have an email address I can use to send you something? I'd like to test your thing with an experimental MediaQ driver (I need a real world application to validate a few ideas).
bluescrn · 04 Dec 2003, 18:35 UTC — 3D Pool tech demo - Performance/Compatibility testing wanted
Thierry wrote:
MMmm... Do you have an email address I can use to send you something? I'd like to test your thing with an experimental MediaQ driver (I need a real world application to validate a few ideas).


dave.reed (at) realismstudios.com

(If it's a quick job, I can probably do it right now)
Kzinti · 04 Dec 2003, 18:40 UTC — 3D Pool tech demo - Performance/Compatibility testing wanted
bluescrn":2zn7lqmj]


It's basically just relinking with a new PHAL.lib, but I can only send it to you tonight (it's 10h40 AM here).
bluescrn · 04 Dec 2003, 18:45 UTC — 3D Pool tech demo - Performance/Compatibility testing wanted
Thierry":1f5c0vpi]
bluescrn wrote:


ok, it's 6:40pm here... so I'll proably be asleep by then. If you send the lib, I'll do it tomorrow
StephC · 04 Dec 2003, 20:30 UTC — 3D Pool tech demo - Performance/Compatibility testing wanted
bluescrn wrote:
35fps on a 2215? That's a bit disappointing - Especially when compared to the PocketQuake benchmarks where the 2215 is far faster than the 206Mhz StrongARM-based iPaqs...


Hell... How many people are relying on this PQ benchmark to evaluate gaming performance of a device ?
Considering I haven't heard any major discrepencies until now, it's been pretty damn accurate in ranking devices in terms of speed. Last I checked, SPB Benchmark and the such also found the 2215 to be fast in numbers.

For some reason, other MediaQ devices like the Dell have been slower than the norm.
bluescrn · 04 Dec 2003, 20:38 UTC — 3D Pool tech demo - Performance/Compatibility testing wanted
StephC wrote:
Hell... How many people are relying on this PQ benchmark to evaluate gaming performance of a device ?


It seemed like a reasonable benchmark of CPU power and main memory bandwidth....

But in the case of devices with the MediaQ chip, they seem absolutely crippled by the final blit to VRAM.... so low-framerate benchmarks (PQ) give no indication of the performance of higher framerate games (my pool game)

I suppose there's an ideal framerate/level of graphics detail, where the 400Mhz/MediaQ devices run at the same framerate as the 206Mhz SA/Normal LCD controller devices... Probably at 25-30fps, though, which is lower than I want to run at....

Basically, the 400Mhz/MediaQ devices are fast for slow games and slow for fast games!
StephC · 04 Dec 2003, 21:14 UTC — 3D Pool tech demo - Performance/Compatibility testing wanted
bluescrn wrote:
It seemed like a reasonable benchmark of CPU power and main memory bandwidth....

Basically, the 400Mhz/MediaQ devices are fast for slow games and slow for fast games!


In my opinion PQ benchmark is not good at all for ranking devices for gaming, unless you want to test only the CPU power (and memory bandwidth), because given the framerate of PQ it does not simulate a real game.

An accurate game benchmark have to report the flipscreen timing, it's sometimes more important than raw CPU power.

I've found that those concepts are REALLY hard to explain to most users... And not being an established developer don't help.
sponge wrote:
For some reason, other MediaQ devices like the Dell have been slower than the norm.


In fact there is not only one MediaQ device, some are 33MHz and others 66MHz, the MQ1178 (the one you'll find in the 2215) is the 66MHz one.

The Dell also have a PXA250 CPU, and a 100MHz bus...
Blue: Nice graphics. What graphics editor did you use?
Updating all the pixels on a 66 mhz MediaQ (ex: 2215) takes around 17 ms. Updating the 33 mhz MediaQ would take around 34 ms (consistent with reports from others, I've heard 35 ms on the 300 mhz Axim).

There is simply no way around it: the bus to the MediaQ is the limiting factor.

This means that high-FPS games (like this pool demo) will suffer a lot and low-FPS games (Quake) won't suffer as much because they don't render that many frames anyway.

It is important to understand that the speed hit is proportional to how many frames you display (per seconds).

Even if we could somehow update the display through a DMA transfer, it wouldn't change the fact that it takes 17 ms for 320x240x2 bytes to be transferred to the MediaQ.
Dan East · 05 Dec 2003, 00:35 UTC — 3D Pool tech demo - Performance/Compatibility testing wanted
bluescrn wrote:
35fps on a 2215? That's a bit disappointing - Especially when compared to the PocketQuake benchmarks where the 2215 is far faster than the 206Mhz StrongARM-based iPaqs...


PocketQuake has to do a lookup into the palette for every pixel output to the display. Thus that may serve as an equalizer for devices with slow display access, because something else is happening (palette loaded into cache line) between each pixel.

Also, if people are not benchmarking at 320x240 (which is my recommended resolution to benchmark at) then only half the screen is being drawn to each frame, which further equalizes performance for devices with slow display access.

Dan East
denthorq wrote:
Blue: Nice graphics. What graphics editor did you use?


The 2D stuff, including textures, all starts out in Paint Shop Pro, then effects like glows, bevelled edges, and drop shadows are added in Photoshop (layer blending options).

(The font was created in Photoshop from a truetype font, and saved with the alpha channel intact)

(Note: if you're creating a small font, Paint Shop Pro can often render small fonts far more cleanly than Photoshop - you can still use Photoshop to add outlines/gradients/drop shadows afterwards)

I load them as .TGAs, and support alpha channels (for the font)

The balls were a very simple 3D rendered sphere. It's a 128x128 texture (actually, one for each ball colour), with no mip maps, so rendering that at small sizes is no good for the cache.. I'm surprised how well they come out when scaled, actually...

Shadows are done by halving the RGB values of the pixel (mask and shift right)

Eventually I plan to support 'american style' pool balls - which are going to be much more tricky - mapping the spots/stripes texture onto a circle (using some sort of normal map/'euler angle map'?), then blending that with the specular highlights...

But the next job is physics... first ball-ball, then the cushions - but I want to be able to support odd shaped tables eventually... (L-shaped, circular)
Kzinti · 05 Dec 2003, 16:51 UTC — 3D Pool tech demo - Performance/Compatibility testing wanted
bluescrn wrote:
ok, it's 6:40pm here... so I'll proably be asleep by then. If you send the lib, I'll do it tomorrow


I just emailed you a version of PocketHAL that includes an experimental driver for MediaQ chips. If you could link it with your pool game and make it available, I'd like to see how well it performs.
bluescrn · 05 Dec 2003, 17:19 UTC — 3D Pool tech demo - Performance/Compatibility testing wanted
Thierry":3ghigaug]


It's there now, in the same .zip as the original demo
a620: 65 to 75 fps
Kzinti · 05 Dec 2003, 18:31 UTC — 3D Pool tech demo - Performance/Compatibility testing wanted
bluescrn":2xqdxsj2]


I've tried it and the speed goes from 35-37 FPS to 65-69 FPS. Quite a nice boost... Except that there is a lot of artifacts on the screen.

Is it possible that you rely on the backbuffer's content (on the previous frame) to update it? If so, have you properly initialized PocketHAL with the SWAP_COPY mode? It looks like you are assuming the copy mode and that PocketHAL was initialized in the default SWAP_DISCARD mode.
bluescrn · 05 Dec 2003, 18:57 UTC — 3D Pool tech demo - Performance/Compatibility testing wanted
Thierry wrote:
Is it possible that you rely on the backbuffer's content (on the previous frame) to update it? If so, have you properly initialized PocketHAL with the SWAP_COPY mode? It looks like you are assuming the copy mode and that PocketHAL was initialized in the default SWAP_DISCARD mode.


No, I'm redrawing the whole screen every frame, straight onto the PocketHAL back buffer, in roughly this order:

- Draw the bottom panel
- Clear top section of the screen (ARM ASM function)
- Update and render all 3D
- Draw text

I think I'm using the default swap mode - will check now. (Does it look like it's drawing to the front buffer??)
Ok, I've uploaded a new version, that sets it to SWAP_COPY. See if that makes any difference?
Kzinti · 05 Dec 2003, 19:03 UTC — 3D Pool tech demo - Performance/Compatibility testing wanted
bluescrn wrote:
No, I'm redrawing the whole screen every frame, straight onto the PocketHAL back buffer, in roughly this order:


Then the default mode (SWAP_DISCARD) is what you want.

I just figured out why it doesn't work properly. It's a bug in my code. Again I won't be able to update you with a new version until tonight or tomorrow morning.
bluescrn · 05 Dec 2003, 19:08 UTC — 3D Pool tech demo - Performance/Compatibility testing wanted
Thierry wrote:
Then the default mode (SWAP_DISCARD) is what you want.


In this mode am I directly accessing VRAM? Or a PocketHAL buffer in normal RAM?

(Directly writing to VRAM could be a bad thing, as I've got a fair bit of overdraw)

Thierry wrote:
I just figured out why it doesn't work properly. It's a bug in my code. Again I won't be able to update you with a new version until tonight or tomorrow morning.


Is it still going to run as fast?.... :)

Anyway, I'm going to the pub now, so won't be messing with it again till tomorrow...
bluescrn wrote:
Ok, I've uploaded a new version, that sets it to SWAP_COPY. See if that makes any difference?


Nice, it works perfectly. Frame rate is now moving between 60-76.

Mmm... Maybe this isn't a bug in my code after all. Not sure. I will investigate and let you know.

Can someone with a slow-ass MediaQ (ex: Axim) try this? Test the normal version and the one named "MediaQ Test 2" and report your results.

Thanks!
heh, well me and my slow ass Axim 400 ran the MediaQ Test 2 version and here is what we found.

Before: 24fps
After: 39-46fps

Note, while the first version held a constant framerate when the display was not moving (ie, i don't press any keys) the second version varied from 39-46fps.

Impressive.

Cheers,
jb

(Note: if you're creating a small font, Paint Shop Pro can often render small fonts far more cleanly than Photoshop - you can still use Photoshop to add outlines/gradients/drop shadows afterwards)


Have you ever tried playing with the different font antialiasing methods? If you turn it off altogether it should be sharp at very small fonts in photoshop(no need to keep switching).

Oh, and that pool game definatly looks awesome.

Thierry, did you call my Axim slow ass!!!!! :D
Have you ever tried playing with the different font antialiasing methods? If you turn it off altogether it should be sharp at very small fonts in photoshop(no need to keep switching).


How do I do that Dill? I'm using Photoshop for all my games graphics. But never experiment on antialiasing ;-)
denthorq, if your using version 6 or 7 it should be in the top toolbar when your currently creating the text. It should be right next to the size box represented by an (aa).

There are options for sharp,crisp,strong, smooth and none.

Sharp is really nice for just any day graphics, but if you want a font you can easily color key, you could choose none. Choosing none should also allow very tiny fonts to be easily readable.
Thierry":36o5vl3a]


Cool, that's the sort of speed I was hoping for :)

If I optimize out some redundant divides, and write my inner loops in assembler, then I think I'll be able to turn vsync on :)

Lots of physics/collision code to write first, though....

btw, what changed with the new MediaQ driver? Is that the difference between a DMA copy and CPU copy (wouldn't surprise me after working with the GBA), or something else?

If the FPS display seems to vary a bit, it might be because I'm using GetTickCount (averaged over 32 frames) - is it as inaccurate on PPC as it is on Win32?

As for Photoshop vs Paint Shop Pro font rendering, I've found that PSP is often unbeatable for small fonts, regardless of the Photoshop antialiasing quality setting... - but Photoshop has it's awesome layer blending effects and good alpha channel support... (Paint Shop Pro really doesn't do alpha channels well....) So for best results, use a mix of the two....
bluescrn wrote:
btw, what changed with the new MediaQ driver? Is that the difference between a DMA copy and CPU copy (wouldn't surprise me after working with the GBA), or something else?


It's something else... ;)

bluescrn wrote:
If the FPS display seems to vary a bit, it might be because I'm using GetTickCount (averaged over 32 frames) - is it as inaccurate on PPC as it is on Win32?


The variable frame rate is a side effect of the method I use to update the display on MediaQ.

GetTickCount() sucks big time and shouldn't be used for anything, really. Try QueryPerformanceCounter() instead.

Your code should have worked with SWAP_DISCARD, I have to fix this before it can become PocketHAL v0.6.
I'm getting 44-55 fps on my 3650.
Thierry, we are interested in testing out your MediaQ optimization ASAP. We can provide benchmarks for the 300mhz Axim X5 as well.

Thanks!

Dan East
Dan East wrote:
Thierry, we are interested in testing out your MediaQ optimization ASAP. We can provide benchmarks for the 300mhz Axim X5 as well.


Do you have an email address I can send the prototype to? As soon as I fix the issue with SWAP_DISCARD I'll drop it in your mailbox.
info@dexplor.com

Thanks!

Dan East
On my pxa 250 (400mhz) Axim, I get between 39 and 69 fps with the second MediaQ version.

The original version gave me 27-29 fps.

Jon
Just following up on what happened: the artifacts that both Bluescrn and Dan were gettting were caused by caching the framebuffer pointer from frame to frame.

You should never do that when using PocketHAL as different buffers can and will be returned depending on the active driver.
And the 3600s are getting nearly the same score? Does this mean a large amount of the MediaQ's performance issue are by and large done by using PocketHAL? I must say, I'm very impressed at what this could bring.
sponge wrote:
And the 3600s are getting nearly the same score?


This seems to be the case for this particular demo. It is by no mean representative of all games.

sponge wrote:
Does this mean a large amount of the MediaQ's performance issue are by and large done by using PocketHAL?


Yes and no. Like I already said, the memory bandwidth to the MediaQ is severely limited. Whether this is caused by the chip itself, it's on-board memory or the 16-bit bus doesn't matter. Writting to video is slow.

The PocketHAL MediaQ Test is basically trying to only update the pixels that have changed. This means that if no pixels have changed, the "swap" is super fast, around 3 ms. In the worst case (all pixels have changed), performances can be slower (ex: iPAQ 2215 = 19.3 ms instead of GAPI's 16.7 ms).

Note that the IPAQ 2215 uses the MQ1178 (66 mhz) and that most (all?) other devices use the MQ1132 (33 mhz). It seems the performance gain is even higher on the MQ1132 (it makes sense... slower bus = bigger gain when not updating it). Dan reported no loss of performances with a 3D engine on the 300 mhz axim when the camera is moving, and a considerable gain when it is not.

sponge wrote:
I must say, I'm very impressed at what this could bring.


The results of this test have convinced me to go ahead and finish implementing my algo for the MediaQ. Basically this means supporting viewports and making sure it works with all orientations/settings.
Ah, I understand. The speedups aren't neccecarily constant in certain conditions (This is what happens when you have utter non-developers trying to understand these things heh..)
Since it is so expensive to transfer data to the display on MediaQ devices, it is better to first check to see if the backbuffer (what the game draws to) has been changed compared to what is currently being displayed (what has already been transferred to DRAM). If no change has taken place for a certain region of the buffer then that region does not need to be transferred to the display for that frame.

As Thierry said, the performance gain is dependant on how much of the screen is updated each frame. For example with a game like PacMan or Asteroids, only a small portion of the screen changes each frame, so very little information actually needs to be uploaded to the display hardware. However with a 3D engine, or a game in which the whole screen scrolls, the entire buffer will need to be sent if the camera is in motion.

Dan East
yes, this is what we've been doing. we added the extra optimization that we usually know if the new screen is going to be really different than the last one, in which case we bypass the 'CheckBLT' (as we call it). you can also do the CheckBLT two pixels at a time (you are probably doing that Thierry, if not, it helps). we actually change some of our game play to present situations were not much changes thus we get great framerates on ball rollouts and such (yep, doing a pool game as well). we also keep track of parts of the screen we know didn't change and don't even bother checking there. Dan... I think we talked about this a couple of months ago. it is a hybrid dirty rectangle approach. you use rectangles for the bulk of the to update or not to update areas and do pixel checks on the smaller areas. this allows us to meet frame rates on the Axim (thus MediaQ) PPCs even with full physics, game play, MP3 streaming etc, etc. the first beta is done and we hope to have the first public beta before XMas. we have some PS2 and XBox titles holding up progress, mainly cause we get paid for them... ;)

Cheers,
rcp
rcp wrote:
you can also do the CheckBLT two pixels at a time (you are probably doing that Thierry, if not, it helps).


I am doing this 2 pixels at a time. I was going to try 1 pixel at a time just to make sure it wasn't faster, but I'll trust your work instead and move to other things. I was expecting it to be slower.
rcp wrote:
(yep, doing a pool game as well)


Doh!... I thought I'd actually found something that hadn't been done particularly well yet on PocketPC, (and more importantly could be done fairly well on my own without an artist....)

Is it you thats doing 'Pool Challenge' (AIM Productions?) - or is that yet another one? (no mention of 3D though, for that one, and no screenshots yet)
I think that this could be useful to add one parameter to the PocketHal Flip function.

A very simple unsigned 32 bits integer.

If this parameter is zero then PH will behave as usual, blitting all the screen (or only some pixels if mediaq is used).

If the param is non zero, then consider each bit as a dirty rectangle :

Example for a 240*320 screen :

bit 0 : (0 0) (240 10)
bit 1 : (0 10) (240 20)
bit 2 : (0 20) (240 30)
.
.
.

This kind of dirty rectangle management add very little overhead to the graphics primitives, and is still efficient.

My 2 cents.
StephC wrote:
If the param is non zero, then consider each bit as a dirty rectangle :

Example for a 240*320 screen :

bit 0 : (0 0) (240 10)
bit 1 : (0 10) (240 20)
bit 2 : (0 20) (240 30)


It would be more consistant to make 0xffffffff mean the entire display needs to be updated, and 0x0 mean that none of the display needs to be updated.

virtual void Swap(unsigned int nDirtyBits=0xffffffff) = 0;

Dan East
StephC wrote:
I think that this could be useful to add one parameter to the PocketHal Flip function.
(...)
If the param is non zero, then consider each bit as a dirty rectangle :


I really like this idea of using a bitfield to specify the update regions. But the mapping you propose doesn't provide any advantages over setting the viewport.

One thing that you can't do right now is specify multiple dirty rects and this is something I'd like to have. Think about a game like Pac-Man that has 5 sprites moving and 4 powerpill flashing. I'd like to only update these 9 small rectangles, not the whole screen or a viewport that wraps them all.
I agree with Dan about the default value, 0xffffffff is more consistent, but its not an usual default value... I fact it doesnt matter much.

Thierry wrote:

I really like this idea of using a bitfield to specify the update regions.
One thing that you can't do right now is specify multiple dirty rects and this is something I'd like to have.


You may have multiple bits set in the 32 bits integer.

if two sprites are moving in the top and one in the bottom this may result in something like :

1100000000000000000000000000001

(considering than at least one of the top sprites is overlapping on two rectangles.
StephC wrote:
You may have multiple bits set in the 32 bits integer.


It would actually be easier to let the user specify an array of 'n' rectangles... I don't see the gain in having the users calculate this imprecise bitmask and PocketHAL converting it back to rectangles.
Thierry wrote:
It would actually be easier to let the user specify an array of 'n' rectangles... I don't see the gain in having the users calculate this imprecise bitmask and PocketHAL converting it back to rectangles.


I think it's the faster way to maintain a set of dirty rectangles, because you don't have to maintain any structure in memory, the gain is on the cache memory access.

And I don't think PHAL has to convert the bitfield back to rectangles...

Also you don't have to test x coordinate when you set the bits in the bitfield.

But it's imprecise, it's not easy to evaluate precisely if this algo will add a real gain or not.

But I like it, and "feel" that it's the fastest technique.

I know this technique was used by some demomakers in the past, and those guys know what is fast and what is not.
StephC wrote:
I think it's the faster way to maintain a set of dirty rectangles, because you don't have to maintain any structure in memory, the gain is on the cache memory access.


Agreed.

I see two potential problems:

1) What if the blit from the backbuffer needs to be rotated by 90 degrees. You end up with vertical strips instead of nice memory-aligned bands.

2) What about supporting different resolutions (E805, SmartPhone, HPC, ...). Your bands no longer have a fixed height.
sorry for the late reply.

The pool game is a port of Virtual Pool. (www.celeris.com) The game is basically the VirtualPool 1 physics/gameplay with a new graphics engine. It is in 3D with full textured rooms, table and light mapped balls. I will try to post screenshots soon. VP has a good following and is fun to play.. IMHO, it is really fun on the PPC due to the stylus control. I promise a public beta before XMas. I am really anxious to see what you guys think.

Cheers,

jb