diff options
author | Rob Clark <[email protected]> | 2014-12-04 16:56:33 -0500 |
---|---|---|
committer | Rob Clark <[email protected]> | 2014-12-09 18:01:21 -0500 |
commit | 5d7c9c9160e0d425df220e5e1898d0ab7dee2c83 (patch) | |
tree | c0d46c7a97849181363e07054caa535c6a8de308 /src/gallium/drivers | |
parent | 8ecbcbf0aab60e044dc4a9dabef2bdfb8db5abe9 (diff) |
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 <[email protected]>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/freedreno/freedreno_resource.c | 50 |
1 files changed, 14 insertions, 36 deletions
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) |