freedreno: Extract out shared LRZFC layout helpers
Signed-off-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30304>
This commit is contained in:
64
src/freedreno/common/freedreno_lrz.h
Normal file
64
src/freedreno/common/freedreno_lrz.h
Normal file
@@ -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 <chip CHIP>
|
||||
struct fd_lrzfc_layout;
|
||||
|
||||
template <>
|
||||
struct PACKED fd_lrzfc_layout<A6XX> {
|
||||
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<A7XX> {
|
||||
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
|
@@ -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<CHIP>;
|
||||
using LRZFC = fd_lrzfc_layout<CHIP>;
|
||||
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,
|
||||
|
@@ -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<CHIP>::FC_SIZE &&
|
||||
lrz_fc_size <= fd_lrzfc_layout<CHIP>::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<CHIP>);
|
||||
lrz_size += sizeof(fd_lrzfc_layout<CHIP>);
|
||||
}
|
||||
|
||||
image->total_size += lrz_size;
|
||||
|
@@ -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.
|
||||
*
|
||||
|
@@ -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 <chip CHIP>
|
||||
struct tu_lrzfc_layout;
|
||||
|
||||
template <>
|
||||
struct PACKED tu_lrzfc_layout<A6XX> {
|
||||
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<A7XX> {
|
||||
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 <chip CHIP>
|
||||
void
|
||||
tu6_emit_lrz(struct tu_cmd_buffer *cmd, struct tu_cs *cs);
|
||||
|
Reference in New Issue
Block a user