From: José Fonseca Date: Thu, 26 Jun 2008 14:39:13 +0000 (+0900) Subject: gallium: Describe pixel block. X-Git-Tag: 062012170305~17580^2~390^2~1090 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=38d779a3e68bb0ed78135c868e5bd435e1d91fb5;p=profile%2Fivi%2Fmesa.git gallium: Describe pixel block. Chars-per-pixel paradigm is not enough to represent compressed and yuv pixel formats. --- diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h index 00aa023..d973fb3 100644 --- a/src/gallium/include/pipe/p_format.h +++ b/src/gallium/include/pipe/p_format.h @@ -445,6 +445,62 @@ static INLINE uint pf_get_size( enum pipe_format format ) return pf_get_bits(format) / 8; } +/** + * Describe accurately the pixel format. + * + * The chars-per-pixel concept falls apart with compressed and yuv images, where + * more than one pixel are coded in a single data block. This structure + * describes that block. + * + * Simple pixel formats are effectively a 1x1xcpp block. + */ +struct pipe_format_block +{ + /** Block size in bytes */ + unsigned size; + + /** Block width in pixels */ + unsigned width; + + /** Block height in pixels */ + unsigned height; +}; + +/** + * Describe pixel format's block. + * + * @sa http://msdn2.microsoft.com/en-us/library/ms796147.aspx + */ +static INLINE void +pf_get_block(enum pipe_format format, struct pipe_format_block *block) +{ + switch(format) { + case PIPE_FORMAT_DXT1_RGBA: + case PIPE_FORMAT_DXT1_RGB: + block->size = 8; + block->width = 4; + block->height = 4; + break; + case PIPE_FORMAT_DXT3_RGBA: + case PIPE_FORMAT_DXT5_RGBA: + block->size = 16; + block->width = 4; + block->height = 4; + break; + case PIPE_FORMAT_YCBCR: + case PIPE_FORMAT_YCBCR_REV: + block->size = 4; /* 2*cpp */ + block->width = 2; + block->height = 1; + break; + default: + block->size = pf_get_size(format); + block->width = 1; + block->height = 1; + break; + } +} + #ifdef __cplusplus } #endif