[Mesa-dev] [PATCH 3/4] pipe-loader: remove config from pipe_loader_create_screen

Nicolai Hähnle nhaehnle at gmail.com
Thu Aug 3 13:44:40 UTC 2017


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

The config passed into the screen should be independent from the state
tracker, because at least in the case of radeonsi, the screen structure
can be shared between different state trackers.

Incidentally, this also fixes crashes that were recently introduced.

Fixes: a35a9e7c ("gallium: add driconf options to pipe_screen_config")
Cc: Jan Vesely <jan.vesely at rutgers.edu>
---
 src/gallium/auxiliary/pipe-loader/pipe_loader.c   | 9 +++++----
 src/gallium/auxiliary/pipe-loader/pipe_loader.h   | 5 +----
 src/gallium/auxiliary/vl/vl_winsys_dri.c          | 2 +-
 src/gallium/auxiliary/vl/vl_winsys_dri3.c         | 2 +-
 src/gallium/auxiliary/vl/vl_winsys_drm.c          | 2 +-
 src/gallium/state_trackers/clover/core/device.cpp | 2 +-
 src/gallium/state_trackers/dri/dri2.c             | 8 ++------
 src/gallium/state_trackers/dri/drisw.c            | 3 +--
 src/gallium/state_trackers/xa/xa_tracker.c        | 2 +-
 src/gallium/targets/d3dadapter9/drm.c             | 4 ++--
 src/gallium/tests/trivial/compute.c               | 2 +-
 src/gallium/tests/trivial/quad-tex.c              | 2 +-
 src/gallium/tests/trivial/tri.c                   | 2 +-
 13 files changed, 19 insertions(+), 26 deletions(-)

diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader.c b/src/gallium/auxiliary/pipe-loader/pipe_loader.c
index 6d9acebdb68..926db49fd24 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.c
@@ -123,13 +123,14 @@ pipe_loader_get_driinfo_xml(const char *driver_name)
 }
 
 struct pipe_screen *
-pipe_loader_create_screen(struct pipe_loader_device *dev,
-                          struct pipe_screen_config *config)
+pipe_loader_create_screen(struct pipe_loader_device *dev)
 {
+   struct pipe_screen_config config;
+
    pipe_loader_load_options(dev);
-   config->options = &dev->option_cache;
+   config.options = &dev->option_cache;
 
-   return dev->ops->create_screen(dev, config);
+   return dev->ops->create_screen(dev, &config);
 }
 
 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 b6e81cf3915..b50114310b4 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader.h
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.h
@@ -86,12 +86,9 @@ pipe_loader_probe(struct pipe_loader_device **devs, int ndev);
  * Create a pipe_screen for the specified device.
  *
  * \param dev Device the screen will be created for.
- * \param config Configuration options. The lifetime of this structure and its
- *               elements may be limited to the duration of this call.
  */
 struct pipe_screen *
-pipe_loader_create_screen(struct pipe_loader_device *dev,
-                          struct pipe_screen_config *config);
+pipe_loader_create_screen(struct pipe_loader_device *dev);
 
 /**
  * Query the configuration parameters for the specified device.
diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri.c b/src/gallium/auxiliary/vl/vl_winsys_dri.c
index 7a0fc3c3bf2..b4fb47ea8e4 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri.c
@@ -406,7 +406,7 @@ vl_dri2_screen_create(Display *display, int screen)
       goto free_authenticate;
 
    if (pipe_loader_drm_probe_fd(&scrn->base.dev, fd))
-      scrn->base.pscreen = pipe_loader_create_screen(scrn->base.dev, NULL);
+      scrn->base.pscreen = pipe_loader_create_screen(scrn->base.dev);
 
    if (!scrn->base.pscreen)
       goto release_pipe;
diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri3.c b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
index fbb729ae176..8251087f3f9 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri3.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
@@ -817,7 +817,7 @@ vl_dri3_screen_create(Display *display, int screen)
    free(geom_reply);
 
    if (pipe_loader_drm_probe_fd(&scrn->base.dev, fd))
-      scrn->base.pscreen = pipe_loader_create_screen(scrn->base.dev, NULL);
+      scrn->base.pscreen = pipe_loader_create_screen(scrn->base.dev);
 
    if (!scrn->base.pscreen)
       goto release_pipe;
diff --git a/src/gallium/auxiliary/vl/vl_winsys_drm.c b/src/gallium/auxiliary/vl/vl_winsys_drm.c
index 07ce380ef55..df8809c501c 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_drm.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_drm.c
@@ -52,7 +52,7 @@ vl_drm_screen_create(int fd)
       goto free_screen;
 
    if (pipe_loader_drm_probe_fd(&vscreen->dev, new_fd))
-      vscreen->pscreen = pipe_loader_create_screen(vscreen->dev, NULL);
+      vscreen->pscreen = pipe_loader_create_screen(vscreen->dev);
 
    if (!vscreen->pscreen)
       goto release_pipe;
diff --git a/src/gallium/state_trackers/clover/core/device.cpp b/src/gallium/state_trackers/clover/core/device.cpp
index bd07670f384..8dfba1ad9fd 100644
--- a/src/gallium/state_trackers/clover/core/device.cpp
+++ b/src/gallium/state_trackers/clover/core/device.cpp
@@ -42,7 +42,7 @@ namespace {
 
 device::device(clover::platform &platform, pipe_loader_device *ldev) :
    platform(platform), ldev(ldev) {
-   pipe = pipe_loader_create_screen(ldev, NULL);
+   pipe = pipe_loader_create_screen(ldev);
    if (!pipe || !pipe->get_param(pipe, PIPE_CAP_COMPUTE)) {
       if (pipe)
          pipe->destroy(pipe);
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index 0f36e1bf894..3555107856c 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -2071,11 +2071,9 @@ dri2_init_screen(__DRIscreen * sPriv)
 
 
    if (pipe_loader_drm_probe_fd(&screen->dev, fd)) {
-      struct pipe_screen_config config = {};
-
       dri_init_options(screen);
 
-      pscreen = pipe_loader_create_screen(screen->dev, &config);
+      pscreen = pipe_loader_create_screen(screen->dev);
    }
 
    if (!pscreen)
@@ -2166,12 +2164,10 @@ dri_kms_init_screen(__DRIscreen * sPriv)
    if (screen->fd < 0 || (fd = fcntl(screen->fd, F_DUPFD_CLOEXEC, 3)) < 0)
       goto free_screen;
 
-   struct pipe_screen_config config = {};
-
    dri_init_options(screen);
 
    if (pipe_loader_sw_probe_kms(&screen->dev, fd))
-      pscreen = pipe_loader_create_screen(screen->dev, &config);
+      pscreen = pipe_loader_create_screen(screen->dev);
 
    if (!pscreen)
        goto release_pipe;
diff --git a/src/gallium/state_trackers/dri/drisw.c b/src/gallium/state_trackers/dri/drisw.c
index ad40e2f837b..46ec95c6906 100644
--- a/src/gallium/state_trackers/dri/drisw.c
+++ b/src/gallium/state_trackers/dri/drisw.c
@@ -401,10 +401,9 @@ drisw_init_screen(__DRIscreen * sPriv)
    sPriv->extensions = drisw_screen_extensions;
 
    if (pipe_loader_sw_probe_dri(&screen->dev, &drisw_lf)) {
-      struct pipe_screen_config config;
       dri_init_options(screen);
 
-      pscreen = pipe_loader_create_screen(screen->dev, &config);
+      pscreen = pipe_loader_create_screen(screen->dev);
    }
 
    if (!pscreen)
diff --git a/src/gallium/state_trackers/xa/xa_tracker.c b/src/gallium/state_trackers/xa/xa_tracker.c
index d4114ab5591..03a3abf6835 100644
--- a/src/gallium/state_trackers/xa/xa_tracker.c
+++ b/src/gallium/state_trackers/xa/xa_tracker.c
@@ -162,7 +162,7 @@ xa_tracker_create(int drm_fd)
 	goto out_no_fd;
 
     if (pipe_loader_drm_probe_fd(&xa->dev, fd))
-	xa->screen = pipe_loader_create_screen(xa->dev, NULL);
+	xa->screen = pipe_loader_create_screen(xa->dev);
 
     if (!xa->screen)
 	goto out_no_screen;
diff --git a/src/gallium/targets/d3dadapter9/drm.c b/src/gallium/targets/d3dadapter9/drm.c
index e6e71448a28..9c5bd8a15b2 100644
--- a/src/gallium/targets/d3dadapter9/drm.c
+++ b/src/gallium/targets/d3dadapter9/drm.c
@@ -229,7 +229,7 @@ drm_create_adapter( int fd,
         return D3DERR_DRIVERINTERNALERROR;
     }
 
-    ctx->base.hal = pipe_loader_create_screen(ctx->dev, NULL);
+    ctx->base.hal = pipe_loader_create_screen(ctx->dev);
     if (!ctx->base.hal) {
         ERR("Unable to load requested driver.\n");
         drm_destroy(&ctx->base);
@@ -312,7 +312,7 @@ drm_create_adapter( int fd,
 
     /* wrap it to create a software screen that can share resources */
     if (pipe_loader_sw_probe_wrapped(&ctx->swdev, ctx->base.hal))
