zink: consider polygon-mode for rast_prim

But because polygon-offset needs to consider the primitive-type *before*
overriding the type, add a zink_prim_type()-helper for the partially
resolved state.

Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19438>
This commit is contained in:
Erik Faye-Lund
2022-11-01 14:08:09 +01:00
committed by Marge Bot
parent 1859941768
commit 7d7e94066d
2 changed files with 31 additions and 6 deletions

View File

@@ -459,7 +459,7 @@ traces:
freedreno-a630:
checksum: 0a6a16c394a413f02ec2ebcc3251e366
zink-a630:
checksum: 42ec4a9cae7fe1eac6f8472269140fe5
checksum: 0a6a16c394a413f02ec2ebcc3251e366
gputest/tessmark-v2.trace:
freedreno-a306:

View File

@@ -360,7 +360,7 @@ update_gfx_pipeline(struct zink_context *ctx, struct zink_batch_state *bs, enum
}
static enum pipe_prim_type
zink_rast_prim(const struct zink_context *ctx,
zink_prim_type(const struct zink_context *ctx,
const struct pipe_draw_info *dinfo)
{
if (ctx->gfx_pipeline_state.shader_rast_prim != PIPE_PRIM_MAX)
@@ -369,6 +369,28 @@ zink_rast_prim(const struct zink_context *ctx,
return u_reduced_prim((enum pipe_prim_type)dinfo->mode);
}
static enum pipe_prim_type
zink_rast_prim(const struct zink_context *ctx,
const struct pipe_draw_info *dinfo)
{
enum pipe_prim_type prim_type = zink_prim_type(ctx, dinfo);
assert(prim_type != PIPE_PRIM_MAX);
if (prim_type == PIPE_PRIM_TRIANGLES &&
ctx->rast_state->base.fill_front != PIPE_POLYGON_MODE_FILL) {
switch(ctx->rast_state->base.fill_front) {
case PIPE_POLYGON_MODE_POINT:
return PIPE_PRIM_POINTS;
case PIPE_POLYGON_MODE_LINE:
return PIPE_PRIM_LINES;
default:
unreachable("unexpected polygon mode");
}
}
return prim_type;
}
template <zink_multidraw HAS_MULTIDRAW, zink_dynamic_state DYNAMIC_STATE, bool BATCH_CHANGED, bool DRAW_STATE>
void
zink_draw(struct pipe_context *pctx,
@@ -503,7 +525,9 @@ zink_draw(struct pipe_context *pctx,
zink_set_last_vertex_key(ctx)->push_drawid = drawid_broken;
bool rast_prim_changed = false;
if (mode_changed || ctx->gfx_pipeline_state.modules_changed) {
bool rast_state_changed = ctx->rast_state_changed;
if (mode_changed || ctx->gfx_pipeline_state.modules_changed ||
rast_state_changed) {
enum pipe_prim_type rast_prim = zink_rast_prim(ctx, dinfo);
if (rast_prim != ctx->gfx_pipeline_state.rast_prim) {
bool points_changed =
@@ -641,7 +665,6 @@ zink_draw(struct pipe_context *pctx,
}
ctx->dsa_state_changed = false;
bool rast_state_changed = ctx->rast_state_changed;
if (DYNAMIC_STATE != ZINK_NO_DYNAMIC_STATE && (BATCH_CHANGED || rast_state_changed)) {
VKCTX(CmdSetFrontFaceEXT)(batch->state->cmdbuf, (VkFrontFace)ctx->gfx_pipeline_state.dyn_state1.front_face);
VKCTX(CmdSetCullModeEXT)(batch->state->cmdbuf, ctx->gfx_pipeline_state.dyn_state1.cull_mode);
@@ -685,9 +708,11 @@ zink_draw(struct pipe_context *pctx,
VKCTX(CmdSetLineWidth)(batch->state->cmdbuf, rast_state->line_width);
}
if (BATCH_CHANGED || rast_state_changed || rast_prim_changed) {
if (BATCH_CHANGED || mode_changed ||
ctx->gfx_pipeline_state.modules_changed ||
rast_state_changed) {
bool depth_bias =
ctx->gfx_pipeline_state.rast_prim == PIPE_PRIM_TRIANGLES &&
zink_prim_type(ctx, dinfo) == PIPE_PRIM_TRIANGLES &&
rast_state->offset_fill;
if (depth_bias) {