Which API for 2D?

Started by
4 comments, last by frob 17 years, 1 month ago
I'm currently writing my own 2D engine for fun, and I'm kinda lost as to which API to use. Originally, I had planned to use Direct3D Mobile, but a multitude of complications as well as low performance has me rethinking my decisions. Remembering the horrors of DirectDraw on the PC, I had decided to use D3DM in the hopes that the 3D hardware would be faster than the 2D hardware. After implementing it, it's horrendously slow. Just clearing the backbuffer takes ~15ms. Drawing 200 32x32 alpha-blended sprites on the screen takes ~50ms. So a program doing nothing but clearing the backbuffer, and rendering 200 32x32 sprites, runs at about 15fps at 480x640. I've got a Dell Axim X51v, by the way, which is supposed to have a 16mb graphics chip (Intel 2700G) and Intel XScale CPU clocked at 624mhz. I guess I've got 3 other choices: - GDI - GAPI - DirectDraw GDI is kinda out of the picture for fast rendering. I'm leaning towards DirectDraw right now, but I don't know if it's really a better choice than what I've got now. Would using the 2D hardware through DirectDraw really be faster than using the 3D hardware through Direct3D? And does it support things like alpha and additive blending, rotations and scaling?
NextWar: The Quest for Earth available now for Windows Phone 7.
Advertisement
Quote:Original post by Sc4Freak
So a program doing nothing but clearing the backbuffer, and rendering 200 32x32 sprites, runs at about 15fps at 480x640.

Nothing wrong with that.

Note that the device will wait until the next buffer swap and may block your rendering until it is finished. 15fps is a common rate on the devices.

If you don't like waiting until the next flip is done, you can draw to the back buffer and then blit them directly to the front buffer. It will cause your image to shear if you aren't careful. Additionally, you can not call Clear() if your application will be drawing something to the background anyway. See the documentation on Clear to tell you how to avoid this redundant call.

Also, try rendering more complex objects. Drawing larger models is as fast or faster than drawing a whole bunch of textured quads.
Quote:I had decided to use D3DM in the hopes that the 3D hardware would be faster than the 2D hardware. After implementing it, it's horrendously slow.
...
I've got a Dell Axim X51v, by the way, which is supposed to have a 16mb graphics chip (Intel 2700G) and Intel XScale CPU clocked at 624mhz.

It DOES have that graphics chips. Both it and the X50v with WM5 run reasonably fast relative to other devices for pure 3D.

Remember that you are on a 600 MHz machine, not a 3GHz desktop. Also remember that not all functionality is pure hardware, you should double check that the features you are using are actually hardware accelerated.
Quote:I guess I've got 3 other choices:
- GDI
- GAPI
- DirectDraw

GDI is pretty good if you are 2D. Perhaps the best thing about it is that it works with old devices where D3DM and DD will not. It will work well with QVGA, VGA, and square screens if you design your program properly.

GAPI is deprecated. Don't bother with it on new devices for a whole lot of reasons. If you have to support old devices or legacy applications, you should probably weigh it against simple GDI, if only for the VGA support alone.

DD is great for WM5 devices, but isn't backwards compatible. Many of the functions are accelerated on all devices (including phones) whereas 3D function calls are frequently not accelerated on new, low end devices.
Quote:Would using the 2D hardware through DirectDraw really be faster than using the 3D hardware through Direct3D? And does it support things like alpha and additive blending, rotations and scaling?

Hardware support for 2D and 3D are different, and vary based on devices. Many lower end devices have 2D support but no 3D support, so yes they would be faster on them.

DD supports the AlphaBlt function but I don't know about additive blending. The Blt function is generally slower, but it does support alpha blending, rotation, flipping, scaling, and several other operations. BltFast supports fewer functions and can be a little faster if you are working purely in memory.

Any other questions?
Thanks for the help!

I guess I was expecting a bit much from my PDA in terms of performance. I'm almost certain that I'm graphics limited, though. If I assume for now that my PDA is the only one that's going to run this engine, then what would you recommend? Stay with Direct3D, or move to DirectDraw? Is it worth the trouble?

Thanks.
NextWar: The Quest for Earth available now for Windows Phone 7.
Quote:Original post by Sc4Freak
Thanks for the help!

I guess I was expecting a bit much from my PDA in terms of performance. I'm almost certain that I'm graphics limited, though. If I assume for now that my PDA is the only one that's going to run this engine, then what would you recommend? Stay with Direct3D, or move to DirectDraw? Is it worth the trouble?

Thanks.


That's your own choice.

If you are writing a sprite based game and assuming only WM5 devices, I'd go with DirectDraw. You don't need the added overhead of texture manipulation, and you will be able to run on other devices if you ever take that route.

If it were actual 3D stuff, I'd certainly stick with D3DM. As far as evidence that the chipset can perform well, see the Cube port to Pocket PC, that shows off the 2700 hardware. Sure it only runs at 10-15 fps, but hey, if you're hooked on the game that's good enough.
To re-iterate what Frob said:

You can basically choose between GDI, DirectDraw and Direct3D mobile - GAPI is on its last legs.

The Axim is certainly more powerful than what you are getting out of it. You can see that it will run Quake III at 25fps here. So you may well be using less than optimal practices. The Axim, AFAIK, is the only production device with any 3D hardware acceleration at all.

There are some other tricks you might be able to employ as well, perhaps you can render to a 320x240 backbuffer and then stretch it to 640x480 to present it. This would cut your framebuffer bandwidth requirements by 50-75%.

Even low-end devices at least have basic support for hardware accelerated DirectDraw, and when they don't a software fallback is usually fast enough if you use it minimally. Presubably, you shouldn't be expecting to use something that's appearantly that expensive to perform in silicon too much anyhow :) The low-level option is always there as well: lock your buffer, get the bits, poke your own pixels, unlock. You can do anything you want.

DDraw is actually fairly pleasant to use on mobile devices, even though I'd never recomend it for modern desktop use.

As far as what features are supported on your device, you'd have to check the cap bits, every device will be different anyhow, so you can't rely on a feature existing on all devices. Being that your device supports 3D acceleration I would bet that its 2D support is very strong, and is likely mapped internally to the same silicon that performs its 3D rendering.

throw table_exception("(? ???)? ? ???");

Quote:Original post by ravyne2001
The Axim, AFAIK, is the only production device with any 3D hardware acceleration at all.


There is at least one other, which I test on.

The HX4700/4705 has an ATI Imageon GPU that has different performance pros/cons relative to the Axim X50/51.


As an asside , Nokia may be making moves toward WM5 and they have 3D chipsets. They have announced several pieces of software targeting Windows Mobile, including Nokia Maps that targets their S60 phones and Windows Mobile 5. They have phones with 3D support, but they are all Symbian as far as I know. It has puzzled a few of us why they are supporting Windows Mobile 5. They're already using ARM9 processors so it isn't that big of a stretch.



This topic is closed to new replies.

Advertisement