PocketMatrix forums

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

PocketHAL 0.4 released

The fourth release of PocketHAL, the next generation library for Pocket PC game development has been released.

Get it fresh at: http://pockethal.droneship.com

PocketHAL can currently be seen as an alternative to GAPI and GAPI-based libraries. You though GAPI was the fastest way to do graphics on your Pocket PC? Think again. PocketHAL can often run twice as fast as GAPI and further optimizations are in the work.

What's new in the 0.4 build:

* This is the first Beta version!
* Added support for viewports, allowing the user to specify the update region.
* Added a PC .LIB file to allow desktop development.
First off, I'm impressed with the performance on my iPaq 3600, which already has a fast blit. Varium FPS increased from 38 to 43, purely from switching to PocketHAL. And my GAPI blit was just a memcpy, so it's pretty amazing that it increased performance that much.

My question is in regards to the future of PocketHAL. Will it always be free, or will that change when it reaches the release state?

Dan East
ChezDoodles · 22 Nov 2003, 23:56 UTC — Smartphone
Sir,

Is Smartphone supported?
Dan East wrote:
First off, I'm impressed with the performance on my iPaq 3600, which already has a fast blit. Varium FPS increased from 38 to 43, purely from switching to PocketHAL. And my GAPI blit was just a memcpy, so it's pretty amazing that it increased performance that much.


That's good to hear! I believe most (if not all) games can benefit greatly from PocketHAL.

Dan East wrote:
My question is in regards to the future of PocketHAL. Will it always be free, or will that change when it reaches the release state?


It will always be free. This won't change. PocketHAL is my own personal project and is not financed by anyone/anything except my free time.
Kzinti · 23 Nov 2003, 00:29 UTC — Smartphone
ChezDoodles wrote:
Is Smartphone supported?


PocketHAL (version 0.4) doesn't yet support SmartPhone, but this will change.

The intention is to at least support all the Windows CE (3.0 and above) devices, and this includes Pocket PCs, Handheld PCs and Smartphones.
[ignorance]
Don't suppose there would be a way in which an end-user can run a program, have it hook into something, and gain at least a fraction of the speed PocketHAL would give you? IE replace all calls for something with PocketHAL's.
[/ignorance]
Let me ask you another question. On your website you mention that devices that are not currently optimized for fall back to the same mechanism as GAPI. Do you have a list of specific devices that are optimized for? We see no performance change on the Axim X5 300mhz with PocketHAL. Have you optimized for that device? If not then it would be a very good candidate, because it is prolific, and has terrible display write speed. Like max 45 FPS with nothing but a memcpy loop.

Dan East
sponge wrote:
[ignorance]
Don't suppose there would be a way in which an end-user can run a program, have it hook into something, and gain at least a fraction of the speed PocketHAL would give you? IE replace all calls for something with PocketHAL's.
[/ignorance]


My first idea with PocketHAL was actually to provide a replacement for GAPI. (i.e. PocketHAL would just be a GX.DLL to replace the existing one). This in theory would give you a nice speed boost for all programs.

Unfortunately it doesn't work because most applications are not properly calling GXBeginDraw()/GXEndDraw() each frame. The worst part is that Microsoft is explicitely saying that it is ok to only call GXBeginDraw() once in the platform builder documentation.
Okay, I found this page: http://pockethal.droneship.com/features.html

So any other devices using those controllers are optimized for as well?

The GAPI memcpy time on the x5 300mhz is 35 MS 8O.

Dan East
Where does it say anything about GAPI in the Platform Builder docs? AFAIK, GAPI isn't even a CE.Net component. It's something the PocketPC/SmartPhone product group added to their platform.
Digby wrote:
Where does it say anything about GAPI in the Platform Builder docs? AFAIK, GAPI isn't even a CE.Net component. It's something the PocketPC/SmartPhone product group added to their platform.


Maybe it was in a different place. I can't find it now, but I'm sure I read something about last week (MSDN?) Basically they were talking about what is needed in the display driver to properly support GAPI. One line was saying something like "It is not necessary to call GXEndDraw()/GXBeginDraw() each frame as long as you call GXEndDraw() when the application loose focus".

