From 7d7e94066da4b7f04af98d9c314d080af53c79a8 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Tue, 1 Nov 2022 14:08:09 +0100 Subject: [PATCH] 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 Part-of: --- src/freedreno/ci/traces-freedreno.yml | 2 +- src/gallium/drivers/zink/zink_draw.cpp | 35 ++++++++++++++++++++++---- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/freedreno/ci/traces-freedreno.yml b/src/freedreno/ci/traces-freedreno.yml index 18cdb0ed30f..6e9c267596f 100644 --- a/src/freedreno/ci/traces-freedreno.yml +++ b/src/freedreno/ci/traces-freedreno.yml @@ -459,7 +459,7 @@ traces: freedreno-a630: checksum: 0a6a16c394a413f02ec2ebcc3251e366 zink-a630: - checksum: 42ec4a9cae7fe1eac6f8472269140fe5 + checksum: 0a6a16c394a413f02ec2ebcc3251e366 gputest/tessmark-v2.trace: freedreno-a306: diff --git a/src/gallium/drivers/zink/zink_draw.cpp b/src/gallium/drivers/zink/zink_draw.cpp index f67f72454f3..40844d27995 100644 --- a/src/gallium/drivers/zink/zink_draw.cpp +++ b/src/gallium/drivers/zink/zink_draw.cpp @@ -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 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) {