Re: [AD] power-of-two textures?

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


On Tue, 2008-02-12 at 00:01 +1100, Peter Wang wrote:
> Hi,
> 
> Apparently my old, old video card or its driver doesn't support
> non-power-of-two textures, so the current X driver doesn't work.
> 
> What is the plan for Allegro to support such a limitation?  Do we just
> need to modify ALLEGRO_BITMAP to hold the "actual" width and height
> fields, and allocate extra space?  `al_lock_bitmap' would take that into
> account when calculating the pitch.  What else needs to be done?

Yes. Basically, we need to do everything AllegroGL does (especially
detection heuristics when we can and when can't use NPOT textures). I
think one idea could be if we slightly change the bitmap API semantics
so it is possible that al_create_bitmap returns a sub-bitmap. In this
case, if a driver only allows POT textures (or knows that OpenGL will
fall back to software mode for NPOT) it could create a POT bitmap, then
return a sub-bitmap of that. As far as I can see, this should have no
bad side effects.

Another problem is maximum texture size. In theory, old drivers might
have a limit as low as 256x256 - but I guess every normally we could
expect at least 2048x2048. Still, if the user creates a 3000x500 bitmap,
I don't think this should be allowed to fail. So in a similar way, my
idea is to allow "composed bitmaps". Those are bitmaps consisting of
multiple smaller ones.

The latter does add a bit of complexity, but it should not be too hard
to deal with. For one, drivers themselves never need to know about such
bitmaps, as we can handle them on a higher level: For example,
al_draw_line, when drawing into a composed bitmap consisting of 4
bitmaps, simply would call itself 4 times on each of the bitmaps. And
second, except for some extreme cases like this 3000x500 and a driver
who can't fit that into a single texture, they shouldn't occur often, so
no performance concerns.

I hope to get around and implement both soon, unless someone else is
faster.

-- 
Elias Pschernig <elias@xxxxxxxxxx>





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