-        ctx->base.ref = pipe_loader_create_screen(ctx->swdev, NULL);
+        ctx->base.ref = pipe_loader_create_screen(ctx->swdev);
 
     if (!ctx->base.ref) {
         ERR("Couldn't wrap drm screen to swrast screen. Software devices "
diff --git a/src/gallium/tests/trivial/compute.c b/src/gallium/tests/trivial/compute.c
index 49fefd84b4b..443451e13d2 100644
--- a/src/gallium/tests/trivial/compute.c
+++ b/src/gallium/tests/trivial/compute.c
@@ -76,7 +76,7 @@ static void init_ctx(struct context *ctx)
         ret = pipe_loader_probe(&ctx->dev, 1);
         assert(ret);
 
-        ctx->screen = pipe_loader_create_screen(ctx->dev, NULL);
+        ctx->screen = pipe_loader_create_screen(ctx->dev);
         assert(ctx->screen);
 
         ctx->pipe = ctx->screen->context_create(ctx->screen, NULL, 0);
diff --git a/src/gallium/tests/trivial/quad-tex.c b/src/gallium/tests/trivial/quad-tex.c
index f6232d5dc3a..2ee544a4129 100644
--- a/src/gallium/tests/trivial/quad-tex.c
+++ b/src/gallium/tests/trivial/quad-tex.c
@@ -96,7 +96,7 @@ static void init_prog(struct program *p)
 	assert(ret);
 
 	/* init a pipe screen */
-	p->screen = pipe_loader_create_screen(p->dev, NULL);
+	p->screen = pipe_loader_create_screen(p->dev);
 	assert(p->screen);
 
 	/* create the pipe driver context and cso context */
diff --git a/src/gallium/tests/trivial/tri.c b/src/gallium/tests/trivial/tri.c
index b45a408d425..a2031696f02 100644
--- a/src/gallium/tests/trivial/tri.c
+++ b/src/gallium/tests/trivial/tri.c
@@ -91,7 +91,7 @@ static void init_prog(struct program *p)
 	assert(ret);
 
 	/* init a pipe screen */
-	p->screen = pipe_loader_create_screen(p->dev, NULL);
+	p->screen = pipe_loader_create_screen(p->dev);
 	assert(p->screen);
 
 	/* create the pipe driver context and cso context */
-- 
2.11.0



More information about the mesa-dev mailing list