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;
*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;
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;
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;
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 = {};
}
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;
}
-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;
}
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);
}
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;
}
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);
}
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;
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);
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;
#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;
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,
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,
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;
}
*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;
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 {
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);
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);
}
}
-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)
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);
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;
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;
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;
}
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;
}
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);
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);
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);
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);
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;
/* 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