Re: [AD] [4.9] pitch in memory bitmap

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]



what are the reasons for a :

8 bit alignment.
32 bit alignment.
128 bit alignment.



8.. pro: saves memory con: prevents tricks like using uint32_t to move 4 at a time, fails SSE alignment rules. 32: pro: average alignment for many cases at many pixel depths. con: small waste of space; fails SSE alignment rules. 128: pro: SSE aligned (non aligned data can actually crash if (some) SSE instructions are issued). con: waste of space.



128bit alignments worst case, is lots of space wasted.. how much? lets say a 1025 x 768 surface.. (why anyone would have a 102[5], i dont know!!, anyway).. 1025 would have 15 bytes of slop per line, 15*768 = 11500 bytes

mmm... 11k is not completely trivial, but its not outrageous either.

however, real use-case suggests anyone wanting surfaces of this size would be making 102[4] x .. not 102[5]. more reality use-case suggests anyone make a bazillion 33x33 surfaces for sprites, isn't going to use SSE anyway (the overhead is not worth it). therefore doesn't need 128bit alignment.


The use-case really determines the alignment requirements; it has to be left upto the user to specify if they want other than the default. Anyone aware of alignment issues and has alignment requirements is going to set the alignment they want regardless of what the default is.. By that i mean, document it to say "the default", never say 32, 8, 128 whatever, dont be specific; as long as the docs always say default, then the user must take responsibility to set it to their requirements. That can be made quite clear in the docs, "If you want an alignment other than default, you must specify it before creating the bitmap".


Speaking as a user, if the API for this gets screwed up, i'll be re-writing my own allegro version to give me 128bit alignment were i need it. For me, the only con for 128bit is the amount of waste, which i find acceptable given the amount of memory modern PCs have, and the majority of use-cases aligns naturally.




Peter Wang wrote:
On 2008-02-21, Peter Hull <peterhull90@xxxxxxxxxx> wrote:
The actual value should be transparent to the user - it's only
relevant if the bitmap is locked for direct access and in that case
the pitch is given by the ALLEGRO_LOCKED_REGION structure. The default
should be chosen by Allegro based on the platform, is there any reason
why the user would need to change it?

I'm not sure that Allegro will always be able to pick an alignment that
suits all uses, and when that happens the user would be SOL.  Not sure
how likely that is though.

Peter


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/