summaryrefslogtreecommitdiffstats
path: root/src/util/Makefile.sources
Commit message (Collapse)AuthorAgeFilesLines
* util: promote u_memory to src/utilDylan Baker2018-11-271-0/+5
| | | | | as well as os_memory* Reviewed-by: Rob Clark <[email protected]>
* util: move u_cpu_detect to utilDylan Baker2018-10-301-0/+2
| | | | | | | | | CC: [email protected] Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107870 Fixes: 80825abb5d1a7491035880253ffd531c55acae6b ("move u_math to src/util") Tested-by: Brian Paul <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
* util: Move u_debug to utilsDylan Baker2018-10-301-0/+2
| | | | | Tested-by: Brian Paul <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
* util: Move os_misc to utilDylan Baker2018-10-301-0/+2
| | | | | | | this is needed by u_debug Tested-by: Brian Paul <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
* util: import public domain code for integer division by a constantMarek Olšák2018-10-101-0/+2
| | | | | | | | | | | | | Compilers can use this to generate optimal code for integer division by a constant. Additionally, an unsigned division by a uniform that is constant but not known at compile time can still be optimized by passing 2-4 division factors to the shader as uniforms and executing one of the fast_udiv* variants. The signed division algorithm doesn't have this capability. Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
* util: Add a simple big math libraryJason Ekstrand2018-10-101-0/+1
| | | | Reviewed-by: Ian Romanick <[email protected]>
* move u_math to src/utilDylan Baker2018-09-071-0/+2
| | | | | | | | | | | | | | | Currently we have two sets of functions for bit counts, one in gallium and one in core mesa. The ones in core mesa are header only in many cases, since they reduce to "#define _mesa_bitcount popcount", but they provide a fallback implementation. This is important because 32bit msvc doesn't have popcountll, just popcount; so when nir (for example) includes the core mesa header it doesn't (and shouldn't) link with core mesa. To fix this we'll promote the version out of gallium util, then replace the core mesa uses with the util version, since nir (and other non-core mesa users) can and do link with mesautils. Acked-by: Eric Engestrom <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* util: move process.[ch] to u_process.[ch]Dylan Baker2018-08-011-2/+2
| | | | | | | | | | | | | 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: 2e1e6511f76370870b5cde10caa9ca3b6d0dc65f ("util: extract get_process_name from xmlconfig.c") Signed-off-by: Dylan Baker <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
* util: rb-tree: A simple, invasive, red-black treeJason Ekstrand2018-07-051-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | This is a simple, invasive, liberally licensed red-black tree implementation. It's an invasive data structure similar to the Linux kernel linked-list where the intention is that you embed a rb_node struct the data structure you intend to put into the tree. The implementation is mostly based on the one in "Introduction to Algorithms", third edition, by Cormen, Leiserson, Rivest, and Stein. There were a few other key design points: * It's an invasive data structure similar to the [Linux kernel linked list]. * It uses NULL for leaves instead of a sentinel. This means a few algorithms differ a small bit from the ones in "Introduction to Algorithms". * All search operations are inlined so that the compiler can optimize away the function pointer call. Reviewed-by: Lionel Landwerlin <[email protected]>
* util: extract get_process_name from xmlconfig.cMarek Olšák2018-07-041-0/+2
| | | | | Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* util: Add a virtual memory allocatorJason Ekstrand2018-05-311-1/+3
| | | | | | | | | | | | | | | | | | | | | | 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: move os_time.[ch] to src/utilNicolai Hähnle2017-11-091-0/+2
| | | | Reviewed-by: Marek Olšák <[email protected]>
* util: move futex helpers into futex.hNicolai Hähnle2017-11-091-0/+1
| | | | | | v2: style fixes Reviewed-by: Marek Olšák <[email protected]> (v1)
* mesa: Add new fast mtx_t mutex type for basic use casesTimothy Arceri2017-11-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While modern pthread mutexes are very fast, they still incur a call to an external DSO and overhead of the generality and features of pthread mutexes. Most mutexes in mesa only needs lock/unlock, and the idea here is that we can inline the atomic operation and make the fast case just two intructions. Mutexes are subtle and finicky to implement, so we carefully copy the implementation from Ulrich Dreppers well-written and well-reviewed paper: "Futexes Are Tricky" http://www.akkadia.org/drepper/futex.pdf We implement "mutex3", which gives us a mutex that has no syscalls on uncontended lock or unlock. Further, the uncontended case boils down to a cmpxchg and an untaken branch and the uncontended unlock is just a locked decr and an untaken branch. We use __builtin_expect() to indicate that contention is unlikely so that gcc will put the contention code out of the main code flow. A fast mutex only supports lock/unlock, can't be recursive or used with condition variables. We keep the pthread mutex implementation around as for the few places where we use condition variables or recursive locking. For platforms or compilers where futex and atomics aren't available, simple_mtx_t falls back to the pthread mutex. The pthread mutex lock/unlock overhead shows up on benchmarks for CPU bound applications. Most CPU bound cases are helped and some of our internal bind_buffer_object heavy benchmarks gain up to 10%. Signed-off-by: Kristian Høgsberg <[email protected]> Signed-off-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* util: Add a string buffer implementationThomas Helland2017-09-261-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: move string_to_uint_map to glslEmil Velikov2017-08-291-2/+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]>
* xmlconfig: move into src/utilNicolai Hähnle2017-07-311-0/+4
| | | | | | | | v2: attempt to fix Android build (Emil) v3: add missing include path Reviewed-by: Marek Olšák <[email protected]> (v1)
* util: Move u_dynarray to src/utilThomas Helland2017-06-071-0/+1
| | | | | | | This will be used as the basis for unification Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* util/vulkan: Move Vulkan utilities to src/vulkan/utilAlex Smith2017-06-061-3/+1
| | | | | | | | | | | | | We have Vulkan utilities in both src/util and src/vulkan/util. The latter seems a more appropriate place for Vulkan-specific things, so move them there. v2: Android build system changes (from Tapani Pälli) Signed-off-by: Alex Smith <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Acked-by: Jason Ekstrand <[email protected]>
* util/u_atomic: provide 64bit atomics where they're missingGrazvydas Ignotas2017-04-031-0/+1
| | | | | | | | | | | | | | | | 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: move rand_xorshift128plus() to utilsTimothy Arceri2017-03-231-0/+2
| | | | | | | | 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]>
* 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: inline strndup implementation in the headerEmil Velikov2017-03-221-1/+0
| | | | | | | 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]>
* gallium/util: move u_queue.{c,h} to src/utilTimothy Arceri2017-03-121-0/+2
| | | | | | | 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-121-0/+1
| | | | | | | 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-121-0/+1
| | | | | | | | 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: Add utility build-id code.Matt Turner2017-02-151-0/+2
| | | | | | | | 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-141-1/+2
| | | | Reviewed-by: Dave Airlie <[email protected]>
* util: import sha1 implementation from OpenBSD17.0-branchpointEmil Velikov2017-01-181-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* util: import CRC32 implementation from galliumMarek Olšák2016-11-221-0/+2
| | | | Reviewed-by: Timothy Arceri <[email protected]>
* util: import cache.c/h from glslMarek Olšák2016-11-151-0/+2
| | | | | | | | | | 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]>
* vulkan: add vk_alloc.h shared allocation inlines.Dave Airlie2016-10-191-1/+2
| | | | | | | | 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: add vector util code.Dave Airlie2016-10-191-1/+3
| | | | | | | | 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]>
* mesa/glsl: Move string_to_uint_map into the util folderThomas Helland2016-09-121-0/+2
| | | | | | | | | | This clears the last bits of the usecases of the hash table located in mesa/program, allowing us to remove it. V2: Rebase on top of changes to Makefile.sources Signed-off-by: Thomas Helland <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* util: import the slab allocator from galliumMarek Olšák2016-09-061-0/+2
| | | | There are also some cosmetic changes.
* gallium/util: move endian detect into a separate fileDave Airlie2016-09-061-1/+2
| | | | | | | | This just ports the simpler endian detection bits, addrlib sharing wants this outside gallium. Acked-by: Marek Olšák <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* util: Move format_r11g11b10f.h to src/utilJason Ekstrand2016-08-051-0/+1
| | | | | | | It's used from both mesa main and gallium. Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
* util: Move format_rgb9e5.h to src/utilJason Ekstrand2016-08-051-0/+1
| | | | | | | It's used from both mesa main and gallium. Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
* mesa/gallium: Move u_bit_scan{,64} from gallium to util.Mathias Fröhlich2016-06-141-0/+2
| | | | | | | | | | | | | | | The functions are also useful for mesa. Introduce src/util/bitscan.{h,c}. Move ffs function implementations from src/mesa/main/imports.{h,c}. Move bit scan related functions from src/gallium/auxiliary/util/u_math.h. Merge platform handling with what is available from within mesa. v2: Try to fix MSVC compile. Reviewed-by: Brian Paul <[email protected]> Tested-by: Brian Paul <[email protected]> Signed-off-by: Mathias Fröhlich <[email protected]>
* glsl: move half<->float convertion to utilRob Clark2015-10-161-0/+2
| | | | | | | | Needed in NIR too, so move out of mesa/main/imports.c Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Signed-off-by: Rob Clark <[email protected]>
* util: Move DRI parse_debug_string() to utilKristian Høgsberg Kristensen2015-10-081-0/+2
| | | | | | | | | | We want to use intel_debug.c in code that doesn't link to dri common. v2: Remove unnecessary stddef.h include (Topi), use util/debug.h in all DRI driver and remove driParseDebugString() (Iago). Reviewed-by: Topi Pohjolainen <[email protected]> Signed-off-by: Kristian Høgsberg Kristensen <[email protected]>
* util: implement strndup for WIN32Samuel Iglesias Gonsalvez2015-09-291-0/+2
| | | | | | | | | | | v2: - Add strndup.h to Makefile.sources (Emil) - Use calloc instead of malloc (Emil). - Check if allocation fails (Emil, Jose) - Add '#pragma once' and include stdlib.h to strndup.h (Jose) Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92124 Reviewed-by: Jose Fonseca <[email protected]>
* util: always include sha1 into the buildIlia Mirkin2015-09-061-4/+2
| | | | | | | | | SHA1 is now used in all builds when HAVE_SHA1 is defined. Adjust src to do the same thing, rather than predicating on shader cache. Fixes: 04e201d0c02 ("mesa: change 'SHADER_SUBST' facility to work with env variables") Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
* util: port _mesa_strto[df] to CErik Faye-Lund2015-06-291-1/+1
| | | | | | | | | | | | | _mesa_strtod and _mesa_strtof are only used from the GLSL compiler and the ARB_[vertex|fragment]_program code, meaning that the locale doesn't need to be initialized before the first OpenGL context gets initialized. So let's use explicit initialization from the one-time init code instead of depending on a C++ compiler to initialize at image-load time. Signed-off-by: Erik Faye-Lund <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* util: Move gallium's linked list to utilJason Ekstrand2015-05-081-0/+1
| | | | | | | | | The linked list in gallium is pretty much the kernel list and we would like to have a C-based linked list for all of mesa. Let's not duplicate and just steal the gallium one. Acked-by: Connor Abbott <[email protected]> Reviewed-by: Rob Clark <[email protected]>
* mesa: Replace _mesa_round_to_even() with _mesa_roundeven().Matt Turner2015-03-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Eric's initial patch adding constant expression evaluation for ir_unop_round_even used nearbyint. The open-coded _mesa_round_to_even implementation came about without much explanation after a reviewer asked whether nearbyint depended on the application not modifying the rounding mode. Of course (as Eric commented) we rely on the application not changing the rounding mode from its default (round-to-nearest) in many other places, including the IROUND function used by _mesa_round_to_even! Worse, IROUND() is implemented using the trunc(x + 0.5) trick which fails for x = nextafterf(0.5, 0.0). Still worse, _mesa_round_to_even unexpectedly returns an int. I suspect that could cause problems when rounding large integral values not representable as an int in ir_constant_expression.cpp's ir_unop_round_even evaluation. Its use of _mesa_round_to_even is clearly broken for doubles (as noted during review). The constant expression evaluation code for the packing built-in functions also mistakenly assumed that _mesa_round_to_even returned a float, as can be seen by the cast through a signed integer type to an unsigned (since negative float -> unsigned conversions are undefined). rint() and nearbyint() implement the round-half-to-even behavior we want when the rounding mode is set to the default round-to-nearest. The only difference between them is that nearbyint() raises the inexact exception. This patch implements _mesa_roundeven{f,}, a function similar to the roundeven function added by a yet unimplemented technical specification (ISO/IEC TS 18661-1:2014), with a small difference in behavior -- we don't bother raising the inexact exception, which I don't think we care about anyway. At least recent Intel CPUs can quickly change a subset of the bits in the x87 floating-point control register, but the exception mask bits are not included. rint() does not need to change these bits, but nearbyint() does (twice: save old, set new, and restore old) in order to raise the inexact exception, which would incur some penalty. Reviewed-by: Carl Worth <[email protected]>
* util: Move Mesa's bitset.h to util/.Eric Anholt2015-02-201-0/+1
| | | | Reviewed-by: Jose Fonseca <[email protected]>
* mesa: Move simple_list.h to src/util.Eric Anholt2015-01-281-0/+1
| | | | | | We have two copies of it in the tree, I'm going to delete one. Reviewed-by: Marek Olšák <[email protected]>
* Rename sha1.c and sha1.h to mesa-sha1.c and mesa-sha1.hCarl Worth2015-01-191-2/+2
| | | | | | | | The filename of sha1.h was conflicting with the system-provided sha1.h, (and in some confiurations, our sha1.c was unsuccessfully attemping to include "sha1.h" and <sha1.h> as two different files). Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88523