[PATCH 1/2] radeon: fix mipmap level 0 and 1 alignment for SI and CIK
Marek Olšák
maraeo at gmail.com
Fri Nov 15 09:55:26 PST 2013
From: Michel Dänzer <michel.daenzer at amd.com>
Signed-off-by: Marek Olšák <marek.olsak at amd.com>
---
radeon/radeon_surface.c | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/radeon/radeon_surface.c b/radeon/radeon_surface.c
index d5c45c4..56e2e4a 100644
--- a/radeon/radeon_surface.c
+++ b/radeon/radeon_surface.c
@@ -1540,6 +1540,7 @@ static int si_surface_init_1d(struct radeon_surface_manager *surf_man,
uint64_t offset, unsigned start_level)
{
uint32_t xalign, yalign, zalign, slice_align;
+ unsigned alignment = MAX2(256, surf_man->hw_info.group_bytes);
unsigned i;
/* compute alignment */
@@ -1551,11 +1552,11 @@ static int si_surface_init_1d(struct radeon_surface_manager *surf_man,
xalign = MAX2((bpe == 1) ? 64 : 32, xalign);
}
- if (!start_level) {
- surf->bo_alignment = MAX2(256, surf_man->hw_info.group_bytes);
+ if (start_level <= 1) {
+ surf->bo_alignment = MAX2(surf->bo_alignment, alignment);
if (offset) {
- offset = ALIGN(offset, surf->bo_alignment);
+ offset = ALIGN(offset, alignment);
}
}
@@ -1566,7 +1567,7 @@ static int si_surface_init_1d(struct radeon_surface_manager *surf_man,
/* level0 and first mipmap need to have alignment */
offset = surf->bo_size;
if ((i == 0)) {
- offset = ALIGN(offset, surf->bo_alignment);
+ offset = ALIGN(offset, alignment);
}
if (surf->flags & RADEON_SURF_HAS_TILE_MODE_INDEX) {
if (surf->level == level) {
@@ -1608,6 +1609,7 @@ static int si_surface_init_2d(struct radeon_surface_manager *surf_man,
uint64_t offset,
unsigned start_level)
{
+ uint64_t aligned_offset = offset;
unsigned tilew, tileh, tileb;
unsigned mtilew, mtileh, mtileb;
unsigned slice_pt;
@@ -1631,19 +1633,19 @@ static int si_surface_init_2d(struct radeon_surface_manager *surf_man,
/* macro tile bytes */
mtileb = (mtilew / tilew) * (mtileh / tileh) * tileb;
- if (!start_level) {
+ if (start_level <= 1) {
unsigned alignment = MAX2(256, mtileb);
surf->bo_alignment = MAX2(surf->bo_alignment, alignment);
- if (offset) {
- offset = ALIGN(offset, alignment);
+ if (aligned_offset) {
+ aligned_offset = ALIGN(aligned_offset, alignment);
}
}
/* build mipmap tree */
for (i = start_level; i <= surf->last_level; i++) {
level[i].mode = RADEON_SURF_MODE_2D;
- si_surf_minify_2d(surf, level+i, bpe, i, slice_pt, mtilew, mtileh, 1, mtileb, offset);
+ si_surf_minify_2d(surf, level+i, bpe, i, slice_pt, mtilew, mtileh, 1, mtileb, aligned_offset);
if (level[i].mode == RADEON_SURF_MODE_1D) {
switch (tile_mode) {
case SI_TILE_MODE_COLOR_2D_8BPP:
@@ -1657,10 +1659,7 @@ static int si_surface_init_2d(struct radeon_surface_manager *surf_man,
tile_mode = SI_TILE_MODE_COLOR_1D_SCANOUT;
break;
case SI_TILE_MODE_DEPTH_STENCIL_2D:
- if (surf_man->family >= CHIP_BONAIRE)
- tile_mode = CIK_TILE_MODE_DEPTH_STENCIL_1D;
- else
- tile_mode = SI_TILE_MODE_DEPTH_STENCIL_1D;
+ tile_mode = SI_TILE_MODE_DEPTH_STENCIL_1D;
break;
default:
return -EINVAL;
@@ -1668,9 +1667,9 @@ static int si_surface_init_2d(struct radeon_surface_manager *surf_man,
return si_surface_init_1d(surf_man, surf, level, bpe, tile_mode, offset, i);
}
/* level0 and first mipmap need to have alignment */
- offset = surf->bo_size;
+ aligned_offset = surf->bo_size;
if ((i == 0)) {
- offset = ALIGN(offset, surf->bo_alignment);
+ aligned_offset = ALIGN(aligned_offset, surf->bo_alignment);
}
if (surf->flags & RADEON_SURF_HAS_TILE_MODE_INDEX) {
if (surf->level == level) {
--
1.8.3.2
More information about the dri-devel
mailing list