util: Replace usage of boolean with c11 bool in src/util/format/* and src/util/tests/format/*

This is done by find and replace:
boolean -> bool
TRUE -> true
FALSE -> false

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: David Heidelberg <david.heidelberg@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19649>
This commit is contained in:
Yonggang Luo 2022-11-07 13:34:30 +08:00 committed by Marge Bot
parent d13d93b089
commit 5d794e8e3d
7 changed files with 264 additions and 264 deletions

View file

@ -94,7 +94,7 @@ util_copy_rect(ubyte * dst,
}
boolean
bool
util_format_is_float(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
@ -102,15 +102,15 @@ util_format_is_float(enum pipe_format format)
i = util_format_get_first_non_void_channel(format);
if (i < 0) {
return FALSE;
return false;
}
return desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT ? TRUE : FALSE;
return desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT ? true : false;
}
/** Test if the format contains RGB, but not alpha */
boolean
bool
util_format_has_alpha(enum pipe_format format)
{
const struct util_format_description *desc =
@ -122,7 +122,7 @@ util_format_has_alpha(enum pipe_format format)
}
/** Test if format has alpha as 1 (like RGBX) */
boolean
bool
util_format_has_alpha1(enum pipe_format format)
{
const struct util_format_description *desc =
@ -134,7 +134,7 @@ util_format_has_alpha1(enum pipe_format format)
desc->swizzle[3] == PIPE_SWIZZLE_1;
}
boolean
bool
util_format_is_luminance(enum pipe_format format)
{
const struct util_format_description *desc =
@ -146,12 +146,12 @@ util_format_is_luminance(enum pipe_format format)
desc->swizzle[1] == PIPE_SWIZZLE_X &&
desc->swizzle[2] == PIPE_SWIZZLE_X &&
desc->swizzle[3] == PIPE_SWIZZLE_1) {
return TRUE;
return true;
}
return FALSE;
return false;
}
boolean
bool
util_format_is_alpha(enum pipe_format format)
{
const struct util_format_description *desc =
@ -163,12 +163,12 @@ util_format_is_alpha(enum pipe_format format)
desc->swizzle[1] == PIPE_SWIZZLE_0 &&
desc->swizzle[2] == PIPE_SWIZZLE_0 &&
desc->swizzle[3] == PIPE_SWIZZLE_X) {
return TRUE;
return true;
}
return FALSE;
return false;
}
boolean
bool
util_format_is_pure_integer(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
@ -185,12 +185,12 @@ util_format_is_pure_integer(enum pipe_format format)
/* Find the first non-void channel. */
i = util_format_get_first_non_void_channel(format);
if (i == -1)
return FALSE;
return false;
return desc->channel[i].pure_integer ? TRUE : FALSE;
return desc->channel[i].pure_integer ? true : false;
}
boolean
bool
util_format_is_pure_sint(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
@ -198,12 +198,12 @@ util_format_is_pure_sint(enum pipe_format format)
i = util_format_get_first_non_void_channel(format);
if (i == -1)
return FALSE;
return false;
return (desc->channel[i].type == UTIL_FORMAT_TYPE_SIGNED && desc->channel[i].pure_integer) ? TRUE : FALSE;
return (desc->channel[i].type == UTIL_FORMAT_TYPE_SIGNED && desc->channel[i].pure_integer) ? true : false;
}
boolean
bool
util_format_is_pure_uint(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
@ -211,15 +211,15 @@ util_format_is_pure_uint(enum pipe_format format)
i = util_format_get_first_non_void_channel(format);
if (i == -1)
return FALSE;
return false;
return (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED && desc->channel[i].pure_integer) ? TRUE : FALSE;
return (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED && desc->channel[i].pure_integer) ? true : false;
}
/**
* Returns true if the format contains normalized signed channels.
*/
boolean
bool
util_format_is_snorm(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
@ -230,7 +230,7 @@ util_format_is_snorm(enum pipe_format format)
/**
* Returns true if the format contains normalized unsigned channels.
*/
boolean
bool
util_format_is_unorm(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
@ -241,7 +241,7 @@ util_format_is_unorm(enum pipe_format format)
/**
* Returns true if the format contains scaled integer format channels.
*/
boolean
bool
util_format_is_scaled(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
@ -249,30 +249,30 @@ util_format_is_scaled(enum pipe_format format)
/* format none is described as scaled but not for this check */
if (format == PIPE_FORMAT_NONE)
return FALSE;
return false;
/* Find the first non-void channel. */
i = util_format_get_first_non_void_channel(format);
if (i == -1)
return FALSE;
return false;
return !desc->channel[i].pure_integer && !desc->channel[i].normalized &&
(desc->channel[i].type == UTIL_FORMAT_TYPE_SIGNED ||
desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED);
}
boolean
bool
util_format_is_snorm8(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
int i;
if (desc->is_mixed)
return FALSE;
return false;
i = util_format_get_first_non_void_channel(format);
if (i == -1)
return FALSE;
return false;
return desc->channel[i].type == UTIL_FORMAT_TYPE_SIGNED &&
!desc->channel[i].pure_integer &&
@ -280,7 +280,7 @@ util_format_is_snorm8(enum pipe_format format)
desc->channel[i].size == 8;
}
boolean
bool
util_format_is_luminance_alpha(enum pipe_format format)
{
const struct util_format_description *desc =
@ -292,13 +292,13 @@ util_format_is_luminance_alpha(enum pipe_format format)
desc->swizzle[1] == PIPE_SWIZZLE_X &&
desc->swizzle[2] == PIPE_SWIZZLE_X &&
desc->swizzle[3] == PIPE_SWIZZLE_Y) {
return TRUE;
return true;
}
return FALSE;
return false;
}
boolean
bool
util_format_is_intensity(enum pipe_format format)
{
const struct util_format_description *desc =
@ -310,12 +310,12 @@ util_format_is_intensity(enum pipe_format format)
desc->swizzle[1] == PIPE_SWIZZLE_X &&
desc->swizzle[2] == PIPE_SWIZZLE_X &&
desc->swizzle[3] == PIPE_SWIZZLE_X) {
return TRUE;
return true;
}
return FALSE;
return false;
}
boolean
bool
util_format_is_subsampled_422(enum pipe_format format)
{
const struct util_format_description *desc =
@ -511,31 +511,31 @@ util_format_write_4ub(enum pipe_format format, const uint8_t *src, unsigned src_
* r10g10b10a2_uscaled -> r10g10b10x2_uscaled
* r10sg10sb10sa2u_norm -> r10g10b10x2_snorm
*/
boolean
bool
util_is_format_compatible(const struct util_format_description *src_desc,
const struct util_format_description *dst_desc)
{
unsigned chan;
if (src_desc->format == dst_desc->format) {
return TRUE;
return true;
}
if (src_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN ||
dst_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) {
return FALSE;
return false;
}
if (src_desc->block.bits != dst_desc->block.bits ||
src_desc->nr_channels != dst_desc->nr_channels ||
src_desc->colorspace != dst_desc->colorspace) {
return FALSE;
return false;
}
for (chan = 0; chan < 4; ++chan) {
if (src_desc->channel[chan].size !=
dst_desc->channel[chan].size) {
return FALSE;
return false;
}
}
@ -544,22 +544,22 @@ util_is_format_compatible(const struct util_format_description *src_desc,
if (swizzle < 4) {
if (src_desc->swizzle[chan] != swizzle) {
return FALSE;
return false;
}
if ((src_desc->channel[swizzle].type !=
dst_desc->channel[swizzle].type) ||
(src_desc->channel[swizzle].normalized !=
dst_desc->channel[swizzle].normalized)) {
return FALSE;
return false;
}
}
}
return TRUE;
return true;
}
boolean
bool
util_format_fits_8unorm(const struct util_format_description *format_desc)
{
unsigned chan;
@ -569,7 +569,7 @@ util_format_fits_8unorm(const struct util_format_description *format_desc)
*/
if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) {
return FALSE;
return false;
}
switch (format_desc->layout) {
@ -578,23 +578,23 @@ util_format_fits_8unorm(const struct util_format_description *format_desc)
/*
* These are straight forward.
*/
return TRUE;
return true;
case UTIL_FORMAT_LAYOUT_RGTC:
if (format_desc->format == PIPE_FORMAT_RGTC1_SNORM ||
format_desc->format == PIPE_FORMAT_RGTC2_SNORM ||
format_desc->format == PIPE_FORMAT_LATC1_SNORM ||
format_desc->format == PIPE_FORMAT_LATC2_SNORM)
return FALSE;
return TRUE;
return false;
return true;
case UTIL_FORMAT_LAYOUT_BPTC:
if (format_desc->format == PIPE_FORMAT_BPTC_RGBA_UNORM)
return TRUE;
return FALSE;
return true;
return false;
case UTIL_FORMAT_LAYOUT_ETC:
if (format_desc->format == PIPE_FORMAT_ETC1_RGB8)
return TRUE;
return FALSE;
return true;
return false;
case UTIL_FORMAT_LAYOUT_PLAIN:
/*
@ -608,14 +608,14 @@ util_format_fits_8unorm(const struct util_format_description *format_desc)
case UTIL_FORMAT_TYPE_UNSIGNED:
if (!format_desc->channel[chan].normalized ||
format_desc->channel[chan].size > 8) {
return FALSE;
return false;
}
break;
default:
return FALSE;
return false;
}
}
return TRUE;
return true;
default:
/*
@ -628,16 +628,16 @@ util_format_fits_8unorm(const struct util_format_description *format_desc)
case PIPE_FORMAT_YUYV:
case PIPE_FORMAT_R8G8_B8G8_UNORM:
case PIPE_FORMAT_G8R8_G8B8_UNORM:
return TRUE;
return true;
default:
return FALSE;
return false;
}
}
}
boolean
bool
util_format_translate(enum pipe_format dst_format,
void *dst, unsigned dst_stride,
unsigned dst_x, unsigned dst_y,
@ -669,7 +669,7 @@ util_format_translate(enum pipe_format dst_format,
util_copy_rect(dst, dst_format, dst_stride, dst_x, dst_y,
width, height, src, (int)src_stride,
src_x, src_y);
return TRUE;
return true;
}
assert(dst_x % dst_format_desc->block.width == 0);
@ -733,7 +733,7 @@ util_format_translate(enum pipe_format dst_format,
free(tmp_z);
return TRUE;
return true;
}
if (util_format_fits_8unorm(src_format_desc) ||
@ -743,13 +743,13 @@ util_format_translate(enum pipe_format dst_format,
if ((!unpack->unpack_rgba_8unorm && !unpack->unpack_rgba_8unorm_rect) ||
!pack->pack_rgba_8unorm) {
return FALSE;
return false;
}
tmp_stride = MAX2(width, x_step) * 4 * sizeof *tmp_row;
tmp_row = malloc(y_step * tmp_stride);
if (!tmp_row)
return FALSE;
return false;
while (height >= y_step) {
util_format_unpack_rgba_8unorm_rect(src_format, tmp_row, tmp_stride, src_row, src_stride, width, y_step);
@ -774,13 +774,13 @@ util_format_translate(enum pipe_format dst_format,
if (util_format_is_pure_sint(src_format) !=
util_format_is_pure_sint(dst_format)) {
return FALSE;
return false;
}
tmp_stride = MAX2(width, x_step) * 4 * sizeof *tmp_row;
tmp_row = malloc(y_step * tmp_stride);
if (!tmp_row)
return FALSE;
return false;
while (height >= y_step) {
util_format_unpack_rgba_rect(src_format, tmp_row, tmp_stride, src_row, src_stride, width, y_step);
@ -805,13 +805,13 @@ util_format_translate(enum pipe_format dst_format,
if ((!unpack->unpack_rgba && !unpack->unpack_rgba_rect) ||
!pack->pack_rgba_uint) {
return FALSE;
return false;
}
tmp_stride = MAX2(width, x_step) * 4 * sizeof *tmp_row;
tmp_row = malloc(y_step * tmp_stride);
if (!tmp_row)
return FALSE;
return false;
while (height >= y_step) {
util_format_unpack_rgba_rect(src_format, tmp_row, tmp_stride, src_row, src_stride, width, y_step);
@ -835,13 +835,13 @@ util_format_translate(enum pipe_format dst_format,
if ((!unpack->unpack_rgba && !unpack->unpack_rgba_rect) ||
!pack->pack_rgba_float) {
return FALSE;
return false;
}
tmp_stride = MAX2(width, x_step) * 4 * sizeof *tmp_row;
tmp_row = malloc(y_step * tmp_stride);
if (!tmp_row)
return FALSE;
return false;
while (height >= y_step) {
util_format_unpack_rgba_rect(src_format, tmp_row, tmp_stride, src_row, src_stride, width, y_step);
@ -859,10 +859,10 @@ util_format_translate(enum pipe_format dst_format,
free(tmp_row);
}
return TRUE;
return true;
}
boolean
bool
util_format_translate_3d(enum pipe_format dst_format,
void *dst, unsigned dst_stride,
unsigned dst_slice_stride,
@ -888,12 +888,12 @@ util_format_translate_3d(enum pipe_format dst_format,
src_format, src_layer, src_stride,
src_x, src_y,
width, height))
return FALSE;
return false;
dst_layer += dst_slice_stride;
src_layer += src_slice_stride;
}
return TRUE;
return true;
}
void util_format_compose_swizzles(const unsigned char swz1[4],
@ -911,7 +911,7 @@ void util_format_compose_swizzles(const unsigned char swz1[4],
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)
const bool is_integer)
{
unsigned c;

View file

@ -473,26 +473,26 @@ util_format_short_name(enum pipe_format format)
/**
* Whether this format is plain, see UTIL_FORMAT_LAYOUT_PLAIN for more info.
*/
static inline boolean
static inline bool
util_format_is_plain(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
if (!format) {
return FALSE;
return false;
}
return desc->layout == UTIL_FORMAT_LAYOUT_PLAIN ? TRUE : FALSE;
return desc->layout == UTIL_FORMAT_LAYOUT_PLAIN ? true : false;
}
static inline boolean
static inline bool
util_format_is_compressed(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
assert(desc);
if (!desc) {
return FALSE;
return false;
}
switch (desc->layout) {
@ -504,81 +504,81 @@ util_format_is_compressed(enum pipe_format format)
case UTIL_FORMAT_LAYOUT_ATC:
case UTIL_FORMAT_LAYOUT_FXT1:
/* XXX add other formats in the future */
return TRUE;
return true;
default:
return FALSE;
return false;
}
}
static inline boolean
static inline bool
util_format_is_s3tc(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
assert(desc);
if (!desc) {
return FALSE;
return false;
}
return desc->layout == UTIL_FORMAT_LAYOUT_S3TC ? TRUE : FALSE;
return desc->layout == UTIL_FORMAT_LAYOUT_S3TC ? true : false;
}
static inline boolean
static inline bool
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 false;
}
return desc->layout == UTIL_FORMAT_LAYOUT_ETC ? TRUE : FALSE;
return desc->layout == UTIL_FORMAT_LAYOUT_ETC ? true : false;
}
static inline boolean
static inline bool
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 bool
util_format_has_depth(const struct util_format_description *desc)
{
return desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS &&
desc->swizzle[0] != PIPE_SWIZZLE_NONE;
}
static inline boolean
static inline bool
util_format_has_stencil(const struct util_format_description *desc)
{
return desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS &&
desc->swizzle[1] != PIPE_SWIZZLE_NONE;
}
static inline boolean
static inline bool
util_format_is_depth_or_stencil(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
assert(desc);
if (!desc) {
return FALSE;
return false;
}
return util_format_has_depth(desc) ||
util_format_has_stencil(desc);
}
static inline boolean
static inline bool
util_format_is_depth_and_stencil(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
assert(desc);
if (!desc) {
return FALSE;
return false;
}
return util_format_has_depth(desc) &&
@ -606,14 +606,14 @@ util_format_get_depth_only(enum pipe_format format)
}
}
static inline boolean
static inline bool
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 false;
}
return desc->colorspace == UTIL_FORMAT_COLORSPACE_YUV;
@ -711,65 +711,65 @@ util_format_colormask(const struct util_format_description *desc)
* @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 bool
util_format_colormask_full(const struct util_format_description *desc, unsigned colormask)
{
return (~colormask & util_format_colormask(desc)) == 0;
}
boolean
bool
util_format_is_float(enum pipe_format format) ATTRIBUTE_CONST;
boolean
bool
util_format_has_alpha(enum pipe_format format) ATTRIBUTE_CONST;
boolean
bool
util_format_has_alpha1(enum pipe_format format) ATTRIBUTE_CONST;
boolean
bool
util_format_is_luminance(enum pipe_format format) ATTRIBUTE_CONST;
boolean
bool
util_format_is_alpha(enum pipe_format format) ATTRIBUTE_CONST;
boolean
bool
util_format_is_luminance_alpha(enum pipe_format format) ATTRIBUTE_CONST;
boolean
bool
util_format_is_intensity(enum pipe_format format) ATTRIBUTE_CONST;
boolean
bool
util_format_is_subsampled_422(enum pipe_format format) ATTRIBUTE_CONST;
boolean
bool
util_format_is_pure_integer(enum pipe_format format) ATTRIBUTE_CONST;
boolean
bool
util_format_is_pure_sint(enum pipe_format format) ATTRIBUTE_CONST;
boolean
bool
util_format_is_pure_uint(enum pipe_format format) ATTRIBUTE_CONST;
boolean
bool
util_format_is_snorm(enum pipe_format format) ATTRIBUTE_CONST;
boolean
bool
util_format_is_unorm(enum pipe_format format) ATTRIBUTE_CONST;
boolean
bool
util_format_is_snorm8(enum pipe_format format) ATTRIBUTE_CONST;
boolean
bool
util_format_is_scaled(enum pipe_format format) ATTRIBUTE_CONST;
/**
* 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
* the reverse.
*/
boolean
bool
util_is_format_compatible(const struct util_format_description *src_desc,
const struct util_format_description *dst_desc) ATTRIBUTE_CONST;
@ -780,7 +780,7 @@ util_is_format_compatible(const struct util_format_description *src_desc,
*
* PIPE_FORMAT_?8?8?8?8_UNORM
*/
static inline boolean
static inline bool
util_format_is_rgba8_variant(const struct util_format_description *desc)
{
unsigned chan;
@ -788,20 +788,20 @@ util_format_is_rgba8_variant(const struct util_format_description *desc)
if(desc->block.width != 1 ||
desc->block.height != 1 ||
desc->block.bits != 32)
return FALSE;
return false;
for(chan = 0; chan < 4; ++chan) {
if(desc->channel[chan].type != UTIL_FORMAT_TYPE_UNSIGNED &&
desc->channel[chan].type != UTIL_FORMAT_TYPE_VOID)
return FALSE;
return false;
if(desc->channel[chan].type == UTIL_FORMAT_TYPE_UNSIGNED &&
!desc->channel[chan].normalized)
return FALSE;
return false;
if(desc->channel[chan].size != 8)
return FALSE;
return false;
}
return TRUE;
return true;
}
@ -1627,10 +1627,10 @@ util_format_unpack_rgba_8unorm_rect(enum pipe_format format,
* Generic format conversion;
*/
boolean
bool
util_format_fits_8unorm(const struct util_format_description *format_desc) ATTRIBUTE_CONST;
boolean
bool
util_format_translate(enum pipe_format dst_format,
void *dst, unsigned dst_stride,
unsigned dst_x, unsigned dst_y,
@ -1639,7 +1639,7 @@ util_format_translate(enum pipe_format dst_format,
unsigned src_x, unsigned src_y,
unsigned width, unsigned height);
boolean
bool
util_format_translate_3d(enum pipe_format dst_format,
void *dst, unsigned dst_stride,
unsigned dst_slice_stride,
@ -1672,7 +1672,7 @@ void util_format_compose_swizzles(const unsigned char swz1[4],
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);
const bool is_integer);
void pipe_swizzle_4f(float *dst, const float *src,
const unsigned char swz[4]);

View file

@ -1549,7 +1549,7 @@ static inline void
util_format_fxtn_rgb_unpack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst_stride,
const uint8_t *restrict src_row, unsigned src_stride,
unsigned width, unsigned height,
boolean rgba)
bool rgba)
{
const unsigned bw = 8, bh = 4, comps = 4;
unsigned x, y, i, j;
@ -1596,7 +1596,7 @@ static inline void
util_format_fxtn_rgb_unpack_rgba_float(float *dst_row, unsigned dst_stride,
const uint8_t *restrict src_row, unsigned src_stride,
unsigned width, unsigned height,
boolean rgba)
bool rgba)
{
const unsigned bw = 8, bh = 4, comps = 4;
unsigned x, y, i, j;

View file

@ -124,7 +124,7 @@ util_format_dxtn_rgb_unpack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst_
const uint8_t *restrict src_row, unsigned src_stride,
unsigned width, unsigned height,
util_format_dxtn_fetch_t fetch,
unsigned block_size, boolean srgb)
unsigned block_size, bool srgb)
{
const unsigned bw = 4, bh = 4, comps = 4;
unsigned x, y, i, j;
@ -159,7 +159,7 @@ util_format_dxt1_rgb_unpack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst_
src_row, src_stride,
width, height,
util_format_dxt1_rgb_fetch,
8, FALSE);
8, false);
}
void
@ -171,7 +171,7 @@ util_format_dxt1_rgba_unpack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst
src_row, src_stride,
width, height,
util_format_dxt1_rgba_fetch,
8, FALSE);
8, false);
}
void
@ -183,7 +183,7 @@ util_format_dxt3_rgba_unpack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst
src_row, src_stride,
width, height,
util_format_dxt3_rgba_fetch,
16, FALSE);
16, false);
}
void
@ -195,7 +195,7 @@ util_format_dxt5_rgba_unpack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst
src_row, src_stride,
width, height,
util_format_dxt5_rgba_fetch,
16, FALSE);
16, false);
}
static inline void
@ -203,7 +203,7 @@ util_format_dxtn_rgb_unpack_rgba_float(float *restrict dst_row, unsigned dst_str
const uint8_t *restrict src_row, unsigned src_stride,
unsigned width, unsigned height,
util_format_dxtn_fetch_t fetch,
unsigned block_size, boolean srgb)
unsigned block_size, bool srgb)
{
unsigned x, y, i, j;
for(y = 0; y < height; y += 4) {
@ -242,7 +242,7 @@ util_format_dxt1_rgb_unpack_rgba_float(void *restrict dst_row, unsigned dst_stri
src_row, src_stride,
width, height,
util_format_dxt1_rgb_fetch,
8, FALSE);
8, false);
}
void
@ -254,7 +254,7 @@ util_format_dxt1_rgba_unpack_rgba_float(void *restrict dst_row, unsigned dst_str
src_row, src_stride,
width, height,
util_format_dxt1_rgba_fetch,
8, FALSE);
8, false);
}
void
@ -266,7 +266,7 @@ util_format_dxt3_rgba_unpack_rgba_float(void *restrict dst_row, unsigned dst_str
src_row, src_stride,
width, height,
util_format_dxt3_rgba_fetch,
16, FALSE);
16, false);
}
void
@ -278,7 +278,7 @@ util_format_dxt5_rgba_unpack_rgba_float(void *restrict dst_row, unsigned dst_str
src_row, src_stride,
width, height,
util_format_dxt5_rgba_fetch,
16, FALSE);
16, false);
}
@ -291,7 +291,7 @@ util_format_dxtn_pack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst_stride
const uint8_t *restrict src, unsigned src_stride,
unsigned width, unsigned height,
enum util_format_dxtn format,
unsigned block_size, boolean srgb)
unsigned block_size, bool srgb)
{
const unsigned bw = 4, bh = 4, comps = 4;
unsigned x, y, i, j, k;
@ -331,7 +331,7 @@ util_format_dxt1_rgb_pack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst_st
{
util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src, src_stride,
width, height, UTIL_FORMAT_DXT1_RGB,
8, FALSE);
8, false);
}
void
@ -341,7 +341,7 @@ util_format_dxt1_rgba_pack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst_s
{
util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src, src_stride,
width, height, UTIL_FORMAT_DXT1_RGBA,
8, FALSE);
8, false);
}
void
@ -351,7 +351,7 @@ util_format_dxt3_rgba_pack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst_s
{
util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src, src_stride,
width, height, UTIL_FORMAT_DXT3_RGBA,
16, FALSE);
16, false);
}
void
@ -361,7 +361,7 @@ util_format_dxt5_rgba_pack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst_s
{
util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src, src_stride,
width, height, UTIL_FORMAT_DXT5_RGBA,
16, FALSE);
16, false);
}
static inline void
@ -369,7 +369,7 @@ util_format_dxtn_pack_rgba_float(uint8_t *restrict dst_row, unsigned dst_stride,
const float *restrict src, unsigned src_stride,
unsigned width, unsigned height,
enum util_format_dxtn format,
unsigned block_size, boolean srgb)
unsigned block_size, bool srgb)
{
unsigned x, y, i, j, k;
for(y = 0; y < height; y += 4) {
@ -407,7 +407,7 @@ util_format_dxt1_rgb_pack_rgba_float(uint8_t *restrict dst_row, unsigned dst_str
{
util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src, src_stride,
width, height, UTIL_FORMAT_DXT1_RGB,
8, FALSE);
8, false);
}
void
@ -417,7 +417,7 @@ util_format_dxt1_rgba_pack_rgba_float(uint8_t *restrict dst_row, unsigned dst_st
{
util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src, src_stride,
width, height, UTIL_FORMAT_DXT1_RGBA,
8, FALSE);
8, false);
}
void
@ -427,7 +427,7 @@ util_format_dxt3_rgba_pack_rgba_float(uint8_t *restrict dst_row, unsigned dst_st
{
util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src, src_stride,
width, height, UTIL_FORMAT_DXT3_RGBA,
16, FALSE);
16, false);
}
void
@ -437,7 +437,7 @@ util_format_dxt5_rgba_pack_rgba_float(uint8_t *restrict dst_row, unsigned dst_st
{
util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src, src_stride,
width, height, UTIL_FORMAT_DXT5_RGBA,
16, FALSE);
16, false);
}
@ -544,7 +544,7 @@ util_format_dxt1_srgb_unpack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst
src_row, src_stride,
width, height,
util_format_dxt1_rgb_fetch,
8, TRUE);
8, true);
}
void
@ -554,7 +554,7 @@ util_format_dxt1_srgba_unpack_rgba_8unorm(uint8_t *restrict dst_row, unsigned ds
src_row, src_stride,
width, height,
util_format_dxt1_rgba_fetch,
8, TRUE);
8, true);
}
void
@ -564,7 +564,7 @@ util_format_dxt3_srgba_unpack_rgba_8unorm(uint8_t *restrict dst_row, unsigned ds
src_row, src_stride,
width, height,
util_format_dxt3_rgba_fetch,
16, TRUE);
16, true);
}
void
@ -574,7 +574,7 @@ util_format_dxt5_srgba_unpack_rgba_8unorm(uint8_t *restrict dst_row, unsigned ds
src_row, src_stride,
width, height,
util_format_dxt5_rgba_fetch,
16, TRUE);
16, true);
}
void
@ -584,7 +584,7 @@ util_format_dxt1_srgb_unpack_rgba_float(void *restrict dst_row, unsigned dst_str
src_row, src_stride,
width, height,
util_format_dxt1_rgb_fetch,
8, TRUE);
8, true);
}
void
@ -594,7 +594,7 @@ util_format_dxt1_srgba_unpack_rgba_float(void *restrict dst_row, unsigned dst_st
src_row, src_stride,
width, height,
util_format_dxt1_rgba_fetch,
8, TRUE);
8, true);
}
void
@ -604,7 +604,7 @@ util_format_dxt3_srgba_unpack_rgba_float(void *restrict dst_row, unsigned dst_st
src_row, src_stride,
width, height,
util_format_dxt3_rgba_fetch,
16, TRUE);
16, true);
}
void
@ -614,7 +614,7 @@ util_format_dxt5_srgba_unpack_rgba_float(void *restrict dst_row, unsigned dst_st
src_row, src_stride,
width, height,
util_format_dxt5_rgba_fetch,
16, TRUE);
16, true);
}
void
@ -622,7 +622,7 @@ util_format_dxt1_srgb_pack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst_s
{
util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride,
width, height, UTIL_FORMAT_DXT1_RGB,
8, TRUE);
8, true);
}
void
@ -630,7 +630,7 @@ util_format_dxt1_srgba_pack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst_
{
util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride,
width, height, UTIL_FORMAT_DXT1_RGBA,
8, TRUE);
8, true);
}
void
@ -638,7 +638,7 @@ util_format_dxt3_srgba_pack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst_
{
util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride,
width, height, UTIL_FORMAT_DXT3_RGBA,
16, TRUE);
16, true);
}
void
@ -646,7 +646,7 @@ util_format_dxt5_srgba_pack_rgba_8unorm(uint8_t *restrict dst_row, unsigned dst_
{
util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride,
width, height, UTIL_FORMAT_DXT5_RGBA,
16, TRUE);
16, true);
}
void
@ -654,7 +654,7 @@ util_format_dxt1_srgb_pack_rgba_float(uint8_t *restrict dst_row, unsigned dst_st
{
util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src_row, src_stride,
width, height, UTIL_FORMAT_DXT1_RGB,
8, TRUE);
8, true);
}
void
@ -662,7 +662,7 @@ util_format_dxt1_srgba_pack_rgba_float(uint8_t *restrict dst_row, unsigned dst_s
{
util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src_row, src_stride,
width, height, UTIL_FORMAT_DXT1_RGBA,
8, TRUE);
8, true);
}
void
@ -670,7 +670,7 @@ util_format_dxt3_srgba_pack_rgba_float(uint8_t *restrict dst_row, unsigned dst_s
{
util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src_row, src_stride,
width, height, UTIL_FORMAT_DXT3_RGBA,
16, TRUE);
16, true);
}
void
@ -678,6 +678,6 @@ util_format_dxt5_srgba_pack_rgba_float(uint8_t *restrict dst_row, unsigned dst_s
{
util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src_row, src_stride,
width, height, UTIL_FORMAT_DXT5_RGBA,
16, TRUE);
16, true);
}

