virgl: resize resource bo allocation if we need to.
authorDave Airlie <airlied@redhat.com>
Mon, 12 Mar 2018 00:21:21 +0000 (10:21 +1000)
committerDave Airlie <airlied@redhat.com>
Thu, 15 Mar 2018 02:26:39 +0000 (12:26 +1000)
This fixes an illegal command buffer on the host seen with
piglit arb_internalformat_query2-max-dimensions

Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c

index 77854680e59c8d77b5158b9f0ba5707a81f884a7..cf3c3bac4b4cbf01a070258fdabd766c3f7e8cb8 100644 (file)
@@ -620,8 +620,12 @@ static void virgl_drm_add_res(struct virgl_drm_winsys *qdws,
    unsigned hash = res->res_handle & (sizeof(cbuf->is_handle_added)-1);
 
    if (cbuf->cres > cbuf->nres) {
-      fprintf(stderr,"failure to add relocation\n");
-      return;
+      cbuf->nres += 256;
+      cbuf->res_bo = realloc(cbuf->res_bo, cbuf->nres * sizeof(struct virgl_hw_buf*));
+      if (!cbuf->res_bo) {
+          fprintf(stderr,"failure to add relocation %d, %d\n", cbuf->cres, cbuf->nres);
+          return;
+      }
    }
 
    cbuf->res_bo[cbuf->cres] = NULL;
index f62d0d0981dd162f26f835d77f646b8d1b827dca..9a96c6eb83f5753b66eaba04f34b4b231b5c8bc2 100644 (file)
@@ -460,8 +460,12 @@ static void virgl_vtest_add_res(struct virgl_vtest_winsys *vtws,
    unsigned hash = res->res_handle & (sizeof(cbuf->is_handle_added)-1);
 
    if (cbuf->cres > cbuf->nres) {
-      fprintf(stderr,"failure to add relocation\n");
-      return;
+      cbuf->nres += 256;
+      cbuf->res_bo = realloc(cbuf->res_bo, cbuf->nres * sizeof(struct virgl_hw_buf*));
+      if (!cbuf->res_bo) {
+          fprintf(stderr,"failure to add relocation %d, %d\n", cbuf->cres, cbuf->nres);
+          return;
+      }
    }
 
    cbuf->res_bo[cbuf->cres] = NULL;