vk/meta: Make some helpers public

vk_image_view_type_to_sampler_dim() and vk_image_view_type_is_array()
can be useful to driver-specific meta shaders.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31441>
This commit is contained in:
Boris Brezillon 2024-09-24 13:31:48 +02:00 committed by Marge Bot
parent cd38fd37f7
commit 3d7bf07089
2 changed files with 44 additions and 44 deletions

View file

@ -393,6 +393,50 @@ void vk_meta_fill_buffer(struct vk_command_buffer *cmd,
struct vk_meta_device *meta, VkBuffer buffer,
VkDeviceSize offset, VkDeviceSize size, uint32_t data);
static inline enum glsl_sampler_dim
vk_image_view_type_to_sampler_dim(VkImageViewType view_type)
{
switch (view_type) {
case VK_IMAGE_VIEW_TYPE_1D:
case VK_IMAGE_VIEW_TYPE_1D_ARRAY:
return GLSL_SAMPLER_DIM_1D;
case VK_IMAGE_VIEW_TYPE_2D:
case VK_IMAGE_VIEW_TYPE_2D_ARRAY:
return GLSL_SAMPLER_DIM_2D;
case VK_IMAGE_VIEW_TYPE_CUBE:
case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY:
return GLSL_SAMPLER_DIM_CUBE;
case VK_IMAGE_VIEW_TYPE_3D:
return GLSL_SAMPLER_DIM_3D;
default:
unreachable();
}
}
static inline bool
vk_image_view_type_is_array(VkImageViewType view_type)
{
switch (view_type) {
case VK_IMAGE_VIEW_TYPE_1D_ARRAY:
case VK_IMAGE_VIEW_TYPE_2D_ARRAY:
case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY:
return true;
case VK_IMAGE_VIEW_TYPE_1D:
case VK_IMAGE_VIEW_TYPE_2D:
case VK_IMAGE_VIEW_TYPE_3D:
case VK_IMAGE_VIEW_TYPE_CUBE:
return false;
default:
unreachable();
}
}
#ifdef __cplusplus
}
#endif

View file

@ -102,50 +102,6 @@ vk_image_storage_view_type(const struct vk_image *image)
}
}
static inline enum glsl_sampler_dim
vk_image_view_type_to_sampler_dim(VkImageViewType view_type)
{
switch (view_type) {
case VK_IMAGE_VIEW_TYPE_1D:
case VK_IMAGE_VIEW_TYPE_1D_ARRAY:
return GLSL_SAMPLER_DIM_1D;
case VK_IMAGE_VIEW_TYPE_2D:
case VK_IMAGE_VIEW_TYPE_2D_ARRAY:
return GLSL_SAMPLER_DIM_2D;
case VK_IMAGE_VIEW_TYPE_CUBE:
case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY:
return GLSL_SAMPLER_DIM_CUBE;
case VK_IMAGE_VIEW_TYPE_3D:
return GLSL_SAMPLER_DIM_3D;
default:
unreachable();
}
}
static inline bool
vk_image_view_type_is_array(VkImageViewType view_type)
{
switch (view_type) {
case VK_IMAGE_VIEW_TYPE_1D_ARRAY:
case VK_IMAGE_VIEW_TYPE_2D_ARRAY:
case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY:
return true;
case VK_IMAGE_VIEW_TYPE_1D:
case VK_IMAGE_VIEW_TYPE_2D:
case VK_IMAGE_VIEW_TYPE_3D:
case VK_IMAGE_VIEW_TYPE_CUBE:
return false;
default:
unreachable();
}
}
#ifdef __cplusplus
}
#endif