Mesa (main): gallium/driconf: Allow the driver to parse the driconf options.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Aug 3 00:25:18 UTC 2021


Module: Mesa
Branch: main
Commit: b080aa94664e23b4be4f565e442eac0292fd3e9d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b080aa94664e23b4be4f565e442eac0292fd3e9d

Author: Emma Anholt <emma at anholt.net>
Date:   Fri Jul 30 14:47:33 2021 -0700

gallium/driconf: Allow the driver to parse the driconf options.

This will give the driver a chance to set a device name separate from the
driver name, using info probed during screen creation.  All drivers
querying driconf in screen creation now have to call parsing on their own,
but other drivers get fallback parsing after screen creation.

Reviewed-by: Emil Velikov <emil.l.velikov at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12135>

---

 src/gallium/auxiliary/pipe-loader/pipe_loader.c | 13 ++++++++++---
 src/gallium/drivers/crocus/crocus_screen.c      |  3 +++
 src/gallium/drivers/iris/iris_screen.c          |  3 +++
 src/gallium/drivers/radeonsi/si_pipe.c          |  3 +++
 src/gallium/drivers/v3d/v3d_screen.c            |  3 +++
 src/gallium/drivers/virgl/virgl_screen.c        |  3 +++
 src/gallium/drivers/zink/zink_screen.c          |  5 ++++-
 src/gallium/frontends/dri/dri_screen.c          |  2 ++
 src/gallium/include/pipe/p_screen.h             |  3 ++-
 9 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader.c b/src/gallium/auxiliary/pipe-loader/pipe_loader.c
index 1c46cb429e6..d044db40b46 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.c
@@ -124,13 +124,19 @@ pipe_loader_load_options(struct pipe_loader_device *dev)
 
    const driOptionDescription *merged_driconf =
       merge_driconf(driver_driconf, driver_count, &merged_count);
-
    driParseOptionInfo(&dev->option_info, merged_driconf, merged_count);
-   driParseConfigFiles(&dev->option_cache, &dev->option_info, 0,
-                       dev->driver_name, NULL, NULL, 0, NULL, 0);
    free((void *)merged_driconf);
 }
 
