vws->sock_fd = sock;
virgl_vtest_send_init(vws);
vws->protocol_version = virgl_vtest_negotiate_version(vws);
+
+ /* Version 1 is deprecated. */
+ if (vws->protocol_version == 1)
+ vws->protocol_version = 0;
+
return 0;
}
{
uint32_t res_create_buf[VCMD_RES_CREATE_SIZE], vtest_hdr[VTEST_HDR_SIZE];
- if (vws->protocol_version >= 1)
+ if (vws->protocol_version >= 2)
return virgl_vtest_send_resource_create2(vws, handle, target, format,
bind, width, height, depth,
array_size, last_level,
uint32_t data_size,
uint32_t offset)
{
- if (vws->protocol_version < 1)
+ if (vws->protocol_version < 2)
return virgl_vtest_send_transfer_cmd(vws, VCMD_TRANSFER_GET, handle,
level, stride, layer_stride, box,
data_size);
uint32_t data_size,
uint32_t offset)
{
- if (vws->protocol_version < 1)
+ if (vws->protocol_version < 2)
return virgl_vtest_send_transfer_cmd(vws, VCMD_TRANSFER_PUT, handle,
level, stride, layer_stride, box,
data_size);
uint32_t data_size,
uint32_t stride,
const struct pipe_box *box,
- uint32_t format, uint32_t res_stride)
+ uint32_t format)
{
- char *ptr = data;
- uint32_t bytes_to_read = data_size;
- char dump[1024];
-
- /* Copy the date from the IOV to the target resource respecting
- * the different strides */
- for (int y = 0 ; y < box->height && bytes_to_read > 0; ++y) {
- uint32_t btr = MIN2(res_stride, bytes_to_read);
- virgl_block_read(vws->sock_fd, ptr, btr);
+ void *line;
+ void *ptr = data;
+ int hblocks = util_format_get_nblocksy(format, box->height);
+
+ line = malloc(stride);
+ while (hblocks) {
+ virgl_block_read(vws->sock_fd, line, stride);
+ memcpy(ptr, line, util_format_get_stride(format, box->width));
ptr += stride;
- bytes_to_read -= btr;
- }
-
- /* It seems that there may be extra bytes that need to be read */
- while (bytes_to_read > 0 && bytes_to_read < data_size) {
- uint32_t btr = MIN2(sizeof(dump), bytes_to_read);
- virgl_block_read(vws->sock_fd, dump, btr);
- bytes_to_read -= btr;
+ hblocks--;
}
+ free(line);
return 0;
}
size = vtest_get_transfer_size(res, box, stride, layer_stride, level,
&valid_stride);
- /* The size calculated above is the full box size, but if this box origin
- * is not zero we may have to correct the transfer size to not read past the
- * end of the resource. The correct adjustment depends on various factors
- * that are not documented, so instead of going though all the hops to get
- * the size right up-front, we just make sure we don't read past the end.
- * FIXME: figure out what it takes to actually get this right.
- */
- if (size + buf_offset > res->size)
- size = res->size - buf_offset;
-
virgl_vtest_send_transfer_put(vtws, res->res_handle,
level, stride, layer_stride,
box, size, buf_offset);
size = vtest_get_transfer_size(res, box, stride, layer_stride, level,
&valid_stride);
- /* Don't ask for more pixels than available (see above) */
- if (size + buf_offset > res->size)
- size = res->size - buf_offset;
-
virgl_vtest_send_transfer_get(vtws, res->res_handle,
level, stride, layer_stride,
box, size, buf_offset);
ptr = virgl_vtest_resource_map(vws, res);
- /* This functions seems to be using a specific transfer resource that
- * has exactly the box size and hence its src stride is equal to the target
- * stride */
virgl_vtest_recv_transfer_get_data(vtws, ptr + buf_offset, size,
- valid_stride, box, res->format, valid_stride);
+ valid_stride, box, res->format);
virgl_vtest_resource_unmap(vws, res);
return 0;
* a hardware imposed stride that is different from the IOV stride used to
* get the data. */
virgl_vtest_recv_transfer_get_data(vtws, map + offset, size, valid_stride,
- &box, res->format,
- vtws->protocol_version == 0 ? valid_stride : util_format_get_stride(res->format, res->width));
+ &box, res->format);
vtws->sws->displaytarget_unmap(vtws->sws, res->dt);
uint32_t data_size,
uint32_t stride,
const struct pipe_box *box,
- uint32_t format, uint32_t res_width);
+ uint32_t format);
int virgl_vtest_busy_wait(struct virgl_vtest_winsys *vws, int handle,
int flags);
#define VTEST_PROTOCOL
#define VTEST_DEFAULT_SOCKET_NAME "/tmp/.virgl_test"
-#define VTEST_PROTOCOL_VERSION 1
+#define VTEST_PROTOCOL_VERSION 0
/* 32-bit length field */
/* 32-bit cmd field */