driconfig: Add support for device specific config
Add support for driconf overrides on a per-device level, for cases where we don't want to override behavior for all devices supported by a particular driver. Signed-off-by: Rob Clark <robdclark@chromium.org> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12135>
This commit is contained in:
parent
b080aa9466
commit
6edf0d8e90
|
@ -874,7 +874,7 @@ radv_init_dri_options(struct radv_instance *instance)
|
|||
{
|
||||
driParseOptionInfo(&instance->available_dri_options, radv_dri_options,
|
||||
ARRAY_SIZE(radv_dri_options));
|
||||
driParseConfigFiles(&instance->dri_options, &instance->available_dri_options, 0, "radv", NULL,
|
||||
driParseConfigFiles(&instance->dri_options, &instance->available_dri_options, 0, "radv", NULL, NULL,
|
||||
instance->vk.app_info.app_name, instance->vk.app_info.app_version,
|
||||
instance->vk.app_info.engine_name, instance->vk.app_info.engine_version);
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ 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);
|
||||
dev->driver_name, NULL, NULL, NULL, 0, NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -766,7 +766,7 @@ crocus_screen_create(int fd, const struct pipe_screen_config *config)
|
|||
screen->no_hw = true;
|
||||
|
||||
driParseConfigFiles(config->options, config->options_info, 0, "crocus",
|
||||
NULL, NULL, 0, NULL, 0);
|
||||
NULL, NULL, NULL, 0, NULL, 0);
|
||||
|
||||
bool bo_reuse = false;
|
||||
int bo_reuse_mode = driQueryOptioni(config->options, "bo_reuse");
|
||||
|
|
|
@ -812,7 +812,7 @@ iris_screen_create(int fd, const struct pipe_screen_config *config)
|
|||
return NULL;
|
||||
|
||||
driParseConfigFiles(config->options, config->options_info, 0, "iris",
|
||||
NULL, NULL, 0, NULL, 0);
|
||||
NULL, NULL, NULL, 0, NULL, 0);
|
||||
|
||||
bool bo_reuse = false;
|
||||
int bo_reuse_mode = driQueryOptioni(config->options, "bo_reuse");
|
||||
|
|
|
@ -1400,7 +1400,7 @@ struct pipe_screen *radeonsi_screen_create(int fd, const struct pipe_screen_conf
|
|||
struct radeon_winsys *rw = NULL;
|
||||
|
||||
driParseConfigFiles(config->options, config->options_info, 0, "radeonsi",
|
||||
NULL, NULL, 0, NULL, 0);
|
||||
NULL, NULL, NULL, 0, NULL, 0);
|
||||
|
||||
switch (version->version_major) {
|
||||
case 2:
|
||||
|
|
|
@ -794,7 +794,7 @@ v3d_screen_create(int fd, const struct pipe_screen_config *config,
|
|||
goto fail;
|
||||
|
||||
driParseConfigFiles(config->options, config->options_info, 0, "v3d",
|
||||
NULL, NULL, 0, NULL, 0);
|
||||
NULL, NULL, NULL, 0, NULL, 0);
|
||||
|
||||
/* We have to driCheckOption for the simulator mode to not assertion
|
||||
* fail on not having our XML config.
|
||||
|
|
|
@ -943,7 +943,7 @@ virgl_create_screen(struct virgl_winsys *vws, const struct pipe_screen_config *c
|
|||
|
||||
if (config && config->options) {
|
||||
driParseConfigFiles(config->options, config->options_info, 0, "virtio_gpu",
|
||||
NULL, NULL, 0, NULL, 0);
|
||||
NULL, NULL, NULL, 0, NULL, 0);
|
||||
|
||||
screen->tweak_gles_emulate_bgra =
|
||||
driQueryOptionb(config->options, VIRGL_GLES_EMULATE_BGRA);
|
||||
|
|
|
@ -1904,7 +1904,7 @@ zink_internal_create_screen(const struct pipe_screen_config *config)
|
|||
#if WITH_XMLCONFIG
|
||||
if (config) {
|
||||
driParseConfigFiles(config->options, config->options_info, 0, "zink",
|
||||
NULL, NULL, 0, NULL, 0);
|
||||
NULL, 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");
|
||||
}
|
||||
|
|
|
@ -257,7 +257,7 @@ drm_create_adapter( int fd,
|
|||
driParseOptionInfo(&defaultInitOptions, __driConfigOptionsNine,
|
||||
ARRAY_SIZE(__driConfigOptionsNine));
|
||||
driParseConfigFiles(&userInitOptions, &defaultInitOptions, 0,
|
||||
"nine", NULL, NULL, 0, NULL, 0);
|
||||
"nine", NULL, NULL, NULL, 0, NULL, 0);
|
||||
if (driCheckOption(&userInitOptions, "throttle_value", DRI_INT)) {
|
||||
throttling_value_user = driQueryOptioni(&userInitOptions, "throttle_value");
|
||||
if (throttling_value_user == -1)
|
||||
|
|
|
@ -1036,7 +1036,7 @@ anv_init_dri_options(struct anv_instance *instance)
|
|||
driParseOptionInfo(&instance->available_dri_options, anv_dri_options,
|
||||
ARRAY_SIZE(anv_dri_options));
|
||||
driParseConfigFiles(&instance->dri_options,
|
||||
&instance->available_dri_options, 0, "anv", NULL,
|
||||
&instance->available_dri_options, 0, "anv", NULL, NULL,
|
||||
instance->vk.app_info.app_name,
|
||||
instance->vk.app_info.app_version,
|
||||
instance->vk.app_info.engine_name,
|
||||
|
|
|
@ -195,7 +195,7 @@ static char *loader_get_dri_config_driver(int fd)
|
|||
driParseOptionInfo(&defaultInitOptions, __driConfigOptionsLoader,
|
||||
ARRAY_SIZE(__driConfigOptionsLoader));
|
||||
driParseConfigFiles(&userInitOptions, &defaultInitOptions, 0,
|
||||
"loader", kernel_driver, NULL, 0, NULL, 0);
|
||||
"loader", kernel_driver, NULL, NULL, 0, NULL, 0);
|
||||
if (driCheckOption(&userInitOptions, "dri_driver", DRI_STRING)) {
|
||||
char *opt = driQueryOptionstr(&userInitOptions, "dri_driver");
|
||||
/* not an empty string */
|
||||
|
@ -218,7 +218,7 @@ static char *loader_get_dri_config_device_id(void)
|
|||
driParseOptionInfo(&defaultInitOptions, __driConfigOptionsLoader,
|
||||
ARRAY_SIZE(__driConfigOptionsLoader));
|
||||
driParseConfigFiles(&userInitOptions, &defaultInitOptions, 0,
|
||||
"loader", NULL, NULL, 0, NULL, 0);
|
||||
"loader", NULL, NULL, NULL, 0, NULL, 0);
|
||||
if (driCheckOption(&userInitOptions, "device_id", DRI_STRING))
|
||||
prime = strdup(driQueryOptionstr(&userInitOptions, "device_id"));
|
||||
driDestroyOptionCache(&userInitOptions);
|
||||
|
|
|
@ -155,7 +155,7 @@ driCreateNewScreen2(int scrn, int fd,
|
|||
driParseOptionInfo(&psp->optionInfo,
|
||||
__dri2ConfigOptions, ARRAY_SIZE(__dri2ConfigOptions));
|
||||
driParseConfigFiles(&psp->optionCache, &psp->optionInfo, psp->myNum,
|
||||
"dri2", NULL, NULL, 0, NULL, 0);
|
||||
"dri2", NULL, NULL, NULL, 0, NULL, 0);
|
||||
|
||||
*driver_configs = psp->driver->InitScreen(psp);
|
||||
if (*driver_configs == NULL) {
|
||||
|
|
|
@ -447,7 +447,7 @@ intelInitContext(struct intel_context *intel,
|
|||
0, sizeof(ctx->TextureFormatSupported));
|
||||
|
||||
driParseConfigFiles(&intel->optionCache, &intelScreen->optionCache,
|
||||
sPriv->myNum, "i915", NULL, NULL, 0, NULL, 0);
|
||||
sPriv->myNum, "i915", NULL, NULL, NULL, 0, NULL, 0);
|
||||
intel->maxBatchSize = 4096;
|
||||
|
||||
/* Estimate the size of the mappable aperture into the GTT. There's an
|
||||
|
|
|
@ -2543,7 +2543,7 @@ __DRIconfig **brw_init_screen(__DRIscreen *dri_screen)
|
|||
|
||||
driParseOptionInfo(&options, brw_driconf, ARRAY_SIZE(brw_driconf));
|
||||
driParseConfigFiles(&screen->optionCache, &options, dri_screen->myNum,
|
||||
"i965", NULL, NULL, 0, NULL, 0);
|
||||
"i965", NULL, NULL, NULL, 0, NULL, 0);
|
||||
driDestroyOptionCache(&options);
|
||||
|
||||
screen->driScrnPriv = dri_screen;
|
||||
|
|
|
@ -217,7 +217,7 @@ GLboolean r200CreateContext( gl_api api,
|
|||
* the default textures.
|
||||
*/
|
||||
driParseConfigFiles (&rmesa->radeon.optionCache, &screen->optionCache,
|
||||
screen->driScreen->myNum, "r200", NULL, NULL, 0, NULL, 0);
|
||||
screen->driScreen->myNum, "r200", NULL, NULL, NULL, 0, NULL, 0);
|
||||
rmesa->radeon.initialMaxAnisotropy = driQueryOptionf(&rmesa->radeon.optionCache,
|
||||
"def_max_anisotropy");
|
||||
|
||||
|
|
|
@ -183,7 +183,7 @@ r100CreateContext( gl_api api,
|
|||
* the default textures.
|
||||
*/
|
||||
driParseConfigFiles (&rmesa->radeon.optionCache, &screen->optionCache,
|
||||
screen->driScreen->myNum, "radeon", NULL, NULL, 0, NULL, 0);
|
||||
screen->driScreen->myNum, "radeon", NULL, NULL, NULL, 0, NULL, 0);
|
||||
rmesa->radeon.initialMaxAnisotropy = driQueryOptionf(&rmesa->radeon.optionCache,
|
||||
"def_max_anisotropy");
|
||||
|
||||
|
|
|
@ -31,7 +31,8 @@ TODO: document the other workarounds.
|
|||
<!DOCTYPE driconf [
|
||||
<!ELEMENT driconf (device+)>
|
||||
<!ELEMENT device (application | engine)+>
|
||||
<!ATTLIST device driver CDATA #IMPLIED>
|
||||
<!ATTLIST device driver CDATA #IMPLIED
|
||||
device CDATA #IMPLIED>
|
||||
<!ELEMENT application (option+)>
|
||||
<!ATTLIST application name CDATA #REQUIRED
|
||||
executable CDATA #IMPLIED
|
||||
|
|
|
@ -68,6 +68,7 @@ class Device(object):
|
|||
def __init__(self, xml):
|
||||
self.cname = cname('device')
|
||||
self.driver = xml.attrib.get('driver', None)
|
||||
self.device = xml.attrib.get('device', None)
|
||||
self.applications = []
|
||||
self.engines = []
|
||||
|
||||
|
@ -133,6 +134,7 @@ struct driconf_engine {
|
|||
|
||||
struct driconf_device {
|
||||
const char *driver;
|
||||
const char *device;
|
||||
unsigned num_engines;
|
||||
const struct driconf_engine *engines;
|
||||
unsigned num_applications;
|
||||
|
@ -196,6 +198,9 @@ static const struct driconf_application ${device.cname}_applications[] = {
|
|||
static const struct driconf_device ${device.cname} = {
|
||||
% if device.driver:
|
||||
.driver = "${device.driver}",
|
||||
% endif
|
||||
% if device.device:
|
||||
.device = "${device.device}",
|
||||
% endif
|
||||
.num_engines = ${len(device.engines)},
|
||||
% if len(device.engines) > 0:
|
||||
|
|
|
@ -143,7 +143,7 @@ TEST_F(xmlconfig_test, copy_cache)
|
|||
* user's homedir/environment that would override us.
|
||||
*/
|
||||
driParseConfigFiles(&cache, &options,
|
||||
0, "driver", "drm",
|
||||
0, "driver", "drm", NULL,
|
||||
NULL, 0,
|
||||
NULL, 0);
|
||||
|
||||
|
@ -184,7 +184,7 @@ xmlconfig_test::drirc_init(const char *driver, const char *drm,
|
|||
* based on the setting of $HOME by meson.build.
|
||||
*/
|
||||
driParseConfigFiles(&cache, &options,
|
||||
0, driver, drm,
|
||||
0, driver, drm, NULL,
|
||||
app, appver,
|
||||
engine, enginever);
|
||||
|
||||
|
|
|
@ -595,6 +595,7 @@ struct OptConfData {
|
|||
int screenNum;
|
||||
const char *driverName, *execName;
|
||||
const char *kernelDriverName;
|
||||
const char *deviceName;
|
||||
const char *engineName;
|
||||
const char *applicationName;
|
||||
uint32_t engineVersion;
|
||||
|
@ -648,11 +649,12 @@ static void
|
|||
parseDeviceAttr(struct OptConfData *data, const char **attr)
|
||||
{
|
||||
uint32_t i;
|
||||
const char *driver = NULL, *screen = NULL, *kernel = NULL;
|
||||
const char *driver = NULL, *screen = NULL, *kernel = NULL, *device = NULL;
|
||||
for (i = 0; attr[i]; i += 2) {
|
||||
if (!strcmp(attr[i], "driver")) driver = attr[i+1];
|
||||
else if (!strcmp(attr[i], "screen")) screen = attr[i+1];
|
||||
else if (!strcmp(attr[i], "kernel_driver")) kernel = attr[i+1];
|
||||
else if (!strcmp(attr[i], "device")) device = attr[i+1];
|
||||
else XML_WARNING("unknown device attribute: %s.", attr[i]);
|
||||
}
|
||||
if (driver && strcmp(driver, data->driverName))
|
||||
|
@ -660,6 +662,9 @@ parseDeviceAttr(struct OptConfData *data, const char **attr)
|
|||
else if (kernel && (!data->kernelDriverName ||
|
||||
strcmp(kernel, data->kernelDriverName)))
|
||||
data->ignoringDevice = data->inDevice;
|
||||
else if (device && (!data->deviceName ||
|
||||
strcmp(device, data->deviceName)))
|
||||
data->ignoringDevice = data->inDevice;
|
||||
else if (screen) {
|
||||
driOptionValue screenNum;
|
||||
if (!parseValue(&screenNum, DRI_INT, screen))
|
||||
|
@ -1059,6 +1064,7 @@ parseStaticConfig(struct OptConfData *data)
|
|||
const struct driconf_device *d = driconf[i];
|
||||
const char *devattr[] = {
|
||||
"driver", d->driver,
|
||||
"device", d->device,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@ -1149,6 +1155,7 @@ void
|
|||
driParseConfigFiles(driOptionCache *cache, const driOptionCache *info,
|
||||
int screenNum, const char *driverName,
|
||||
const char *kernelDriverName,
|
||||
const char *deviceName,
|
||||
const char *applicationName, uint32_t applicationVersion,
|
||||
const char *engineName, uint32_t engineVersion)
|
||||
{
|
||||
|
@ -1159,6 +1166,7 @@ driParseConfigFiles(driOptionCache *cache, const driOptionCache *info,
|
|||
userData.screenNum = screenNum;
|
||||
userData.driverName = driverName;
|
||||
userData.kernelDriverName = kernelDriverName;
|
||||
userData.deviceName = deviceName;
|
||||
userData.applicationName = applicationName ? applicationName : "";
|
||||
userData.applicationVersion = applicationVersion;
|
||||
userData.engineName = engineName ? engineName : "";
|
||||
|
|
|
@ -139,6 +139,7 @@ void driParseOptionInfo(driOptionCache *info,
|
|||
void driParseConfigFiles(driOptionCache *cache, const driOptionCache *info,
|
||||
int screenNum, const char *driverName,
|
||||
const char *kernelDriverName,
|
||||
const char *deviceName,
|
||||
const char *applicationName, uint32_t applicationVersion,
|
||||
const char *engineName, uint32_t engineVersion);
|
||||
/** \brief Destroy option info
|
||||
|
|
|
@ -726,7 +726,7 @@ vn_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
|
|||
driParseOptionInfo(&instance->available_dri_options, vn_dri_options,
|
||||
ARRAY_SIZE(vn_dri_options));
|
||||
driParseConfigFiles(&instance->dri_options,
|
||||
&instance->available_dri_options, 0, "venus", NULL,
|
||||
&instance->available_dri_options, 0, "venus", NULL, NULL,
|
||||
instance->base.base.app_info.app_name,
|
||||
instance->base.base.app_info.app_version,
|
||||
instance->base.base.app_info.engine_name,
|
||||
|
|
Loading…
Reference in New Issue