*/
UTIL_FORMAT_LAYOUT_ETC = 6,
+ /**
+ * BC6/7 Texture Compression
+ */
+ UTIL_FORMAT_LAYOUT_BPTC = 7,
+
+ /**
+ * ASTC
+ */
+ UTIL_FORMAT_LAYOUT_ASTC = 8,
+
/**
* Everything else that doesn't fit in any of the above layouts.
*/
- UTIL_FORMAT_LAYOUT_OTHER = 7
+ UTIL_FORMAT_LAYOUT_OTHER = 9
};
};
-enum util_format_swizzle {
- UTIL_FORMAT_SWIZZLE_X = 0,
- UTIL_FORMAT_SWIZZLE_Y = 1,
- UTIL_FORMAT_SWIZZLE_Z = 2,
- UTIL_FORMAT_SWIZZLE_W = 3,
- UTIL_FORMAT_SWIZZLE_0 = 4,
- UTIL_FORMAT_SWIZZLE_1 = 5,
- UTIL_FORMAT_SWIZZLE_NONE = 6,
- UTIL_FORMAT_SWIZZLE_MAX = 7 /**< Number of enums counter (must be last) */
-};
-
-
enum util_format_colorspace {
UTIL_FORMAT_COLORSPACE_RGB = 0,
UTIL_FORMAT_COLORSPACE_SRGB = 1,
* Format query functions.
*/
-static INLINE const char *
+static inline const char *
util_format_name(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
return desc->name;
}
-static INLINE const char *
+static inline const char *
util_format_short_name(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
/**
* Whether this format is plain, see UTIL_FORMAT_LAYOUT_PLAIN for more info.
*/
-static INLINE boolean
+static inline boolean
util_format_is_plain(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
return desc->layout == UTIL_FORMAT_LAYOUT_PLAIN ? TRUE : FALSE;
}
-static INLINE boolean
+static inline boolean
util_format_is_compressed(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
case UTIL_FORMAT_LAYOUT_S3TC:
case UTIL_FORMAT_LAYOUT_RGTC:
case UTIL_FORMAT_LAYOUT_ETC:
+ case UTIL_FORMAT_LAYOUT_BPTC:
+ case UTIL_FORMAT_LAYOUT_ASTC:
/* XXX add other formats in the future */
return TRUE;
default:
}
}
-static INLINE boolean
+static inline boolean
util_format_is_s3tc(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
return desc->layout == UTIL_FORMAT_LAYOUT_S3TC ? TRUE : FALSE;
}
-static INLINE boolean
+static inline boolean
util_format_is_srgb(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
return desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB;
}
-static INLINE boolean
+static inline boolean
util_format_has_depth(const struct util_format_description *desc)
{
return desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS &&
- desc->swizzle[0] != UTIL_FORMAT_SWIZZLE_NONE;
+ desc->swizzle[0] != PIPE_SWIZZLE_NONE;
}
-static INLINE boolean
+static inline boolean
util_format_has_stencil(const struct util_format_description *desc)
{
return desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS &&
- desc->swizzle[1] != UTIL_FORMAT_SWIZZLE_NONE;
+ desc->swizzle[1] != PIPE_SWIZZLE_NONE;
}
-static INLINE boolean
+static inline boolean
util_format_is_depth_or_stencil(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
util_format_has_stencil(desc);
}
-static INLINE boolean
+static inline boolean
util_format_is_depth_and_stencil(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
/**
* Calculates the depth format type based upon the incoming format description.
*/
-static INLINE unsigned
+static inline unsigned
util_get_depth_format_type(const struct util_format_description *desc)
{
unsigned depth_channel = desc->swizzle[0];
if (desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS &&
- depth_channel != UTIL_FORMAT_SWIZZLE_NONE) {
+ depth_channel != PIPE_SWIZZLE_NONE) {
return desc->channel[depth_channel].type;
} else {
return UTIL_FORMAT_TYPE_VOID;
* Return whether this is an RGBA, Z, S, or combined ZS format.
* Useful for initializing pipe_blit_info::mask.
*/
-static INLINE unsigned
+static inline unsigned
util_format_get_mask(enum pipe_format format)
{
const struct util_format_description *desc =
*
* That is, the channels whose values are preserved.
*/
-static INLINE unsigned
+static inline unsigned
util_format_colormask(const struct util_format_description *desc)
{
unsigned colormask;
* @param desc a format description to check colormask with
* @param colormask a bit mask for channels, matches format of PIPE_MASK_RGBA
*/
-static INLINE boolean
+static inline boolean
util_format_colormask_full(const struct util_format_description *desc, unsigned colormask)
{
return (~colormask & util_format_colormask(desc)) == 0;
boolean
util_format_is_luminance(enum pipe_format format);
+boolean
+util_format_is_alpha(enum pipe_format format);
boolean
util_format_is_luminance_alpha(enum pipe_format format);
boolean
util_format_is_intensity(enum pipe_format format);
+boolean
+util_format_is_subsampled_422(enum pipe_format format);
+
boolean
util_format_is_pure_integer(enum pipe_format format);
boolean
util_format_is_snorm(enum pipe_format format);
+boolean
+util_format_is_snorm8(enum pipe_format format);
+
/**
* Check if the src format can be blitted to the destination format with
* a simple memcpy. For example, blitting from RGBA to RGBx is OK, but not
*
* PIPE_FORMAT_?8?8?8?8_UNORM
*/
-static INLINE boolean
+static inline boolean
util_format_is_rgba8_variant(const struct util_format_description *desc)
{
unsigned chan;
/**
* Return total bits needed for the pixel format per block.
*/
-static INLINE uint
+static inline uint
util_format_get_blocksizebits(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
/**
* Return bytes per block (not pixel) for the given format.
*/
-static INLINE uint
+static inline uint
util_format_get_blocksize(enum pipe_format format)
{
uint bits = util_format_get_blocksizebits(format);
return bytes;
}
-static INLINE uint
+static inline uint
util_format_get_blockwidth(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
return desc->block.width;
}
-static INLINE uint
+static inline uint
util_format_get_blockheight(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
return desc->block.height;
}
-static INLINE unsigned
+static inline unsigned
util_format_get_nblocksx(enum pipe_format format,
unsigned x)
{
return (x + blockwidth - 1) / blockwidth;
}
-static INLINE unsigned
+static inline unsigned
util_format_get_nblocksy(enum pipe_format format,
unsigned y)
{
return (y + blockheight - 1) / blockheight;
}
-static INLINE unsigned
+static inline unsigned
util_format_get_nblocks(enum pipe_format format,
unsigned width,
unsigned height)
return util_format_get_nblocksx(format, width) * util_format_get_nblocksy(format, height);
}
-static INLINE size_t
+static inline size_t
util_format_get_stride(enum pipe_format format,
unsigned width)
{
return util_format_get_nblocksx(format, width) * util_format_get_blocksize(format);
}
-static INLINE size_t
+static inline size_t
util_format_get_2d_size(enum pipe_format format,
size_t stride,
unsigned height)
return util_format_get_nblocksy(format, height) * stride;
}
-static INLINE uint
+static inline uint
util_format_get_component_bits(enum pipe_format format,
enum util_format_colorspace colorspace,
uint component)
}
switch (desc->swizzle[component]) {
- case UTIL_FORMAT_SWIZZLE_X:
+ case PIPE_SWIZZLE_X:
return desc->channel[0].size;
- case UTIL_FORMAT_SWIZZLE_Y:
+ case PIPE_SWIZZLE_Y:
return desc->channel[1].size;
- case UTIL_FORMAT_SWIZZLE_Z:
+ case PIPE_SWIZZLE_Z:
return desc->channel[2].size;
- case UTIL_FORMAT_SWIZZLE_W:
+ case PIPE_SWIZZLE_W:
return desc->channel[3].size;
default:
return 0;
* Given a linear RGB colorspace format, return the corresponding SRGB
* format, or PIPE_FORMAT_NONE if none.
*/
-static INLINE enum pipe_format
+static inline enum pipe_format
util_format_srgb(enum pipe_format format)
{
if (util_format_is_srgb(format))
return PIPE_FORMAT_DXT3_SRGBA;
case PIPE_FORMAT_DXT5_RGBA:
return PIPE_FORMAT_DXT5_SRGBA;
+ case PIPE_FORMAT_B5G6R5_UNORM:
+ return PIPE_FORMAT_B5G6R5_SRGB;
+ case PIPE_FORMAT_BPTC_RGBA_UNORM:
+ return PIPE_FORMAT_BPTC_SRGBA;
+ case PIPE_FORMAT_ASTC_4x4:
+ return PIPE_FORMAT_ASTC_4x4_SRGB;
+ case PIPE_FORMAT_ASTC_5x4:
+ return PIPE_FORMAT_ASTC_5x4_SRGB;
+ case PIPE_FORMAT_ASTC_5x5:
+ return PIPE_FORMAT_ASTC_5x5_SRGB;
+ case PIPE_FORMAT_ASTC_6x5:
+ return PIPE_FORMAT_ASTC_6x5_SRGB;
+ case PIPE_FORMAT_ASTC_6x6:
+ return PIPE_FORMAT_ASTC_6x6_SRGB;
+ case PIPE_FORMAT_ASTC_8x5:
+ return PIPE_FORMAT_ASTC_8x5_SRGB;
+ case PIPE_FORMAT_ASTC_8x6:
+ return PIPE_FORMAT_ASTC_8x6_SRGB;
+ case PIPE_FORMAT_ASTC_8x8:
+ return PIPE_FORMAT_ASTC_8x8_SRGB;
+ case PIPE_FORMAT_ASTC_10x5:
+ return PIPE_FORMAT_ASTC_10x5_SRGB;
+ case PIPE_FORMAT_ASTC_10x6:
+ return PIPE_FORMAT_ASTC_10x6_SRGB;
+ case PIPE_FORMAT_ASTC_10x8:
+ return PIPE_FORMAT_ASTC_10x8_SRGB;
+ case PIPE_FORMAT_ASTC_10x10:
+ return PIPE_FORMAT_ASTC_10x10_SRGB;
+ case PIPE_FORMAT_ASTC_12x10:
+ return PIPE_FORMAT_ASTC_12x10_SRGB;
+ case PIPE_FORMAT_ASTC_12x12:
+ return PIPE_FORMAT_ASTC_12x12_SRGB;
+
default:
return PIPE_FORMAT_NONE;
}
* Given an sRGB format, return the corresponding linear colorspace format.
* For non sRGB formats, return the format unchanged.
*/
-static INLINE enum pipe_format
+static inline enum pipe_format
util_format_linear(enum pipe_format format)
{
switch (format) {
return PIPE_FORMAT_DXT3_RGBA;
case PIPE_FORMAT_DXT5_SRGBA:
return PIPE_FORMAT_DXT5_RGBA;
+ case PIPE_FORMAT_B5G6R5_SRGB:
+ return PIPE_FORMAT_B5G6R5_UNORM;
+ case PIPE_FORMAT_BPTC_SRGBA:
+ return PIPE_FORMAT_BPTC_RGBA_UNORM;
+ case PIPE_FORMAT_ASTC_4x4_SRGB:
+ return PIPE_FORMAT_ASTC_4x4;
+ case PIPE_FORMAT_ASTC_5x4_SRGB:
+ return PIPE_FORMAT_ASTC_5x4;
+ case PIPE_FORMAT_ASTC_5x5_SRGB:
+ return PIPE_FORMAT_ASTC_5x5;
+ case PIPE_FORMAT_ASTC_6x5_SRGB:
+ return PIPE_FORMAT_ASTC_6x5;
+ case PIPE_FORMAT_ASTC_6x6_SRGB:
+ return PIPE_FORMAT_ASTC_6x6;
+ case PIPE_FORMAT_ASTC_8x5_SRGB:
+ return PIPE_FORMAT_ASTC_8x5;
+ case PIPE_FORMAT_ASTC_8x6_SRGB:
+ return PIPE_FORMAT_ASTC_8x6;
+ case PIPE_FORMAT_ASTC_8x8_SRGB:
+ return PIPE_FORMAT_ASTC_8x8;
+ case PIPE_FORMAT_ASTC_10x5_SRGB:
+ return PIPE_FORMAT_ASTC_10x5;
+ case PIPE_FORMAT_ASTC_10x6_SRGB:
+ return PIPE_FORMAT_ASTC_10x6;
+ case PIPE_FORMAT_ASTC_10x8_SRGB:
+ return PIPE_FORMAT_ASTC_10x8;
+ case PIPE_FORMAT_ASTC_10x10_SRGB:
+ return PIPE_FORMAT_ASTC_10x10;
+ case PIPE_FORMAT_ASTC_12x10_SRGB:
+ return PIPE_FORMAT_ASTC_12x10;
+ case PIPE_FORMAT_ASTC_12x12_SRGB:
+ return PIPE_FORMAT_ASTC_12x12;
default:
return format;
}
* Given a depth-stencil format, return the corresponding stencil-only format.
* For stencil-only formats, return the format unchanged.
*/
-static INLINE enum pipe_format
+static inline enum pipe_format
util_format_stencil_only(enum pipe_format format)
{
switch (format) {
* Converts PIPE_FORMAT_*I* to PIPE_FORMAT_*R*.
* This is identity for non-intensity formats.
*/
-static INLINE enum pipe_format
+static inline enum pipe_format
util_format_intensity_to_red(enum pipe_format format)
{
switch (format) {
* Converts PIPE_FORMAT_*L* to PIPE_FORMAT_*R*.
* This is identity for non-luminance formats.
*/
-static INLINE enum pipe_format
+static inline enum pipe_format
util_format_luminance_to_red(enum pipe_format format)
{
switch (format) {
return PIPE_FORMAT_RGTC1_SNORM;
case PIPE_FORMAT_L4A4_UNORM:
- /* XXX A4R4 is defined as x00y in u_format.csv */
- return PIPE_FORMAT_A4R4_UNORM;
+ return PIPE_FORMAT_R4A4_UNORM;
case PIPE_FORMAT_L8A8_UNORM:
return PIPE_FORMAT_R8A8_UNORM;
* Return the number of components stored.
* Formats with block size != 1x1 will always have 1 component (the block).
*/
-static INLINE unsigned
+static inline unsigned
util_format_get_nr_components(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
* Return the index of the first non-void channel
* -1 if no non-void channels
*/
-static INLINE int
+static inline int
util_format_get_first_non_void_channel(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
unsigned src_x, unsigned src_y,
unsigned width, unsigned height);
+boolean
+util_format_translate_3d(enum pipe_format dst_format,
+ void *dst, unsigned dst_stride,
+ unsigned dst_slice_stride,
+ unsigned dst_x, unsigned dst_y,
+ unsigned dst_z,
+ enum pipe_format src_format,
+ const void *src, unsigned src_stride,
+ unsigned src_slice_stride,
+ unsigned src_x, unsigned src_y,
+ unsigned src_z, unsigned width,
+ unsigned height, unsigned depth);
+
/*
* Swizzle operations.
*/
/* Apply the swizzle provided in \param swz (which is one of PIPE_SWIZZLE_x)
* to \param src and store the result in \param dst.
- * \param is_integer determines the value written for PIPE_SWIZZLE_ONE.
+ * \param is_integer determines the value written for PIPE_SWIZZLE_1.
*/
void util_format_apply_color_swizzle(union pipe_color_union *dst,
const union pipe_color_union *src,
const unsigned char swz[4],
const boolean is_integer);
-void util_format_swizzle_4f(float *dst, const float *src,
+void pipe_swizzle_4f(float *dst, const float *src,
const unsigned char swz[4]);
void util_format_unswizzle_4f(float *dst, const float *src,