PocketMatrix forums

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

GapiDraw 1.1 beta1 16-bit desktop requirement

Ok,

Submit your opinion on this topic here...
If this library was designed to be used to create games that run on PCs, I don't see how you could not support 24/32-bpp color depths. Asking a user to change their desktop color depth in order to run a game is unacceptable. I would also question the use of this library to develop PC games if you're not going to optimize the 24/32-bpp routines. If my game was targetted to run in a window on the PC and I couldn't get acceptable performance from the graphics library, I wouldn't use it.

Asking a developer to change their desktop to 16-bpp in order to develop their PocketPC game on the desktop is restrictive, but certainly more tolerable than asking end-users to do it. If the only reason your library runs on PCs is to allow this sort of development/debug process, then it's probably OK.

I must confess, I don't use GAPIDraw so don't put too much weight on my comments. I'm just giving an opinion.
Typically older games handled this by just notifying the user that not being in the bit mode the game expects will slow performance, but the library completely limiting that to not happening doesn't make sense.

I would think the only changes needed to GapiDraw would be for it to create a primary surface of the BPP of the desktop and still treat everything else the same. Hell, a simple way would be just an added step in the final flip that flips twice. No, this isn't a preferred way, but then again how much speed are they gaining doing everything else native 16bpp in their game compared to speed lost doing a final extra 16->32 bit flip?

As long as the user is told this it's not a big deal, but users get REAL pissy when you FORCE them to do something like switch their resolution.
Using anything less then 32 bpp for my desktop is a definite no-no. If an application doesn't run because of that, it gets the shift-delete treatment: it doesn't even hit the recycle bin.
I'm thinking about what hosed said. Isn't this possible to do all the things accelerated and then do this additional last blit 16->32bpp ?

But another idea would be to enable direct 24/32bpp for everything/surfaces when running on desktop-PCs. I mean, future PocketPCs will for sure have TrueColor, too. Or is GapiDraw too hardcoded to 16bpp and this would be too much rework ?

Greets,
Michael Ritter
5am|coderz
Performance on my desktop is the last thing I worry about, even though I plan to release desktop versions of my apps along with the PPC versions.
The way I look at it, my ppc will never have the performance of my desktop. So taking a few hits against the performance on the desktop is fine as long as the PPC performance is streamlined. My vote is slow down the desktop performance so we can atleast debug easily.

Just my 0.02 cents (or less) worth...
Thanks for all the feedback. Since GapiDraw is based upon DirectDraw on the desktop I have to deal with the limitations of that. One such restriction is that video surfaces can only be created in the same bit resolution as the primary surface (i.e. if the desktop is 32-bit, all video surfaces will be 32-bit).

Many of the unaccelerated operations in GapiDraw (DirectDraw doesn't do alpha blends/opacity etc) operate on multiple pixels simultaneously. Given that we still use 32-bit memory access, 16-bit surfaces is the fastest way to do this while still achieving acceptable image quality.

I will change the implementation so that all hardware acceleration is disabled when the application is run windowed. For those of you that need the performance boost in full screen mode (in 1024x768 for example) you will have that as well..

Changing the GapiDraw implementation to support 32-bit surfaces is simple. One such step is already done in GapiDraw 1.1 where GetBuffer() returns a void pointer to the bits (where it previously returned a WORD*). Internally everything is very flexible, with switches to enable/disable operation on multiple pixels (which has to be disabled in 32-bit mode).

Again, thanks for all the feedback!
Thanks for asking :)

You could have just as easily of said "Screw you guys, I'm going home", but ya didn't :D
Yip, Hosed is right... ;)

Beside of that, in the meantime I found out that MS is even more insane as I thought (And I thought they're a lot).

If you go to:
http://msdn.microsoft.com/archive/defau ... f_2m9j.asp
Then you will find everything needed to define how AlphaBleding should be done in DirectDraw incl. EdgeBlendung und such stuff.

Then you look at the description of the function that's using this struct:
http://msdn.microsoft.com/archive/defau ... f_4jp3.asp
There you will read:"The IDirectDrawSurface7::BltBatchmethod is not currently implemented."

And then you feel really f***ed up the ***

This is so absolutely nasty stuff. They declared everything and documented it well. But they hadn't implemented it. So insane...

So now I have 3 options:
1) Using ColorKeying instead of AlphaChannel. I had rendered my sprites on black background with AlphaChannel. So if I would use ColorKey Blit (Using black as colorkey) with them there would be strong visible black borders around the sprites. So I will have to render them all again.

2) Write an OpenGL wrapper that wraps GapiDraw functions to OpenGL functions. Beside of full hardware acceleration I would benefit from Cross Platform/OS compatibility. And even comming PDAs that will have OpenGL or at least OpenGL ES would benefit.

3) Try to hack some nasty D3D stuff into GapiDraw that will accelerate AlphaBlt.

But the 3rd option would be the last thing I would do in my life... I don't need even more nasty MS stuff.

I think I will go with the first option for now and will do that OpenGL wrapper when the game is finished. I had planned this anyway later to support MacOSX and Linux.

Greets,
Micharl Ritter
5am|coderz
sbl,

You can most certainly create offscreen DirectDraw surfaces that reside in video memory that are not the same pixel color depth as the primary.

DirectDraw will not perform color-conversion during blits between dissimimlar surfaces though. Maybe that's what your limitation is?

Blacky,

I think you're slightly confused. BltBatch is used to submit a list of blit operations to the hardware through a single API call. The API was designed to support alpha blits in the same manner as Blt was (see DDBLTFX members). The reason none of this is supported is because hardware vendors didn't feel it was worth putting 2D alpha blending capability in their GPUs. They threw all of their time and effort into hardware acceleration of 3D operations instead.

Today, the overwhelming majority of game developers that want to do 2D effects in their game do this with the 3D chip and draw viewport-aligned texture-mapped quads instead of blitting bitmaps. You get things like alpha blending, rotation, scaling, and batching all for free. Plus, if your game uses 3D and you try to use DDraw to blit some type of HUD or UI on the screen you will cause your performance to drop because it will have to flush the 3D pipeline (stalling) before the blits can execute. It's far more efficient to do everything as 3D which won't result in a stall of the GPU.
Digby: Ok, cool.. I know I had some issues with this earlier, and from the documentation it says "Additionally, you can create surfaces whose pixel format differs from the primary surface's pixel format. However, in this case there is one drawback—you are limited to using system memory. " - taken from the DirectDraw documentation on creating surfaces. I'll give it a new try, it would most certainly be the best solution to have all surfaces in video memory, in 16-bit format, and then only do one final conversion in the last blit to screen...
If you must keep all of the offscreen surfaces as 16-bpp with GAPIDraw, you'll be better off locating all of them in system memory (provided you're going to perform a color conversion using the CPU).

Reading from video memory can be extremely slow (up to 10x slower compared to writing).