Seems to be a bit different for a6xx, so let's split this out.
Signed-off-by: Rob Clark <robdclark@chromium.org>
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;
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;
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)
{
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)
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;