[Mesa-dev] [PATCH 07/22] intel/blorp: Emit more complete DEPTH_STENCIL state
Pohjolainen, Topi
topi.pohjolainen at gmail.com
Mon Oct 10 05:28:43 UTC 2016
On Fri, Oct 07, 2016 at 09:41:05PM -0700, Jason Ekstrand wrote:
> This should now set the pipeline up properly for doing depth and/or stencil
> clears by plumbing through depth/stencil test values.
If you like you could also say that color calculator state is now emitted
also for blorp operations without actual shader (no prog_data).
Patches 2-7 are:
Reviewed-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
>
> Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>
> ---
> src/intel/blorp/blorp_genX_exec.h | 56 +++++++++++++++++++++++++++++++--------
> src/intel/blorp/blorp_priv.h | 1 +
> 2 files changed, 46 insertions(+), 11 deletions(-)
>
> diff --git a/src/intel/blorp/blorp_genX_exec.h b/src/intel/blorp/blorp_genX_exec.h
> index 6bbabcf..d72965e 100644
> --- a/src/intel/blorp/blorp_genX_exec.h
> +++ b/src/intel/blorp/blorp_genX_exec.h
> @@ -868,11 +868,17 @@ static uint32_t
> blorp_emit_color_calc_state(struct blorp_batch *batch,
> const struct blorp_params *params)
> {
> + struct GENX(COLOR_CALC_STATE) cc = { 0 };
> +
> +#if GEN_GEN <= 8
> + cc.StencilReferenceValue = params->stencil_ref;
> +#endif
> +
> uint32_t offset;
> void *state = blorp_alloc_dynamic_state(batch, AUB_TRACE_CC_STATE,
> GENX(COLOR_CALC_STATE_length) * 4,
> 64, &offset);
> - memset(state, 0, GENX(COLOR_CALC_STATE_length) * 4);
> + GENX(COLOR_CALC_STATE_pack)(NULL, state, &cc);
>
> #if GEN_GEN >= 7
> blorp_emit(batch, GENX(3DSTATE_CC_STATE_POINTERS), sp) {
> @@ -898,16 +904,44 @@ blorp_emit_depth_stencil_state(struct blorp_batch *batch,
> struct GENX(DEPTH_STENCIL_STATE) ds = { 0 };
> #endif
>
> - ds.DepthBufferWriteEnable = params->depth.addr.buffer != NULL;
> + if (params->depth.addr.buffer) {
> + ds.DepthBufferWriteEnable = true;
>
> - /* See the following sections of the Sandy Bridge PRM, Volume 1, Part2:
> - * - 7.5.3.1 Depth Buffer Clear
> - * - 7.5.3.2 Depth Buffer Resolve
> - * - 7.5.3.3 Hierarchical Depth Buffer Resolve
> - */
> - if (params->hiz_op == BLORP_HIZ_OP_DEPTH_RESOLVE) {
> - ds.DepthTestEnable = true;
> - ds.DepthTestFunction = COMPAREFUNCTION_NEVER;
> + switch (params->hiz_op) {
> + case BLORP_HIZ_OP_NONE:
> + ds.DepthTestEnable = true;
> + ds.DepthTestFunction = COMPAREFUNCTION_ALWAYS;
> + break;
> +
> + /* See the following sections of the Sandy Bridge PRM, Volume 2, Part1:
> + * - 7.5.3.1 Depth Buffer Clear
> + * - 7.5.3.2 Depth Buffer Resolve
> + * - 7.5.3.3 Hierarchical Depth Buffer Resolve
> + */
> + case BLORP_HIZ_OP_DEPTH_RESOLVE:
> + ds.DepthTestEnable = true;
> + ds.DepthTestFunction = COMPAREFUNCTION_NEVER;
> + break;
> +
> + case BLORP_HIZ_OP_DEPTH_CLEAR:
> + case BLORP_HIZ_OP_HIZ_RESOLVE:
> + ds.DepthTestEnable = false;
> + break;
> + }
> + }
> +
> + if (params->stencil.addr.buffer) {
> + ds.StencilBufferWriteEnable = true;
> + ds.StencilTestEnable = true;
> + ds.DoubleSidedStencilEnable = false;
> +
> + ds.StencilTestFunction = COMPAREFUNCTION_ALWAYS;
> + ds.StencilPassDepthPassOp = STENCILOP_REPLACE;
> +
> + ds.StencilWriteMask = 0xff;
> +#if GEN_GEN >= 9
> + ds.StencilReferenceValue = params->stencil_ref;
> +#endif
> }
>
> #if GEN_GEN >= 8
> @@ -1163,8 +1197,8 @@ blorp_exec(struct blorp_batch *batch, const struct blorp_params *params)
>
> if (params->wm_prog_data) {
> blend_state_offset = blorp_emit_blend_state(batch, params);
> - color_calc_state_offset = blorp_emit_color_calc_state(batch, params);
> }
> + color_calc_state_offset = blorp_emit_color_calc_state(batch, params);
> depth_stencil_state_offset = blorp_emit_depth_stencil_state(batch, params);
>
> #if GEN_GEN <= 6
> diff --git a/src/intel/blorp/blorp_priv.h b/src/intel/blorp/blorp_priv.h
> index 82a7bef..e9f0124 100644
> --- a/src/intel/blorp/blorp_priv.h
> +++ b/src/intel/blorp/blorp_priv.h
> @@ -180,6 +180,7 @@ struct blorp_params
> uint32_t x1;
> uint32_t y1;
> float z;
> + uint8_t stencil_ref;
> struct brw_blorp_surface_info depth;
> struct brw_blorp_surface_info stencil;
> uint32_t depth_format;
> --
> 2.5.0.400.gff86faf
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list