+void
+pipe_loader_config_options(struct pipe_loader_device *dev)
+{
+   if (!dev->option_cache.info) {
+      driParseConfigFiles(&dev->option_cache, &dev->option_info, 0,
+                          dev->driver_name, NULL, NULL, 0, NULL, 0);
+   }
+}
+
 char *
 pipe_loader_get_driinfo_xml(const char *driver_name)
 {
@@ -161,6 +167,7 @@ pipe_loader_create_screen_vk(struct pipe_loader_device *dev, bool sw_vk)
 
    util_cpu_detect();
    pipe_loader_load_options(dev);
+   config.options_info = &dev->option_info;
    config.options = &dev->option_cache;
 
    return dev->ops->create_screen(dev, &config, sw_vk);
diff --git a/src/gallium/drivers/crocus/crocus_screen.c b/src/gallium/drivers/crocus/crocus_screen.c
index c0828e98b42..7ed222801b1 100644
--- a/src/gallium/drivers/crocus/crocus_screen.c
+++ b/src/gallium/drivers/crocus/crocus_screen.c
@@ -765,6 +765,9 @@ crocus_screen_create(int fd, const struct pipe_screen_config *config)
    if (getenv("INTEL_NO_HW") != NULL)
       screen->no_hw = true;
 
+   driParseConfigFiles(config->options, config->options_info, 0, "crocus",
+                       NULL, NULL, 0, NULL, 0);
+
    bool bo_reuse = false;
    int bo_reuse_mode = driQueryOptioni(config->options, "bo_reuse");
    switch (bo_reuse_mode) {
diff --git a/src/gallium/drivers/iris/iris_screen.c b/src/gallium/drivers/iris/iris_screen.c
index 78db283ec37..d9b667d13d2 100644
--- a/src/gallium/drivers/iris/iris_screen.c
+++ b/src/gallium/drivers/iris/iris_screen.c
@@ -811,6 +811,9 @@ iris_screen_create(int fd, const struct pipe_screen_config *config)
    if (screen->devinfo.ver < 8 || screen->devinfo.is_cherryview)
       return NULL;
 
+   driParseConfigFiles(config->options, config->options_info, 0, "iris",
+                       NULL, NULL, 0, NULL, 0);
+
    bool bo_reuse = false;
    int bo_reuse_mode = driQueryOptioni(config->options, "bo_reuse");
    switch (bo_reuse_mode) {
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
index ebba2ecdc2d..ded49817f7e 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -1399,6 +1399,9 @@ struct pipe_screen *radeonsi_screen_create(int fd, const struct pipe_screen_conf
    drmVersionPtr version = drmGetVersion(fd);
    struct radeon_winsys *rw = NULL;
 
+   driParseConfigFiles(config->options, config->options_info, 0, "radeonsi",
+                       NULL, NULL, 0, NULL, 0);
+
    switch (version->version_major) {
    case 2:
       rw = radeon_drm_winsys_create(fd, config, radeonsi_screen_create_impl);
diff --git a/src/gallium/drivers/v3d/v3d_screen.c b/src/gallium/drivers/v3d/v3d_screen.c
index 6112e4b1290..fef538f8ec7 100644
--- a/src/gallium/drivers/v3d/v3d_screen.c
+++ b/src/gallium/drivers/v3d/v3d_screen.c
@@ -793,6 +793,9 @@ v3d_screen_create(int fd, const struct pipe_screen_config *config,
         if (!v3d_get_device_info(screen->fd, &screen->devinfo, &v3d_ioctl))
                 goto fail;
 
+        driParseConfigFiles(config->options, config->options_info, 0, "v3d",
+                            NULL, NULL, 0, NULL, 0);
+
         /* We have to driCheckOption for the simulator mode to not assertion
          * fail on not having our XML config.
          */
diff --git a/src/gallium/drivers/virgl/virgl_screen.c b/src/gallium/drivers/virgl/virgl_screen.c
index d9c18f545e4..a089a52d7f6 100644
--- a/src/gallium/drivers/virgl/virgl_screen.c
+++ b/src/gallium/drivers/virgl/virgl_screen.c
@@ -942,6 +942,9 @@ virgl_create_screen(struct virgl_winsys *vws, const struct pipe_screen_config *c
    virgl_debug = debug_get_option_virgl_debug();
 
    if (config && config->options) {
+      driParseConfigFiles(config->options, config->options_info, 0, "virtio_gpu",
+                          NULL, NULL, 0, NULL, 0);
+
       screen->tweak_gles_emulate_bgra =
             driQueryOptionb(config->options, VIRGL_GLES_EMULATE_BGRA);
       screen->tweak_gles_apply_bgra_dest_swizzle =
diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c
index f75c07f7ab8..256f53f56ea 100644
--- a/src/gallium/drivers/zink/zink_screen.c
+++ b/src/gallium/drivers/zink/zink_screen.c
@@ -1902,9 +1902,12 @@ zink_internal_create_screen(const struct pipe_screen_config *config)
    slab_create_parent(&screen->transfer_pool, sizeof(struct zink_transfer), 16);
 
 #if WITH_XMLCONFIG
-   if (config)
+   if (config) {
+      driParseConfigFiles(config->options, config->options_info, 0, "zink",
+                          NULL, NULL, 0, NULL, 0);
       screen->driconf.dual_color_blend_by_location = driQueryOptionb(config->options, "dual_color_blend_by_location");
       //screen->driconf.inline_uniforms = driQueryOptionb(config->options, "radeonsi_inline_uniforms");
+   }
 #endif
    screen->driconf.inline_uniforms = debug_get_bool_option("ZINK_INLINE_UNIFORMS", false);
 
diff --git a/src/gallium/frontends/dri/dri_screen.c b/src/gallium/frontends/dri/dri_screen.c
index c53501429b2..4810dd4d787 100644
--- a/src/gallium/frontends/dri/dri_screen.c
+++ b/src/gallium/frontends/dri/dri_screen.c
@@ -59,6 +59,8 @@ const __DRIconfigOptionsExtension gallium_config_options = {
 void
 dri_init_options(struct dri_screen *screen)
 {
+   pipe_loader_config_options(screen->dev);
+
    struct st_config_options *options = &screen->options;
    const struct driOptionCache *optionCache = &screen->dev->option_cache;
 
diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h
index 82ec36e256b..7accb591f09 100644
--- a/src/gallium/include/pipe/p_screen.h
+++ b/src/gallium/include/pipe/p_screen.h
@@ -611,7 +611,8 @@ struct pipe_screen {
  * Global configuration options for screen creation.
  */
 struct pipe_screen_config {
-   const struct driOptionCache *options;
+   struct driOptionCache *options;
+   const struct driOptionCache *options_info;
 };
 
 



More information about the mesa-commit mailing list