From 7bac333508835776573e6f3192c819dbe4303480 Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Wed, 28 Oct 2015 09:54:15 +0000 Subject: [PATCH] winsys/virgl: rework line wrapping/indent Wrap some of the 'omg it's getting out of hand' long lines, and re-indent where things feel off. Signed-off-by: Emil Velikov Reviewed-by: Dave Airlie --- .../winsys/virgl/drm/virgl_drm_winsys.c | 83 +++++++------ .../winsys/virgl/vtest/virgl_vtest_socket.c | 13 +- .../winsys/virgl/vtest/virgl_vtest_winsys.c | 117 ++++++++++-------- .../winsys/virgl/vtest/virgl_vtest_winsys.h | 3 +- 4 files changed, 124 insertions(+), 92 deletions(-) diff --git a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c index c9cdf68c5d0..d77ebd6ca15 100644 --- a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c +++ b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c @@ -66,7 +66,8 @@ static void virgl_hw_res_destroy(struct virgl_drm_winsys *qdws, FREE(res); } -static boolean virgl_drm_resource_is_busy(struct virgl_drm_winsys *qdws, struct virgl_hw_res *res) +static boolean virgl_drm_resource_is_busy(struct virgl_drm_winsys *qdws, + struct virgl_hw_res *res) { struct drm_virtgpu_3d_wait waitcmd; int ret; @@ -159,17 +160,18 @@ static void virgl_drm_resource_reference(struct virgl_drm_winsys *qdws, *dres = sres; } -static struct virgl_hw_res *virgl_drm_winsys_resource_create(struct virgl_winsys *qws, - enum pipe_texture_target target, - uint32_t format, - uint32_t bind, - uint32_t width, - uint32_t height, - uint32_t depth, - uint32_t array_size, - uint32_t last_level, - uint32_t nr_samples, - uint32_t size) +static struct virgl_hw_res * +virgl_drm_winsys_resource_create(struct virgl_winsys *qws, + enum pipe_texture_target target, + uint32_t format, + uint32_t bind, + uint32_t width, + uint32_t height, + uint32_t depth, + uint32_t array_size, + uint32_t last_level, + uint32_t nr_samples, + uint32_t size) { struct virgl_drm_winsys *qdws = virgl_drm_winsys(qws); struct drm_virtgpu_resource_create createcmd; @@ -214,7 +216,8 @@ static struct virgl_hw_res *virgl_drm_winsys_resource_create(struct virgl_winsys static inline int virgl_is_res_compat(struct virgl_drm_winsys *qdws, struct virgl_hw_res *res, - uint32_t size, uint32_t bind, uint32_t format) + uint32_t size, uint32_t bind, + uint32_t format) { if (res->bind != bind) return 0; @@ -272,17 +275,18 @@ virgl_bo_transfer_get(struct virgl_winsys *vws, return drmIoctl(vdws->fd, DRM_IOCTL_VIRTGPU_TRANSFER_FROM_HOST, &fromhostcmd); } -static struct virgl_hw_res *virgl_drm_winsys_resource_cache_create(struct virgl_winsys *qws, - enum pipe_texture_target target, - uint32_t format, - uint32_t bind, - uint32_t width, - uint32_t height, - uint32_t depth, - uint32_t array_size, - uint32_t last_level, - uint32_t nr_samples, - uint32_t size) +static struct virgl_hw_res * +virgl_drm_winsys_resource_cache_create(struct virgl_winsys *qws, + enum pipe_texture_target target, + uint32_t format, + uint32_t bind, + uint32_t width, + uint32_t height, + uint32_t depth, + uint32_t array_size, + uint32_t last_level, + uint32_t nr_samples, + uint32_t size) { struct virgl_drm_winsys *qdws = virgl_drm_winsys(qws); struct virgl_hw_res *res, *curr_res; @@ -355,8 +359,9 @@ alloc: return res; } -static struct virgl_hw_res *virgl_drm_winsys_resource_create_handle(struct virgl_winsys *qws, - struct winsys_handle *whandle) +static struct virgl_hw_res * +virgl_drm_winsys_resource_create_handle(struct virgl_winsys *qws, + struct winsys_handle *whandle) { struct virgl_drm_winsys *qdws = virgl_drm_winsys(qws); struct drm_gem_open open_arg = {}; @@ -462,14 +467,15 @@ static boolean virgl_drm_winsys_resource_get_handle(struct virgl_winsys *qws, } static void virgl_drm_winsys_resource_unref(struct virgl_winsys *qws, - struct virgl_hw_res *hres) + struct virgl_hw_res *hres) { struct virgl_drm_winsys *qdws = virgl_drm_winsys(qws); virgl_drm_resource_reference(qdws, &hres, NULL); } -static void *virgl_drm_resource_map(struct virgl_winsys *qws, struct virgl_hw_res *res) +static void *virgl_drm_resource_map(struct virgl_winsys *qws, + struct virgl_hw_res *res) { struct virgl_drm_winsys *qdws = virgl_drm_winsys(qws); struct drm_virtgpu_map mmap_arg; @@ -493,7 +499,8 @@ static void *virgl_drm_resource_map(struct virgl_winsys *qws, struct virgl_hw_re } -static void virgl_drm_resource_wait(struct virgl_winsys *qws, struct virgl_hw_res *res) +static void virgl_drm_resource_wait(struct virgl_winsys *qws, + struct virgl_hw_res *res) { struct virgl_drm_winsys *qdws = virgl_drm_winsys(qws); struct drm_virtgpu_3d_wait waitcmd; @@ -566,7 +573,8 @@ static boolean virgl_drm_lookup_res(struct virgl_drm_cmd_buf *cbuf, } static void virgl_drm_add_res(struct virgl_drm_winsys *qdws, - struct virgl_drm_cmd_buf *cbuf, struct virgl_hw_res *res) + struct virgl_drm_cmd_buf *cbuf, + struct virgl_hw_res *res) { unsigned hash = res->res_handle & (sizeof(cbuf->is_handle_added)-1); @@ -586,7 +594,7 @@ static void virgl_drm_add_res(struct virgl_drm_winsys *qdws, } static void virgl_drm_release_all_res(struct virgl_drm_winsys *qdws, - struct virgl_drm_cmd_buf *cbuf) + struct virgl_drm_cmd_buf *cbuf) { int i; @@ -598,7 +606,8 @@ static void virgl_drm_release_all_res(struct virgl_drm_winsys *qdws, } static void virgl_drm_emit_res(struct virgl_winsys *qws, - struct virgl_cmd_buf *_cbuf, struct virgl_hw_res *res, boolean write_buf) + struct virgl_cmd_buf *_cbuf, + struct virgl_hw_res *res, boolean write_buf) { struct virgl_drm_winsys *qdws = virgl_drm_winsys(qws); struct virgl_drm_cmd_buf *cbuf = virgl_drm_cmd_buf(_cbuf); @@ -612,8 +621,8 @@ static void virgl_drm_emit_res(struct virgl_winsys *qws, } static boolean virgl_drm_res_is_ref(struct virgl_winsys *qws, - struct virgl_cmd_buf *_cbuf, - struct virgl_hw_res *res) + struct virgl_cmd_buf *_cbuf, + struct virgl_hw_res *res) { if (!res->num_cs_references) return FALSE; @@ -621,7 +630,8 @@ static boolean virgl_drm_res_is_ref(struct virgl_winsys *qws, return TRUE; } -static int virgl_drm_winsys_submit_cmd(struct virgl_winsys *qws, struct virgl_cmd_buf *_cbuf) +static int virgl_drm_winsys_submit_cmd(struct virgl_winsys *qws, + struct virgl_cmd_buf *_cbuf) { struct virgl_drm_winsys *qdws = virgl_drm_winsys(qws); struct virgl_drm_cmd_buf *cbuf = virgl_drm_cmd_buf(_cbuf); @@ -648,7 +658,8 @@ static int virgl_drm_winsys_submit_cmd(struct virgl_winsys *qws, struct virgl_cm return ret; } -static int virgl_drm_get_caps(struct virgl_winsys *vws, struct virgl_drm_caps *caps) +static int virgl_drm_get_caps(struct virgl_winsys *vws, + struct virgl_drm_caps *caps) { struct virgl_drm_winsys *vdws = virgl_drm_winsys(vws); struct drm_virtgpu_get_caps args; diff --git a/src/gallium/winsys/virgl/vtest/virgl_vtest_socket.c b/src/gallium/winsys/virgl/vtest/virgl_vtest_socket.c index e33475334ce..01ee710b8cd 100644 --- a/src/gallium/winsys/virgl/vtest/virgl_vtest_socket.c +++ b/src/gallium/winsys/virgl/vtest/virgl_vtest_socket.c @@ -62,7 +62,9 @@ static int virgl_block_read(int fd, void *buf, int size) do { ret = read(fd, ptr, left); if (ret <= 0) { - fprintf(stderr, "lost connection to rendering server on %d read %d %d\n", size, ret, errno); + fprintf(stderr, + "lost connection to rendering server on %d read %d %d\n", + size, ret, errno); abort(); return ret < 0 ? -errno : 0; } @@ -216,10 +218,12 @@ int virgl_vtest_send_transfer_cmd(struct virgl_vtest_winsys *vws, { uint32_t vtest_hdr[VTEST_HDR_SIZE]; uint32_t cmd[VCMD_TRANSFER_HDR_SIZE]; - bool is_put = (vcmd == VCMD_TRANSFER_PUT); - vtest_hdr[VTEST_CMD_LEN] = VCMD_TRANSFER_HDR_SIZE + (is_put ? (data_size + 3 / 4) : 0); + vtest_hdr[VTEST_CMD_LEN] = VCMD_TRANSFER_HDR_SIZE; vtest_hdr[VTEST_CMD_ID] = vcmd; + if (vcmd == VCMD_TRANSFER_PUT) + vtest_hdr[VTEST_CMD_LEN] += data_size + 3 / 4; + cmd[0] = handle; cmd[1] = level; cmd[2] = stride; @@ -248,7 +252,8 @@ int virgl_vtest_recv_transfer_get_data(struct virgl_vtest_winsys *vws, void *data, uint32_t data_size, uint32_t stride, - const struct pipe_box *box, uint32_t format) + const struct pipe_box *box, + uint32_t format) { void *line = malloc(stride); void *ptr = data; diff --git a/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c b/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c index 6181d7c1976..7c2236fe734 100644 --- a/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c +++ b/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c @@ -30,8 +30,11 @@ #include "virgl_vtest_winsys.h" #include "virgl_vtest_public.h" -static void *virgl_vtest_resource_map(struct virgl_winsys *vws, struct virgl_hw_res *res); -static void virgl_vtest_resource_unmap(struct virgl_winsys *vws, struct virgl_hw_res *res); +static void *virgl_vtest_resource_map(struct virgl_winsys *vws, + struct virgl_hw_res *res); +static void virgl_vtest_resource_unmap(struct virgl_winsys *vws, + struct virgl_hw_res *res); + static inline boolean can_cache_resource(struct virgl_hw_res *res) { return res->cacheable == TRUE; @@ -73,7 +76,8 @@ virgl_vtest_transfer_put(struct virgl_winsys *vws, void *ptr; uint32_t valid_stride; - size = vtest_get_transfer_size(res, box, stride, layer_stride, level, &valid_stride); + size = vtest_get_transfer_size(res, box, stride, layer_stride, level, + &valid_stride); virgl_vtest_send_transfer_cmd(vtws, VCMD_TRANSFER_PUT, res->res_handle, level, stride, layer_stride, @@ -96,7 +100,8 @@ virgl_vtest_transfer_get(struct virgl_winsys *vws, void *ptr; uint32_t valid_stride; - size = vtest_get_transfer_size(res, box, stride, layer_stride, level, &valid_stride); + size = vtest_get_transfer_size(res, box, stride, layer_stride, level, + &valid_stride); virgl_vtest_send_transfer_cmd(vtws, VCMD_TRANSFER_GET, res->res_handle, level, stride, layer_stride, @@ -104,7 +109,8 @@ virgl_vtest_transfer_get(struct virgl_winsys *vws, ptr = virgl_vtest_resource_map(vws, res); - virgl_vtest_recv_transfer_get_data(vtws, ptr + buf_offset, size, valid_stride, box, res->format); + virgl_vtest_recv_transfer_get_data(vtws, ptr + buf_offset, size, + valid_stride, box, res->format); virgl_vtest_resource_unmap(vws, res); return 0; } @@ -196,18 +202,18 @@ static void virgl_vtest_resource_reference(struct virgl_vtest_winsys *vtws, *dres = sres; } -static struct virgl_hw_res *virgl_vtest_winsys_resource_create( - struct virgl_winsys *vws, - enum pipe_texture_target target, - uint32_t format, - uint32_t bind, - uint32_t width, - uint32_t height, - uint32_t depth, - uint32_t array_size, - uint32_t last_level, - uint32_t nr_samples, - uint32_t size) +static struct virgl_hw_res * +virgl_vtest_winsys_resource_create(struct virgl_winsys *vws, + enum pipe_texture_target target, + uint32_t format, + uint32_t bind, + uint32_t width, + uint32_t height, + uint32_t depth, + uint32_t array_size, + uint32_t last_level, + uint32_t nr_samples, + uint32_t size) { struct virgl_vtest_winsys *vtws = virgl_vtest_winsys(vws); struct virgl_hw_res *res; @@ -218,12 +224,8 @@ static struct virgl_hw_res *virgl_vtest_winsys_resource_create( return NULL; if (bind & (VIRGL_BIND_DISPLAY_TARGET | VIRGL_BIND_SCANOUT)) { - res->dt = vtws->sws->displaytarget_create(vtws->sws, - bind, - format, - width, - height, - 64, + res->dt = vtws->sws->displaytarget_create(vtws->sws, bind, format, + width, height, 64, &res->stride); } else { @@ -238,9 +240,9 @@ static struct virgl_hw_res *virgl_vtest_winsys_resource_create( res->format = format; res->height = height; res->width = width; - virgl_vtest_send_resource_create(vtws, handle, target, format, bind, width, - height, depth, array_size, last_level, - nr_samples); + virgl_vtest_send_resource_create(vtws, handle, target, format, bind, + width, height, depth, array_size, + last_level, nr_samples); res->res_handle = handle++; pipe_reference_init(&res->reference, 1); @@ -254,7 +256,8 @@ static void virgl_vtest_winsys_resource_unref(struct virgl_winsys *vws, virgl_vtest_resource_reference(vtws, &hres, NULL); } -static void *virgl_vtest_resource_map(struct virgl_winsys *vws, struct virgl_hw_res *res) +static void *virgl_vtest_resource_map(struct virgl_winsys *vws, + struct virgl_hw_res *res) { struct virgl_vtest_winsys *vtws = virgl_vtest_winsys(vws); @@ -266,7 +269,8 @@ static void *virgl_vtest_resource_map(struct virgl_winsys *vws, struct virgl_hw_ } } -static void virgl_vtest_resource_unmap(struct virgl_winsys *vws, struct virgl_hw_res *res) +static void virgl_vtest_resource_unmap(struct virgl_winsys *vws, + struct virgl_hw_res *res) { struct virgl_vtest_winsys *vtws = virgl_vtest_winsys(vws); if (res->mapped) @@ -276,7 +280,8 @@ static void virgl_vtest_resource_unmap(struct virgl_winsys *vws, struct virgl_hw vtws->sws->displaytarget_unmap(vtws->sws, res->dt); } -static void virgl_vtest_resource_wait(struct virgl_winsys *vws, struct virgl_hw_res *res) +static void virgl_vtest_resource_wait(struct virgl_winsys *vws, + struct virgl_hw_res *res) { struct virgl_vtest_winsys *vtws = virgl_vtest_winsys(vws); @@ -285,7 +290,8 @@ static void virgl_vtest_resource_wait(struct virgl_winsys *vws, struct virgl_hw_ static inline int virgl_is_res_compat(struct virgl_vtest_winsys *vtws, struct virgl_hw_res *res, - uint32_t size, uint32_t bind, uint32_t format) + uint32_t size, uint32_t bind, + uint32_t format) { if (res->bind != bind) return 0; @@ -303,17 +309,18 @@ static inline int virgl_is_res_compat(struct virgl_vtest_winsys *vtws, return 1; } -static struct virgl_hw_res *virgl_vtest_winsys_resource_cache_create(struct virgl_winsys *vws, - enum pipe_texture_target target, - uint32_t format, - uint32_t bind, - uint32_t width, - uint32_t height, - uint32_t depth, - uint32_t array_size, - uint32_t last_level, - uint32_t nr_samples, - uint32_t size) +static struct virgl_hw_res * +virgl_vtest_winsys_resource_cache_create(struct virgl_winsys *vws, + enum pipe_texture_target target, + uint32_t format, + uint32_t bind, + uint32_t width, + uint32_t height, + uint32_t depth, + uint32_t array_size, + uint32_t last_level, + uint32_t nr_samples, + uint32_t size) { struct virgl_vtest_winsys *vtws = virgl_vtest_winsys(vws); struct virgl_hw_res *res, *curr_res; @@ -378,8 +385,8 @@ static struct virgl_hw_res *virgl_vtest_winsys_resource_cache_create(struct virg alloc: res = virgl_vtest_winsys_resource_create(vws, target, format, bind, - width, height, depth, array_size, - last_level, nr_samples, size); + width, height, depth, array_size, + last_level, nr_samples, size); if (bind == VIRGL_BIND_CONSTANT_BUFFER || bind == VIRGL_BIND_INDEX_BUFFER || bind == VIRGL_BIND_VERTEX_BUFFER) res->cacheable = TRUE; @@ -414,7 +421,7 @@ static void virgl_vtest_cmd_buf_destroy(struct virgl_cmd_buf *_cbuf) } static boolean virgl_vtest_lookup_res(struct virgl_vtest_cmd_buf *cbuf, - struct virgl_hw_res *res) + struct virgl_hw_res *res) { unsigned hash = res->res_handle & (sizeof(cbuf->is_handle_added)-1); int i; @@ -447,7 +454,8 @@ static void virgl_vtest_release_all_res(struct virgl_vtest_winsys *vtws, } static void virgl_vtest_add_res(struct virgl_vtest_winsys *vtws, - struct virgl_vtest_cmd_buf *cbuf, struct virgl_hw_res *res) + struct virgl_vtest_cmd_buf *cbuf, + struct virgl_hw_res *res) { unsigned hash = res->res_handle & (sizeof(cbuf->is_handle_added)-1); @@ -465,7 +473,8 @@ static void virgl_vtest_add_res(struct virgl_vtest_winsys *vtws, cbuf->cres++; } -static int virgl_vtest_winsys_submit_cmd(struct virgl_winsys *vws, struct virgl_cmd_buf *_cbuf) +static int virgl_vtest_winsys_submit_cmd(struct virgl_winsys *vws, + struct virgl_cmd_buf *_cbuf) { struct virgl_vtest_winsys *vtws = virgl_vtest_winsys(vws); struct virgl_vtest_cmd_buf *cbuf = virgl_vtest_cmd_buf(_cbuf); @@ -482,7 +491,9 @@ static int virgl_vtest_winsys_submit_cmd(struct virgl_winsys *vws, struct virgl_ return ret; } -static void virgl_vtest_emit_res(struct virgl_winsys *vws, struct virgl_cmd_buf *_cbuf, struct virgl_hw_res *res, boolean write_buf) +static void virgl_vtest_emit_res(struct virgl_winsys *vws, + struct virgl_cmd_buf *_cbuf, + struct virgl_hw_res *res, boolean write_buf) { struct virgl_vtest_winsys *vtws = virgl_vtest_winsys(vws); struct virgl_vtest_cmd_buf *cbuf = virgl_vtest_cmd_buf(_cbuf); @@ -504,7 +515,8 @@ static boolean virgl_vtest_res_is_ref(struct virgl_winsys *vws, return TRUE; } -static int virgl_vtest_get_caps(struct virgl_winsys *vws, struct virgl_drm_caps *caps) +static int virgl_vtest_get_caps(struct virgl_winsys *vws, + struct virgl_drm_caps *caps) { struct virgl_vtest_winsys *vtws = virgl_vtest_winsys(vws); return virgl_vtest_send_get_caps(vtws, caps); @@ -575,7 +587,8 @@ static void virgl_vtest_flush_frontbuffer(struct virgl_winsys *vws, if (sub_box) { box = *sub_box; - offset = (res->stride * (box.y / util_format_get_blockheight(res->format))) + (box.x / util_format_get_blockwidth(res->format)) * util_format_get_blocksize(res->format); + offset = box.y / util_format_get_blockheight(res->format) * res->stride + + box.x / util_format_get_blockwidth(res->format) * util_format_get_blocksize(res->format); } else { box.z = layer; box.width = res->width; @@ -591,10 +604,12 @@ static void virgl_vtest_flush_frontbuffer(struct virgl_winsys *vws, /* execute a transfer */ virgl_vtest_send_transfer_cmd(vtws, VCMD_TRANSFER_GET, res->res_handle, level, res->stride, 0, &box, size); - virgl_vtest_recv_transfer_get_data(vtws, map + offset, size, valid_stride, &box, res->format); + virgl_vtest_recv_transfer_get_data(vtws, map + offset, size, valid_stride, + &box, res->format); vtws->sws->displaytarget_unmap(vtws->sws, res->dt); - vtws->sws->displaytarget_display(vtws->sws, res->dt, winsys_drawable_handle, sub_box); + vtws->sws->displaytarget_display(vtws->sws, res->dt, winsys_drawable_handle, + sub_box); } static void diff --git a/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.h b/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.h index 72ca2b207b1..b4faa70b67e 100644 --- a/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.h +++ b/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.h @@ -141,7 +141,8 @@ int virgl_vtest_recv_transfer_get_data(struct virgl_vtest_winsys *vws, void *data, uint32_t data_size, uint32_t stride, - const struct pipe_box *box, uint32_t format); + const struct pipe_box *box, + uint32_t format); int virgl_vtest_busy_wait(struct virgl_vtest_winsys *vws, int handle, int flags); -- 2.30.2