[virglrenderer-devel] [PATCH 1/3] renderer: Add callback for resource destruction

Tomeu Vizoso tomeu.vizoso at collabora.com
Thu Aug 2 09:09:43 UTC 2018


---
 src/virglrenderer.c  | 7 +++++++
 src/virglrenderer.h  | 2 ++
 src/vrend_renderer.c | 2 ++
 src/vrend_renderer.h | 2 ++
 4 files changed, 13 insertions(+)

diff --git a/src/virglrenderer.c b/src/virglrenderer.c
index 9a81887d9088..a2785905e312 100644
--- a/src/virglrenderer.c
+++ b/src/virglrenderer.c
@@ -215,6 +215,12 @@ static void virgl_write_fence(uint32_t fence_id)
    rcbs->write_fence(dev_cookie, fence_id);
 }
 
+static void virgl_res_destroy(uint32_t handle)
+{
+   if (rcbs->res_destroy)
+      rcbs->res_destroy(dev_cookie, handle);
+}
+
 static virgl_renderer_gl_context create_gl_context(int scanout_idx, struct virgl_gl_ctx_param *param)
 {
    struct virgl_renderer_gl_ctx_param vparam;
@@ -265,6 +271,7 @@ static struct vrend_if_cbs virgl_cbs = {
    create_gl_context,
    destroy_gl_context,
    make_current,
+   virgl_res_destroy,
 };
 
 void *virgl_renderer_get_cursor_data(uint32_t resource_id, uint32_t *width, uint32_t *height)
diff --git a/src/virglrenderer.h b/src/virglrenderer.h
index bc7cedfeaa53..1d117b6a03f5 100644
--- a/src/virglrenderer.h
+++ b/src/virglrenderer.h
@@ -56,6 +56,8 @@ struct virgl_renderer_callbacks {
    int (*make_current)(void *cookie, int scanout_idx, virgl_renderer_gl_context ctx);
 
    int (*get_drm_fd)(void *cookie); /* v2, used with flags & VIRGL_RENDERER_USE_EGL */
+
+   void (*res_destroy)(void *cookie, uint32_t handle);
 };
 
 /* virtio-gpu compatible interface */
diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index b2378c0c0632..66a71d87030f 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -5707,6 +5707,8 @@ int vrend_renderer_resource_create(struct vrend_renderer_resource_create_args *a
 
 void vrend_renderer_resource_destroy(struct vrend_resource *res, bool remove)
 {
+   vrend_clicbs->res_destroy(res->handle);
+
    if (res->readback_fb_id)
       glDeleteFramebuffers(1, &res->readback_fb_id);
 
diff --git a/src/vrend_renderer.h b/src/vrend_renderer.h
index 4cdcf6635d65..e1dfe0154747 100644
--- a/src/vrend_renderer.h
+++ b/src/vrend_renderer.h
@@ -100,6 +100,8 @@ struct vrend_if_cbs {
    virgl_gl_context (*create_gl_context)(int scanout, struct virgl_gl_ctx_param *params);
    void (*destroy_gl_context)(virgl_gl_context ctx);
    int (*make_current)(int scanout, virgl_gl_context ctx);
+
+   void (*res_destroy)(uint32_t handle);
 };
 
 #define VREND_USE_THREAD_SYNC 1
-- 
2.17.1



More information about the virglrenderer-devel mailing list