Debian Codegraph @

src/panfrost/vulkan/panvk_image_view.h

raw
1 /*
2 * Copyright © 2021 Collabora Ltd.
3 * SPDX-License-Identifier: MIT
4 */
5
6 #ifndef PANVK_IMAGE_VIEW_H
7 #define PANVK_IMAGE_VIEW_H
8
9 #ifndef PAN_ARCH
10 #error "PAN_ARCH must be defined"
11 #endif
12
13 #include <stdint.h>
14
15 #include "vk_image.h"
16
17 #include "pan_texture.h"
18
19 #include "genxml/gen_macros.h"
20 #include "panvk_image.h"
21
22 struct panvk_priv_bo;
23
24 struct panvk_image_view {
25 struct vk_image_view vk;
26
27 struct pan_image_view pview;
28
29 struct panvk_priv_mem mem;
30
31 struct {
32 union {
33 struct mali_texture_packed tex[PANVK_MAX_PLANES];
34 struct {
35 struct mali_texture_packed tex;
36 struct mali_texture_packed other_aspect_tex;
37 } zs;
38 };
39 #if PAN_ARCH >= 9
40 /* Valhall passes a limited texture descriptor to the LEA_TEX instruction */
41 struct mali_texture_packed storage_tex[PANVK_MAX_PLANES];
42 #else
43 struct mali_attribute_buffer_packed img_attrib_buf[2];
44 #endif
45 } descs;
46
47 /* One image each for 2x 4x 8x 16x. We don't support more than 16x. */
48 VkImageView ms_views[4];
49 };
50
51 VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_image_view, vk.base, VkImageView,
52 VK_OBJECT_TYPE_IMAGE_VIEW);
53
54 static inline uint32_t
55 panvk_image_view_plane_index(struct panvk_image_view *view)
56 {
57 struct panvk_image *image =
58 container_of(view->vk.image, struct panvk_image, vk);
59
60 if (vk_format_is_depth_or_stencil(view->vk.image->format) &&
61 view->vk.aspects == VK_IMAGE_ASPECT_COLOR_BIT) {
62 /* Color views of ZS is needed for meta copies. 1 byte format is always
63 * stencil, and if it's not the stencil component the caller wants, it
64 * has to be the depth.
65 */
66 if (vk_format_get_blocksize(view->vk.view_format) == 1)
67 return panvk_plane_index(image, VK_IMAGE_ASPECT_STENCIL_BIT);
68 else
69 return panvk_plane_index(image, VK_IMAGE_ASPECT_DEPTH_BIT);
70 } else {
71 return panvk_plane_index(image, view->vk.aspects);
72 }
73 }
74
75 static_assert(offsetof(struct panvk_image_view, descs.zs.tex) ==
76 offsetof(struct panvk_image_view, descs.tex),
77 "ZS texture descriptor must alias with color texture descriptor");
78
79 #endif