Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Allegro 5 graphics API - take 6

This thread is locked; no one can reply to it. rss feed Print
 1   2   3   4 
Allegro 5 graphics API - take 6
Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

We'd just need to add a 1-bpp bitmap type to make it work like Allegro 4.

Why not allow for 2 and 4bit color depths too? Just make the depth stuff extensible :)

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

lwithers
Member #630
September 2000

Hmm, I think it is going to be pretty fast as it is. Especially if any asm routines ever get written (I might even learn myself, if I'm not too busy over the coming months). But the main point is that to make it fast, you need to use the direct access functions, but then you need to perform your own clipping.

As to making all fonts be bitmaps: possibly, that's really up to you guys. Why not wait and see how this font renderer turns out?

When it comes to monochrome fonts, Allegro currently uses an undocumented 1bpp bitmap (called a FONT_GLYPH, but it really is a 1bpp bitmap). My new renderer uses RLE, which obviously doesn't store too much info in a mono font :-)

Out of interest, what is branch prediction? I am aware it is to do with superscalar processors executing things out of order, but how does it apply to my font renderer? :-)

Bob
Free Market Evangelist
September 2000
avatar

Branch prediction has more to do with pipelining than with superscalar-ness.

The problem with pipelining is that the CPU takes several steps to "execute" instructions. Thus, it will not realize that a conditional jump has jumped (or not) before it's too late. This means that the CPU has probably started executing instructions from the wrong side of the branch. Worse, it may have already completed instructions from that side of hte branch, especially when you consider that the CPU is Out-of-Order!

When the CPU realizes that it took the wrong code path, it must stop its current operation, undo everything it has done upto the branch code, flush the instruction pipeline, update the instruction pointer, start fetching instructions from the new location, then restart executation from that point on.

This can cost hundreds of cycles (or more if the new code isn't in L1).

To remedy this, CPUs have a "branch prediction unit". This piece of of the CPU attempts to predict if a jump will pass or not as soon as it has fetched the instruction. This way, it can fetch subsequent instructions from the right location in memory.

The prediction unit uses a combination of static and dynamic prediction techiques. Statics are used when the branch instruction is new to the CPU (ie: there's no past history), and it includes things like "branch is taken if it goes backwards" (think: loops).

Dynamic prediction is statiscally based. If the branch was taken the last 50 times in a row, then there's a good chance that it will be taken the 51rst time too.

The cost of a mis-predict is still very high though.

Now, the trouble with RLE is that you're going to have really small spans of contiguous pixels (like 3 or 4, or maybe just 1 pixel). So you'll probably mispredict on the first loop iteration, as the last time you had exited the loop. You'll also mispredict on the last iteration of the loop. But if the loop runs only 3 times for three pixels, then you'll mispredict 66% of the time!

Hope this cleared up things!

--
- Bob
[ -- All my signature links are 404 -- ]

frenchfry
Member #2,636
August 2002
avatar

this looks cool. I don't really mind about the incompatability with old versions. The way it looks is people who start Allegro will use 4 until they get good at that and then make a transition to 5. 5 looks very nice so far. I just hope the WinXP flickering problem is fixed in 5 :p. Very annoying. How many years do you think it'll be until you get 5 released? Or are you not going to say because of the community (you know, people getting ticked because something takes longer than said).

It looks a lot more organised. One thing I don't like about Allegro 4 is how unorganised the code is.

------------------------------
"You can't catch me, I'm the gingerbread man!" - The Gingerbread Man

Bob
Free Market Evangelist
September 2000
avatar

There is a potential fix for the flickering in the CVS version of Allegro. This is unrelated to the API change, as it's a driver problem.

As for when v5 will be out, it'll be out when it's ready ;D

--
- Bob
[ -- All my signature links are 404 -- ]

frenchfry
Member #2,636
August 2002
avatar

I figured you'd say that :p

------------------------------
"You can't catch me, I'm the gingerbread man!" - The Gingerbread Man

kazzmir
Member #1,786
December 2001
avatar

i hope you mean truly ready when you say "ready". allegro 4.x is good enough for whatever everyone is doing now,. so i would hope that you optimize everything you can in 5 before you release it. dont worry about us end-users, well wait for perfection.

ReyBrujo
Moderator
January 2001
avatar

Quote:

r u gonna make any faster fixtoi and itofix code?

Better said, is it going to be supported (fixed numbers)? All prototypes Bob posted were using floats, not fixed... Also, notice how Allegro 5 will hardly fit a < Pentium Pro.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

spellcaster
Member #1,493
September 2001
avatar

I like the ide with fonts being lists of AL_BITMAP :)
This would allow to implement Anti-Aliased fonts really easy (just use a bitmap with alpha channel)... i like the idea.

--
There are no stupid questions, but there are a lot of inquisitive idiots.

Richard Phipps
Member #1,632
November 2001
avatar

As regarding the RLE font plotter:

Why don't the developers here each write a small routine with their way of doing this. Then compare the speeds of all the routines. Take the best one and then all look at it and see if you can all optimise it some more.

By only dealing with a small routine it won't be too much work, but should give you a better renderer quicker than one person trying out different ideas/routines.

Think of it as AllegroHack.. ;)

(you have one weekend.. :D)

Bob
Free Market Evangelist
September 2000
avatar

Ok, we now have a mailing list! Feel free to register here.

Discussion is probably easier since it's threaded. It'll also use up less bandwidth, and is publically archived.

--
- Bob
[ -- All my signature links are 404 -- ]

Thomas Fjellstrom
Member #476
June 2000
avatar

um... Bob? can't we have an english mailing list? I can't read Big5 encoded text... nor the language ;D

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Bob
Free Market Evangelist
September 2000
avatar

It's in English, written in ASCII...

