zink: fix enabled vertex buffer mask calculation
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Wed, 15 Sep 2021 14:50:03 +0000 (10:50 -0400)
committerMarge Bot <eric+marge@anholt.net>
Thu, 16 Sep 2021 01:43:40 +0000 (01:43 +0000)
the mask can't entirely be calculated based on the integer parameters,
as it's possible for some of the "bind" slots to actually be unbinds,
so remove bits as necessary to fix this

also add some debug asserts to ensure I don't break this again for the
tenth time

Fixes: 6dd02a5139a ("zink: stop using util_set_vertex_buffers_mask()")

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12871>

src/gallium/drivers/zink/zink_context.c

index d35332d..1f97c14 100644 (file)
@@ -938,7 +938,8 @@ zink_set_vertex_buffers(struct pipe_context *pctx,
             zink_resource_buffer_barrier(ctx, res, VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT,
                                          VK_PIPELINE_STAGE_VERTEX_INPUT_BIT);
             set_vertex_buffer_clamped(ctx, start_slot + i);
-         }
+         } else
+            enabled_buffers &= ~BITFIELD_BIT(i);
       }
    } else {
       if (need_state_change)
@@ -954,6 +955,10 @@ zink_set_vertex_buffers(struct pipe_context *pctx,
    }
    ctx->gfx_pipeline_state.vertex_buffers_enabled_mask = enabled_buffers;
    ctx->vertex_buffers_dirty = num_buffers > 0;
+#ifndef NDEBUG
+   u_foreach_bit(b, enabled_buffers)
+      assert(ctx->vertex_buffers[b].buffer.resource);
+#endif
 }
 
 static void