PocketMatrix forums

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

What is Dram in gapi

I have read that Dram is not used in Gapi,is this correct, if not what does it do
It depends on the hardware. Some devices expose their display via DRAM. You have to check the flag to determine the type of display access for that device.

Dan East
thank you
Sorry, after re-reading your post I didn't completely answer your question.

If GXBeginDraw returns a pointer to DRAM then there is an intermediate buffer before the actual display buffer. When you call GXEndDraw that intermediate buffer is blitted to the display by the hardware (or in some cases by a slow software routine like with the iPaq 38xx). So if DRAM is true, then you can blit smaller chunks directly to the display buffer and not worry about the user seeing small incremental changes as you are doing the drawing. If DRAM is false then every pixel you modify will be visible the next time that scanline is refreshed. So in that case you need a backbuffer to do your drawing to, and then flip / blit that buffer all in one pass to the display buffer. If you do not do that blit oriented with the display buffer then you may see tearing, particularly when you are scrolling large portions of the display at once.

If GAPI exposes DRAM then you MUST call GXEndDraw each frame or the DRAM buffer will never be blitted to the actual hardware. For non-DRAM devices you don't need to call GXEndDraw each frame, but it is probably good practice anyway.

Dan East
To expand on the iPaq 38xx device. The iPaq 36xx's display is actually oriented sideways, so as you increase the X you are moving up the screen. The iPaq 38xx used different display hardware that was oriented portrait. Compaq was afraid that by exposing different GAPI properties many games would not work on the 38xx. All ARM devices up to that point had the same display properties as the original ARM device, the 36xx, so most games just hardcoded the display properties for ARM.

So the 38xx's GAPI implementation returns a "DRAM" buffer, which is really just a regular buffer that is oriented to match the 36xx and software blitted to the actual display buffer. That maintains compatibility, but is very, very slow. If I remember correctly, it was not possible to achieve even 30 FPS just calling GXBeginDraw / GXEndDraw in a loop.

So for the 38xx devices developers resorted to hardcoding the actual display address, and then using the display properties that were determined for the actual hardware. The address is 0xac0755a0, and if you search these forums for that you will find how to determine if the device is an iPaq 38xx, and the proper display properties to use with that address.

Dan East
Just to be a wise-ass (but with an actual point!)...

This is EXACTLY the reason you should run screaming from your IDE right now and download any graphics library out there! With the performance and quality of libraries like GapiDraw and PocketFrog, among others, there's really not too many good reasons any more (outside of emulators maybe?) to write your own GAPI code.

Speaking as someone who went through all these details a year or so ago writing my own library, I can tell you the best thing I ever did was drop that effort and grab a copy of PocketFrog. I've never looked back, and my hair has halted it's premature graying too! :)
agreed...
Well i didnt read that way in Jonathon Harbours Pocket Pc book, that is why i asked the question,ive seen gapi code pointing to the memory address but i thought this was due to a buggy gx.dll

I dont think ill be writing my own library but i do like to stick my head under the hood for a more complete understanding.

I assume that im better not using GXBeginDraw and to use the memory address instead
Only for iPaq model 38xx. For all other devices you should NOT bypass GAPI. The memory address I mentioned above would only pertain to an iPaq 38xx and no other device.

Dan East
Funny, I was thinking about this the other day.

On my J680 (HPC, 640x240 display) Doing Full-screen blits drops the framereate like a brick! (I was using GameX to get the display pointer)

Does this mean that double buffering is not needed on those devices, because it has to be copied from DRAM to display hardware every frame anyway?
Yes, you could just not bother double-buffering on your own and let the device handle it.

However, if you can get access to the raw display buffer, then you might want to handle it yourself for performance reasons. A plain old memcpy from backbuffer to display puts you in the realm of hundreds of fps instead of the pathetic 30 you would get letting the 38xx series have its way.
so if i create a buffer(new (unsigned short*)test[320*240]) as a backbuffer. iw ould be correct, but how do i use the dram buffer
Just call GxBeginDraw and it returns the buffer. Call GxEndDraw to flush it to the display.

Dan East
so i9 always need to create my own offscreen buffer..?
No, only if GxBeginDraw does NOT return a pointer to DRAM. You have to query GAPI first to see if that device exposes DRAM or not.

Dan East
However, if you can get access to the raw display buffer, then you might want to handle it yourself for performance reasons. A plain old memcpy from backbuffer to display puts you in the realm of hundreds of fps instead of the pathetic 30 you would get letting the 38xx series have its way.


So does this mean you can call VirtualAlloc() on the pointer returned by GXBeginDraw() to access the display memory directly? But then if you are not getting a DRAM buffer from you need to double buffer anyway to prevent flickering, if you are getting a DRAM buffer from GXBeginDraw() and a final blit to display memory is being performed on GXEndDraw() then how do you get the actual display memory pointer?

Also, is the 38xx blit just slow or is it throttling the game as the display hardware can only handle so many fps anyway? I doubt the screen can keep up with 100's fps!
So does this mean you can call VirtualAlloc() on the pointer returned by GXBeginDraw() to access the display memory directly?


Why? The pointer points to a DRAM buffer that you can write to. That's all you need - no calls to VirtualAlloc necessary.

then how do you get the actual display memory pointer?


If the device is giving you a DRAM buffer, then it is (usually) giving you the display memory's pointer (that of the off-screen bank). When you call GXEndDraw it flips the banks and GXBeginDraw now gives you the address of the "new" off-screen bank.

The 38xx GAPI "blit" is just plain nasty and slow because of the orientation of the screen - most devices are 320x240; the 38xx is 240x320 so the blit in GAPI also has to rotate. Icky. If you handle that yourself, performance is much faster.

The screens can generally keep up with 70fps. You wouldn't actually bother doing 70fps though (many discussions about fps here before though).
That makes more sense to me now. Thanks!