mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-04 11:20:20 +01:00
intel/isl: Add a helper for swizzling color values
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15624>
This commit is contained in:
parent
4489933842
commit
257a20f40d
2 changed files with 37 additions and 0 deletions
|
|
@ -3328,6 +3328,38 @@ isl_swizzle_invert(struct isl_swizzle swizzle)
|
|||
return (struct isl_swizzle) { chans[0], chans[1], chans[2], chans[3] };
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
isl_color_value_channel(union isl_color_value src,
|
||||
enum isl_channel_select chan,
|
||||
uint32_t one)
|
||||
{
|
||||
if (chan == ISL_CHANNEL_SELECT_ZERO)
|
||||
return 0;
|
||||
if (chan == ISL_CHANNEL_SELECT_ONE)
|
||||
return one;
|
||||
|
||||
assert(chan >= ISL_CHANNEL_SELECT_RED);
|
||||
assert(chan < ISL_CHANNEL_SELECT_RED + 4);
|
||||
|
||||
return src.u32[chan - ISL_CHANNEL_SELECT_RED];
|
||||
}
|
||||
|
||||
/** Applies an inverse swizzle to a color value */
|
||||
union isl_color_value
|
||||
isl_color_value_swizzle(union isl_color_value src,
|
||||
struct isl_swizzle swizzle,
|
||||
bool is_float)
|
||||
{
|
||||
uint32_t one = is_float ? 0x3f800000 : 1;
|
||||
|
||||
return (union isl_color_value) { .u32 = {
|
||||
isl_color_value_channel(src, swizzle.r, one),
|
||||
isl_color_value_channel(src, swizzle.g, one),
|
||||
isl_color_value_channel(src, swizzle.b, one),
|
||||
isl_color_value_channel(src, swizzle.a, one),
|
||||
} };
|
||||
}
|
||||
|
||||
/** Applies an inverse swizzle to a color value */
|
||||
union isl_color_value
|
||||
isl_color_value_swizzle_inv(union isl_color_value src,
|
||||
|
|
|
|||
|
|
@ -2013,6 +2013,11 @@ enum isl_format isl_format_rgb_to_rgba(enum isl_format rgb) ATTRIBUTE_CONST;
|
|||
enum isl_format isl_format_rgb_to_rgbx(enum isl_format rgb) ATTRIBUTE_CONST;
|
||||
enum isl_format isl_format_rgbx_to_rgba(enum isl_format rgb) ATTRIBUTE_CONST;
|
||||
|
||||
union isl_color_value
|
||||
isl_color_value_swizzle(union isl_color_value src,
|
||||
struct isl_swizzle swizzle,
|
||||
bool is_float);
|
||||
|
||||
union isl_color_value
|
||||
isl_color_value_swizzle_inv(union isl_color_value src,
|
||||
struct isl_swizzle swizzle);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue