vtest: add support for sending caps v2 (v1.1)

I've come up with a workaround on the mesa side that should be
backwards compatible with old vtests and vice-versa.

It involves sending both caps 2 and 1 queries back to back,
and taking the first response an indication of what to expect,

v1.1: Check max_size is > 0 before mallocing

Reviewed-by: Jakob Bornecrantz <jakob@collabora.com>
macos/master
Dave Airlie 7 years ago
parent 4b19c86de1
commit febede1955
  1. 2
      vtest/vtest.h
  2. 2
      vtest/vtest_protocol.h
  3. 31
      vtest/vtest_renderer.c
  4. 3
      vtest/vtest_server.c

@ -28,7 +28,7 @@
int vtest_create_renderer(int in_fd, int out_fd, uint32_t length);
int vtest_send_caps(void);
int vtest_send_caps2(void);
int vtest_create_resource(void);
int vtest_resource_unref(void);
int vtest_submit_cmd(uint32_t length_dw);

@ -48,6 +48,8 @@
/* pass the process cmd line for debugging */
#define VCMD_CREATE_RENDERER 8
#define VCMD_GET_CAPS2 9
/* get caps */
/* 0 length cmd */
/* resp VCMD_GET_CAPS + caps */

@ -154,6 +154,37 @@ void vtest_destroy_renderer(void)
renderer.out_fd = -1;
}
int vtest_send_caps2(void)
{
uint32_t hdr_buf[2];
void *caps_buf;
int ret;
uint32_t max_ver, max_size;
virgl_renderer_get_cap_set(2, &max_ver, &max_size);
if (max_size == 0)
return -1;
caps_buf = malloc(max_size);
if (!caps_buf)
return -1;
virgl_renderer_fill_caps(2, 1, caps_buf);
hdr_buf[0] = max_size + 1;
hdr_buf[1] = 2;
ret = vtest_block_write(renderer.out_fd, hdr_buf, 8);
if (ret < 0)
goto end;
vtest_block_write(renderer.out_fd, caps_buf, max_size);
if (ret < 0)
goto end;
end:
free(caps_buf);
return 0;
}
int vtest_send_caps(void)
{
uint32_t max_ver, max_size;

@ -129,6 +129,9 @@ again:
vtest_renderer_create_fence();
ret = vtest_resource_busy_wait();
break;
case VCMD_GET_CAPS2:
ret = vtest_send_caps2();
break;
default:
break;
}

Loading…
Cancel
Save