zink: fix VK_DYNAMIC_STATE_LINE_WIDTH usage
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Wed, 25 Jan 2023 14:24:16 +0000 (09:24 -0500)
committerEric Engestrom <eric@engestrom.ch>
Thu, 26 Jan 2023 15:40:35 +0000 (15:40 +0000)
add a special tracker here to set the state only when necessary

Fixes: 659c39fafbb ("zink: rework primitive rasterization type logic")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20886>
(cherry picked from commit 06a125942bef6a03a12b67f691ab4ad86e49c2df)

.pick_status.json
src/gallium/drivers/zink/zink_draw.cpp
src/gallium/drivers/zink/zink_state.c
src/gallium/drivers/zink/zink_types.h

index 03036e5..5a3d3d3 100644 (file)
         "description": "zink: fix VK_DYNAMIC_STATE_LINE_WIDTH usage",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "659c39fafbb53e27e6816fa872ac6eb78772e519"
     },
index 035e20b..2188407 100644 (file)
@@ -703,9 +703,11 @@ zink_draw(struct pipe_context *pctx,
       }
    }
 
-   if ((BATCH_CHANGED || rast_state_changed || rast_prim_changed) &&
-       ctx->gfx_pipeline_state.rast_prim == PIPE_PRIM_LINES) {
+   if (BATCH_CHANGED ||
+       /* only re-emit on non-batch change when actually drawing lines */
+       ((ctx->line_width_changed || rast_prim_changed) && ctx->gfx_pipeline_state.rast_prim == PIPE_PRIM_LINES)) {
       VKCTX(CmdSetLineWidth)(batch->state->cmdbuf, rast_state->line_width);
+      ctx->line_width_changed = false;
    }
 
    if (BATCH_CHANGED || mode_changed ||
index 1953d05..c38a06e 100644 (file)
@@ -623,6 +623,7 @@ zink_bind_rasterizer_state(struct pipe_context *pctx, void *cso)
    bool clip_halfz = ctx->rast_state ? ctx->rast_state->hw_state.clip_halfz : false;
    bool rasterizer_discard = ctx->rast_state ? ctx->rast_state->base.rasterizer_discard : false;
    bool half_pixel_center = ctx->rast_state ? ctx->rast_state->base.half_pixel_center : true;
+   float line_width = ctx->rast_state ? ctx->rast_state->base.line_width : 1.0;
    ctx->rast_state = cso;
 
    if (ctx->rast_state) {
@@ -644,6 +645,9 @@ zink_bind_rasterizer_state(struct pipe_context *pctx, void *cso)
          ctx->vp_state_changed = true;
       }
 
+      if (fabs(ctx->rast_state->base.line_width - line_width) > FLT_EPSILON)
+         ctx->line_width_changed = true;
+
       if (ctx->gfx_pipeline_state.dyn_state1.front_face != ctx->rast_state->front_face) {
          ctx->gfx_pipeline_state.dyn_state1.front_face = ctx->rast_state->front_face;
          ctx->gfx_pipeline_state.dirty |= !zink_screen(pctx->screen)->info.have_EXT_extended_dynamic_state;
index 5aa5931..93ae9ac 100644 (file)
@@ -1680,6 +1680,7 @@ struct zink_context {
    bool blend_state_changed : 1;
    bool sample_mask_changed : 1;
    bool rast_state_changed : 1;
+   bool line_width_changed : 1;
    bool dsa_state_changed : 1;
    bool stencil_ref_changed : 1;
    bool rasterizer_discard_changed : 1;