*/
UTIL_FORMAT_LAYOUT_BPTC = 7,
- /**
- * ASTC
- */
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 = 9
+ UTIL_FORMAT_LAYOUT_OTHER = 10
};
*/
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_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:
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)
{
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 (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:
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 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.
*/
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