diff options
author | Marek Olšák <[email protected]> | 2019-08-27 21:18:20 -0400 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2019-09-09 23:43:03 -0400 |
commit | e4c84d8678010743aece15ed8d33527766badc53 (patch) | |
tree | 1373421a9b9ed2387e615899890b2db6043968fe /src/gallium | |
parent | 58ccadfc5c94295d3ab78444f851ca0b54b1bc31 (diff) |
radeonsi: move texture storage allocation outside of radeonsi
possible code sharing with radv
Acked-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/radeonsi/si_texture.c | 58 | ||||
-rw-r--r-- | src/gallium/winsys/radeon/drm/radeon_drm_surface.c | 23 |
2 files changed, 32 insertions, 49 deletions
diff --git a/src/gallium/drivers/radeonsi/si_texture.c b/src/gallium/drivers/radeonsi/si_texture.c index 439de3d0ffa..ddef8da4e14 100644 --- a/src/gallium/drivers/radeonsi/si_texture.c +++ b/src/gallium/drivers/radeonsi/si_texture.c @@ -1243,10 +1243,7 @@ si_texture_create_object(struct pipe_screen *screen, /* don't include stencil-only formats which we don't support for rendering */ tex->is_depth = util_format_has_depth(util_format_description(tex->buffer.b.b.format)); - tex->surface = *surface; - tex->size = tex->surface.surf_size; - tex->tc_compatible_htile = tex->surface.htile_size != 0 && (tex->surface.flags & RADEON_SURF_TC_COMPATIBLE_HTILE); @@ -1276,6 +1273,15 @@ si_texture_create_object(struct pipe_screen *screen, */ tex->ps_draw_ratio = 0; + /* TODO: remove these */ + tex->fmask_offset = tex->surface.fmask_offset; + tex->cmask_offset = tex->surface.cmask_offset; + tex->htile_offset = tex->surface.htile_offset; + tex->dcc_offset = tex->surface.dcc_offset; + tex->display_dcc_offset = tex->surface.display_dcc_offset; + tex->dcc_retile_map_offset = tex->surface.dcc_retile_map_offset; + tex->size = tex->surface.total_size; + if (tex->is_depth) { if (sscreen->info.chip_class >= GFX9) { tex->can_sample_z = true; @@ -1294,55 +1300,11 @@ si_texture_create_object(struct pipe_screen *screen, } tex->db_compatible = surface->flags & RADEON_SURF_ZBUFFER; - - if (tex->surface.htile_size) { - tex->htile_offset = align64(tex->size, - tex->surface.htile_alignment); - tex->size = tex->htile_offset + tex->surface.htile_size; - } } else { - if (tex->surface.fmask_size) { - /* Allocate FMASK. */ - tex->fmask_offset = align64(tex->size, - tex->surface.fmask_alignment); - tex->size = tex->fmask_offset + tex->surface.fmask_size; - - /* Allocate CMASK. */ - tex->cmask_offset = align64(tex->size, tex->surface.cmask_alignment); - tex->size = tex->cmask_offset + tex->surface.cmask_size; + if (tex->surface.cmask_offset) { tex->cb_color_info |= S_028C70_FAST_CLEAR(1); tex->cmask_buffer = &tex->buffer; } - - if (tex->surface.dcc_size && - (sscreen->info.use_display_dcc_unaligned || - sscreen->info.use_display_dcc_with_retile_blit || - !(tex->surface.flags & RADEON_SURF_SCANOUT))) { - /* Add space for the DCC buffer. */ - tex->dcc_offset = align64(tex->size, tex->surface.dcc_alignment); - tex->size = tex->dcc_offset + tex->surface.dcc_size; - - if (sscreen->info.chip_class >= GFX9 && - tex->surface.u.gfx9.dcc_retile_num_elements) { - /* Add space for the displayable DCC buffer. */ - tex->display_dcc_offset = - align64(tex->size, tex->surface.u.gfx9.display_dcc_alignment); - tex->size = tex->display_dcc_offset + - tex->surface.u.gfx9.display_dcc_size; - - /* Add space for the DCC retile buffer. (16-bit or 32-bit elements) */ - tex->dcc_retile_map_offset = - align64(tex->size, sscreen->info.tcc_cache_line_size); - - if (tex->surface.u.gfx9.dcc_retile_use_uint16) { - tex->size = tex->dcc_retile_map_offset + - tex->surface.u.gfx9.dcc_retile_num_elements * 2; - } else { - tex->size = tex->dcc_retile_map_offset + - tex->surface.u.gfx9.dcc_retile_num_elements * 4; - } - } - } } /* Now create the backing buffer. */ diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_surface.c b/src/gallium/winsys/radeon/drm/radeon_drm_surface.c index 332b9e4a428..a49f3eb4ed8 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_surface.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_surface.c @@ -432,9 +432,30 @@ static int radeon_winsys_surface_init(struct radeon_winsys *rws, si_compute_cmask(&ws->info, &config, surf_ws); } - if (ws->gen == DRV_SI) + if (ws->gen == DRV_SI) { si_compute_htile(&ws->info, surf_ws, util_num_layers(tex, 0)); + /* Determine the memory layout of multiple allocations in one buffer. */ + surf_ws->total_size = surf_ws->surf_size; + + if (surf_ws->htile_size) { + surf_ws->htile_offset = align64(surf_ws->total_size, surf_ws->htile_alignment); + surf_ws->total_size = surf_ws->htile_offset + surf_ws->htile_size; + } + + if (surf_ws->fmask_size) { + assert(tex->nr_samples >= 2); + surf_ws->fmask_offset = align64(surf_ws->total_size, surf_ws->fmask_alignment); + surf_ws->total_size = surf_ws->fmask_offset + surf_ws->fmask_size; + } + + /* Single-sample CMASK is in a separate buffer. */ + if (surf_ws->cmask_size && tex->nr_samples >= 2) { + surf_ws->cmask_offset = align64(surf_ws->total_size, surf_ws->cmask_alignment); + surf_ws->total_size = surf_ws->cmask_offset + surf_ws->cmask_size; + } + } + return 0; } |