Commit Graph

47 Commits

Author SHA1 Message Date
Michel Zou bd3556a669 util/xmlconfig: fix -Wmaybe-uninitialized warning
```
xmlconfig.c:570:7: warning: 'userData.name' may be used uninitialized [-Wmaybe-uninitialized]
```

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16912>
2022-06-29 20:06:13 +00:00
Yonggang Luo d9c3601e29 util: trim trailing space for files src/util/**/*
Using the following bash script doing that
```
cd src/util
find . -type f -print0 | xargs -0 -n1 sed -i 's/[ \t]*$//'
```

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15093>
2022-03-21 17:57:15 +00:00
Lepton Wu d15021435e driconf: Fix unhandled tags in static conf
A rule with executable_regexp tag would match every executable
without this fix and force_glsl_extensions_warn would be always
set to true which breaks some dEQP tests.

Fixes: 5740ac3701 ("xmlconfig: Add static driconfig support")

Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14562>
2022-01-14 22:09:50 +00:00
Thomas H.P. Andersen 7daba1fe65 replace 0 with NULL for NULL pointers
This updates many places where 0 is used as NULL pointer.

There are a few warnings left when I build the default
configuration but they either relate to code
outside of mesa or where "None" is used instead.

Found with static analysis (smatch)

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12174>
2022-01-10 22:53:32 +00:00
Ryan Houdek 0ae1231879 util/xmlconfig: Allow DT_UNKNOWN files
Some filesystems don't fill in d_type in dirent. Resulting in
DT_UNKNOWN. Pass this entry through to the next step and use stat on the
full filepath to determine if it is a file.

sshfs is known to not fill d_type.
This resolves an issue where driconf living on an sshfs path wasn't
working.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13697>
2021-11-09 23:25:32 +00:00
Pierre-Eric Pelloux-Prayer fc3ef76eec glx/drirc: add a force_direct_glx_context option
Some applications may request an indirect context but this feature is
disabled by default on Xorg and thus context creation will fail.

This commit adds a drirc setting to force the creation of direct glx
context, regardless of what the app is requesting.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13246>
2021-11-04 13:59:00 +01:00
Qiang Yu 9a24de9aa7 driconf: add executable_regexp application attribute
For matching executable with variable names like Mari which
append version string to its executable like: Mari4.5v2, Mari4.7v4.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13304>
2021-11-02 02:21:00 +00:00
Jesse Natalie 68ff6f8be5 xmlconfig: Use static inline for regex fallback to prevent -O0 issues
A non-static inline function body is only actually emitted by GCC during optimization passes,
so running -O0 ends up never emitting the body, producing linker errors.

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
Reviewed-by: Neha Bhende <bhenden@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12158>
2021-08-10 15:14:26 +00:00
Rob Clark 6edf0d8e90 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>
2021-08-02 16:37:24 -07:00
Jesse Natalie 2b69dd6809 xmlconfig: Fix MSVC warning C4334 (32bit shift cast to 64bit)
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-By: Bill Kristiansen <billkris@microsoft.com>
Cc: mesa-stable@lists.freedesktop.org
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10331>
2021-04-20 00:28:35 +00:00
Michel Zou 5a2b930014 meson/xmlconfig: win32 regex fallback
xmlconfig now uses regex fonctions even without xml support

Fixes: c83400e6
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9261>
2021-02-25 14:03:27 +00:00
Rob Clark 5740ac3701 xmlconfig: Add static driconfig support
For platforms which do not have support for parsing driconf from xml
files on the filesystem, build in driconf tables generated from
00-mesa-defaults.conf at compile time and use that for option matching.

This allows us to have game/engine specific overrides built in to mesa.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9179>
2021-02-24 16:02:51 +00:00
Rob Clark c83400e673 xmlconfig: Reshuffle to keep attr processing
For the static-table alternative to WITH_XMLCONFIG, we are going to want
to re-use the element attribute processing, to avoid duplicating things
like engine name regexp matching and version range matching.  This just
shuffles things around a bit so we can re-use useful parts in the next
patch.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9179>
2021-02-24 16:02:51 +00:00
Eric Anholt b4ae9e07cd xmlconfig: Warn if parsing the engine/app versions fails.
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7048>
2020-12-04 21:32:17 +00:00
Eric Anholt 1618bd1bee xmlconfig: Add unit tests for recent bugs in the driconf rewrite.
This covers:
7fb4ab9ec1 ("driconf: Restore the ability to override driconf with the environment.")
2b977adff8 ("xmlconfig: fix scandir_filter")

