intel/isl: Add an isl_color_value_is_zero helper

Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Nanley Chery <nanley.g.chery@intel.com>
(cherry picked from commit 4796025ba5)
This commit is contained in:
Jason Ekstrand 2018-02-12 15:50:12 -08:00 committed by Emil Velikov
parent 03d801a176
commit 5b6b4e4f38
2 changed files with 23 additions and 0 deletions

View file

@ -268,6 +268,26 @@ isl_tiling_get_info(enum isl_tiling tiling,
};
}
bool
isl_color_value_is_zero(union isl_color_value value,
enum isl_format format)
{
const struct isl_format_layout *fmtl = isl_format_get_layout(format);
#define RETURN_FALSE_IF_NOT_0(c, i) \
if (fmtl->channels.c.bits && value.u32[i] != 0) \
return false
RETURN_FALSE_IF_NOT_0(r, 0);
RETURN_FALSE_IF_NOT_0(g, 1);
RETURN_FALSE_IF_NOT_0(b, 2);
RETURN_FALSE_IF_NOT_0(a, 3);
#undef RETURN_FALSE_IF_NOT_0
return true;
}
bool
isl_color_value_is_zero_one(union isl_color_value value,
enum isl_format format)

View file

@ -1668,6 +1668,9 @@ isl_extent4d(uint32_t width, uint32_t height, uint32_t depth,
return e;
}
bool isl_color_value_is_zero(union isl_color_value value,
enum isl_format format);
bool isl_color_value_is_zero_one(union isl_color_value value,
enum isl_format format);