[Mesa-dev] [PATCH v03 34/38] i965: Port push constant code to genxml.

Kenneth Graunke kenneth at whitecape.org
Thu May 4 02:54:15 UTC 2017


On Monday, May 1, 2017 6:43:22 PM PDT Rafael Antognolli wrote:
> The following states are ported on this patch:
>    - gen6_gs_push_constants
>    - gen6_vs_push_constants
>    - gen6_wm_push_constants
>    - gen7_tes_push_constants
> 
> v2:
>    - Use helper to setup brw_address (Kristian)
> v3:
>    - Do not use macro for upload_constant_state (Ken)
>    - Do not re-declare MOCS macro (Ken)
> 
> Signed-off-by: Rafael Antognolli <rafael.antognolli at intel.com>
> ---
>  src/mesa/drivers/dri/i965/Makefile.sources    |   4 +-
>  src/mesa/drivers/dri/i965/brw_state.h         |   5 +-
>  src/mesa/drivers/dri/i965/gen6_gs_state.c     |  33 +---
>  src/mesa/drivers/dri/i965/gen6_vs_state.c     |  70 +------
>  src/mesa/drivers/dri/i965/gen6_wm_state.c     |  70 +------
>  src/mesa/drivers/dri/i965/gen7_ds_state.c     |  57 +-----
>  src/mesa/drivers/dri/i965/gen7_hs_state.c     |  60 +-----
>  src/mesa/drivers/dri/i965/genX_state_upload.c | 240 +++++++++++++++++--
>  8 files changed, 227 insertions(+), 312 deletions(-)
>  delete mode 100644 src/mesa/drivers/dri/i965/gen6_vs_state.c
>  delete mode 100644 src/mesa/drivers/dri/i965/gen6_wm_state.c
>  delete mode 100644 src/mesa/drivers/dri/i965/gen7_ds_state.c
>  delete mode 100644 src/mesa/drivers/dri/i965/gen7_hs_state.c

Shouldn't gen7_upload_constant_state() in gen6_constant_state.c get
deleted in this patch?

> @@ -1752,6 +1764,145 @@ static const struct brw_tracked_state genX(scissor_state) = {
>     .emit = genX(upload_scissor_state),
>  };
>  
> +#if GEN_GEN >= 7
> +UNUSED static const uint32_t push_constant_opcodes[] = {
> +   [MESA_SHADER_VERTEX]                      = 21,
> +   [MESA_SHADER_TESS_CTRL]                   = 25, /* HS */
> +   [MESA_SHADER_TESS_EVAL]                   = 26, /* DS */
> +   [MESA_SHADER_GEOMETRY]                    = 22,
> +   [MESA_SHADER_FRAGMENT]                    = 23,
> +   [MESA_SHADER_COMPUTE]                     = 0,
> +};
> +
> +static void
> +upload_constant_state(struct brw_context *brw,
> +                      struct brw_stage_state *stage_state,
> +                      bool active, uint32_t stage)
> +{
> +   UNUSED uint32_t mocs = GEN_GEN < 8 ? GEN7_MOCS_L3 : 0;
> +   active = active && stage_state->push_const_size != 0;
> +
> +   brw_batch_emit(brw, GENX(3DSTATE_CONSTANT_VS), pkt) {
> +      pkt._3DCommandSubOpcode = push_constant_opcodes[stage];
> +      if (active) {
> +#if GEN_GEN >= 9
> +         pkt.ConstantBody.ConstantBuffer2ReadLength =
> +            stage_state->push_const_size;
> +         pkt.ConstantBody.PointerToConstantBuffer2 =
> +            render_ro_bo(
> +               brw->batch.bo, stage_state->push_const_offset);

I don't think you need to line-wrap this.

> +#else
> +         pkt.ConstantBody.ConstantBuffer0ReadLength =
> +            stage_state->push_const_size;
> +         pkt.ConstantBody.PointerToConstantBuffer0.offset =
> +            stage_state->push_const_offset | mocs;
> +#endif
> +      }
> +   }
> +
> +   brw->ctx.NewDriverState |= GEN_GEN >= 9 ? BRW_NEW_SURFACES : 0;
> +}
> +#endif
> +
> +static void
> +genX(upload_vs_push_constants)(struct brw_context *brw)
> +{
> +   struct brw_stage_state *stage_state = &brw->vs.base;
> +
> +   /* _BRW_NEW_VERTEX_PROGRAM */
> +   const struct brw_program *vp = brw_program_const(brw->vertex_program);
> +   /* BRW_NEW_VS_PROG_DATA */
> +   const struct brw_stage_prog_data *prog_data = brw->vs.base.prog_data;
> +
> +   _mesa_shader_write_subroutine_indices(&brw->ctx, MESA_SHADER_VERTEX);
> +   gen6_upload_push_constants(brw, &vp->program, prog_data, stage_state);
> +
> +#if GEN_GEN >= 7
> +   if (brw->gen == 7 && !brw->is_haswell && !brw->is_baytrail)

   if (GEN_GEN == 7 && !GEN_IS_HASWELL && !brw->is_baytrail)

> +      gen7_emit_vs_workaround_flush(brw);
> +
> +   upload_constant_state(brw, stage_state, true /* active */,
> +                         MESA_SHADER_VERTEX);
> +#endif
> +}

With the old code deleted,
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170503/19372686/attachment.sig>


More information about the mesa-dev mailing list