View file

@ -61,9 +61,9 @@ type_map = {
def bool_map(value):
if value:
return "TRUE"
return "true"
else:
return "FALSE"
return "false"
swizzle_map = {

View file

@ -32,7 +32,7 @@
#include "util/format/u_format.h"
static boolean
static bool
test_all(void)
{
enum pipe_format src_format;
@ -56,13 +56,13 @@ test_all(void)
}
}
return TRUE;
return true;
}
int main(int argc, char **argv)
{
boolean success;
bool success;
success = test_all();

View file

@ -37,7 +37,7 @@
#include "util/format/u_format_s3tc.h"
static boolean
static bool
compare_float(float x, float y)
{
float error = y - x;
@ -46,10 +46,10 @@ compare_float(float x, float y)
error = -error;
if (error > FLT_EPSILON) {
return FALSE;
return false;
}
return TRUE;
return true;
}
@ -201,7 +201,7 @@ print_unpacked_s_8uint(const struct util_format_description *format_desc,
}
static boolean
static bool
test_format_fetch_rgba(const struct util_format_description *format_desc,
const struct util_format_test_case *test)
{
@ -209,15 +209,15 @@ test_format_fetch_rgba(const struct util_format_description *format_desc,
util_format_fetch_rgba_func(format_desc->format);
float unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH][4] = { { { 0 } } };
unsigned i, j, k;
boolean success;
bool success;
success = TRUE;
success = true;
for (i = 0; i < format_desc->block.height; ++i) {
for (j = 0; j < format_desc->block.width; ++j) {
fetch_rgba(unpacked[i][j], test->packed, j, i);
for (k = 0; k < 4; ++k) {
if (!compare_float(test->unpacked[i][j][k], unpacked[i][j][k])) {
success = FALSE;
success = false;
}
}
}
@ -225,7 +225,7 @@ test_format_fetch_rgba(const struct util_format_description *format_desc,
/* Ignore S3TC errors */
if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC) {
success = TRUE;
success = true;
}
if (!success) {
@ -237,24 +237,24 @@ test_format_fetch_rgba(const struct util_format_description *format_desc,
}
static boolean
static bool
test_format_unpack_rgba(const struct util_format_description *format_desc,
const struct util_format_test_case *test)
{
float unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH][4] = { { { 0 } } };
unsigned i, j, k;
boolean success;
bool success;
util_format_unpack_rgba_rect(format_desc->format, &unpacked[0][0][0], sizeof unpacked[0],
test->packed, 0,
format_desc->block.width, format_desc->block.height);
success = TRUE;
success = true;
for (i = 0; i < format_desc->block.height; ++i) {
for (j = 0; j < format_desc->block.width; ++j) {
for (k = 0; k < 4; ++k) {
if (!compare_float(test->unpacked[i][j][k], unpacked[i][j][k])) {
success = FALSE;
success = false;
}
}
}
@ -262,7 +262,7 @@ test_format_unpack_rgba(const struct util_format_description *format_desc,
/* Ignore S3TC errors */
if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC) {
success = TRUE;
success = true;
}
if (!success) {
@ -274,7 +274,7 @@ test_format_unpack_rgba(const struct util_format_description *format_desc,
}
static boolean
static bool
test_format_pack_rgba_float(const struct util_format_description *format_desc,
const struct util_format_test_case *test)
{
@ -283,7 +283,7 @@ test_format_pack_rgba_float(const struct util_format_description *format_desc,
float unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH][4];
uint8_t packed[UTIL_FORMAT_MAX_PACKED_BYTES];
unsigned i, j, k;
boolean success;
bool success;
if (test->format == PIPE_FORMAT_DXT1_RGBA) {
/*
@ -291,7 +291,7 @@ test_format_pack_rgba_float(const struct util_format_description *format_desc,
*
* TODO: Do a round trip conversion.
*/
return TRUE;
return true;
}
memset(packed, 0, sizeof packed);
@ -307,19 +307,19 @@ test_format_pack_rgba_float(const struct util_format_description *format_desc,
&unpacked[0][0][0], sizeof unpacked[0],
format_desc->block.width, format_desc->block.height);
success = TRUE;
success = true;
for (i = 0; i < format_desc->block.bits/8; ++i) {
if ((test->packed[i] & test->mask[i]) != (packed[i] & test->mask[i]))
success = FALSE;
success = false;
}
/* Ignore NaN */
if (util_is_double_nan(test->unpacked[0][0][0]))
success = TRUE;
success = true;
/* Ignore S3TC errors */
if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC) {
success = TRUE;
success = true;
}
if (!success) {
@ -331,19 +331,19 @@ test_format_pack_rgba_float(const struct util_format_description *format_desc,
}
static boolean
static bool
convert_float_to_8unorm(uint8_t *dst, const double *src)
{
unsigned i;
boolean accurate = TRUE;
bool accurate = true;
for (i = 0; i < UTIL_FORMAT_MAX_UNPACKED_HEIGHT*UTIL_FORMAT_MAX_UNPACKED_WIDTH*4; ++i) {
if (src[i] < 0.0) {
accurate = FALSE;
accurate = false;
dst[i] = 0;
}
else if (src[i] > 1.0) {
accurate = FALSE;
accurate = false;
dst[i] = 255;
}
else {
@ -355,17 +355,17 @@ convert_float_to_8unorm(uint8_t *dst, const double *src)
}
static boolean
static bool
test_format_unpack_rgba_8unorm(const struct util_format_description *format_desc,
const struct util_format_test_case *test)
{
uint8_t unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH][4] = { { { 0 } } };
uint8_t expected[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH][4] = { { { 0 } } };
unsigned i, j, k;
boolean success;
bool success;
if (util_format_is_pure_integer(format_desc->format))
return FALSE;
return false;
util_format_unpack_rgba_8unorm_rect(format_desc->format, &unpacked[0][0][0], sizeof unpacked[0],
test->packed, 0,
@ -373,12 +373,12 @@ test_format_unpack_rgba_8unorm(const struct util_format_description *format_desc
convert_float_to_8unorm(&expected[0][0][0], &test->unpacked[0][0][0]);
success = TRUE;
success = true;
for (i = 0; i < format_desc->block.height; ++i) {
for (j = 0; j < format_desc->block.width; ++j) {
for (k = 0; k < 4; ++k) {
if (expected[i][j][k] != unpacked[i][j][k]) {
success = FALSE;
success = false;
}
}
}
@ -386,7 +386,7 @@ test_format_unpack_rgba_8unorm(const struct util_format_description *format_desc
/* Ignore NaN */
if (util_is_double_nan(test->unpacked[0][0][0]))
success = TRUE;
success = true;
if (!success) {
print_unpacked_rgba_8unorm(format_desc, "FAILED: ", unpacked, " obtained\n");
@ -397,7 +397,7 @@ test_format_unpack_rgba_8unorm(const struct util_format_description *format_desc
}
static boolean
static bool
test_format_pack_rgba_8unorm(const struct util_format_description *format_desc,
const struct util_format_test_case *test)
{
@ -406,7 +406,7 @@ test_format_pack_rgba_8unorm(const struct util_format_description *format_desc,
uint8_t unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH][4];
uint8_t packed[UTIL_FORMAT_MAX_PACKED_BYTES];
unsigned i;
boolean success;
bool success;
if (test->format == PIPE_FORMAT_DXT1_RGBA) {
/*
@ -414,14 +414,14 @@ test_format_pack_rgba_8unorm(const struct util_format_description *format_desc,
*
* TODO: Do a round trip conversion.
*/
return TRUE;
return true;
}
if (!convert_float_to_8unorm(&unpacked[0][0][0], &test->unpacked[0][0][0])) {
/*
* Skip test cases which cannot be represented by four unorm bytes.
*/
return TRUE;
return true;
}
memset(packed, 0, sizeof packed);
@ -430,26 +430,26 @@ test_format_pack_rgba_8unorm(const struct util_format_description *format_desc,
&unpacked[0][0][0], sizeof unpacked[0],
format_desc->block.width, format_desc->block.height);
success = TRUE;
success = true;
for (i = 0; i < format_desc->block.bits/8; ++i)
if ((test->packed[i] & test->mask[i]) != (packed[i] & test->mask[i]))
success = FALSE;
success = false;
/* Ignore NaN */
if (util_is_double_nan(test->unpacked[0][0][0]))
success = TRUE;
success = true;
/* Ignore failure cases due to unorm8 format */
if (test->unpacked[0][0][0] > 1.0f || test->unpacked[0][0][0] < 0.0f)
success = TRUE;
success = true;
/* Multiple of 255 */
if ((test->unpacked[0][0][0] * 255.0) != (int)(test->unpacked[0][0][0] * 255.0))
success = TRUE;
success = true;
/* Ignore S3TC errors */
if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC) {
success = TRUE;
success = true;
}
if (!success) {
@ -461,7 +461,7 @@ test_format_pack_rgba_8unorm(const struct util_format_description *format_desc,
}
static boolean
static bool
test_format_unpack_z_float(const struct util_format_description *format_desc,
const struct util_format_test_case *test)
{
@ -469,17 +469,17 @@ test_format_unpack_z_float(const struct util_format_description *format_desc,
util_format_unpack_description(format_desc->format);
float unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH] = { { 0 } };
unsigned i, j;
boolean success;
bool success;
unpack->unpack_z_float(&unpacked[0][0], sizeof unpacked[0],
test->packed, 0,
format_desc->block.width, format_desc->block.height);
success = TRUE;
success = true;
for (i = 0; i < format_desc->block.height; ++i) {
for (j = 0; j < format_desc->block.width; ++j) {
if (!compare_float(test->unpacked[i][j][0], unpacked[i][j])) {
success = FALSE;
success = false;
}
}
}
@ -493,7 +493,7 @@ test_format_unpack_z_float(const struct util_format_description *format_desc,
}
static boolean
static bool
test_format_pack_z_float(const struct util_format_description *format_desc,
const struct util_format_test_case *test)
{
@ -502,14 +502,14 @@ test_format_pack_z_float(const struct util_format_description *format_desc,
float unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH];
uint8_t packed[UTIL_FORMAT_MAX_PACKED_BYTES];
unsigned i, j;
boolean success;
bool success;
memset(packed, 0, sizeof packed);
for (i = 0; i < format_desc->block.height; ++i) {
for (j = 0; j < format_desc->block.width; ++j) {
unpacked[i][j] = (float) test->unpacked[i][j][0];
if (test->unpacked[i][j][1]) {
return TRUE;
return true;
}
}
}
@ -518,10 +518,10 @@ test_format_pack_z_float(const struct util_format_description *format_desc,
&unpacked[0][0], sizeof unpacked[0],
format_desc->block.width, format_desc->block.height);
success = TRUE;
success = true;
for (i = 0; i < format_desc->block.bits/8; ++i)
if ((test->packed[i] & test->mask[i]) != (packed[i] & test->mask[i]))
success = FALSE;
success = false;
if (!success) {
print_packed(format_desc, "FAILED: ", packed, " obtained\n");
@ -532,7 +532,7 @@ test_format_pack_z_float(const struct util_format_description *format_desc,
}
static boolean
static bool
test_format_unpack_z_32unorm(const struct util_format_description *format_desc,
const struct util_format_test_case *test)
{
@ -541,7 +541,7 @@ test_format_unpack_z_32unorm(const struct util_format_description *format_desc,
uint32_t unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH] = { { 0 } };
uint32_t expected[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH] = { { 0 } };
unsigned i, j;
boolean success;
bool success;
unpack->unpack_z_32unorm(&unpacked[0][0], sizeof unpacked[0],
test->packed, 0,
@ -553,11 +553,11 @@ test_format_unpack_z_32unorm(const struct util_format_description *format_desc,
}
}
success = TRUE;
success = true;
for (i = 0; i < format_desc->block.height; ++i) {
for (j = 0; j < format_desc->block.width; ++j) {
if (expected[i][j] != unpacked[i][j]) {
success = FALSE;
success = false;
}
}
}
@ -571,7 +571,7 @@ test_format_unpack_z_32unorm(const struct util_format_description *format_desc,
}
static boolean
static bool
test_format_pack_z_32unorm(const struct util_format_description *format_desc,
const struct util_format_test_case *test)
{
@ -580,13 +580,13 @@ test_format_pack_z_32unorm(const struct util_format_description *format_desc,
uint32_t unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH];
uint8_t packed[UTIL_FORMAT_MAX_PACKED_BYTES];
unsigned i, j;
boolean success;
bool success;
for (i = 0; i < format_desc->block.height; ++i) {
for (j = 0; j < format_desc->block.width; ++j) {
unpacked[i][j] = test->unpacked[i][j][0] * 0xffffffff;
if (test->unpacked[i][j][1]) {
return TRUE;
return true;
}
}
}
@ -597,10 +597,10 @@ test_format_pack_z_32unorm(const struct util_format_description *format_desc,
&unpacked[0][0], sizeof unpacked[0],
format_desc->block.width, format_desc->block.height);
success = TRUE;
success = true;
for (i = 0; i < format_desc->block.bits/8; ++i)
if ((test->packed[i] & test->mask[i]) != (packed[i] & test->mask[i]))
success = FALSE;
success = false;
if (!success) {
print_packed(format_desc, "FAILED: ", packed, " obtained\n");
@ -611,7 +611,7 @@ test_format_pack_z_32unorm(const struct util_format_description *format_desc,
}
static boolean
static bool
test_format_unpack_s_8uint(const struct util_format_description *format_desc,
const struct util_format_test_case *test)
{
@ -620,7 +620,7 @@ test_format_unpack_s_8uint(const struct util_format_description *format_desc,
uint8_t unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH] = { { 0 } };
uint8_t expected[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH] = { { 0 } };
unsigned i, j;
boolean success;
bool success;
unpack->unpack_s_8uint(&unpacked[0][0], sizeof unpacked[0],
test->packed, 0,
@ -632,11 +632,11 @@ test_format_unpack_s_8uint(const struct util_format_description *format_desc,
}
}
success = TRUE;
success = true;
for (i = 0; i < format_desc->block.height; ++i) {
for (j = 0; j < format_desc->block.width; ++j) {
if (expected[i][j] != unpacked[i][j]) {
success = FALSE;
success = false;
}
}
}
@ -650,7 +650,7 @@ test_format_unpack_s_8uint(const struct util_format_description *format_desc,
}
static boolean
static bool
test_format_pack_s_8uint(const struct util_format_description *format_desc,
const struct util_format_test_case *test)
{
@ -659,13 +659,13 @@ test_format_pack_s_8uint(const struct util_format_description *format_desc,
uint8_t unpacked[UTIL_FORMAT_MAX_UNPACKED_HEIGHT][UTIL_FORMAT_MAX_UNPACKED_WIDTH];
uint8_t packed[UTIL_FORMAT_MAX_PACKED_BYTES];
unsigned i, j;
boolean success;
bool success;
for (i = 0; i < format_desc->block.height; ++i) {
for (j = 0; j < format_desc->block.width; ++j) {
unpacked[i][j] = test->unpacked[i][j][1];
if (test->unpacked[i][j][0]) {
return TRUE;
return true;
}
}
}
@ -676,10 +676,10 @@ test_format_pack_s_8uint(const struct util_format_description *format_desc,
&unpacked[0][0], sizeof unpacked[0],
format_desc->block.width, format_desc->block.height);
success = TRUE;
success = true;
for (i = 0; i < format_desc->block.bits/8; ++i)
if ((test->packed[i] & test->mask[i]) != (packed[i] & test->mask[i]))
success = FALSE;
success = false;
if (!success) {
print_packed(format_desc, "FAILED: ", packed, " obtained\n");
@ -691,10 +691,10 @@ test_format_pack_s_8uint(const struct util_format_description *format_desc,
/* Touch-test that the unorm/snorm flags are set up right by codegen. */
static boolean
static bool
test_format_norm_flags(const struct util_format_description *format_desc)
{
boolean success = TRUE;
bool success = true;
#define FORMAT_CASE(format, unorm, snorm) \
case format: \
@ -703,18 +703,18 @@ test_format_norm_flags(const struct util_format_description *format_desc)
break
switch (format_desc->format) {
FORMAT_CASE(PIPE_FORMAT_R8G8B8A8_UNORM, TRUE, FALSE);
FORMAT_CASE(PIPE_FORMAT_R8G8B8A8_SRGB, TRUE, FALSE);
FORMAT_CASE(PIPE_FORMAT_R8G8B8A8_SNORM, FALSE, TRUE);
FORMAT_CASE(PIPE_FORMAT_R32_FLOAT, FALSE, FALSE);
FORMAT_CASE(PIPE_FORMAT_X8Z24_UNORM, TRUE, FALSE);
FORMAT_CASE(PIPE_FORMAT_S8X24_UINT, FALSE, FALSE);
FORMAT_CASE(PIPE_FORMAT_DXT1_RGB, TRUE, FALSE);
FORMAT_CASE(PIPE_FORMAT_ETC2_RGB8, TRUE, FALSE);
FORMAT_CASE(PIPE_FORMAT_ETC2_R11_SNORM, FALSE, TRUE);
FORMAT_CASE(PIPE_FORMAT_ASTC_4x4, TRUE, FALSE);
FORMAT_CASE(PIPE_FORMAT_BPTC_RGBA_UNORM, TRUE, FALSE);
FORMAT_CASE(PIPE_FORMAT_BPTC_RGB_FLOAT, FALSE, FALSE);
FORMAT_CASE(PIPE_FORMAT_R8G8B8A8_UNORM, true, false);
FORMAT_CASE(PIPE_FORMAT_R8G8B8A8_SRGB, true, false);
FORMAT_CASE(PIPE_FORMAT_R8G8B8A8_SNORM, false, true);
FORMAT_CASE(PIPE_FORMAT_R32_FLOAT, false, false);
FORMAT_CASE(PIPE_FORMAT_X8Z24_UNORM, true, false);
FORMAT_CASE(PIPE_FORMAT_S8X24_UINT, false, false);
FORMAT_CASE(PIPE_FORMAT_DXT1_RGB, true, false);
FORMAT_CASE(PIPE_FORMAT_ETC2_RGB8, true, false);
FORMAT_CASE(PIPE_FORMAT_ETC2_R11_SNORM, false, true);
FORMAT_CASE(PIPE_FORMAT_ASTC_4x4, true, false);
FORMAT_CASE(PIPE_FORMAT_BPTC_RGBA_UNORM, true, false);
FORMAT_CASE(PIPE_FORMAT_BPTC_RGB_FLOAT, false, false);
default:
success = !(format_desc->is_unorm && format_desc->is_snorm);
break;
@ -731,18 +731,18 @@ test_format_norm_flags(const struct util_format_description *format_desc)
return success;
}
typedef boolean
typedef bool
(*test_func_t)(const struct util_format_description *format_desc,
const struct util_format_test_case *test);
static boolean
static bool
test_one_func(const struct util_format_description *format_desc,
test_func_t func,
const char *suffix)
{
unsigned i;
boolean success = TRUE;
bool success = true;
printf("Testing util_format_%s_%s ...\n",
format_desc->short_name, suffix);
@ -753,7 +753,7 @@ test_one_func(const struct util_format_description *format_desc,
if (test->format == format_desc->format) {
if (!func(format_desc, &util_format_test_cases[i])) {
success = FALSE;
success = false;
}
}
}
@ -761,28 +761,28 @@ test_one_func(const struct util_format_description *format_desc,
return success;
}
static boolean
static bool
test_format_metadata(const struct util_format_description *format_desc,
boolean (*func)(const struct util_format_description *format_desc),
bool (*func)(const struct util_format_description *format_desc),
const char *suffix)
{
boolean success = TRUE;
bool success = true;
printf("Testing util_format_%s_%s ...\n", format_desc->short_name, suffix);
fflush(stdout);
if (!func(format_desc)) {
success = FALSE;
success = false;
}
return success;
}
static boolean
static bool
test_all(void)
{
enum pipe_format format;
boolean success = TRUE;
bool success = true;
for (format = 1; format < PIPE_FORMAT_COUNT; ++format) {
const struct util_format_description *format_desc;
@ -799,32 +799,32 @@ test_all(void)
# define TEST_ONE_PACK_FUNC(name) \
if (util_format_pack_description(format)->name) { \
if (!test_one_func(format_desc, &test_format_##name, #name)) { \
success = FALSE; \
success = false; \
} \
}
# define TEST_ONE_UNPACK_FUNC(name) \
if (util_format_unpack_description(format)->name) { \
if (!test_one_func(format_desc, &test_format_##name, #name)) { \
success = FALSE; \
success = false; \
} \
}
# define TEST_ONE_UNPACK_RECT_FUNC(name) \
if (util_format_unpack_description(format)->name || util_format_unpack_description(format)->name##_rect) { \
if (!test_one_func(format_desc, &test_format_##name, #name)) { \
success = FALSE; \
success = false; \
} \
}
# define TEST_FORMAT_METADATA(name) \
if (!test_format_metadata(format_desc, &test_format_##name, #name)) { \
success = FALSE; \
success = false; \
} \
if (util_format_fetch_rgba_func(format)) {
if (!test_one_func(format_desc, test_format_fetch_rgba, "fetch_rgba"))
success = FALSE;
success = false;
}
if (util_format_is_snorm(format)) {
@ -835,11 +835,11 @@ test_all(void)
} else if (unorm == format) {
fprintf(stderr, "%s missing from util_format_snorm_to_unorm().\n",
util_format_name(format));
success = FALSE;
success = false;
} else if (!util_format_is_unorm(unorm)) {
fprintf(stderr, "util_format_snorm_to_unorm(%s) returned non-unorm %s.\n",
util_format_name(format), util_format_name(unorm));
success = FALSE;
success = false;
}
}
@ -867,7 +867,7 @@ test_all(void)
int main(int argc, char **argv)
{
boolean success;
bool success;
success = test_all();