1 /*
2 * Copyright © 2022 Collabora Ltd
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23 #ifndef VK_META_PRIVATE_H
24 #define VK_META_PRIVATE_H
25
26 #include "vk_image.h"
27 #include "vk_meta.h"
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 extern const VkPipelineVertexInputStateCreateInfo vk_meta_draw_rects_vi_state;
34 extern const VkPipelineInputAssemblyStateCreateInfo vk_meta_draw_rects_ia_state;
35 extern const VkPipelineViewportStateCreateInfo vk_meta_draw_rects_vs_state;
36
37 struct nir_shader *
38 vk_meta_draw_rects_vs_nir(struct vk_meta_device *device, bool use_gs);
39
40 struct nir_shader *
41 vk_meta_draw_rects_gs_nir(struct vk_meta_device *device);
42
43 static inline void
vk_meta_rendering_info_copy(struct vk_meta_rendering_info * dst,const struct vk_meta_rendering_info * src)44 vk_meta_rendering_info_copy(struct vk_meta_rendering_info *dst,
45 const struct vk_meta_rendering_info *src)
46 {
47 dst->view_mask = src->view_mask;
48 dst->samples = src->samples;
49 dst->color_attachment_count = src->color_attachment_count;
50 for (uint32_t a = 0; a < src->color_attachment_count; a++)
51 dst->color_attachment_formats[a] = src->color_attachment_formats[a];
52 dst->depth_attachment_format = src->depth_attachment_format;
53 dst->stencil_attachment_format = src->stencil_attachment_format;
54 }
55
56 static inline VkImageViewType
vk_image_sampled_view_type(const struct vk_image * image)57 vk_image_sampled_view_type(const struct vk_image *image)
58 {
59 switch (image->image_type) {
60 case VK_IMAGE_TYPE_1D: return VK_IMAGE_VIEW_TYPE_1D_ARRAY;
61 case VK_IMAGE_TYPE_2D: return VK_IMAGE_VIEW_TYPE_2D_ARRAY;
62 case VK_IMAGE_TYPE_3D: return VK_IMAGE_VIEW_TYPE_3D;
63 default: unreachable("Invalid image type");
64 }
65 }
66
67 static inline VkImageViewType
vk_image_render_view_type(const struct vk_image * image,uint32_t layer_count)68 vk_image_render_view_type(const struct vk_image *image, uint32_t layer_count)
69 {
70 switch (image->image_type) {
71 case VK_IMAGE_TYPE_1D:
72 return layer_count == 1 ? VK_IMAGE_VIEW_TYPE_1D :
73 VK_IMAGE_VIEW_TYPE_1D_ARRAY;
74 case VK_IMAGE_TYPE_2D:
75 case VK_IMAGE_TYPE_3D:
76 return layer_count == 1 ? VK_IMAGE_VIEW_TYPE_2D :
77 VK_IMAGE_VIEW_TYPE_2D_ARRAY;
78 default:
79 unreachable("Invalid image type");
80 }
81 }
82
83 #ifdef __cplusplus
84 }
85 #endif
86
87 #endif /* VK_META_PRIVATE_H */
88