Mesa (master): gallium/drm: Deduplicate screen creation for the dynamic (clover) pipe loader.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Sep 25 00:02:11 UTC 2020


Module: Mesa
Branch: master
Commit: 9ec28b8d226558aa2748dbf813b125f8938a09cc
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9ec28b8d226558aa2748dbf813b125f8938a09cc

Author: Eric Anholt <eric at anholt.net>
Date:   Wed Sep 16 08:54:12 2020 -0700

gallium/drm: Deduplicate screen creation for the dynamic (clover) pipe loader.

We can just reuse drm_helper.h, which has either the real code or the stub
for all pipe_screens based on the GALLIUM_* driver defines, and the
dynamic pipe loader's .c build will only define one GALLIUM_* driver
define.  The remaining stubs should get GCed by the linker.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6751>

---

 src/gallium/targets/pipe-loader/pipe_i915.c     | 21 +--------------------
 src/gallium/targets/pipe-loader/pipe_kmsro.c    | 16 +---------------
 src/gallium/targets/pipe-loader/pipe_msm.c      | 17 ++---------------
 src/gallium/targets/pipe-loader/pipe_nouveau.c  | 17 ++---------------
 src/gallium/targets/pipe-loader/pipe_r300.c     | 12 ++----------
 src/gallium/targets/pipe-loader/pipe_r600.c     | 12 ++----------
 src/gallium/targets/pipe-loader/pipe_radeonsi.c | 11 ++---------
 src/gallium/targets/pipe-loader/pipe_vmwgfx.c   | 22 ++--------------------
 8 files changed, 14 insertions(+), 114 deletions(-)

diff --git a/src/gallium/targets/pipe-loader/pipe_i915.c b/src/gallium/targets/pipe-loader/pipe_i915.c
index 927bad0de2c..14e5a5ac3cf 100644
--- a/src/gallium/targets/pipe-loader/pipe_i915.c
+++ b/src/gallium/targets/pipe-loader/pipe_i915.c
@@ -4,24 +4,5 @@
 #include "i915/drm/i915_drm_public.h"
 #include "i915/i915_public.h"
 
-static struct pipe_screen *
-create_screen(int fd, const struct pipe_screen_config *config)
-{
-   struct i915_winsys *iws;
-   struct pipe_screen *screen;
-
-   iws = i915_drm_winsys_create(fd);
-   if (!iws)
-      return NULL;
-
-   screen = i915_screen_create(iws);
-   if (!screen)
-      return NULL;
-
-   screen = debug_screen_wrap(screen);
-
-   return screen;
-}
-
 PUBLIC
-DRM_DRIVER_DESCRIPTOR("i915", NULL, create_screen)
+DRM_DRIVER_DESCRIPTOR("i915", NULL, pipe_i915_create_screen)
diff --git a/src/gallium/targets/pipe-loader/pipe_kmsro.c b/src/gallium/targets/pipe-loader/pipe_kmsro.c
index 79c66bd3695..2e9626833e3 100644
--- a/src/gallium/targets/pipe-loader/pipe_kmsro.c
+++ b/src/gallium/targets/pipe-loader/pipe_kmsro.c
@@ -3,19 +3,5 @@
 #include "frontend/drm_driver.h"
 #include "kmsro/drm/kmsro_drm_public.h"
 
-static struct pipe_screen *
-create_screen(int fd, const struct pipe_screen_config *config)
-{
-   struct pipe_screen *screen;
-
-   screen = kmsro_drm_screen_create(fd, config);
-   if (!screen)
-      return NULL;
-
-   screen = debug_screen_wrap(screen);
-
-   return screen;
-}
-
 PUBLIC
-DRM_DRIVER_DESCRIPTOR("kmsro", NULL, create_screen)
+DRM_DRIVER_DESCRIPTOR("kmsro", NULL, pipe_kmsro_create_screen)
diff --git a/src/gallium/targets/pipe-loader/pipe_msm.c b/src/gallium/targets/pipe-loader/pipe_msm.c
index 4868a8bcd8d..28098e830ee 100644
--- a/src/gallium/targets/pipe-loader/pipe_msm.c
+++ b/src/gallium/targets/pipe-loader/pipe_msm.c
@@ -1,21 +1,8 @@
 
+#include "target-helpers/drm_helper.h"
 #include "target-helpers/inline_debug_helper.h"
 #include "frontend/drm_driver.h"
 #include "freedreno/drm/freedreno_drm_public.h"
 
-static struct pipe_screen *
-create_screen(int fd, const struct pipe_screen_config *config)
-{
-   struct pipe_screen *screen;
-
-   screen = fd_drm_screen_create(fd, NULL);
-   if (!screen)
-      return NULL;
-
-   screen = debug_screen_wrap(screen);
-
-   return screen;
-}
-
 PUBLIC
-DRM_DRIVER_DESCRIPTOR("msm", NULL, create_screen)
+DRM_DRIVER_DESCRIPTOR("msm", NULL, pipe_freedreno_create_screen)
diff --git a/src/gallium/targets/pipe-loader/pipe_nouveau.c b/src/gallium/targets/pipe-loader/pipe_nouveau.c
index 6b5ee18408c..5907a75cbc1 100644
--- a/src/gallium/targets/pipe-loader/pipe_nouveau.c
+++ b/src/gallium/targets/pipe-loader/pipe_nouveau.c
@@ -1,21 +1,8 @@
 
+#include "target-helpers/drm_helper.h"
 #include "target-helpers/inline_debug_helper.h"
 #include "frontend/drm_driver.h"
 #include "nouveau/drm/nouveau_drm_public.h"
 
