From 679e9093e13e72631e242f0c385da5253be4543f Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Tue, 23 Jul 2024 12:49:04 -0700 Subject: [PATCH] freedreno: Extract out shared LRZFC layout helpers Signed-off-by: Rob Clark Part-of: --- src/freedreno/common/freedreno_lrz.h | 64 +++++++++++++++++++++++++++ src/freedreno/vulkan/tu_clear_blit.cc | 3 +- src/freedreno/vulkan/tu_image.cc | 5 ++- src/freedreno/vulkan/tu_lrz.cc | 1 + src/freedreno/vulkan/tu_lrz.h | 53 ---------------------- 5 files changed, 70 insertions(+), 56 deletions(-) create mode 100644 src/freedreno/common/freedreno_lrz.h diff --git a/src/freedreno/common/freedreno_lrz.h b/src/freedreno/common/freedreno_lrz.h new file mode 100644 index 00000000000..fcb08b4d12e --- /dev/null +++ b/src/freedreno/common/freedreno_lrz.h @@ -0,0 +1,64 @@ +/* + * Copyright © 2024 Igalia S.L. + * SPDX-License-Identifier: MIT + */ + +#ifndef __FREEDRENO_LRZ_H__ +#define __FREEDRENO_LRZ_H__ + +#include "adreno_common.xml.h" + +/* Layout of LRZ fast-clear buffer templated on the generation, the + * members are as follows: + * - fc1: The first FC buffer, always present. This may contain multiple + * sub-buffers with _a/_b suffixes for concurrent binning which + * can be checked using HAS_CB. + * - fc2: The second FC buffer, used for bidirectional LRZ and only present + * when HAS_BIDIR set. It has suffixes for CB like fc1. + * - metadata: Metadata buffer for LRZ fast-clear. The contents are not + * always known, since they're handled by the hardware. + */ +template +struct fd_lrzfc_layout; + +template <> +struct PACKED fd_lrzfc_layout { + static const bool HAS_BIDIR = false; + static const bool HAS_CB = false; + static const size_t FC_SIZE = 512; + + uint8_t fc1[FC_SIZE]; + union { + struct { + uint8_t dir_track; + uint8_t _pad_; + uint32_t gras_lrz_depth_view; + }; + uint8_t metadata[6]; + }; +}; + +template <> +struct PACKED fd_lrzfc_layout { + static const bool HAS_BIDIR = true; + static const bool HAS_CB = true; + static const size_t FC_SIZE = 1024; + + union { + struct { + uint8_t fc1_a[FC_SIZE]; + uint8_t fc1_b[FC_SIZE]; + }; + uint8_t fc1[FC_SIZE * 2]; + }; + uint8_t metadata[512]; + union { + struct { + uint8_t fc2_a[FC_SIZE]; + uint8_t fc2_b[FC_SIZE]; + }; + uint8_t fc2[FC_SIZE * 2]; + }; +}; + +#endif diff --git a/src/freedreno/vulkan/tu_clear_blit.cc b/src/freedreno/vulkan/tu_clear_blit.cc index 0541566778f..248e86647ac 100644 --- a/src/freedreno/vulkan/tu_clear_blit.cc +++ b/src/freedreno/vulkan/tu_clear_blit.cc @@ -25,6 +25,7 @@ #include "tu_lrz.h" #include "common/freedreno_gpu_event.h" +#include "common/freedreno_lrz.h" static const VkOffset2D blt_no_coord = { ~0, ~0 }; @@ -1833,7 +1834,7 @@ tu6_dirty_lrz_fc(struct tu_cmd_buffer *cmd, VkClearValue clear = {}; clear.color.uint32[0] = 0xffffffff; - using LRZFC = tu_lrzfc_layout; + using LRZFC = fd_lrzfc_layout; uint64_t lrz_fc_iova = image->iova + image->lrz_fc_offset; ops->setup(cmd, cs, PIPE_FORMAT_R32_UINT, PIPE_FORMAT_R32_UINT, VK_IMAGE_ASPECT_COLOR_BIT, 0, true, false, diff --git a/src/freedreno/vulkan/tu_image.cc b/src/freedreno/vulkan/tu_image.cc index 74315ebe704..8448020047d 100644 --- a/src/freedreno/vulkan/tu_image.cc +++ b/src/freedreno/vulkan/tu_image.cc @@ -10,6 +10,7 @@ #include "tu_image.h" #include "fdl/fd6_format_table.h" +#include "common/freedreno_lrz.h" #include "util/u_debug.h" #include "util/format/u_format.h" @@ -594,12 +595,12 @@ tu_image_update_layout(struct tu_device *device, struct tu_image *image, /* Fast-clear buffer cannot be larger than 512 bytes on A6XX and 1024 bytes on A7XX (HW limitation) */ image->has_lrz_fc = device->physical_device->info->a6xx.enable_lrz_fast_clear && - lrz_fc_size <= tu_lrzfc_layout::FC_SIZE && + lrz_fc_size <= fd_lrzfc_layout::FC_SIZE && !TU_DEBUG(NOLRZFC); if (image->has_lrz_fc || device->physical_device->info->a6xx.has_lrz_dir_tracking) { image->lrz_fc_offset = image->total_size + lrz_size; - lrz_size += sizeof(tu_lrzfc_layout); + lrz_size += sizeof(fd_lrzfc_layout); } image->total_size += lrz_size; diff --git a/src/freedreno/vulkan/tu_lrz.cc b/src/freedreno/vulkan/tu_lrz.cc index 17b2e1de454..ab7689ae700 100644 --- a/src/freedreno/vulkan/tu_lrz.cc +++ b/src/freedreno/vulkan/tu_lrz.cc @@ -11,6 +11,7 @@ #include "tu_image.h" #include "common/freedreno_gpu_event.h" +#include "common/freedreno_lrz.h" /* See lrz.rst for how HW works. Here are only the implementation notes. * diff --git a/src/freedreno/vulkan/tu_lrz.h b/src/freedreno/vulkan/tu_lrz.h index 4132c9c05e8..002ca4a4a04 100644 --- a/src/freedreno/vulkan/tu_lrz.h +++ b/src/freedreno/vulkan/tu_lrz.h @@ -42,59 +42,6 @@ struct tu_lrz_state enum tu_lrz_direction prev_direction; }; -/* Layout of LRZ fast-clear buffer templated on the generation, the - * members are as follows: - * - fc1: The first FC buffer, always present. This may contain multiple - * sub-buffers with _a/_b suffixes for concurrent binning which - * can be checked using HAS_CB. - * - fc2: The second FC buffer, used for bidirectional LRZ and only present - * when HAS_BIDIR set. It has suffixes for CB like fc1. - * - metadata: Metadata buffer for LRZ fast-clear. The contents are not - * always known, since they're handled by the hardware. - */ -template -struct tu_lrzfc_layout; - -template <> -struct PACKED tu_lrzfc_layout { - static const bool HAS_BIDIR = false; - static const bool HAS_CB = false; - static const size_t FC_SIZE = 512; - - uint8_t fc1[FC_SIZE]; - union { - struct { - uint8_t dir_track; - uint8_t _pad_; - uint32_t gras_lrz_depth_view; - }; - uint8_t metadata[6]; - }; -}; - -template <> -struct PACKED tu_lrzfc_layout { - static const bool HAS_BIDIR = true; - static const bool HAS_CB = true; - static const size_t FC_SIZE = 1024; - - union { - struct { - uint8_t fc1_a[FC_SIZE]; - uint8_t fc1_b[FC_SIZE]; - }; - uint8_t fc1[FC_SIZE * 2]; - }; - uint8_t metadata[512]; - union { - struct { - uint8_t fc2_a[FC_SIZE]; - uint8_t fc2_b[FC_SIZE]; - }; - uint8_t fc2[FC_SIZE * 2]; - }; -}; - template void tu6_emit_lrz(struct tu_cmd_buffer *cmd, struct tu_cs *cs);