diff options
author | Jonathan Marek <[email protected]> | 2020-01-21 17:07:52 -0500 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-06-21 21:11:50 +0000 |
commit | eb6c546493b34f4503132084a881c21868678a92 (patch) | |
tree | 2e2dd793bbcb69c1cb1de01948f73a70718b9322 /src/gallium/drivers/freedreno | |
parent | 6c92a4004ccdb1e2fdaa5929b17c9dc3b400831f (diff) |
freedreno/a4xx: simplify setup_slices
Note: untested
Signed-off-by: Jonathan Marek <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5132>
Diffstat (limited to 'src/gallium/drivers/freedreno')
-rw-r--r-- | src/gallium/drivers/freedreno/a4xx/fd4_resource.c | 90 |
1 files changed, 25 insertions, 65 deletions
diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_resource.c b/src/gallium/drivers/freedreno/a4xx/fd4_resource.c index 04b812ebf43..1640a1acb95 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_resource.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_resource.c @@ -22,17 +22,17 @@ * * Authors: * Rob Clark <[email protected]> + * Jonathan Marek <[email protected]> */ #include "fd4_resource.h" -static uint32_t -setup_slices(struct fd_resource *rsc, uint32_t alignment, enum pipe_format format) +uint32_t +fd4_setup_slices(struct fd_resource *rsc) { struct pipe_resource *prsc = &rsc->base; - struct fd_screen *screen = fd_screen(prsc->screen); + enum pipe_format format = prsc->format; enum util_format_layout layout = util_format_description(format)->layout; - uint32_t pitchalign = screen->gmem_alignw; uint32_t level, size = 0; uint32_t width = prsc->width0; uint32_t height = prsc->height0; @@ -40,33 +40,39 @@ setup_slices(struct fd_resource *rsc, uint32_t alignment, enum pipe_format forma /* in layer_first layout, the level (slice) contains just one * layer (since in fact the layer contains the slices) */ - uint32_t layers_in_level = rsc->layout.layer_first ? 1 : prsc->array_size; + uint32_t layers_in_level, alignment; + + if (prsc->target == PIPE_TEXTURE_3D) { + rsc->layout.layer_first = false; + layers_in_level = prsc->array_size; + alignment = 4096; + } else { + rsc->layout.layer_first = true; + layers_in_level = 1; + alignment = 1; + } for (level = 0; level <= prsc->last_level; level++) { struct fdl_slice *slice = fd_resource_slice(rsc, level); uint32_t blocks; if (layout == UTIL_FORMAT_LAYOUT_ASTC) - width = util_align_npot(width, pitchalign * util_format_get_blockwidth(format)); + width = util_align_npot(width, 32 * util_format_get_blockwidth(format)); else - width = align(width, pitchalign); + width = align(width, 32); slice->pitch = util_format_get_nblocksx(format, width) * rsc->layout.cpp; slice->offset = size; blocks = util_format_get_nblocks(format, width, height); - /* 1d array and 2d array textures must all have the same layer size - * for each miplevel on a3xx. 3d textures can have different layer - * sizes for high levels, but the hw auto-sizer is buggy (or at least - * different than what this code does), so as soon as the layer size - * range gets into range, we stop reducing it. + /* 3d textures can have different layer sizes for high levels, but the + * hw auto-sizer is buggy (or at least different than what this code + * does), so as soon as the layer size range gets into range, we stop + * reducing it. */ - if (prsc->target == PIPE_TEXTURE_3D && ( - level == 1 || - (level > 1 && fd_resource_slice(rsc, level - 1)->size0 > 0xf000))) - slice->size0 = align(blocks * rsc->layout.cpp, alignment); - else if (level == 0 || rsc->layout.layer_first || alignment == 1) - slice->size0 = align(blocks * rsc->layout.cpp, alignment); - else + if (prsc->target == PIPE_TEXTURE_3D && + (level > 1 && fd_resource_slice(rsc, level - 1)->size0 <= 0xf000)) slice->size0 = fd_resource_slice(rsc, level - 1)->size0; + else + slice->size0 = align(blocks * rsc->layout.cpp, alignment); size += slice->size0 * depth * layers_in_level; @@ -77,49 +83,3 @@ setup_slices(struct fd_resource *rsc, uint32_t alignment, enum pipe_format forma return size; } - -static uint32_t -slice_alignment(enum pipe_texture_target target) -{ - /* on a3xx, 2d array and 3d textures seem to want their - * layers aligned to page boundaries: - */ - switch (target) { - case PIPE_TEXTURE_3D: - case PIPE_TEXTURE_1D_ARRAY: - case PIPE_TEXTURE_2D_ARRAY: - return 4096; - default: - return 1; - } -} - -/* cross generation texture layout to plug in to screen->setup_slices().. - * replace with generation specific one as-needed. - * - * TODO for a4xx probably can extract out the a4xx specific logic int - * a small fd4_setup_slices() wrapper that sets up layer_first, and then - * calls this. - */ -uint32_t -fd4_setup_slices(struct fd_resource *rsc) -{ - uint32_t alignment; - - alignment = slice_alignment(rsc->base.target); - - struct fd_screen *screen = fd_screen(rsc->base.screen); - if (is_a4xx(screen)) { - switch (rsc->base.target) { - case PIPE_TEXTURE_3D: - rsc->layout.layer_first = false; - break; - default: - rsc->layout.layer_first = true; - alignment = 1; - break; - } - } - - return setup_slices(rsc, alignment, rsc->base.format); -} |