[Mesa-dev] [PATCH 2/2] radeonsi: decompress DCC in set_sampler_view instead of create_sampler_view (v2)
Nicolai Hähnle
nhaehnle at gmail.com
Fri Mar 31 06:07:57 UTC 2017
Both patches:
Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>
On 30.03.2017 16:30, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> v2: don't add a new decompress helper function
> ---
> src/gallium/drivers/radeonsi/si_descriptors.c | 14 +++++++++++---
> src/gallium/drivers/radeonsi/si_pipe.h | 1 +
> src/gallium/drivers/radeonsi/si_state.c | 7 ++++---
> 3 files changed, 16 insertions(+), 6 deletions(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c
> index f28202f..2b91158 100644
> --- a/src/gallium/drivers/radeonsi/si_descriptors.c
> +++ b/src/gallium/drivers/radeonsi/si_descriptors.c
> @@ -473,47 +473,55 @@ static void si_set_sampler_view(struct si_context *sctx,
> struct si_sampler_views *views = &sctx->samplers[shader].views;
> struct si_sampler_view *rview = (struct si_sampler_view*)view;
> struct si_descriptors *descs = si_sampler_descriptors(sctx, shader);
> uint32_t *desc = descs->list + slot * 16;
>
> if (views->views[slot] == view && !disallow_early_out)
> return;
>
> if (view) {
> struct r600_texture *rtex = (struct r600_texture *)view->texture;
> + bool is_buffer = rtex->resource.b.b.target == PIPE_BUFFER;
> +
> + if (unlikely(!is_buffer && rview->dcc_incompatible)) {
> + if (vi_dcc_enabled(rtex, view->u.tex.first_level))
> + if (!r600_texture_disable_dcc(&sctx->b, rtex))
> + sctx->b.decompress_dcc(&sctx->b.b, rtex);
> +
> + rview->dcc_incompatible = false;
> + }
>
> assert(rtex); /* views with texture == NULL aren't supported */
> pipe_sampler_view_reference(&views->views[slot], view);
> memcpy(desc, rview->state, 8*4);
>
> - if (rtex->resource.b.b.target == PIPE_BUFFER) {
> + if (is_buffer) {
> rtex->resource.bind_history |= PIPE_BIND_SAMPLER_VIEW;
>
> si_set_buf_desc_address(&rtex->resource,
> view->u.buf.offset,
> desc + 4);
> } else {
> bool is_separate_stencil =
> rtex->db_compatible &&
> rview->is_stencil_sampler;
>
> si_set_mutable_tex_desc_fields(sctx->screen, rtex,
> rview->base_level_info,
> rview->base_level,
> rview->base.u.tex.first_level,
> rview->block_width,
> is_separate_stencil,
> desc);
> }
>
> - if (rtex->resource.b.b.target != PIPE_BUFFER &&
> - rtex->fmask.size) {
> + if (!is_buffer && rtex->fmask.size) {
> memcpy(desc + 8,
> rview->fmask_state, 8*4);
> } else {
> /* Disable FMASK and bind sampler state in [12:15]. */
> memcpy(desc + 8,
> null_texture_descriptor, 4*4);
>
> if (views->sampler_states[slot])
> memcpy(desc + 12,
> views->sampler_states[slot]->val, 4*4);
> diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h
> index e1df3b6..3a6503a 100644
> --- a/src/gallium/drivers/radeonsi/si_pipe.h
> +++ b/src/gallium/drivers/radeonsi/si_pipe.h
> @@ -120,20 +120,21 @@ struct si_blend_color {
> struct si_sampler_view {
> struct pipe_sampler_view base;
> /* [0..7] = image descriptor
> * [4..7] = buffer descriptor */
> uint32_t state[8];
> uint32_t fmask_state[8];
> const struct legacy_surf_level *base_level_info;
> unsigned base_level;
> unsigned block_width;
> bool is_stencil_sampler;
> + bool dcc_incompatible;
> };
>
> #define SI_SAMPLER_STATE_MAGIC 0x34f1c35a
>
> struct si_sampler_state {
> #ifdef DEBUG
> unsigned magic;
> #endif
> uint32_t val[4];
> };
> diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
> index 2c2e3c7..f8c6faf 100644
> --- a/src/gallium/drivers/radeonsi/si_state.c
> +++ b/src/gallium/drivers/radeonsi/si_state.c
> @@ -3430,23 +3430,24 @@ si_create_sampler_view_custom(struct pipe_context *ctx,
> case PIPE_FORMAT_X24S8_UINT:
> case PIPE_FORMAT_S8X24_UINT:
> case PIPE_FORMAT_X32_S8X24_UINT:
> pipe_format = PIPE_FORMAT_S8_UINT;
> surflevel = tmp->surface.u.legacy.stencil_level;
> break;
> default:;
> }
> }
>
> - vi_disable_dcc_if_incompatible_format(&sctx->b, texture,
> - state->u.tex.first_level,
> - state->format);
> + view->dcc_incompatible =
> + vi_dcc_formats_are_incompatible(texture,
> + state->u.tex.first_level,
> + state->format);
>
> si_make_texture_descriptor(sctx->screen, tmp, true,
> state->target, pipe_format, state_swizzle,
> first_level, last_level,
> state->u.tex.first_layer, last_layer,
> width, height, depth,
> view->state, view->fmask_state);
>
> view->base_level_info = &surflevel[base_level];
> view->base_level = base_level;
>
--
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.
More information about the mesa-dev
mailing list