summaryrefslogtreecommitdiffstats
path: root/src/gallium/winsys
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2019-05-15 15:28:52 -0700
committerChia-I Wu <[email protected]>2019-06-17 09:36:31 -0700
commitad1ef35dc1e7a0f905e856648727e00219a48ebe (patch)
tree81d8fd6050789ef6a68fd4cc0a65c1a06019abfa /src/gallium/winsys
parent73bf669e3fa06af0b00cf4ab321393e5069aa6ab (diff)
virgl: add resource_reference to virgl_winsys
It works similar to pipe_resource_reference but is for virgl_hw_res. It can also replace resource_unref. Signed-off-by: Chia-I Wu <[email protected]> Reviewed-by: Alexandros Frantzis <[email protected]>
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r--src/gallium/winsys/virgl/drm/virgl_drm_winsys.c28
-rw-r--r--src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c19
2 files changed, 17 insertions, 30 deletions
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;