1 /* 2 * Copyright © 2016 Red Hat. 3 * Copyright © 2016 Bas Nieuwenhuizen 4 * SPDX-License-Identifier: MIT 5 * 6 * based in part on anv driver which is: 7 * Copyright © 2015 Intel Corporation 8 */ 9 10 #ifndef TU_IMAGE_H 11 #define TU_IMAGE_H 12 13 #include "tu_common.h" 14 15 #define tu_image_view_stencil(iview, x) \ 16 ((iview->view.x & ~A6XX_##x##_COLOR_FORMAT__MASK) | A6XX_##x##_COLOR_FORMAT(FMT6_8_UINT)) 17 18 #define tu_image_view_depth(iview, x) \ 19 ((iview->view.x & ~A6XX_##x##_COLOR_FORMAT__MASK) | A6XX_##x##_COLOR_FORMAT(FMT6_32_FLOAT)) 20 21 struct tu_image 22 { 23 struct vk_image vk; 24 25 struct fdl_layout layout[3]; 26 uint32_t total_size; 27 28 #ifdef ANDROID 29 /* For VK_ANDROID_native_buffer, the WSI image owns the memory, */ 30 VkDeviceMemory owned_memory; 31 #endif 32 33 /* Set when bound */ 34 struct tu_bo *bo; 35 uint64_t iova; 36 37 uint32_t lrz_height; 38 uint32_t lrz_pitch; 39 uint32_t lrz_offset; 40 uint32_t lrz_fc_offset; 41 uint32_t lrz_fc_size; 42 }; 43 VK_DEFINE_NONDISP_HANDLE_CASTS(tu_image, vk.base, VkImage, VK_OBJECT_TYPE_IMAGE) 44 45 struct tu_image_view 46 { 47 struct vk_image_view vk; 48 49 struct tu_image *image; /**< VkImageViewCreateInfo::image */ 50 51 struct fdl6_view view; 52 53 /* for d32s8 separate depth */ 54 uint64_t depth_base_addr; 55 uint32_t depth_layer_size; 56 uint32_t depth_PITCH; 57 58 /* for d32s8 separate stencil */ 59 uint64_t stencil_base_addr; 60 uint32_t stencil_layer_size; 61 uint32_t stencil_PITCH; 62 }; 63 VK_DEFINE_NONDISP_HANDLE_CASTS(tu_image_view, vk.base, VkImageView, 64 VK_OBJECT_TYPE_IMAGE_VIEW); 65 66 struct tu_buffer_view 67 { 68 struct vk_object_base base; 69 70 uint32_t descriptor[A6XX_TEX_CONST_DWORDS]; 71 72 struct tu_buffer *buffer; 73 }; 74 VK_DEFINE_NONDISP_HANDLE_CASTS(tu_buffer_view, base, VkBufferView, 75 VK_OBJECT_TYPE_BUFFER_VIEW) 76 77 uint32_t tu6_plane_count(VkFormat format); 78 enum pipe_format tu6_plane_format(VkFormat format, uint32_t plane); 79 80 uint32_t tu6_plane_index(VkFormat format, VkImageAspectFlags aspect_mask); 81 82 enum pipe_format tu_format_for_aspect(enum pipe_format format, 83 VkImageAspectFlags aspect_mask); 84 85 void 86 tu_cs_image_ref(struct tu_cs *cs, const struct fdl6_view *iview, uint32_t layer); 87 88 void 89 tu_cs_image_ref_2d(struct tu_cs *cs, const struct fdl6_view *iview, uint32_t layer, bool src); 90 91 void 92 tu_cs_image_flag_ref(struct tu_cs *cs, const struct fdl6_view *iview, uint32_t layer); 93 94 void 95 tu_cs_image_stencil_ref(struct tu_cs *cs, const struct tu_image_view *iview, uint32_t layer); 96 97 void 98 tu_cs_image_depth_ref(struct tu_cs *cs, const struct tu_image_view *iview, uint32_t layer); 99 100 bool 101 tiling_possible(VkFormat format); 102 103 bool 104 ubwc_possible(VkFormat format, VkImageType type, VkImageUsageFlags usage, VkImageUsageFlags stencil_usage, 105 const struct fd_dev_info *info, VkSampleCountFlagBits samples, 106 bool use_z24uint_s8uint); 107 108 void 109 tu_buffer_view_init(struct tu_buffer_view *view, 110 struct tu_device *device, 111 const VkBufferViewCreateInfo *pCreateInfo); 112 113 #endif /* TU_IMAGE_H */ 114