From: Rob Clark Date: Thu, 4 Dec 2014 21:56:33 +0000 (-0500) Subject: freedreno: cleanup slice alignment/setup X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5d7c9c9160e0d425df220e5e1898d0ab7dee2c83;p=mesa.git freedreno: cleanup slice alignment/setup Collapse things back into a setup_slices() which takes the desired alignment as a param. This gets things ready for a4xx which has some slightly different requirements. Signed-off-by: Rob Clark --- diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index 6b31d263290..461e378c89e 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -188,7 +188,7 @@ static const struct u_resource_vtbl fd_resource_vtbl = { }; static uint32_t -setup_slices(struct fd_resource *rsc) +setup_slices(struct fd_resource *rsc, uint32_t alignment) { struct pipe_resource *prsc = &rsc->base.b; uint32_t level, size = 0; @@ -201,7 +201,7 @@ setup_slices(struct fd_resource *rsc) slice->pitch = align(width, 32); slice->offset = size; - slice->size0 = slice->pitch * height * rsc->cpp; + slice->size0 = align(slice->pitch * height * rsc->cpp, alignment); size += slice->size0 * depth * prsc->array_size; @@ -213,33 +213,20 @@ setup_slices(struct fd_resource *rsc) return size; } -/* 2d array and 3d textures seem to want their layers aligned to - * page boundaries - */ static uint32_t -setup_slices_array(struct fd_resource *rsc) +slice_alignment(struct pipe_screen *pscreen, const struct pipe_resource *tmpl) { - struct pipe_resource *prsc = &rsc->base.b; - uint32_t level, size = 0; - uint32_t width = prsc->width0; - uint32_t height = prsc->height0; - uint32_t depth = prsc->depth0; - - for (level = 0; level <= prsc->last_level; level++) { - struct fd_resource_slice *slice = fd_resource_slice(rsc, level); - - slice->pitch = align(width, 32); - slice->offset = size; - slice->size0 = align(slice->pitch * height * rsc->cpp, 4096); - - size += slice->size0 * depth * prsc->array_size; - - width = u_minify(width, 1); - height = u_minify(height, 1); - depth = u_minify(depth, 1); + /* on a3xx, 2d array and 3d textures seem to want their + * layers aligned to page boundaries: + */ + switch (tmpl->target) { + case PIPE_TEXTURE_3D: + case PIPE_TEXTURE_1D_ARRAY: + case PIPE_TEXTURE_2D_ARRAY: + return 4096; + default: + return 1; } - - return size; } /** @@ -273,16 +260,7 @@ fd_resource_create(struct pipe_screen *pscreen, assert(rsc->cpp); - switch (tmpl->target) { - case PIPE_TEXTURE_3D: - case PIPE_TEXTURE_1D_ARRAY: - case PIPE_TEXTURE_2D_ARRAY: - size = setup_slices_array(rsc); - break; - default: - size = setup_slices(rsc); - break; - } + size = setup_slices(rsc, slice_alignment(pscreen, tmpl)); realloc_bo(rsc, size); if (!rsc->bo)