vtest: add functions to read from buffer

Signed-off-by: David Riley <davidriley@chromium.org>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
macos/master
David Riley 6 years ago committed by David Riley
parent fecb792dd4
commit 7b8b4db88b
  1. 7
      vtest/vtest.h
  2. 14
      vtest/vtest_renderer.c

@ -27,9 +27,15 @@
#include <errno.h>
struct vtest_buffer {
const void *buffer;
int size;
};
struct vtest_input {
union {
int fd;
struct vtest_buffer *buffer;
} data;
int (*read)(struct vtest_input *input, void *buf, int size);
};
@ -50,6 +56,7 @@ int vtest_transfer_put(uint32_t length_dw);
int vtest_transfer_put2(uint32_t length_dw);
int vtest_block_read(struct vtest_input *input, void *buf, int size);
int vtest_buf_read(struct vtest_input *input, void *buf, int size);
int vtest_resource_busy_wait(uint32_t length_dw);
int vtest_renderer_create_fence(void);

@ -187,6 +187,20 @@ static int vtest_send_fd(int socket_fd, int fd)
return 0;
}
int vtest_buf_read(struct vtest_input *input, void *buf, int size)
{
struct vtest_buffer *inbuf = input->data.buffer;
if (size > inbuf->size) {
return 0;
}
memcpy(buf, inbuf->buffer, size);
inbuf->buffer += size;
inbuf->size -= size;
return size;
}
int vtest_create_renderer(struct vtest_input *input, int out_fd, uint32_t length,
int ctx_flags)
{

Loading…
Cancel
Save