This is obviously wrong for buffered devices (ex: Casio E-125, iPAQ 3800) and they were not saying anything about GXIsDramBuffer().
Dan East wrote:
The GAPI memcpy time on the x5 300mhz is 35 MS 8O.


That is horrible. I unfortunately don't have access to the device. Do you know anything about it? Video controller being used? What are the GAPI properties? Maybe it has the same problem as the iPAQ 3800?
I don't know what type of video controller it uses.

Code:

/*
GXDisplayProperties:
cxWidth = 240
cyHeight = 320
cbxPitch = 2
cbyPitch = 480
cBPP = 16
ffFormat = 0x000000a0
= kfDirect | kfDirect565

GXIsDisplayDRAMBuffer returns 0x00000000 (FALSE)

GXBeginDraw returns 0xbe042000

Basic GAPI Performance:
GXBeginDraw = 0.00005 secs.
GXEndDraw = 0.00004 secs.
memset to sysmem = 0.00100 secs.
memcpy vid-to-sys = 0.06748 secs.
memset to vidmem = 0.03503 secs.
memcpy sys-to-vid = 0.03554 secs.
*/


We see lots of tearing and overdraw affects if I treat it as a DRAM buffer, plus BeginDraw / EndDraw have no overhead, so that must be an actual video address.

Dan East
Dan East wrote:
I don't know what type of video controller it uses.


It uses a MediaQ 1132, cadenced at 33MHz.

The MQ 1178 of the HP22xx is at 66MHz.

I've tested various things to try to solve this problem, and for now the best solution I've found is to blit only half of the frames.

If you consider your game as :

1/ game logic
2/ backbuffer drawing
3/ blit of backbuffer
4/ sync of frame

Then instead of doing 1-2-3-4 1-2-3-4
I do 1-2-4 1-3-4 sequences.

It's very easy to implement and the user will not experience the game too badly.
64 bit ? wow :) Can't wait !

---

The company said the controller incorporates a full 64-bit Graphics engine and embeds 256 KB of SRAM to improve the applications graphics performance and reduce power consumption.

"MediaQ's MQ-1132 was the perfect choice for our new e310 Pocket PC based PDA." said Oscar Koenders, a VP at Toshiba CSG. "It delivers high performance with intelligent integration of the most popular peripherals, while still meeting our stringent system-level power budgets. We believe that MediaQ's ultra low power designs and their high performance display technology with direct interface to our LCD panels are a significant enhancement to our PocketPC product line".

According to MediaQ, the MQ-1000 family of controllers offloads graphic, video and input/output tasks from the system CPU to boost system performance and reduce energy consumption.
You have to love the hype they spin with these product descriptions:
MQ1132
A high-performance 64-bit 2D graphics acceleration engine provides users with graphics performance normally associated with desktop computers.

Alright, so this baby is so fast that I should see performance rivaling my desktop, even though the fastest the chip can be accessed is 28 FPS, which consumes 100% of the cpu in the process.

MQ1178
With twice the clockrate of earlier MediaQ chips, the MQ1178/88 controller dramatically boosts the performance of graphics functions such as color image capturing and rendering, and video playback.

Alright, now we're talking. So this one is twice as fast and dramatically boosts performance compared the MQ1132, which is already supposed to perform as fast as a desktop machine. Geez, then why doesn't NVidia start putting these blazingly fast chips in desktop machines? :P

Oh, and the 1178 is still 8 times slower than the very first ARM PPC (iPaq 3600) which is 3 years old.

Dan East
Dan,

I'll never forget the feeling I had when I first read this off the MediaQ website. It was like "oh man, this thing is gonna scream". Of course, after working with it for a couple of days, *I* was the one screaming. These chips suck, and suck badly. They are many times slower than the *on-chip* LCD controller. The only reason that I can think of for even having them is that they at least keep the chip-bus from having to deal with feeding an LCD. The funny thing is that the MediaQ chips really are *very* fast, just only when doing vram to vram copies. Getting something into vram, however, takes several days. It is kinda like running the CPU 2x faster than its memory. Oh, wait, Intel already does that. This all kinda sums up my Dell Axim. It is super fast as long as I don't use memory or try to display anything. It is kinda legend in its own mind. ;)

Cheers,
rcp
The only way to get speed on the MediaQ chips would be to setup a DMA transfer using the CPU.

I have tried to do so on the StrongARM processor but couldn't get it to work. Not having access to platform builder is holding me back.
I've been very pleased with PocketHAL, but I have some suggestions.

I'll start with just one - the most important one at this point. PocketHAL translates input based on the buffer orientation, however I feel the two are not related. So I request an option to turn off any key /stylus translation in PocketHAL. Going by your benchmarks, there is still an advantage for the game to orient itself to the native display, even for some devices PocketHAL is already optimized for. Varium is already designed to operate at any orientation. Being that it is a 3D engine it is much easier to provide that flexibility than for a raster based engine.

I'm sure there will be some developers that will want PocketHAL to take of all that for them (translating input). For me PocketHAL is simply the fastest way to blit - I do not need it to handle orientation issues for me. I will simply tell PocketHAL to use the fastest orientation for that device.

Which leads me to three other suggestions I'll go ahead and post now.

PocketHAL should be able to report whether or not it has hardware optimizations for the current device.

PocketHAL should report the optimimum orientation to be used for the current device.

Finally, I assume that PocketHAL cannot actively detect the device's video controller and use the appropriate routines (IE you have hardcoded it to use routine A for "IPAQ 3600", and routine B for "TOSHIBA E740", etc). If that is the case then new devices may be released with controllers that PocketHAL is already optimized for, but PocketHAL wouldn't know to use them. So I request some sort of Registry entry or other method to force PocketHAL to assume the device uses a certain controller. Of course that could be dangerous to mess around with, but it would allow developers to support new devices without having to wait for you to modify PocketHAL, then build and distribute a whole new version of their game, etc.

Thanks!

Dan East
Dan East wrote:
I've been very pleased with PocketHAL, but I have some suggestions.


Thanks for your feedback Dan, it is appreciated.

Dan East wrote:
PocketHAL translates input based on the buffer orientation, however I feel the two are not related. So I request an option to turn off any key /stylus translation in PocketHAL. (...) Being that it is a 3D engine it is much easier to provide that flexibility than for a raster based engine.


Yes, I can see how all this is not desirable in a 3D engine. In fact, I've had this request made by a few people. I will make sure that PocketHAL allows you to disable input translation and that you can select the "native" orientation.

Dan East wrote:
PocketHAL should be able to report whether or not it has hardware optimizations for the current device.


I was thinking about letting the application enumerate the different drivers available and select one of it's choice. By default, the fastest one would be selected. This functionality already exists, it is just not exposed.

Dan East wrote:
PocketHAL should report the optimimum orientation to be used for the current device.


Again, this is highly desirable for 3D rendering. It will be included.


Dan East wrote:
Finally, I assume that PocketHAL cannot actively detect the device's video controller and use the appropriate routines


This is not the case. PocketHAL properly detects the video controller in use and automatically enable optimizations for it. This means that future devices that uses known video controller will be automatically optimized. There is only one exception and that is the iPAQ 3800 (I'm sure you know about it's display being mounted upside-down).


I am thinking about changing the initialization process to something more Direct3D-like. The reason for this is that I would like to support other devices then PocketPC. I am unsure if it is desirable to have different orientations on a SmartPhone for example. There is also the issue of having really different resolutions on different type of devices. Finally, there is new Pocket PCs coming out that can support multiple resolutions.

Because of all this, I was thinking about letting the application enumerate available resolutions and pick one. So for example, an iPAQ 3600 would return: (240x320) and (320x240). I am unsure about upside-down modes. Should they be reported as (-240x-320) and (-320x-240) or should I use flags? With flags, I could have:

FLAG_UPSIDEDOWN --> Flip 180 degrees
FLAG_NATIVE --> Native mode, optimal for 3D

Thing is I am not a big fan of enumerations, but I don't see any other way to report different resolutions through a generic interface. When I say enumeration, I don't necessarely mean a callback mechanism as in D3D, just a way to retrieve the available resolutions and select one.

Let me know what you think!

Thierry
Is it a simple task for someone (ie me, no programming experience) to compile a PocketHAL version of something, given the Embedded tools, and the source code to the program?
sponge wrote:
Is it a simple task for someone (ie me, no programming experience) to compile a PocketHAL version of something, given the Embedded tools, and the source code to the program?


