vk/meta: Move get_uint_format_for_blk_size to common

Reviewed-by: Mary Guillemard <mary@mary.zone>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/42262>
This commit is contained in:
Mel Henning 2026-05-14 16:02:41 -04:00 committed by Marge Bot
parent 37e57b9890
commit 2a0264f064
2 changed files with 27 additions and 27 deletions

View file

@ -24,31 +24,6 @@ enum panvk_meta_object_key_type {
PANVK_META_OBJECT_KEY_FB_RESOLVE_SHADER,
};
static inline VkFormat
panvk_meta_get_uint_format_for_blk_size(unsigned blk_sz)
{
switch (blk_sz) {
case 1:
return VK_FORMAT_R8_UINT;
case 2:
return VK_FORMAT_R8G8_UINT;
case 3:
return VK_FORMAT_R8G8B8_UINT;
case 4:
return VK_FORMAT_R8G8B8A8_UINT;
case 6:
return VK_FORMAT_R16G16B16_UINT;
case 8:
return VK_FORMAT_R32G32_UINT;
case 12:
return VK_FORMAT_R32G32B32_UINT;
case 16:
return VK_FORMAT_R32G32B32A32_UINT;
default:
return VK_FORMAT_UNDEFINED;
}
}
static inline VkFormat
panvk_meta_get_blendable_format_for_blk_size(unsigned blk_sz)
{
@ -167,7 +142,7 @@ panvk_meta_copy_get_image_properties(struct panvk_image *img,
/* there are no blendable formats with blk_sz > 4 */
(prefer_blendable && blk_sz <= 4) ?
panvk_meta_get_blendable_format_for_blk_size(blk_sz) :
panvk_meta_get_uint_format_for_blk_size(blk_sz);
vk_meta_get_uint_format_for_blk_size(blk_sz);
}
}
} else {
@ -180,7 +155,7 @@ panvk_meta_copy_get_image_properties(struct panvk_image *img,
/* there are no blendable formats with blk_sz > 4 */
(prefer_blendable && blk_sz <= 4) ?
panvk_meta_get_blendable_format_for_blk_size(blk_sz) :
panvk_meta_get_uint_format_for_blk_size(blk_sz);
vk_meta_get_uint_format_for_blk_size(blk_sz);
}
}

View file

@ -454,6 +454,31 @@ vk_image_view_type_is_array(VkImageViewType view_type)
}
}
static inline VkFormat
vk_meta_get_uint_format_for_blk_size(unsigned blk_sz)
{
switch (blk_sz) {
case 1:
return VK_FORMAT_R8_UINT;
case 2:
return VK_FORMAT_R8G8_UINT;
case 3:
return VK_FORMAT_R8G8B8_UINT;
case 4:
return VK_FORMAT_R8G8B8A8_UINT;
case 6:
return VK_FORMAT_R16G16B16_UINT;
case 8:
return VK_FORMAT_R32G32_UINT;
case 12:
return VK_FORMAT_R32G32B32_UINT;
case 16:
return VK_FORMAT_R32G32B32A32_UINT;
default:
return VK_FORMAT_UNDEFINED;
}
}
#ifdef __cplusplus
}
#endif