FREE(qdws);
}
-static void virgl_drm_resource_reference(struct virgl_drm_winsys *qdws,
- struct virgl_hw_res **dres,
- struct virgl_hw_res *sres)
+static void virgl_drm_resource_reference(struct virgl_winsys *qws,
+ struct virgl_hw_res **dres,
+ struct virgl_hw_res *sres)
{
+ struct virgl_drm_winsys *qdws = virgl_drm_winsys(qws);
struct virgl_hw_res *old = *dres;
+
if (pipe_reference(&(*dres)->reference, &sres->reference)) {
if (!can_cache_resource_with_bind(old->bind) ||
if (res) {
struct virgl_hw_res *r = NULL;
- virgl_drm_resource_reference(qdws, &r, res);
+ virgl_drm_resource_reference(&qdws->base, &r, res);
goto done;
}
return TRUE;
}
-static void virgl_drm_winsys_resource_unref(struct virgl_winsys *qws,
- 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_free_res_list(struct virgl_drm_cmd_buf *cbuf)
{
- struct virgl_drm_winsys *qdws = virgl_drm_winsys(cbuf->ws);
int i;
for (i = 0; i < cbuf->cres; i++) {
p_atomic_dec(&cbuf->res_bo[i]->num_cs_references);
- virgl_drm_resource_reference(qdws, &cbuf->res_bo[i], NULL);
+ virgl_drm_resource_reference(cbuf->ws, &cbuf->res_bo[i], NULL);
}
FREE(cbuf->res_hlist);
FREE(cbuf->res_bo);
}
cbuf->res_bo[cbuf->cres] = NULL;
- virgl_drm_resource_reference(qdws, &cbuf->res_bo[cbuf->cres], res);
+ virgl_drm_resource_reference(&qdws->base, &cbuf->res_bo[cbuf->cres], res);
cbuf->res_hlist[cbuf->cres] = res->bo_handle;
cbuf->is_handle_added[hash] = TRUE;
/* This is called after the cbuf is submitted. */
static void virgl_drm_clear_res_list(struct virgl_drm_cmd_buf *cbuf)
{
- struct virgl_drm_winsys *qdws = virgl_drm_winsys(cbuf->ws);
int i;
for (i = 0; i < cbuf->cres; i++) {
p_atomic_set(&cbuf->res_bo[i]->maybe_busy, true);
p_atomic_dec(&cbuf->res_bo[i]->num_cs_references);
- virgl_drm_resource_reference(qdws, &cbuf->res_bo[i], NULL);
+ virgl_drm_resource_reference(cbuf->ws, &cbuf->res_bo[i], NULL);
}
cbuf->cres = 0;
qdws->base.transfer_put = virgl_bo_transfer_put;
qdws->base.transfer_get = virgl_bo_transfer_get;
qdws->base.resource_create = virgl_drm_winsys_resource_cache_create;
- qdws->base.resource_unref = virgl_drm_winsys_resource_unref;
+ qdws->base.resource_reference = virgl_drm_resource_reference;
qdws->base.resource_create_from_handle = virgl_drm_winsys_resource_create_handle;
qdws->base.resource_get_handle = virgl_drm_winsys_resource_get_handle;
qdws->base.resource_map = virgl_drm_resource_map;
return ret == 1 ? TRUE : FALSE;
}
-static void virgl_vtest_resource_reference(struct virgl_vtest_winsys *vtws,
+static void virgl_vtest_resource_reference(struct virgl_winsys *vws,
struct virgl_hw_res **dres,
struct virgl_hw_res *sres)
{
+ struct virgl_vtest_winsys *vtws = virgl_vtest_winsys(vws);
struct virgl_hw_res *old = *dres;
+
if (pipe_reference(&(*dres)->reference, &sres->reference)) {
if (!can_cache_resource_with_bind(old->bind)) {
virgl_hw_res_destroy(vtws, old);
return res;
}
-static void virgl_vtest_winsys_resource_unref(struct virgl_winsys *vws,
- struct virgl_hw_res *hres)
-{
- struct virgl_vtest_winsys *vtws = virgl_vtest_winsys(vws);
- virgl_vtest_resource_reference(vtws, &hres, NULL);
-}
-
static void *virgl_vtest_resource_map(struct virgl_winsys *vws,
struct virgl_hw_res *res)
{
for (i = 0; i < cbuf->cres; i++) {
p_atomic_dec(&cbuf->res_bo[i]->num_cs_references);
- virgl_vtest_resource_reference(vtws, &cbuf->res_bo[i], NULL);
+ virgl_vtest_resource_reference(&vtws->base, &cbuf->res_bo[i], NULL);
}
cbuf->cres = 0;
}
}
cbuf->res_bo[cbuf->cres] = NULL;
- virgl_vtest_resource_reference(vtws, &cbuf->res_bo[cbuf->cres], res);
+ virgl_vtest_resource_reference(&vtws->base, &cbuf->res_bo[cbuf->cres], res);
cbuf->is_handle_added[hash] = TRUE;
cbuf->reloc_indices_hashlist[hash] = cbuf->cres;
struct pipe_fence_handle *src)
{
struct virgl_vtest_winsys *vdws = virgl_vtest_winsys(vws);
- virgl_vtest_resource_reference(vdws, (struct virgl_hw_res **)dst,
+ virgl_vtest_resource_reference(&vdws->base, (struct virgl_hw_res **)dst,
virgl_hw_res(src));
}
vtws->base.transfer_get = virgl_vtest_transfer_get;
vtws->base.resource_create = virgl_vtest_winsys_resource_cache_create;
- vtws->base.resource_unref = virgl_vtest_winsys_resource_unref;
+ vtws->base.resource_reference = virgl_vtest_resource_reference;
vtws->base.resource_map = virgl_vtest_resource_map;
vtws->base.resource_wait = virgl_vtest_resource_wait;
vtws->base.resource_is_busy = virgl_vtest_resource_is_busy;