summaryrefslogtreecommitdiffstats
path: root/src/util
Commit message (Collapse)AuthorAgeFilesLines
* util/tests/vma: Fix warning c++11-narrowingScott D Phillips2018-06-051-1/+1
| | | | | | Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106801 Fixes: 943fecc569 ("util: Add a randomized test for the virtual memory allocator") Reviewed-by: Dylan Baker <[email protected]>
* util: tests: vma test depends on C++11 supportScott D Phillips2018-06-051-2/+5
| | | | | | | Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106776 Fixes: 943fecc569 ("util: Add a randomized test for the virtual memory allocator") Tested-by: Vinson Lee <[email protected]> Reviewed-by: Dylan Baker <[email protected]>
* util: Add a randomized test for the virtual memory allocatorScott D Phillips2018-05-315-1/+315
| | | | | | | | | | | | | | | | | The test pseudo-randomly makes allocations and deallocations with the virtual memory allocator and checks that the results are consistent. Specifically, we test that: * no result from the allocator overlaps an already allocated range * allocated memory fulfills the stated alignment requirement * a failed result from the allocator could not have been fulfilled * memory freed to the allocator can later be allocated again v2: - fix if() in test() to actually run fill() v3: - add c++11 build flag (Jason) - test the full 64-bit range (Jason) Reviewed-by: Jason Ekstrand <[email protected]>
* util: Add a virtual memory allocatorJason Ekstrand2018-05-314-1/+292
| | | | | | | | | | | | | | | | | | | | | | This is simple linear-walk first-fit allocator roughly based on the allocator in the radeon winsys code. This allocator has two primary functional differences: 1) It cleanly returns 0 on allocation failure 2) It allocates addresses top-down instead of bottom-up. The second one is needed for Intel because high addresses (with bit 47 set) need to be canonicalized in order to work properly. If we allocate bottom-up, then high addresses will be very rare (if they ever happen). We'd rather always have high addresses so that the canonicalization code gets better testing. v2: - [scott-ph] remove _heap_validate() if NDEBUG is defined (Jordan) Reviewed-by: Scott D Phillips <[email protected]> Tested-by: Scott D Phillips <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* util/u_math: Implement a logbase2 function for unsigned longPierre Moreau2018-05-291-0/+11
| | | | | | | | | | v2 (Karol Herbst <[email protected]>): * removed unneeded ll * ll -> ull Signed-off-by: Karol Herbst <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* util/set: add a set_clear functionScott D Phillips2018-05-042-0/+26
| | | | | | | Clear a set back to the state of having zero entries. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* util/u_queue: fix a deadlock in util_queue_finishMarek Olšák2018-04-272-0/+10
| | | | | Cc: 18.0 18.1 <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* util/srgb: Add a float sRGB -> linear helperJason Ekstrand2018-04-241-0/+14
| | | | | Reviewed-by: Nanley Chery <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* mesa: include mtypes.h lessMarek Olšák2018-04-122-1/+1
| | | | | | | | | | - remove mtypes.h from most header files - add main/menums.h for often used definitions - remove main/core.h v2: fix radv build Reviewed-by: Brian Paul <[email protected]>
* util: Include bitscan.h directlyIan Romanick2018-03-291-1/+1
| | | | | | | | | | | | | | | Previously bitset.h would include u_math.h to get bitscan.h. u_math.h lives in src/gallium/auxiliary/util while both bitset.h and bitscan.h live in src/util. Having the one file directly include another file that lives in the same directory makes much more sense. As a side-effect, several files need to directly include standard header files that were previously indirectly included. v2: Fix build break in src/amd/common/ac_nir_to_llvm.c. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eduardo Lima Mitev <[email protected]>
* util: Optimize util_is_power_of_two_nonzeroIan Romanick2018-03-291-0/+17
| | | | | | Signed-off-by: Ian Romanick <[email protected]> Suggested-by: Matt Turner <[email protected]> Reviewed-by: Eduardo Lima Mitev <[email protected]>
* util: Use util_is_power_of_two_nonzero in u_vectorIan Romanick2018-03-291-2/+2
| | | | | | | | Previously size=0, element_size=0 would have been allowed. That combination can only lead to despair. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Alejandro Piñeiro <[email protected]>
* util: Add and use util_is_power_of_two_nonzeroIan Romanick2018-03-291-0/+11
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eduardo Lima Mitev <[email protected]>
* util: Move util_is_power_of_two to bitscan.h and rename to ↵Ian Romanick2018-03-292-2/+14
| | | | | | | | | | | util_is_power_of_two_or_zero The new name make the zero-input behavior more obvious. The next patch adds a new function with different zero-input behavior. Signed-off-by: Ian Romanick <[email protected]> Suggested-by: Matt Turner <[email protected]> Reviewed-by: Alejandro Piñeiro <[email protected]>
* drirc: whitelist glthread for Medieval II: TW, Carnivores: DHR, Far Cry 2Marek Olšák2018-03-281-0/+15
|
* meson/configure: detect endian.h instead of trying to guess when it's availableEric Engestrom2018-03-231-1/+1
| | | | | | | | | | | Cc: Maxin B. John <[email protected]> Cc: Khem Raj <[email protected]> Cc: Rob Herring <[email protected]> Suggested-by: Jon Turney <[email protected]> Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Dylan Baker <[email protected]> Cc: <[email protected]>
* util: Use set_foreach instead of rolling our ownThomas Helland2018-03-141-6/+2
| | | | | | This follows the same pattern as in the hash_table. Reviewed-by: Jason Ekstrand <jason.ekstrand at intel.com>
* util: Implement a hash table cloning functionThomas Helland2018-03-142-0/+24
| | | | | | | V2: Don't rzalloc; we are about to rewrite the whole thing (Vladislav) Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* drirc: whitespace fixEric Engestrom2018-03-081-2/+2
| | | | Signed-off-by: Eric Engestrom <[email protected]>
* drirc: Disable the GLX_SGI_video_sync extension for gnome-shell on vmwareThomas Hellstrom2018-03-081-0/+1
| | | | | | | | | | | With this extension enabled and a server GLX implementation that actually honors it, Window movement lags considerably on gnome-shell/vmware, so disable it by default. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Sinclair Yeh <[email protected]> Reviewed-by: Deepak Rawat <[email protected]>
* glx/dri: Add a driconf option to disable GLX_SGI_video_syncThomas Hellstrom2018-03-081-0/+5
| | | | | | | | | | | Drivers on virtual hardware don't want to expose this extension to GLX compositors, similarly to GLX_OML_sync_control, since that significantly increases latency. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Sinclair Yeh <[email protected]> Reviewed-by: Deepak Rawat <[email protected]>
* disk cache: Link with -latomic if necessaryThierry Reding2018-03-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | The disk cache implementation uses 64-bit atomic operations. For some architectures, such as 32-bit ARM, GCC will not be able to translate these operations into atomic, lock-free instructions and will instead rely on the external atomics library to provide these operations. Check at configuration time whether or not linking against libatomic is necessary and if so, create a dependency that can be used while linking the mesautil library. This is the meson equivalent of 2ef7f23820a6 ("configure: check if -latomic is needed for __atomic_*"). For some background information on this, see: https://gcc.gnu.org/wiki/Atomic/GCCMM Changes in v2: - clarify meaning of lock-free in commit message - fix build if -latomic is not necessary Acked-by: Matt Turner <[email protected]> Reviewed-by: Dylan Baker <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
* util: use clock_gettime() on PIPE_OS_BSDJonathan Gray2018-03-011-1/+1
| | | | | | | | OpenBSD, FreeBSD, NetBSD and DragonFlyBSD all have clock_gettime() so use it when PIPE_OS_BSD is defined. Signed-off-by: Jonathan Gray <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* util/bitset: Make C++ wrapper trivially constructible.Francisco Jerez2018-02-271-17/+20
| | | | | | | | | | | | | | | In order to fix a build failure on compilers not implementing unrestricted unions, which is a C++11 feature. v2: Provide signed integer comparison and assignment operators instead of BITSET_WORD ones to avoid spurious ambiguity warnings on comparisons with a signed integer literal. Fixes: ba79a90fb52e1e81fb "glsl: Switch ast_type_qualifier to a 128-bit bitset." Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105238 Tested-by: Roland Scheidegger <[email protected]> Tested-By: George Kyriazis <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
* util/bitset: Add C++ wrapper for static-size bitsets.Francisco Jerez2018-02-241-0/+114
| | | | Reviewed-by: Plamena Manolova <[email protected]>
* util: Add EXPLICIT_CONVERSION macro.Francisco Jerez2018-02-241-0/+10
| | | | | | | | | This can be used to specify that a C++ conversion operator is not meant to be used for implicit conversions, which can lead to unintended loss of information in some cases. Implemented as a macro in order to keep old GCC versions happy. Reviewed-by: Plamena Manolova <[email protected]>
* disk cache: move path creation back to constructorTapani Pälli2018-02-091-86/+76
| | | | | | | | | | | This patch moves disk cache path and index creation back to the constructor which matches previous behavior. We still allow create to succeed without path so that cache can be used with callback functionality. Fixes: c95d3ed091 "disk cache: create cache even if path creation fails" Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* disk cache: add callback functionalityTapani Pälli2018-02-072-0/+67
| | | | | | | | | | | v2: add disk_cache_has_key, disk_cache_put_key support using blob cache (Nicolai, Jordan) v3: rename set_cb as put_cb to match existing naming (Timothy) Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* disk cache: initialize cache path and index only when usedTapani Pälli2018-02-071-49/+80
| | | | | | | | | | | | This patch makes disk_cache initialize path and index lazily so that we can utilize disk_cache without a path using callback functionality introduced by next patch. v2: unmap mmap and destroy queue only if index_mmap exists Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* util: remove redundant check for the __clang__ macroVlad Golovkin2018-02-061-1/+2
| | | | | | | | | Clang defines __GNUC__ macro, so one doesn't need to check __clang__ macro in this particular case. v2: added comment as per Brian Paul's suggestion Reviewed-by: Brian Paul <[email protected]>
* util/build-id: Fix address comparison for binaries with LOAD vaddr > 0Stephan Gerhold2018-02-051-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | build_id_find_nhdr_for_addr() fails to find the build-id if the first LOAD segment has a virtual address other than 0x0. For most shared libraries, the first LOAD segment has vaddr=0x0: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x000000 0x00000000 0x00000000 0x2d2e26 0x2d2e26 R E 0x1000 LOAD 0x2d2e54 0x002d3e54 0x002d3e54 0x2e248 0x2f148 RW 0x1000 However, compiling the Intel Vulkan driver as 32-bit binary on Android produces the following ELF header with vaddr=0x8000 instead: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align PHDR 0x000034 0x00008034 0x00008034 0x00100 0x00100 R 0x4 LOAD 0x000000 0x00008000 0x00008000 0x224a04 0x224a04 R E 0x1000 LOAD 0x225710 0x0022e710 0x0022e710 0x25988 0x27364 RW 0x1000 build_id_find_nhdr_callback() compares the address of dli_fbase from dladdr() and dlpi_addr from dl_iterate_phdr(). With vaddr > 0, these point to a different memory address, e.g.: dli_fbase=0xd8395000 (offset 0x8000) dlpi_addr=0xd838d000 At least on glibc and bionic (Android) dli_fbase refers to the address where the shared object is mapped into the process space, whereas dlpi_addr is just the base address for the vaddrs declared in the ELF header. To compare them correctly, we need to calculate the start of the mapping by adding the vaddr of the first LOAD segment to the base address. Note: musl users will need the following patch. https://git.musl-libc.org/cgit/musl/commit/?id=b3ae7beabb9f0c219bb8a8b63567a01c6530c1ac Cc: Chad Versace <[email protected]> Cc: <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104642 Fixes: 5c98d38 "util: Query build-id by symbol address, not library name" Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* meson: correctly set SYSCONFDIR for loading dirrcDylan Baker2018-01-241-2/+6
| | | | | | | Fixes: d1992255bb29 ("meson: Add build Intel "anv" vulkan driver") Reported-by: Marc Dietrich <[email protected]> Signed-off-by: Dylan Baker <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* u_thread: Use pthread_setname_np on linux only.Samuel Thibault2018-01-221-1/+2
| | | | | | | pthread_setname_np was added in glibc 2.12 for the Linux port only, other ports do not necessarily have it. Signed-off-by: Jose Fonseca <[email protected]>
* autotools: include meson build files in tarballDylan Baker2018-01-194-2/+8
| | | | | | | | | | | | This adds the meson.build, meson_options.txt, and a few scripts that are used exclusively by the meson build. v2: - Remove accidentally included changes needed to test make dist with LLVM > 3.9 Signed-off-by: Dylan Baker <[email protected]> Acked-by: Eric Engestrom <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* util: include string.h in u_dynarray.hBrian Paul2018-01-171-0/+1
| | | | | | To get memset() prototype. Reviewed-by: Nicolai Hähnle <[email protected]>
* mesa: include compiler.h in disk_cache.cBrian Paul2018-01-171-0/+1
| | | | | | Instead of indirect inclusion to get CPU_TO_LE32() macro. Reviewed-by: Nicolai Hähnle <[email protected]>
* util: use faster zlib's CRC32 implementaionGrazvydas Ignotas2018-01-141-0/+13
| | | | | | | | | | | | | | | | | | | | zlib provides a faster slice-by-4 CRC32 implementation than the traditional single byte lookup one used by mesa. As most supported platforms now link zlib unconditionally, we can easily use it. Improvement for a 1MB buffer (avg MB/s, n=100, zlib 1.2.8): i5-6600K C2D E4500 mesa zlib mesa zlib 443 1443 225% +/- 2.1% 403 1175 191% +/- 0.9% It has been verified the calculation results stay the same after this change. Signed-off-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* util/crc32: don't drop the const qualifierGrazvydas Ignotas2018-01-141-1/+1
| | | | | | Signed-off-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* util: fix NORETURN for msvc, add HAVE_FUNC_ATTRIBUTE_NORETURN to c99_compat.hRoland Scheidegger2018-01-121-4/+8
| | | | | | | | | | We've seen some problems internally due to macro redefinition. Fix this by adding HAVE_FUNC_ATTRIBUTE_NORETURN to c99_compat.h, and defining it for msvc. And avoid redefinition just in case. Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Jose Fonseca <[email protected]>
* meson: Use consistent style for testsDylan Baker2018-01-113-37/+45
| | | | | | | Don't use intermediate variables, use consistent whitespace. Acked-by: Eric Engestrom <[email protected]> Signed-off-by: Dylan Baker <[email protected]>
* link mesautil with pthreadsIgor Gnatenko2018-01-081-0/+2
| | | | | | | | | | | | | | | | | | | | | | ../../src/util/.libs/libmesautil.a(libmesautil_la-u_queue.o): In function `u_thread_setname': /builddir/build/BUILD/mesa-17.3.1/src/util/../../src/util/u_thread.h:66: undefined reference to `pthread_setname_np' ../../src/util/.libs/libmesautil.a(libmesautil_la-u_queue.o): In function `thrd_join': /builddir/build/BUILD/mesa-17.3.1/src/util/../../include/c11/threads_posix.h:336: undefined reference to `pthread_join' ../../src/util/.libs/libmesautil.a(libmesautil_la-u_queue.o): In function `u_thread_create': /builddir/build/BUILD/mesa-17.3.1/src/util/../../src/util/u_thread.h:48: undefined reference to `pthread_sigmask' ../../src/util/.libs/libmesautil.a(libmesautil_la-u_queue.o): In function `thrd_create': /builddir/build/BUILD/mesa-17.3.1/src/util/../../include/c11/threads_posix.h:296: undefined reference to `pthread_create' ../../src/util/.libs/libmesautil.a(libmesautil_la-u_queue.o): In function `u_thread_create': /builddir/build/BUILD/mesa-17.3.1/src/util/../../src/util/u_thread.h:50: undefined reference to `pthread_sigmask' /builddir/build/BUILD/mesa-17.3.1/src/util/../../src/util/u_thread.h:50: undefined reference to `pthread_sigmask' ../../src/util/.libs/libmesautil.a(libmesautil_la-u_queue.o): In function `call_once': /builddir/build/BUILD/mesa-17.3.1/src/util/../../include/c11/threads_posix.h:96: undefined reference to `pthread_once' ../../src/util/.libs/libmesautil.a(libmesautil_la-u_queue.o): In function `u_thread_get_time_nano': /builddir/build/BUILD/mesa-17.3.1/src/util/../../src/util/u_thread.h:84: undefined reference to `pthread_getcpuclockid' collect2: error: ld returned 1 exit status Reviewed-by: Adam Jackson <[email protected]> Signed-off-by: Igor Gnatenko <[email protected]>
* dri/common: Add option to allow exposure of 10 bpc color configs. (v2)Mario Kleiner2018-01-031-0/+5
| | | | | | | | | | | | | | | | | Some clients may not like RGB10X2 and RGB10A2 fbconfigs and visuals. Add a new driconf option 'allow_rgb10_configs' to allow per application enable/disable. The option defaults to enabled. v2: Rename expose_rgb10_configs to allow_rgb10_configs, as suggested by Emil. Add comment to option parsing, to make sure it stays before the ->InitScreen(). Signed-off-by: Mario Kleiner <[email protected]> Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Signed-off-by: Marek Olšák <[email protected]>
* Android: util: fix locale generation in options.hRob Herring2018-01-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | The parameters to gen_xmlpool.py are wrong and cause the following warnings: Warning: language 'out/target/product/linaro_x86_64/gen/STATIC_LIBRARIES/libmesa_util_intermediates/xmlpool/es/LC_MESSAGES/options.mo' not found. Warning: language 'out/target/product/linaro_x86_64/gen/STATIC_LIBRARIES/libmesa_util_intermediates/xmlpool/nl/LC_MESSAGES/options.mo' not found. Warning: language 'out/target/product/linaro_x86_64/gen/STATIC_LIBRARIES/libmesa_util_intermediates/xmlpool/fr/LC_MESSAGES/options.mo' not found. Warning: language 'out/target/product/linaro_x86_64/gen/STATIC_LIBRARIES/libmesa_util_intermediates/xmlpool/sv/LC_MESSAGES/options.mo' not found. Warning: language 'external/mesa3d/src/util/xmlpool/t_options.h' not found. Warning: language 'out/target/product/linaro_x86_64/gen/STATIC_LIBRARIES/libmesa_util_intermediates/xmlpool' not found. Warning: language 'de' not found. Warning: language 'es' not found. Warning: language 'nl' not found. Warning: language 'fr' not found. Warning: language 'sv' not found. The result is English is the only language in options.h. Use "$<" instead of "$^" because we only need the first dependency (the script), not all dependencies. Signed-off-by: Rob Herring <[email protected]>
* drirc: set allow_glsl_cross_stage_interpolation_mismatch for more gamesTapani Pälli2017-12-201-0/+8
| | | | | | | Signed-off-by: Tapani Pälli <[email protected]> Suggested-by: Darius Spitznagel <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104288 Acked-by: Kenneth Graunke <[email protected]>
* util: scons: wire up the sha1 testEmil Velikov2017-12-151-0/+7
| | | | | Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Andres Gomez <[email protected]>
* drirc: whitelist glthread for Mount and Blade Warband againMarek Olšák2017-12-111-0/+3
|
* meson: add dep_thread to every lib that includes threads.hEric Engestrom2017-12-071-1/+1
| | | | | | Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104141 Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Dylan Baker <[email protected]>
* util/disk_cache: Remove unneeded free() on always null stringVadym Shovkoplias2017-12-071-1/+0
| | | | | | | | | At this point dc_job->cache_item_metadata.keys always equals NULL, so call to free() is useless Fixes: b86ecea3446 ("util/disk_cache: write cache item metadata to disk") Signed-off-by: Vadym Shovkoplias <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* util: Add a NORETURN macroJason Ekstrand2017-12-041-0/+6
| | | | | Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa: add AllowGLSLCrossStageInterpolationMismatch workaroundTapani Pälli2017-11-302-0/+12
| | | | | | | | | | | | | This fixes issues seen with certain versions of Unreal Engine 4 editor and games built with that using GLSL 4.30. v2: add driinfo_gallium change (Emil Velikov) Signed-off-by: Tapani Pälli <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97852 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103801 Acked-by: Andres Gomez <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>