aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/freedreno/a3xx/fd3_resource.c
diff options
context:
space:
mode:
authorJonathan Marek <[email protected]>2020-07-07 18:27:32 -0400
committerMarge Bot <[email protected]>2020-07-08 20:46:08 +0000
commit979e7e3680792dc23d434295edd10b161af8aee3 (patch)
tree3a04deaed74d2a95215e05c8c8ccb00884e05f1b /src/gallium/drivers/freedreno/a3xx/fd3_resource.c
parent4b290b759a8c85c7d493f1ddd7d38b322bbe1276 (diff)
freedreno/layout: layout simplifications and pitch from level 0 pitch
This updates a3xx/a4xx/a5xx to fix the fetchsize to "PITCHALIGN" (called "MINLINEOFFSET" by the a3xx docs), and some simplifications to make things more like a6xx. Also similar simplifications for a2xx layout code. The pitch can always be determined using a simple calculation from the base level pitch, so don't pre-calculate a pitch for each mipmap level. Signed-off-by: Jonathan Marek <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5796>
Diffstat (limited to 'src/gallium/drivers/freedreno/a3xx/fd3_resource.c')
-rw-r--r--src/gallium/drivers/freedreno/a3xx/fd3_resource.c54
1 files changed, 17 insertions, 37 deletions
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_resource.c b/src/gallium/drivers/freedreno/a3xx/fd3_resource.c
index 49a7e0babec..500b4150c62 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_resource.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_resource.c
@@ -29,42 +29,26 @@ static uint32_t
setup_slices(struct fd_resource *rsc, uint32_t alignment, enum pipe_format format)
{
struct pipe_resource *prsc = &rsc->base;
- struct fd_screen *screen = fd_screen(prsc->screen);
- uint32_t pitchalign = screen->gmem_alignw;
uint32_t level, size = 0;
- uint32_t width = prsc->width0;
- uint32_t height = prsc->height0;
- uint32_t depth = prsc->depth0;
+ uint32_t width0 = prsc->width0;
+
+ if (rsc->layout.tile_mode && prsc->target != PIPE_TEXTURE_CUBE)
+ width0 = util_next_power_of_two(width0);
+
+ /* 32 pixel alignment */
+ fdl_set_pitchalign(&rsc->layout, fdl_cpp_shift(&rsc->layout) + 5);
for (level = 0; level <= prsc->last_level; level++) {
struct fdl_slice *slice = fd_resource_slice(rsc, level);
- uint32_t blocks;
-
+ uint32_t pitch = fdl_pitch(&rsc->layout, level);
+ uint32_t height = u_minify(prsc->height0, level);
if (rsc->layout.tile_mode) {
- if (prsc->target != PIPE_TEXTURE_CUBE) {
- if (level == 0) {
- width = util_next_power_of_two(width);
- height = util_next_power_of_two(height);
- }
- width = MAX2(width, 8);
- height = MAX2(height, 4);
- // Multiplying by 4 is the result of the 4x4 tiling pattern.
- slice->pitch = width * 4;
- blocks = util_format_get_nblocks(format, width, height);
- } else {
- uint32_t twidth, theight;
- twidth = align(width, 8);
- theight = align(height, 4);
- // Multiplying by 4 is the result of the 4x4 tiling pattern.
- slice->pitch = twidth * 4;
- blocks = util_format_get_nblocks(format, twidth, theight);
- }
- } else {
- slice->pitch = width = align(width, pitchalign);
- blocks = util_format_get_nblocks(format, slice->pitch, height);
+ height = align(height, 4);
+ if (prsc->target != PIPE_TEXTURE_CUBE)
+ height = util_next_power_of_two(height);
}
- slice->pitch = util_format_get_nblocksx(format, slice->pitch) *
- rsc->layout.cpp;
+
+ uint32_t nblocksy = util_format_get_nblocksy(format, height);
slice->offset = size;
/* 1d array and 2d array textures must all have the same layer size
@@ -76,17 +60,13 @@ setup_slices(struct fd_resource *rsc, uint32_t alignment, enum pipe_format forma
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);
+ slice->size0 = align(nblocksy * pitch, alignment);
else if (level == 0 || alignment == 1)
- slice->size0 = align(blocks * rsc->layout.cpp, alignment);
+ slice->size0 = align(nblocksy * pitch, alignment);
else
slice->size0 = fd_resource_slice(rsc, level - 1)->size0;
- size += slice->size0 * depth * prsc->array_size;
-
- width = u_minify(width, 1);
- height = u_minify(height, 1);
- depth = u_minify(depth, 1);
+ size += slice->size0 * u_minify(prsc->depth0, level) * prsc->array_size;
}
return size;