util/format: add helper to check if a format is scaled.
lavapipe/llvmpipe need this to rule out scaled formats for non-vertex format usage. Note NONE is defined as scaled in u_format, but for the purposes of this helper I don't want it to be considered scaled. Reviewed-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Roland Scheidegger <sroland@vmware.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8907>
This commit is contained in:
parent
2b6d59bd8c
commit
8258726d90
|
@ -234,6 +234,29 @@ util_format_is_unorm(enum pipe_format format)
|
|||
return desc->is_unorm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the format contains scaled integer format channels.
|
||||
*/
|
||||
boolean
|
||||
util_format_is_scaled(enum pipe_format format)
|
||||
{
|
||||
const struct util_format_description *desc = util_format_description(format);
|
||||
int i;
|
||||
|
||||
/* format none is described as scaled but not for this check */
|
||||
if (format == PIPE_FORMAT_NONE)
|
||||
return FALSE;
|
||||
|
||||
/* Find the first non-void channel. */
|
||||
i = util_format_get_first_non_void_channel(format);
|
||||
if (i == -1)
|
||||
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
|
||||
util_format_is_snorm8(enum pipe_format format)
|
||||
{
|
||||
|
|
|
@ -729,6 +729,8 @@ util_format_is_unorm(enum pipe_format format) ATTRIBUTE_CONST;
|
|||
boolean
|
||||
util_format_is_snorm8(enum pipe_format format) ATTRIBUTE_CONST;
|
||||
|
||||
boolean
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue