This site is no longer active and is available for archival purposes only. Registration and login is disabled.

Notes on built-in clipping performance


Notes on built-in clipping performance

Postby fzammetti » Aug 4, 2003 @ 6:03pm

...and so I said to Mr. Gates: "$640 billion should be enough for anyone!"
User avatar
fzammetti
pm Insider
 
Posts: 1496
Joined: Jun 4, 2002 @ 6:21pm
Location: Omnytex Technologies


warmi

Postby warmi » Aug 4, 2003 @ 9:24pm

warmi
pm Insider
 
Posts: 518
Joined: Aug 24, 2002 @ 8:07am
Location: Chicago USA


Postby fzammetti » Aug 4, 2003 @ 10:31pm

...and so I said to Mr. Gates: "$640 billion should be enough for anyone!"
User avatar
fzammetti
pm Insider
 
Posts: 1496
Joined: Jun 4, 2002 @ 6:21pm
Location: Omnytex Technologies


Postby tedson » Aug 5, 2003 @ 2:54am

I live by the statement, "make it work right, then make it work fast." A clever optimization is almost never worth the complexity of the code, and when running a program through a profilier the bottlenecks are almost always some place unexpected.
tedson
pm Member
 
Posts: 85
Joined: May 29, 2002 @ 8:22pm


Postby warmi » Aug 5, 2003 @ 3:21am

"make it work right, then make it work fast."

That's precisely why it is much simpler and much less error prone to create a generic clipping routine that will work in every situation than to worry about solutions like oversized surfaces and similar stuff that changes with every game and can lead to memory overrun errors as soon as your sprite strays even only 1 pixels beyond the limits of the surface.
warmi
pm Insider
 
Posts: 518
Joined: Aug 24, 2002 @ 8:07am
Location: Chicago USA


Postby fzammetti » Aug 5, 2003 @ 3:48am

I disagree with part of what you said warmi...

Since GD just doesn't draw anything that strays off the edge of a surface, and since we all trust Johan to have implemented that in such a way that a memory overrun wouldn't occur, that solution is no more error-prone than a generic clipper in my mind.

In addition, since you are basically creating a viewport by virtue of the fact that you are only blitting to backbuffer a portion of the oversized surface, it's not truly as inefficient as it could be. Worse than simply clipping, true (that was the point of my post), but not terribly so.

Creating a generic clipper that works in every case isn't quite as trivial as it seems (I think even Johan had some trouble with regard to clipping and rotations if I remember correctly). It's arguably not an efficient use of my time to code that, even if it only takes an hour let's say, when I can do the oversized surface thing in 1 minute and spend the other 59 minutes coding my game.

I do agree that such a solution might well change from game to game, and that is undesireable. But I think it's not what I would call a big deal: "hmm, lemme see... my oversized surface was 400x400 in the last game, but this is a full-screen game, so I guess it should be something like 480x640 this time around". See, not a big deal to change it.

That all being said, this is all really more a matter of code aesthetics, since performance is pretty close with either solution. My original point was simply that when I had to have extra lines in my own code to do clipping myself, I didn't like it and preferred the "cleaner" approach, relatively speaking, of the oversized surface approach. With it built into GD now, that concern has been rendered null and void and I don't advocate the oversized surface approach at all. Just offering a comparison if anyone else is considering it for some reason.

In the end, I suspect we're all going to use the built-in clipper and be happy doing so. The rest of this discussion is just interesting chatter now.
...and so I said to Mr. Gates: "$640 billion should be enough for anyone!"
User avatar
fzammetti
pm Insider
 
Posts: 1496
Joined: Jun 4, 2002 @ 6:21pm
Location: Omnytex Technologies


Postby tedson » Aug 5, 2003 @ 3:54am

tedson
pm Member
 
Posts: 85
Joined: May 29, 2002 @ 8:22pm


Return to GapiDraw


Sort


Forum Description

The Cross-platform Graphics SDK for Palms, Pocket PCs, Symbian Devices, and Stationary PCs.

Moderators:

sponge, Johan

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum