From: Lucas Stach Date: Wed, 16 Nov 2022 18:22:46 +0000 (+0100) Subject: etnaviv: add helper to get TS validity X-Git-Tag: upstream/23.3.3~5619 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0f2df7d361520aa2c88c51a3990e05f8849cbf35;p=platform%2Fupstream%2Fmesa.git etnaviv: add helper to get TS validity Add a small helper to get the validity of the TS buffer for a resource level. We can drop the ts_size check in several places, as we never set ts_valid to true if there is no TS buffer. Signed-off-by: Lucas Stach Reviewed-by: Christian Gmeiner Part-of: --- diff --git a/src/gallium/drivers/etnaviv/etnaviv_blt.c b/src/gallium/drivers/etnaviv/etnaviv_blt.c index c76980a..a8be4bb 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_blt.c +++ b/src/gallium/drivers/etnaviv/etnaviv_blt.c @@ -471,7 +471,7 @@ etna_try_blt_blit(struct pipe_context *pctx, */ if (src == dst) { assert(!memcmp(&blit_info->src, &blit_info->dst, sizeof(blit_info->src))); - if (!src_lev->ts_size || !src_lev->ts_valid) /* No TS, no worries */ + if (!etna_resource_level_ts_valid(src_lev)) /* No TS, no worries */ return true; } @@ -517,7 +517,7 @@ etna_try_blt_blit(struct pipe_context *pctx, for (unsigned x=0; x<4; ++x) op.src.swizzle[x] = x; - if (src_lev->ts_size && src_lev->ts_valid) { + if (etna_resource_level_ts_valid(src_lev)) { op.src.use_ts = 1; op.src.ts_addr.bo = src->ts_bo; op.src.ts_addr.offset = src_lev->ts_offset + blit_info->src.box.z * src_lev->ts_layer_stride; diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.h b/src/gallium/drivers/etnaviv/etnaviv_resource.h index e972cb0..ff74f96 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_resource.h +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.h @@ -94,6 +94,12 @@ etna_resource_level_older(struct etna_resource_level *a, return (int)(a->seqno - b->seqno) < 0; } +static inline bool +etna_resource_level_ts_valid(struct etna_resource_level *lvl) +{ + return lvl->ts_valid; +} + /* returns TRUE if a is older than b */ static inline bool etna_resource_level_needs_flush(struct etna_resource_level *lvl) diff --git a/src/gallium/drivers/etnaviv/etnaviv_rs.c b/src/gallium/drivers/etnaviv/etnaviv_rs.c index 80c9099..3e8623f 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_rs.c +++ b/src/gallium/drivers/etnaviv/etnaviv_rs.c @@ -734,7 +734,7 @@ etna_try_rs_blit(struct pipe_context *pctx, /* Set up color TS to source surface before blit, if needed */ bool source_ts_valid = false; - if (src_lev->ts_size && src_lev->ts_valid) { + if (etna_resource_level_ts_valid(src_lev)) { struct etna_reloc reloc; unsigned ts_offset = src_lev->ts_offset + blit_info->src.box.z * src_lev->ts_layer_stride; diff --git a/src/gallium/drivers/etnaviv/etnaviv_state.c b/src/gallium/drivers/etnaviv/etnaviv_state.c index 8cc09fb..02e4eb5 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_state.c +++ b/src/gallium/drivers/etnaviv/etnaviv_state.c @@ -650,7 +650,7 @@ etna_update_ts_config(struct etna_context *ctx) if (ctx->framebuffer_s.nr_cbufs > 0) { struct etna_surface *c_surf = etna_surface(ctx->framebuffer_s.cbufs[0]); - if(c_surf->level->ts_size && c_surf->level->ts_valid) { + if (etna_resource_level_ts_valid(c_surf->level)) { new_ts_config |= VIVS_TS_MEM_CONFIG_COLOR_FAST_CLEAR; } else { new_ts_config &= ~VIVS_TS_MEM_CONFIG_COLOR_FAST_CLEAR; @@ -660,7 +660,7 @@ etna_update_ts_config(struct etna_context *ctx) if (ctx->framebuffer_s.zsbuf) { struct etna_surface *zs_surf = etna_surface(ctx->framebuffer_s.zsbuf); - if(zs_surf->level->ts_size && zs_surf->level->ts_valid) { + if (etna_resource_level_ts_valid(zs_surf->level)) { new_ts_config |= VIVS_TS_MEM_CONFIG_DEPTH_FAST_CLEAR; } else { new_ts_config &= ~VIVS_TS_MEM_CONFIG_DEPTH_FAST_CLEAR; diff --git a/src/gallium/drivers/etnaviv/etnaviv_texture.c b/src/gallium/drivers/etnaviv/etnaviv_texture.c index 9108803..f97d1e9 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_texture.c +++ b/src/gallium/drivers/etnaviv/etnaviv_texture.c @@ -96,7 +96,7 @@ etna_configure_sampler_ts(struct etna_sampler_ts *sts, struct pipe_sampler_view (lev->clear_value >> 32) != sts->TS_SAMPLER_CLEAR_VALUE2) dirty = true; - assert(rsc->ts_bo && lev->ts_valid); + assert(rsc->ts_bo && etna_resource_level_ts_valid(lev)); sts->mode = lev->ts_mode; sts->comp = lev->ts_compress_fmt >= 0; @@ -151,7 +151,7 @@ etna_can_use_sampler_ts(struct pipe_sampler_view *view, int num) return false; /* The resource TS is valid for level 0. */ - if (!rsc->levels[0].ts_valid) + if (!etna_resource_level_ts_valid(&rsc->levels[0])) return false; return true;