GapiDraw 2.x - need feedback on RLE encoding
Hi all,
I have some thoughts on how to improve sprite blitting. Imagine that sprite blitting in GapiDraw would improve in performance with a significant amount. The drawback would be that you would not be able edit ANY surface in the system - you would only be able to upload image bitmaps much as you are using GDI with BitBlt today. Of course rendering effects such as colorfill etc would still be there...
How much of a drawback would this be? I was thinking of many of the games out there today, but most are using GapiDraw as a pure sprite engine...
I am also thinking of disallowing direct read and write access to the display and back buffer. The drawback to this is that GapiDraw extensions such as video playback and 3d renderers will not be possible.
I am not saying I will change anything in GapiDraw. I am mostly looking for feedback on if an engine with the above limitations would be usable (and used).
Diabling access to the back buffer would be a drawback for me. I have been playing with drawing 3d to it.
I am not sure what you mean by "not able to edit". Do you mean no line drawing, FillRects etc. Most of the time that wouldn't matter but I have a couple of uses for gd that require drawing on a surface. You could always make a separate class RleSurface ( or NonRleSurface :-) )
Regards
Sean
Johan, I do not quite understand what you mean could you exemplify what you wouldn't be able to do.
Both our games uses drawing functions. Beshaped uses fillrect and 3Dris uses a lot of line drawing. Very little is prerendered.
I think that if you would remove the ability to render lines points and rects from GapiDraw I would be very dissapointed!
MrX: I won't remove anything from GapiDraw. I am just playing around with some ideas. In practice it would mean that GetBuffer/ReleaseBuffer and GetDC/ReleaseDC would not be available... But as I said, it will not affect GapiDraw...
PejoSoftware: Nothing will change in GapiDraw.. There are however lots of other work being done on sprite engines for Pocket PCs and I am just curious on their usage... FillRect / DrawLine and all other drawing functions would still be available...
One problem with RLE blitting would be that partial blits are not possible (well, not efficiently) - so anyone loading a tileset or animation in as a single surface may not be able to use it.
There would need to be a way of chopping a regular surface into a number of RLE surfaces at run-time, as having to saving each frame as a separate file would be just horrible.... (Anyone else had to do this with J2ME? - images created at runtime blit very slowly on certain Nokia phones?)
Clipping could get nasty.
Rotation and scaling will not be possible.
But in many cases - particularly for sprites with large areas of transparency, an RLE surface type could be beneficial, as long as the app was designed to work with it.
It could be a very useful addition, but not a suitable replacement for 'normal' surfaces
Well.. In that case. You are thinking of creating a sprite engine, not built on GapiDraw directly that would have better performance than GapiDraw but lack the ability to do GetBuffer or GetDC. Then I am sure it quite alot of people will find it useful.
But you could also spend your time on GapiDraw making for example polygon routines.
My question would be: how much better do we really need GD performance to be?
I would much rather see time spent adding features to what exists now, since I believe the performance we currently have is more than sufficient for most purposes. With hardware increases it'll keep up nicely too, so I'm not sure it would be time well-spent in the long run.
Would it be possible for you to create a seperate version of GapiDraw that did this?
I really like playing around/experimenting with some of the low level stuff while still being abstracted from individual device specifics.
With that said though, I am currently developing a top down shooter where there is ALOT going on at one time. So far it seems to run extremely fast with a VERY large amount of stuff goin on(I had over 70 bad guys shooting missels with alpha bitted smoke trails running just fine on my Axim). I suppose this sort of game could gain some speed from your RLE encoded blits, but I *think* that its going to run just fine.
If you did create a 2nd version of GapiDraw I am sure I would port my code over to see how fast it ran. The only thing that would hurt is if you cant do partial blits.
Another approach:
Add CGapiSurface::PrepareOptimizedSurface() which creates an RLE-optimized version for super-fast Blt-ing. Call this during CreateSurfaces(), or any time you update the "sprite" - just not every frame!
This would create an RLE-compressed variant optimized for the current screen pitch - so the CGapiSurface surface would have the raw and the compressed version attached. Then you can still use PNGs (etc) to load arbitrary surfaces, but if you know you're just doing relatively simple blits you can get extra performance out at the expense of memory.
(Or maybe this function takes a CGapiCompressedSurface as a param, so you can throw away the original if necessary and, like Alpha surfaces, this one has special smarts associated with it.)
Thanks for all the replies!
As it is, I think there might be too many issues involved in supporting compressed surfaces.. Clipping as mentioned would not work - a showstopper for many uses... I think I'll put my thoughts on other stuff for a while..
InexorableTash: I have thought about this as well.. Supporting a "Compressed copy" would however mean that I would have to rewrite ALL blit loops in CGapiSurface.. CGapiCompressedSurface or similar might work though..
The reason I was asking on GetBuffer was that one could achieve quite some performance boost of using for example GDI on some devices - but that way images would be read only...
Johan wrote:
Thanks for all the replies!
As it is, I think there might be too many issues involved in supporting compressed surfaces.. Clipping as mentioned would not work - a showstopper for many uses... I think I'll put my thoughts on other stuff for a while..
I've clipping, scaling and rotation working perfectly with my RLE sprite engine.
So it's not impossible to do ;)
StephC: Your engine impresses me more everytime I hear about it...

Really, you have done an incredible job with it...
(clipping, rotation
and scaling.. now that's something to write home about)
StephC wrote:
I've clipping, scaling and rotation working perfectly with my RLE sprite engine.
So it's not impossible to do
Ok, it's not impossible.... but surely rotation must have a huge performance overhead? (or are you talking about 90-degree increments only)
In fact rotation and scaling are done at load time ;)
So its not true rotation eh? As I read your last post its precached?
It's true rotation but it's precached.
Precaching saves a lot of CPU cyles and only consumes more memory.
Yeh, but its really no different as if you did it in a graphics editing program.
I ment by "on the fly" by true, I should have been more clear since true doesn't accuratly describe that.
Anyhow, Your the one making the "mode 7" racing game right? I am also doing something like that on and off, and Id have to say, your movies/screenshots impress me.
DillRye wrote:
Yeh, but its really no different as if you did it in a graphics editing program.
It saves space, time for the artist and it's a lot more flexible...
DillRye wrote:
Anyhow, Your the one making the "mode 7" racing game right? I am also doing something like that on and off, and Id have to say, your movies/screenshots impress me.
I've made parts of this game (UI and "mode7" code) but I am not the lead coder on this project.