st/dri: get drirc options before creating pipe_screen
authorMarek Olšák <marek.olsak@amd.com>
Tue, 20 Jun 2017 22:34:12 +0000 (00:34 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 23 Jun 2017 17:50:20 +0000 (19:50 +0200)
dri_init_options_get_screen_flags will return the flags for create_screen().

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/state_trackers/dri/dri2.c
src/gallium/state_trackers/dri/dri_screen.c
src/gallium/state_trackers/dri/dri_screen.h
src/gallium/state_trackers/dri/drisw.c

index 2d0e78cfdda9356826adac7f6109f031e96a1bff..2402c61bd85e25cb99cd822113843239f24e2523 100644 (file)
@@ -2025,8 +2025,13 @@ dri2_init_screen(__DRIscreen * sPriv)
    if (screen->fd < 0 || (fd = fcntl(screen->fd, F_DUPFD_CLOEXEC, 3)) < 0)
       goto free_screen;
 
-   if (pipe_loader_drm_probe_fd(&screen->dev, fd))
-      pscreen = pipe_loader_create_screen(screen->dev, 0);
+
+   if (pipe_loader_drm_probe_fd(&screen->dev, fd)) {
+      unsigned flags =
+         dri_init_options_get_screen_flags(screen, screen->dev->driver_name);
+
+      pscreen = pipe_loader_create_screen(screen->dev, flags);
+   }
 
    if (!pscreen)
        goto release_pipe;
@@ -2064,7 +2069,7 @@ dri2_init_screen(__DRIscreen * sPriv)
    else
       sPriv->extensions = dri_screen_extensions;
 
-   configs = dri_init_screen_helper(screen, pscreen, screen->dev->driver_name);
+   configs = dri_init_screen_helper(screen, pscreen);
    if (!configs)
       goto destroy_screen;
 
@@ -2116,8 +2121,10 @@ dri_kms_init_screen(__DRIscreen * sPriv)
    if (screen->fd < 0 || (fd = fcntl(screen->fd, F_DUPFD_CLOEXEC, 3)) < 0)
       goto free_screen;
 
+   unsigned flags = dri_init_options_get_screen_flags(screen, "swrast");
+
    if (pipe_loader_sw_probe_kms(&screen->dev, fd))
-      pscreen = pipe_loader_create_screen(screen->dev, 0);
+      pscreen = pipe_loader_create_screen(screen->dev, flags);
 
    if (!pscreen)
        goto release_pipe;
@@ -2137,7 +2144,7 @@ dri_kms_init_screen(__DRIscreen * sPriv)
 
    sPriv->extensions = dri_screen_extensions;
 
-   configs = dri_init_screen_helper(screen, pscreen, "swrast");
+   configs = dri_init_screen_helper(screen, pscreen);
    if (!configs)
       goto destroy_screen;
 
index a66689e99e9a9e2e811fe4f82cce50bd9531db52..1b414b28d1adc3f335b2216304cacd04149899af 100644 (file)
@@ -460,10 +460,25 @@ dri_set_background_context(struct st_context_iface *st)
    backgroundCallable->setBackgroundContext(ctx->cPriv->loaderPrivate);
 }
 
+unsigned
+dri_init_options_get_screen_flags(struct dri_screen *screen,
+                                  const char* driver_name)
+{
+   unsigned flags = 0;
+
+   driParseOptionInfo(&screen->optionCacheDefaults, gallium_config_options.xml);
+   driParseConfigFiles(&screen->optionCache,
+                       &screen->optionCacheDefaults,
+                       screen->sPriv->myNum,
+                       driver_name);
+   dri_fill_st_options(screen);
+
+   return flags;
+}
+
 const __DRIconfig **
 dri_init_screen_helper(struct dri_screen *screen,
-                       struct pipe_screen *pscreen,
-                       const char* driver_name)
+                       struct pipe_screen *pscreen)
 {
    screen->base.screen = pscreen;
    screen->base.get_egl_image = dri_get_egl_image;
@@ -479,15 +494,6 @@ dri_init_screen_helper(struct dri_screen *screen,
    else
       screen->target = PIPE_TEXTURE_RECT;
 
-   driParseOptionInfo(&screen->optionCacheDefaults, gallium_config_options.xml);
-
-   driParseConfigFiles(&screen->optionCache,
-                       &screen->optionCacheDefaults,
-                       screen->sPriv->myNum,
-                       driver_name);
-
-   dri_fill_st_options(screen);
-
    /* Handle force_s3tc_enable. */
    if (!util_format_s3tc_enabled && screen->options.force_s3tc_enable) {
       /* Ensure libtxc_dxtn has been loaded if available.
index 7f5fd13630f9072bff037fb80e41e648ad767a2a..550bc510cecfefa481c3612bb0b142cf30f38ab1 100644 (file)
@@ -137,10 +137,13 @@ void
 dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen,
                    const struct gl_config *mode);
 
+unsigned
+dri_init_options_get_screen_flags(struct dri_screen *screen,
+                                  const char* driver_name);
+
 const __DRIconfig **
 dri_init_screen_helper(struct dri_screen *screen,
-                       struct pipe_screen *pscreen,
-                       const char* driver_name);
+                       struct pipe_screen *pscreen);
 
 void
 dri_destroy_screen_helper(struct dri_screen * screen);
index 877aa716d2686f74bf4d6516f220a50ae1e11d1f..189d61c4cb6e16f780734deba78e3fbbec47120f 100644 (file)
@@ -399,13 +399,15 @@ drisw_init_screen(__DRIscreen * sPriv)
    sPriv->driverPrivate = (void *)screen;
    sPriv->extensions = drisw_screen_extensions;
 
+   unsigned flags = dri_init_options_get_screen_flags(screen, "swrast");
+
    if (pipe_loader_sw_probe_dri(&screen->dev, &drisw_lf))
-      pscreen = pipe_loader_create_screen(screen->dev, 0);
+      pscreen = pipe_loader_create_screen(screen->dev, flags);
 
    if (!pscreen)
       goto fail;
 
-   configs = dri_init_screen_helper(screen, pscreen, "swrast");
+   configs = dri_init_screen_helper(screen, pscreen);
    if (!configs)
       goto fail;