mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-27 19:10:14 +01:00
freedreno/a5xx+a6xx: split LRZ layout to per-gen
Seems to be a bit different for a6xx, so let's split this out. Signed-off-by: Rob Clark <robdclark@chromium.org>
This commit is contained in:
parent
3b074a2e53
commit
6cf101402d
4 changed files with 70 additions and 45 deletions
|
|
@ -127,11 +127,42 @@ setup_slices(struct fd_resource *rsc, uint32_t alignment, enum pipe_format forma
|
|||
return size;
|
||||
}
|
||||
|
||||
static void
|
||||
setup_lrz(struct fd_resource *rsc)
|
||||
{
|
||||
struct fd_screen *screen = fd_screen(rsc->base.screen);
|
||||
const uint32_t flags = DRM_FREEDRENO_GEM_CACHE_WCOMBINE |
|
||||
DRM_FREEDRENO_GEM_TYPE_KMEM; /* TODO */
|
||||
unsigned lrz_pitch = align(DIV_ROUND_UP(rsc->base.width0, 8), 64);
|
||||
unsigned lrz_height = DIV_ROUND_UP(rsc->base.height0, 8);
|
||||
|
||||
/* LRZ buffer is super-sampled: */
|
||||
switch (rsc->base.nr_samples) {
|
||||
case 4:
|
||||
lrz_pitch *= 2;
|
||||
/* fallthrough */
|
||||
case 2:
|
||||
lrz_height *= 2;
|
||||
}
|
||||
|
||||
unsigned size = lrz_pitch * lrz_height * 2;
|
||||
|
||||
size += 0x1000; /* for GRAS_LRZ_FAST_CLEAR_BUFFER */
|
||||
|
||||
rsc->lrz_height = lrz_height;
|
||||
rsc->lrz_width = lrz_pitch;
|
||||
rsc->lrz_pitch = lrz_pitch;
|
||||
rsc->lrz = fd_bo_new(screen->dev, size, flags, "lrz");
|
||||
}
|
||||
|
||||
uint32_t
|
||||
fd5_setup_slices(struct fd_resource *rsc)
|
||||
{
|
||||
uint32_t alignment;
|
||||
|
||||
if ((fd_mesa_debug & FD_DBG_LRZ) && has_depth(rsc->base.format))
|
||||
setup_lrz(rsc);
|
||||
|
||||
switch (rsc->base.target) {
|
||||
case PIPE_TEXTURE_3D:
|
||||
rsc->layout.layer_first = false;
|
||||
|
|
|
|||
|
|
@ -289,11 +289,42 @@ fd6_validate_format(struct fd_context *ctx, struct fd_resource *rsc,
|
|||
fd_resource_uncompress(ctx, rsc);
|
||||
}
|
||||
|
||||
static void
|
||||
setup_lrz(struct fd_resource *rsc)
|
||||
{
|
||||
struct fd_screen *screen = fd_screen(rsc->base.screen);
|
||||
const uint32_t flags = DRM_FREEDRENO_GEM_CACHE_WCOMBINE |
|
||||
DRM_FREEDRENO_GEM_TYPE_KMEM; /* TODO */
|
||||
unsigned lrz_pitch = align(DIV_ROUND_UP(rsc->base.width0, 8), 64);
|
||||
unsigned lrz_height = DIV_ROUND_UP(rsc->base.height0, 8);
|
||||
|
||||
/* LRZ buffer is super-sampled: */
|
||||
switch (rsc->base.nr_samples) {
|
||||
case 4:
|
||||
lrz_pitch *= 2;
|
||||
/* fallthrough */
|
||||
case 2:
|
||||
lrz_height *= 2;
|
||||
}
|
||||
|
||||
unsigned size = lrz_pitch * lrz_height * 2;
|
||||
|
||||
size += 0x1000; /* for GRAS_LRZ_FAST_CLEAR_BUFFER */
|
||||
|
||||
rsc->lrz_height = lrz_height;
|
||||
rsc->lrz_width = lrz_pitch;
|
||||
rsc->lrz_pitch = lrz_pitch;
|
||||
rsc->lrz = fd_bo_new(screen->dev, size, flags, "lrz");
|
||||
}
|
||||
|
||||
uint32_t
|
||||
fd6_setup_slices(struct fd_resource *rsc)
|
||||
{
|
||||
uint32_t alignment;
|
||||
|
||||
if ((fd_mesa_debug & FD_DBG_LRZ) && has_depth(rsc->base.format))
|
||||
setup_lrz(rsc);
|
||||
|
||||
switch (rsc->base.target) {
|
||||
case PIPE_TEXTURE_3D:
|
||||
rsc->layout.layer_first = false;
|
||||
|
|
|
|||
|
|
@ -877,25 +877,6 @@ fd_resource_resize(struct pipe_resource *prsc, uint32_t sz)
|
|||
realloc_bo(rsc, fd_screen(prsc->screen)->setup_slices(rsc));
|
||||
}
|
||||
|
||||
// TODO common helper?
|
||||
static bool
|
||||
has_depth(enum pipe_format format)
|
||||
{
|
||||
switch (format) {
|
||||
case PIPE_FORMAT_Z16_UNORM:
|
||||
case PIPE_FORMAT_Z32_UNORM:
|
||||
case PIPE_FORMAT_Z32_FLOAT:
|
||||
case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
|
||||
case PIPE_FORMAT_Z24_UNORM_S8_UINT:
|
||||
case PIPE_FORMAT_S8_UINT_Z24_UNORM:
|
||||
case PIPE_FORMAT_Z24X8_UNORM:
|
||||
case PIPE_FORMAT_X8Z24_UNORM:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
fd_resource_layout_init(struct pipe_resource *prsc)
|
||||
{
|
||||
|
|
@ -1009,32 +990,6 @@ fd_resource_create_with_modifiers(struct pipe_screen *pscreen,
|
|||
|
||||
rsc->internal_format = format;
|
||||
|
||||
// XXX probably need some extra work if we hit rsc shadowing path w/ lrz..
|
||||
if ((is_a5xx(screen) || is_a6xx(screen)) &&
|
||||
(fd_mesa_debug & FD_DBG_LRZ) && has_depth(format)) {
|
||||
const uint32_t flags = DRM_FREEDRENO_GEM_CACHE_WCOMBINE |
|
||||
DRM_FREEDRENO_GEM_TYPE_KMEM; /* TODO */
|
||||
unsigned lrz_pitch = align(DIV_ROUND_UP(tmpl->width0, 8), 64);
|
||||
unsigned lrz_height = DIV_ROUND_UP(tmpl->height0, 8);
|
||||
|
||||
/* LRZ buffer is super-sampled: */
|
||||
switch (prsc->nr_samples) {
|
||||
case 4:
|
||||
lrz_pitch *= 2;
|
||||
case 2:
|
||||
lrz_height *= 2;
|
||||
}
|
||||
|
||||
unsigned size = lrz_pitch * lrz_height * 2;
|
||||
|
||||
size += 0x1000; /* for GRAS_LRZ_FAST_CLEAR_BUFFER */
|
||||
|
||||
rsc->lrz_height = lrz_height;
|
||||
rsc->lrz_width = lrz_pitch;
|
||||
rsc->lrz_pitch = lrz_pitch;
|
||||
rsc->lrz = fd_bo_new(screen->dev, size, flags, "lrz");
|
||||
}
|
||||
|
||||
size = screen->setup_slices(rsc);
|
||||
|
||||
if (allow_ubwc && screen->fill_ubwc_buffer_sizes && rsc->layout.tile_mode)
|
||||
|
|
|
|||
|
|
@ -113,6 +113,14 @@ pending(struct fd_resource *rsc, bool write)
|
|||
return false;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
has_depth(enum pipe_format format)
|
||||
{
|
||||
const struct util_format_description *desc =
|
||||
util_format_description(format);
|
||||
return util_format_has_depth(desc);
|
||||
}
|
||||
|
||||
struct fd_transfer {
|
||||
struct pipe_transfer base;
|
||||
struct pipe_resource *staging_prsc;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue