* when we don't decompress but TC-compatible planes are dirty.
*/
si_make_DB_shader_coherent(sctx, tex->resource.b.b.nr_samples,
- inplace_planes & PIPE_MASK_S);
+ inplace_planes & PIPE_MASK_S,
+ tex->tc_compatible_htile &&
+ first_level == 0);
- /* If we flush DB caches for TC-compatible depth, the dirty
- * state becomes 0 for the whole mipmap tree and all planes.
- * (there is nothing else to flush)
- */
if (tex->tc_compatible_htile) {
/* Only clear the mask that we are flushing, because
* si_make_DB_shader_coherent() can treat depth and
* stencil differently.
*/
if (inplace_planes & PIPE_MASK_Z)
- tex->dirty_level_mask = 0;
+ tex->dirty_level_mask &= ~levels_z;
if (inplace_planes & PIPE_MASK_S)
- tex->stencil_dirty_level_mask = 0;
+ tex->stencil_dirty_level_mask &= ~levels_s;
}
}
/* set_framebuffer_state takes care of coherency for single-sample.
bool dirty_zsbuf;
bool any_dst_linear;
bool CB_has_shader_readable_metadata;
+ bool DB_has_shader_readable_metadata;
};
struct si_clip_state {
static inline void
si_make_DB_shader_coherent(struct si_context *sctx, unsigned num_samples,
- bool include_stencil)
+ bool include_stencil, bool shaders_read_metadata)
{
sctx->b.flags |= SI_CONTEXT_FLUSH_AND_INV_DB |
SI_CONTEXT_INV_VMEM_L1;
- /* Single-sample depth (not stencil) is coherent with shaders on GFX9. */
- if (sctx->b.chip_class <= VI || num_samples >= 2 || include_stencil)
+ if (sctx->b.chip_class >= GFX9) {
+ /* Single-sample depth (not stencil) is coherent with shaders
+ * on GFX9, but L2 metadata must be flushed if shaders read
+ * metadata.
+ */
+ if (num_samples >= 2 || include_stencil)
+ sctx->b.flags |= SI_CONTEXT_INV_GLOBAL_L2;
+ else if (shaders_read_metadata)
+ sctx->b.flags |= SI_CONTEXT_INV_L2_METADATA;
+ } else {
+ /* SI-CI-VI */
sctx->b.flags |= SI_CONTEXT_INV_GLOBAL_L2;
+ }
}
#endif
* Note that lower mipmap levels aren't compressed.
*/
if (sctx->generate_mipmap_for_depth)
- si_make_DB_shader_coherent(sctx, 1, false);
+ si_make_DB_shader_coherent(sctx, 1, false,
+ sctx->framebuffer.DB_has_shader_readable_metadata);
/* Take the maximum of the old and new count. If the new count is lower,
* dirtying is needed to disable the unbound colorbuffers.
sctx->framebuffer.log_samples = util_logbase2(sctx->framebuffer.nr_samples);
sctx->framebuffer.any_dst_linear = false;
sctx->framebuffer.CB_has_shader_readable_metadata = false;
+ sctx->framebuffer.DB_has_shader_readable_metadata = false;
for (i = 0; i < state->nr_cbufs; i++) {
if (!state->cbufs[i])
if (!surf->depth_initialized) {
si_init_depth_surface(sctx, surf);
}
+
+ if (rtex->tc_compatible_htile && !surf->base.u.tex.level)
+ sctx->framebuffer.DB_has_shader_readable_metadata = true;
+
r600_context_add_resource_size(ctx, surf->base.texture);
}