diff --git a/vtest/vtest.h b/vtest/vtest.h index 73e8a2b..8b942cd 100644 --- a/vtest/vtest.h +++ b/vtest/vtest.h @@ -27,9 +27,15 @@ #include +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); diff --git a/vtest/vtest_renderer.c b/vtest/vtest_renderer.c index f5c6115..5fc705b 100644 --- a/vtest/vtest_renderer.c +++ b/vtest/vtest_renderer.c @@ -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) {