aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/freedreno
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2019-12-10 14:24:59 -0800
committerRob Clark <[email protected]>2019-12-10 22:55:21 +0000
commit6cf101402df1908c80a3f655d02c9cd3b495c075 (patch)
treea85f0ecb62b4f1073f3d28e779ef697ba00c9117 /src/gallium/drivers/freedreno
parent3b074a2e53186b1c18334a7436df419d5a204887 (diff)
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 <[email protected]>
Diffstat (limited to 'src/gallium/drivers/freedreno')
-rw-r--r--src/gallium/drivers/freedreno/a5xx/fd5_resource.c31
-rw-r--r--src/gallium/drivers/freedreno/a6xx/fd6_resource.c31
-rw-r--r--src/gallium/drivers/freedreno/freedreno_resource.c45
-rw-r--r--src/gallium/drivers/freedreno/freedreno_resource.h8
4 files changed, 70 insertions, 45 deletions
diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_resource.c b/src/gallium/drivers/freedreno/a5xx/fd5_resource.c
index 7e1497630b0..0d356286eb5 100644
--- a/src/gallium/drivers/freedreno/a5xx/fd5_resource.c
+++ b/src/gallium/drivers/freedreno/a5xx/fd5_resource.c
@@ -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;
diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_resource.c b/src/gallium/drivers/freedreno/a6xx/fd6_resource.c
index 430044aebbb..f75ca0666be 100644
--- a/src/gallium/drivers/freedreno/a6xx/fd6_resource.c
+++ b/src/gallium/drivers/freedreno/a6xx/fd6_resource.c
@@ -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;
diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c
index b998bac36eb..c17bd365f1a 100644
--- a/src/gallium/drivers/freedreno/freedreno_resource.c
+++ b/src/gallium/drivers/freedreno/freedreno_resource.c
@@ -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)
diff --git a/src/gallium/drivers/freedreno/freedreno_resource.h b/src/gallium/drivers/freedreno/freedreno_resource.h
index bc972297a35..7a4f9fe2930 100644
--- a/src/gallium/drivers/freedreno/freedreno_resource.h
+++ b/src/gallium/drivers/freedreno/freedreno_resource.h
@@ -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;