xref: /aosp_15_r20/external/mesa3d/src/amd/vulkan/radv_image_view.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright © 2016 Red Hat.
3  * Copyright © 2016 Bas Nieuwenhuizen
4  *
5  * based in part on anv driver which is:
6  * Copyright © 2015 Intel Corporation
7  *
8  * SPDX-License-Identifier: MIT
9  */
10 
11 #ifndef RADV_IMAGE_VIEW_H
12 #define RADV_IMAGE_VIEW_H
13 
14 #include "ac_surface.h"
15 
16 #include "radv_image.h"
17 
18 union radv_descriptor {
19    struct {
20       uint32_t plane0_descriptor[8];
21       uint32_t fmask_descriptor[8];
22    };
23    struct {
24       uint32_t plane_descriptors[3][8];
25    };
26 };
27 
28 struct radv_image_view {
29    struct vk_image_view vk;
30    struct radv_image *image; /**< VkImageViewCreateInfo::image */
31 
32    unsigned plane_id;
33    VkExtent3D extent; /**< Extent of VkImageViewCreateInfo::baseMipLevel. */
34 
35    /* Whether the image iview supports fast clear. */
36    bool support_fast_clear;
37 
38    bool disable_dcc_mrt;
39 
40    union radv_descriptor descriptor;
41 
42    /* Descriptor for use as a storage image as opposed to a sampled image.
43     * This has a few differences for cube maps (e.g. type).
44     */
45    union radv_descriptor storage_descriptor;
46 
47    /* Block-compressed image views on GFX10+. */
48    struct ac_surf_nbc_view nbc_view;
49 };
50 
51 VK_DEFINE_NONDISP_HANDLE_CASTS(radv_image_view, vk.base, VkImageView, VK_OBJECT_TYPE_IMAGE_VIEW);
52 
53 struct radv_image_view_extra_create_info {
54    bool disable_compression;
55    bool enable_compression;
56    bool disable_dcc_mrt;
57    bool from_client; /**< Set only if this came from vkCreateImage */
58 };
59 
60 void radv_image_view_init(struct radv_image_view *view, struct radv_device *device,
61                           const VkImageViewCreateInfo *pCreateInfo, VkImageCreateFlags img_create_flags,
62                           const struct radv_image_view_extra_create_info *extra_create_info);
63 void radv_image_view_finish(struct radv_image_view *iview);
64 
65 void radv_set_mutable_tex_desc_fields(struct radv_device *device, struct radv_image *image,
66                                       const struct legacy_surf_level *base_level_info, unsigned plane_id,
67                                       unsigned base_level, unsigned first_level, unsigned block_width, bool is_stencil,
68                                       bool is_storage_image, bool disable_compression, bool enable_write_compression,
69                                       uint32_t *state, const struct ac_surf_nbc_view *nbc_view);
70 
71 void radv_make_texture_descriptor(struct radv_device *device, struct radv_image *image, bool is_storage_image,
72                                   VkImageViewType view_type, VkFormat vk_format, const VkComponentMapping *mapping,
73                                   unsigned first_level, unsigned last_level, unsigned first_layer, unsigned last_layer,
74                                   unsigned width, unsigned height, unsigned depth, float min_lod, uint32_t *state,
75                                   uint32_t *fmask_state, VkImageCreateFlags img_create_flags,
76                                   const struct ac_surf_nbc_view *nbc_view,
77                                   const VkImageViewSlicedCreateInfoEXT *sliced_3d);
78 
79 #endif /* RADV_IMAGE_VIEW_H */
80