[Mesa-dev] [PATCH v2] r600g: Pass conservative depth parameters to hw

Marek Olšák maraeo at gmail.com
Sat Oct 17 12:32:38 PDT 2015


Reviewed-by: Marek Olšák <marek.olsak at amd.com>


On Sat, Oct 17, 2015 at 4:53 PM, Glenn Kennard <glenn.kennard at gmail.com> wrote:
> Supported on R700 and up.
>
> Signed-off-by: Glenn Kennard <glenn.kennard at gmail.com>
> ---
> v2:
>   Use correct register for R700, set from r600_emit_db_misc_state
>   Added ps_conservative_z field to r600_db_misc_state
>   Shrunk ps_conservative_z to uint8 since only 2 bits are needed
>
> Thanks Alex for noting the incorrect register on R700, would have gone
> unnoticed for years otherwise since the feature isn't directly observable...
>
>  src/gallium/drivers/r600/evergreen_state.c | 13 +++++++++++++
>  src/gallium/drivers/r600/evergreend.h      |  7 +++++++
>  src/gallium/drivers/r600/r600_pipe.h       |  1 +
>  src/gallium/drivers/r600/r600_shader.c     |  1 +
>  src/gallium/drivers/r600/r600_shader.h     |  2 ++
>  src/gallium/drivers/r600/r600_state.c      | 22 +++++++++++++++++++++-
>  src/gallium/drivers/r600/r600d.h           |  8 ++++++++
>  7 files changed, 53 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c
> index c6702a9..96c6b11 100644
> --- a/src/gallium/drivers/r600/evergreen_state.c
> +++ b/src/gallium/drivers/r600/evergreen_state.c
> @@ -2940,6 +2940,19 @@ void evergreen_update_ps_state(struct pipe_context *ctx, struct r600_pipe_shader
>         db_shader_control |= S_02880C_STENCIL_EXPORT_ENABLE(stencil_export);
>         db_shader_control |= S_02880C_MASK_EXPORT_ENABLE(mask_export);
>
> +       switch (rshader->ps_conservative_z) {
> +       default: /* fall through */
> +       case TGSI_FS_DEPTH_LAYOUT_ANY:
> +               db_shader_control |= S_02880C_CONSERVATIVE_Z_EXPORT(V_02880C_EXPORT_ANY_Z);
> +               break;
> +       case TGSI_FS_DEPTH_LAYOUT_GREATER:
> +               db_shader_control |= S_02880C_CONSERVATIVE_Z_EXPORT(V_02880C_EXPORT_GREATER_THAN_Z);
> +               break;
> +       case TGSI_FS_DEPTH_LAYOUT_LESS:
> +               db_shader_control |= S_02880C_CONSERVATIVE_Z_EXPORT(V_02880C_EXPORT_LESS_THAN_Z);
> +               break;
> +       }
> +
>         exports_ps = 0;
>         for (i = 0; i < rshader->noutput; i++) {
>                 if (rshader->output[i].name == TGSI_SEMANTIC_POSITION ||
> diff --git a/src/gallium/drivers/r600/evergreend.h b/src/gallium/drivers/r600/evergreend.h
> index 937ffcb..a9a65f7 100644
> --- a/src/gallium/drivers/r600/evergreend.h
> +++ b/src/gallium/drivers/r600/evergreend.h
> @@ -815,6 +815,13 @@
>  #define     V_02880C_EXPORT_DB_FOUR16                  0x01
>  #define     V_02880C_EXPORT_DB_TWO                     0x02
>  #define   S_02880C_ALPHA_TO_MASK_DISABLE(x)            (((x) & 0x1) << 12)
> +#define   S_02880C_CONSERVATIVE_Z_EXPORT(x)            (((x) & 0x03) << 16)
> +#define   G_02880C_CONSERVATIVE_Z_EXPORT(x)            (((x) >> 16) & 0x03)
> +#define   C_02880C_CONSERVATIVE_Z_EXPORT               0xFFFCFFFF
> +#define     V_02880C_EXPORT_ANY_Z                      0
> +#define     V_02880C_EXPORT_LESS_THAN_Z                1
> +#define     V_02880C_EXPORT_GREATER_THAN_Z             2
> +#define     V_02880C_EXPORT_RESERVED                   3
>
>  #define R_028A00_PA_SU_POINT_SIZE                    0x028A00
>  #define   S_028A00_HEIGHT(x)                           (((x) & 0xFFFF) << 0)
> diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h
> index 520b03f..950bb6b 100644
> --- a/src/gallium/drivers/r600/r600_pipe.h
> +++ b/src/gallium/drivers/r600/r600_pipe.h
> @@ -116,6 +116,7 @@ struct r600_db_misc_state {
>         unsigned                        log_samples;
>         unsigned                        db_shader_control;
>         bool                            htile_clear;
> +       uint8_t                         ps_conservative_z;
>  };
>
>  struct r600_cb_misc_state {
> diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c
> index 8efe902..613f94e 100644
> --- a/src/gallium/drivers/r600/r600_shader.c
> +++ b/src/gallium/drivers/r600/r600_shader.c
> @@ -2048,6 +2048,7 @@ static int r600_shader_from_tgsi(struct r600_context *rctx,
>
>         shader->fs_write_all = ctx.info.properties[TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS];
>         shader->vs_position_window_space = ctx.info.properties[TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION];
> +       shader->ps_conservative_z = (uint8_t)ctx.info.properties[TGSI_PROPERTY_FS_DEPTH_LAYOUT];
>
>         if (shader->vs_as_gs_a)
>                 vs_add_primid_output(&ctx, key.vs.prim_id_out);
> diff --git a/src/gallium/drivers/r600/r600_shader.h b/src/gallium/drivers/r600/r600_shader.h
> index c240e71..2040f73 100644
> --- a/src/gallium/drivers/r600/r600_shader.h
> +++ b/src/gallium/drivers/r600/r600_shader.h
> @@ -76,6 +76,8 @@ struct r600_shader {
>         boolean                 uses_tex_buffers;
>         boolean                 gs_prim_id_input;
>
> +       uint8_t                 ps_conservative_z;
> +
>         /* Size in bytes of a data item in the ring(s) (single vertex data).
>            Stages with only one ring items 123 will be set to 0. */
>         unsigned                ring_item_sizes[4];
> diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c
> index 1be3e1b..1305efa 100644
> --- a/src/gallium/drivers/r600/r600_state.c
> +++ b/src/gallium/drivers/r600/r600_state.c
> @@ -1628,6 +1628,21 @@ static void r600_emit_db_misc_state(struct r600_context *rctx, struct r600_atom
>                 S_028D10_FORCE_HIS_ENABLE0(V_028D10_FORCE_DISABLE) |
>                 S_028D10_FORCE_HIS_ENABLE1(V_028D10_FORCE_DISABLE);
>
> +       if (rctx->b.chip_class >= R700) {
> +               switch (a->ps_conservative_z) {
> +               default: /* fall through */
> +               case TGSI_FS_DEPTH_LAYOUT_ANY:
> +                       db_render_control |= S_028D0C_CONSERVATIVE_Z_EXPORT(V_028D0C_EXPORT_ANY_Z);
> +                       break;
> +               case TGSI_FS_DEPTH_LAYOUT_GREATER:
> +                       db_render_control |= S_028D0C_CONSERVATIVE_Z_EXPORT(V_028D0C_EXPORT_GREATER_THAN_Z);
> +                       break;
> +               case TGSI_FS_DEPTH_LAYOUT_LESS:
> +                       db_render_control |= S_028D0C_CONSERVATIVE_Z_EXPORT(V_028D0C_EXPORT_LESS_THAN_Z);
> +                       break;
> +               }
> +       }
> +
>         if (a->occlusion_query_enabled) {
>                 if (rctx->b.chip_class >= R700) {
>                         db_render_control |= S_028D0C_R700_PERFECT_ZPASS_COUNTS(1);
> @@ -2787,6 +2802,7 @@ void r600_update_db_shader_control(struct r600_context * rctx)
>  {
>         bool dual_export;
>         unsigned db_shader_control;
> +       uint8_t ps_conservative_z;
>
>         if (!rctx->ps_shader) {
>                 return;
> @@ -2798,6 +2814,8 @@ void r600_update_db_shader_control(struct r600_context * rctx)
>         db_shader_control = rctx->ps_shader->current->db_shader_control |
>                             S_02880C_DUAL_EXPORT_ENABLE(dual_export);
>
> +       ps_conservative_z = rctx->ps_shader->current->shader.ps_conservative_z;
> +
>         /* When alpha test is enabled we can't trust the hw to make the proper
>          * decision on the order in which ztest should be run related to fragment
>          * shader execution.
> @@ -2811,8 +2829,10 @@ void r600_update_db_shader_control(struct r600_context * rctx)
>                 db_shader_control |= S_02880C_Z_ORDER(V_02880C_EARLY_Z_THEN_LATE_Z);
>         }
>
> -       if (db_shader_control != rctx->db_misc_state.db_shader_control) {
> +       if (db_shader_control != rctx->db_misc_state.db_shader_control ||
> +               ps_conservative_z != rctx->db_misc_state.ps_conservative_z) {
>                 rctx->db_misc_state.db_shader_control = db_shader_control;
> +               rctx->db_misc_state.ps_conservative_z = ps_conservative_z;
>                 r600_mark_atom_dirty(rctx, &rctx->db_misc_state.atom);
>         }
>  }
> diff --git a/src/gallium/drivers/r600/r600d.h b/src/gallium/drivers/r600/r600d.h
> index 6bba88c..53f5ad6 100644
> --- a/src/gallium/drivers/r600/r600d.h
> +++ b/src/gallium/drivers/r600/r600d.h
> @@ -781,6 +781,14 @@
>  #define   S_028D0C_COPY_CENTROID(x)                    (((x) & 0x1) << 7)
>  #define   S_028D0C_COPY_SAMPLE(x)                      (((x) & 0x1) << 8)
>  #define   S_028D0C_R700_PERFECT_ZPASS_COUNTS(x)        (((x) & 0x1) << 15)
> +#define   S_028D0C_CONSERVATIVE_Z_EXPORT(x)            (((x) & 0x03) << 13)
> +#define   G_028D0C_CONSERVATIVE_Z_EXPORT(x)            (((x) >> 13) & 0x03)
> +#define   C_028D0C_CONSERVATIVE_Z_EXPORT               0xFFFF9FFF
> +#define     V_028D0C_EXPORT_ANY_Z                      0
> +#define     V_028D0C_EXPORT_LESS_THAN_Z                1
> +#define     V_028D0C_EXPORT_GREATER_THAN_Z             2
> +#define     V_028D0C_EXPORT_RESERVED                   3
> +
>  #define R_028D10_DB_RENDER_OVERRIDE                  0x028D10
>  #define   V_028D10_FORCE_OFF                         0
>  #define   V_028D10_FORCE_ENABLE                      1
> --
> 1.9.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list