gallium: move loading of drirc to pipe-loader
v2: rebase compile fix: addition of mesa_no_error Reviewed-by: Marek Olšák <marek.olsak@amd.com> (v1)
This commit is contained in:
parent
678dadf123
commit
e794f8bf8b
|
@ -31,6 +31,7 @@
|
||||||
#include "util/u_memory.h"
|
#include "util/u_memory.h"
|
||||||
#include "util/u_string.h"
|
#include "util/u_string.h"
|
||||||
#include "util/u_dl.h"
|
#include "util/u_dl.h"
|
||||||
|
#include "util/xmlconfig.h"
|
||||||
#include "util/xmlpool.h"
|
#include "util/xmlpool.h"
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
@ -71,6 +72,16 @@ pipe_loader_release(struct pipe_loader_device **devs, int ndev)
|
||||||
devs[i]->ops->release(&devs[i]);
|
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 *
|
const struct drm_conf_ret *
|
||||||
pipe_loader_configuration(struct pipe_loader_device *dev,
|
pipe_loader_configuration(struct pipe_loader_device *dev,
|
||||||
enum drm_conf conf)
|
enum drm_conf conf)
|
||||||
|
@ -78,6 +89,24 @@ pipe_loader_configuration(struct pipe_loader_device *dev,
|
||||||
return dev->ops->configuration(dev, conf);
|
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 *
|
struct pipe_screen *
|
||||||
pipe_loader_create_screen(struct pipe_loader_device *dev,
|
pipe_loader_create_screen(struct pipe_loader_device *dev,
|
||||||
struct pipe_screen_config *config)
|
struct pipe_screen_config *config)
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
#include "pipe/p_compiler.h"
|
#include "pipe/p_compiler.h"
|
||||||
#include "state_tracker/drm_driver.h"
|
#include "state_tracker/drm_driver.h"
|
||||||
|
#include "util/xmlconfig.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -65,6 +66,9 @@ struct pipe_loader_device {
|
||||||
|
|
||||||
char *driver_name;
|
char *driver_name;
|
||||||
const struct pipe_loader_ops *ops;
|
const struct pipe_loader_ops *ops;
|
||||||
|
|
||||||
|
driOptionCache option_cache;
|
||||||
|
driOptionCache option_info;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -99,6 +103,16 @@ const struct drm_conf_ret *
|
||||||
pipe_loader_configuration(struct pipe_loader_device *dev,
|
pipe_loader_configuration(struct pipe_loader_device *dev,
|
||||||
enum drm_conf conf);
|
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.
|
* Release resources allocated for a list of devices.
|
||||||
*
|
*
|
||||||
|
|
|
@ -264,8 +264,7 @@ pipe_loader_drm_release(struct pipe_loader_device **dev)
|
||||||
|
|
||||||
close(ddev->fd);
|
close(ddev->fd);
|
||||||
FREE(ddev->base.driver_name);
|
FREE(ddev->base.driver_name);
|
||||||
FREE(ddev);
|
pipe_loader_base_release(dev);
|
||||||
*dev = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct drm_conf_ret *
|
static const struct drm_conf_ret *
|
||||||
|
|
|
@ -47,4 +47,15 @@ struct util_dl_library *
|
||||||
pipe_loader_find_module(struct pipe_loader_device *dev,
|
pipe_loader_find_module(struct pipe_loader_device *dev,
|
||||||
const char *library_paths);
|
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 */
|
#endif /* PIPE_LOADER_PRIV_H */
|
||||||
|
|
|
@ -282,8 +282,7 @@ pipe_loader_sw_release(struct pipe_loader_device **dev)
|
||||||
close(sdev->fd);
|
close(sdev->fd);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FREE(sdev);
|
pipe_loader_base_release(dev);
|
||||||
*dev = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct drm_conf_ret *
|
static const struct drm_conf_ret *
|
||||||
|
|
|
@ -1941,10 +1941,10 @@ dri2GalliumConfigQueryb(__DRIscreen *sPriv, const char *var,
|
||||||
{
|
{
|
||||||
struct dri_screen *screen = dri_screen(sPriv);
|
struct dri_screen *screen = dri_screen(sPriv);
|
||||||
|
|
||||||
if (!driCheckOption(&screen->optionCache, var, DRI_BOOL))
|
if (!driCheckOption(&screen->dev->option_cache, var, DRI_BOOL))
|
||||||
return dri2ConfigQueryExtension.configQueryb(sPriv, var, val);
|
return dri2ConfigQueryExtension.configQueryb(sPriv, var, val);
|
||||||
|
|
||||||
*val = driQueryOptionb(&screen->optionCache, var);
|
*val = driQueryOptionb(&screen->dev->option_cache, var);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1957,11 +1957,11 @@ dri2GalliumConfigQueryi(__DRIscreen *sPriv, const char *var, int *val)
|
||||||
{
|
{
|
||||||
struct dri_screen *screen = dri_screen(sPriv);
|
struct dri_screen *screen = dri_screen(sPriv);
|
||||||
|
|
||||||
if (!driCheckOption(&screen->optionCache, var, DRI_INT) &&
|
if (!driCheckOption(&screen->dev->option_cache, var, DRI_INT) &&
|
||||||
!driCheckOption(&screen->optionCache, var, DRI_ENUM))
|
!driCheckOption(&screen->dev->option_cache, var, DRI_ENUM))
|
||||||
return dri2ConfigQueryExtension.configQueryi(sPriv, var, val);
|
return dri2ConfigQueryExtension.configQueryi(sPriv, var, val);
|
||||||
|
|
||||||
*val = driQueryOptioni(&screen->optionCache, var);
|
*val = driQueryOptioni(&screen->dev->option_cache, var);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1974,10 +1974,10 @@ dri2GalliumConfigQueryf(__DRIscreen *sPriv, const char *var, float *val)
|
||||||
{
|
{
|
||||||
struct dri_screen *screen = dri_screen(sPriv);
|
struct dri_screen *screen = dri_screen(sPriv);
|
||||||
|
|
||||||
if (!driCheckOption(&screen->optionCache, var, DRI_FLOAT))
|
if (!driCheckOption(&screen->dev->option_cache, var, DRI_FLOAT))
|
||||||
return dri2ConfigQueryExtension.configQueryf(sPriv, var, val);
|
return dri2ConfigQueryExtension.configQueryf(sPriv, var, val);
|
||||||
|
|
||||||
*val = driQueryOptionf(&screen->optionCache, var);
|
*val = driQueryOptionf(&screen->dev->option_cache, var);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2059,7 +2059,7 @@ dri2_init_screen(__DRIscreen * sPriv)
|
||||||
struct pipe_screen_config config = {};
|
struct pipe_screen_config config = {};
|
||||||
|
|
||||||
config.flags =
|
config.flags =
|
||||||
dri_init_options_get_screen_flags(screen, screen->dev->driver_name);
|
dri_init_options_get_screen_flags(screen);
|
||||||
|
|
||||||
pscreen = pipe_loader_create_screen(screen->dev, &config);
|
pscreen = pipe_loader_create_screen(screen->dev, &config);
|
||||||
}
|
}
|
||||||
|
@ -2154,7 +2154,7 @@ dri_kms_init_screen(__DRIscreen * sPriv)
|
||||||
|
|
||||||
struct pipe_screen_config config = {};
|
struct pipe_screen_config config = {};
|
||||||
|
|
||||||
config.flags = dri_init_options_get_screen_flags(screen, "swrast");
|
config.flags = dri_init_options_get_screen_flags(screen);
|
||||||
|
|
||||||
if (pipe_loader_sw_probe_kms(&screen->dev, fd))
|
if (pipe_loader_sw_probe_kms(&screen->dev, fd))
|
||||||
pscreen = pipe_loader_create_screen(screen->dev, &config);
|
pscreen = pipe_loader_create_screen(screen->dev, &config);
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include "state_tracker/drm_driver.h"
|
#include "state_tracker/drm_driver.h"
|
||||||
|
|
||||||
#include "pipe/p_context.h"
|
#include "pipe/p_context.h"
|
||||||
|
#include "pipe-loader/pipe_loader.h"
|
||||||
#include "state_tracker/st_context.h"
|
#include "state_tracker/st_context.h"
|
||||||
|
|
||||||
GLboolean
|
GLboolean
|
||||||
|
@ -124,7 +125,7 @@ dri_create_context(gl_api api, const struct gl_config * visual,
|
||||||
ctx->cPriv = cPriv;
|
ctx->cPriv = cPriv;
|
||||||
ctx->sPriv = sPriv;
|
ctx->sPriv = sPriv;
|
||||||
|
|
||||||
if (driQueryOptionb(&screen->optionCache, "mesa_no_error"))
|
if (driQueryOptionb(&screen->dev->option_cache, "mesa_no_error"))
|
||||||
attribs.flags |= ST_CONTEXT_FLAG_NO_ERROR;
|
attribs.flags |= ST_CONTEXT_FLAG_NO_ERROR;
|
||||||
|
|
||||||
attribs.options = screen->options;
|
attribs.options = screen->options;
|
||||||
|
@ -167,7 +168,7 @@ dri_create_context(gl_api api, const struct gl_config * visual,
|
||||||
|
|
||||||
/* Do this last. */
|
/* Do this last. */
|
||||||
if (ctx->st->start_thread &&
|
if (ctx->st->start_thread &&
|
||||||
driQueryOptionb(&screen->optionCache, "mesa_glthread")) {
|
driQueryOptionb(&screen->dev->option_cache, "mesa_glthread")) {
|
||||||
|
|
||||||
if (backgroundCallable && backgroundCallable->base.version >= 2 &&
|
if (backgroundCallable && backgroundCallable->base.version >= 2 &&
|
||||||
backgroundCallable->isThreadSafe) {
|
backgroundCallable->isThreadSafe) {
|
||||||
|
|
|
@ -59,7 +59,7 @@ static void
|
||||||
dri_fill_st_options(struct dri_screen *screen)
|
dri_fill_st_options(struct dri_screen *screen)
|
||||||
{
|
{
|
||||||
struct st_config_options *options = &screen->options;
|
struct st_config_options *options = &screen->options;
|
||||||
const struct driOptionCache *optionCache = &screen->optionCache;
|
const struct driOptionCache *optionCache = &screen->dev->option_cache;
|
||||||
|
|
||||||
options->disable_blend_func_extended =
|
options->disable_blend_func_extended =
|
||||||
driQueryOptionb(optionCache, "disable_blend_func_extended");
|
driQueryOptionb(optionCache, "disable_blend_func_extended");
|
||||||
|
@ -156,7 +156,7 @@ dri_fill_in_modes(struct dri_screen *screen)
|
||||||
GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
|
GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
|
||||||
};
|
};
|
||||||
|
|
||||||
if (driQueryOptionb(&screen->optionCache, "always_have_depth_buffer")) {
|
if (driQueryOptionb(&screen->dev->option_cache, "always_have_depth_buffer")) {
|
||||||
/* all visuals will have a depth buffer */
|
/* all visuals will have a depth buffer */
|
||||||
depth_buffer_factor = 0;
|
depth_buffer_factor = 0;
|
||||||
}
|
}
|
||||||
|
@ -416,28 +416,6 @@ dri_get_param(struct st_manager *smapi,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
dri_destroy_option_cache(struct dri_screen * screen)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (screen->optionCache.info) {
|
|
||||||
for (i = 0; i < (1 << screen->optionCache.tableSize); ++i) {
|
|
||||||
free(screen->optionCache.info[i].name);
|
|
||||||
free(screen->optionCache.info[i].ranges);
|
|
||||||
}
|
|
||||||
free(screen->optionCache.info);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(screen->optionCache.values);
|
|
||||||
|
|
||||||
/* Default values are copied to screen->optionCache->values in
|
|
||||||
* initOptionCache. The info field, however, is a pointer copy, so don't free
|
|
||||||
* that twice.
|
|
||||||
*/
|
|
||||||
free(screen->optionCacheDefaults.values);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
dri_destroy_screen_helper(struct dri_screen * screen)
|
dri_destroy_screen_helper(struct dri_screen * screen)
|
||||||
{
|
{
|
||||||
|
@ -450,7 +428,6 @@ dri_destroy_screen_helper(struct dri_screen * screen)
|
||||||
if (screen->base.screen)
|
if (screen->base.screen)
|
||||||
screen->base.screen->destroy(screen->base.screen);
|
screen->base.screen->destroy(screen->base.screen);
|
||||||
|
|
||||||
dri_destroy_option_cache(screen);
|
|
||||||
mtx_destroy(&screen->opencl_func_mutex);
|
mtx_destroy(&screen->opencl_func_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,7 +451,7 @@ dri_postprocessing_init(struct dri_screen *screen)
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
for (i = 0; i < PP_FILTERS; i++) {
|
for (i = 0; i < PP_FILTERS; i++) {
|
||||||
screen->pp_enabled[i] = driQueryOptioni(&screen->optionCache,
|
screen->pp_enabled[i] = driQueryOptioni(&screen->dev->option_cache,
|
||||||
pp_filters[i].name);
|
pp_filters[i].name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -499,19 +476,15 @@ dri_set_background_context(struct st_context_iface *st,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned
|
unsigned
|
||||||
dri_init_options_get_screen_flags(struct dri_screen *screen,
|
dri_init_options_get_screen_flags(struct dri_screen *screen)
|
||||||
const char* driver_name)
|
|
||||||
{
|
{
|
||||||
unsigned flags = 0;
|
unsigned flags = 0;
|
||||||
|
|
||||||
driParseOptionInfo(&screen->optionCacheDefaults, gallium_config_options.xml);
|
pipe_loader_load_options(screen->dev);
|
||||||
driParseConfigFiles(&screen->optionCache,
|
|
||||||
&screen->optionCacheDefaults,
|
|
||||||
screen->sPriv->myNum,
|
|
||||||
driver_name);
|
|
||||||
dri_fill_st_options(screen);
|
dri_fill_st_options(screen);
|
||||||
|
|
||||||
if (driQueryOptionb(&screen->optionCache,
|
if (driQueryOptionb(&screen->dev->option_cache,
|
||||||
"glsl_correct_derivatives_after_discard"))
|
"glsl_correct_derivatives_after_discard"))
|
||||||
flags |= PIPE_SCREEN_ENABLE_CORRECT_TGSI_DERIVATIVES_AFTER_KILL;
|
flags |= PIPE_SCREEN_ENABLE_CORRECT_TGSI_DERIVATIVES_AFTER_KILL;
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
#define DRI_SCREEN_H
|
#define DRI_SCREEN_H
|
||||||
|
|
||||||
#include "dri_util.h"
|
#include "dri_util.h"
|
||||||
#include "util/xmlconfig.h"
|
|
||||||
|
|
||||||
#include "pipe/p_compiler.h"
|
#include "pipe/p_compiler.h"
|
||||||
#include "pipe/p_context.h"
|
#include "pipe/p_context.h"
|
||||||
|
@ -61,12 +60,6 @@ struct dri_screen
|
||||||
boolean throttling_enabled;
|
boolean throttling_enabled;
|
||||||
int default_throttle_frames;
|
int default_throttle_frames;
|
||||||
|
|
||||||
/** Configuration cache with default values for all contexts */
|
|
||||||
driOptionCache optionCacheDefaults;
|
|
||||||
|
|
||||||
/** The screen's effective configuration options */
|
|
||||||
driOptionCache optionCache;
|
|
||||||
|
|
||||||
struct st_config_options options;
|
struct st_config_options options;
|
||||||
|
|
||||||
/* Which postprocessing filters are enabled. */
|
/* Which postprocessing filters are enabled. */
|
||||||
|
@ -138,8 +131,7 @@ dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen,
|
||||||
const struct gl_config *mode);
|
const struct gl_config *mode);
|
||||||
|
|
||||||
unsigned
|
unsigned
|
||||||
dri_init_options_get_screen_flags(struct dri_screen *screen,
|
dri_init_options_get_screen_flags(struct dri_screen *screen);
|
||||||
const char* driver_name);
|
|
||||||
|
|
||||||
const __DRIconfig **
|
const __DRIconfig **
|
||||||
dri_init_screen_helper(struct dri_screen *screen,
|
dri_init_screen_helper(struct dri_screen *screen,
|
||||||
|
|
|
@ -402,7 +402,7 @@ drisw_init_screen(__DRIscreen * sPriv)
|
||||||
|
|
||||||
struct pipe_screen_config config;
|
struct pipe_screen_config config;
|
||||||
|
|
||||||
config.flags = dri_init_options_get_screen_flags(screen, "swrast");
|
config.flags = dri_init_options_get_screen_flags(screen);
|
||||||
|
|
||||||
if (pipe_loader_sw_probe_dri(&screen->dev, &drisw_lf))
|
if (pipe_loader_sw_probe_dri(&screen->dev, &drisw_lf))
|
||||||
pscreen = pipe_loader_create_screen(screen->dev, &config);
|
pscreen = pipe_loader_create_screen(screen->dev, &config);
|
||||||
|
|
Loading…
Reference in New Issue