amd/common: Add total alignment calculation.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Sun, 24 May 2020 12:23:24 +0000 (14:23 +0200)
committerMarge Bot <eric+marge@anholt.net>
Fri, 5 Jun 2020 13:27:55 +0000 (13:27 +0000)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5194>

src/amd/common/ac_surface.c
src/amd/common/ac_surface.h

index 8203a7f04261db157c54205820fc9fe80021dbcd..cbbd86093e790aa372e96970ab039644283bc9a8 100644 (file)
@@ -1871,22 +1871,26 @@ int ac_compute_surface(ADDR_HANDLE addrlib, const struct radeon_info *info,
 
        /* Determine the memory layout of multiple allocations in one buffer. */
        surf->total_size = surf->surf_size;
+       surf->alignment = surf->surf_alignment;
 
        if (surf->htile_size) {
                surf->htile_offset = align64(surf->total_size, surf->htile_alignment);
                surf->total_size = surf->htile_offset + surf->htile_size;
+               surf->alignment = MAX2(surf->alignment, surf->htile_alignment);
        }
 
        if (surf->fmask_size) {
                assert(config->info.samples >= 2);
                surf->fmask_offset = align64(surf->total_size, surf->fmask_alignment);
                surf->total_size = surf->fmask_offset + surf->fmask_size;
+               surf->alignment = MAX2(surf->alignment, surf->fmask_alignment);
        }
 
        /* Single-sample CMASK is in a separate buffer. */
        if (surf->cmask_size && config->info.samples >= 2) {
                surf->cmask_offset = align64(surf->total_size, surf->cmask_alignment);
                surf->total_size = surf->cmask_offset + surf->cmask_size;
+               surf->alignment = MAX2(surf->alignment, surf->cmask_alignment);
        }
 
        if (surf->dcc_size &&
@@ -1918,6 +1922,7 @@ int ac_compute_surface(ADDR_HANDLE addrlib, const struct radeon_info *info,
 
                surf->dcc_offset = align64(surf->total_size, surf->dcc_alignment);
                surf->total_size = surf->dcc_offset + surf->dcc_size;
+               surf->alignment = MAX2(surf->alignment, surf->dcc_alignment);
        }
 
        return 0;
index 161a54c988837e70ff88f744de715006b859e768..22858206e462e73bc0b677a78a7a361368df4f52 100644 (file)
@@ -247,6 +247,7 @@ struct radeon_surf {
     uint64_t                    display_dcc_offset;
     uint64_t                    dcc_retile_map_offset;
     uint64_t                    total_size;
+    uint32_t                    alignment;
 
     union {
         /* Return values for GFX8 and older.