diff options
author | Marek Olšák <[email protected]> | 2018-06-21 22:54:59 -0400 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2018-06-25 18:33:58 -0400 |
commit | 166250f4e5486e1e44ed97a8ab2ee0691e41cfa1 (patch) | |
tree | 9e3688cc2c5c468a563594a7d8f7e1897fb67c3f /src/amd | |
parent | 3da693b7d98782437c25b1f6c2d0efb3a398246b (diff) |
radeonsi: move CMASK size computation into ac_surface
Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/amd')
-rw-r--r-- | src/amd/common/ac_surface.c | 61 | ||||
-rw-r--r-- | src/amd/common/ac_surface.h | 5 |
2 files changed, 66 insertions, 0 deletions
diff --git a/src/amd/common/ac_surface.c b/src/amd/common/ac_surface.c index f5f88c1e791..9eb63bab038 100644 --- a/src/amd/common/ac_surface.c +++ b/src/amd/common/ac_surface.c @@ -547,6 +547,66 @@ static int gfx6_surface_settings(ADDR_HANDLE addrlib, return 0; } +void ac_compute_cmask(const struct radeon_info *info, + const struct ac_surf_config *config, + struct radeon_surf *surf) +{ + unsigned pipe_interleave_bytes = info->pipe_interleave_bytes; + unsigned num_pipes = info->num_tile_pipes; + unsigned cl_width, cl_height; + + if (surf->flags & RADEON_SURF_Z_OR_SBUFFER) + return; + + assert(info->chip_class <= VI); + + switch (num_pipes) { + case 2: + cl_width = 32; + cl_height = 16; + break; + case 4: + cl_width = 32; + cl_height = 32; + break; + case 8: + cl_width = 64; + cl_height = 32; + break; + case 16: /* Hawaii */ + cl_width = 64; + cl_height = 64; + break; + default: + assert(0); + return; + } + + unsigned base_align = num_pipes * pipe_interleave_bytes; + + unsigned width = align(config->info.width, cl_width*8); + unsigned height = align(config->info.height, cl_height*8); + unsigned slice_elements = (width * height) / (8*8); + + /* Each element of CMASK is a nibble. */ + unsigned slice_bytes = slice_elements / 2; + + surf->u.legacy.cmask_slice_tile_max = (width * height) / (128*128); + if (surf->u.legacy.cmask_slice_tile_max) + surf->u.legacy.cmask_slice_tile_max -= 1; + + unsigned num_layers; + if (config->is_3d) + num_layers = config->info.depth; + else if (config->is_cube) + num_layers = 6; + else + num_layers = config->info.array_size; + + surf->cmask_alignment = MAX2(256, base_align); + surf->cmask_size = align(slice_bytes, base_align) * num_layers; +} + /** * Fill in the tiling information in \p surf based on the given surface config. * @@ -962,6 +1022,7 @@ static int gfx6_compute_surface(ADDR_HANDLE addrlib, return ADDR_ERROR; } + ac_compute_cmask(info, config, surf); return 0; } diff --git a/src/amd/common/ac_surface.h b/src/amd/common/ac_surface.h index 01f1cc8dbac..6d95e610a59 100644 --- a/src/amd/common/ac_surface.h +++ b/src/amd/common/ac_surface.h @@ -109,6 +109,7 @@ struct legacy_surf_layout { uint8_t tiling_index[RADEON_SURF_MAX_LEVELS]; uint8_t stencil_tiling_index[RADEON_SURF_MAX_LEVELS]; struct legacy_surf_fmask fmask; + unsigned cmask_slice_tile_max; }; /* Same as addrlib - AddrResourceType. */ @@ -248,6 +249,10 @@ int ac_compute_surface(ADDR_HANDLE addrlib, const struct radeon_info *info, enum radeon_surf_mode mode, struct radeon_surf *surf); +void ac_compute_cmask(const struct radeon_info *info, + const struct ac_surf_config *config, + struct radeon_surf *surf); + #ifdef __cplusplus } #endif |