and touches a bit more of drirc logic while I'm here.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7048>
2020-12-04 21:32:17 +00:00
James Park 6a189c89f8 util/xmlconfig: Disable for Windows like Android
The code does not compile on Windows, so just disable for now. There is
already a pattern to do this for Android.

Stop including expat dependency if building Windows.

Disable WITH_XMLCONFIG if _WIN32 is defined.

Tuck _WIN32 incompatible includes inside WITH_XMLCONFIG.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7249>
2020-10-25 03:04:09 +00:00
Martin Peres f9763b2054 driconf: initialize the option value before using it
ParseValue is freeing the pointer if the address is != 0. However,
since we allocate this value on the stack, we need to initialize the
data first.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Martin Peres <martin.peres@mupuf.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7212>
2020-10-22 07:47:28 +03:00
Andrii Simiklit cc00d57a3c util/xmlconfig: eliminate memory leak
It fixes coverity issue: CID 1467703: (RESOURCE_LEAK):
`Variable "cp" going out of scope leaks the storage it points to.`

Fixes: 23c3eb1fe1 ("driconf: Delete disjoint range support")
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Andrii Simiklit <andrii.simiklit@globallogic.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7021>
2020-10-08 15:43:52 +00:00
Eric Anholt 7fb4ab9ec1 driconf: Restore the ability to override driconf with the environment.
I distinctly remember testing this during development, yet clearly deleted
the code.

I pulled the parseValue code back up to the top where it used to be since
we have to use it, rather than just adding a prototype.

Fixes: 8a05d6ffc6 ("driconf: Make the driver's declarations be structs instead of XML.")
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7012>
2020-10-06 17:03:49 +00:00
Eric Anholt 455bfecdff driconf: Make sure that the range check on the defaults actually works.
Fixes: 8a05d6ffc6 ("driconf: Make the driver's declarations be structs instead of XML.")
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7012>
2020-10-06 17:03:49 +00:00
Michel Zou 82563b6a9f util: drop non-posix header fnmatch
Seems fnmatch usage was removed but not the include

Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7013>
2020-10-06 08:33:09 +00:00
Mike Blumenkrantz 2b977adff8 xmlconfig: fix scandir_filter
this was changed from a fnmatch usage to strcmp, and the return value
was flipped, breaking matching

also fix the formatting of the changed lines

Fixes: 4f37161a8f2: ("util/xmlconfig: Indent to Mesa style.")

Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7018>
2020-10-06 04:43:12 +00:00
Eric Anholt 2fb2749937 android: Disable the user XML config parsing.
The android platform is not interested in this feature of Mesa.  There are
currently workarounds for apps on Android, and no support for it in the
xmlconfig code.  Even if there we do need workarounds eventually, we'll
want to bake them in as structs rather than have this awkward external
dependency for parsing user-readable data installed by Mesa for
Mesa-internal details.

This gets rid of the expat dependency in the turnip driver.

Note that rather than have more #ifdefs in the file, I've opted to move
the code to have more logical locations since the structs refactor had
left less-used helpers scattered across the file.

Acked-by: Eric Engestrom <eric@engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6916>
2020-10-02 23:59:52 +00:00
Eric Anholt 7edb2aed55 util/xmlconfig: Drop use of XML_Char in parsing.
We don't define the use-16-bit-unicode defines (and our strings are plain
utf8), so it's just char.  This will let me use some of this code in the
absence of expat.

Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6916>
2020-10-02 23:59:52 +00:00
Eric Anholt 6f3352b6a7 driconf: Stop quoting true/false in boolean option definitions.
Now that we're not trying to evade preprocessor macro expansion in
preprocessor string concatenation, we can use plain old bools in option
setup.

Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6916>
2020-10-02 23:59:52 +00:00
Eric Anholt 8a05d6ffc6 driconf: Make the driver's declarations be structs instead of XML.
We can generate the XML if anybody actually queries it, but this reduces
the amount of work in driver setup and means that we'll be able to support
driconf option queries on Android without libexpat.

