PocketMatrix forums

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

Using pBuffer of surface other than frame buffer

Currently sprite.GetBuffer is returning different pitches for different rotations of the screen, is this right?

If you step through the frame buffer using backbuffer.xPitch and backbuffer.yPitch then surely it should be possible to use the data of sprites etc as is. :?

Colin
After some more investigating, it seems that on the iPaq at least accessing memory in columns (i.e y++) is REALLY slow, therefore I can see some sense in accessing the sprites vertically and stepping through the frame buffer x loop , y loop order.

Colin
Ok, been thinking about it some more, it has been a LONG time since I've had to worry about processors with small data caches, hence by discoveries. Does anyone know the size of the data caches on the popular pocket pcs?

This makes GapiDraw all the more impressive, I'm assuming that it figures out from the pitches whether to access source surface data either row or column wise.

Which hardware does NOT have the video memory in the same orientation as the iPAQ, anyone?

Colin

PS Wooo, one man thread :D
Not sure why you wish to do this, probably for collision purposes. I'd recommend using Masked surfaces instead. GapiDraw has accelerated pixel based collision detection via mask surfaces.
The cache size on the ARM and XSCALE is 64 bytes, so it is not that "smaller" then on your desktop PC.

The other thing is that video memory is usually not cacheable. (I have yet to see a PPC where it is.) This means that accessing the video memory won't thrash your CPU cache.
But if the video ram is not cachable, why is it when video ram is accessed loop x, loop y it is about half the speed?

Ahh, but of course I am not writing to video ram, but the back buffer instead, hence the cache misses ?!?!

Colin
IIRC, the iPaqs are the only devices with the rotated display orientation. To complicate matters, some of the iPaq models are oriented 90 deg clockwise, and others are rotated 90 deg counterclockwise.

StrongARM
8KB Data cache
16KB Instruction cache

XScale
32KB Data cache
32KB Instruction cache

There's plenty of info on these chips on Intel's website.
Cheers for that info.

I have been doing some more tests concerning cache misses, my testbed uses the 'Simple' sample with the rotating ipaq removed, screen orientation is GDDISPMODE_ROTATE90CCW. My test data is an animating sprite sized 64x48 pixels with 14 frames.

I am drawing 200 sprites, each one cycling through the frames (sprite 0 = frame 0, sprite 1 = frame 1) so as to totally thrash the cache.

Using bltfast (ie. mfc sample) 59.4ms (iPaq 3970)
Using my own keycol blitter 59.1ms
Using keycol span skipper 51.3ms

Now this span skipper method just finds the portions of the sprites that are not keycol'd out (ie. not magenta), now what happens if we move all of the drawable span data into a single array of data with no gaps....

Using datacomp span skipper 45.1ms

Here we can see that by bunching all of the data into a single array we are not hitting the cache as badly and hence we get much better draw time.

Of course the problem is that we cannot bltfast this compressed data and it only works when drawing from the data row wise.

Still, quite an improvement. :P

Colin
That's exactly the sort of optimization that you'd hope your graphics library would do for you under the hood. If the API exposed a way to reveal to the library that the image is static (i.e. your app isn't going to be changing the bits), then it is free to store the image in a more efficient format internally. In the case of a sprite with a color-key, a run-length encoding (RLE) scheme sounds like it would be quite beneficial. The same would be true for images that contain an alpha channel and have a fair amount of spans of transparent pixels.

FYI, DirectDraw supports this sort of thing via the DSCAPS2_HINTSTATIC flag when creating surfaces. The "swizzling" of pixel data occurs in the display driver though and not within the API itself.