- if (vbuf_count > 0) {
- /* If we haven't yet emitted a drawing command or if any
- * vertex buffer state is changing, issue that state now.
+
+ /* If we haven't yet emitted a drawing command or if any
+ * vertex buffer state is changing, issue that state now.
+ */
+ if (rebind_vbuf ||
+ ((hwtnl->cmd.swc->hints & SVGA_HINT_FLAG_CAN_PRE_FLUSH) == 0) ||
+ vbuf_count != svga->state.hw_draw.num_vbuffers ||
+ memcmp(vbuffer_attrs, svga->state.hw_draw.vbuffer_attrs,
+ vbuf_count * sizeof(vbuffer_attrs[0])) ||
+ memcmp(vbuffers, svga->state.hw_draw.vbuffers,
+ vbuf_count * sizeof(vbuffers[0]))) {
+
+ unsigned num_vbuffers;
+
+ /* get the max of the current bound vertex buffers count and
+ * the to-be-bound vertex buffers count, so as to unbind
+ * the unused vertex buffers.