mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 11:48:06 +02:00
wsi: add rgb_component_bits_are_equal
Signed-off-by: Oleksii Bozhenko oleksii.bozhenko@globallogic.com Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com> Reviewed-by: Eric Engestrom <eric@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22337>
This commit is contained in:
parent
7704773619
commit
53106c3a4f
1 changed files with 10 additions and 6 deletions
|
|
@ -799,6 +799,14 @@ format_get_component_bits(VkFormat format, int comp)
|
|||
return vk_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, comp);
|
||||
}
|
||||
|
||||
static bool
|
||||
rgb_component_bits_are_equal(VkFormat format, const xcb_visualtype_t* type)
|
||||
{
|
||||
return format_get_component_bits(format, 0) == util_bitcount(type->red_mask) &&
|
||||
format_get_component_bits(format, 1) == util_bitcount(type->green_mask) &&
|
||||
format_get_component_bits(format, 2) == util_bitcount(type->blue_mask);
|
||||
}
|
||||
|
||||
static bool
|
||||
get_sorted_vk_formats(VkIcdSurfaceBase *surface, struct wsi_device *wsi_device,
|
||||
VkFormat *sorted_formats, unsigned *count)
|
||||
|
|
@ -814,18 +822,14 @@ get_sorted_vk_formats(VkIcdSurfaceBase *surface, struct wsi_device *wsi_device,
|
|||
/* use the root window's visual to set the default */
|
||||
*count = 0;
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(formats); i++) {
|
||||
if (format_get_component_bits(formats[i], 0) == util_bitcount(rootvis->red_mask) &&
|
||||
format_get_component_bits(formats[i], 1) == util_bitcount(rootvis->green_mask) &&
|
||||
format_get_component_bits(formats[i], 2) == util_bitcount(rootvis->blue_mask))
|
||||
if (rgb_component_bits_are_equal(formats[i], rootvis))
|
||||
sorted_formats[(*count)++] = formats[i];
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(formats); i++) {
|
||||
if (formats[i] == sorted_formats[0])
|
||||
continue;
|
||||
if (format_get_component_bits(formats[i], 0) == util_bitcount(visual->red_mask) &&
|
||||
format_get_component_bits(formats[i], 1) == util_bitcount(visual->green_mask) &&
|
||||
format_get_component_bits(formats[i], 2) == util_bitcount(visual->blue_mask))
|
||||
if (rgb_component_bits_are_equal(formats[i], visual))
|
||||
sorted_formats[(*count)++] = formats[i];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue