st/dri: Allow separate dri-targets
authorEmil Velikov <emil.l.velikov@gmail.com>
Sun, 15 Jun 2014 23:20:07 +0000 (00:20 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Wed, 2 Jul 2014 09:52:52 +0000 (10:52 +0100)
With this commit we add a couple of DEFINES making the ST code
conditional, in a way that we can use it to gradually convert
the dri-targets from separate libraries into a single one.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Tested-by: Rob Clark <robclark@freedesktop.org>
Tested-by: Thomas Helland <thomashelland90 at gmail.com>
Acked-by: Tom Stellard <thomas.stellard@amd.com>
src/gallium/state_trackers/dri/common/dri_screen.c
src/gallium/state_trackers/dri/common/dri_screen.h
src/gallium/state_trackers/dri/drm/Makefile.am
src/gallium/state_trackers/dri/drm/SConscript
src/gallium/state_trackers/dri/drm/dri2.c
src/gallium/state_trackers/dri/sw/Makefile.am
src/gallium/state_trackers/dri/sw/SConscript

index 7a6dcb278fd49f10df28523743f6df9e44e4e928..dceb628015ee5834c19b560a046a333d3c55985c 100644 (file)
@@ -37,6 +37,7 @@
 #include "util/u_inlines.h"
 #include "pipe/p_screen.h"
 #include "pipe/p_format.h"
+#include "pipe-loader/pipe_loader.h"
 #include "state_tracker/st_gl_api.h" /* for st_gl_api_create */
 #include "state_tracker/drm_driver.h"
 
@@ -387,6 +388,12 @@ dri_destroy_screen(__DRIscreen * sPriv)
 
    dri_destroy_screen_helper(screen);
 
+#if !SPLIT_TARGETS
+#if !GALLIUM_STATIC_TARGETS
+   pipe_loader_release(&screen->dev, 1);
+#endif // !GALLIUM_STATIC_TARGETS
+#endif // !SPLIT_TARGETS
+
    free(screen);
    sPriv->driverPrivate = NULL;
    sPriv->extensions = NULL;
@@ -428,9 +435,17 @@ dri_init_screen_helper(struct dri_screen *screen,
    driParseOptionInfo(&screen->optionCacheDefaults, gallium_config_options.xml);
 
    driParseConfigFiles(&screen->optionCache,
-                      &screen->optionCacheDefaults,
+                       &screen->optionCacheDefaults,
                        screen->sPriv->myNum,
+#if SPLIT_TARGETS
                        driver_descriptor.name);
+#else
+#if GALLIUM_STATIC_TARGETS
+                       dd_driver_name());
+#else
+                       screen->dev->driver_name);
+#endif // GALLIUM_STATIC_TARGETS
+#endif // SPLIT_TARGETS
 
    /* Handle force_s3tc_enable. */
    if (!util_format_s3tc_enabled &&
index 7c8e5823fc3a7c87c0fd1ba9d932f12c9bc11ba5..2d07f517db6ae819ad3e46f0b00b4b6dba6d63ce 100644 (file)
@@ -43,6 +43,7 @@
 
 struct dri_context;
 struct dri_drawable;
+struct pipe_loader_device;
 
 struct dri_screen
 {
@@ -70,6 +71,8 @@ struct dri_screen
    /* drm */
    int fd;
 
+   struct pipe_loader_device *dev;
+
    /* gallium */
    boolean d_depth_bits_last;
    boolean sd_depth_bits_last;
index f41f45d957ddc9b84fd15be14a72a09bde606a78..a348f65f39000b8c7c12c5450f6cbdb64945c159 100644 (file)
@@ -24,6 +24,8 @@ include Makefile.sources
 include $(top_srcdir)/src/gallium/Automake.inc
 
 AM_CPPFLAGS = \
+       $(GALLIUM_PIPE_LOADER_DEFINES) \
+       -DPIPE_SEARCH_DIR=\"$(libdir)/gallium-pipe\" \
        -I$(top_srcdir)/include \
        -I$(top_srcdir)/src/mapi \
        -I$(top_srcdir)/src/mesa \
@@ -36,4 +38,8 @@ AM_CPPFLAGS = \
 
 noinst_LTLIBRARIES = libdridrm.la
 
+libdridrm_la_CPPFLAGS = \
+       $(AM_CPPFLAGS) \
+       -DSPLIT_TARGETS=1
+
 libdridrm_la_SOURCES = $(C_SOURCES)
index 07eaa0ae1b5081b8c2a1512ea64861bfc64dc429..258f7eed702caf01b3097c43182d2f0a08d12151 100644 (file)
@@ -15,6 +15,8 @@ env.Append(CPPPATH = [
     xmlpool_options.dir.dir, # Dir to generated xmlpool/options.h
 ])
 
+env.Append(CPPDEFINES = [('SPLIT_TARGETS', '1')])
+
 st_dri = env.ConvenienceLibrary(
     target = 'st_dri',
     source = env.ParseSourceList('Makefile.sources', 'C_SOURCES')
index 275c6508cfcb80bcc1767fa8ae225b0c444b2239..898fd0ab1f68027e5657976886ab00fe39646cc2 100644 (file)
@@ -36,6 +36,7 @@
 #include "state_tracker/drm_driver.h"
 #include "state_tracker/st_texture.h"
 #include "state_tracker/st_context.h"
+#include "pipe-loader/pipe_loader.h"
 #include "main/texobj.h"
 
 #include "dri_screen.h"
@@ -1227,7 +1228,7 @@ dri2_init_screen(__DRIscreen * sPriv)
 {
    const __DRIconfig **configs;
    struct dri_screen *screen;
-   struct pipe_screen *pscreen;
+   struct pipe_screen *pscreen = NULL;
    const struct drm_conf_ret *throttle_ret = NULL;
    const struct drm_conf_ret *dmabuf_ret = NULL;
 
@@ -1240,12 +1241,29 @@ dri2_init_screen(__DRIscreen * sPriv)
 
    sPriv->driverPrivate = (void *)screen;
 
+#if SPLIT_TARGETS
    pscreen = driver_descriptor.create_screen(screen->fd);
    if (driver_descriptor.configuration) {
       throttle_ret = driver_descriptor.configuration(DRM_CONF_THROTTLE);
       dmabuf_ret = driver_descriptor.configuration(DRM_CONF_SHARE_FD);
    }
 
+#else
+#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, true)) {
+      pscreen = pipe_loader_create_screen(screen->dev, PIPE_SEARCH_DIR);
+
+      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
+#endif // SPLIT_TARGETS
+
    if (throttle_ret && throttle_ret->val.val_int != -1) {
       screen->throttling_enabled = TRUE;
       screen->default_throttle_frames = throttle_ret->val.val_int;
@@ -1276,6 +1294,12 @@ dri2_init_screen(__DRIscreen * sPriv)
    return configs;
 fail:
    dri_destroy_screen_helper(screen);
+#if !SPLIT_TARGETS
+#if !GALLIUM_STATIC_TARGETS
+   if (screen->dev)
+      pipe_loader_release(&screen->dev, 1);
+#endif // !GALLIUM_STATIC_TARGETS
+#endif // !SPLIT_TARGETS
    FREE(screen);
    return NULL;
 }
index 555ea171636f35034f97b301e2e3d282b24e7386..0cebd6df5fa0a53d94e2775a4e7d1d0bf59772cc 100644 (file)
@@ -24,6 +24,9 @@ include Makefile.sources
 include $(top_srcdir)/src/gallium/Automake.inc
 
 AM_CPPFLAGS = \
+       $(GALLIUM_PIPE_LOADER_DEFINES) \
+       -DPIPE_SEARCH_DIR=\"$(libdir)/gallium-pipe\" \
+       -DSPLIT_TARGETS=1 \
        -I$(top_srcdir)/src/mapi \
        -I$(top_srcdir)/src/mesa \
        -I$(top_srcdir)/src/gallium/state_trackers/dri/common \
index 6d482a5bc947070139e9f6dcabc5af533341e0d3..5a71b2246f04796a51db3771ced251c96467d786 100644 (file)
@@ -14,6 +14,7 @@ env.Append(CPPPATH = [
 ])
 
 env.Append(CPPDEFINES = [('__NOT_HAVE_DRM_H', '1')])
+env.Append(CPPDEFINES = [('SPLIT_TARGETS', '1')])
 
 st_drisw = env.ConvenienceLibrary(
     target = 'st_drisw',