This updates the driconf interface struct version for i965, i915, and
radeon to use the new getXml entrypoint to call the on-demand xml
generation.  Note that our loaders (egl, glx) implement the v2 function
interface and don't use .xml when that's set, and the X server doesn't use
this interface at all.

XML generation tested on iris and i965 using adriconf

Acked-by: Eric Engestrom <eric@engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6916>
2020-10-02 23:59:52 +00:00
Eric Anholt 23c3eb1fe1 driconf: Delete disjoint range support.
The only user was radeon/r200, which was using it to have something that
looks a lot like an enum value return a float from the config option.
Just convert that option to a plain float value (for compat with existing
driconfs) with the min and max of its disjoint range as the range.  The
driver's option handling code already correctly deals with other values in
the range.

The disjoint range support was a bunch of extra parsing for this dead
driver, and made turning driconf into static structs difficult.

Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6916>
2020-10-02 23:59:52 +00:00
Eric Anholt 4f37161a8f util/xmlconfig: Indent to Mesa style.
I'm heavily editing this code, and having Mesa's style not apply sucks.

Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6916>
2020-10-02 23:59:52 +00:00
Eric Anholt 91ccbb399f util/xmlconfig: Drop silly open-coded strdup.
The comment about using "malloc"?  The strdup man page says 'Memory for
the new string is obtained with malloc(3), and can be freed with free(3)'

Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6916>
2020-10-02 23:59:52 +00:00
Bas Nieuwenhuizen a1d4721e21 driconf: Support selection by Vulkan applicationName.
This adds applicationName + version through like engineName.

Rationale: A game (World War Z) includes the store name in the
executable name, so has multiple executable names.

CC: <mesa-stable@lists.freedesktop.org>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6120>
2020-08-18 20:31:07 +02:00
Pierre-Eric Pelloux-Prayer 43f785419c util/xmlconfig: fix sha1 comparison code
Fixes: 8f48e7b1e9 ("util/xmlconfig: add new sha1 application attribute")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2730
Reviewed-by: Dave Airlie <airlied@redhat.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4426>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4426>
2020-04-03 11:44:00 +02:00
Pierre-Eric Pelloux-Prayer 8f48e7b1e9 util/xmlconfig: add new sha1 application attribute
This is useful to enable workarounds for applications with a generic name.

For instance all games made with the YoYo game engine have the same executable
name "runner".

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4181>
2020-03-24 08:33:29 +01:00
Marek Olšák 5e81fbf44a util/driconfig: print ATTENTION if MESA_DEBUG=silent is not set
unix-bytebenchmark refuses to run if the driver prints ATTENTION to stderr.

Acked-by: Eric Engestrom <eric@engestrom.ch>
2019-11-28 14:36:32 -05:00
Dylan Baker 474d6f8e08 util/xmlconfig: include strndup.h for windows
Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
Acked-by: Kristian H. Kristensen <hoegsberg@google.com>
2019-10-10 16:33:04 -07:00
Lionel Landwerlin 10206ba17b util/xmlconfig: fix regexp compile failure check
This is embarrasing...

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: 04dc6074cf ("driconfig: add a new engine name/version parameter")
Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
2019-09-16 21:47:21 +03:00
Lionel Landwerlin 04dc6074cf driconfig: add a new engine name/version parameter
Vulkan applications can register with the following structure :

typedef struct VkApplicationInfo {
    VkStructureType    sType;
    const void*        pNext;
    const char*        pApplicationName;
    uint32_t           applicationVersion;
    const char*        pEngineName;
    uint32_t           engineVersion;
    uint32_t           apiVersion;
} VkApplicationInfo;

This enables the Vulkan implementations to apply workarounds based off
matching this description.

Here we add a new parameter for matching the driconfig options with
the following :

    <device driver="anv">
        <application engine_name_match="MyOwnEngine.*" engine_versions="10:12,40:42">
            <option name="blaaah" value="true" />
        </application>
    </device>

v2: switch engine name match to use regexps

