*/
UTIL_FORMAT_LAYOUT_BPTC = 7,
+ UTIL_FORMAT_LAYOUT_ASTC = 8,
+
+ UTIL_FORMAT_LAYOUT_ATC = 9,
+
/**
* Everything else that doesn't fit in any of the above layouts.
*/
- UTIL_FORMAT_LAYOUT_OTHER = 8
+ UTIL_FORMAT_LAYOUT_OTHER = 10
};
};
-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,
*/
unsigned is_mixed:1;
+ /**
+ * Whether the format contains UNORM channels
+ */
+ unsigned is_unorm:1;
+
+ /**
+ * Whether the format contains SNORM channels
+ */
+ unsigned is_snorm:1;
+
/**
* Input channel description, in the order XYZW.
*
case UTIL_FORMAT_LAYOUT_RGTC:
case UTIL_FORMAT_LAYOUT_ETC:
case UTIL_FORMAT_LAYOUT_BPTC:
+ case UTIL_FORMAT_LAYOUT_ASTC:
+ case UTIL_FORMAT_LAYOUT_ATC:
/* XXX add other formats in the future */
return TRUE;
default:
return desc->layout == UTIL_FORMAT_LAYOUT_S3TC ? TRUE : FALSE;
}
+static inline boolean
+util_format_is_etc(enum pipe_format format)
+{
+ const struct util_format_description *desc = util_format_description(format);
+
+ assert(desc);
+ if (!desc) {
+ return FALSE;
+ }
+
+ return desc->layout == UTIL_FORMAT_LAYOUT_ETC ? TRUE : FALSE;
+}
+
static inline boolean
util_format_is_srgb(enum pipe_format format)
{
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
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
util_format_has_stencil(desc);
}
+/**
+ * For depth-stencil formats, return the equivalent depth-only format.
+ */
+static inline boolean
+util_format_get_depth_only(enum pipe_format format)
+{
+ switch (format) {
+ case PIPE_FORMAT_Z24_UNORM_S8_UINT:
+ return PIPE_FORMAT_Z24X8_UNORM;
+
+ case PIPE_FORMAT_S8_UINT_Z24_UNORM:
+ return PIPE_FORMAT_X8Z24_UNORM;
+
+ case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
+ return PIPE_FORMAT_Z32_FLOAT;
+
+ default:
+ return format;
+ }
+}
+
+static inline boolean
+util_format_is_yuv(enum pipe_format format)
+{
+ const struct util_format_description *desc = util_format_description(format);
+
+ assert(desc);
+ if (!desc) {
+ return FALSE;
+ }
+
+ return desc->colorspace == UTIL_FORMAT_COLORSPACE_YUV;
+}
/**
* Calculates the depth format type based upon the incoming format description.
{
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;
boolean
util_format_is_snorm(enum pipe_format format);
+boolean
+util_format_is_unorm(enum pipe_format format);
+
boolean
util_format_is_snorm8(enum pipe_format format);
util_is_format_compatible(const struct util_format_description *src_desc,
const struct util_format_description *dst_desc);
-/**
- * Whether the format is supported by Gallium for the given bindings.
- * This covers S3TC textures and floating-point render targets.
- */
-boolean
-util_format_is_supported(enum pipe_format format, unsigned bind);
-
/**
* Whether this format is a rgab8 variant.
*
return TRUE;
}
-
/**
* Return total bits needed for the pixel format per block.
*/
}
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;
switch (format) {
case PIPE_FORMAT_L8_UNORM:
return PIPE_FORMAT_L8_SRGB;
+ case PIPE_FORMAT_R8_UNORM:
+ return PIPE_FORMAT_R8_SRGB;
case PIPE_FORMAT_L8A8_UNORM:
return PIPE_FORMAT_L8A8_SRGB;
case PIPE_FORMAT_R8G8B8_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;
}
switch (format) {
case PIPE_FORMAT_L8_SRGB:
return PIPE_FORMAT_L8_UNORM;
+ case PIPE_FORMAT_R8_SRGB:
+ return PIPE_FORMAT_R8_UNORM;
case PIPE_FORMAT_L8A8_SRGB:
return PIPE_FORMAT_L8A8_UNORM;
case PIPE_FORMAT_R8G8B8_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;
}
return i;
}
+/**
+ * Whether this format is any 8-bit UNORM variant. Looser than
+ * util_is_rgba8_variant (also includes alpha textures, for instance).
+ */
+
+static inline bool
+util_format_is_unorm8(const struct util_format_description *desc)
+{
+ int c = util_format_get_first_non_void_channel(desc->format);
+
+ if (c == -1)
+ return false;
+
+ return desc->is_unorm && desc->is_array && desc->channel[c].size == 8;
+}
+
/*
* Format access functions.
*/
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,
const unsigned char swz[4]);
+enum pipe_format
+util_format_snorm8_to_sint8(enum pipe_format format);
+
#ifdef __cplusplus
} // extern "C" {
#endif