{st,targets}/dri: use static/dynamic pipe-loader
authorEmil Velikov <emil.l.velikov@gmail.com>
Wed, 14 Oct 2015 22:48:15 +0000 (23:48 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Sat, 21 Nov 2015 12:52:20 +0000 (12:52 +0000)
Covert DRI to use only the pipe-loader interface.

With drisw_create_screen and kms_swrast_create_screen replaced by their
pipe-loader equivalent, we can now drop them.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Acked-by: Rob Clark <robclark@freedesktop.org>
13 files changed:
src/gallium/auxiliary/target-helpers/inline_drm_helper.h
src/gallium/auxiliary/target-helpers/inline_sw_helper.h
src/gallium/drivers/softpipe/Automake.inc
src/gallium/state_trackers/dri/Android.mk
src/gallium/state_trackers/dri/Makefile.am
src/gallium/state_trackers/dri/SConscript
src/gallium/state_trackers/dri/dri2.c
src/gallium/state_trackers/dri/dri_screen.c
src/gallium/state_trackers/dri/drisw.c
src/gallium/targets/dri/Android.mk
src/gallium/targets/dri/Makefile.am
src/gallium/targets/dri/SConscript
src/gallium/targets/dri/target.c

index 55f636339b3a95de5ebaf3595609932ef37998af..c57fbac7f358c15a6fba7200ce716557a273346b 100644 (file)
@@ -4,9 +4,6 @@
 #include "state_tracker/drm_driver.h"
 #include "target-helpers/inline_debug_helper.h"
 #include "loader.h"
-#if defined(DRI_TARGET)
-#include "dri_screen.h"
-#endif
 
 #if GALLIUM_SOFTPIPE
 #include "target-helpers/inline_sw_helper.h"
@@ -68,27 +65,6 @@ static char* driver_name = NULL;
 
 /* XXX: We need to teardown the winsys if *screen_create() fails. */
 
-#if defined(GALLIUM_SOFTPIPE)
-#if defined(DRI_TARGET)
-#if defined(HAVE_LIBDRM)
-
-struct pipe_screen *
-kms_swrast_create_screen(int fd)
-{
-   struct sw_winsys *sws;
-   struct pipe_screen *screen;
-
-   sws = kms_dri_create_winsys(fd);
-   if (!sws)
-      return NULL;
-
-   screen = sw_screen_create(sws);
-   return screen ? debug_screen_wrap(screen) : NULL;
-}
-#endif
-#endif
-#endif
-
 #if defined(GALLIUM_I915)
 
 static struct pipe_screen *
index 16937bc6a53dd1457d6d559a18ec2ab8ec3c097a..a9ab16f2b544ee3622ffe2f4dadbf477743fc784 100644 (file)
@@ -69,32 +69,4 @@ sw_screen_create(struct sw_winsys *winsys)
    return sw_screen_create_named(winsys, driver);
 }
 
-#if defined(GALLIUM_SOFTPIPE)
-#if defined(DRI_TARGET)
-#include "target-helpers/inline_debug_helper.h"
-#include "sw/dri/dri_sw_winsys.h"
-
-inline struct pipe_screen *
-drisw_create_screen(struct drisw_loader_funcs *lf)
-{
-   struct sw_winsys *winsys = NULL;
-   struct pipe_screen *screen = NULL;
-
-   winsys = dri_create_sw_winsys(lf);
-   if (winsys == NULL)
-      return NULL;
-
-   screen = sw_screen_create(winsys);
-   if (screen == NULL) {
-      winsys->destroy(winsys);
-      return NULL;
-   }
-
-   screen = debug_screen_wrap(screen);
-   return screen;
-}
-#endif // DRI_TARGET
-#endif // GALLIUM_SOFTPIPE
-
-
 #endif
index 5cedcef9772a625a86135780e8edaebbfc608c15..bd3c2eead16d115c9e51edf33cf9c1376b34029f 100644 (file)
@@ -3,13 +3,10 @@ if HAVE_GALLIUM_SOFTPIPE
 TARGET_DRIVERS += swrast
 TARGET_CPPFLAGS += -DGALLIUM_SOFTPIPE
 TARGET_LIB_DEPS += \
-       $(top_builddir)/src/gallium/winsys/sw/dri/libswdri.la \
        $(top_builddir)/src/gallium/drivers/softpipe/libsoftpipe.la
 
 if HAVE_DRISW_KMS
 TARGET_DRIVERS += kms_swrast
-TARGET_LIB_DEPS += \
-       $(top_builddir)/src/gallium/winsys/sw/kms-dri/libswkmsdri.la
 
 endif
 endif
index 43f0de9b46468aec58288d6535f9cbcda98ea86b..f0eb18dcacf3d7c2eaf96d682942e5968827c884 100644 (file)
@@ -29,9 +29,6 @@ include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := $(common_SOURCES)
 
-LOCAL_CFLAGS := \
-       -DGALLIUM_STATIC_TARGETS=1 \
-
 LOCAL_C_INCLUDES := \
        $(MESA_TOP)/src/mapi \
        $(MESA_TOP)/src/mesa \
