diff options
author | Nicolai Hähnle <[email protected]> | 2017-06-28 17:50:19 +0200 |
---|---|---|
committer | Nicolai Hähnle <[email protected]> | 2017-08-02 09:50:57 +0200 |
commit | e794f8bf8bdb7cd0820251b46a9387ea5a7316da (patch) | |
tree | cda2f6ab2301d409ce404f13ab5b4bfcbe3588a9 /src/gallium/auxiliary/pipe-loader | |
parent | 678dadf1237a3fb492ee2d8daa32d0205dea59ba (diff) |
gallium: move loading of drirc to pipe-loader
v2: rebase compile fix: addition of mesa_no_error
Reviewed-by: Marek Olšák <[email protected]> (v1)
Diffstat (limited to 'src/gallium/auxiliary/pipe-loader')
-rw-r--r-- | src/gallium/auxiliary/pipe-loader/pipe_loader.c | 29 | ||||
-rw-r--r-- | src/gallium/auxiliary/pipe-loader/pipe_loader.h | 14 | ||||
-rw-r--r-- | src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c | 3 | ||||
-rw-r--r-- | src/gallium/auxiliary/pipe-loader/pipe_loader_priv.h | 11 | ||||
-rw-r--r-- | src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c | 3 |
5 files changed, 56 insertions, 4 deletions
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader.c b/src/gallium/auxiliary/pipe-loader/pipe_loader.c index bb65be15289..95e6b42cf71 100644 --- a/src/gallium/auxiliary/pipe-loader/pipe_loader.c +++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.c @@ -31,6 +31,7 @@ #include "util/u_memory.h" #include "util/u_string.h" #include "util/u_dl.h" +#include "util/xmlconfig.h" #include "util/xmlpool.h" #ifdef _MSC_VER @@ -71,6 +72,16 @@ pipe_loader_release(struct pipe_loader_device **devs, int ndev) devs[i]->ops->release(&devs[i]); } +void +pipe_loader_base_release(struct pipe_loader_device **dev) +{ + driDestroyOptionCache(&(*dev)->option_cache); + driDestroyOptionInfo(&(*dev)->option_info); + + FREE(*dev); + *dev = NULL; +} + const struct drm_conf_ret * pipe_loader_configuration(struct pipe_loader_device *dev, enum drm_conf conf) @@ -78,6 +89,24 @@ pipe_loader_configuration(struct pipe_loader_device *dev, return dev->ops->configuration(dev, conf); } +void +pipe_loader_load_options(struct pipe_loader_device *dev) +{ + if (dev->option_info.info) + return; + + const char *xml_options = gallium_driinfo_xml; + const struct drm_conf_ret *xml_options_conf = + pipe_loader_configuration(dev, DRM_CONF_XML_OPTIONS); + + if (xml_options_conf) + xml_options = xml_options_conf->val.val_pointer; + + driParseOptionInfo(&dev->option_info, xml_options); + driParseConfigFiles(&dev->option_cache, &dev->option_info, 0, + dev->driver_name); +} + struct pipe_screen * pipe_loader_create_screen(struct pipe_loader_device *dev, struct pipe_screen_config *config) diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader.h b/src/gallium/auxiliary/pipe-loader/pipe_loader.h index d24480dfd91..a4502ae2586 100644 --- a/src/gallium/auxiliary/pipe-loader/pipe_loader.h +++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.h @@ -35,6 +35,7 @@ #include "pipe/p_compiler.h" #include "state_tracker/drm_driver.h" +#include "util/xmlconfig.h" #ifdef __cplusplus extern "C" { @@ -65,6 +66,9 @@ struct pipe_loader_device { char *driver_name; const struct pipe_loader_ops *ops; + + driOptionCache option_cache; + driOptionCache option_info; }; /** @@ -100,6 +104,16 @@ pipe_loader_configuration(struct pipe_loader_device *dev, enum drm_conf conf); /** + * Ensure that dev->option_cache is initialized appropriately for the driver. + * + * This function can be called multiple times. + * + * \param dev Device for which options should be loaded. + */ +void +pipe_loader_load_options(struct pipe_loader_device *dev); + +/** * Release resources allocated for a list of devices. * * Should be called when the specified devices are no longer in use to diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c index 385d8145223..193c8ddff2f 100644 --- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c +++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c @@ -264,8 +264,7 @@ pipe_loader_drm_release(struct pipe_loader_device **dev) close(ddev->fd); FREE(ddev->base.driver_name); - FREE(ddev); - *dev = NULL; + pipe_loader_base_release(dev); } static const struct drm_conf_ret * diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_priv.h b/src/gallium/auxiliary/pipe-loader/pipe_loader_priv.h index 7708455d949..37219fb8941 100644 --- a/src/gallium/auxiliary/pipe-loader/pipe_loader_priv.h +++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_priv.h @@ -47,4 +47,15 @@ struct util_dl_library * pipe_loader_find_module(struct pipe_loader_device *dev, const char *library_paths); +/** + * Free the base device structure. + * + * Implementations of pipe_loader_ops::release must call this. + * + * (*dev)->driver_name must be freed by the caller if it was allocated on the + * heap. + */ +void +pipe_loader_base_release(struct pipe_loader_device **dev); + #endif /* PIPE_LOADER_PRIV_H */ diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c index 3c8e0c2d523..696ba2c5338 100644 --- a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c +++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c @@ -282,8 +282,7 @@ pipe_loader_sw_release(struct pipe_loader_device **dev) close(sdev->fd); #endif - FREE(sdev); - *dev = NULL; + pipe_loader_base_release(dev); } static const struct drm_conf_ret * |