next up previous contents
Next: Hardware Abstraction Layer: Portable Up: The Fully Portable Subsystems Previous: Sync Objects: Condition Variable   Contents

Platform-Independent Images

Most people would argue that this has no business in the main kernel library, and they may very well be right. However, I wanted this to be a standard part of KOS on any platform it got ported to so that you're guaranteed some platform-independet, device-dependent representation of images. This way, any image loader library that is ported to KOS can convert to this data format and it can be used by anything in the kernel that understands it (drivers, etc).

KOS doesn't try to put any limitations on what format the image may take; instead it tries to encapsulate most of the common formats you'd want to use in writing a game or demo and then provides an ``out'' for platform-specific things that are just too strange to be used elsewhere. A good example of this (though one which isn't actually used currently) would be the PVR2's ``twiddled'' textures. Some somewhat strange things that it does cover are inverted axis textures (e.g., for GL) and YUV formats for MPEG (tm) .

The majority of the PII system is just format specifications so that pieces have a common language to talk about the images. This includes a structure (kos_img_t) that contains a pointer to the raw data, width and height in pixels, and a format descriptor. The first three pieces are pretty self-explanatory, so I won't waste any time on those. However, the format descriptor deserves some attention.

The format descriptor is composed of two parts: the platform independent part, and the platform dependent part. Each of these parts is 16 bits wide. The platform independent part is further divided into a format specifier and standard flags. The format specifier may be one of:

The attributes will be a bitmask with the following:

There is one function associated with the PII system currently:

Several macros are also available for tearing apart and putting together the format descriptor:

Note that KOS_IMG_FMT(KOS_IMG_FMT_I(x), KOS_IMG_FMT_D(x)) === x.

In the future, the PII system may also include functions to convert between image formats, but this hasn't been done yet.


next up previous contents
Next: Hardware Abstraction Layer: Portable Up: The Fully Portable Subsystems Previous: Sync Objects: Condition Variable   Contents
Dan Potter 2002-07-29