summaryrefslogtreecommitdiffstats
path: root/src/gallium/winsys
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r--src/gallium/winsys/virgl/drm/virgl_drm_winsys.c8
-rw-r--r--src/gallium/winsys/virgl/drm/virgl_drm_winsys.h3
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