diff options
author | Chia-I Wu <[email protected]> | 2019-06-06 14:58:39 -0700 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2019-06-11 10:03:54 -0700 |
commit | 71465fe569d782e798895ed7d06805b42a1eabec (patch) | |
tree | 65902dff34983a3507a10817feb311d3f232c484 /src/gallium/winsys | |
parent | 7d43999e6365520a3c5b1e45a61b1590e4cb18a3 (diff) |
virgl: do not cache external resources
We should not reuse a resource for other purposes when it can still
be accessed by another process or device.
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.c | 8 | ||||
-rw-r--r-- | src/gallium/winsys/virgl/drm/virgl_drm_winsys.h | 3 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c index 0f6403f691f..441ca69d76a 100644 --- a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c +++ b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c @@ -160,7 +160,8 @@ static void virgl_drm_resource_reference(struct virgl_drm_winsys *qdws, struct virgl_hw_res *old = *dres; if (pipe_reference(&(*dres)->reference, &sres->reference)) { - if (!can_cache_resource_with_bind(old->bind)) { + if (!can_cache_resource_with_bind(old->bind) || + p_atomic_read(&old->external)) { virgl_hw_res_destroy(qdws, old); } else { mtx_lock(&qdws->mutex); @@ -226,6 +227,7 @@ virgl_drm_winsys_resource_create(struct virgl_winsys *qws, res->size = size; res->stride = stride; pipe_reference_init(&res->reference, 1); + p_atomic_set(&res->external, false); p_atomic_set(&res->num_cs_references, 0); return res; } @@ -456,6 +458,7 @@ virgl_drm_winsys_resource_create_handle(struct virgl_winsys *qws, res->size = info_arg.size; res->stride = info_arg.stride; pipe_reference_init(&res->reference, 1); + p_atomic_set(&res->external, true); res->num_cs_references = 0; if (res->flink_name) @@ -502,6 +505,9 @@ static boolean virgl_drm_winsys_resource_get_handle(struct virgl_winsys *qws, util_hash_table_set(qdws->bo_handles, (void *)(uintptr_t)res->bo_handle, res); mtx_unlock(&qdws->bo_handles_mutex); } + + p_atomic_set(&res->external, true); + whandle->stride = stride; return TRUE; } diff --git a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.h b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.h index de84f308d97..8bc874cb351 100644 --- a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.h +++ b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.h @@ -47,6 +47,9 @@ struct virgl_hw_res { uint32_t bind; int64_t start, end; uint32_t flink_name; + + /* true when the resource is imported or exported */ + int external; }; struct virgl_drm_winsys |