v3: Verify that the regexec returns REG_NOMATCH for match failure (Eric)

v4: Add missing bit that went to the following commit (Eric)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Cc: 19.2 <mesa-stable@lists.freedesktop.org>
2019-09-15 15:37:02 +03:00
Eric Engestrom ad0ee5bfa5 xmlconfig: add missing #include
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
2019-06-27 17:42:25 +00:00
Eric Engestrom 91cc6fcbb0 util: #define PATH_MAX when undefined (eg. Hurd)
Cc: Timo Aaltonen <tjaalton@debian.org>
Cc: James Clarke <jrtc27@debian.org>
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2019-03-05 12:27:35 +00:00
Alan Coopersmith 066850edad util: Make xmlconfig.c build on Solaris without d_type in dirent (v2)
v2: check for lstat() failing

Fixes: 04bdbbcab3 "xmlconfig: read more config files from drirc.d/"
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Roland Mainz <roland.mainz@nrubsig.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2018-10-05 17:30:45 -07:00
Qiang Yu 3bbe180b98 xmlconfig: add kernel_driver device attribute
This attribute can be used by loader to apply different
option to device use specific kernel driver.

Signed-off-by: Qiang Yu <Qiang.Yu@amd.com>
Acked-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2018-08-17 17:16:32 +01:00
Qiang Yu 04bdbbcab3 xmlconfig: read more config files from drirc.d/
Driver and application can put their drirc files in
${datadir}/drirc.d/ with name xxx.conf. Config files
will be read and applied in file name alphabetic order.

So there are three places for drirc listed in order:
1. /usr/share/drirc.d/
2. /etc/drirc
3. ~/.drirc

v4:
  fix meson build

v3:
  1. seperate driParseConfigFiles refine into another patch
  2. fix entries[i] mem leak

v2:
  drop /etc/drirc.d

Signed-off-by: Qiang Yu <Qiang.Yu@amd.com>
Acked-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2018-08-17 17:16:32 +01:00
Emil Velikov 0da417129e xmlconfig: refine driParseConfigFiles to use parseOneConfigFile
Also prepare for the usage of following parseConfigDir patch.

Signed-off-by: Qiang Yu <Qiang.Yu@amd.com>
Acked-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
[Emil: add #include <limits.h>]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2018-08-17 17:16:32 +01:00
Dylan Baker 17f49950da util: move process.[ch] to u_process.[ch]
On windows process.h is a system provided header, and it's required in
include/c11/threads_win32.h. This header interferes with searching for
that header, and results in windows build warnings with scons, but
errors in meson which doesn't allow implicit function declarations. Just
rename process to u_process, which follows the style of utils anyway.

Fixes: 2e1e6511f7
       ("util: extract get_process_name from xmlconfig.c")
Signed-off-by: Dylan Baker <dylan.c.baker@intel.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2018-08-01 12:47:16 -07:00
Marek Olšák 2e1e6511f7 util: extract get_process_name from xmlconfig.c
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
2018-07-04 21:16:03 -04:00
Timothy Arceri de93f546a7 util: manually extract the program name from program_invocation_name
Glibc has the same code to get program_invocation_short_name. However
for some reason the short name gets mangled for some wine apps.

For example with Google Earth VR I get:

program_invocation_name:
"/home/tarceri/.local/share/Steam/steamapps/common/EarthVR/Earth.exe"

program_invocation_short_name:
"e"

Acked-by: Eric Engestrom <eric.engestrom@intel.com>
2018-06-19 12:09:56 +10:00
Emil Velikov 98030f92e8 xmlconfig: use the portable __VA_ARGS__
Follow the example used through mesa and use "..." + "__VA_ARGS__".
The former tends to be more common and portable.

v2: use ##__VA_ARGS__ (Eric)

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2017-08-26 11:20:06 +01:00
Nicolai Hähnle 601093f95d xmlconfig: move into src/util
v2: attempt to fix Android build (Emil)

v3: add missing include path

Reviewed-by: Marek Olšák <marek.olsak@amd.com> (v1)
2017-07-31 15:38:41 +02:00
Renamed from src/mesa/drivers/dri/common/xmlconfig.c (Browse further)