[Mesa-dev] [PATCH v5 01/12] gallium: move pipe_screen destroy into pipe-loader
Rob Herring
robh at kernel.org
Mon Aug 7 22:58:00 UTC 2017
In preparation to add reference counting of pipe_screen in the pipe-loader,
pipe_loader_release needs to destroy the pipe_screen instead of state
trackers.
Signed-off-by: Rob Herring <robh at kernel.org>
Cc: Emil Velikov <emil.l.velikov at gmail.com>
---
src/gallium/auxiliary/pipe-loader/pipe_loader.c | 14 ++++++++++++--
src/gallium/auxiliary/pipe-loader/pipe_loader.h | 1 +
src/gallium/auxiliary/vl/vl_winsys_dri.c | 1 -
src/gallium/auxiliary/vl/vl_winsys_dri3.c | 1 -
src/gallium/auxiliary/vl/vl_winsys_drm.c | 1 -
src/gallium/state_trackers/clover/core/device.cpp | 4 +---
src/gallium/state_trackers/dri/dri_screen.c | 3 ---
src/gallium/state_trackers/xa/xa_tracker.c | 2 --
src/gallium/tests/trivial/compute.c | 1 -
src/gallium/tests/trivial/quad-tex.c | 1 -
src/gallium/tests/trivial/tri.c | 1 -
11 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader.c b/src/gallium/auxiliary/pipe-loader/pipe_loader.c
index 926db49fd24b..61e5786a2528 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.c
@@ -67,13 +67,20 @@ pipe_loader_probe(struct pipe_loader_device **devs, int ndev)
return n;
}
+static void
+pipe_loader_release_dev(struct pipe_loader_device *dev)
+{
+ dev->pscreen->destroy(dev->pscreen);
+ dev->ops->release(&dev);
+}
+
void
pipe_loader_release(struct pipe_loader_device **devs, int ndev)
{
int i;
for (i = 0; i < ndev; i++)
- devs[i]->ops->release(&devs[i]);
+ pipe_loader_release_dev(devs[i]);
}
void
@@ -125,12 +132,15 @@ pipe_loader_get_driinfo_xml(const char *driver_name)
struct pipe_screen *
pipe_loader_create_screen(struct pipe_loader_device *dev)
{
+ struct pipe_screen *pscreen;
struct pipe_screen_config config;
pipe_loader_load_options(dev);
config.options = &dev->option_cache;
- return dev->ops->create_screen(dev, &config);
+ pscreen = dev->ops->create_screen(dev, &config);
+ dev->pscreen = pscreen;
+ return pscreen;
}
struct util_dl_library *
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader.h b/src/gallium/auxiliary/pipe-loader/pipe_loader.h
index b50114310b4a..25cf5616f785 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader.h
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.h
@@ -66,6 +66,7 @@ struct pipe_loader_device {
char *driver_name;
const struct pipe_loader_ops *ops;
+ struct pipe_screen *pscreen;
driOptionCache option_cache;
driOptionCache option_info;
diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri.c b/src/gallium/auxiliary/vl/vl_winsys_dri.c
index b4fb47ea8e46..444fff321eae 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri.c
@@ -463,7 +463,6 @@ vl_dri2_screen_destroy(struct vl_screen *vscreen)
}
vl_dri2_destroy_drawable(scrn);
- scrn->base.pscreen->destroy(scrn->base.pscreen);
pipe_loader_release(&scrn->base.dev, 1);
FREE(scrn);
}
diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri3.c b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
index 8251087f3f90..4ed7ef0eacad 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri3.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
@@ -732,7 +732,6 @@ vl_dri3_screen_destroy(struct vl_screen *vscreen)
xcb_unregister_for_special_event(scrn->conn, scrn->special_event);
}
scrn->pipe->destroy(scrn->pipe);
- scrn->base.pscreen->destroy(scrn->base.pscreen);
pipe_loader_release(&scrn->base.dev, 1);
FREE(scrn);
diff --git a/src/gallium/auxiliary/vl/vl_winsys_drm.c b/src/gallium/auxiliary/vl/vl_winsys_drm.c
index df8809c501cb..6bbc87635c78 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_drm.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_drm.c
@@ -81,7 +81,6 @@ vl_drm_screen_destroy(struct vl_screen *vscreen)
{
assert(vscreen);
- vscreen->pscreen->destroy(vscreen->pscreen);
pipe_loader_release(&vscreen->dev, 1);
FREE(vscreen);
}
diff --git a/src/gallium/state_trackers/clover/core/device.cpp b/src/gallium/state_trackers/clover/core/device.cpp
index 8dfba1ad9fd9..bfdd32c794a1 100644
--- a/src/gallium/state_trackers/clover/core/device.cpp
+++ b/src/gallium/state_trackers/clover/core/device.cpp
@@ -45,14 +45,12 @@ device::device(clover::platform &platform, pipe_loader_device *ldev) :
pipe = pipe_loader_create_screen(ldev);
if (!pipe || !pipe->get_param(pipe, PIPE_CAP_COMPUTE)) {
if (pipe)
- pipe->destroy(pipe);
+ pipe_loader_release(&ldev, 1);
throw error(CL_INVALID_DEVICE);
}
}
device::~device() {
- if (pipe)
- pipe->destroy(pipe);
if (ldev)
pipe_loader_release(&ldev, 1);
}
diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c
index 406e97dc2429..01ca2202b4c8 100644
--- a/src/gallium/state_trackers/dri/dri_screen.c
+++ b/src/gallium/state_trackers/dri/dri_screen.c
@@ -428,9 +428,6 @@ dri_destroy_screen_helper(struct dri_screen * screen)
if (screen->st_api && screen->st_api->destroy)
screen->st_api->destroy(screen->st_api);
- if (screen->base.screen)
- screen->base.screen->destroy(screen->base.screen);
-
mtx_destroy(&screen->opencl_func_mutex);
}
diff --git a/src/gallium/state_trackers/xa/xa_tracker.c b/src/gallium/state_trackers/xa/xa_tracker.c
index 03a3abf6835a..fee83afcc66e 100644
--- a/src/gallium/state_trackers/xa/xa_tracker.c
+++ b/src/gallium/state_trackers/xa/xa_tracker.c
@@ -209,7 +209,6 @@ xa_tracker_create(int drm_fd)
out_sf_alloc_fail:
xa_context_destroy(xa->default_ctx);
out_no_pipe:
- xa->screen->destroy(xa->screen);
out_no_screen:
if (xa->dev)
pipe_loader_release(&xa->dev, 1);
@@ -225,7 +224,6 @@ xa_tracker_destroy(struct xa_tracker *xa)
{
free(xa->supported_formats);
xa_context_destroy(xa->default_ctx);
- xa->screen->destroy(xa->screen);
pipe_loader_release(&xa->dev, 1);
free(xa);
}
diff --git a/src/gallium/tests/trivial/compute.c b/src/gallium/tests/trivial/compute.c
index 443451e13d24..d718906eb7c8 100644
--- a/src/gallium/tests/trivial/compute.c
+++ b/src/gallium/tests/trivial/compute.c
@@ -90,7 +90,6 @@ static void init_ctx(struct context *ctx)
static void destroy_ctx(struct context *ctx)
{
ctx->pipe->destroy(ctx->pipe);
- ctx->screen->destroy(ctx->screen);
pipe_loader_release(&ctx->dev, 1);
FREE(ctx);
}
diff --git a/src/gallium/tests/trivial/quad-tex.c b/src/gallium/tests/trivial/quad-tex.c
index 2ee544a41294..8b8352d5c535 100644
--- a/src/gallium/tests/trivial/quad-tex.c
+++ b/src/gallium/tests/trivial/quad-tex.c
@@ -291,7 +291,6 @@ static void close_prog(struct program *p)
pipe_resource_reference(&p->vbuf, NULL);
p->pipe->destroy(p->pipe);
- p->screen->destroy(p->screen);
pipe_loader_release(&p->dev, 1);
FREE(p);
diff --git a/src/gallium/tests/trivial/tri.c b/src/gallium/tests/trivial/tri.c
index a2031696f029..bb053e761b75 100644
--- a/src/gallium/tests/trivial/tri.c
+++ b/src/gallium/tests/trivial/tri.c
@@ -231,7 +231,6 @@ static void close_prog(struct program *p)
pipe_resource_reference(&p->vbuf, NULL);
p->pipe->destroy(p->pipe);
- p->screen->destroy(p->screen);
pipe_loader_release(&p->dev, 1);
FREE(p);
--
2.11.0
More information about the mesa-dev
mailing list