summaryrefslogtreecommitdiffstats
path: root/src/util
Commit message (Collapse)AuthorAgeFilesLines
* 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]>
* util: Also include endian.h on cygwinJon Turney2017-11-291-1/+1
| | | | | | | | If u_endian.h can't determine the endianess, the default behaviour in sha1.c is to build for big-endian Signed-off-by: Jon Turney <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* util: add mesa-sha1 test to mesonEric Engestrom2017-11-281-0/+9
| | | | | | Fixes: 513d7ffa23d42e96f831 "util: Add a SHA1 unit test program" Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* util: Just give up and define PIPE_ARCH_LITTLE_ENDIAN on MSVCMatt Turner2017-11-251-2/+3
| | | | MSVC doesn't support #warning?! Getting really tired of this.
* util: Use preprocessor correctlyMatt Turner2017-11-251-1/+1
| | | | | Fixes: 6a353479a757 ("util: Assume little endian in the absence of platform-specific handling")
* util: Fix disk_cache index calculation on big endianMatt Turner2017-11-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The cache-test test program attempts to create a collision (using key_a and key_a_collide) by making the first two bytes identical. The idea is fine -- the shader cache wants to use the first four characters of a SHA1 hex digest as the index. The following program unsigned char array[4] = {1, 2, 3, 4}; int *ptr = (int *)array; for (int i = 0; i < 4; i++) { printf("%02x", array[i]); } printf("\n"); printf("%08x\n", *ptr); prints 01020304 04030201 on little endian, and 01020304 01020304 on big endian. On big endian platforms reading the character array back as an int (as is done in disk_cache.c) does not yield the same results as reading the byte array. To get the first four characters of the SHA1 hex digest when we mask with CACHE_INDEX_KEY_MASK, we need to byte swap the int on big endian platforms. Bugzilla: https://bugs.freedesktop.org/103668 Bugzilla: https://bugs.gentoo.org/637060 Bugzilla: https://bugs.gentoo.org/636326 Fixes: 87ab26b2ab35 ("glsl: Add initial functions to implement an on-disk cache") Reviewed-by: Emil Velikov <[email protected]>
* util: Add a SHA1 unit test programMatt Turner2017-11-252-1/+67
| | | | Reviewed-by: Emil Velikov <[email protected]>
* util: Fix SHA1 implementation on big endianMatt Turner2017-11-251-1/+2
| | | | | | | | | | | The code defines a macro blk0(i) based on the preprocessor condition BYTE_ORDER == LITTLE_ENDIAN. If true, blk0(i) is defined as a byte swap operation. Unfortunately, if the preprocessor macros used in the test are no defined, then the comparison becomes 0 == 0 and it evaluates as true. Fixes: d1efa09d342b ("util: import sha1 implementation from OpenBSD") Reviewed-by: Emil Velikov <[email protected]>
* util: Assume little endian in the absence of platform-specific handlingMatt Turner2017-11-251-0/+3
|
* util/u_queue: really use futex-based fencesNicolai Hähnle2017-11-201-1/+1
| | | | | | | The relevant define changed in the final revision of the simple mutex patch. Reviewed-by: Marek Olšák <[email protected]>
* util/u_queue: fix timeout handling in util_queue_fence_wait_timeoutNicolai Hähnle2017-11-201-1/+1
| | | | | Fixes: e3a8013de8ca ("util/u_queue: add util_queue_fence_wait_timeout") Reviewed-by: Marek Olšák <[email protected]>
* src/util/simple_mtx.h: Fix two -Wunused-param warnings.Gert Wollny2017-11-171-2/+2
| | | | | | | | | | Decorate the parameters accordingly with "UNUSED" or "MAYBE_UNUSED" (for the param that is used in debug mode, but not in release mode). v2: move UNUSED decoration in front of parameter declaration Signed-off-by: Gert Wollny <[email protected]> Reviewed-by: Brian Paul <[email protected]> (v1)
* util: add new ASSERT_BITFIELD_SIZE() macro (v3)Brian Paul2017-11-161-0/+17
| | | | | | | | | | For checking that bitfields are large enough to hold the largest expected value. v2: move into existing util/macros.h header where STATIC_ASSERT() lives. v3: add MAYBE_UNUSED to variable declaration Reviewed-by: Ian Romanick <[email protected]>
* util: include unistd.h, which may be required for usleep prototypeJon Turney2017-11-101-0/+1
| | | | | | | | | | This seems to be dropped in 222a2fb9 "util: move os_time.[ch] to src/util" ../../../src/util/os_time.c: In function ‘os_time_sleep’: ../../../src/util/os_time.c:104:4: error: implicit declaration of function ‘usleep’ [-Werror=implicit-function-declaration] Signed-off-by: Jon Turney <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* util/u_thread: fix compilation on Mac OSNicolai Hähnle2017-11-101-1/+1
| | | | | | | | | | | | Apparently, it doesn't have pthread barriers. p_config.h (which was originally used to guard this code) uses the __APPLE__ macro to detect Mac OS. Fixes: f0d3a4de75 ("util: move pipe_barrier into src/util and rename to util_barrier") Cc: Roland Scheidegger <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* util/u_queue: handle OS_TIMEOUT_INFINITE in util_queue_fence_wait_timeoutNicolai Hähnle2017-11-101-0/+6
| | | | | | | Fixes e.g. piglit/bin/bufferstorage-persistent read -auto Fixes: e6dbc804a87a ("winsys/amdgpu: handle cs_add_fence_dependency for deferred/unsubmitted fences") Reviewed-by: Marek Olšák <[email protected]>
* util/u_queue: add util_queue_fence_wait_timeoutNicolai Hähnle2017-11-094-26/+121
| | | | | | | | v2: - style fixes - fix missing timeout handling in futex path Reviewed-by: Marek Olšák <[email protected]>
* util: move os_time.[ch] to src/utilNicolai Hähnle2017-11-094-0/+325
| | | | Reviewed-by: Marek Olšák <[email protected]>
* u_queue: add util_queue_finish for waiting for previously added jobsNicolai Hähnle2017-11-092-0/+37
| | | | | | | | | Schedule one job for every thread, and wait on a barrier inside the job execution function. v2: avoid alloca (fixes Windows build error) Reviewed-by: Marek Olšák <[email protected]> (v1)
* util: move pipe_barrier into src/util and rename to util_barrierNicolai Hähnle2017-11-091-0/+74
| | | | | | | | | The #if guard is probably not 100% equivalent to the previous PIPE_OS check, but if anything it should be an over-approximation (are there pthread implementations without barriers?), so people will get either a good implementation or compile errors that are easy to fix. Reviewed-by: Marek Olšák <[email protected]>
* u_queue: add a futex-based implementation of fencesNicolai Hähnle2017-11-092-0/+94
| | | | | | | | | | | | | | | | | Fences are now 4 bytes instead of 96 bytes (on my 64-bit system). Signaling a fence is a single atomic operation in the fast case plus a syscall in the slow case. Testing if a fence is signaled is the same as before (a simple comparison), but waiting on a fence is now no more expensive than just testing it in the fast (already signaled) case. v2: - style fixes - use p_atomic_xxx macros with the right barriers Acked-by: Marek Olšák <[email protected]>
* u_queue: add util_queue_fence_resetNicolai Hähnle2017-11-092-3/+14
| | | | Reviewed-by: Marek Olšák <[email protected]>
* u_queue: export util_queue_fence_signalNicolai Hähnle2017-11-092-1/+2
| | | | Reviewed-by: Marek Olšák <[email protected]>
* u_queue: group fence functions togetherNicolai Hähnle2017-11-091-9/+10
| | | | Reviewed-by: Marek Olšák <[email protected]>
* util/u_atomic: add p_atomic_xchgNicolai Hähnle2017-11-091-1/+31
| | | | | | | | | The closest to it in the old-style gcc builtins is __sync_lock_test_and_set, however, that is only guaranteed to work with values 0 and 1 and only provides an acquire barrier. I also don't know about other OSes, so we provide a simple & stupid emulation via p_atomic_cmpxchg. Reviewed-by: Marek Olšák <[email protected]>
* util: move futex helpers into futex.hNicolai Hähnle2017-11-094-21/+57
| | | | | | 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-093-0/+157
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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]>
* disk_cache: Fix issue reading GLSL metadataJordan Justen2017-10-311-1/+1
| | | | | | | | | | | | | | This would cause the read of the metadata content to fail, which would prevent the linking from being skipped. Seen on Rocket League with i965 shader cache. Fixes: b86ecea3446e "util/disk_cache: write cache item metadata to disk" Cc: Timothy Arceri <[email protected]> Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* util: hashtable: make hashing prototypes matchLionel Landwerlin2017-10-302-2/+3
| | | | | | | | | It seems nobody's using the string hashing function. If you try to pass it directly to the hashtable creation function, you'll get compiler warning for non matching prototypes. Let's make them match. Signed-off-by: Lionel Landwerlin <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* radeonsi: update hack for HTILE corruption in ARK: Survival EvolvedSamuel Pitoiset2017-10-272-4/+4
| | | | | | | | | | | | It appears that flushing the DB metadata is actually not sufficient since the driver uses the new VS blit shaders. This looks quite strange though, but it seems like we need to flush DB for fixing the corruption. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102955 Fixes: 69ccb9dae7 (radeonsi: use new VS blit shaders (VS inputs in SGPRs) Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
* 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]>