[Mesa-dev] [PATCH v02 18/37] i965: Port Gen6+ DEPTH_STENCIL state to genxml.
Kenneth Graunke
kenneth at whitecape.org
Tue Apr 25 22:58:09 UTC 2017
On Monday, April 24, 2017 3:19:13 PM PDT Rafael Antognolli wrote:
[snip]
> diff --git a/src/mesa/drivers/dri/i965/genX_state_upload.c b/src/mesa/drivers/dri/i965/genX_state_upload.c
> index b9e207d..ff28cf5 100644
> --- a/src/mesa/drivers/dri/i965/genX_state_upload.c
> +++ b/src/mesa/drivers/dri/i965/genX_state_upload.c
> @@ -30,6 +30,9 @@
> #include "brw_state.h"
>
> #include "intel_batchbuffer.h"
> +#include "intel_fbo.h"
> +
> +#include "main/stencil.h"
>
> UNUSED static void *
> emit_dwords(struct brw_context *brw, unsigned n)
> @@ -98,9 +101,9 @@ __gen_combine_address(struct brw_context *brw, void *location,
> _dw + 1; /* Array starts at dw[1] */ \
> })
>
> -#define brw_state_emit(brw, cmd, aub, align, offset, name) \
> +#define brw_state_emit(brw, cmd, align, offset, name) \
> for (struct cmd name = { 0, }, \
> - *_dst = brw_state_batch(brw, aub,_brw_cmd_length(cmd) * 4, \
> + *_dst = brw_state_batch(brw, _brw_cmd_length(cmd) * 4, \
> align, offset); \
> __builtin_expect(_dst != NULL, 1); \
> _brw_cmd_pack(cmd)(brw, (void *)_dst, &name), \
Thus hunk should go in patch 15.
> @@ -108,9 +111,105 @@ __gen_combine_address(struct brw_context *brw, void *location,
>
> /* ---------------------------------------------------------------------- */
>
> +#if GEN_GEN >= 6
>
> /* ---------------------------------------------------------------------- */
>
> +static void
> +genX(upload_depth_stencil_state)(struct brw_context *brw)
> +{
> + struct gl_context *ctx = &brw->ctx;
> +
> + /* _NEW_BUFFERS */
> + struct intel_renderbuffer *depth_irb =
> + intel_get_renderbuffer(ctx->DrawBuffer, BUFFER_DEPTH);
> +
> + /* _NEW_DEPTH */
> + struct gl_depthbuffer_attrib *depth = &ctx->Depth;
> +
> + /* _NEW_STENCIL */
> + struct gl_stencil_attrib *stencil = &ctx->Stencil;
> + const int b = stencil->_BackFace;
> +
> +#if GEN_GEN >= 8
> + brw_batch_emit(brw, GENX(3DSTATE_WM_DEPTH_STENCIL), wmds) {
> +#else
> + uint32_t ds_offset;
> + brw_state_emit(brw, GENX(DEPTH_STENCIL_STATE), 64, &ds_offset, wmds) {
> +#endif
> + if (depth->Test && depth_irb) {
> + wmds.DepthTestEnable = true;
> + wmds.DepthBufferWriteEnable = brw_depth_writes_enabled(brw);
> + wmds.DepthTestFunction = intel_translate_compare_func(depth->Func);
> + }
> +
> + if (stencil->_Enabled) {
> + wmds.StencilTestEnable = true;
> + wmds.StencilWriteMask = stencil->WriteMask[0] & 0xff;
> + wmds.StencilTestMask = stencil->ValueMask[0] & 0xff;
> +
> + wmds.StencilTestFunction =
> + intel_translate_compare_func(stencil->Function[0]);
> + wmds.StencilFailOp =
> + intel_translate_stencil_op(stencil->FailFunc[0]);
> + wmds.StencilPassDepthPassOp =
> + intel_translate_stencil_op(stencil->ZPassFunc[0]);
> + wmds.StencilPassDepthFailOp =
> + intel_translate_stencil_op(stencil->ZFailFunc[0]);
> +
> + wmds.StencilBufferWriteEnable = stencil->_WriteEnabled;
> +
> + if (stencil->_TestTwoSide) {
> + wmds.DoubleSidedStencilEnable = true;
> + wmds.BackfaceStencilWriteMask = stencil->WriteMask[b] & 0xff;
> + wmds.BackfaceStencilTestMask = stencil->ValueMask[b] & 0xff;
> +
> + wmds.BackfaceStencilTestFunction =
> + intel_translate_compare_func(stencil->Function[b]);
> + wmds.BackfaceStencilFailOp =
> + intel_translate_stencil_op(stencil->FailFunc[b]);
> + wmds.BackfaceStencilPassDepthPassOp =
> + intel_translate_stencil_op(stencil->ZPassFunc[b]);
> + wmds.BackfaceStencilPassDepthFailOp =
> + intel_translate_stencil_op(stencil->ZFailFunc[b]);
> + }
> +
> +#if GEN_GEN >= 9
> + wmds.StencilReferenceValue = _mesa_get_stencil_ref(ctx, 0);
> + wmds.BackfaceStencilReferenceValue = _mesa_get_stencil_ref(ctx, b);
> +#endif
> + }
> + }
> +
> +#if GEN_GEN == 6
> + brw_batch_emit(brw, GENX(3DSTATE_CC_STATE_POINTERS), ptr) {
> + ptr.PointertoDEPTH_STENCIL_STATE = ds_offset;
> + ptr.DEPTH_STENCIL_STATEChange = true;
> + }
> +#elif GEN_GEN == 7
> + brw_batch_emit(brw, GENX(3DSTATE_DEPTH_STENCIL_STATE_POINTERS), ptr) {
> + ptr.PointertoDEPTH_STENCIL_STATE = ds_offset;
> + }
> +#endif
> +}
> +
> +static const struct brw_tracked_state genX(depth_stencil_state) = {
> + .dirty = {
> + .mesa = _NEW_BUFFERS |
> + _NEW_DEPTH |
> + _NEW_STENCIL,
> + .brw = BRW_NEW_BLORP |
> + (GEN_GEN >= 8 ? BRW_NEW_CONTEXT
> + : BRW_NEW_BLORP |
> + BRW_NEW_STATE_BASE_ADDRESS),
I made a mistake here, I wrote BRW_NEW_BLORP twice instead of
BRW_NEW_BATCH. It should be:
.brw = BRW_NEW_BLORP |
(GEN_GEN >= 8 ? BRW_NEW_CONTEXT
: BRW_NEW_BATCH |
BRW_NEW_STATE_BASE_ADDRESS),
Otherwise this patch looks good to me.
-------------- 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/20170425/ec734c5e/attachment.sig>
More information about the mesa-dev
mailing list