Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>tags/17.3-branchpoint
} | } | ||||
} | } | ||||
surf->has_stencil = !!(surf->flags & RADEON_SURF_SBUFFER); | |||||
surf->num_dcc_levels = 0; | surf->num_dcc_levels = 0; | ||||
surf->surf_size = 0; | surf->surf_size = 0; | ||||
surf->dcc_size = 0; | surf->dcc_size = 0; | ||||
} | } | ||||
surf->u.gfx9.resource_type = AddrSurfInfoIn.resourceType; | surf->u.gfx9.resource_type = AddrSurfInfoIn.resourceType; | ||||
surf->has_stencil = !!(surf->flags & RADEON_SURF_SBUFFER); | |||||
surf->num_dcc_levels = 0; | surf->num_dcc_levels = 0; | ||||
surf->surf_size = 0; | surf->surf_size = 0; |
*/ | */ | ||||
unsigned num_dcc_levels:4; | unsigned num_dcc_levels:4; | ||||
unsigned is_linear:1; | unsigned is_linear:1; | ||||
unsigned has_stencil:1; | |||||
/* Displayable, thin, depth, rotated. AKA D,S,Z,R swizzle modes. */ | /* Displayable, thin, depth, rotated. AKA D,S,Z,R swizzle modes. */ | ||||
unsigned micro_tile_mode:3; | unsigned micro_tile_mode:3; | ||||
uint32_t flags; | uint32_t flags; |
} | } | ||||
format = radv_translate_dbformat(iview->image->vk_format); | format = radv_translate_dbformat(iview->image->vk_format); | ||||
stencil_format = iview->image->surface.flags & RADEON_SURF_SBUFFER ? | |||||
stencil_format = iview->image->surface.has_stencil ? | |||||
V_028044_STENCIL_8 : V_028044_STENCIL_INVALID; | V_028044_STENCIL_8 : V_028044_STENCIL_INVALID; | ||||
uint32_t max_slice = radv_surface_layer_count(iview); | uint32_t max_slice = radv_surface_layer_count(iview); | ||||
if (iview->image->surface.htile_size && !level) { | if (iview->image->surface.htile_size && !level) { | ||||
ds->db_z_info |= S_028038_TILE_SURFACE_ENABLE(1); | ds->db_z_info |= S_028038_TILE_SURFACE_ENABLE(1); | ||||
if (!(iview->image->surface.flags & RADEON_SURF_SBUFFER)) | |||||
if (!iview->image->surface.has_stencil) | |||||
/* Use all of the htile_buffer for depth if there's no stencil. */ | /* Use all of the htile_buffer for depth if there's no stencil. */ | ||||
ds->db_stencil_info |= S_02803C_TILE_STENCIL_DISABLE(1); | ds->db_stencil_info |= S_02803C_TILE_STENCIL_DISABLE(1); | ||||
va = device->ws->buffer_get_va(iview->bo) + iview->image->offset + | va = device->ws->buffer_get_va(iview->bo) + iview->image->offset + | ||||
if (iview->image->surface.htile_size && !level) { | if (iview->image->surface.htile_size && !level) { | ||||
ds->db_z_info |= S_028040_TILE_SURFACE_ENABLE(1); | ds->db_z_info |= S_028040_TILE_SURFACE_ENABLE(1); | ||||
if (!(iview->image->surface.flags & RADEON_SURF_SBUFFER)) | |||||
if (!iview->image->surface.has_stencil) | |||||
/* Use all of the htile_buffer for depth if there's no stencil. */ | /* Use all of the htile_buffer for depth if there's no stencil. */ | ||||
ds->db_stencil_info |= S_028044_TILE_STENCIL_DISABLE(1); | ds->db_stencil_info |= S_028044_TILE_STENCIL_DISABLE(1); | ||||
surf->db_depth_slice = S_02805C_SLICE_TILE_MAX(levelinfo->nblk_x * | surf->db_depth_slice = S_02805C_SLICE_TILE_MAX(levelinfo->nblk_x * | ||||
levelinfo->nblk_y / 64 - 1); | levelinfo->nblk_y / 64 - 1); | ||||
if (rtex->surface.flags & RADEON_SURF_SBUFFER) { | |||||
if (rtex->surface.has_stencil) { | |||||
uint64_t stencil_offset; | uint64_t stencil_offset; | ||||
unsigned stile_split = rtex->surface.u.legacy.stencil_tile_split; | unsigned stile_split = rtex->surface.u.legacy.stencil_tile_split; | ||||
r600_blit_decompress_depth_in_place(rctx, rtex, false, | r600_blit_decompress_depth_in_place(rctx, rtex, false, | ||||
level, level, | level, level, | ||||
first_layer, last_layer); | first_layer, last_layer); | ||||
if (rtex->surface.flags & RADEON_SURF_SBUFFER) { | |||||
if (rtex->surface.has_stencil) { | |||||
r600_blit_decompress_depth_in_place(rctx, rtex, true, | r600_blit_decompress_depth_in_place(rctx, rtex, true, | ||||
level, level, | level, level, | ||||
first_layer, last_layer); | first_layer, last_layer); |
rtex->dirty_level_mask |= 1 << surf->u.tex.level; | rtex->dirty_level_mask |= 1 << surf->u.tex.level; | ||||
if (rtex->surface.flags & RADEON_SURF_SBUFFER) | |||||
if (rtex->surface.has_stencil) | |||||
rtex->stencil_dirty_level_mask |= 1 << surf->u.tex.level; | rtex->stencil_dirty_level_mask |= 1 << surf->u.tex.level; | ||||
} | } | ||||
if (rctx->framebuffer.compressed_cb_mask) { | if (rctx->framebuffer.compressed_cb_mask) { |
rtex->surface.u.legacy.level[i].mode, | rtex->surface.u.legacy.level[i].mode, | ||||
rtex->surface.u.legacy.tiling_index[i]); | rtex->surface.u.legacy.tiling_index[i]); | ||||
if (rtex->surface.flags & RADEON_SURF_SBUFFER) { | |||||
if (rtex->surface.has_stencil) { | |||||
u_log_printf(log, " StencilLayout: tilesplit=%u\n", | u_log_printf(log, " StencilLayout: tilesplit=%u\n", | ||||
rtex->surface.u.legacy.stencil_tile_split); | rtex->surface.u.legacy.stencil_tile_split); | ||||
for (i = 0; i <= rtex->resource.b.b.last_level; i++) { | for (i = 0; i <= rtex->resource.b.b.last_level; i++) { | ||||
clear = PIPE_CLEAR_DEPTH; | clear = PIPE_CLEAR_DEPTH; | ||||
desc->unpack_z_float(&depth, 0, data, 0, 1, 1); | desc->unpack_z_float(&depth, 0, data, 0, 1, 1); | ||||
if (rtex->surface.flags & RADEON_SURF_SBUFFER) { | |||||
if (rtex->surface.has_stencil) { | |||||
clear |= PIPE_CLEAR_STENCIL; | clear |= PIPE_CLEAR_STENCIL; | ||||
desc->unpack_s_8uint(&stencil, 0, data, 0, 1, 1); | desc->unpack_s_8uint(&stencil, 0, data, 0, 1, 1); | ||||
} | } |
if (rtex->db_compatible) { | if (rtex->db_compatible) { | ||||
planes &= PIPE_MASK_Z | PIPE_MASK_S; | planes &= PIPE_MASK_Z | PIPE_MASK_S; | ||||
if (!(rtex->surface.flags & RADEON_SURF_SBUFFER)) | |||||
if (!rtex->surface.has_stencil) | |||||
planes &= ~PIPE_MASK_S; | planes &= ~PIPE_MASK_S; | ||||
/* If we've rendered into the framebuffer and it's a blitting | /* If we've rendered into the framebuffer and it's a blitting |
uint32_t z_info, s_info; | uint32_t z_info, s_info; | ||||
format = si_translate_dbformat(rtex->db_render_format); | format = si_translate_dbformat(rtex->db_render_format); | ||||
stencil_format = rtex->surface.flags & RADEON_SURF_SBUFFER ? | |||||
stencil_format = rtex->surface.has_stencil ? | |||||
V_028044_STENCIL_8 : V_028044_STENCIL_INVALID; | V_028044_STENCIL_8 : V_028044_STENCIL_INVALID; | ||||
assert(format != V_028040_Z_INVALID); | assert(format != V_028040_Z_INVALID); | ||||
s_info |= S_02803C_ITERATE_FLUSH(1); | s_info |= S_02803C_ITERATE_FLUSH(1); | ||||
} | } | ||||
if (rtex->surface.flags & RADEON_SURF_SBUFFER) { | |||||
if (rtex->surface.has_stencil) { | |||||
/* Stencil buffer workaround ported from the SI-CI-VI code. | /* Stencil buffer workaround ported from the SI-CI-VI code. | ||||
* See that for explanation. | * See that for explanation. | ||||
*/ | */ | ||||
z_info |= S_028040_TILE_SURFACE_ENABLE(1) | | z_info |= S_028040_TILE_SURFACE_ENABLE(1) | | ||||
S_028040_ALLOW_EXPCLEAR(1); | S_028040_ALLOW_EXPCLEAR(1); | ||||
if (rtex->surface.flags & RADEON_SURF_SBUFFER) { | |||||
if (rtex->surface.has_stencil) { | |||||
/* Workaround: For a not yet understood reason, the | /* Workaround: For a not yet understood reason, the | ||||
* combination of MSAA, fast stencil clear and stencil | * combination of MSAA, fast stencil clear and stencil | ||||
* decompress messes with subsequent stencil buffer | * decompress messes with subsequent stencil buffer | ||||
rtex->dirty_level_mask |= 1 << surf->u.tex.level; | rtex->dirty_level_mask |= 1 << surf->u.tex.level; | ||||
if (rtex->surface.flags & RADEON_SURF_SBUFFER) | |||||
if (rtex->surface.has_stencil) | |||||
rtex->stencil_dirty_level_mask |= 1 << surf->u.tex.level; | rtex->stencil_dirty_level_mask |= 1 << surf->u.tex.level; | ||||
} | } | ||||
if (sctx->framebuffer.compressed_cb_mask) { | if (sctx->framebuffer.compressed_cb_mask) { |
struct r600_texture *rtex = | struct r600_texture *rtex = | ||||
(struct r600_texture*)sctx->framebuffer.state.zsbuf->texture; | (struct r600_texture*)sctx->framebuffer.state.zsbuf->texture; | ||||
unsigned depth_coeff = dsa->depth_enabled ? 5 : 0; | unsigned depth_coeff = dsa->depth_enabled ? 5 : 0; | ||||
unsigned stencil_coeff = rtex->surface.flags & RADEON_SURF_SBUFFER && | |||||
unsigned stencil_coeff = rtex->surface.has_stencil && | |||||
dsa->stencil_enabled ? 1 : 0; | dsa->stencil_enabled ? 1 : 0; | ||||
unsigned sum = 4 * (depth_coeff + stencil_coeff) * | unsigned sum = 4 * (depth_coeff + stencil_coeff) * | ||||
sctx->framebuffer.nr_samples; | sctx->framebuffer.nr_samples; |
surf_ws->blk_h = surf_drm->blk_h; | surf_ws->blk_h = surf_drm->blk_h; | ||||
surf_ws->bpe = surf_drm->bpe; | surf_ws->bpe = surf_drm->bpe; | ||||
surf_ws->is_linear = surf_drm->level[0].mode <= RADEON_SURF_MODE_LINEAR_ALIGNED; | surf_ws->is_linear = surf_drm->level[0].mode <= RADEON_SURF_MODE_LINEAR_ALIGNED; | ||||
surf_ws->has_stencil = !!(surf_drm->flags & RADEON_SURF_SBUFFER); | |||||
surf_ws->flags = surf_drm->flags; | surf_ws->flags = surf_drm->flags; | ||||
surf_ws->surf_size = surf_drm->bo_size; | surf_ws->surf_size = surf_drm->bo_size; |