index 102b84390bbbd69993e280e8c42848d1c4e622cb..74bccaa6416bba8b2d59dd675e4b960ee4d62f76 100644 (file)
@@ -34,15 +34,10 @@ AM_CPPFLAGS = \
        $(LIBDRM_CFLAGS) \
        $(VISIBILITY_CFLAGS)
 
-if HAVE_GALLIUM_STATIC_TARGETS
-AM_CPPFLAGS += \
-       -DGALLIUM_STATIC_TARGETS=1
-
 if HAVE_GALLIUM_SOFTPIPE
 AM_CPPFLAGS += \
        -DGALLIUM_SOFTPIPE
 endif # HAVE_GALLIUM_SOFTPIPE
-endif # HAVE_GALLIUM_STATIC_TARGETS
 
 noinst_LTLIBRARIES = libdri.la
 libdri_la_SOURCES = $(common_SOURCES)
index 657300baf1344f619778bc2c49457a8123d8dba5..fa48fb8a0d7517b3b47f75e05b806eef7c875b73 100644 (file)
@@ -15,10 +15,6 @@ env.Append(CPPPATH = [
     xmlpool_options.dir.dir, # Dir to generated xmlpool/options.h
 ])
 
-env.Append(CPPDEFINES = [
-    ('GALLIUM_STATIC_TARGETS', '1'),
-])
-
 sources = env.ParseSourceList('Makefile.sources', 'common_SOURCES')
 
 # XXX: if HAVE_DRISW
index a11f3b8d21c154fb5a28e052fe0ff50cb0e157a9..62173750381d4515d8fc38cd27efb08ca425040e 100644 (file)
@@ -1457,19 +1457,12 @@ dri2_init_screen(__DRIscreen * sPriv)
 
    sPriv->driverPrivate = (void *)screen;
 
-#if GALLIUM_STATIC_TARGETS
-   pscreen = dd_create_screen(screen->fd);
-
-   throttle_ret = dd_configuration(DRM_CONF_THROTTLE);
-   dmabuf_ret = dd_configuration(DRM_CONF_SHARE_FD);
-#else
    if (pipe_loader_drm_probe_fd(&screen->dev, screen->fd)) {
       pscreen = pipe_loader_create_screen(screen->dev);
 
       throttle_ret = pipe_loader_configuration(screen->dev, DRM_CONF_THROTTLE);
       dmabuf_ret = pipe_loader_configuration(screen->dev, DRM_CONF_SHARE_FD);
    }
-#endif // GALLIUM_STATIC_TARGETS
 
    if (throttle_ret && throttle_ret->val.val_int != -1) {
       screen->throttling_enabled = TRUE;
@@ -1495,11 +1488,7 @@ dri2_init_screen(__DRIscreen * sPriv)
 
    /* dri_init_screen_helper checks pscreen for us */
 
-#if GALLIUM_STATIC_TARGETS
-   configs = dri_init_screen_helper(screen, pscreen, dd_driver_name());
-#else
    configs = dri_init_screen_helper(screen, pscreen, screen->dev->driver_name);
-#endif // GALLIUM_STATIC_TARGETS
    if (!configs)
       goto fail;
 
@@ -1511,10 +1500,8 @@ dri2_init_screen(__DRIscreen * sPriv)
    return configs;
 fail:
    dri_destroy_screen_helper(screen);
-#if !GALLIUM_STATIC_TARGETS
    if (screen->dev)
       pipe_loader_release(&screen->dev, 1);
-#endif // !GALLIUM_STATIC_TARGETS
    FREE(screen);
    return NULL;
 }
@@ -1527,7 +1514,6 @@ fail:
 static const __DRIconfig **
 dri_kms_init_screen(__DRIscreen * sPriv)
 {
-#if GALLIUM_STATIC_TARGETS
 #if defined(GALLIUM_SOFTPIPE)
    const __DRIconfig **configs;
    struct dri_screen *screen;
@@ -1543,7 +1529,8 @@ dri_kms_init_screen(__DRIscreen * sPriv)
 
    sPriv->driverPrivate = (void *)screen;
 
-   pscreen = kms_swrast_create_screen(screen->fd);
+   if (pipe_loader_sw_probe_kms(&screen->dev, screen->fd))
+      pscreen = pipe_loader_create_screen(screen->dev);
 
    if (drmGetCap(sPriv->fd, DRM_CAP_PRIME, &cap) == 0 &&
           (cap & DRM_PRIME_CAP_IMPORT)) {
@@ -1566,9 +1553,10 @@ dri_kms_init_screen(__DRIscreen * sPriv)
    return configs;
 fail:
    dri_destroy_screen_helper(screen);
+   if (screen->dev)
+      pipe_loader_release(&screen->dev, 1);
    FREE(screen);
 #endif // GALLIUM_SOFTPIPE
-#endif // GALLIUM_STATIC_TARGETS
    return NULL;
 }
 
index c4c2d9c8fb134352471ba1e24149926f7d372e81..cf0f26554d37ed550d341d6f28733a68344fc005 100644 (file)
@@ -390,9 +390,7 @@ dri_destroy_screen(__DRIscreen * sPriv)
 
    dri_destroy_screen_helper(screen);
 
-#if !GALLIUM_STATIC_TARGETS
    pipe_loader_release(&screen->dev, 1);
-#endif // !GALLIUM_STATIC_TARGETS
 
    free(screen);
    sPriv->driverPrivate = NULL;
index 1b24f4896eacc946d8d0928c4dc395dabb1a9683..06fa94276675f4b35bbda1be5b74191bf6818b01 100644 (file)
  * for createImage/destroyImage similar to DRI2 getBuffers.
  */
 
-/* XXX: Temporary hack, until we get rid of drisw_create_screen() */
-#define DRI_TARGET
-
 #include "util/u_format.h"
 #include "util/u_memory.h"
 #include "util/u_inlines.h"
 #include "util/u_box.h"
 #include "pipe/p_context.h"
+#include "pipe-loader/pipe_loader.h"
 #include "state_tracker/drisw_api.h"
 #include "state_tracker/st_context.h"
 
@@ -385,7 +383,7 @@ drisw_init_screen(__DRIscreen * sPriv)
 {
    const __DRIconfig **configs;
    struct dri_screen *screen;
-   struct pipe_screen *pscreen;
+   struct pipe_screen *pscreen = NULL;
 
    screen = CALLOC_STRUCT(dri_screen);
    if (!screen)
@@ -399,7 +397,9 @@ drisw_init_screen(__DRIscreen * sPriv)
    sPriv->driverPrivate = (void *)screen;
    sPriv->extensions = drisw_screen_extensions;
 
-   pscreen = drisw_create_screen(&drisw_lf);
+   if (pipe_loader_sw_probe_dri(&screen->dev, &drisw_lf))
+      pscreen = pipe_loader_create_screen(screen->dev);
+
    /* dri_init_screen_helper checks pscreen for us */
 
    configs = dri_init_screen_helper(screen, pscreen, "swrast");
@@ -409,6 +409,8 @@ drisw_init_screen(__DRIscreen * sPriv)
    return configs;
 fail:
    dri_destroy_screen_helper(screen);
+   if (screen->dev)
+      pipe_loader_release(&screen->dev, 1);
    FREE(screen);
    return NULL;
 }
index 89b420fa7fead26a35a874a8e6961e22246a6fe3..2d9610ee9abbcb2b7263d6aaa9793eac7694a75e 100644 (file)
@@ -108,6 +108,7 @@ LOCAL_STATIC_LIBRARIES := \
        libmesa_dri_common \
        libmesa_megadriver_stub \
        libmesa_gallium \
+       libmesa_pipe_loader \
        libmesa_util \
        libmesa_loader \
 
index b05441f8a9f77d851d7fa1da164749cc5796da36..2666524fbfe9100d901614f00fd16a54747ac59b 100644 (file)
@@ -64,7 +64,7 @@ EXTRA_DIST = \
 
 TARGET_DRIVERS =
 TARGET_CPPFLAGS =
-TARGET_LIB_DEPS = $(top_builddir)/src/loader/libloader.la
+TARGET_LIB_DEPS =
 
 include $(top_srcdir)/src/gallium/drivers/i915/Automake.inc
 
@@ -91,7 +91,10 @@ if HAVE_GALLIUM_STATIC_TARGETS
 
 gallium_dri_la_SOURCES += target.c
 gallium_dri_la_CPPFLAGS = $(AM_CPPFLAGS) $(TARGET_CPPFLAGS)
-gallium_dri_la_LIBADD += $(TARGET_LIB_DEPS) \
+gallium_dri_la_LIBADD += \
+       $(top_builddir)/src/gallium/auxiliary/pipe-loader/libpipe_loader_static.la \
+       $(GALLIUM_PIPE_LOADER_WINSYS_LIBS) \
+       $(TARGET_LIB_DEPS) \
        $(TARGET_RADEON_WINSYS) $(TARGET_RADEON_COMMON)
 
 else # HAVE_GALLIUM_STATIC_TARGETS
index 8d28924cb040276b5bfb0e4840ec464213bccc15..b4516598675937c7f72ec3bbe9cfb4b71af6f74b 100644 (file)
@@ -38,6 +38,7 @@ env.Prepend(LIBS = [
     svga,
     ws_dri,
     softpipe,
+    pipe_loader,
     libloader,
     mesautil,
     mesa,
index 16a958bdf6717f4cc57d08dfcb8c5854910ca04a..d6fbd01b88f227f3fe59d8a73f052a62fbab6b0d 100644 (file)
@@ -1,5 +1,4 @@
-#include "target-helpers/inline_drm_helper.h"
-#include "target-helpers/inline_sw_helper.h"
+#include "target-helpers/drm_helper.h"
 
 #include "dri_screen.h"