[Mesa-dev] [PATCH v3 01/11] gallium: move pipe_screen destroy into pipe-loader
Rob Herring
robh at kernel.org
Wed Jul 20 22:25:02 UTC 2016
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.h | 1 +
src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c | 9 ++++++++-
src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c | 6 ++++++
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 -
12 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader.h b/src/gallium/auxiliary/pipe-loader/pipe_loader.h
index 690d088..25cd4d1 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader.h
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.h
@@ -65,6 +65,7 @@ struct pipe_loader_device {
char *driver_name;
const struct pipe_loader_ops *ops;
+ struct pipe_screen *pscreen;
};
/**
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
index 994a284..7bdd2ec 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
@@ -39,6 +39,7 @@
#include "target-helpers/drm_helper_public.h"
#include "state_tracker/drm_driver.h"
#include "pipe_loader_priv.h"
+#include "pipe/p_screen.h"
#include "util/u_memory.h"
#include "util/u_dl.h"
@@ -269,6 +270,9 @@ static void
pipe_loader_drm_release(struct pipe_loader_device **dev)
{
struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(*dev);
+ struct pipe_screen *pscreen = ddev->base.pscreen;
+
+ pscreen->destroy(pscreen);
#ifndef GALLIUM_STATIC_TARGETS
if (ddev->lib)
@@ -297,8 +301,11 @@ static struct pipe_screen *
pipe_loader_drm_create_screen(struct pipe_loader_device *dev)
{
struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(dev);
+ struct pipe_screen *pscreen;
- return ddev->dd->create_screen(ddev->fd);
+ pscreen = ddev->dd->create_screen(ddev->fd);
+ ddev->base.pscreen = pscreen;
+ return pscreen;
}
static const struct pipe_loader_ops pipe_loader_drm_ops = {
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
index e7fa974..ce5c2b3 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
@@ -27,6 +27,7 @@
#include "pipe_loader_priv.h"
+#include "pipe/p_screen.h"
#include "util/u_memory.h"
#include "util/u_dl.h"
#include "sw/dri/dri_sw_winsys.h"
@@ -271,6 +272,9 @@ static void
pipe_loader_sw_release(struct pipe_loader_device **dev)
{
struct pipe_loader_sw_device *sdev = pipe_loader_sw_device(*dev);
+ struct pipe_screen *pscreen = sdev->base.pscreen;
+
+ pscreen->destroy(pscreen);
#ifndef GALLIUM_STATIC_TARGETS
if (sdev->lib)
@@ -301,6 +305,8 @@ pipe_loader_sw_create_screen(struct pipe_loader_device *dev)
if (!screen)
sdev->ws->destroy(sdev->ws);
+ sdev->base.pscreen = screen;
+
return screen;
}
diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri.c b/src/gallium/auxiliary/vl/vl_winsys_dri.c
index 9ecc216..db90c54 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri.c
@@ -461,7 +461,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 493e645..c8c0198 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri3.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
@@ -611,7 +611,6 @@ vl_dri3_screen_destroy(struct vl_screen *vscreen)
if (scrn->special_event)
xcb_unregister_for_special_event(scrn->conn, scrn->special_event);
- 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 6a759ae..aa690a2 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_drm.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_drm.c
@@ -80,7 +80,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 39f39f4..74ed794 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 b16585a..64ea771 100644
--- a/src/gallium/state_trackers/dri/dri_screen.c
+++ b/src/gallium/state_trackers/dri/dri_screen.c
@@ -378,9 +378,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);
-
dri_destroy_option_cache(screen);
pipe_mutex_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 e091b083..dea4205 100644
--- a/src/gallium/state_trackers/xa/xa_tracker.c
+++ b/src/gallium/state_trackers/xa/xa_tracker.c
@@ -208,7 +208,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);
@@ -224,7 +223,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 443451e..d718906 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 ddee294..2f8b642 100644
--- a/src/gallium/tests/trivial/quad-tex.c
+++ b/src/gallium/tests/trivial/quad-tex.c
@@ -289,7 +289,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 914f5e7..6ee0529 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.9.2
More information about the mesa-dev
mailing list