mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 19:40:10 +01:00
asahi: Split RASTERIZER into constituent words
As done in the PowerVR driver. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18421>
This commit is contained in:
parent
f9057cea51
commit
d93878f77a
3 changed files with 70 additions and 59 deletions
|
|
@ -325,34 +325,47 @@
|
|||
<field name="Clamp" size="32" start="2:0" type="float"/>
|
||||
</struct>
|
||||
|
||||
<struct name="Rasterizer face" size="8">
|
||||
<field name="Stencil reference" size="8" start="0:0" type="hex"/>
|
||||
<struct name="Fragment face">
|
||||
<field name="Stencil reference" size="8" start="0" type="hex"/>
|
||||
<!-- line width is 4:4 fixed point with off-by-one applied -->
|
||||
<field name="Line width" size="8" start="0:8" type="hex"/>
|
||||
<field name="Polygon mode" size="2" start="0:18" type="Polygon Mode"/>
|
||||
<field name="Disable depth write" size="1" start="0:21" type="bool"/>
|
||||
<field name="Unk - visibility test internal" size="2" start="0:22" type="hex"/>
|
||||
<field name="Depth function" size="3" start="0:24" type="ZS Func"/>
|
||||
<field name="Stencil write mask" size="8" start="1:0" type="hex"/>
|
||||
<field name="Stencil read mask" size="8" start="1:8" type="hex"/>
|
||||
<field name="Depth pass" size="3" start="1:16" type="Stencil Op"/>
|
||||
<field name="Depth fail" size="3" start="1:19" type="Stencil Op"/>
|
||||
<field name="Stencil fail" size="3" start="1:22" type="Stencil Op"/>
|
||||
<field name="Stencil compare" size="3" start="1:25" type="ZS Func"/>
|
||||
<field name="Line width" size="8" start="8" type="hex"/>
|
||||
<field name="Polygon mode" size="2" start="18" type="Polygon Mode"/>
|
||||
<field name="Disable depth write" size="1" start="21" type="bool"/>
|
||||
<field name="Unk - visibility test internal" size="2" start="22" type="hex"/>
|
||||
<field name="Depth function" size="3" start="24" type="ZS Func"/>
|
||||
</struct>
|
||||
|
||||
<struct name="Fragment stencil" size="8">
|
||||
<field name="Write mask" size="8" start="0" type="hex"/>
|
||||
<field name="Read mask" size="8" start="8" type="hex"/>
|
||||
<field name="Depth pass" size="3" start="16" type="Stencil Op"/>
|
||||
<field name="Depth fail" size="3" start="19" type="Stencil Op"/>
|
||||
<field name="Stencil fail" size="3" start="22" type="Stencil Op"/>
|
||||
<field name="Compare" size="3" start="25" type="ZS Func"/>
|
||||
</struct>
|
||||
|
||||
<struct name="Fragment control">
|
||||
<field name="Unk 1" size="1" start="9" type="hex" default="0x1"/>
|
||||
<field name="Visibility mode" size="2" start="14" type="Visibility Mode"/>
|
||||
<field name="Scissor enable" size="1" start="16" type="bool"/>
|
||||
<field name="Depth bias enable" size="1" start="17" type="bool"/>
|
||||
<field name="Stencil test enable" size="1" start="18" type="bool"/>
|
||||
<field name="Two-sided stencil" size="1" start="19" type="bool"/>
|
||||
<field name="Unk fill lines" size="1" start="26" type="hex" default="0x0"/> <!-- set when drawing LINES -->
|
||||
</struct>
|
||||
|
||||
<struct name="Fragment occlusion query">
|
||||
<field name="Offset" size="18" start="14" type="uint"/>
|
||||
</struct>
|
||||
|
||||
<struct name="Rasterizer" size="28">
|
||||
<field name="Tag" size="32" start="0:0" type="hex" default="0x10000b5"/>
|
||||
<field name="Unk 1" size="1" start="1:9" type="hex" default="0x1"/>
|
||||
<field name="Visibility mode" size="2" start="1:14" type="Visibility Mode"/>
|
||||
<field name="Scissor enable" size="1" start="1:16" type="bool"/>
|
||||
<field name="Depth bias enable" size="1" start="1:17" type="bool"/>
|
||||
<field name="Stencil test enable" size="1" start="1:18" type="bool"/>
|
||||
<field name="Two-sided stencil" size="1" start="1:19" type="bool"/>
|
||||
<field name="Unk fill lines" size="1" start="1:26" type="hex" default="0x0"/> <!-- set when drawing LINES -->
|
||||
<field name="Front" size="64" start="2:0" type="Rasterizer face"/>
|
||||
<field name="Back" size="64" start="4:0" type="Rasterizer face"/>
|
||||
<field name="Visibility buffer offset" size="18" start="6:14" type="uint"/>
|
||||
<field name="Common" size="32" start="1:0" type="Fragment control"/>
|
||||
<field name="Front" size="32" start="2:0" type="Fragment face"/>
|
||||
<field name="Front stencil" size="32" start="3:0" type="Fragment stencil"/>
|
||||
<field name="Back" size="32" start="4:0" type="Fragment face"/>
|
||||
<field name="Back stencil" size="32" start="5:0" type="Fragment stencil"/>
|
||||
<field name="Occlusion query" size="32" start="6:0" type="Fragment occlusion query"/>
|
||||
</struct>
|
||||
|
||||
<struct name="Unknown face" size="4">
|
||||
|
|
|
|||
|
|
@ -182,33 +182,28 @@ static const enum agx_stencil_op agx_stencil_ops[PIPE_STENCIL_OP_INVERT + 1] = {
|
|||
};
|
||||
|
||||
static void
|
||||
agx_pack_rasterizer_face(struct agx_rasterizer_face_packed *out,
|
||||
struct pipe_stencil_state st,
|
||||
enum agx_zs_func z_func,
|
||||
bool disable_z_write)
|
||||
agx_pack_stencil(struct agx_fragment_stencil_packed *out,
|
||||
struct pipe_stencil_state st)
|
||||
{
|
||||
agx_pack(out, RASTERIZER_FACE, cfg) {
|
||||
cfg.depth_function = z_func;
|
||||
cfg.disable_depth_write = disable_z_write;
|
||||
|
||||
if (st.enabled) {
|
||||
cfg.stencil_write_mask = st.writemask;
|
||||
cfg.stencil_read_mask = st.valuemask;
|
||||
if (st.enabled) {
|
||||
agx_pack(out, FRAGMENT_STENCIL, cfg) {
|
||||
cfg.compare = (enum agx_zs_func) st.func;
|
||||
cfg.write_mask = st.writemask;
|
||||
cfg.read_mask = st.valuemask;
|
||||
|
||||
cfg.depth_pass = agx_stencil_ops[st.zpass_op];
|
||||
cfg.depth_fail = agx_stencil_ops[st.zfail_op];
|
||||
cfg.stencil_fail = agx_stencil_ops[st.fail_op];
|
||||
|
||||
cfg.stencil_compare = (enum agx_zs_func) st.func;
|
||||
} else {
|
||||
cfg.stencil_write_mask = 0xFF;
|
||||
cfg.stencil_read_mask = 0xFF;
|
||||
}
|
||||
} else {
|
||||
agx_pack(out, FRAGMENT_STENCIL, cfg) {
|
||||
cfg.compare = AGX_ZS_FUNC_ALWAYS;
|
||||
cfg.write_mask = 0xFF;
|
||||
cfg.read_mask = 0xFF;
|
||||
|
||||
cfg.depth_pass = AGX_STENCIL_OP_KEEP;
|
||||
cfg.depth_fail = AGX_STENCIL_OP_KEEP;
|
||||
cfg.stencil_fail = AGX_STENCIL_OP_KEEP;
|
||||
|
||||
cfg.stencil_compare = AGX_ZS_FUNC_ALWAYS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -232,18 +227,20 @@ agx_create_zsa_state(struct pipe_context *ctx,
|
|||
STATIC_ASSERT((enum agx_zs_func) PIPE_FUNC_GEQUAL == AGX_ZS_FUNC_GEQUAL);
|
||||
STATIC_ASSERT((enum agx_zs_func) PIPE_FUNC_ALWAYS == AGX_ZS_FUNC_ALWAYS);
|
||||
|
||||
enum agx_zs_func z_func = state->depth_enabled ?
|
||||
((enum agx_zs_func) state->depth_func) : AGX_ZS_FUNC_ALWAYS;
|
||||
agx_pack(&so->depth, FRAGMENT_FACE, cfg) {
|
||||
cfg.depth_function = state->depth_enabled ?
|
||||
((enum agx_zs_func) state->depth_func) : AGX_ZS_FUNC_ALWAYS;
|
||||
|
||||
agx_pack_rasterizer_face(&so->front,
|
||||
state->stencil[0], z_func, !state->depth_writemask);
|
||||
cfg.disable_depth_write = !state->depth_writemask;
|
||||
}
|
||||
|
||||
agx_pack_stencil(&so->front_stencil, state->stencil[0]);
|
||||
|
||||
if (state->stencil[1].enabled) {
|
||||
agx_pack_rasterizer_face(&so->back,
|
||||
state->stencil[1], z_func, !state->depth_writemask);
|
||||
agx_pack_stencil(&so->back_stencil, state->stencil[1]);
|
||||
} else {
|
||||
/* One sided stencil */
|
||||
so->back = so->front;
|
||||
so->back_stencil = so->front_stencil;
|
||||
}
|
||||
|
||||
return so;
|
||||
|
|
@ -1496,34 +1493,34 @@ demo_rasterizer(struct agx_context *ctx, struct agx_pool *pool, bool is_points)
|
|||
struct agx_rasterizer_packed out;
|
||||
|
||||
agx_pack(&out, RASTERIZER, cfg) {
|
||||
cfg.stencil_test_enable = ctx->zs->base.stencil[0].enabled;
|
||||
cfg.two_sided_stencil = ctx->zs->base.stencil[1].enabled;
|
||||
cfg.common.stencil_test_enable = ctx->zs->base.stencil[0].enabled;
|
||||
cfg.common.two_sided_stencil = ctx->zs->base.stencil[1].enabled;
|
||||
|
||||
cfg.front.stencil_reference = ctx->stencil_ref.ref_value[0];
|
||||
cfg.back.stencil_reference = cfg.two_sided_stencil ?
|
||||
cfg.back.stencil_reference = cfg.common.two_sided_stencil ?
|
||||
ctx->stencil_ref.ref_value[1] :
|
||||
cfg.front.stencil_reference;
|
||||
|
||||
cfg.front.line_width = cfg.back.line_width = rast->line_width;
|
||||
cfg.front.polygon_mode = cfg.back.polygon_mode = AGX_POLYGON_MODE_FILL;
|
||||
|
||||
cfg.unk_fill_lines = is_points; /* XXX: what is this? */
|
||||
cfg.common.unk_fill_lines = is_points; /* XXX: what is this? */
|
||||
|
||||
/* Always enable scissoring so we may scissor to the viewport (TODO:
|
||||
* optimize this out if the viewport is the default and the app does not
|
||||
* use the scissor test) */
|
||||
cfg.scissor_enable = true;
|
||||
cfg.common.scissor_enable = true;
|
||||
|
||||
cfg.depth_bias_enable = rast->base.offset_tri;
|
||||
cfg.common.depth_bias_enable = rast->base.offset_tri;
|
||||
};
|
||||
|
||||
/* Words 2-3: front */
|
||||
out.opaque[2] |= ctx->zs->front.opaque[0];
|
||||
out.opaque[3] |= ctx->zs->front.opaque[1];
|
||||
out.opaque[2] |= ctx->zs->depth.opaque[0];
|
||||
out.opaque[3] |= ctx->zs->front_stencil.opaque[0];
|
||||
|
||||
/* Words 4-5: back */
|
||||
out.opaque[4] |= ctx->zs->back.opaque[0];
|
||||
out.opaque[5] |= ctx->zs->back.opaque[1];
|
||||
out.opaque[4] |= ctx->zs->depth.opaque[0];
|
||||
out.opaque[5] |= ctx->zs->back_stencil.opaque[0];
|
||||
|
||||
return agx_pool_upload_aligned(pool, &out, sizeof(out), 64);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,7 +117,8 @@ struct agx_batch {
|
|||
|
||||
struct agx_zsa {
|
||||
struct pipe_depth_stencil_alpha_state base;
|
||||
struct agx_rasterizer_face_packed front, back;
|
||||
struct agx_fragment_face_packed depth;
|
||||
struct agx_fragment_stencil_packed front_stencil, back_stencil;
|
||||
};
|
||||
|
||||
struct agx_blend {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue