From 24378086710bae7eb7b6d0cb4ec0e718d36ba32c Mon Sep 17 00:00:00 2001 From: Jonathan Marek Date: Tue, 7 Apr 2020 21:12:45 -0400 Subject: turnip: image_view rework Instead of exposing various layout functions, move image-related logic into tu_image.c and have the image_view pre-fill relevant register values. This changes the clear/blit code to use image_view. This will make it much easier to deal with aspect masks, in particular for planar formats and D32_S8. Signed-off-by: Jonathan Marek Part-of: --- src/freedreno/vulkan/tu_private.h | 135 ++++++++++---------------------------- 1 file changed, 33 insertions(+), 102 deletions(-) (limited to 'src/freedreno/vulkan/tu_private.h') diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h index 1c081a2ddda..4953075375f 100644 --- a/src/freedreno/vulkan/tu_private.h +++ b/src/freedreno/vulkan/tu_private.h @@ -1433,116 +1433,25 @@ tu_get_levelCount(const struct tu_image *image, : range->levelCount; } -static inline VkDeviceSize -tu_layer_size(struct tu_image *image, int level) -{ - return fdl_layer_stride(&image->layout, level); -} - -static inline uint32_t -tu_image_stride(struct tu_image *image, int level) -{ - return image->layout.slices[level].pitch * image->layout.cpp; -} - -/* to get the right pitch for compressed formats */ -static inline uint32_t -tu_image_pitch(struct tu_image *image, int level) -{ - uint32_t stride = tu_image_stride(image, level); - return stride / vk_format_get_blockwidth(image->vk_format); -} - -static inline uint64_t -tu_image_base(struct tu_image *image, int level, int layer) -{ - return image->bo->iova + image->bo_offset + - fdl_surface_offset(&image->layout, level, layer); -} - -#define tu_image_base_ref(image, level, layer) \ - .bo = image->bo, \ - .bo_offset = (image->bo_offset + fdl_surface_offset(&image->layout, \ - level, layer)) - -#define tu_image_view_base_ref(iview) \ - tu_image_base_ref(iview->image, iview->base_mip, iview->base_layer) - -static inline VkDeviceSize -tu_image_ubwc_size(struct tu_image *image, int level) -{ - return image->layout.ubwc_layer_size; -} - -static inline uint32_t -tu_image_ubwc_pitch(struct tu_image *image, int level) -{ - return image->layout.ubwc_slices[level].pitch; -} - -static inline uint64_t -tu_image_ubwc_surface_offset(struct tu_image *image, int level, int layer) -{ - return image->layout.ubwc_slices[level].offset + - layer * tu_image_ubwc_size(image, level); -} - -static inline uint64_t -tu_image_ubwc_base(struct tu_image *image, int level, int layer) -{ - return image->bo->iova + image->bo_offset + - tu_image_ubwc_surface_offset(image, level, layer); -} - -#define tu_image_ubwc_base_ref(image, level, layer) \ - .bo = image->bo, \ - .bo_offset = (image->bo_offset + tu_image_ubwc_surface_offset(image, \ - level, layer)) - -#define tu_image_view_ubwc_base_ref(iview) \ - tu_image_ubwc_base_ref(iview->image, iview->base_mip, iview->base_layer) - -#define tu_image_view_ubwc_pitches(iview) \ - .pitch = tu_image_ubwc_pitch(iview->image, iview->base_mip), \ - .array_pitch = tu_image_ubwc_size(iview->image, iview->base_mip) >> 2 - -enum a6xx_tile_mode -tu6_get_image_tile_mode(struct tu_image *image, int level); enum a3xx_msaa_samples tu_msaa_samples(uint32_t samples); enum a6xx_tex_fetchsize tu6_fetchsize(VkFormat format); -static inline struct tu_native_format -tu6_format_image(struct tu_image *image, VkFormat format, uint32_t level) -{ - struct tu_native_format fmt = - tu6_format_color(format, image->layout.tile_mode); - fmt.tile_mode = tu6_get_image_tile_mode(image, level); - return fmt; -} - -static inline struct tu_native_format -tu6_format_image_src(struct tu_image *image, VkFormat format, uint32_t level) -{ - struct tu_native_format fmt = - tu6_format_texture(format, image->layout.tile_mode); - fmt.tile_mode = tu6_get_image_tile_mode(image, level); - return fmt; -} - struct tu_image_view { struct tu_image *image; /**< VkImageViewCreateInfo::image */ - VkImageViewType type; - VkImageAspectFlags aspect_mask; - VkFormat vk_format; - uint32_t base_layer; - uint32_t layer_count; - uint32_t base_mip; - uint32_t level_count; - VkExtent3D extent; /**< Extent of VkImageViewCreateInfo::baseMipLevel. */ + uint64_t base_addr; + uint64_t ubwc_addr; + uint32_t layer_size; + uint32_t ubwc_layer_size; + + /* used to determine if fast gmem store path can be used */ + VkExtent2D extent; + bool need_y2_align; + + bool ubwc_enabled; uint32_t descriptor[A6XX_TEX_CONST_DWORDS]; @@ -1550,12 +1459,35 @@ struct tu_image_view * This has a few differences for cube maps (e.g. type). */ uint32_t storage_descriptor[A6XX_TEX_CONST_DWORDS]; + + /* pre-filled register values */ + uint32_t PITCH; + uint32_t FLAG_BUFFER_PITCH; + + uint32_t RB_MRT_BUF_INFO; + uint32_t SP_FS_MRT_REG; + + uint32_t SP_PS_2D_SRC_INFO; + uint32_t SP_PS_2D_SRC_SIZE; + + uint32_t RB_2D_DST_INFO; + + uint32_t RB_BLIT_DST_INFO; }; struct tu_sampler { uint32_t descriptor[A6XX_TEX_SAMP_DWORDS]; }; +void +tu_cs_image_ref(struct tu_cs *cs, const struct tu_image_view *iview, uint32_t layer); + +void +tu_cs_image_ref_2d(struct tu_cs *cs, const struct tu_image_view *iview, uint32_t layer, bool src); + +void +tu_cs_image_flag_ref(struct tu_cs *cs, const struct tu_image_view *iview, uint32_t layer); + VkResult tu_image_create(VkDevice _device, const VkImageCreateInfo *pCreateInfo, @@ -1572,7 +1504,6 @@ tu_image_from_gralloc(VkDevice device_h, void tu_image_view_init(struct tu_image_view *view, - struct tu_device *device, const VkImageViewCreateInfo *pCreateInfo); struct tu_buffer_view -- cgit v1.2.3