summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gallium/drivers/virgl/virgl_resource.c2
-rw-r--r--src/gallium/drivers/virgl/virgl_winsys.h4
-rw-r--r--src/gallium/winsys/virgl/drm/virgl_drm_winsys.c28
-rw-r--r--src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c19
4 files changed, 21 insertions, 32 deletions
diff --git a/src/gallium/drivers/virgl/virgl_resource.c b/src/gallium/drivers/virgl/virgl_resource.c
index 4d427894dac..1c8e264e573 100644
--- a/src/gallium/drivers/virgl/virgl_resource.c
+++ b/src/gallium/drivers/virgl/virgl_resource.c
@@ -459,7 +459,7 @@ void virgl_resource_destroy(struct pipe_screen *screen,
if (res->u.b.target == PIPE_BUFFER)
util_range_destroy(&res->valid_buffer_range);
- vs->vws->resource_unref(vs->vws, res->hw_res);
+ vs->vws->resource_reference(vs->vws, &res->hw_res, NULL);
FREE(res);
}
diff --git a/src/gallium/drivers/virgl/virgl_winsys.h b/src/gallium/drivers/virgl/virgl_winsys.h
index bab3dbaa2d1..d880648d59d 100644
--- a/src/gallium/drivers/virgl/virgl_winsys.h
+++ b/src/gallium/drivers/virgl/virgl_winsys.h
@@ -70,7 +70,9 @@ struct virgl_winsys {
uint32_t last_level, uint32_t nr_samples,
uint32_t size);
- void (*resource_unref)(struct virgl_winsys *vws, struct virgl_hw_res *res);
+ void (*resource_reference)(struct virgl_winsys *qws,
+ struct virgl_hw_res **dres,
+ struct virgl_hw_res *sres);
void *(*resource_map)(struct virgl_winsys *vws, struct virgl_hw_res *res);
void (*resource_wait)(struct virgl_winsys *vws, struct virgl_hw_res *res);
diff --git a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
index 4ce2302f317..41e47837acf 100644
--- a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
+++ b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
@@ -121,11 +121,13 @@ virgl_drm_winsys_destroy(struct virgl_winsys *qws)
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) ||
@@ -338,7 +340,7 @@ virgl_drm_winsys_resource_create_handle(struct virgl_winsys *qws,
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;
}
@@ -429,14 +431,6 @@ static boolean virgl_drm_winsys_resource_get_handle(struct virgl_winsys *qws,
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)
{
@@ -503,12 +497,11 @@ static bool virgl_drm_alloc_res_list(struct virgl_drm_cmd_buf *cbuf,
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);
@@ -564,7 +557,7 @@ static void virgl_drm_add_res(struct virgl_drm_winsys *qdws,
}
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;
@@ -576,7 +569,6 @@ static void virgl_drm_add_res(struct virgl_drm_winsys *qdws,
/* 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++) {
@@ -584,7 +576,7 @@ static void virgl_drm_clear_res_list(struct virgl_drm_cmd_buf *cbuf)
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;
@@ -983,7 +975,7 @@ virgl_drm_winsys_create(int drmFD)
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;
diff --git a/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c b/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c
index 8bc28af45de..b6f5a8324e7 100644
--- a/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c
+++ b/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c
@@ -202,11 +202,13 @@ static boolean virgl_vtest_resource_is_busy(struct virgl_winsys *vws,
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);
@@ -296,13 +298,6 @@ out:
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)
{
@@ -409,7 +404,7 @@ static void virgl_vtest_release_all_res(struct virgl_vtest_winsys *vtws,
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;
}
@@ -435,7 +430,7 @@ static void virgl_vtest_add_res(struct virgl_vtest_winsys *vtws,
}
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;
@@ -586,7 +581,7 @@ static void virgl_fence_reference(struct virgl_winsys *vws,
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));
}
@@ -678,7 +673,7 @@ virgl_vtest_winsys_wrap(struct sw_winsys *sws)
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;