summaryrefslogtreecommitdiffstats
path: root/src/util
Commit message (Collapse)AuthorAgeFilesLines
* util: fix MSVC warning in u_align_u32()Brian Paul2017-04-031-1/+1
| | | | | | | | | To silence C:\Users\Brian\projects\mesa\src\util/u_vector.h(41) : warning C4146: unary minus operator applied to unsigned type, result still unsigned Reviewed-by: Jose Fonseca <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* util: #include "c99_compat.h" to fix Windows buildBrian Paul2017-04-032-0/+2
| | | | | | | | Otherwise, we were getting the definition for 'inline' by chance from some other preceeding #include. Reviewed-by: Jose Fonseca <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* util: s/SHA1_H/MESA_SHA1_H/Brian Paul2017-04-031-2/+2
| | | | | | | To follow the convention of other header include guards. Reviewed-by: Jose Fonseca <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* util/u_atomic: provide 64bit atomics where they're missingGrazvydas Ignotas2017-04-032-0/+76
| | | | | | | | | | | | | | | | There are still some distributions trying to support unfortunate people with old or exotic CPUs that don't have 64bit atomic operations. When compiling for such a machine, gcc conveniently inserts a library call to a helper, but it's implementation is missing and we get a linker error. This allows us to provide our own implementation, which is marked weak to prefer a better implementation, should one exist. v2: changed copyright, some style adjustments v3: [mattst88] Print results with AC_MSG_CHECKING/AC_MSG_RESULT Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93089 Signed-off-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* util/disk_cache: don't deadlock on premature EOFGrazvydas Ignotas2017-03-251-17/+26
| | | | | | | | | | | | | | If we get EOF earlier than expected, the current read loops will deadlock. This may easily happen if the disk cache gets corrupted. Fix it by using a helper function that handles EOF. Steps to reproduce (on a build with asserts disabled): $ glxgears $ find ~/.cache/mesa/ -type f -exec truncate -s 0 '{}' \; $ glxgears # deadlock Signed-off-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* util/disk_cache: write cache entry keys to file headerTimothy Arceri2017-03-241-6/+44
| | | | | | | | | | | | This can be used to deal with key hash collisions from different versions (should we find that to actually happen) and to find which mesa version produced the cache entry. V2: use blob created at cache creation. v3: remove left over var from v1. Reviewed-by: Grazvydas Ignotas <[email protected]>
* util/disk_cache: hash pointer size and gpu name into cache keysGrazvydas Ignotas2017-03-242-43/+15
| | | | | | | | | | | | | | | | This allows to get rid of the arch and gpu name directories. v2: (Timothy Arceri) don't use an opaque data type to store pointer size and gpu name. v3: (Timothy Arceri) use blob to store driver keys just make sure to store null terminator for strings, and make sure blob is defined by disk_cache and not it's users. v4: (Timothy Arceri) fix typo, and make ptr_size a uint8_t. Signed-off-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* util/disk_cache: hash timestamps into the cache keysGrazvydas Ignotas2017-03-241-51/+26
| | | | | | | | | | | | | | | | | | | | | | | | Instead of using a directory, hash the timestamps into the cache keys themselves. Since there is no more timestamp directory, there is no more need for deleting the cache of other mesa versions and we rely on eviction to clean up the old cache entries. This solves the problem of using several incarnations of disk_cache at the same time, where one deletes a directory belonging to the other, like when both OpenGL and gallium nine are used simultaneously (or several different mesa installations). v2: using additional blob instead of trying to clone sha1 state v3: (Timothy Arceri) don't use an opaque data type to store timestamp. V4: (Timothy Arceri) use blob to store driver keys just make sure to store null terminator for strings, and make sure blob is defined by disk_cache and not it's users. Signed-off-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100091
* util/disk_cache: use rand_xorshift128plus() to get our random intTimothy Arceri2017-03-231-8/+10
| | | | | | | | | | | Otherwise for apps that don't seed the regular rand() we will always remove old cache entries from the same dirs. V2: assume bits returned by rand are independent uniformly distributed bits and grab our hex value without taking the modulus of the whole value, this also fixes a bug where 'f' was always missing. Reviewed-by: Nicolai Hähnle <[email protected]>
* util/rand_xor: add function to seed randTimothy Arceri2017-03-232-0/+69
| | | | | | | | V2: pass the seed to the seed function so that we can isolate its uses. Stop leaking fd when urandom couldn't be read. Reviewed-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* util: move rand_xorshift128plus() to utilsTimothy Arceri2017-03-233-0/+55
| | | | | | | | V2: pass the seed to rand_xorshift128plus() so that we can isolate its uses. Reviewed-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* Android: remove host libmesa_utilRob Herring2017-03-221-35/+0
| | | | | | | | The host libmesa_util is never used for Android builds, so remove it. Signed-off-by: Rob Herring <[email protected]> Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* util: automake: beautify sources listEmil Velikov2017-03-221-3/+3
| | | | | | | | | Remove trailing tabs and sort alphabetically. Signed-off-by: Emil Velikov <[email protected]> Acked-by: Vedran Miletić <[email protected]> Acked-by: Juha-Pekka Heikkila <[email protected]> Reviewed-by: Edward O'Callaghan <[email protected]>
* util/strndup: move header inclusion as applicableEmil Velikov2017-03-221-2/+1
| | | | | | | Signed-off-by: Emil Velikov <[email protected]> Acked-by: Vedran Miletić <[email protected]> Acked-by: Juha-Pekka Heikkila <[email protected]> Reviewed-by: Edward O'Callaghan <[email protected]>
* util: inline strndup implementation in the headerEmil Velikov2017-03-223-50/+20
| | | | | | | Signed-off-by: Emil Velikov <[email protected]> Acked-by: Vedran Miletić <[email protected]> Acked-by: Juha-Pekka Heikkila <[email protected]> Reviewed-by: Edward O'Callaghan <[email protected]>
* util: consistently use ifndef guards over pragma onceEmil Velikov2017-03-224-2/+19
| | | | | | | Signed-off-by: Emil Velikov <[email protected]> Acked-by: Vedran Miletić <[email protected]> Acked-by: Juha-Pekka Heikkila <[email protected]> Reviewed-by: Edward O'Callaghan <[email protected]>
* util/sha1: harmonize _mesa_sha1_* wrappersGrazvydas Ignotas2017-03-222-9/+10
| | | | | | | | | | Rather than using 3 different ways to wrap _mesa_sha1_*() to SHA1*() functions (a macro, prototype with implementation in .c and an inline function), make all 3 inline functions. Signed-off-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* util/disk_cache: fix build on platforms where shader cache is disabledTimothy Arceri2017-03-211-1/+1
|
* util/disk_cache: add a write helperGrazvydas Ignotas2017-03-211-14/+23
| | | | | | | | | | | | | Simplifies the write code a bit and handles EINTR. V2: (Timothy Arceri) Drop EINTR handling. To do it properly we would need a retry limit but it's probably best to just avoid trying to write if we hit EINTR and try again next time we see the program. Signed-off-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* util/disk_cache: use a helper to compute cache keysGrazvydas Ignotas2017-03-212-0/+21
| | | | | | | | | | This will allow to hash additional data into the cache keys or even change the hashing algorithm easily, should we decide to do so. v2: don't try to compute key (and crash) if cache is disabled Signed-off-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* util/disk_cache: check rename resultGrazvydas Ignotas2017-03-201-2/+6
| | | | | | | | | I haven't seen this causing problems in practice, but for correctness we should also check if rename succeeded to avoid breaking accounting and leaving a .tmp file behind. Signed-off-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* util/disk_cache: delete .tmp if target existsGrazvydas Ignotas2017-03-201-1/+3
| | | | | | | | | | | At the time of target file check, .tmp file is already created and file lock is held, so we should remove the .tmp, like in other error paths. With this, piglit no longer leaves large amount of empty .tmp files behind, which waste directory entries and may interfere with eviction. Signed-off-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* util/disk_cache: fix stored_keys indexGrazvydas Ignotas2017-03-201-2/+2
| | | | | | | | | | | | | | It seems there is a bug because: - 20 bytes are compared, but only 1 byte stored_keys step is used - entries can overlap each other by 19 bytes - index_mmap is ~1.3M in size, but only first 64K is used With this fix for Deus Ex: - startup time (from launch to Feral logo): ~38s -> ~16s - disk_cache_has_key() hit rate: ~50% -> ~96% Signed-off-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* util/disk_cache: pass predicate functions file stats directly (v4)Alan Swanson2017-03-181-34/+21
| | | | | | | | | | | | | | | Since switching to LRU eviction the only user of these predicate functions now resolves directory entry stats itself so pass them directly saving calling fstat and strlen twice (and the expensive strlen is skipped entirely if access time is newer). v2: Update for empty cache dir detection changes v3: Fix passing string length to predicate with the +1 for NULL termination and also pass sb as pointer v4: Missed ampersand for passing sb as pointer Reviewed-by: Grazvydas Ignotas <[email protected]> Acked-by: Timothy Arceri <[email protected]>
* util/build-id: check dlpi_name before strstr callTapani Pälli2017-03-171-0/+6
| | | | | | | | | | | | According to dl_iterate_phdr man page first object visited is the main program where dlpi_name is an empty string. This fixes segfault on Android when using build-id as identifier. Fixes: d4fa083e11f ("util: Add utility build-id code.") Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Plamena Manolova <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* util/disk_cache: do eviction before creating .tmpGrazvydas Ignotas2017-03-161-10/+8
| | | | | | | | | | | | | | cache_put() first creates a .tmp file and then tries to do eviction. The recently added LRU eviction code selects non-empty directory with the oldest access time, but that may easily be the one with just the new .tmp file, especially on Linux where atime is updated lazily (with "relatime" mount option, which is the default). So when cache is small, if random doesn't hit another dir LRU keeps selecting the same dir with just the .tmp and not deleting anything. To fix this (and the tests), do eviction earlier. Signed-off-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* util/sha1: drop _mesa_sha1_{update, format} return typeEmil Velikov2017-03-152-7/+4
| | | | | | | | | Unused/unchecked by any of the callers. v2: Fix the glsl cases that have crept in since v1 Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Grazvydas Ignotas <[email protected]>
* util/sha1: rework _mesa_sha1_{init,final}Emil Velikov2017-03-152-34/+13
| | | | | | | | | | | | Rather than having an extra memory allocation [that we currently do not and act accordingly] just make the API take an pointer to a stack allocated instance. This and follow-up steps will effectively make the _mesa_sha1_foo simple define/inlines around their SHA1 counterparts. Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Grazvydas Ignotas <[email protected]>
* util/sha1: add non-typedef name for the SHA1_CTX structEmil Velikov2017-03-152-1/+4
| | | | | | | | | | Using typedef(s) is not always the answer and makes it harder for people to do clever (or one might call nasty) things with the code. Add a struct name which we will use with follow-up commit. Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Grazvydas Ignotas <[email protected]>
* util/disk_cache: scale cache according to filesystem sizeAlan Swanson2017-03-151-3/+8
| | | | | | | | Select higher of current 1G default or 10% of filesystem where cache is located. Acked-by: Timothy Arceri <[email protected]> Reviewed-by: Grazvydas Ignotas <[email protected]>
* util/disk_cache: actually enforce cache sizeAlan Swanson2017-03-151-1/+5
| | | | | | | | | | Currently only a one in one out eviction so if at max_size and cache files were to constantly increase in size then so would the cache. Restrict to limit of 8 evictions per new cache entry. V2: (Timothy Arceri) fix make check tests Reviewed-by: Grazvydas Ignotas <[email protected]>
* util/disk_cache: use LRU eviction rather than random evictionAlan Swanson2017-03-151-43/+34
| | | | | | | | | | | Still using fast random selection of two-character subdirectory in which to check cache files rather than scanning entire cache. v2: Factor out double strlen call v3: C99 declaration of variables where used Reviewed-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* util/disk_cache: don't fallback to an empty cache dir on evictTimothy Arceri2017-03-151-6/+27
| | | | | | | | | | If we fail to randomly select a two letter cache dir, don't select an empty dir on fallback. In real world use we should never hit the fallback path but it can be hit by tests when the cache is set to a very small max value. Reviewed-by: Grazvydas Ignotas <[email protected]>
* util/disk_cache: use a thread queue to write to shader cacheTimothy Arceri2017-03-151-13/+28
| | | | | | | | | | | | | | This should help reduce any overhead added by the shader cache when programs are not found in the cache. To avoid creating any special function just for the sake of the tests we add a one second delay whenever we call dick_cache_put() to give it time to finish. V2: poll for file when waiting for thread in test V3: fix poll delay to really be 100ms, and simplify the wait function Reviewed-by: Grazvydas Ignotas <[email protected]>
* util/disk_cache: add helpers for creating/destroying disk cache put jobsTimothy Arceri2017-03-151-0/+40
| | | | | | | V2: Make a copy of the data so we don't have to worry about it being freed before we are done compressing/writing. Reviewed-by: Grazvydas Ignotas <[email protected]>
* util/disk_cache: add thread queue to disk cacheTimothy Arceri2017-03-151-1/+15
| | | | | Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Grazvydas Ignotas <[email protected]>
* util/vk: Add helpers for finding an extension structJason Ekstrand2017-03-151-0/+17
| | | | Reviewed-by: Dave Airlie <[email protected]>
* util/vulkan: Add vk_outarray (v2)Chad Versace2017-03-131-0/+140
| | | | | | | | | | | This is a wrapper for a Vulkan output array. A Vulkan output array is one that follows the convention of the parameters to vkGetPhysicalDeviceQueueFamilyProperties(). v2: Replace vk_outarray_is_incomplete() with vk_outarray_status(). For Jason. Reviewed-by: Jason Ekstrand <[email protected]>
* util/u_thread.h: Include stdint.h for int64_t definition.Jose Fonseca2017-03-131-0/+2
| | | | Fixes MinGW build. Trivial.
* util/bitscan: use correct signature for ffs/ffsllEmil Velikov2017-03-132-6/+6
| | | | | | | | | | | | | Otherwise we'll get errors such as error: conflicting types for ‘ffs’ error: conflicting types for ‘ffsll’ We might want to improve the heuristics and provide a definition only when a native one is missing. We can address that at a later stage. Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* util/u_queue: make u_queue accessible to cppTimothy Arceri2017-03-131-0/+8
| | | | Reviewed-by: Marek Olšák <[email protected]>
* gallium/util: move u_queue.{c,h} to src/utilTimothy Arceri2017-03-123-0/+442
| | | | | | | This will allow us to use it outside of gallium for things like compressing shader cache entries. Reviewed-by: Marek Olšák <[email protected]>
* util: add u_thread.hTimothy Arceri2017-03-122-0/+90
| | | | | | | This is a minimal copy of os_thread.h from gallium in order to move u_queue.{c,h} to this directory. Reviewed-by: Marek Olšák <[email protected]>
* gallium/util: move u_string.h to src/util/u_string.hTimothy Arceri2017-03-122-0/+205
| | | | | | | | This will help us move u_queue.c here eventually and also provide string function wrappers for anyone wishing to port disk_cache.c to windows. Reviewed-by: Marek Olšák <[email protected]>
* util: remove shebang from format_srgb.pyEmil Velikov2017-03-101-1/+0
| | | | | | | Analogous to earlier commit(s). Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* util/disk_cache: fix size subtraction on 32bitGrazvydas Ignotas2017-03-091-3/+3
| | | | | | | | | | Negating size_t on 32bit produces a 32bit result. This was effectively adding values close to UINT_MAX to the cache size (the files are usually small) instead of intended subtraction. Fixes 'make check' disk_cache failures on 32bit. Signed-off-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* util/disk_cache: fix compressed size calculationGrazvydas Ignotas2017-03-091-1/+1
| | | | | | | | | It incorrectly doubles the size on each iteration. Fixes: 85a9b1b5 "util/disk_cache: compress individual cache entries" Signed-off-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* ralloc: don't leave out the alignment factorGrazvydas Ignotas2017-03-061-1/+3
| | | | | | | | | | | | | | | Experimentation shows that without alignment factor gcc and clang choose a factor of 16 even on IA-32, which doesn't match what malloc() uses (8). The problem is it makes gcc assume the pointer is 16 byte aligned, so with -O3 it starts using aligned SSE instructions that later fault, so always specify a suitable alignment factor. Cc: Jonas Pfeil <[email protected]> Fixes: cd2b55e5 "ralloc: Make sure ralloc() allocations match malloc()'s alignment." Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100049 Signed-off-by: Grazvydas Ignotas <[email protected]> Tested by: Mike Lothian <[email protected]> Tested by: Jonas Pfeil <[email protected]>
* util/disk_cache: fix make checkTimothy Arceri2017-03-062-17/+18
| | | | | Fixes make check after 11f0efec2e615f5233d which caused disk cache to create an additional directory.
* Revert "glsl: Switch to disable-by-default for the GLSL shader cache"Timothy Arceri2017-03-061-7/+0
| | | | | | | | | This reverts commit 0f60c6616e93cba72bff4fbfedb72a753ef78e05. Piglit and all games tested so far seem to be working without issue. This change will allow wide user testing and we can decided before the next release if we need to turn it off again. Reviewed-by: Marek Olšák <[email protected]>