--
- Bob
[ -- All my signature links are 404 -- ]

Thomas Fjellstrom
Member #476
June 2000
avatar

but its called alleg-big5, you should have called it alleg-ascii... ;D

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Bob
Free Market Evangelist
September 2000
avatar

OOoooh, now I understand! :)
Well, I didn't pick the name, tjaden did :)

--
- Bob
[ -- All my signature links are 404 -- ]

Javier Gonzalez
Member #1,559
October 2001
avatar

Only one simple complain:

  • Loading and saving */

AL_BITMAP *al_load_bitmap(const char *filename);
int al_save_bitmap(AL_BITMAP *bmp, const char *filename);

Loading and saving to memory! :)

spellcaster
Member #1,493
September 2001
avatar

Good point.
In fact, it would be great if all the load / save functions would work on memory.

load_bitmap(filename) {
     allocate memory for file
     read file into memory
     decode in memory
     free memory
     return bitmap
}

if the decode-in-memory step would be a callable function, you could do lot's of nice stuff.

--
There are no stupid questions, but there are a lot of inquisitive idiots.

Bob
Free Market Evangelist
September 2000
avatar

Or, make load_bitmap and save_bitmap take a packfile as a parameter. Then, you can read the bitmap from any file stream, or even from memory.

--
- Bob
[ -- All my signature links are 404 -- ]

Marcello
Member #1,860
January 2002
avatar

I get a 404 if I click to view the mailing list archive...

Marcello

lwithers
Member #630
September 2000

That's not really a 404, it's more a SF thing. And it might simply be because there haven't been any posts to the list recently (although I did just get two).

Thomas Harte
Member #33
April 2000
avatar

Quote:

Or, make load_bitmap and save_bitmap take a packfile as a parameter. Then, you can read the bitmap from any file stream, or even from memory.

From which one can conclude that packfiles will remain in the core library? Shame.

lwithers
Member #630
September 2000

Why a shame? Although libc's stdio does provide portable file routines, Allegro's routines are:

  • More portable (ie. if you write a '\n' to a file, you don't get a broken OS inserting a '\r' for you),

  • Simpler to understand in certain situations (ie. there are routines for writing numbers to disk, and also the pack_write function takes an argument size in bytes!),

  • Potentially (ie. will be in Allegro 5) more powerful, allowing you to have files in RAM or attached to the executable or ...

  • Compressed. I know the compression ratio isn't good (although there is no reason why we can't provide bzip2, gzip, etc. compression in Allegro 5) but one of the advantages of this is that loading such a compressed file from disk and decompressing it is faster than loading the decompressed file. (Also for saving). This is an advantage for games where fast disk access can be essential.

Is there anything specific that you don't like about packfiles, that we could maybe address?
Personally, I don't like the seeking restriction, and I would also upgrade the string read/write functions, as well as provide a way to write floating point numbers to disk.

But I think packfiles (and datafiles, which are basically enhanced packfiles) are a great help for writing games and therefore one of the strengths of Allegro.

Thomas Harte
Member #33
April 2000
avatar

Quote:

Is there anything specific that you don't like about packfiles, that we could maybe address?

Its yet another feature that was added to Allegro despite the fact that it would sit better as an external library. And, despite the fact that in a world where ZLib exists, it already does.

Here are the benefits of ZLib over packfiles :

  • non-proprietary, well documented and widely supported standard

  • external to any other library, decreasing bloat

  • already included in almost every Linux/BSD distribution
  • And here are the benefits of packfiles over ZLib :

    [*]

    lwithers
    Member #630
    September 2000

    I disagree that packfiles would be better as an external library on the basis that they are how datafiles are implemented, and I would definitely count datafiles as a core component (how else do you get sound and graphics into a game)? Datafiles are chunked packfiles, something which libc doesn't support, so we'd need to have some layer between datafiles and the OS anyway.

    And I think you can add these two to your list :-)

  • already included in every single Allegro distribution, ever

  • significantly faster (I believe Shawn designed packfiles with speed rather than size in mind, kind of like RLE sprites).
  • Thomas Harte
    Member #33
    April 2000
    avatar

    Quote:

    I would definitely count datafiles as a core component (how else do you get sound and graphics into a game)?

    Thats like arguing that a tile engine should be built in, or how else would anyone ever write a game that used tiled graphics? There are several other ways of getting sound and graphics into a game - notably including load_bitmap which is exactly what we were just talking about. Surely the argument should be one of how tightly the idea of datafiles as a core component is required by the remit of Allegro, but of course it doesn't seem to have a well defined remit. Which is something that needs to be addressed, in my opinion. "Allegro is a game library" isn't really good enough.

    In any case, returning to the point, I don't see datafiles as a core component either, just as a feature of the packfile library.

    Quote:

    already included in every single Allegro distribution, ever

    Not relevant with discussion to Allegro 5, which is, after all, an entirely new library with the same name.

    Quote:

    significantly faster (I believe Shawn designed packfiles with speed rather than size in mind, kind of like RLE sprites).

    I read that Shawn originally shunned ZLib because it was 'too slow', but to be honest I'm not sure I believe that story. Either way, this is no longer relevant, due to a combination of factors.

    Firstly, the concept of video and system bitmaps (and hardware samples if Allegro supported them explicitly) means that everyone has to accept they can't just pull very much data off the disc and use it without getting severe speed penalties.

    Secondly, everything has sped up to the point where ZLib is fast enough on modern hardware, since drive speeds and CPU speed are rarely the bottleneck for 2d games. Personally, I've used ZLib in speed critical environments (see ElectrEm, on allegro.cc in the emulators section - UEF's are a chunk based format written on top of ZLib), and it has not caused any problems.

     1   2   3   4 


    Go to: