mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 22:38:05 +02:00
radeonsi: move initial framebuffer barrier code into si_barrier.c
The new function si_fb_barrier_after_rendering will flag cache flushes and waits in future commits. This is the beginning of unifying all framebuffer barrier code. Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31193>
This commit is contained in:
parent
834aa812ea
commit
895226e3ab
6 changed files with 52 additions and 54 deletions
|
|
@ -641,7 +641,7 @@ static void si_texture_barrier(struct pipe_context *ctx, unsigned flags)
|
|||
{
|
||||
struct si_context *sctx = (struct si_context *)ctx;
|
||||
|
||||
si_update_fb_dirtiness_after_rendering(sctx);
|
||||
si_fb_barrier_after_rendering(sctx);
|
||||
|
||||
/* Multisample surfaces are flushed in si_decompress_textures. */
|
||||
if (sctx->framebuffer.uncompressed_cb_mask) {
|
||||
|
|
@ -718,6 +718,52 @@ static void si_memory_barrier(struct pipe_context *ctx, unsigned flags)
|
|||
si_mark_atom_dirty(sctx, &sctx->atoms.s.barrier);
|
||||
}
|
||||
|
||||
static void si_set_sampler_depth_decompress_mask(struct si_context *sctx, struct si_texture *tex)
|
||||
{
|
||||
assert(sctx->gfx_level < GFX12);
|
||||
|
||||
/* Check all sampler bindings in all shaders where depth textures are bound, and update
|
||||
* which samplers should be decompressed.
|
||||
*/
|
||||
u_foreach_bit(sh, sctx->shader_has_depth_tex) {
|
||||
u_foreach_bit(i, sctx->samplers[sh].has_depth_tex_mask) {
|
||||
if (sctx->samplers[sh].views[i]->texture == &tex->buffer.b.b) {
|
||||
sctx->samplers[sh].needs_depth_decompress_mask |= 1 << i;
|
||||
sctx->shader_needs_decompress_mask |= 1 << sh;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void si_fb_barrier_after_rendering(struct si_context *sctx)
|
||||
{
|
||||
if (sctx->gfx_level < GFX12 && !sctx->decompression_enabled) {
|
||||
if (sctx->framebuffer.state.zsbuf) {
|
||||
struct pipe_surface *surf = sctx->framebuffer.state.zsbuf;
|
||||
struct si_texture *tex = (struct si_texture *)surf->texture;
|
||||
|
||||
tex->dirty_level_mask |= 1 << surf->u.tex.level;
|
||||
|
||||
if (tex->surface.has_stencil)
|
||||
tex->stencil_dirty_level_mask |= 1 << surf->u.tex.level;
|
||||
|
||||
si_set_sampler_depth_decompress_mask(sctx, tex);
|
||||
}
|
||||
|
||||
unsigned compressed_cb_mask = sctx->framebuffer.compressed_cb_mask;
|
||||
while (compressed_cb_mask) {
|
||||
unsigned i = u_bit_scan(&compressed_cb_mask);
|
||||
struct pipe_surface *surf = sctx->framebuffer.state.cbufs[i];
|
||||
struct si_texture *tex = (struct si_texture *)surf->texture;
|
||||
|
||||
if (tex->surface.fmask_offset) {
|
||||
tex->dirty_level_mask |= 1 << surf->u.tex.level;
|
||||
tex->fmask_is_identity = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void si_init_barrier_functions(struct si_context *sctx)
|
||||
{
|
||||
if (sctx->gfx_level >= GFX10)
|
||||
|
|
|
|||
|
|
@ -933,7 +933,7 @@ void si_decompress_subresource(struct pipe_context *ctx, struct pipe_resource *t
|
|||
*/
|
||||
if (sctx->framebuffer.state.zsbuf && sctx->framebuffer.state.zsbuf->u.tex.level == level &&
|
||||
sctx->framebuffer.state.zsbuf->texture == tex)
|
||||
si_update_fb_dirtiness_after_rendering(sctx);
|
||||
si_fb_barrier_after_rendering(sctx);
|
||||
|
||||
si_decompress_depth(sctx, stex, planes, level, level, first_layer, last_layer);
|
||||
} else if (stex->surface.fmask_size || stex->cmask_buffer ||
|
||||
|
|
@ -946,7 +946,7 @@ void si_decompress_subresource(struct pipe_context *ctx, struct pipe_resource *t
|
|||
if (sctx->framebuffer.state.cbufs[i] &&
|
||||
sctx->framebuffer.state.cbufs[i]->u.tex.level == level &&
|
||||
sctx->framebuffer.state.cbufs[i]->texture == tex) {
|
||||
si_update_fb_dirtiness_after_rendering(sctx);
|
||||
si_fb_barrier_after_rendering(sctx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1187,7 +1187,7 @@ static void si_launch_grid(struct pipe_context *ctx, const struct pipe_grid_info
|
|||
if (sctx->has_graphics) {
|
||||
if (sctx->num_draw_calls_sh_coherent.with_cb != sctx->num_draw_calls ||
|
||||
sctx->num_draw_calls_sh_coherent.with_db != sctx->num_draw_calls) {
|
||||
si_update_fb_dirtiness_after_rendering(sctx);
|
||||
si_fb_barrier_after_rendering(sctx);
|
||||
|
||||
if (sctx->force_shader_coherency.with_cb ||
|
||||
si_check_needs_implicit_sync(sctx, RADEON_USAGE_CB_NEEDS_IMPLICIT_SYNC)) {
|
||||
|
|
|
|||
|
|
@ -1380,6 +1380,7 @@ void si_barrier_before_simple_buffer_op(struct si_context *sctx, unsigned flags,
|
|||
struct pipe_resource *dst, struct pipe_resource *src);
|
||||
void si_barrier_after_simple_buffer_op(struct si_context *sctx, unsigned flags,
|
||||
struct pipe_resource *dst, struct pipe_resource *src);
|
||||
void si_fb_barrier_after_rendering(struct si_context *sctx);
|
||||
void si_init_barrier_functions(struct si_context *sctx);
|
||||
|
||||
/* si_blit.c */
|
||||
|
|
|
|||
|
|
@ -2476,53 +2476,6 @@ static void si_init_depth_surface(struct si_context *sctx, struct si_surface *su
|
|||
surf->depth_initialized = true;
|
||||
}
|
||||
|
||||
void si_set_sampler_depth_decompress_mask(struct si_context *sctx, struct si_texture *tex)
|
||||
{
|
||||
assert(sctx->gfx_level < GFX12);
|
||||
|
||||
/* Check all sampler bindings in all shaders where depth textures are bound, and update
|
||||
* which samplers should be decompressed.
|
||||
*/
|
||||
u_foreach_bit(sh, sctx->shader_has_depth_tex) {
|
||||
u_foreach_bit(i, sctx->samplers[sh].has_depth_tex_mask) {
|
||||
if (sctx->samplers[sh].views[i]->texture == &tex->buffer.b.b) {
|
||||
sctx->samplers[sh].needs_depth_decompress_mask |= 1 << i;
|
||||
sctx->shader_needs_decompress_mask |= 1 << sh;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void si_update_fb_dirtiness_after_rendering(struct si_context *sctx)
|
||||
{
|
||||
if (sctx->gfx_level >= GFX12 || sctx->decompression_enabled)
|
||||
return;
|
||||
|
||||
if (sctx->framebuffer.state.zsbuf) {
|
||||
struct pipe_surface *surf = sctx->framebuffer.state.zsbuf;
|
||||
struct si_texture *tex = (struct si_texture *)surf->texture;
|
||||
|
||||
tex->dirty_level_mask |= 1 << surf->u.tex.level;
|
||||
|
||||
if (tex->surface.has_stencil)
|
||||
tex->stencil_dirty_level_mask |= 1 << surf->u.tex.level;
|
||||
|
||||
si_set_sampler_depth_decompress_mask(sctx, tex);
|
||||
}
|
||||
|
||||
unsigned compressed_cb_mask = sctx->framebuffer.compressed_cb_mask;
|
||||
while (compressed_cb_mask) {
|
||||
unsigned i = u_bit_scan(&compressed_cb_mask);
|
||||
struct pipe_surface *surf = sctx->framebuffer.state.cbufs[i];
|
||||
struct si_texture *tex = (struct si_texture *)surf->texture;
|
||||
|
||||
if (tex->surface.fmask_offset) {
|
||||
tex->dirty_level_mask |= 1 << surf->u.tex.level;
|
||||
tex->fmask_is_identity = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void si_dec_framebuffer_counters(const struct pipe_framebuffer_state *state)
|
||||
{
|
||||
for (int i = 0; i < state->nr_cbufs; ++i) {
|
||||
|
|
@ -2594,7 +2547,7 @@ static void si_set_framebuffer_state(struct pipe_context *ctx,
|
|||
return;
|
||||
}
|
||||
|
||||
si_update_fb_dirtiness_after_rendering(sctx);
|
||||
si_fb_barrier_after_rendering(sctx);
|
||||
|
||||
/* Disable DCC if the formats are incompatible. */
|
||||
if (sctx->gfx_level >= GFX8 && sctx->gfx_level < GFX11) {
|
||||
|
|
|
|||
|
|
@ -628,8 +628,6 @@ void si_init_gfx_preamble_state(struct si_context *sctx);
|
|||
void si_make_buffer_descriptor(struct si_screen *screen, struct si_resource *buf,
|
||||
enum pipe_format format, unsigned offset, unsigned num_elements,
|
||||
uint32_t *state);
|
||||
void si_set_sampler_depth_decompress_mask(struct si_context *sctx, struct si_texture *tex);
|
||||
void si_update_fb_dirtiness_after_rendering(struct si_context *sctx);
|
||||
void si_mark_display_dcc_dirty(struct si_context *sctx, struct si_texture *tex);
|
||||
void si_update_ps_iter_samples(struct si_context *sctx);
|
||||
void si_save_qbo_state(struct si_context *sctx, struct si_qbo_state *st);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue