![]() |
|
Allegro 5 graphics API - take 6 |
Thomas Fjellstrom
Member #476
June 2000
![]() |
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 -- |
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
![]() |
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! -- |
frenchfry
Member #2,636
August 2002
![]() |
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.
------------------------------ |
Bob
Free Market Evangelist
September 2000
![]() |
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 -- |
frenchfry
Member #2,636
August 2002
![]() |
I figured you'd say that :p
------------------------------ |
kazzmir
Member #1,786
December 2001
![]() |
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
![]() |
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. -- |
spellcaster
Member #1,493
September 2001
![]() |
I like the ide with fonts being lists of AL_BITMAP -- |
Richard Phipps
Member #1,632
November 2001
![]() |
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.. |
Bob
Free Market Evangelist
September 2000
![]() |
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. -- |
Thomas Fjellstrom
Member #476
June 2000
![]() |
um... Bob? can't we have an english mailing list? I can't read Big5 encoded text... nor the language -- |
Bob
Free Market Evangelist
September 2000
![]() |
It's in English, written in ASCII... -- |
Thomas Fjellstrom
Member #476
June 2000
![]() |
but its called alleg-big5, you should have called it alleg-ascii... -- |
Bob
Free Market Evangelist
September 2000
![]() |
OOoooh, now I understand! -- |
Javier Gonzalez
Member #1,559
October 2001
![]() |
Only one simple complain:
AL_BITMAP *al_load_bitmap(const char *filename); Loading and saving to memory!
|
spellcaster
Member #1,493
September 2001
![]() |
Good point. 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. -- |
Bob
Free Market Evangelist
September 2000
![]() |
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. -- |
Marcello
Member #1,860
January 2002
![]() |
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
![]() |
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. [My site] [Tetrominoes] |
lwithers
Member #630
September 2000
|
Why a shame? Although libc's stdio does provide portable file routines, Allegro's routines are:
Is there anything specific that you don't like about packfiles, that we could maybe address? 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
![]() |
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 : And here are the benefits of packfiles over ZLib : [*] [My site] [Tetrominoes] |
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 :-) |
Thomas Harte
Member #33
April 2000
![]() |
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. [My site] [Tetrominoes] |
|
|