virgl: Fix flush in virgl_encoder_inline_write.
authorLepton Wu <lepton@chromium.org>
Tue, 17 Jul 2018 01:56:32 +0000 (18:56 -0700)
committerDave Airlie <airlied@redhat.com>
Tue, 17 Jul 2018 04:56:25 +0000 (14:56 +1000)
The current code is buggy: if there are only 12 dwords left in cbuf,
we emit a zero data length command which will be rejected by virglrenderer.
Fix it by calling flush in this case.

Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Dave Airlie <airlied@redhat.com>
src/gallium/drivers/virgl/virgl_encode.c

index c7c6b1e7d34e3791e1a336bf1419154a797a18fd..c1af01b6fdf9382c7fc1e2adefc61732ad60698e 100644 (file)
@@ -528,7 +528,7 @@ int virgl_encoder_inline_write(struct virgl_context *ctx,
 
    left_bytes = size;
    while (left_bytes) {
-      if (ctx->cbuf->cdw + 12 > VIRGL_MAX_CMDBUF_DWORDS)
+      if (ctx->cbuf->cdw + 12 >= VIRGL_MAX_CMDBUF_DWORDS)
          ctx->base.flush(&ctx->base, NULL, 0);
 
       thispass = (VIRGL_MAX_CMDBUF_DWORDS - ctx->cbuf->cdw - 12) * 4;