zink: track zsbuf info even when rp optimizing is disabled

this should allow zsbuf elimination in some cases

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21988>
This commit is contained in:
Mike Blumenkrantz 2023-03-17 09:47:10 -04:00 committed by Marge Bot
parent d750ad19fd
commit d8bb8af4f5
5 changed files with 39 additions and 2 deletions

View file

@ -298,10 +298,15 @@ zink_clear(struct pipe_context *pctx,
if (buffers & PIPE_CLEAR_STENCIL)
clear->zs.stencil = stencil;
clear->zs.bits |= (buffers & PIPE_CLEAR_DEPTHSTENCIL);
if (zink_fb_clear_first_needs_explicit(fb_clear))
if (zink_fb_clear_first_needs_explicit(fb_clear)) {
ctx->rp_clears_enabled &= ~PIPE_CLEAR_DEPTHSTENCIL;
else
if (!zink_screen(ctx->base.screen)->driver_workarounds.track_renderpasses)
ctx->dynamic_fb.tc_info.zsbuf_clear_partial = true;
} else {
ctx->rp_clears_enabled |= (buffers & PIPE_CLEAR_DEPTHSTENCIL);
if (!zink_screen(ctx->base.screen)->driver_workarounds.track_renderpasses)
ctx->dynamic_fb.tc_info.zsbuf_clear = true;
}
}
assert(!ctx->batch.in_rp);
ctx->rp_changed |= ctx->rp_clears_enabled != rp_clears_enabled;

View file

@ -67,6 +67,20 @@ update_tc_info(struct zink_context *ctx)
const struct tc_renderpass_info *info = threaded_context_get_renderpass_info(ctx->tc);
ctx->rp_changed |= ctx->dynamic_fb.tc_info.data != info->data;
ctx->dynamic_fb.tc_info.data = info->data;
} else {
struct tc_renderpass_info info = ctx->dynamic_fb.tc_info;
bool zsbuf_used = zink_is_zsbuf_used(ctx);
bool zsbuf_write = zink_is_zsbuf_write(ctx);
ctx->dynamic_fb.tc_info.data32[0] = 0;
if (ctx->clears_enabled & PIPE_CLEAR_DEPTHSTENCIL)
ctx->dynamic_fb.tc_info.zsbuf_clear_partial = true;
if (ctx->rp_clears_enabled & PIPE_CLEAR_DEPTHSTENCIL)
ctx->dynamic_fb.tc_info.zsbuf_clear = true;
if (ctx->dynamic_fb.tc_info.zsbuf_clear != info.zsbuf_clear)
ctx->rp_loadop_changed = true;
if (zink_is_zsbuf_write(ctx) != zsbuf_write)
ctx->rp_layout_changed = true;
ctx->rp_changed |= zink_is_zsbuf_used(ctx) != zsbuf_used;
}
}
@ -5284,6 +5298,18 @@ zink_tc_parse_fs(void *state, struct tc_renderpass_info *info)
info->cbuf_fbfetch |= zs->nir->info.fs.uses_fbfetch_output ? BITFIELD_BIT(0) : 0;
}
void
zink_parse_tc_info(struct zink_context *ctx)
{
struct tc_renderpass_info *info = &ctx->dynamic_fb.tc_info;
/* reset cso info first */
info->data16[2] = 0;
if (ctx->gfx_stages[MESA_SHADER_FRAGMENT])
zink_tc_parse_fs(ctx->gfx_stages[MESA_SHADER_FRAGMENT], info);
if (ctx->dsa_state)
zink_tc_parse_dsa(ctx->dsa_state, info);
}
struct pipe_context *
zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
{

View file

@ -166,6 +166,8 @@ zink_rebind_all_buffers(struct zink_context *ctx);
void
zink_rebind_all_images(struct zink_context *ctx);
void
zink_parse_tc_info(struct zink_context *ctx);
void
zink_flush_memory_barrier(struct zink_context *ctx, bool is_compute);
void

View file

@ -1767,6 +1767,8 @@ zink_bind_fs_state(struct pipe_context *pctx,
if (shadow_mask != ctx->gfx_stages[MESA_SHADER_FRAGMENT]->fs.legacy_shadow_mask &&
!zink_screen(pctx->screen)->driver_workarounds.needs_zs_shader_swizzle)
zink_update_shadow_samplerviews(ctx, shadow_mask | ctx->gfx_stages[MESA_SHADER_FRAGMENT]->fs.legacy_shadow_mask);
if (!zink_screen(ctx->base.screen)->driver_workarounds.track_renderpasses && !ctx->blitting)
zink_parse_tc_info(ctx);
}
zink_update_fbfetch(ctx);
}

View file

@ -522,6 +522,8 @@ zink_bind_depth_stencil_alpha_state(struct pipe_context *pctx, void *cso)
state->dirty |= !zink_screen(pctx->screen)->info.have_EXT_extended_dynamic_state;
ctx->dsa_state_changed = true;
}
if (!zink_screen(ctx->base.screen)->driver_workarounds.track_renderpasses && !ctx->blitting)
zink_parse_tc_info(ctx);
}
bool zs_write = ctx->dsa_state ? ctx->dsa_state->hw_state.depth_write || ctx->dsa_state->hw_state.stencil_test : false;
if (prev_zswrite != zs_write) {