-static struct pipe_screen *
-create_screen(int fd, const struct pipe_screen_config *config)
-{
-   struct pipe_screen *screen;
-
-   screen = nouveau_drm_screen_create(fd);
-   if (!screen)
-      return NULL;
-
-   screen = debug_screen_wrap(screen);
-
-   return screen;
-}
-
 PUBLIC
-DRM_DRIVER_DESCRIPTOR("nouveau", NULL, create_screen)
+DRM_DRIVER_DESCRIPTOR("nouveau", NULL, pipe_nouveau_create_screen)
diff --git a/src/gallium/targets/pipe-loader/pipe_r300.c b/src/gallium/targets/pipe-loader/pipe_r300.c
index 268a5eee287..8fd1899230f 100644
--- a/src/gallium/targets/pipe-loader/pipe_r300.c
+++ b/src/gallium/targets/pipe-loader/pipe_r300.c
@@ -1,17 +1,9 @@
+#include "target-helpers/drm_helper.h"
 #include "target-helpers/inline_debug_helper.h"
 #include "frontend/drm_driver.h"
 #include "radeon/drm/radeon_drm_public.h"
 #include "radeon/radeon_winsys.h"
 #include "r300/r300_public.h"
 
-static struct pipe_screen *
-create_screen(int fd, const struct pipe_screen_config *config)
-{
-   struct radeon_winsys *sws;
-
-   sws = radeon_drm_winsys_create(fd, config, r300_screen_create);
-   return sws ? debug_screen_wrap(sws->screen) : NULL;
-}
-
 PUBLIC
-DRM_DRIVER_DESCRIPTOR("r300", NULL, create_screen)
+DRM_DRIVER_DESCRIPTOR("r300", NULL, pipe_r300_create_screen)
diff --git a/src/gallium/targets/pipe-loader/pipe_r600.c b/src/gallium/targets/pipe-loader/pipe_r600.c
index 871dff3f7e1..092f51b9d2e 100644
--- a/src/gallium/targets/pipe-loader/pipe_r600.c
+++ b/src/gallium/targets/pipe-loader/pipe_r600.c
@@ -1,17 +1,9 @@
 #include "frontend/drm_driver.h"
+#include "target-helpers/drm_helper.h"
 #include "target-helpers/inline_debug_helper.h"
 #include "radeon/drm/radeon_drm_public.h"
 #include "radeon/radeon_winsys.h"
 #include "r600/r600_public.h"
 
-static struct pipe_screen *
-create_screen(int fd, const struct pipe_screen_config *config)
-{
-   struct radeon_winsys *rw;
-
-   rw = radeon_drm_winsys_create(fd, config, r600_screen_create);
-   return rw ? debug_screen_wrap(rw->screen) : NULL;
-}
-
 PUBLIC
-DRM_DRIVER_DESCRIPTOR("r600", NULL, create_screen)
+DRM_DRIVER_DESCRIPTOR("r600", NULL, pipe_r600_create_screen)
diff --git a/src/gallium/targets/pipe-loader/pipe_radeonsi.c b/src/gallium/targets/pipe-loader/pipe_radeonsi.c
index d8cbe02c1b7..57177d8a723 100644
--- a/src/gallium/targets/pipe-loader/pipe_radeonsi.c
+++ b/src/gallium/targets/pipe-loader/pipe_radeonsi.c
@@ -1,19 +1,12 @@
 #include "frontend/drm_driver.h"
+#include "target-helpers/drm_helper.h"
 #include "target-helpers/inline_debug_helper.h"
 #include "radeonsi/si_public.h"
 #include "util/driconf.h"
 
-static struct pipe_screen *
-create_screen(int fd, const struct pipe_screen_config *config)
-{
-   struct pipe_screen *screen = radeonsi_screen_create(fd, config);
-
-   return screen ? debug_screen_wrap(screen) : NULL;
-}
-
 static const char *driconf_xml =
    #include "radeonsi/si_driinfo.h"
    ;
 
 PUBLIC
-DRM_DRIVER_DESCRIPTOR("radeonsi", &driconf_xml, create_screen)
+DRM_DRIVER_DESCRIPTOR("radeonsi", &driconf_xml, pipe_radeonsi_create_screen)
diff --git a/src/gallium/targets/pipe-loader/pipe_vmwgfx.c b/src/gallium/targets/pipe-loader/pipe_vmwgfx.c
index 73c6bda9879..91539017fea 100644
--- a/src/gallium/targets/pipe-loader/pipe_vmwgfx.c
+++ b/src/gallium/targets/pipe-loader/pipe_vmwgfx.c
@@ -1,27 +1,9 @@
 
 #include "target-helpers/inline_debug_helper.h"
+#include "target-helpers/drm_helper.h"
 #include "frontend/drm_driver.h"
 #include "svga/drm/svga_drm_public.h"
 #include "svga/svga_public.h"
 
-static struct pipe_screen *
-create_screen(int fd, const struct pipe_screen_config *config)
-{
-   struct svga_winsys_screen *sws;
-   struct pipe_screen *screen;
-
-   sws = svga_drm_winsys_screen_create(fd);
-   if (!sws)
-      return NULL;
-
-   screen = svga_screen_create(sws);
-   if (!screen)
-      return NULL;
-
-   screen = debug_screen_wrap(screen);
-
-   return screen;
-}
-
 PUBLIC
-DRM_DRIVER_DESCRIPTOR("vmwgfx", NULL, create_screen)
+DRM_DRIVER_DESCRIPTOR("vmwgfx", NULL, pipe_vmwgfx_create_screen)



More information about the mesa-commit mailing list