summaryrefslogtreecommitdiffstats
path: root/src/util
Commit message (Collapse)AuthorAgeFilesLines
* util: use OpenBSD/NetBSD code on FreeBSD/DragonFlyGreg V2017-10-261-1/+2
| | | | | | | | | Obtained from: FreeBSD ports Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Brian Paul <[email protected]> [Emil Velikov: wrap long line] Reviewed-by: Emil Velikov <[email protected]>
* util: add util_strdup() wrapper macroBrian Paul2017-10-231-0/+2
| | | | | | To work around MSVC warning that strdup() is a deprecated POSIX function. Reviewed-by: Nicolai Hähnle <[email protected]>
* drirc: Group a few games in the glthread whitelist together.Darren Salt2017-10-191-6/+21
| | | | Signed-off-by: Marek Olšák <[email protected]>
* drirc: Enable glthread for more games (Saints Row 4 & Gat out of Hell).Darren Salt2017-10-191-0/+6
| | | | | | | | | | | | “Saints Row: Gat out of Hell” benefits from this on slower CPUs in that usage spikes on individual cores are avoided, which in turn makes it harder to hit a bug which causes broken audio and the game to hang on exit. “Saints Row IV” appears to be fine either way, but also exhibits the audio breakage bug: glthread is therefore being enabled on the grounds that it should make it a little harder to hit that bug. Signed-off-by: Marek Olšák <[email protected]>
* ralloc: Allow reparenting to a NULL contextJason Ekstrand2017-10-121-1/+1
| | | | | | | Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* radv: create on-disk shader cacheTimothy Arceri2017-10-121-0/+15
| | | | | | | This is the drivers on-disk cache intended to be used as a fallback as opposed to the pipeline cache provided by apps. Reviewed-by: Bas Nieuwenhuizen <[email protected]>
* mesa: move _mesa_half_is_negative() to half_float.hBrian Paul2017-10-101-0/+8
| | | | | | | | v2: use !! in the function to be explicit about type conversion. Though, gcc generates the same code with or without the logical !!. Reviewed-by: Roland Scheidegger <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* disk_cache: remove unnecessary NULL-pointer guardsNicolai Hähnle2017-10-101-4/+2
| | | | Reviewed-by: Marek Olšák <[email protected]>
* disk_cache: fix a memory leakNicolai Hähnle2017-10-101-0/+1
| | | | Reviewed-by: Marek Olšák <[email protected]>
* meson: Build i965 and dri stackDylan Baker2017-10-092-1/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This gets pretty much the entire classic tree building, as well as i965, including the various glapis. There are some workarounds for bugs that are fixed in meson 0.43.0, which is due out on October 8th. I have tested this with piglit using glx. v2: - fix typo "vaule" -> "value" - use gtest dep instead of linking to libgtest (rebase error) - use gtest dep instead of linking against libgtest (rebase error) - copy the megadriver, then create hard links from that, then delete the megadriver. This matches the behavior of the autotools build. (Eric A) - Use host_machine instead of target_machine (Eric A) - Put a comment in the right place (Eric A) - Don't have two variables for the same information (Eric A) - Put pre_args at top of file in this patch (Eric A) - Fix glx generators in this patch instead of next (Eric A) - Remove -DMESON hack (Eric A) - add sha1_h to mesa in this patch (Eric A) - Put generators in loops when possible to reduce code in mapi/glapi/gen (Eric A) v3: - put HAVE_X11_PLATFORM in this patch Signed-off-by: Dylan Baker <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* drirc: whitelist glthread for Spec Ops: The LineMarek Olšák2017-10-091-0/+6
| | | | | | On i7 4790k and a 280X, there is a boost of about 10% more FPS. Nominated by John Ettedgui.
* radeonsi: add a drirc workaround for HTILE corruption in ARK: Survival EvolvedMarek Olšák2017-10-062-0/+10
| | | | | | | | v2: use DB_META | PS_PARTIAL_FLUSH Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102955 Reviewed-by: Samuel Pitoiset <[email protected]> (v1) Reviewed-by: Nicolai Hähnle <[email protected]> (v1)
* util: include string.h in u_string.hBrian Paul2017-10-031-0/+1
| | | | | | | To fix MinGW compiler warning about missing strlen() prototype. Not sure how I missed this when fixing the malloc() / stdlib.h issue. Reviewed-by: Charmaine Lee <[email protected]>
* meson: convert gtest to an internal dependencyDylan Baker2017-10-031-2/+2
| | | | | | | | | | | | In truth gtest is an external dependency that upstream expects you to "vendor" into your own tree. As such, it makes sense to treat it more like a dependency than an internal library, and collect it's requirements together in a dependency object. v2: - include with -isystem instead of setting compiler args (Eric) Signed-off-by: Dylan Baker <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* util: include stdlib.h in u_string.h to silence MinGW warningBrian Paul2017-10-031-0/+1
| | | | | | Otherwise we don't get a prototype for malloc(). Reviewed-by: Eric Engestrom <[email protected]>
* mesa: Remove force_s3tc_enable driconf variableMatt Turner2017-10-021-5/+0
| | | | | Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* drirc: whitelist glthread for OutlastKamil Páral2017-09-291-0/+3
| | | | | FPS increase 10-20% in starting locations on Core i5-4570 + Radeon R9 270.
* util/queue: fix a race condition in the fence codeNicolai Hähnle2017-09-291-0/+13
| | | | | | | | | | | | | | | | A tempting alternative fix would be adding a lock/unlock pair in util_queue_fence_is_signalled. However, that wouldn't actually improve anything in the semantics of util_queue_fence_is_signalled, while making that test much more heavy-weight. So this lock/unlock pair in util_queue_fence_destroy for "flushing out" other threads that may still be in util_queue_fence_signal looks like the better fix. v2: rephrase the comment Cc: [email protected] Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Gustaw Smolarczyk <[email protected]>
* util: fix in-class initialization of static memberThomas Helland2017-09-281-3/+6
| | | | | | | | | | | | | | Fix a compile error with G++ 4.4 string_buffer_test.cpp:43: error: ISO C++ forbids initialization of member ‘str1’ string_buffer_test.cpp:43: error: making ‘str1’ static string_buffer_test.cpp:43: error: invalid in-class initialization of static data member of non-integral type ‘const char*’ Tested-by: Vinson Lee <vlee at freedesktop.org> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103002
* util: add util_vasprintf() for Windows (v2)Brian Paul2017-09-281-0/+22
| | | | | | | | We don't have vasprintf() on Windows so we need to implement it ourselves. v2: compute actual length of output string, per Nicolai Hähnle. Reviewed-by: Nicolai Hähnle <[email protected]>
* meson: Add build Intel "anv" vulkan driverDylan Baker2017-09-273-0/+198
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows building and installing the Intel "anv" Vulkan driver using meson and ninja, the driver has been tested against the CTS and has seems to pass the same series of tests (they both segfault when the CTS tries to run wayland wsi tests). There are still a mess of TODO, XXX, and FIXME comments in here. Those are mostly for meson bugs I'm trying to fix, or for additional things to implement for other drivers/features. I have configured all intermediate libraries and optional tools to not build by default, meaning they will only be built if they're pulled in as a dependency of a target that will actually be installed) this allows us to avoid massive if chains, while ensuring that only the bits that need to be built are. v2: - enable anv, x11, and wayland by default - add configure option to disable valgrind v3: - fix typo in meson_options (Nicholas) v4: - Remove dead code (Eric) - Remove change to generator that was from v0 (Eric) - replace if chain with loop (Eric) - Fix typos (Eric) - define HAVE_DLOPEN for both libdl and builtin dl cases (Eric) v5: - rebase on util string buffer implementation Signed-off-by: Dylan Baker <[email protected]> Reviewed-by: Eric Anholt <[email protected]> (v4)
* util/ralloc: Don't define assert with magic member without DEBUGDylan Baker2017-09-271-0/+8
| | | | | | | | | | It is possible to have DEBUG disabled but asserts on (NDEBUG), which cannot build because these asserts work on members that are only present when DEBUG is on. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Signed-off-by: Dylan Baker <[email protected]>
* util: Add tests for the string bufferThomas Helland2017-09-263-1/+163
| | | | | | | | | | | | | | | | | | | | | | | More tests could probably be added, but this should cover concatenation, resizing, clearing, formatted printing, and checking the length, so it should be quite complete. Signed-off-by: Thomas Helland <[email protected]> Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com> Tested-by: Dieter Nützel <Dieter at nuetzel-hh.de> V2: Address review feedback from Timothy, plus fixes - Use a large enough char array - Actually test the formatted appending - Test that clear function resets string length V3: Port to gtest V4: Fix test makefile Fix copyright header Fix missing extern C Use more appropriate name for C-file Add tests for append_char
* util: Add a string buffer implementationThomas Helland2017-09-263-0/+254
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Based on Vladislav Egorovs work on the preprocessor, but split out to a util functionality that should be universal. Setup, teardown, memory handling and general layout is modeled around the hash_table and the set, to make it familiar for everyone. A notable change is that this implementation is always null terminated. The rationale is that it will be less error-prone, as one might access the buffer directly, thereby reading a non-terminated string. Also, vsnprintf and friends prints the null-terminator. Signed-off-by: Thomas Helland <[email protected]> Tested-by: Dieter Nützel <Dieter at nuetzel-hh.de> Reviewed-by: Nicolai Hähnle <[email protected]> V2: Address review feedback from Timothy and Grazvydas - Fix MINGW preprocessor check - Changed len from uint to int - Make string argument const in append function - Move to header and inline append function - Add crimp_to_fit function for resizing buffer V3: Move include of ralloc to string_buffer.h V4: Use u_string.h for a cross-platform working vsnprintf V5: Remember to cast to char * in crimp function V6: Address review feedback from Nicolai - Handle !str->buf in buffer_create - Ensure va_end is always called in buffer_append_all - Add overflow check in buffer_append_len - Do not expose buffer_space_left, just remove it - Clarify why a loop is used in vprintf, change to for-loop - Add a va_copy to buffer_vprintf to fix failure to append arguments when having to resize the buffer for vsnprintf. V7: Address more review feedback from Nicolai - Add missing va_end corresponding to va_copy - Error check failure to allocate in crimp_to_fit
* util/u_atomic: remove unnecessaty __atomic functionsGrazvydas Ignotas2017-09-221-12/+0
| | | | | | | | | They are now provided by -latomic, which should be linked as needed since previous commit. Signed-off-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* configure: check if -latomic is needed for __atomic_*Grazvydas Ignotas2017-09-221-1/+2
| | | | | | | | | | | | | | | | | | On some platforms, gcc generates library calls when __atomic_* functions are used, but does not link the required library (libatomic) automatically (supposedly to allow the app to use some other atomics implementation?). Detect this at configure time and add the library when needed. Tested on armel (library was added) and on x86_64 (was not, as expected). Some documentation on this is provided in GCC wiki: https://gcc.gnu.org/wiki/Atomic/GCCMM Fixes: 8915f0c0 "util: use GCC atomic intrinsics with explicit memory model" Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102573 Signed-off-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* radeonsi: allow out-of-order rasterization in commutative blending casesNicolai Hähnle2017-09-181-0/+5
| | | | | | | | | | | | We do not enable this by default for additive blending, since it slightly breaks OpenGL invariance guarantees due to non-determinism. Still, there may be some applications can benefit from white-listing via the radeonsi_commutative_blend_add drirc setting without any real visible artifacts. Reviewed-by: Marek Olšák <[email protected]> Tested-by: Dieter Nützel <[email protected]>
* radeonsi: add drirc option "radeonsi_assume_no_z_fights"Nicolai Hähnle2017-09-181-0/+5
| | | | | | | | | | | | | | This option enables a performance optimization where typical non-blending draws with depth buffer may be rasterized out-of-order (on VI+, multi-SE chips). This optimization can lead to incorrect results when an applications renders multiple objects with the same Z value at the same pixel, so we will never enable it by default. But there may be applications that could benefit from white-listing. Reviewed-by: Marek Olšák <[email protected]> Tested-by: Dieter Nützel <[email protected]>
* util/u_atomic: Add implementation of __sync_val_compare_and_swap_8Matt Turner2017-09-151-0/+14
| | | | | | | | | Needed for 32-bit PowerPC. Cc: "17.2" <[email protected]> Fixes: a6a38a038bd ("util/u_atomic: provide 64bit atomics where they're missing") Reviewed-by: Emil Velikov <[email protected]>
* util: Link libmesautil into u_atomic_testMatt Turner2017-09-151-0/+1
| | | | | | | | | | Platforms without particular atomic operations require the implementations in u_atomic.c Cc: "17.2" <[email protected]> Fixes: a6a38a038bd ("util/u_atomic: provide 64bit atomics where they're missing") Reviewed-by: Emil Velikov <[email protected]>
* drirc: enable glthread for more games (Civ5, CivBE, Dreamfall, Hitman, SR3)Christoph Berliner2017-09-141-0/+15
| | | | Signed-off-by: Marek Olšák <[email protected]>
* util/build_id: Include <dlfcn.h>Chad Versace2017-09-131-0/+1
| | | | | | | | | | | Fix the build for Android Nougat. The dladdr(3) manpage says that <dlfcn.h> is required. On Linux, the build succeeded without it because build_id.c includes <link.h> which includes <dlfcn.h>. On Android, we must include <dlfcn.h> directly. Fixes: 5c98d382 "util: Query build-id by symbol address, not library name" Reviewed-by: Matt Turner <[email protected]>
* util: Query build-id by symbol address, not library nameChad Versace2017-09-132-12/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch renames build_id_find_nhdr() to build_id_find_nhdr_for_addr(), and changes it to never examine the library name. Tested on Fedora by confirming that build_id_get_data() returns the same build-id as the file(1) tool. For BSD, I confirmed that the API used (dladdr() and struct Dl_info) is documented in FreeBSD's manpages. This solves two problems: - We can now the query the build-id without knowing the installed library's filename. This matters because Android requires specific filenames for HAL modules, such as "/vendor/lib/hw/vulkan.${board}.so". The HAL filenames do not follow the Unix convention of "libfoo.so". In other words, the same query code will now work on Linux and Android. - Querying the build-id now works correctly when the process contains multiple shared objects with the same basename. (Admittedly, this is a highly unlikely scenario). Cc: Jonathan Gray <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* util/disk_cache: turn MESA_GLSL_CACHE_DISABLE into a booleanEric Engestrom2017-09-121-1/+2
| | | | | | | | | | Instead of setting based on set/unset, allow users to use boolean values. In the docs and tests, use `DISABLE=true` instead of `DISABLE=1` as it's clearer IMO. Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* disk_cache: make the thread queue resizable and low priorityMarek Olšák2017-09-071-6/+8
| | | | | Acked-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* util: rename include guard to avoid clashEric Engestrom2017-09-071-3/+3
| | | | | | | | src/mesa/main/debug.h uses the same include guard. Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* util/ralloc: set prev-pointers correctly in ralloc_adoptNicolai Hähnle2017-09-061-1/+3
| | | | | | | | | | | | Found by inspection. I'm not aware of any actual failures caused by this, but a precise sequence of ralloc_adopt and ralloc_free should be able to cause problems. v2: make the code slightly clearer (Eric) Reviewed-by: Eric Engestrom <[email protected]>
* util: improve compiler guardEric Engestrom2017-09-031-6/+6
| | | | | | | | | | | | | | | Glibc 2.26 has dropped xlocale.h, but the functions needed (strtod_l() and strdof_l()) can be found in stdlib.h. Improve the detection method to allow newer builds to still make use of the locale-setting. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102454 Cc: Laurent Carlier <[email protected]> Cc: Emil Velikov <[email protected]> Cc: Rob Herring <[email protected]> Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Laurent Carlier <[email protected]> Reviewed-by: Jose Fonseca <[email protected]>
* util: only use SCHED_IDLE in pthread_setschedparam() when it's definedRoland Scheidegger2017-09-011-1/+1
| | | | | | Fixes build error when it's not. Reviewed-by: Jose Fonseca <[email protected]>
* util: move string_to_uint_map to glslEmil Velikov2017-08-293-221/+0
| | | | | | | | | | | | | | | | | | The functionality is used by glsl and mesa. With the latter already depending on the former. With this in place the src/util/ static library libmesautil.la no longer has a C++ dependency. Thus objects which use it (like libEGL) don't need the C++ link. Cc: "17.2" <[email protected]> Fixes: 02cc35937277 ("egl/wayland: Use linux-dmabuf interface for buffers") Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101851 Signed-off-by: Emil Velikov <[email protected]> Suggested-by: Jason Ekstrand <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Tested-by: Mike Lothian <[email protected]> Tested-by: James Harvey <[email protected]>
* disk_cache: assert if a cache entries keys don't match mesaTimothy Arceri2017-08-281-1/+3
| | | | | | | | | In ef42423e7be9 I enabled the check for release builds however we still want to assert in debug builds in case of collisions or just general bugs with the key building/compare code. Otherwise it will just fail silently effectively disabling the cache. Reviewed-by: Eduardo Lima Mitev <[email protected]>
* xmlconfig: use the portable __VA_ARGS__Emil Velikov2017-08-261-6/+6
| | | | | | | | | | | 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 <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* util/disk_cache: write cache item metadata to diskTimothy Arceri2017-08-251-1/+87
| | | | Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: pass shader source keys to the disk cacheTimothy Arceri2017-08-252-5/+9
| | | | | | | We don't actually write them to disk here. That will happen in the following commit. Reviewed-by: Nicolai Hähnle <[email protected]>
* util/disk_cache: add struct cache_item_metadataTimothy Arceri2017-08-251-0/+20
| | | | | | | | | This will be used to store more information about the cache item in it's header. This information is intended for 3rd party and cache analysis use but can also be used for detecting the unlikely scenario of cache collisions. Reviewed-by: Nicolai Hähnle <[email protected]>
* disk_cache: enable limited hash collision detection in release buildsTimothy Arceri2017-08-251-16/+10
| | | | | | | It really doesn't cost us much and will stop strange crashes should the stars align. Reviewed-by: Nicolai Hähnle <[email protected]>
* util/disk_cache: rename mesa cache dir and introduce cache versioningTimothy Arceri2017-08-252-12/+38
| | | | | | | | | | | | | | | | | | Steam is already analysing cache items, unfortunatly we did not introduce a versioning mechanism for identifying structural changes to cache entries earlier so the only way to do so is to rename the cache directory. Since we are renaming it we take the opportunity to give the directory a more meaningful name. Adding a version field to the header of cache entries will help us to avoid having to rename the directory in future. Please note this is versioning for the internal structure of the entries as defined in disk_cache.{c,h} as opposed to the structure of the data provided to the disk cache by the GLSL compiler and the various driver backends. Reviewed-by: Nicolai Hähnle <[email protected]>
* anv: Move a comment that got left behind in the u_vector refactor.Eric Anholt2017-08-181-0/+9
|
* util: Fix build on old glibc.Eric Anholt2017-08-151-1/+3
| | | | | | | We need to link librt for u_thread.h's clock_gettime() call. Fixes: b822d9dd67b5 ("gallium/util: move u_queue.{c,h} to src/util") Reviewed-by: Matt Turner <[email protected]>
* util/ralloc: add ralloc_str_append() helperTimothy Arceri2017-08-112-0/+37
| | | | | | | | This function differs from ralloc_strcat() and ralloc_strncat() in that it does not do any strlen() calls which can become costly on large strings. Reviewed-by: Thomas Helland <[email protected]>