PocketHAL is not delivered with source code, so you can't compile it. What you get in the archive is already compiled library files that can be used directly in your projects.
Thierry, quick question... And don't misunderstand, I'm not criticizing in any way...

Source is not available for PH, but in a numeber of posts (including this one I believe) you say you won't ever charge for PH. I'm a little curious... if you don't intend to ever try and make money off PH (maybe I'm extrapolating a bit too far with that statement?), then why not release the source?

As I said, don't misunderstand... I have absolutely no problem with you not releasing the source, whatever the reason... I'm just asking because it strikes me as a bit odd for someone not intending to make money on some piece of code to hold back source for it.
fzammetti wrote:
if you don't intend to ever try and make money off PH (maybe I'm extrapolating a bit too far with that statement?), then why not release the source?


I don't know how many times I have to explain this (no offense), but it will definitely go in the FAQ:

thierry wrote:
Some code is written with information acquired under NDA, and I can't release that part.


That by itself is reason enough to explain why I can't release the source code. I could of course remove/disable the parts under NDA, but then the performances wouldn't be what they can be.

fzammetti wrote:
it strikes me as a bit odd for someone not intending to make money on some piece of code to hold back source for it.


There can be other reasons then money. One of them could be that I don't want my code to be integrated in other librairies without my knowledge.
Ok, fair enough.
Thierry wrote:
PocketHAL is not delivered with source code, so you can't compile it. What you get in the archive is already compiled library files that can be used directly in your projects.


I understand that, but do you need programming knowledge in order to use take advantage of PocketHAL in open source programs (say an open source emulator) or is it as simple as a few lines of code and compiling?
you would need to know how to program sponge. Dont tell me your thinking about taking PocketSNES and replacing GAPI with PocketHAL. Its easy but for someone with no programming experience, not that easy.
I wasn't thinking anything in particular, but emus are comonly open source. I know Dan said by just recompiling it, so that's why I asked that.
Jadam wrote:
you would need to know how to program sponge. Dont tell me your thinking about taking PocketSNES and replacing GAPI with PocketHAL. Its easy but for someone with no programming experience, not that easy.


I tend to agree...

But the best thing to do is to try... You'll only lose time and could learn something in the process..
I was wondering...

If GapiDraw were to be recompiled with PocketHAL, would it become PHALDraw, or PHDraw? Just thought I'd toss the question out there...

Awesome work Thierry. Any idea when it might be integrated with PocketFrog? :D

-John
Presto wrote:
Awesome work Thierry. Any idea when it might be integrated with PocketFrog? :D


Following the huge amount of feedback I am getting on PocketHAL, I have decided to concentrate my energies on it for a while. There is a lot of nice features that were suggested and I have a few ideas of my own.

I expect to get back on PocketFrog early next year (mid-January).
Sponge wrote:
I wasn't thinking anything in particular, but emus are comonly open source. I know Dan said by just recompiling it, so that's why I asked that.


I don't remember saying that. I did say this:

Dan East wrote:
Varium FPS increased from 38 to 43, purely from switching to PocketHAL. And my GAPI blit was just a memcpy, so it's pretty amazing that it increased performance that much.


You would have to modify the routines that gain access to the GAPI Buffer, which is not trivial - it depends on how the game was written as to how easy it would be to modify it. However as Thierry said if a game calls GXEndDraw each frame as it should if DRAM is true, then you could create drop-in replacement gx.dll that uses PocketHAL.

Dan East
Oops, must've misread. I understand now, thanks.
Thierry, I'm glad to hear you are continuing your efforts with PocketHAL.

Will you focus again on trying to get DMA copying working for the Axims? Would that fix be specific to the display controller, or would it be a generic XScale DMA copy that could potentitally speed up any DRAM bus limited device?

Thanks!

Dan East
Dan East wrote:
Will you focus again on trying to get DMA copying working for the Axims?


I am currently concentrating my energies on the MediaQ chips, and that includes the Axims.

Dan East wrote:
Would that fix be specific to the display controller, or would it be a generic XScale DMA copy that could potentitally speed up any DRAM bus limited device?


I am currently researching non-DMA based solutions. I've dig quite a bit in the platform builder SDK and doing any kind of DMA is going to be tricky (i.e. What DMA channel can be used?).
Double post.