summaryrefslogtreecommitdiffstats
path: root/src/util
Commit message (Collapse)AuthorAgeFilesLines
* ralloc: Make sure ralloc() allocations match malloc()'s alignment.Jonas Pfeil2017-03-021-1/+12
| | | | | | | | | | | | | | | | | | | The header of ralloc needs to be aligned, because the compiler assumes that malloc returns will be aligned to 8/16 bytes depending on the platform, leading to degraded performance or alignment faults with ralloc. Fixes SIGBUS on Raspberry Pi at high optimization levels. This patch is not perfect for MSVC, as maybe in the future the alignment for the most demanding data type might change to more than 8. v2: Commit message reword/typo fix, and add a bigger explanation in the code (by anholt) Signed-off-by: Jonas Pfeil <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Cc: [email protected]
* util/build-id: Return a pointer rather than copying the dataJason Ekstrand2017-03-012-7/+5
| | | | | | | | We're about to use the build-id as the starting point for another SHA1 hash in the Intel Vulkan driver, and returning a pointer is far more convenient. Reviewed-by: Chad Versace <[email protected]>
* ralloc: Delete autofree handling.Kenneth Graunke2017-02-272-27/+0
| | | | | | | | | | | | | There was exactly one user of this, and I just removed it. It also accessed an implicit global context, with no locking. This meant that it was only safe if all callers of ralloc_autofree_context() held the same lock...which is a pretty terrible thing for a utility library to impose. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]>
* util/disk_cache: Use backward compatible st_mtime.Vinson Lee2017-02-241-1/+1
| | | | | | | | | | | | | | | | Fix Mac OS X build error. CC libmesautil_la-disk_cache.lo In file included from disk_cache.c:46: ./disk_cache.h:57:20: error: no member named 'st_mtim' in 'struct stat' *timestamp = st.st_mtim.tv_sec; ~~ ^ Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99918 Fixes: 207e3a6e4b ("util/radv: move *_get_function_timestamp() to utils") Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* util: automake: add sha1/README to the tarballEmil Velikov2017-02-241-1/+4
| | | | | Suggested-by: Andreas Boll <[email protected]> Signed-off-by: Emil Velikov <[email protected]>
* util/disk_cache: fix bug with deleting old cache dirsTimothy Arceri2017-02-231-4/+6
| | | | | | | | | | If there was more than a single directory in the .cache/mesa dir then it would only remove one (or none) of the directories. Apparently Valgrind was also reporting: Conditional jump or move depends on uninitialised value Reviewed-by: Edward O'Callaghan <[email protected]>
* util: fix MSVC build issue in disk_cache.hBrian Paul2017-02-211-10/+16
| | | | | | | | Windows doesn't have dlfcn.h. Protect the code in question with #if ENABLE_SHADER_CACHE test. And fix indentation. Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
* util/disk_cache: create timestamp and gpu_id dirs when MESA_GLSL_CACHE_DIR ↵Timothy Arceri2017-02-221-2/+8
| | | | | | | | is used The make check test is also updated to make sure these dirs are created. Reviewed-by: Nicolai Hähnle <[email protected]>
* util/radv: move *_get_function_timestamp() to utilsTimothy Arceri2017-02-221-0/+17
| | | | Reviewed-by: Nicolai Hähnle <[email protected]>
* util/build-id: define ElfW and NT_GNU_BUILD_ID if neededJonathan Gray2017-02-201-0/+8
| | | | | | | | | Define ElfW() and NT_GNU_BUILD_ID if needed as these defines are not present on at least OpenBSD and FreeBSD. Fixes the build on OpenBSD. Fixes: d4fa083e11f ("util: Add utility build-id code.") Signed-off-by: Jonathan Gray <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* glsl: disable on disk shader cache when running as another userTimothy Arceri2017-02-171-0/+4
| | | | Reviewed-by: Nicolai Hähnle <[email protected]>
* util/disk_cache: fix typo in function stubTimothy Arceri2017-02-171-1/+1
|
* util/disk_cache: check cache exists before calling munmap()Timothy Arceri2017-02-171-1/+2
| | | | Reviewed-by: Nicolai Hähnle <[email protected]>
* util/disk_cache: add support for removing old versions of the cacheTimothy Arceri2017-02-171-0/+37
| | | | Reviewed-by: Nicolai Hähnle <[email protected]>
* util/disk_cache: allow drivers to pass a directory structureTimothy Arceri2017-02-172-6/+26
| | | | | | | | | | | | | | In order to avoid costly fallback recompiles when cache items are created with an old version of Mesa or for a different gpu on the same system we want to create directories that look like this: ./{TIMESTAMP}_{LLVM_TIMESTAMP}/{GPU_ID} Note: The disk cache util will take a single timestamp string, it is up to the backend to concatenate the llvm string with the mesa string if applicable. Reviewed-by: Nicolai Hähnle <[email protected]>
* util/disk_cache: do not allow space in MESA_GLSL_CACHE_MAX_SIZEEmil Velikov2017-02-161-2/+0
| | | | | | | No other env var used in mesa allows for space in the variable contents. Signed-off-by: Emil Velikov <[email protected]> Acked-by: Timothy Arceri <[email protected]>
* util: Add utility build-id code.Matt Turner2017-02-153-0/+149
| | | | | | | | Provides the ability to read the .note.gnu.build-id section of ELF binaries, which is inserted by the --build-id=... flag to ld. Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* util: Fix a typo in Makefile.sourcesJason Ekstrand2017-02-151-1/+1
| | | | Reviewed-by: Eric Engestrom <[email protected]>
* util: Add helpers for iterating over Vulkan extension structsJason Ekstrand2017-02-142-1/+45
| | | | Reviewed-by: Dave Airlie <[email protected]>
* util/disk_cache: correctly use stat(3)Timothy Arceri2017-02-131-4/+4
| | | | | | | | | I forgot to error check stat() and also I wasn't using the subdir in is_two_character_sub_directory(). Fixes: d7b3707c612 "util/disk_cache: use stat() to check if entry is a directory" Reviewed-by: Plamena Manolova <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* util/disk_cache: use stat() to check if entry is a directoryTimothy Arceri2017-02-101-9/+24
| | | | | | | | d_type is not supported on all systems. Tested-by: Vinson Lee <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97967
* util/disk_cache: error check asprintf()Timothy Arceri2017-02-101-5/+7
| | | | | | | Fixes: f3d911463e8 "util/disk_cache: stop using ralloc_asprintf() unnecessarily" Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* util/disk_cache: stop using ralloc_asprintf() unnecessarilyTimothy Arceri2017-02-091-13/+12
| | | | Reviewed-by: Anuj Phogat <[email protected]>
* util: add a disk_cache_remove() functionTimothy Arceri2017-02-092-0/+34
| | | | | | | | | | This will be used to remove cache items created with old versions of Mesa or other invalid cache items from the cache. V2: rename stub function (cache_* funtions were renamed disk_cache_*) in master. Reviewed-by: Anuj Phogat <[email protected]>
* glsl: Switch to disable-by-default for the GLSL shader cacheCarl Worth2017-01-311-0/+7
| | | | | | | | | | | | | | | | | The shader cache is expected to be developed incrementally over a fairly long series of commits. For that period of instability, we require users to opt into the shader cache by setting: MESA_GLSL_CACHE_ENABLE=1 In the future, when the shader cache is complete, we can revert this commit so that the cache will be on by default. The user can always disable the cache with MESA_GLSL_CACHE_DISABLE=1. That functionality is not affected by this commit, (nor will it be affected by the future revert). Reviewed-by: Eric Anholt <[email protected]>
* utils: really remove the __END_DECLS macroEmil Velikov2017-01-181-1/+0
| | | | | Fixes: d1efa09d342 "util: import sha1 implementation from OpenBSD" Signed-off-by: Emil Velikov <[email protected]>
* utils: build sha1/disk cache only with Android/AutoconfEmil Velikov2017-01-182-0/+46
| | | | | | | | | | Earlier commit imported a SHA1 implementation and relaxed the SHA1 and disk cache handling, broking the Windows builds. Restrict things for now until we get to a proper fix. Fixes: d1efa09d342 "util: import sha1 implementation from OpenBSD" Signed-off-by: Emil Velikov <[email protected]>
* util: import sha1 implementation from OpenBSD17.0-branchpointEmil Velikov2017-01-189-295/+289
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At the moment we support 5+ different implementations each with varying amount of bugs - from thread safely problems [1], to outright broken implementation(s) [2] In order to accommodate these we have 150+ lines of configure script and extra two configure toggles. Whist an actual implementation being ~200loc and our current compat wrapping ~250. Let's not forget that different people use different code paths, thus effectively makes it harder to test and debug since the default implementation is automatically detected. To minimise all these lovely experiences, import the "100% Public Domain" OpenBSD sha1 implementation. Clearly document any changes needed to get building correctly, since many/most of those can be upstreamed making future syncs easier. As an added bonus this will avoid all the 'fun' experiences trying to integrate it with the Android and SCons builds. v2: Manually expand __BEGIN_DECLS/__END_DECLS and document (Tapani). Furthermore it seems that some games (or surrounding runtime) static link against OpenSSL resulting in conflicts. For more information see the discussion thread [3] Bugzilla [1]: https://bugs.freedesktop.org/show_bug.cgi?id=94904 Bugzilla [2]: https://bugs.freedesktop.org/show_bug.cgi?id=97967 [3] https://lists.freedesktop.org/archives/mesa-dev/2017-January/140748.html Cc: Mark Janes <[email protected]> Cc: Vinson Lee <[email protected]> Cc: Tapani Pälli <[email protected]> Cc: Jonathan Gray <[email protected]> Tested-by: Jonathan Gray <[email protected]> Signed-off-by: Emil Velikov <[email protected]> Acked-by: Tapani Pälli <[email protected]> (v1) Acked-by: Jason Ekstrand <[email protected]> (v1)
* radeonsi: make fix_fetch 64-bitMarek Olšák2017-01-161-0/+9
| | | | | | v2: add u_bit_consecutive64 Reviewed-by: Nicolai Hähnle <[email protected]>
* util: fix list_is_singular()Timothy Arceri2017-01-121-1/+1
| | | | | | | | Currently its dependant on the user calling and checking the result of list_empty() before using the result of list_is_singular(). Cc: "13.0" <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* util: import CRC32 implementation from galliumMarek Olšák2016-11-223-0/+178
| | | | Reviewed-by: Timothy Arceri <[email protected]>
* util/disk_cache: close a previously opened handle in disk_cache_put (v2)Gwan-gyeong Mun2016-11-221-6/+5
| | | | | | | | | | | | | | We're missing the close() to the matching open(). CID 1373407 v2: Fixes from Emil Velikov's review Update the teardown in reverse order of the setup/init. Cc: "13.0" <[email protected]> Signed-off-by: Mun Gwan-gyeong <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> (v1)
* mesa: removed redundant #elseGeorge Kyriazis2016-11-211-1/+0
| | | | Reviewed-by: Emil Velikov <[email protected]>
* util/vk_alloc: Add a vk_zalloc2 helperJason Ekstrand2016-11-171-0/+16
| | | | Reviewed-by: Topi Pohjolainen <[email protected]>
* util/vk_alloc: Ensure NULL is handled correctly in vk_freeJason Ekstrand2016-11-161-0/+3
| | | | Reviewed-by: Dave Airlie <[email protected]>
* util: Fix Clang trivial destructor check.Vinson Lee2016-11-151-4/+4
| | | | | | | | | | | | | | | Check for Clang before GCC. Clang defines __GNUC__ == 4 and __GNUC_MINOR__ == 2 and matches the GCC check but not the GCC version for trivial destructor. Fixes: 98ab905af0e0 ("mesa: Define introspection macro to determine whether a type is trivially destructible.") Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98526 Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Edward O'Callaghan <[email protected]> Reviewed-by: Francisco Jerez <[email protected]>
* util/disk_cache: use unambiguous namingMarek Olšák2016-11-152-42/+44
| | | | Reviewed-by: Emil Velikov <[email protected]>
* util: import cache.c/h from glslMarek Olšák2016-11-153-0/+890
| | | | | | | | | | It's not dependent on GLSL and it can be useful for shader caches that don't deal with GLSL. v2: address review comments v3: keep the other 3 lines in configure.ac Reviewed-by: Emil Velikov <[email protected]>
* util: use STATIC_ASSERT instead of static_assertTapani Pälli2016-11-111-1/+1
| | | | | | | | | | | fixes following compilation warnings on Android build: "warning: implicit declaration of function 'static_assert' is invalid in C99 [-Wimplicit-function-declaration]" Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* util: add MSVC HAS_TRIVIAL_DESTRUCTOR implementationBrian Paul2016-11-091-0/+5
| | | | | | | | | | | | Based on a patch by George Kyriazis but changed to test for _MSC_VER >= 1800 (Visual Studio 2015). This fixes the failed CANARY assertion in src/util/ralloc.c:get_header() on Windows. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98595 Tested-by: Brian Paul <[email protected]> Signed-off-by: Brian Paul <[email protected]>
* ralloc: add a linear allocator as a child node of rallocMarek Olšák2016-10-312-4/+433
| | | | | | | v2: remove goto, cosmetic changes Tested-by: Edmondo Tommasina <[email protected]> (v1) Reviewed-by: Nicolai Hähnle <[email protected]>
* ralloc: remove memset from ralloc_sizeMarek Olšák2016-10-311-15/+11
| | | | | | | only do it in rzalloc_size as it was supposed to be Reviewed-by: Edward O'Callaghan <[email protected]> Tested-by: Edmondo Tommasina <[email protected]>
* ralloc: add DECLARE_RZALLOC_CXX_OPERATORSMarek Olšák2016-10-311-2/+7
| | | | | | | Reviewed-by: Edward O'Callaghan <[email protected]> Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* ralloc: don't memset ralloc_header, clear it manuallyMarek Olšák2016-10-311-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | time GALLIUM_NOOP=1 ./run shaders/private/alien_isolation/ >/dev/null Before (2 takes): real 0m8.734s 0m8.773s user 0m34.232s 0m34.348s sys 0m0.084s 0m0.056s After (2 takes): real 0m8.448s 0m8.463s user 0m33.104s 0m33.160s sys 0m0.088s 0m0.076s Average change in "real" time spent: -3.4% calloc should only do 2 things compared to malloc: - check for overflow of "n * size" - call memset I'm not sure if that explains the difference. v2: clear "parent" and "next" in the caller of add_child. Reviewed-by: Edward O'Callaghan <[email protected]> (v1) Tested-by: Edmondo Tommasina <[email protected]> (v1) Reviewed-by: Nicolai Hähnle <[email protected]> (v1)
* util: Include string.h in bitscan.h.Vinson Lee2016-10-201-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Fix build error with clang. Compiling src/compiler/glsl/link_varyings.cpp ... In file included from src/compiler/glsl/link_varyings.cpp:33: In file included from src/compiler/glsl/glsl_symbol_table.h:34: In file included from src/compiler/glsl/ir.h:33: In file included from src/compiler/glsl_types.h:29: /usr/include/string.h:518:12: error: exception specification in declaration does not match previous declaration extern int ffs (int __i) __THROW __attribute__ ((__const__)); ^ src/util/bitscan.h:51:13: note: expanded from macro 'ffs' ^ src/util/bitscan.h:96:18: note: previous declaration is here const int i = ffs(*mask) - 1; ^ src/util/bitscan.h:51:13: note: expanded from macro 'ffs' ^ Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97952 Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* vulkan: add vk_alloc.h shared allocation inlines.Dave Airlie2016-10-192-1/+77
| | | | | | | | vulkan allocation allows for overriding the allocator used, add some macros for anv/radv to share for this. Acked-by: Jason Ekstrand <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* util: move min/max/clamp macros to util macros.hDave Airlie2016-10-191-0/+13
| | | | | | | | | Although the vulkan drivers include mesa macros.h, for radv I'd like to move away from that. Reviewed-by: Nicolai Hähnle <[email protected]> Acked-by: Jason Ekstrand <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* util: add vector util code.Dave Airlie2016-10-193-1/+193
| | | | | | | | This is ported from anv, both anv and radv can share this. Reviewed-by: Nicolai Hähnle <[email protected]> Acked-by: Jason Ekstrand <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* util: remove unused variableTimothy Arceri2016-10-071-4/+2
| | | | | | Also initialise page at declaration. Reviewed-by: Nicolai Hähnle <[email protected]>
* util/slab: re-design to allow migration between pools (v3)Nicolai Hähnle2016-10-052-89/+258
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is basically a re-write of the slab allocator into a design where multiple child pools are linked to a parent pool. The intention is that every (GL, pipe) context has its own child pool, while the corresponding parent pool is held by the winsys or screen, or possibly the GL share group. The fast path is still used when objects are freed by the same child pool that allocated them. However, it is now also possible to free an object in a different pool, as long as they belong to the same parent. Objects also survive the destruction of the (child) pool from which they were allocated. The slow path will return freed objects to the child pool from which they were originally allocated. If that child pool was destroyed, the corresponding page is considered an orphan and will be freed once all objects in it have been freed. This allocation pattern is required for pipe_transfers that correspond to (GL) buffer object mappings when the mapping is created in one context which is later destroyed while other contexts of the same share group live on -- see the bug report referenced below. Note that individual drivers do need to migrate to the new interface in order to benefit and fix the bug. v2: use singly-linked lists everywhere v3: use p_atomic_set for page->u.num_remaining Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97894